# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	v2.5.68 -> 1.1189 
#	drivers/video/fbmem.c	1.72    -> 1.74   
#	drivers/i2c/chips/w83781d.c	1.4     -> 1.5    
#	arch/sparc64/kernel/entry.S	1.22    -> 1.24   
#	 drivers/video/vfb.c	1.26    -> 1.27   
#	  arch/sparc/Kconfig	1.11    -> 1.12   
#	drivers/isdn/eicon/eicon_idi.c	1.10    -> 1.11   
#	drivers/hotplug/cpqphp_core.c	1.15    -> 1.16   
#	drivers/net/8139too.c	1.51    -> 1.52   
#	drivers/eisa/eisa.ids	1.1     -> 1.2    
#	net/core/link_watch.c	1.1     -> 1.2    
#	arch/sparc/kernel/wuf.S	1.3     -> 1.4    
#	include/asm-x86_64/irq.h	1.1     -> 1.2    
#	drivers/net/irda/irtty-sir.c	1.3     -> 1.6    
#	arch/sparc/kernel/sun4d_irq.c	1.14    -> 1.15   
#	sound/oss/gus_card.c	1.5     -> 1.6    
#	drivers/scsi/nsp32.h	1.1     -> 1.3    
#	net/bridge/br_device.c	1.5     -> 1.7    
#	drivers/char/ipmi/ipmi_kcs_intf.c	1.6     -> 1.7    
#	net/ipv4/netfilter/ip_conntrack_core.c	1.25    -> 1.26   
#	drivers/char/drm/drm_agpsupport.h	1.17    -> 1.18   
#	drivers/char/drm/drm_context.h	1.11    -> 1.12   
#	  drivers/net/znet.c	1.11    -> 1.12   
#	 drivers/video/tcx.c	1.4     -> 1.5    
#	 drivers/net/3c59x.c	1.33    -> 1.34   
#	drivers/block/ps2esdi.c	1.63    -> 1.65   
#	drivers/i2c/chips/Makefile	1.4     -> 1.5    
#	arch/sparc64/kernel/smp.c	1.53    -> 1.54   
#	drivers/pcmcia/cs_internal.h	1.10    -> 1.12   
#	 include/pcmcia/ds.h	1.8     -> 1.10   
#	drivers/scsi/megaraid.c	1.37    -> 1.43   
#	drivers/acpi/resources/rsio.c	1.13    -> 1.14   
#	drivers/net/eexpress.c	1.12    -> 1.13   
#	arch/alpha/kernel/core_wildfire.c	1.4     -> 1.5    
#	drivers/char/drm/mga.h	1.6     -> 1.7    
#	drivers/i2c/chips/lm75.c	1.13    -> 1.14   
#	net/ipv4/netfilter/arptable_filter.c	1.4     -> 1.5    
#	      fs/cifs/file.c	1.12    -> 1.15   
#	include/linux/acpi.h	1.23    -> 1.24   
#	drivers/input/keyboard/sunkbd.c	1.10    -> 1.11   
#	drivers/net/irda/nsc-ircc.c	1.19    -> 1.20   
#	drivers/char/drm/mga_irq.c	1.2     -> 1.4    
#	drivers/char/drm/gamma.h	1.5     -> 1.7    
#	  sound/oss/ad1848.h	1.3     -> 1.4    
#	drivers/ide/legacy/hd.c	1.19    -> 1.20   
#	drivers/media/video/tda9887.c	1.4     -> 1.5    
#	arch/ppc/syslib/ppc4xx_setup.c	1.11    -> 1.12   
#	drivers/atm/horizon.c	1.9     -> 1.10   
#	drivers/input/keyboard/newtonkbd.c	1.7     -> 1.8    
#	arch/ppc/8260_io/enet.c	1.7     -> 1.8    
#	drivers/net/tc35815.c	1.9     -> 1.10   
#	arch/ppc/platforms/zx4500_setup.c	1.5     -> 1.7    
#	arch/ppc/xmon/xmon.c	1.11    -> 1.12   
#	  drivers/char/esp.c	1.14    -> 1.18   
#	drivers/input/joystick/stinger.c	1.9     -> 1.10   
#	drivers/net/irda/smc-ircc.c	1.16    -> 1.18   
#	include/asm-sparc/floppy.h	1.2     -> 1.3    
#	  sound/oss/cs46xx.c	1.25    -> 1.29   
#	sound/oss/dmasound/dmasound_paula.c	1.7     -> 1.8    
#	    net/llc/af_llc.c	1.34    -> 1.38   
#	  drivers/scsi/ips.c	1.50    -> 1.52   
#	include/asm-alpha/pgalloc.h	1.11    -> 1.12   
#	drivers/char/drm/sis_drv.c	1.4     -> 1.5    
#	 drivers/net/sonic.h	1.4     -> 1.5    
#	arch/arm/nwfpe/double_cpdo.c	1.4     -> 1.9    
#	drivers/scsi/53c7xx.h	1.2     -> 1.3    
#	include/asm-i386/system.h	1.26    -> 1.28   
#	sound/oss/dmasound/dmasound_q40.c	1.9     -> 1.10   
#	drivers/scsi/scsi_error.c	1.46    -> 1.48   
#	include/asm-ppc/processor.h	1.28    -> 1.29   
#	drivers/isdn/hisax/saphir.c	1.27    -> 1.28   
#	net/bluetooth/rfcomm/core.c	1.14    -> 1.17   
#	include/asm-i386/div64.h	1.1     -> 1.2    
#	include/sound/initval.h	1.8     -> 1.9    
#	drivers/base/hotplug.c	1.11    ->         (deleted)      
#	drivers/media/video/bt856.c	1.8     -> 1.9    
#	 drivers/net/3c501.c	1.17    -> 1.18   
#	arch/ppc/4xx_io/serial_sicc.c	1.4     -> 1.9    
#	drivers/acpi/hardware/hwacpi.c	1.15    -> 1.16   
#	drivers/net/irda/toshoboe.c	1.14    -> 1.15   
#	include/asm-arm/arch-sa1100/h3600_gpio.h	1.1     -> 1.2    
#	          fs/libfs.c	1.15    -> 1.17   
#	drivers/ide/ide-taskfile.c	1.14    -> 1.16   
#	arch/arm/mach-sa1100/assabet.c	1.19    -> 1.20   
#	drivers/char/vme_scc.c	1.12    -> 1.16   
#	include/linux/eeprom.h	1.2     -> 1.3    
#	drivers/ieee1394/raw1394.c	1.22    -> 1.23   
#	   drivers/char/lp.c	1.24    -> 1.25   
#	drivers/media/video/saa7134/saa7134-ts.c	1.4     -> 1.5    
#	drivers/scsi/pas16.c	1.8     -> 1.9    
#	      kernel/ksyms.c	1.189   -> 1.195  
#	sound/pci/korg1212/korg1212.c	1.19    -> 1.22   
#	drivers/cdrom/gscd.c	1.32    -> 1.33   
#	include/linux/ioctl32.h	1.2     -> 1.3    
#	drivers/char/n_tty.c	1.13    -> 1.14   
#	drivers/net/e1000/e1000.h	1.28    -> 1.29   
#	     fs/cifs/inode.c	1.7     -> 1.10   
#	drivers/input/joystick/iforce/iforce-serio.c	1.3     -> 1.4    
#	drivers/input/joystick/magellan.c	1.11    -> 1.12   
#	arch/ppc/platforms/pcore_setup.c	1.6     -> 1.7    
#	net/bluetooth/hci_event.c	1.5     -> 1.6    
#	arch/um/kernel/initrd_kern.c	1.2     -> 1.3    
#	arch/ppc/xmon/start.c	1.11    -> 1.12   
#	include/acpi/acpiosxf.h	1.26    -> 1.27   
#	include/linux/cdrom.h	1.12    -> 1.13   
#	drivers/scsi/aic7xxx_old/aic7xxx.h	1.12    -> 1.13   
#	drivers/isdn/hardware/avm/avm_cs.c	1.6     -> 1.7    
#	include/asm-arm/arch-epxa10db/pld_conf00.h	1.1     -> 1.2    
#	lib/percpu_counter.c	1.1     -> 1.2    
#	drivers/i2c/chips/adm1021.c	1.13    -> 1.15   
#	arch/sparc/kernel/setup.c	1.18    -> 1.19   
#	arch/arm/kernel/signal.c	1.22    -> 1.23   
#	drivers/net/wan/z85230.c	1.6     -> 1.7    
#	 sound/ppc/tumbler.c	1.9     -> 1.10   
#	include/asm-arm/arch-sa1100/memory.h	1.5     -> 1.6    
#	arch/arm/nwfpe/entry.S	1.7     -> 1.8    
#	include/asm-sparc/auxio.h	1.1     -> 1.2    
#	include/media/saa7146.h	1.1     -> 1.2    
#	drivers/net/wan/cosa.c	1.19    -> 1.20   
#	drivers/net/tulip/de4x5.c	1.24    -> 1.25   
#	drivers/acpi/hardware/hwgpe.c	1.18    -> 1.19   
#	arch/parisc/kernel/ioctl32.c	1.5     -> 1.8    
#	drivers/acpi/dispatcher/dsobject.c	1.24    -> 1.25   
#	drivers/scsi/pci2220i.c	1.18    -> 1.20   
#	arch/arm/mm/proc-arm920.S	1.17    -> 1.21   
#	include/asm-arm/dma-mapping.h	1.4     -> 1.5    
#	drivers/net/pci-skeleton.c	1.19    -> 1.20   
#	  sound/oss/dmabuf.c	1.4     -> 1.6    
#	include/asm-ia64/pgalloc.h	1.14    -> 1.16   
#	    sound/oss/vidc.h	1.2     -> 1.3    
#	include/asm-arm/proc-armv/system.h	1.9     -> 1.10   
#	drivers/input/serio/serio.c	1.14    -> 1.15   
#	drivers/net/bagetlance.c	1.8     -> 1.9    
#	include/asm-arm/arch-clps711x/memory.h	1.6     -> 1.7    
#	    fs/ntfs/upcase.c	1.6     -> 1.7    
#	drivers/char/Kconfig	1.12    -> 1.13   
#	drivers/usb/class/usb-midi.c	1.14    -> 1.16   
#	include/linux/buffer_head.h	1.40    -> 1.42   
#	 fs/cifs/cifsproto.h	1.8     -> 1.9    
#	drivers/net/irda/vlsi_ir.c	1.15    -> 1.16   
#	drivers/char/isicom.c	1.13    -> 1.17   
#	include/asm-arm/tlb.h	1.6     -> 1.7    
#	drivers/net/hamradio/baycom_ser_hdx.c	1.7     -> 1.8    
#	drivers/usb/net/Makefile	1.6     -> 1.7    
#	arch/arm/nwfpe/Makefile	1.8     -> 1.10   
#	include/asm-arm/cpu-single.h	1.10    -> 1.15   
#	net/sched/sch_generic.c	1.4     -> 1.5    
#	drivers/i2c/i2c-elektor.c	1.15    -> 1.16   
#	net/sctp/associola.c	1.38    -> 1.39   
#	net/irda/irnet/irnet_irda.c	1.16    -> 1.17   
#	 drivers/net/3c509.c	1.35    -> 1.36   
#	fs/xfs/pagebuf/page_buf.c	1.47    -> 1.48   
#	drivers/mtd/devices/blkmtd.c	1.29    -> 1.31   
#	drivers/media/video/saa7185.c	1.10    -> 1.11   
#	arch/alpha/mm/numa.c	1.11    -> 1.12   
#	drivers/input/serio/ct82c710.c	1.5     -> 1.6    
#	drivers/isdn/tpam/tpam_queues.c	1.3     -> 1.4    
#	include/asm-ppc64/pgalloc.h	1.8     -> 1.10   
#	include/linux/timex.h	1.4     -> 1.5    
#	include/asm-i386/processor.h	1.46    -> 1.48   
#	  net/ipv6/exthdrs.c	1.8     -> 1.9    
#	  include/linux/mm.h	1.116   -> 1.117  
#	arch/x86_64/kernel/setup.c	1.12    -> 1.13   
#	arch/sparc/kernel/irq.c	1.22    -> 1.23   
#	drivers/input/serio/parkbd.c	1.4     -> 1.5    
#	sound/sparc/cs4231.c	1.8     -> 1.10   
#	drivers/scsi/aha152x.c	1.27    -> 1.30   
#	net/core/neighbour.c	1.10    -> 1.11   
#	 net/ipv4/ipconfig.c	1.23    -> 1.24   
#	drivers/serial/8250.c	1.32    -> 1.36   
#	drivers/input/joystick/spaceball.c	1.11    -> 1.12   
#	drivers/block/ioctl.c	1.52    -> 1.54   
#	sound/oss/sb_common.c	1.8     -> 1.9    
#	drivers/video/cyberfb.c	1.15    -> 1.16   
#	  net/llc/llc_s_st.c	1.3     -> 1.4    
#	drivers/scsi/hosts.c	1.57    -> 1.58   
#	net/bridge/br_notify.c	1.2     -> 1.3    
#	arch/i386/kernel/apm.c	1.49    -> 1.50   
#	  drivers/net/dgrs.c	1.15    -> 1.16   
#	drivers/net/natsemi.c	1.47    -> 1.48   
#	 include/sound/gus.h	1.3     -> 1.4    
#	         net/Kconfig	1.10    -> 1.11   
#	drivers/net/skfp/skfddi.c	1.10    -> 1.11   
#	drivers/isdn/hisax/ipac.c	1.2     -> 1.3    
#	arch/arm/mm/proc-arm1020.S	1.12    -> 1.16   
#	 net/sched/sch_tbf.c	1.8     -> 1.9    
#	net/ipv6/ip6_output.c	1.19    -> 1.20   
#	 drivers/base/core.c	1.64    -> 1.65   
#	drivers/scsi/cpqfcTSinit.c	1.33    -> 1.35   
#	drivers/net/sb1000.c	1.15    -> 1.16   
#	drivers/scsi/53c700.h	1.10    -> 1.12   
#	arch/ppc/platforms/4xx/redwood5.h	1.5     -> 1.6    
#	drivers/usb/serial/io_edgeport.c	1.42    -> 1.44   
#	drivers/media/video/mxb.c	1.1     -> 1.3    
#	  net/llc/llc_conn.c	1.24    -> 1.26   
#	drivers/net/hamradio/Kconfig	1.3     -> 1.4    
#	drivers/net/myri_sbus.c	1.13    -> 1.14   
#	drivers/net/ioc3-eth.c	1.16    -> 1.17   
#	net/sctp/sm_statefuns.c	1.41    -> 1.42   
#	arch/i386/kernel/irq.c	1.29    -> 1.34   
#	drivers/video/epson1355fb.c	1.12    -> 1.13   
#	     mm/page_alloc.c	1.153   -> 1.154  
#	drivers/scsi/aic7xxx/aic7xxx_osm.c	1.27    -> 1.28   
#	arch/ppc/8260_io/uart.c	1.12    -> 1.18   
#	drivers/char/watchdog/pcwd.c	1.21    -> 1.22   
#	drivers/scsi/scsi_proc.c	1.18    -> 1.19   
#	drivers/usb/core/inode.c	1.47    -> 1.48   
#	  net/llc/llc_c_ev.c	1.7     -> 1.8    
#	drivers/isdn/hisax/hfc_sx.c	1.38    -> 1.39   
#	net/ipv6/ipv6_sockglue.c	1.18    -> 1.19   
#	drivers/video/vesafb.c	1.30    -> 1.31   
#	sound/pci/cs46xx/cs46xx_lib.c	1.30    -> 1.33   
#	net/ipv6/netfilter/ip6table_filter.c	1.5     -> 1.6    
#	drivers/scsi/mac_scsi.c	1.5     -> 1.6    
#	  arch/arm/mm/init.c	1.20    -> 1.21   
#	arch/sparc/kernel/sun4c_irq.c	1.7     -> 1.8    
#	include/asm-arm/cpu-multi32.h	1.10    -> 1.14   
#	 net/bridge/br_fdb.c	1.3     -> 1.5    
#	include/asm-arm/proc-armv/pgtable.h	1.12    -> 1.13   
#	drivers/acpi/utilities/utmisc.c	1.23    -> 1.24   
#	drivers/scsi/sun3_scsi.c	1.15    -> 1.16   
#	   drivers/fc4/soc.c	1.9     -> 1.11   
#	   drivers/char/dz.c	1.14    -> 1.18   
#	arch/arm/nwfpe/softfloat.h	1.2     -> 1.3    
#	drivers/input/serio/i8042.c	1.25    -> 1.26   
#	arch/sparc/kernel/sparc_ksyms.c	1.16    -> 1.17   
#	drivers/char/drm/i830_dma.c	1.14    -> 1.18   
#	drivers/acpi/hardware/hwsleep.c	1.18    -> 1.19   
#	arch/ppc/amiga/amiints.c	1.9     -> 1.10   
#	net/sched/cls_rsvp.h	1.3     -> 1.4    
#	arch/s390/kernel/setup.c	1.21    -> 1.22   
#	drivers/macintosh/via-cuda.c	1.7     -> 1.8    
#	arch/alpha/kernel/core_marvel.c	1.8     -> 1.9    
#	arch/ia64/sn/io/sn2/pci_bus_cvlink.c	1.1     -> 1.2    
#	drivers/video/pvr2fb.c	1.12    -> 1.14   
#	drivers/net/pcmcia/nmclan_cs.c	1.10    -> 1.13   
#	include/linux/umem.h	1.2     -> 1.3    
#	  net/llc/llc_proc.c	1.8     -> 1.9    
#	drivers/char/drm/drm_proc.h	1.10    -> 1.12   
#	sound/oss/emu10k1/audio.c	1.15    -> 1.16   
#	fs/partitions/nec98.c	1.1     -> 1.2    
#	drivers/isdn/hisax/avm_a1.c	1.24    -> 1.25   
#	sound/drivers/serial-u16550.c	1.13    -> 1.14   
#	drivers/net/wan/comx-hw-comx.c	1.9     -> 1.10   
#	 drivers/net/lance.c	1.17    -> 1.18   
#	drivers/isdn/eicon/uxio.h	1.6     -> 1.7    
#	       kernel/fork.c	1.117   -> 1.118  
#	include/linux/sched.h	1.140   -> 1.142  
#	arch/ppc/platforms/pmac_sleep.S	1.10    -> 1.11   
#	drivers/ide/ppc/pmac.c	1.9     -> 1.10   
#	net/sunrpc/svcsock.c	1.42    -> 1.43   
#	drivers/video/g364fb.c	1.20    -> 1.21   
#	arch/arm/boot/compressed/head-sa1100.S	1.5     -> 1.6    
#	arch/i386/kernel/vm86.c	1.24    -> 1.25   
#	 sound/oss/wf_midi.c	1.7     -> 1.8    
#	drivers/block/ll_rw_blk.c	1.163   -> 1.168  
#	drivers/video/hitfb.c	1.20    -> 1.21   
#	drivers/scsi/ibmmca.c	1.15    -> 1.17   
#	 net/sched/sch_cbq.c	1.9     -> 1.11   
#	drivers/usb/serial/keyspan.c	1.45    -> 1.47   
#	net/ipv4/xfrm4_tunnel.c	1.2     -> 1.3    
#	drivers/i2c/chips/via686a.c	1.5     -> 1.6    
#	drivers/media/radio/miropcm20-rds.c	1.9     -> 1.10   
#	drivers/net/wireless/airo.c	1.37    -> 1.39   
#	drivers/pcmcia/i82092aa.h	1.3     -> 1.4    
#	drivers/video/macfb.c	1.25    -> 1.26   
#	drivers/atm/ambassador.c	1.10    -> 1.11   
#	include/asm-ppc/irq.h	1.8     -> 1.9    
#	arch/ppc/platforms/spruce_setup.c	1.10    -> 1.11   
#	  drivers/net/8390.c	1.12    -> 1.13   
#	drivers/isdn/hisax/hisax_fcclassic.c	1.3     -> 1.4    
#	  drivers/md/Kconfig	1.2     -> 1.3    
#	drivers/video/atafb.c	1.19    -> 1.21   
#	include/asm-sparc64/timer.h	1.3     -> 1.4    
#	include/linux/serial_core.h	1.21    -> 1.23   
#	drivers/isdn/tpam/tpam_commands.c	1.8     -> 1.9    
#	drivers/mtd/maps/pcmciamtd.c	1.2     -> 1.3    
#	drivers/char/mwave/tp3780i.c	1.2     -> 1.3    
#	drivers/isdn/pcbit/layer2.h	1.4     -> 1.5    
#	include/asm-mips/irq.h	1.3     -> 1.4    
#	drivers/serial/amba.c	1.18    -> 1.20   
#	arch/ppc64/kernel/chrp_setup.c	1.21    -> 1.23   
#	drivers/media/video/videodev.c	1.17    -> 1.19   
#	drivers/ieee1394/sbp2.c	1.27    -> 1.29   
#	sound/oss/esssolo1.c	1.23    -> 1.26   
#	net/bridge/br_ioctl.c	1.4     -> 1.8    
#	         fs/dcache.c	1.49    -> 1.51   
#	drivers/atm/firestream.c	1.17    -> 1.18   
#	  drivers/net/tlan.c	1.19    -> 1.20   
#	drivers/net/lasi_82596.c	1.18    -> 1.19   
#	         mm/vmscan.c	1.152   -> 1.156  
#	     fs/smbfs/proc.c	1.28    -> 1.29   
#	drivers/isdn/hardware/eicon/divasmain.c	1.7     -> 1.8    
#	arch/ia64/kernel/setup.c	1.37    -> 1.38   
#	drivers/char/watchdog/eurotechwdt.c	1.12    -> 1.14   
#	include/asm-sparc/iommu.h	1.1     -> 1.2    
#	drivers/s390/char/sclp_tty.c	1.7     -> 1.8    
#	 fs/proc/proc_misc.c	1.74    -> 1.76   
#	drivers/serial/sa1100.c	1.21    -> 1.24   
#	drivers/acpi/executer/exregion.c	1.15    -> 1.16   
#	drivers/isdn/capi/capifs.h	1.4     -> 1.5    
#	drivers/block/cpqarray.c	1.74    -> 1.75   
#	arch/sparc/kernel/process.c	1.23    -> 1.24   
#	net/sctp/sm_make_chunk.c	1.34    -> 1.35   
#	drivers/scsi/sym53c416.c	1.14    -> 1.16   
#	  net/llc/llc_stat.c	1.2     -> 1.3    
#	drivers/i2c/i2c-core.c	1.31    -> 1.32   
#	drivers/net/sk98lin/skge.c	1.14    -> 1.15   
#	 drivers/net/3c515.c	1.19    -> 1.20   
#	drivers/net/tulip/xircom_tulip_cb.c	1.19    -> 1.20   
#	  net/irda/irqueue.c	1.6     -> 1.7    
#	drivers/ieee1394/video1394.c	1.30    -> 1.33   
#	include/linux/genhd.h	1.48    -> 1.51   
#	drivers/block/floppy.c	1.72    -> 1.76   
#	   arch/i386/Kconfig	1.50    -> 1.56   
#	drivers/block/ataflop.c	1.35    -> 1.37   
#	drivers/sbus/char/aurora.c	1.20    -> 1.24   
#	drivers/char/drm/r128_cce.c	1.10    -> 1.12   
#	drivers/isdn/hisax/elsa.c	1.36    -> 1.37   
#	 drivers/base/node.c	1.10    -> 1.11   
#	drivers/scsi/53c700.c	1.26    -> 1.29   
#	include/asm-i386/bugs.h	1.8     -> 1.9    
#	arch/arm/nwfpe/fpsr.h	1.1     -> 1.2    
#	include/linux/if_pppox.h	1.7     -> 1.8    
#	drivers/isdn/hisax/sportster.c	1.25    -> 1.26   
#	drivers/sbus/char/envctrl.c	1.13    -> 1.14   
#	drivers/acpi/events/evxfregn.c	1.14    -> 1.15   
#	drivers/video/aty/mach64_gx.c	1.7     -> 1.8    
#	sound/isa/opti9xx/opti92x-ad1848.c	1.13    -> 1.15   
#	net/sched/sch_dsmark.c	1.8     -> 1.9    
#	    fs/jbd/journal.c	1.31    -> 1.32   
#	    net/ipx/af_ipx.c	1.26    -> 1.28   
#	include/asm-sparc64/pci.h	1.12    -> 1.13   
#	drivers/media/video/saa7134/saa7134-video.c	1.5     -> 1.6    
#	include/asm-arm/procinfo.h	1.8     -> 1.9    
#	drivers/isdn/tpam/tpam.h	1.5     -> 1.6    
#	     fs/devfs/base.c	1.83    -> 1.87   
#	arch/i386/kernel/traps.c	1.50    -> 1.51   
#	         init/main.c	1.97    -> 1.98   
#	drivers/char/drm/drm_memory.h	1.6     -> 1.8    
#	drivers/net/hamradio/6pack.c	1.10    -> 1.11   
#	include/asm-sparc/sbus.h	1.4     -> 1.5    
#	drivers/net/wan/cycx_x25.c	1.9     -> 1.10   
#	arch/alpha/kernel/setup.c	1.33    -> 1.34   
#	    fs/nfsd/nfsctl.c	1.32    -> 1.33   
#	 include/linux/i2c.h	1.23    -> 1.25   
#	drivers/scsi/g_NCR5380.c	1.15    -> 1.17   
#	drivers/usb/media/ultracam.c	1.11    -> 1.12   
#	net/ipv4/fib_semantics.c	1.8     -> 1.10   
#	include/asm-h8300/irq.h	1.1     -> 1.2    
#	drivers/usb/class/usblp.c	1.41    -> 1.42   
#	arch/mips/kernel/setup.c	1.8     -> 1.9    
#	   net/llc/llc_pdu.c	1.6     -> 1.7    
#	arch/ppc/platforms/powerpmc250.c	1.6     -> 1.7    
#	sound/sparc/amd7930.c	1.4     -> 1.6    
#	   scripts/modpost.c	1.11    -> 1.12   
#	net/bluetooth/af_bluetooth.c	1.15    -> 1.16   
#	arch/ppc/kernel/cpu_setup_6xx.S	1.1     -> 1.2    
#	drivers/char/watchdog/machzwd.c	1.17    -> 1.18   
#	drivers/video/skeletonfb.c	1.22    -> 1.23   
#	arch/ppc/mm/pgtable.c	1.10    -> 1.11   
#	drivers/net/68360enet.c	1.2     -> 1.3    
#	drivers/ieee1394/hosts.h	1.14    -> 1.15   
#	drivers/char/drm/radeon_cp.c	1.16    -> 1.18   
#	  net/llc/llc_evnt.c	1.5     -> 1.6    
#	arch/i386/vmlinux.lds.S	1.27    -> 1.29   
#	drivers/scsi/scsi_sysfs.c	1.9     -> 1.10   
#	net/sctp/transport.c	1.16    -> 1.17   
#	include/net/pkt_sched.h	1.3     -> 1.4    
#	 sound/oss/ite8172.c	1.12    -> 1.15   
#	drivers/net/tulip/winbond-840.c	1.30    -> 1.31   
#	drivers/serial/sunsu.c	1.33    -> 1.36   
#	  fs/cifs/cifsglob.h	1.5     -> 1.7    
#	drivers/media/dvb/dvb-core/dvbdev.c	1.7     -> 1.8    
#	       mm/swapfile.c	1.73    -> 1.77   
#	drivers/net/wan/hd6457x.c	1.6     -> 1.7    
#	arch/ppc/platforms/4xx/redwood6.h	1.3     -> 1.4    
#	net/sched/sch_teql.c	1.3     -> 1.4    
#	 fs/partitions/mac.c	1.3     -> 1.4    
#	drivers/serial/anakin.c	1.15    -> 1.16   
#	drivers/video/controlfb.c	1.25    -> 1.26   
#	arch/ppc/kernel/traps.c	1.18    -> 1.19   
#	drivers/char/synclinkmp.c	1.8     -> 1.13   
#	drivers/net/wan/x25_asy.c	1.4     -> 1.5    
#	arch/sparc/kernel/sunos_asm.S	1.1     -> 1.2    
#	arch/alpha/kernel/proto.h	1.14    -> 1.15   
#	drivers/video/cyber2000fb.c	1.26    -> 1.28   
#	drivers/char/cyclades.c	1.17    -> 1.21   
#	drivers/atm/nicstar.c	1.14    -> 1.15   
#	    kernel/cpufreq.c	1.28    -> 1.29   
#	sound/isa/cs423x/cs4231_lib.c	1.13    -> 1.15   
#	arch/cris/drivers/Kconfig	1.2     -> 1.3    
#	drivers/net/ibmlana.c	1.7     -> 1.8    
#	arch/arm/mach-sa1100/h3600.c	1.13    -> 1.14   
#	net/sched/sch_fifo.c	1.3     -> 1.4    
#	drivers/ieee1394/csr.c	1.9     -> 1.11   
#	drivers/net/wan/n2.c	1.10    -> 1.12   
#	   fs/cifs/cifssmb.c	1.11    -> 1.14   
#	   drivers/atm/eni.c	1.11    -> 1.12   
#	 net/bridge/br_stp.c	1.2     -> 1.5    
#	net/bridge/br_private.h	1.8     -> 1.12   
#	include/net/ip6_route.h	1.6     -> 1.7    
#	drivers/char/drm/drm_bufs.h	1.12    -> 1.14   
#	drivers/block/Kconfig	1.4     -> 1.5    
#	include/linux/blkdev.h	1.99    -> 1.101  
#	drivers/scsi/NCR53C9x.c	1.20    -> 1.22   
#	  arch/ppc/mm/init.c	1.27    -> 1.28   
#	drivers/video/pm3fb.c	1.7     -> 1.8    
#	arch/arm/mm/fault-armv.c	1.20    -> 1.21   
#	include/asm-sparc64/asi.h	1.5     -> 1.6    
#	drivers/input/mouse/psmouse.c	1.22    -> 1.23   
#	arch/i386/kernel/microcode.c	1.18    -> 1.19   
#	 drivers/block/nbd.c	1.54    -> 1.55   
#	include/asm-i386/floppy.h	1.5     -> 1.6    
#	net/irda/irlmp_event.c	1.16    -> 1.17   
#	drivers/message/fusion/mptbase.c	1.9     -> 1.10   
#	drivers/net/atarilance.c	1.12    -> 1.13   
#	include/asm-ppc/ocp.h	1.1     -> 1.2    
#	  drivers/atm/zatm.c	1.10    -> 1.11   
#	drivers/video/sun3fb.c	1.14    -> 1.15   
#	 net/sched/cls_api.c	1.2     -> 1.4    
#	drivers/ieee1394/ieee1394_core.c	1.27    -> 1.29   
#	drivers/serial/core.c	1.51    -> 1.59   
#	drivers/char/drm/drm_ioctl.h	1.10    -> 1.11   
#	 sound/oss/btaudio.c	1.12    -> 1.14   
#	drivers/net/pcmcia/3c574_cs.c	1.14    -> 1.17   
#	 net/rose/rose_dev.c	1.6     -> 1.7    
#	  net/llc/llc_actn.c	1.6     -> 1.7    
#	arch/sparc/kernel/head.S	1.5     -> 1.6    
#	include/asm-sparc/kgdb.h	1.1     -> 1.2    
#	  drivers/base/bus.c	1.43    -> 1.44   
#	drivers/media/video/w9966.c	1.9     -> 1.10   
#	drivers/net/rrunner.c	1.14    -> 1.15   
#	drivers/cdrom/optcd.c	1.28    -> 1.29   
#	arch/um/drivers/stdio_console.c	1.9     -> 1.10   
#	drivers/isdn/hisax/nj_u.c	1.25    -> 1.26   
#	drivers/net/wan/comx-hw-munich.c	1.9     -> 1.10   
#	drivers/scsi/NCR5380.c	1.14    -> 1.16   
#	drivers/net/wireless/Kconfig	1.5     -> 1.6    
#	   drivers/scsi/sr.c	1.75    -> 1.76   
#	sound/oss/gus_wave.c	1.8     -> 1.9    
#	drivers/net/wan/Kconfig	1.4     -> 1.5    
#	drivers/net/wan/dscc4.c	1.34    -> 1.35   
#	    net/key/af_key.c	1.31    -> 1.32   
#	arch/sparc64/kernel/pci_common.c	1.18    -> 1.19   
#	drivers/net/tulip/interrupt.c	1.16    -> 1.17   
#	drivers/scsi/aha1740.c	1.12    -> 1.14   
#	drivers/net/starfire.c	1.25    -> 1.26   
#	drivers/char/ftape/lowlevel/fdc-io.c	1.7     -> 1.9    
#	drivers/isdn/capi/capifs.c	1.20    -> 1.22   
#	 drivers/scsi/scsi.h	1.73    -> 1.75   
#	include/asm-sparc64/signal.h	1.8     -> 1.9    
#	    kernel/suspend.c	1.37    -> 1.38   
#	 include/linux/gfp.h	1.12    -> 1.14   
#	net/bridge/br_input.c	1.8     -> 1.10   
#	drivers/net/irda/irtty.c	1.14    -> 1.16   
#	  include/linux/fs.h	1.232   -> 1.238  
#	 drivers/pcmcia/cs.c	1.23    -> 1.26   
#	drivers/video/sa1100fb.c	1.26    -> 1.28   
#	 drivers/atm/lanai.c	1.8     -> 1.9    
#	arch/ppc/platforms/ev64260_setup.c	1.5     -> 1.7    
#	drivers/scsi/ini9100u.c	1.12    -> 1.14   
#	drivers/base/fs/fs.h	1.4     ->         (deleted)      
#	   fs/ntfs/ChangeLog	1.119   -> 1.127  
#	arch/sparc64/kernel/chmc.c	1.3     -> 1.4    
#	include/sound/emu10k1.h	1.13    -> 1.15   
#	drivers/video/vga16fb.c	1.32    -> 1.33   
#	arch/sparc64/kernel/devices.c	1.9     -> 1.10   
#	drivers/char/watchdog/mixcomwd.c	1.14    -> 1.15   
#	drivers/video/maxinefb.c	1.18    -> 1.19   
#	drivers/pcmcia/cardbus.c	1.26    -> 1.27   
#	include/linux/linux_logo.h	1.4     -> 1.5    
#	drivers/video/tdfxfb.c	1.41    -> 1.42   
#	drivers/block/paride/pt.c	1.14    -> 1.15   
#	drivers/net/tokenring/Kconfig	1.6     -> 1.7    
#	drivers/usb/media/ibmcam.c	1.17    -> 1.18   
#	include/asm-arm/arch-ebsa285/irqs.h	1.1     -> 1.2    
#	drivers/md/dm-ioctl.c	1.16    -> 1.19   
#	drivers/usb/image/scanner.c	1.56    -> 1.57   
#	drivers/isdn/hisax/nj_s.c	1.26    -> 1.27   
#	drivers/sgi/char/sgiserial.c	1.8     -> 1.12   
#	drivers/acpi/resources/rsmisc.c	1.11    -> 1.12   
#	  drivers/net/ni65.c	1.15    -> 1.16   
#	include/linux/quotaops.h	1.13    -> 1.14   
#	include/asm-x86_64/floppy.h	1.1     -> 1.2    
#	drivers/char/mwave/mwavedd.c	1.8     -> 1.9    
#	arch/arm/mach-pxa/generic.c	1.6     -> 1.7    
#	drivers/video/q40fb.c	1.22    -> 1.23   
#	drivers/isdn/eicon/eicon.h	1.10    -> 1.11   
#	drivers/isdn/eicon/eicon_io.c	1.4     -> 1.5    
#	drivers/net/lp486e.c	1.10    -> 1.11   
#	arch/i386/kernel/cpu/intel.c	1.18    -> 1.19   
#	drivers/net/pcnet32.c	1.32    -> 1.33   
#	drivers/video/virgefb.c	1.16    -> 1.17   
#	drivers/char/n_hdlc.c	1.11    -> 1.14   
#	drivers/char/ser_a2232.c	1.6     -> 1.8    
#	net/ipv6/netfilter/ip6_queue.c	1.9     -> 1.10   
#	arch/sparc/kernel/smp.c	1.8     -> 1.9    
#	drivers/pcmcia/sa1111_generic.c	1.13    -> 1.14   
#	 drivers/video/cg6.c	1.4     -> 1.5    
#	drivers/eisa/eisa-bus.c	1.5     -> 1.6    
#	drivers/isdn/eicon/linio.c	1.7     -> 1.8    
#	    net/irda/iriap.c	1.13    -> 1.14   
#	arch/arm/boot/compressed/head-xscale.S	1.3     -> 1.4    
#	 net/sched/cls_u32.c	1.6     -> 1.8    
#	drivers/net/Makefile	1.57    -> 1.58   
#	   drivers/ide/ide.c	1.58    -> 1.59   
#	drivers/serial/clps711x.c	1.15    -> 1.17   
#	sound/oss/via82cxxx_audio.c	1.25    -> 1.27   
#	sound/oss/dmasound/dmasound_atari.c	1.8     -> 1.9    
#	     drivers/md/md.c	1.163   -> 1.166  
#	net/ipv4/netfilter/ipt_physdev.c	1.3     -> 1.4    
#	 arch/mips64/Kconfig	1.11    -> 1.12   
#	 fs/cifs/transport.c	1.6     -> 1.7    
#	arch/alpha/kernel/core_titan.c	1.14    -> 1.15   
#	drivers/ieee1394/ieee1394.h	1.5     -> 1.6    
#	net/ipv4/ip_sockglue.c	1.13    -> 1.15   
#	drivers/net/appletalk/ltpc.c	1.9     -> 1.11   
#	drivers/scsi/advansys.c	1.28    -> 1.31   
#	drivers/scsi/ncr53c8xx.c	1.23    -> 1.25   
#	drivers/net/sunlance.c	1.14    -> 1.16   
#	      fs/cifs/link.c	1.3     -> 1.4    
#	include/asm-ppc/machdep.h	1.15    -> 1.16   
#	net/sched/cls_route.c	1.5     -> 1.6    
#	include/asm-arm/arch-nexuspci/irqs.h	1.1     -> 1.2    
#	     net/ipv6/icmp.c	1.23    -> 1.26   
#	drivers/scsi/inia100.c	1.19    -> 1.21   
#	drivers/net/wireless/orinoco.h	1.11    -> 1.12   
#	arch/arm/nwfpe/entry26.S	1.6     -> 1.7    
#	include/linux/wrapper.h	1.1     ->         (deleted)      
#	  include/linux/fb.h	1.51    -> 1.53   
#	drivers/char/drm/i830.h	1.6     -> 1.8    
#	net/sunrpc/rpc_pipe.c	1.7     -> 1.8    
#	drivers/usb/media/se401.c	1.33    -> 1.35   
#	drivers/acpi/parser/psargs.c	1.16    -> 1.17   
#	drivers/eisa/Kconfig	1.2     -> 1.3    
#	arch/ppc/platforms/mvme5100_setup.c	1.5     -> 1.6    
#	net/ipv6/netfilter/ip6t_LOG.c	1.4     -> 1.5    
#	arch/mips/au1000/common/serial.c	1.9     -> 1.15   
#	drivers/scsi/u14-34f.c	1.24    -> 1.26   
#	arch/i386/kernel/mpparse.c	1.38    -> 1.39   
#	arch/arm/kernel/entry-armv.S	1.29    -> 1.30   
#	net/bridge/br_forward.c	1.7     -> 1.9    
#	drivers/media/dvb/dvb-core/dvbdev.h	1.3     -> 1.4    
#	drivers/pcmcia/cistpl.c	1.12    -> 1.13   
#	drivers/isdn/hisax/sedlbauer_cs.c	1.7     -> 1.8    
#	arch/sparc64/kernel/ebus.c	1.13    -> 1.14   
#	  drivers/char/pty.c	1.11    -> 1.17   
#	  drivers/base/cpu.c	1.10    -> 1.11   
#	  net/irda/af_irda.c	1.39    -> 1.41   
#	drivers/usb/media/ov511.c	1.41    -> 1.43   
#	drivers/scsi/hosts.h	1.58    -> 1.59   
#	drivers/char/lp_old98.c	1.1     -> 1.2    
#	drivers/acpi/executer/exfldio.c	1.21    -> 1.22   
#	net/irda/ircomm/ircomm_tty.c	1.16    -> 1.19   
#	include/sound/ad1848.h	1.4     -> 1.5    
#	drivers/scsi/NCR53C9x.h	1.5     -> 1.7    
#	drivers/char/drm/i830_drv.c	1.6     -> 1.7    
#	drivers/video/i810/i810_main.c	1.8     -> 1.9    
#	 fs/reiserfs/inode.c	1.73    -> 1.74   
#	 net/ipv4/tcp_ipv4.c	1.48    -> 1.49   
#	drivers/media/video/tvaudio.c	1.16    -> 1.17   
#	drivers/media/video/saa7134/saa7134-core.c	1.3     -> 1.4    
#	arch/arm/nwfpe/fpopcode.h	1.3     -> 1.6    
#	       fs/ntfs/dir.c	1.65    -> 1.66   
#	drivers/ieee1394/highlevel.h	1.7     -> 1.9    
#	drivers/ide/ide-tape.c	1.21    -> 1.22   
#	drivers/usb/core/hcd.h	1.27    -> 1.28   
#	arch/i386/kernel/io_apic.c	1.62    -> 1.64   
#	drivers/char/drm/i810.h	1.6     -> 1.8    
#	arch/ppc/syslib/ppc8xx_pic.c	1.8     -> 1.9    
#	arch/parisc/kernel/sys_parisc32.c	1.14    -> 1.15   
#	arch/sparc64/defconfig	1.80    -> 1.82   
#	sound/pci/rme9652/hdsp.c	1.16    -> 1.17   
#	sound/pci/ice1712/ice1712.c	1.10    -> 1.13   
#	drivers/acorn/block/fd1772.c	1.34    -> 1.35   
#	drivers/net/sunhme.c	1.31    -> 1.32   
#	drivers/usb/media/vicam.c	1.31    -> 1.34   
#	drivers/input/mouse/pc110pad.c	1.6     -> 1.8    
#	arch/ppc/platforms/prpmc750_setup.c	1.6     -> 1.7    
#	sound/oss/cs4281/cs4281_wrapper-24.c	1.4     -> 1.5    
#	drivers/char/ftape/lowlevel/ftape-buffer.c	1.3     -> 1.5    
#	        mm/filemap.c	1.190   -> 1.191  
#	drivers/char/drm/i810_dma.c	1.22    -> 1.26   
#	sound/oss/waveartist.c	1.6     -> 1.7    
#	drivers/cdrom/sonycd535.c	1.33    -> 1.35   
#	arch/sparc64/kernel/setup.c	1.37    -> 1.38   
#	net/bridge/netfilter/ebtables.c	1.7     -> 1.8    
#	sound/oss/dmasound/dmasound_awacs.c	1.11    -> 1.12   
#	drivers/ide/ide-iops.c	1.15    -> 1.16   
#	drivers/usb/serial/whiteheat.c	1.35    -> 1.37   
#	drivers/input/touchscreen/gunze.c	1.6     -> 1.7    
#	drivers/isdn/hisax/hisax_hfcpci.c	1.7     -> 1.8    
#	arch/ppc/platforms/adir_setup.c	1.4     -> 1.6    
#	include/asm-mips64/irq.h	1.2     -> 1.3    
#	arch/arm/vmlinux-armv.lds.in	1.23    -> 1.24   
#	drivers/char/pcmcia/synclink_cs.c	1.10    -> 1.15   
#	drivers/net/wan/sbni.c	1.16    -> 1.17   
#	drivers/hotplug/cpqphp_ctrl.c	1.9     -> 1.10   
#	drivers/char/drm/r128.h	1.7     -> 1.8    
#	        net/socket.c	1.50    -> 1.55   
#	drivers/ieee1394/pcilynx.c	1.28    -> 1.30   
#	drivers/scsi/ncr53c8xx.h	1.10    -> 1.11   
#	include/asm-parisc/irq.h	1.4     -> 1.5    
#	   sound/pci/rme96.c	1.16    -> 1.17   
#	drivers/char/synclink.c	1.28    -> 1.34   
#	net/ipv4/netfilter/iptable_filter.c	1.7     -> 1.8    
#	drivers/block/swim3.c	1.26    -> 1.28   
#	drivers/scsi/aic7xxx/aic7xxx_osm.h	1.34    -> 1.35   
#	    fs/binfmt_misc.c	1.17    -> 1.19   
#	   arch/arm/Makefile	1.38    -> 1.39   
#	drivers/block/floppy98.c	1.1     -> 1.6    
#	drivers/net/e1000/e1000_main.c	1.62    -> 1.64   
#	drivers/char/hw_random.c	1.9     -> 1.10   
#	 sound/oss/rme96xx.c	1.12    -> 1.13   
#	drivers/acpi/dispatcher/dsmthdat.c	1.19    -> 1.20   
#	 drivers/net/sunqe.c	1.12    -> 1.13   
#	net/core/sysctl_net_core.c	1.3     -> 1.4    
#	arch/alpha/kernel/core_tsunami.c	1.10    -> 1.11   
#	arch/sparc64/mm/init.c	1.43    -> 1.45   
#	arch/arm/nwfpe/fpa11.c	1.9     -> 1.13   
#	 drivers/base/base.h	1.24    -> 1.25   
#	sound/drivers/mpu401/mpu401_uart.c	1.14    -> 1.16   
#	drivers/scsi/fd_mcs.c	1.9     -> 1.11   
#	drivers/net/irda/w83977af_ir.c	1.15    -> 1.16   
#	  fs/proc/proc_tty.c	1.3     -> 1.6    
#	fs/partitions/check.h	1.8     -> 1.10   
#	 include/linux/ide.h	1.44    -> 1.48   
#	drivers/mtd/mtdblock.c	1.41    -> 1.43   
#	arch/sparc64/kernel/head.S	1.16    -> 1.17   
#	drivers/char/rio/riotty.c	1.7     -> 1.8    
#	 drivers/net/hp100.c	1.15    -> 1.16   
#	drivers/scsi/nsp32.c	1.8     -> 1.10   
#	drivers/net/yellowfin.c	1.20    -> 1.21   
#	 drivers/net/3c501.h	1.1     -> 1.2    
#	  net/sched/cls_fw.c	1.3     -> 1.5    
#	net/ipv4/netfilter/ip_fw_compat.c	1.14    -> 1.15   
#	arch/sparc64/kernel/trampoline.S	1.13    -> 1.14   
#	drivers/video/platinumfb.c	1.19    -> 1.20   
#	drivers/scsi/aacraid/linit.c	1.13    -> 1.15   
#	drivers/serial/sunsab.c	1.24    -> 1.27   
#	net/ipv6/netfilter/ip6table_mangle.c	1.7     -> 1.8    
#	net/netlink/netlink_dev.c	1.13    -> 1.15   
#	drivers/net/wireless/ray_cs.c	1.16    -> 1.18   
#	  include/net/snmp.h	1.6     -> 1.7    
#	drivers/isdn/hisax/niccy.c	1.28    -> 1.29   
#	drivers/net/pcmcia/xirc2ps_cs.c	1.14    -> 1.17   
#	drivers/char/ftape/zftape/zftape-init.c	1.16    -> 1.17   
#	  net/llc/llc_main.c	1.25    -> 1.28   
#	drivers/ieee1394/hosts.c	1.17    -> 1.18   
#	   arch/s390/Kconfig	1.9     -> 1.10   
#	           mm/swap.c	1.49    -> 1.50   
#	drivers/net/at1700.c	1.17    -> 1.18   
#	drivers/isdn/hisax/bkm_a4t.c	1.25    -> 1.26   
#	arch/parisc/kernel/irq.c	1.13    -> 1.14   
#	drivers/char/watchdog/advantechwdt.c	1.15    -> 1.16   
#	drivers/bluetooth/dtl1_cs.c	1.7.1.1 -> 1.10   
#	drivers/serial/uart00.c	1.15    -> 1.16   
#	drivers/usb/image/scanner.h	1.32    -> 1.33   
#	drivers/video/fm2fb.c	1.23    -> 1.24   
#	arch/sparc64/solaris/timod.c	1.13    -> 1.14   
#	drivers/net/irda/ali-ircc.c	1.15    -> 1.16   
#	 include/linux/net.h	1.12    -> 1.14   
#	     net/ipv6/proc.c	1.8     -> 1.11   
#	drivers/usb/misc/auerswald.c	1.28    -> 1.29   
#	  drivers/char/rtc.c	1.24    -> 1.26   
#	       init/Makefile	1.25    -> 1.26   
#	arch/um/kernel/mem.c	1.14    -> 1.15   
#	drivers/char/keyboard.c	1.28    -> 1.30   
#	drivers/bluetooth/Kconfig	1.6     -> 1.7    
#	drivers/scsi/atp870u.c	1.17    -> 1.19   
#	   drivers/char/sx.c	1.24    -> 1.28   
#	net/sched/sch_prio.c	1.7     -> 1.8    
#	net/ipv4/netfilter/ipfwadm_core.c	1.13    -> 1.14   
#	 drivers/fc4/socal.c	1.8     -> 1.10   
#	drivers/isdn/act2000/act2000_isa.c	1.6     -> 1.7    
#	    fs/ntfs/attrib.h	1.20    -> 1.21   
#	include/asm-sparc/winmacro.h	1.1     -> 1.2    
#	drivers/ide/ide-disk.c	1.37    -> 1.40   
#	drivers/media/video/saa7111.c	1.10    -> 1.11   
#	drivers/usb/serial/usb-serial.c	1.75    -> 1.77   
#	fs/partitions/Makefile	1.11    -> 1.12   
#	drivers/scsi/aic7xxx_old.c	1.47    -> 1.48   
#	include/asm-m68k/sun3_pgalloc.h	1.10    -> 1.13   
#	  drivers/net/dl2k.c	1.25    -> 1.26   
#	 include/linux/irq.h	1.5     -> 1.6    
#	drivers/char/drm/gamma_drv.h	1.6     -> 1.8    
#	include/asm-ppc/system.h	1.17    -> 1.18   
#	  sound/oss/mpu401.h	1.4     -> 1.5    
#	  sound/isa/es18xx.c	1.16    -> 1.18   
#	drivers/isdn/hisax/hfc_pci.c	1.41    -> 1.42   
#	drivers/input/evbug.c	1.6     -> 1.7    
#	arch/ppc/syslib/m8xx_setup.c	1.21    -> 1.24   
#	include/linux/console.h	1.5     -> 1.7    
#	  net/llc/llc_c_st.c	1.4     -> 1.5    
#	arch/arm/nwfpe/fpopcode.c	1.3     -> 1.6    
#	drivers/usb/input/hiddev.c	1.29    -> 1.31   
#	drivers/media/video/tuner-3036.c	1.7     -> 1.8    
#	drivers/char/watchdog/softdog.c	1.16    -> 1.17   
#	   drivers/net/b44.c	1.6     -> 1.7    
#	drivers/scsi/cpqfcTSstructs.h	1.12    -> 1.14   
#	drivers/net/ppp_synctty.c	1.7     -> 1.8    
#	arch/sparc64/kernel/systbls.S	1.37    -> 1.38   
#	arch/x86_64/ia32/sys_ia32.c	1.29    -> 1.31   
#	drivers/serial/mcfserial.c	1.5     -> 1.9    
#	arch/x86_64/kernel/irq.c	1.12    -> 1.13   
#	include/asm-ppc/cputable.h	1.5     -> 1.6    
#	drivers/net/hamradio/dmascc.c	1.9     -> 1.11   
#	drivers/media/video/tda9875.c	1.11    -> 1.12   
#	drivers/char/serial167.c	1.16    -> 1.21   
#	 include/linux/usb.h	1.73    -> 1.75   
#	drivers/net/sis900.c	1.34    -> 1.35   
#	drivers/hotplug/cpci_hotplug_core.c	1.4     -> 1.5    
#	arch/arm/nwfpe/fpa11.h	1.4     -> 1.7    
#	net/sched/cls_tcindex.c	1.5     -> 1.6    
#	     mm/swap_state.c	1.59    -> 1.60   
#	include/linux/input.h	1.26    -> 1.29   
#	arch/sparc/mm/init.c	1.17    -> 1.19   
#	drivers/net/irda/donauboe.c	1.3     -> 1.5    
#	arch/m68k/sun3x/prom.c	1.4     -> 1.5    
#	drivers/isdn/capi/capidrv.c	1.22    -> 1.23   
#	arch/arm/nwfpe/fpmodule.c	1.6     -> 1.9    
#	sound/oss/nm256_audio.c	1.11    -> 1.12   
#	drivers/net/wan/pc300_tty.c	1.8     -> 1.10   
#	drivers/scsi/seagate.c	1.15    -> 1.17   
#	drivers/input/joystick/spaceorb.c	1.10    -> 1.11   
#	 net/sched/sch_api.c	1.6     -> 1.8    
#	drivers/ide/ide-cd.c	1.42    -> 1.43   
#	sound/oss/sonicvibes.c	1.18    -> 1.21   
#	arch/x86_64/ia32/ia32entry.S	1.18    -> 1.19   
#	net/ipv4/netfilter/ip_conntrack_standalone.c	1.18    -> 1.19   
#	sound/pci/rme9652/rme9652.c	1.17    -> 1.18   
#	      fs/fat/inode.c	1.62    -> 1.63   
#	arch/sparc/mm/io-unit.c	1.6     -> 1.7    
#	arch/arm/mm/proc-syms.c	1.6     -> 1.8    
#	     net/ipx/Kconfig	1.1     -> 1.2    
#	         mm/memory.c	1.121   -> 1.122  
#	include/asm-arm/proc-armv/cache.h	1.13    -> 1.15   
#	sound/pci/ice1712/ice1724.c	1.1     -> 1.3    
#	include/asm-x86_64/mpspec.h	1.4     -> 1.5    
#	  include/sound/sb.h	1.6     -> 1.7    
#	drivers/net/ni5010.c	1.9     -> 1.10   
#	drivers/s390/block/dasd.c	1.56    -> 1.61   
#	   drivers/scsi/sg.c	1.50    -> 1.52   
#	   arch/v850/Kconfig	1.9     -> 1.10   
#	            fs/aio.c	1.30    -> 1.31   
#	arch/ppc/8260_io/fcc_enet.c	1.8     -> 1.9    
#	 net/sched/sch_atm.c	1.8     -> 1.9    
#	drivers/usb/serial/pl2303.c	1.37    -> 1.39   
#	drivers/char/riscom8.c	1.10    -> 1.14   
#	drivers/video/chipsfb.c	1.18    -> 1.19   
#	drivers/scsi/BusLogic.h	1.11    -> 1.13   
#	drivers/usb/usb-skeleton.c	1.31    -> 1.32   
#	         fs/compat.c	1.6     -> 1.7    
#	arch/sparc/kernel/entry.S	1.10    -> 1.11   
#	drivers/net/epic100.c	1.28    -> 1.30   
#	drivers/usb/serial/digi_acceleport.c	1.31    -> 1.33   
#	include/asm-arm/arch-sa1100/uncompress.h	1.4     -> 1.5    
#	net/core/netfilter.c	1.13    -> 1.18   
#	sound/oss/emu10k1/passthrough.c	1.7     -> 1.8    
#	drivers/block/amiflop.c	1.38    -> 1.39   
#	drivers/cdrom/mcdx.c	1.31    -> 1.32   
#	drivers/net/8139cp.c	1.35    -> 1.37   
#	arch/sparc64/kernel/rtrap.S	1.15    -> 1.16   
#	 drivers/ide/Kconfig	1.9     -> 1.10   
#	drivers/video/matrox/i2c-matroxfb.c	1.7     -> 1.8    
#	drivers/net/pcmcia/com20020_cs.c	1.6     -> 1.8    
#	drivers/net/e100/e100_main.c	1.60    -> 1.61   
#	include/asm-arm/arch-iop3xx/iop310.h	1.3     -> 1.4    
#	drivers/block/genhd.c	1.79    -> 1.83   
#	net/irda/irda_device.c	1.15    -> 1.16   
#	sound/isa/sb/sb16_main.c	1.9     -> 1.11   
#	arch/arm/mm/proc-sa110.S	1.16    -> 1.20   
#	arch/ppc64/kernel/setup.c	1.21    -> 1.22   
#	drivers/char/rio/func.h	1.2     -> 1.3    
#	arch/i386/kernel/setup.c	1.74    -> 1.79   
#	arch/arm/tools/mach-types	1.26    -> 1.27   
#	fs/cifs/cifs_debug.c	1.7     -> 1.8    
#	drivers/char/watchdog/sc520_wdt.c	1.8     -> 1.9    
#	drivers/isdn/hisax/elsa_cs.c	1.4     -> 1.5    
#	include/sound/cs4231.h	1.4     -> 1.5    
#	drivers/video/aty/aty128fb.c	1.36    -> 1.37   
#	drivers/scsi/gdth_proc.c	1.12    -> 1.13   
#	drivers/atm/idt77252.c	1.9     -> 1.10   
#	   arch/mips/Kconfig	1.9     -> 1.10   
#	drivers/usb/core/hcd-pci.c	1.12    -> 1.13   
#	drivers/bluetooth/bluecard_cs.c	1.9     -> 1.11   
#	drivers/mtd/mtdblock_ro.c	1.25    -> 1.26   
#	drivers/video/sgivwfb.c	1.28    -> 1.29   
#	arch/um/drivers/ubd_kern.c	1.30    -> 1.32   
#	arch/arm/mach-integrator/cpu.c	1.15    -> 1.16   
#	drivers/scsi/NCR53c406a.c	1.18    -> 1.20   
#	arch/i386/kernel/module.c	1.8     -> 1.10   
#	 drivers/net/3c523.c	1.10    -> 1.11   
#	drivers/net/wan/cycx_main.c	1.7     -> 1.8    
#	include/asm-sh/serial-ec3104.h	1.1     -> 1.2    
#	drivers/video/imsttfb.c	1.26    -> 1.27   
#	arch/ia64/hp/sim/simserial.c	1.11    -> 1.15   
#	arch/parisc/mm/init.c	1.8     -> 1.10   
#	drivers/char/tpqic02.c	1.20    -> 1.22   
#	arch/i386/kernel/time.c	1.30    -> 1.32   
#	sound/isa/sb/es968.c	1.12    -> 1.13   
#	drivers/net/tokenring/smctr.c	1.19    -> 1.20   
#	arch/arm/nwfpe/fpa11.inl	1.3     -> 1.4    
#	drivers/media/video/tea6420.c	1.1     -> 1.2    
#	drivers/net/wan/sdla_chdlc.c	1.21    -> 1.23   
#	drivers/serial/8250_cs.c	1.10    -> 1.11   
#	drivers/scsi/scsi_syms.c	1.30    -> 1.32   
#	net/econet/af_econet.c	1.15    -> 1.16   
#	drivers/input/joydev.c	1.14    -> 1.17   
#	arch/mips64/kernel/ioctl32.c	1.10    -> 1.11   
#	drivers/net/rclanmtl.h	1.5     -> 1.7    
#	include/asm-arm/arch-arc/irqs.h	1.2     -> 1.3    
#	drivers/scsi/scsi_lib.c	1.82    -> 1.84   
#	  net/rose/af_rose.c	1.21    -> 1.22   
#	arch/sparc64/kernel/time.c	1.36    -> 1.39   
#	net/netrom/af_netrom.c	1.23    -> 1.24   
#	net/irda/ircomm/ircomm_param.c	1.9     -> 1.10   
#	    net/llc/llc_if.c	1.19    -> 1.21   
#	drivers/net/appletalk/cops.c	1.15    -> 1.16   
#	 include/linux/tty.h	1.10    -> 1.15   
#	drivers/acpi/namespace/nsutils.c	1.21    -> 1.22   
#	drivers/base/fs/Makefile	1.8     ->         (deleted)      
#	include/asm-arm/setup.h	1.10    -> 1.11   
#	drivers/base/fs/device.c	1.25    ->         (deleted)      
#	include/asm-sh/pgalloc.h	1.7     -> 1.8    
#	arch/arm/mach-iop3xx/mm-321.c	1.1     -> 1.3    
#	net/netlink/af_netlink.c	1.21    -> 1.22   
#	drivers/video/tridentfb.c	1.7     -> 1.8    
#	arch/ppc/syslib/m8260_setup.c	1.17    -> 1.19   
#	include/acpi/actbl.h	1.13    -> 1.14   
#	           ipc/shm.c	1.23    -> 1.25   
#	      net/core/dev.c	1.62    -> 1.65   
#	include/linux/igmp.h	1.5     -> 1.6    
#	arch/ppc/platforms/pmac_smp.c	1.11    -> 1.13   
#	drivers/ide/legacy/pdc4030.c	1.7     -> 1.8    
#	drivers/char/generic_serial.c	1.8     -> 1.10   
#	drivers/input/mouse/logibm.c	1.8     -> 1.9    
#	arch/ppc/platforms/gemini_setup.c	1.13    -> 1.15   
#	include/linux/netfilter.h	1.4     -> 1.5    
#	  fs/ntfs/compress.c	1.51    -> 1.54   
#	arch/mips/gt64120/momenco_ocelot/setup.c	1.2     -> 1.3    
#	drivers/usb/core/usb.c	1.121   -> 1.122  
#	 drivers/scsi/scsi.c	1.102   -> 1.106  
#	drivers/char/drm/radeon_drv.h	1.18    -> 1.20   
#	drivers/usb/misc/brlvger.c	1.15    -> 1.16   
#	 fs/jfs/jfs_logmgr.c	1.46    -> 1.47   
#	drivers/eisa/Makefile	1.3     -> 1.4    
#	drivers/input/mouse/inport.c	1.7     -> 1.8    
#	  drivers/char/mem.c	1.34    -> 1.35   
#	kernel/posix-timers.c	1.13    -> 1.15   
#	arch/alpha/kernel/time.c	1.16    -> 1.17   
#	 drivers/net/r8169.c	1.8     -> 1.9    
#	drivers/char/watchdog/wdt.c	1.18    -> 1.20   
#	    net/irda/Kconfig	1.2     -> 1.3    
#	arch/arm/mm/proc-arm2_3.S	1.9     -> 1.12   
#	drivers/net/mac89x0.c	1.12    -> 1.13   
#	Documentation/filesystems/ntfs.txt	1.34    -> 1.37   
#	arch/arm/nwfpe/ChangeLog	1.2     -> 1.7    
#	net/bridge/br_stp_timer.c	1.1     -> 1.3    
#	drivers/s390/block/dasd_devmap.c	1.6     -> 1.7    
#	drivers/i2c/i2c-sensor.c	1.23    -> 1.26   
#	 drivers/net/depca.c	1.17    -> 1.18   
#	arch/sparc/kernel/sun4m_irq.c	1.7     -> 1.8    
#	drivers/s390/char/tubio.h	1.9     -> 1.11   
#	drivers/scsi/aha1542.c	1.23    -> 1.25   
#	 drivers/net/de620.c	1.15    -> 1.16   
#	net/decnet/af_decnet.c	1.22    -> 1.23   
#	arch/x86_64/ia32/ia32_ioctl.c	1.18    -> 1.22   
#	 drivers/pci/pci.ids	1.40    -> 1.41   
#	drivers/scsi/ultrastor.c	1.14    -> 1.16   
#	include/asm-arm/proc-armv/pgalloc.h	1.6     -> 1.8    
#	drivers/acpi/events/evgpeblk.c	1.4     -> 1.5    
#	drivers/scsi/pcmcia/qlogic_stub.c	1.13    -> 1.14   
#	drivers/char/serial_tx3912.c	1.9     -> 1.12   
#	drivers/video/hpfb.c	1.19    -> 1.20   
#	net/bridge/netfilter/ebt_vlan.c	1.3     -> 1.5    
#	arch/ppc/kernel/cputable.c	1.10    -> 1.11   
#	drivers/scsi/megaraid.h	1.14    -> 1.17   
#	drivers/scsi/NCR5380.h	1.5     -> 1.7    
#	drivers/isdn/hysdn/boardergo.c	1.11    -> 1.12   
#	arch/sparc64/prom/printf.c	1.2     -> 1.3    
#	include/asm-sparc64/irq.h	1.13    -> 1.15   
#	include/asm-x86_64/pgalloc.h	1.6     -> 1.8    
#	include/net/bluetooth/hci_core.h	1.10    -> 1.12   
#	drivers/net/pcmcia/ibmtr_cs.c	1.10    -> 1.12   
#	drivers/net/sun3_82586.c	1.4     -> 1.5    
#	arch/sparc/kernel/windows.c	1.3     -> 1.4    
#	include/asm-mips/pgalloc.h	1.4     -> 1.5    
#	include/linux/interrupt.h	1.21    -> 1.24   
#	   sound/oss/cmpci.c	1.18    -> 1.21   
#	       mm/oom_kill.c	1.21    -> 1.23   
#	    fs/ntfs/layout.h	1.16    -> 1.17   
#	drivers/acpi/resources/rsaddr.c	1.13    -> 1.14   
#	drivers/input/keyboard/xtkbd.c	1.7     -> 1.8    
#	     fs/isofs/rock.c	1.14    -> 1.15   
#	net/irda/irlan/irlan_common.c	1.9     -> 1.10   
#	    arch/arm/Kconfig	1.15    -> 1.18   
#	sound/oss/emu10k1/irqmgr.c	1.4     -> 1.5    
#	arch/sparc/kernel/pcic.c	1.19    -> 1.21   
#	drivers/net/au1000_eth.c	1.11    -> 1.12   
#	drivers/acpi/resources/rscalc.c	1.16    -> 1.17   
#	drivers/net/sunbmac.c	1.16    -> 1.17   
#	arch/arm/mm/proc-arm926.S	1.14    -> 1.18   
#	  drivers/md/raid1.c	1.61    -> 1.62   
#	sound/isa/gus/interwave.c	1.12    -> 1.13   
#	drivers/usb/net/usbnet.c	1.48    -> 1.51   
#	arch/arm/kernel/setup.c	1.29    -> 1.33   
#	drivers/isdn/hisax/isurf.c	1.23    -> 1.24   
#	net/bluetooth/rfcomm/tty.c	1.13    -> 1.19   
#	include/asm-sparc/irq.h	1.4     -> 1.6    
#	     fs/devfs/util.c	1.21    -> 1.23   
#	include/linux/percpu_counter.h	1.1     -> 1.2    
#	arch/ppc/platforms/prpmc800_setup.c	1.6     -> 1.7    
#	drivers/input/input.c	1.27    -> 1.30   
#	  arch/ppc64/Kconfig	1.14    -> 1.15   
#	    fs/cifs/cifsfs.c	1.9     -> 1.11   
#	include/acpi/acmacros.h	1.20    -> 1.21   
#	       kernel/acct.c	1.17    -> 1.18   
#	arch/ppc/xmon/nonstdio.h	1.4     -> 1.5    
#	drivers/i2c/chips/Kconfig	1.9     -> 1.10   
#	drivers/char/drm/drm_fops.h	1.9     -> 1.10   
#	arch/ppc/kernel/head.S	1.30    -> 1.31   
#	include/pcmcia/driver_ops.h	1.3     -> 1.4    
#	arch/ppc/platforms/lopec_setup.c	1.17    -> 1.19   
#	drivers/isdn/hardware/avm/c4.c	1.33    -> 1.34   
#	drivers/net/saa9730.c	1.5     -> 1.6    
#	drivers/s390/net/ctctty.c	1.8     -> 1.11   
#	arch/ia64/ia32/ia32_entry.S	1.22    -> 1.23   
#	drivers/ieee1394/nodemgr.h	1.10    -> 1.13   
#	   drivers/net/tg3.c	1.65    -> 1.68   
#	arch/i386/mm/discontig.c	1.12    -> 1.13   
#	   sound/oss/vwsnd.c	1.9     -> 1.10   
#	drivers/video/igafb.c	1.17    -> 1.18   
#	include/linux/list.h	1.25    -> 1.28   
#	    fs/ntfs/Makefile	1.69    -> 1.73   
#	net/bridge/br_private_stp.h	1.2     -> 1.3    
#	 net/ipv6/tcp_ipv6.c	1.48    -> 1.49   
#	drivers/usb/serial/kl5kusb105.c	1.21    -> 1.22   
#	 net/ipv6/af_inet6.c	1.29    -> 1.31   
#	include/asm-sparc/pgtable.h	1.15    -> 1.16   
#	sound/oss/wavfront.c	1.14    -> 1.15   
#	net/bluetooth/hci_sock.c	1.19    -> 1.20   
#	drivers/pcmcia/tcic.c	1.19    -> 1.21   
#	drivers/net/pcmcia/axnet_cs.c	1.10    -> 1.13   
#	 drivers/net/3c527.c	1.12    -> 1.13   
#	drivers/net/wireless/arlan.h	1.5     -> 1.6    
#	arch/arm/nwfpe/extended_cpdo.c	1.4     -> 1.9    
#	arch/sparc64/solaris/ioctl.c	1.7     -> 1.8    
#	arch/ppc/kernel/l2cr.S	1.6     -> 1.7    
#	 drivers/net/a2065.c	1.12    -> 1.13   
#	include/linux/netfilter_bridge.h	1.4     -> 1.5    
#	drivers/net/wireless/wavelan_cs.c	1.18    -> 1.20   
#	  drivers/net/slip.h	1.1     -> 1.2    
#	drivers/net/tokenring/tms380tr.c	1.12    -> 1.13   
#	 net/sched/sch_csz.c	1.7     -> 1.9    
#	          fs/Kconfig	1.21    -> 1.23   
#	drivers/char/mwave/mwavedd.h	1.2     -> 1.3    
#	drivers/mtd/chips/sharp.c	1.4     -> 1.5    
#	arch/sparc/kernel/time.c	1.14    -> 1.16   
#	drivers/net/amd8111e.c	1.2     -> 1.3    
#	  net/sunrpc/cache.c	1.12    -> 1.13   
#	drivers/net/hamradio/baycom_ser_fdx.c	1.8     -> 1.9    
#	drivers/block/loop.c	1.85    -> 1.86   
#	drivers/mtd/maps/iq80321.c	1.1     -> 1.2    
#	arch/i386/kernel/cpu/mcheck/k7.c	1.3     -> 1.4    
#	arch/sparc/mm/srmmu.c	1.31    -> 1.32   
#	         fs/buffer.c	1.194   -> 1.198  
#	arch/ppc/platforms/pmac_cpufreq.c	1.2     -> 1.3    
#	drivers/pnp/resource.c	1.10    -> 1.11   
#	        mm/vmalloc.c	1.23    -> 1.24   
#	drivers/ide/ide-probe.c	1.40    -> 1.41   
#	drivers/usb/core/hcd.c	1.59    -> 1.61   
#	drivers/video/logo/logo.c	1.4     -> 1.5    
#	include/linux/i2c-sensor.h	1.9     -> 1.12   
#	drivers/usb/input/hid-core.c	1.53    -> 1.54   
#	include/pcmcia/bus_ops.h	1.3     -> 1.4    
#	arch/ppc/syslib/open_pic.c	1.23    -> 1.24   
#	drivers/scsi/dmx3191d.c	1.10    -> 1.11   
#	arch/sparc64/kernel/pci_psycho.c	1.20    -> 1.22   
#	arch/ppc/platforms/apus_setup.c	1.18    -> 1.19   
#	include/asm-sh/serial.h	1.3     -> 1.4    
#	 drivers/char/epca.c	1.19    -> 1.22   
#	include/acpi/actypes.h	1.24    -> 1.25   
#	drivers/usb/serial/belkin_sa.c	1.33    -> 1.34   
#	drivers/media/video/meye.c	1.14    -> 1.16   
#	include/linux/serio.h	1.13    -> 1.14   
#	include/linux/miscdevice.h	1.5     -> 1.7    
#	drivers/scsi/aacraid/sa.c	1.1     -> 1.3    
#	arch/arm/mm/fault-common.c	1.16    -> 1.17   
#	drivers/acpi/events/evgpe.c	1.11    -> 1.12   
#	drivers/net/declance.c	1.14    -> 1.15   
#	  drivers/scsi/ppa.c	1.19    -> 1.20   
#	drivers/video/pmagb-b-fb.c	1.15    -> 1.16   
#	drivers/char/tty_io.c	1.78    -> 1.90   
#	include/asm-sparc/signal.h	1.5     -> 1.6    
#	drivers/scsi/pcmcia/fdomain_stub.c	1.14    -> 1.15   
#	   arch/m68k/Kconfig	1.11    -> 1.12   
#	 drivers/video/bw2.c	1.4     -> 1.5    
#	drivers/video/anakinfb.c	1.15    -> 1.16   
#	drivers/isdn/hardware/avm/t1isa.c	1.26    -> 1.27   
#	    net/ipv6/ndisc.c	1.30    -> 1.33   
#	drivers/usb/core/urb.c	1.16    -> 1.17   
#	sound/pci/maestro3.c	1.18    -> 1.20   
#	include/asm-arm/hardirq.h	1.8     -> 1.9    
#	 fs/jfs/jfs_txnmgr.c	1.42    -> 1.43   
#	            fs/bio.c	1.41    -> 1.42   
#	     fs/proc/array.c	1.46    -> 1.47   
#	  drivers/net/ni52.c	1.10    -> 1.11   
#	sound/isa/gus/gusmax.c	1.6     -> 1.7    
#	 drivers/net/de600.h	1.1     -> 1.2    
#	 drivers/char/pcxx.c	1.7     -> 1.10   
#	drivers/ieee1394/amdtp.c	1.10    -> 1.11   
#	     net/sctp/ipv6.c	1.32    -> 1.34   
#	         MAINTAINERS	1.133   -> 1.136  
#	sound/pci/intel8x0.c	1.31    -> 1.33   
#	 net/sctp/protocol.c	1.40    -> 1.41   
#	drivers/s390/char/tubfs.c	1.15    -> 1.16   
#	fs/reiserfs/journal.c	1.67    -> 1.68   
#	 arch/parisc/Kconfig	1.11    -> 1.12   
#	    net/irda/irttp.c	1.12    -> 1.13   
#	sound/isa/es1688/es1688_lib.c	1.7     -> 1.9    
#	drivers/net/sundance.c	1.39    -> 1.41   
#	    fs/smbfs/proto.h	1.8     -> 1.9    
#	drivers/pcmcia/rsrc_mgr.c	1.13    -> 1.15   
#	      net/core/dst.c	1.8     -> 1.9    
#	drivers/pcmcia/yenta.c	1.21    -> 1.22   
#	drivers/video/tx3912fb.c	1.19    -> 1.20   
#	drivers/ieee1394/nodemgr.c	1.25    -> 1.28   
#	drivers/char/rio/rio_linux.c	1.17    -> 1.19   
#	include/asm-s390/pgalloc.h	1.10    -> 1.11   
#	arch/ia64/ia32/sys_ia32.c	1.49    -> 1.50   
#	net/irda/irlap_event.c	1.19    -> 1.20   
#	drivers/scsi/scsi_debug.c	1.31    -> 1.32   
#	  drivers/block/rd.c	1.70    -> 1.73   
#	include/linux/cpufreq.h	1.22    -> 1.23   
#	include/linux/iso_fs.h	1.10    -> 1.11   
#	sound/oss/msnd_pinnacle.c	1.10    -> 1.11   
#	  sound/oss/ad1848.c	1.19    -> 1.20   
#	 drivers/cdrom/mcd.c	1.31    -> 1.32   
#	include/acpi/aclocal.h	1.28    -> 1.29   
#	drivers/char/istallion.c	1.17    -> 1.20   
#	drivers/media/video/msp3400.c	1.16    -> 1.17   
#	       net/atm/lec.c	1.16    -> 1.17   
#	drivers/video/neofb.c	1.28    -> 1.29   
#	fs/partitions/msdos.c	1.18    -> 1.19   
#	arch/alpha/kernel/core_mcpcia.c	1.5     -> 1.6    
#	arch/sparc/mm/loadmmu.c	1.1     -> 1.2    
#	drivers/ieee1394/eth1394.c	1.9     -> 1.11   
#	  sound/oss/ymfpci.c	1.31    -> 1.32   
#	           mm/mmap.c	1.77    -> 1.79   
#	include/asm-i386/arch_hooks.h	1.2     -> 1.3    
#	drivers/ieee1394/dv1394-private.h	1.8     -> 1.9    
#	sound/oss/uart6850.c	1.7     -> 1.8    
#	 drivers/scsi/gdth.c	1.22    -> 1.26   
#	drivers/char/watchdog/acquirewdt.c	1.20    -> 1.21   
#	drivers/char/watchdog/w83877f_wdt.c	1.15    -> 1.16   
#	   sound/oss/nm256.h	1.3     -> 1.4    
#	 net/sched/sch_htb.c	1.8     -> 1.10   
#	include/linux/time.h	1.11    -> 1.13   
#	  net/unix/af_unix.c	1.39    -> 1.41   
#	drivers/message/i2o/i2o_core.c	1.18    -> 1.19   
#	drivers/video/sstfb.c	1.24    -> 1.25   
#	drivers/acpi/utilities/utdebug.c	1.16    -> 1.17   
#	drivers/media/video/zr36120_mem.c	1.2     -> 1.4    
#	arch/sparc64/kernel/sys_sparc32.c	1.72    -> 1.73   
#	include/linux/tty_driver.h	1.5     -> 1.6    
#	drivers/char/drm/drm_dma.h	1.12    -> 1.14   
#	drivers/net/typhoon.c	1.2     -> 1.4    
#	drivers/char/watchdog/wdt_pci.c	1.21    -> 1.22   
#	include/asm-arm/arch-pxa/pxa-regs.h	1.5     -> 1.6    
#	drivers/net/wireless/arlan.c	1.16    -> 1.17   
#	drivers/net/tokenring/ibmtr.c	1.12    -> 1.14   
#	include/sound/es1688.h	1.1     -> 1.2    
#	include/net/irda/irport.h	1.1     -> 1.3    
#	sound/pci/trident/trident_main.c	1.16    -> 1.19   
#	drivers/usb/class/cdc-acm.c	1.36    -> 1.38   
#	drivers/usb/misc/rio500.c	1.19    -> 1.20   
#	Documentation/eisa.txt	1.1     -> 1.2    
#	 drivers/net/pppoe.c	1.23    -> 1.24   
#	sound/isa/ad1816a/ad1816a_lib.c	1.7     -> 1.9    
#	net/irda/irias_object.c	1.13    -> 1.14   
#	drivers/isdn/hisax/hscx.h	1.10    -> 1.11   
#	drivers/usb/serial/io_tables.h	1.10    -> 1.11   
#	arch/arm/mach-clps711x/fortunet.c	1.3     -> 1.4    
#	arch/sh/kernel/setup.c	1.12    -> 1.14   
#	  sound/oss/sscape.c	1.7     -> 1.9    
#	 drivers/video/cg3.c	1.4     -> 1.5    
#	arch/mips/baget/vacserial.c	1.8     -> 1.12   
#	arch/arm/mm/proc-arm720.S	1.15    -> 1.19   
#	arch/arm/mm/mm-armv.c	1.17    -> 1.19   
#	  sound/isa/sb/sb8.c	1.9     -> 1.11   
#	drivers/scsi/eata_pio.c	1.13    -> 1.16   
#	drivers/net/ariadne.c	1.10    -> 1.11   
#	drivers/isdn/sc/interrupt.c	1.7     -> 1.8    
#	sound/oss/cs46xx_wrapper-24.h	1.2     -> 1.3    
#	drivers/net/rclanmtl.c	1.3     -> 1.6    
#	arch/sparc64/kernel/auxio.c	1.3     -> 1.4    
#	drivers/char/drm/radeon_drm.h	1.12    -> 1.13   
#	drivers/net/eepro100.c	1.59    -> 1.60   
#	drivers/media/video/bttv-vbi.c	1.6     -> 1.7    
#	drivers/char/drm/drm_lock.h	1.7     -> 1.8    
#	drivers/net/sk_mca.c	1.9     -> 1.10   
#	drivers/usb/serial/keyspan_pda.c	1.29    -> 1.30   
#	sound/oss/vidc_fill.S	1.4     -> 1.5    
#	drivers/net/rrunner.h	1.3     -> 1.4    
#	net/irda/irlmp_frame.c	1.8     -> 1.9    
#	include/asm-sparc64/svr4.h	1.1     -> 1.2    
#	net/sctp/sm_sideeffect.c	1.36    -> 1.37   
#	arch/ppc/platforms/pmac_setup.c	1.26    -> 1.29   
#	   kernel/resource.c	1.9     -> 1.10   
#	drivers/net/ac3200.c	1.11    -> 1.12   
#	drivers/scsi/pci2000.c	1.13    -> 1.15   
#	net/ipv4/netfilter/ip_conntrack_amanda.c	1.2     -> 1.3    
#	arch/s390/kernel/compat_ioctl.c	1.1     -> 1.2    
#	  sound/pci/cmipci.c	1.20    -> 1.23   
#	drivers/acpi/events/evregion.c	1.16    -> 1.17   
#	drivers/acpi/dispatcher/dsfield.c	1.17    -> 1.18   
#	drivers/isdn/hisax/avma1_cs.c	1.3     -> 1.4    
#	include/asm-i386/irq.h	1.8     -> 1.9    
#	arch/arm/def-configs/shark	1.12    -> 1.13   
#	drivers/cdrom/sjcd.c	1.25    -> 1.26   
#	arch/ppc/platforms/k2_setup.c	1.8     -> 1.9    
#	drivers/isdn/hisax/hisax.h	1.49    -> 1.50   
#	drivers/isdn/hisax/telespci.c	1.23    -> 1.24   
#	drivers/usb/serial/mct_u232.c	1.36    -> 1.37   
#	drivers/net/irda/irport.c	1.14    -> 1.15   
#	drivers/scsi/sym53c8xx.c	1.32    -> 1.33   
#	net/packet/af_packet.c	1.21    -> 1.22   
#	drivers/char/drm/i830_drv.h	1.7     -> 1.9    
#	drivers/serial/serial98.c	1.1     -> 1.3    
#	       fs/ntfs/mft.c	1.69    -> 1.70   
#	arch/cris/drivers/serial.c	1.14    -> 1.17   
#	drivers/net/pcmcia/fmvj18x_cs.c	1.16    -> 1.19   
#	arch/i386/kernel/timers/timer_tsc.c	1.17    -> 1.19   
#	drivers/block/paride/pf.c	1.39    -> 1.40   
#	drivers/usb/media/stv680.c	1.24    -> 1.26   
#	arch/mips64/mm/init.c	1.7     -> 1.8    
#	arch/sparc64/kernel/pci_schizo.c	1.23    -> 1.24   
#	 mm/page-writeback.c	1.61    -> 1.62   
#	          fs/dquot.c	1.59    -> 1.60   
#	  sound/core/sound.c	1.24    -> 1.25   
#	arch/ppc/platforms/mcpn765_setup.c	1.9     -> 1.11   
#	drivers/scsi/qlogicpti.c	1.17    -> 1.18   
#	drivers/net/pcmcia/smc91c92_cs.c	1.14    -> 1.17   
#	arch/arm/nwfpe/fpa11_cprt.c	1.4     -> 1.7    
#	  sound/core/sgbuf.c	1.3     -> 1.4    
#	net/ipv4/tcp_output.c	1.26    -> 1.27   
#	drivers/usb/serial/keyspan.h	1.17    -> 1.18   
#	arch/i386/kernel/timers/timer_cyclone.c	1.6     -> 1.8    
#	net/irda/irnet/irnet.h	1.16    -> 1.17   
#	arch/x86_64/kernel/time.c	1.14    -> 1.15   
#	drivers/video/sis/sis_main.c	1.20    -> 1.21   
#	net/bluetooth/bnep/core.c	1.15    -> 1.16   
#	include/asm-ppc/delay.h	1.6     -> 1.7    
#	    fs/ntfs/unistr.c	1.18    -> 1.20   
#	drivers/char/mxser.c	1.18    -> 1.21   
#	drivers/input/joystick/warrior.c	1.10    -> 1.11   
#	   net/core/pktgen.c	1.2     -> 1.3    
#	drivers/scsi/psi240i.c	1.6     -> 1.9    
#	include/asm-sparc64/ns87303.h	1.2     -> 1.3    
#	include/asm-m68k/irq.h	1.3     -> 1.4    
#	arch/mips/kernel/irixioctl.c	1.2     -> 1.3    
#	  sound/pci/es1938.c	1.16    -> 1.19   
#	net/bluetooth/l2cap.c	1.21    -> 1.23   
#	drivers/s390/char/tape.h	1.7     -> 1.8    
#	drivers/video/matrox/matroxfb_base.c	1.33    -> 1.34   
#	drivers/isdn/hardware/avm/b1dma.c	1.22    -> 1.23   
#	include/asm-sh/serial-bigsur.h	1.1     -> 1.2    
#	drivers/s390/char/con3215.c	1.15    -> 1.19   
#	drivers/video/console/fbcon.c	1.99    -> 1.100  
#	drivers/cdrom/cdu31a.c	1.35    -> 1.36   
#	drivers/char/watchdog/sbc60xxwdt.c	1.23    -> 1.24   
#	drivers/acpi/resources/rsxface.c	1.14    -> 1.15   
#	drivers/ide/legacy/ide-cs.c	1.8     -> 1.9    
#	     fs/ntfs/super.c	1.123   -> 1.129  
#	drivers/char/rocket.c	1.15    -> 1.19   
#	drivers/video/aty/atyfb_base.c	1.54    -> 1.55   
#	arch/m68knommu/Kconfig	1.8     -> 1.9    
#	drivers/input/mouse/sermouse.c	1.9     -> 1.10   
#	  net/llc/llc_s_ev.c	1.5     -> 1.6    
#	arch/sparc/kernel/auxio.c	1.1     -> 1.2    
#	drivers/media/video/tda9840.c	1.1     -> 1.2    
#	drivers/net/wan/farsync.c	1.13    -> 1.15   
#	arch/alpha/kernel/core_irongate.c	1.10    -> 1.11   
#	sound/oss/pas2_card.c	1.6     -> 1.7    
#	arch/ppc64/kernel/sys_ppc32.c	1.57    -> 1.58   
#	arch/sparc/kernel/signal.c	1.21    -> 1.22   
#	drivers/media/video/cpia.c	1.22    -> 1.24   
#	  drivers/net/8390.h	1.8     -> 1.9    
#	  sound/pci/es1968.c	1.20    -> 1.23   
#	drivers/net/fealnx.c	1.24    -> 1.25   
#	arch/sparc/kernel/wof.S	1.3     -> 1.4    
#	drivers/video/riva/fbdev.c	1.44    -> 1.45   
#	drivers/net/wireless/strip.c	1.10    -> 1.12   
#	drivers/video/tgafb.c	1.23    -> 1.24   
#	 drivers/net/82596.c	1.13    -> 1.14   
#	sound/pci/sonicvibes.c	1.13    -> 1.16   
#	drivers/scsi/fdomain.c	1.19    -> 1.21   
#	 init/do_mounts_rd.c	1.2     -> 1.4    
#	drivers/isdn/sc/init.c	1.5     -> 1.6    
#	drivers/media/video/tda7432.c	1.9     -> 1.10   
#	drivers/video/p9100.c	1.4     -> 1.5    
#	drivers/net/wireless/wavelan.p.h	1.10    -> 1.11   
#	drivers/sbus/char/openprom.c	1.12    -> 1.13   
#	drivers/media/common/saa7146_core.c	1.1     -> 1.2    
#	drivers/ide/legacy/hd98.c	1.2     -> 1.4    
#	drivers/isdn/i4l/isdn_tty.c	1.44    -> 1.47   
#	drivers/char/sonypi.c	1.15    -> 1.16   
#	include/linux/timer.h	1.13    -> 1.14   
#	drivers/s390/block/dasd_int.h	1.15    -> 1.17   
#	net/ipv6/ipv6_syms.c	1.11    -> 1.12   
#	drivers/usb/net/kaweth.c	1.38    -> 1.39   
#	  drivers/net/7990.c	1.8     -> 1.9    
#	  drivers/scsi/dtc.c	1.8     -> 1.9    
#	include/linux/netfilter_ipv4/ipt_physdev.h	1.1     -> 1.2    
#	drivers/net/wan/z85230.h	1.3     -> 1.4    
#	include/asm-sparc64/chafsr.h	1.1     -> 1.2    
#	 drivers/net/3c505.h	1.1     -> 1.2    
#	     kernel/module.c	1.78    -> 1.80   
#	   net/core/skbuff.c	1.24    -> 1.25   
#	include/asm-i386/cpufeature.h	1.7     -> 1.8    
#	sound/pci/emu10k1/irq.c	1.3     -> 1.6    
#	drivers/ieee1394/dv1394.c	1.26    -> 1.29   
#	drivers/i2c/busses/i2c-viapro.c	1.1     -> 1.2    
#	drivers/scsi/qlogicfc.c	1.30    -> 1.31   
#	arch/ppc64/kernel/iSeries_setup.c	1.10    -> 1.11   
#	drivers/input/evdev.c	1.21    -> 1.24   
#	arch/ppc/8xx_io/uart.c	1.19    -> 1.24   
#	drivers/scsi/in2000.c	1.16    -> 1.18   
#	arch/arm/nwfpe/fpa11_cpdo.c	1.3     -> 1.10   
#	include/net/pkt_cls.h	1.1     -> 1.2    
#	arch/arm/mach-iop3xx/iq80310-time.c	1.9     -> 1.10   
#	     net/core/sock.c	1.21    -> 1.23   
#	drivers/net/wan/sdlamain.c	1.15    -> 1.16   
#	    sound/oss/maui.c	1.4     -> 1.5    
#	include/linux/devfs_fs_kernel.h	1.39    -> 1.44   
#	drivers/ieee1394/ieee1394_types.h	1.15    -> 1.16   
#	drivers/char/drm/drmP.h	1.19    -> 1.23   
#	net/irda/irnet/irnet_ppp.c	1.11    -> 1.12   
#	drivers/usb/net/Kconfig	1.3     -> 1.4    
#	 drivers/net/eepro.c	1.16    -> 1.17   
#	drivers/isdn/pcbit/layer2.c	1.6     -> 1.7    
#	drivers/net/ppp_async.c	1.9     -> 1.10   
#	include/asm-arm/bugs.h	1.1     -> 1.2    
#	drivers/media/video/tea6415c.c	1.1     -> 1.2    
#	arch/mips64/kernel/scall_o32.S	1.7     -> 1.8    
#	drivers/net/pcmcia/Kconfig	1.4     -> 1.5    
#	  net/irda/wrapper.c	1.5     -> 1.6    
#	include/asm-ppc/bug.h	1.1     -> 1.2    
#	sound/oss/nec_vrc5477.c	1.11    -> 1.13   
#	   net/ipv4/ip_gre.c	1.22    -> 1.24   
#	drivers/net/hamradio/yam.c	1.14    -> 1.15   
#	drivers/s390/block/xpram.c	1.37    -> 1.38   
#	arch/mips64/sgi-ip27/ip27-pci.c	1.7     -> 1.8    
#	arch/ia64/ia32/ia32_ioctl.c	1.7     -> 1.8    
#	drivers/ieee1394/cmp.c	1.5     -> 1.6    
#	    net/ipv6/route.c	1.25    -> 1.26   
#	  sound/oss/es1371.c	1.23    -> 1.26   
#	sound/isa/wavefront/wavefront.c	1.11    -> 1.12   
#	   fs/nfs/nfs4proc.c	1.20    -> 1.21   
#	drivers/net/wan/c101.c	1.9     -> 1.11   
#	drivers/pcmcia/Kconfig	1.4     -> 1.5    
#	include/acpi/acconfig.h	1.35    -> 1.36   
#	drivers/serial/21285.c	1.16    -> 1.18   
#	net/ipv4/tcp_input.c	1.35    -> 1.36   
#	drivers/isdn/hisax/hisax_fcpcipnp.c	1.16    -> 1.17   
#	drivers/char/stallion.c	1.17    -> 1.21   
#	drivers/media/video/saa5249.c	1.13    -> 1.14   
#	drivers/usb/class/bluetty.c	1.39    -> 1.40   
#	drivers/s390/char/tape_block.c	1.3     -> 1.4    
#	drivers/net/tulip/Kconfig	1.2     -> 1.3    
#	drivers/serial/mux.c	1.4     -> 1.5    
#	arch/sparc/mm/sun4c.c	1.28    -> 1.33   
#	net/ipv4/tcp_minisocks.c	1.25    -> 1.26   
#	drivers/char/drm/i830_irq.c	1.1     -> 1.2    
#	include/asm-arm/proc-armv/tlbflush.h	1.3     -> 1.4    
#	 sound/oss/trident.c	1.37    -> 1.41   
#	sound/oss/i810_audio.c	1.34    -> 1.37   
#	     fs/ntfs/namei.c	1.32    -> 1.33   
#	 drivers/pcmcia/ds.c	1.25    -> 1.27   
#	drivers/serial/8250_pci.c	1.19    -> 1.22   
#	drivers/media/video/bttv-driver.c	1.26    -> 1.27   
#	drivers/net/smc9194.c	1.16    -> 1.17   
#	drivers/bluetooth/hci_ldisc.c	1.8     -> 1.9    
#	  arch/alpha/Kconfig	1.12    -> 1.13   
#	drivers/block/DAC960.c	1.54    -> 1.57   
#	drivers/net/gt96100eth.c	1.8     -> 1.9    
#	drivers/usb/media/pwc-if.c	1.32    -> 1.34   
#	drivers/isdn/hisax/enternow_pci.c	1.20    -> 1.21   
#	      fs/ntfs/aops.c	1.93    -> 1.94   
#	arch/arm/mm/proc-arm6_7.S	1.15    -> 1.19   
#	drivers/net/am79c961a.c	1.9     -> 1.10   
#	drivers/block/DAC960.h	1.17    -> 1.20   
#	 drivers/net/3c507.c	1.11    -> 1.12   
#	arch/sparc/prom/misc.c	1.3     -> 1.4    
#	drivers/usb/storage/unusual_devs.h	1.29    -> 1.33   
#	net/ipv4/netfilter/ip_conntrack_irc.c	1.8     -> 1.9    
#	drivers/net/tokenring/olympic.c	1.20    -> 1.21   
#	Documentation/scsi/scsi_mid_low_api.txt	1.11    -> 1.12   
#	   net/llc/llc_sap.c	1.17    -> 1.18   
#	     fs/ntfs/inode.h	1.29    -> 1.30   
#	include/asm-arm/cpu-multi26.h	1.2     -> 1.4    
#	arch/ia64/sn/io/pci_bus_cvlink.c	1.5     -> 1.6    
#	  arch/h8300/Kconfig	1.1     -> 1.2    
#	net/ipv4/netfilter/ip_conntrack_ftp.c	1.10    -> 1.11   
#	net/sched/sch_ingress.c	1.8     -> 1.12   
#	 net/core/wireless.c	1.7     -> 1.9    
#	include/linux/module.h	1.60    -> 1.62   
#	include/linux/eisa.h	1.3     -> 1.4    
#	arch/alpha/kernel/irq.c	1.19    -> 1.20   
#	     drivers/md/dm.c	1.17    -> 1.18   
#	drivers/net/tulip/xircom_cb.c	1.11    -> 1.12   
#	drivers/isdn/hardware/eicon/diva.c	1.3     -> 1.4    
#	arch/arm/mach-iop3xx/iop321-pci.c	1.1     -> 1.2    
#	net/ipv4/netfilter/ip_nat_standalone.c	1.21    -> 1.22   
#	drivers/acpi/tables/tbutils.c	1.17    -> 1.18   
#	arch/arm/mm/consistent.c	1.9     -> 1.10   
#	drivers/usb/serial/ftdi_sio.c	1.41    -> 1.42   
#	drivers/sbus/char/bbc_i2c.c	1.2     -> 1.3    
#	include/net/bluetooth/rfcomm.h	1.4     -> 1.6    
#	drivers/scsi/scsi_scan.c	1.75    -> 1.80   
#	   sound/pci/fm801.c	1.14    -> 1.17   
#	arch/v850/kernel/simcons.c	1.3     -> 1.4    
#	    fs/filesystems.c	1.13    -> 1.14   
#	 arch/x86_64/Kconfig	1.17    -> 1.18   
#	drivers/bluetooth/hci_usb.h	1.5     -> 1.6    
#	include/asm-sparc64/estate.h	1.1     -> 1.2    
#	net/ipv4/netfilter/ip_fw_compat_masq.c	1.6     -> 1.7    
#	      kernel/sched.c	1.178   -> 1.180  
#	drivers/net/rcpci45.c	1.18    -> 1.20   
#	drivers/media/video/planb.c	1.13    -> 1.15   
#	arch/ppc/platforms/4xx/oak_setup.c	1.10    -> 1.12   
#	include/asm-arm/proc-armo/pgalloc.h	1.2     -> 1.3    
#	net/bridge/br_stp_bpdu.c	1.2     -> 1.4    
#	drivers/block/paride/pd.c	1.48    -> 1.49   
#	sound/drivers/mtpav.c	1.16    -> 1.18   
#	drivers/video/hgafb.c	1.24    -> 1.25   
#	drivers/input/keyboard/atkbd.c	1.28    -> 1.29   
#	  net/sctp/adler32.c	1.6     -> 1.7    
#	arch/arm/mach-sa1100/sleep.S	1.5     -> 1.7    
#	  net/ipv6/ip6_fib.c	1.10    -> 1.11   
#	drivers/scsi/Makefile	1.40    -> 1.41   
#	drivers/net/tulip/de2104x.c	1.15    -> 1.16   
#	include/asm-arm/arch-epxa10db/ether00.h	1.1     -> 1.2    
#	drivers/block/Makefile	1.15    -> 1.16   
#	  drivers/acpi/osl.c	1.31    -> 1.34   
#	drivers/s390/char/tubtty.c	1.9     -> 1.10   
#	sound/oss/emu10k1/cardwo.c	1.9     -> 1.10   
#	        init/Kconfig	1.12    -> 1.13   
#	drivers/net/cs89x0.c	1.15    -> 1.16   
#	   net/llc/llc_mac.c	1.20    -> 1.21   
#	drivers/ieee1394/iso.c	1.3     -> 1.4    
#	  drivers/block/xd.c	1.52    -> 1.54   
#	  include/net/ipv6.h	1.8     -> 1.11   
#	include/asm-arm/arch-integrator/bits.h	1.1     -> 1.2    
#	drivers/ide/ide-io.c	1.7     -> 1.8    
#	 sound/pci/ens1370.c	1.27    -> 1.29   
#	 fs/exportfs/expfs.c	1.12    -> 1.13   
#	drivers/s390/char/tuball.c	1.10    -> 1.11   
#	arch/ppc/kernel/irq.c	1.25    -> 1.26   
#	       net/atm/mpc.c	1.9     -> 1.10   
#	      net/ipv6/udp.c	1.27    -> 1.28   
#	drivers/usb/serial/ipaq.c	1.28    -> 1.29   
#	net/ipv4/netfilter/Kconfig	1.5     -> 1.6    
#	drivers/char/drm/drm_drv.h	1.15    -> 1.17   
#	drivers/base/Makefile	1.19    -> 1.20   
#	drivers/acpi/resources/rsmemory.c	1.12    -> 1.13   
#	drivers/hotplug/cpqphp.h	1.6     -> 1.7    
#	arch/sparc64/kernel/sparc64_ksyms.c	1.45    -> 1.47   
#	include/linux/kdev_t.h	1.8     -> 1.9    
#	net/ipv4/netfilter/ipt_REJECT.c	1.13    -> 1.14   
#	   sound/oss/Kconfig	1.6     -> 1.7    
#	drivers/serial/8250_acorn.c	1.3     -> 1.4    
#	      kernel/timer.c	1.51    -> 1.52   
#	 sound/pci/via82xx.c	1.29    -> 1.31   
#	drivers/net/wireless/airo_cs.c	1.7     -> 1.8    
#	drivers/video/dnfb.c	1.22    -> 1.23   
#	drivers/net/eth16i.c	1.13    -> 1.14   
#	drivers/net/tokenring/tms380tr.h	1.5     -> 1.6    
#	drivers/video/matrox/matroxfb_crtc2.c	1.22    -> 1.23   
#	  drivers/block/xd.h	1.6     -> 1.7    
#	arch/ppc/platforms/chrp_setup.c	1.27    -> 1.30   
#	arch/ia64/hp/sim/hpsim_console.c	1.5     -> 1.6    
#	drivers/char/drm/radeon_state.c	1.19    -> 1.20   
#	drivers/media/video/tuner.c	1.16    -> 1.17   
#	drivers/input/misc/uinput.c	1.8     -> 1.9    
#	drivers/video/valkyriefb.c	1.18    -> 1.19   
#	 include/linux/blk.h	1.33    -> 1.35   
#	include/asm-mips64/pgalloc.h	1.4     -> 1.6    
#	drivers/char/ipmi/ipmi_devintf.c	1.6     -> 1.7    
#	drivers/net/pcmcia/pcnet_cs.c	1.15    -> 1.18   
#	drivers/acpi/hardware/hwregs.c	1.21    -> 1.22   
#	 drivers/base/intf.c	1.15    ->         (deleted)      
#	drivers/serial/nb85e_uart.c	1.9     -> 1.11   
#	     drivers/tc/zs.c	1.9     -> 1.14   
#	arch/i386/kernel/timers/timer_pit.c	1.11    -> 1.12   
#	   fs/cifs/cifspdu.h	1.4     -> 1.5    
#	arch/ppc/amiga/config.c	1.14    -> 1.15   
#	drivers/ieee1394/highlevel.c	1.11    -> 1.13   
#	drivers/ieee1394/ohci1394.c	1.27    -> 1.33   
#	arch/arm/mm/proc-xscale.S	1.17    -> 1.21   
#	   drivers/char/vt.c	1.39    -> 1.43   
#	arch/ppc/platforms/menf1_setup.c	1.8     -> 1.9    
#	drivers/char/hvc_console.c	1.13    -> 1.17   
#	include/video/pm3fb.h	1.4     -> 1.5    
#	arch/arm/mm/discontig.c	1.2     -> 1.3    
#	     sound/oss/gus.h	1.3     -> 1.4    
#	include/asm-cris/pgalloc.h	1.4     -> 1.5    
#	 sound/oss/uart401.c	1.7     -> 1.8    
#	 drivers/net/Kconfig	1.22    -> 1.25   
#	drivers/char/drm/drm_init.h	1.5     -> 1.6    
#	    net/ipv6/mcast.c	1.15    -> 1.18   
#	drivers/char/drm/Kconfig	1.3     -> 1.4    
#	drivers/video/amifb.c	1.24    -> 1.26   
#	include/sound/mpu401.h	1.7     -> 1.10   
#	net/sched/sch_gred.c	1.10    -> 1.11   
#	 drivers/scsi/eata.c	1.28    -> 1.30   
#	sound/pci/nm256/nm256.c	1.14    -> 1.16   
#	      net/irda/qos.c	1.11    -> 1.12   
#	drivers/usb/serial/kobil_sct.c	1.7     -> 1.8    
#	sound/pci/ymfpci/ymfpci_main.c	1.16    -> 1.19   
#	drivers/video/retz3fb.c	1.19    -> 1.20   
#	drivers/base/driver.c	1.20    -> 1.21   
#	drivers/telephony/ixj_pcmcia.c	1.4     -> 1.5    
#	arch/ppc/platforms/prep_setup.c	1.36    -> 1.40   
#	drivers/input/joystick/sidewinder.c	1.11    -> 1.12   
#	arch/ppc64/kernel/misc.S	1.54    -> 1.55   
#	net/ipv4/netfilter/iptable_mangle.c	1.12    -> 1.13   
#	drivers/char/drm/mga_dma.c	1.11    -> 1.13   
#	arch/sparc64/Kconfig	1.17    -> 1.18   
#	 drivers/video/leo.c	1.1     -> 1.2    
#	arch/sparc/kernel/rtrap.S	1.8     -> 1.9    
#	 sound/oss/maestro.c	1.25    -> 1.28   
#	drivers/video/cirrusfb.c	1.21    -> 1.22   
#	     fs/cifs/CHANGES	1.10    -> 1.14   
#	arch/arm/mm/proc-arm922.S	1.12    -> 1.16   
#	Documentation/filesystems/Locking	1.40    -> 1.41   
#	  net/llc/llc_s_ac.c	1.5     -> 1.6    
#	drivers/isdn/hardware/avm/b1.c	1.20    -> 1.21   
#	drivers/usb/host/uhci-hcd.c	1.32    -> 1.33   
#	arch/um/drivers/line.c	1.13    -> 1.16   
#	drivers/char/specialix.c	1.10    -> 1.14   
#	arch/sparc64/kernel/power.c	1.10    -> 1.12   
#	    net/ax25/Kconfig	1.2     -> 1.3    
#	arch/arm/mach-pxa/sleep.S	1.1     -> 1.2    
#	net/bridge/br_stp_if.c	1.3     -> 1.6    
#	drivers/char/drm/mga_drv.h	1.12    -> 1.13   
#	drivers/net/tulip/dmfe.c	1.28    -> 1.30   
#	drivers/pcmcia/i82365.c	1.27    -> 1.29   
#	drivers/isdn/hisax/w6692.c	1.51    -> 1.52   
#	sound/oss/maestro3.c	1.23    -> 1.26   
#	include/acpi/acinterp.h	1.21    -> 1.22   
#	include/asm-sparc/ptrace.h	1.2     -> 1.3    
#	arch/sparc64/kernel/ioctl32.c	1.56    -> 1.60   
#	drivers/char/drm/radeon.h	1.10    -> 1.11   
#	drivers/scsi/pcmcia/aha152x_stub.c	1.13    -> 1.14   
#	net/bridge/netfilter/ebtable_filter.c	1.4     -> 1.5    
#	drivers/input/serio/serport.c	1.10    -> 1.11   
#	arch/ppc/platforms/pmac_pic.c	1.17    -> 1.18   
#	     fs/ext3/super.c	1.58    -> 1.60   
#	  sound/oss/ad1816.c	1.10    -> 1.11   
#	drivers/scsi/Kconfig	1.18    -> 1.20   
#	drivers/net/wireless/orinoco_cs.c	1.17    -> 1.19   
#	drivers/parport/parport_serial.c	1.9     -> 1.10   
#	 drivers/scsi/t128.c	1.9     -> 1.10   
#	drivers/char/drm/gamma_drv.c	1.7     -> 1.8    
#	drivers/scsi/tmscsim.h	1.2     -> 1.3    
#	drivers/cdrom/cm206.c	1.31    -> 1.32   
#	 drivers/net/pppox.c	1.9     -> 1.12   
#	net/irda/ircomm/ircomm_tty_attach.c	1.9     -> 1.10   
#	arch/arm/kernel/process.c	1.26    -> 1.28   
#	include/linux/device.h	1.86    -> 1.87   
#	drivers/macintosh/via-pmu.c	1.18    -> 1.19   
#	include/asm-arm/elf.h	1.4     -> 1.5    
#	   fs/cifs/connect.c	1.13    -> 1.14   
#	drivers/media/video/stradis.c	1.13    -> 1.15   
#	arch/alpha/kernel/srmcons.c	1.1     -> 1.2    
#	arch/alpha/mm/init.c	1.15    -> 1.16   
#	drivers/net/wireless/wavelan.c	1.14    -> 1.15   
#	     fs/ntfs/inode.c	1.102   -> 1.104  
#	drivers/isdn/hardware/avm/avmcard.h	1.15    -> 1.16   
#	       lib/kobject.c	1.19    -> 1.20   
#	    net/irda/irlmp.c	1.23    -> 1.24   
#	drivers/pci/Makefile	1.25    -> 1.26   
#	arch/ppc/kernel/ppc_ksyms.c	1.37    -> 1.38   
#	drivers/char/drm/gamma_drm.h	1.4     -> 1.5    
#	fs/partitions/check.c	1.104   -> 1.108  
#	drivers/char/drm/drm_os_linux.h	1.9     -> 1.10   
#	drivers/media/video/adv7175.c	1.10    -> 1.12   
#	arch/ppc/platforms/pmac_feature.c	1.16    -> 1.17   
#	drivers/input/mousedev.c	1.21    -> 1.24   
#	drivers/char/watchdog/ib700wdt.c	1.13    -> 1.14   
#	   arch/cris/Kconfig	1.6     -> 1.7    
#	arch/ppc/platforms/pal4_setup.c	1.4     -> 1.5    
#	fs/xfs/linux/xfs_super.c	1.34    -> 1.35   
#	drivers/serial/Kconfig	1.7     -> 1.8    
#	  net/ax25/af_ax25.c	1.19    -> 1.20   
#	drivers/net/sb1250-mac.c	1.3     -> 1.4    
#	 net/netrom/nr_dev.c	1.5     -> 1.6    
#	include/asm-x86_64/msr.h	1.4     -> 1.5    
#	drivers/net/sgiseeq.c	1.13    -> 1.14   
#	sound/isa/gus/gus_irq.c	1.3     -> 1.5    
#	include/asm-arm/proc-armv/locks.h	1.3     -> 1.4    
#	drivers/char/drm/gamma_dma.c	1.10    -> 1.12   
#	drivers/cdrom/aztcd.c	1.28    -> 1.29   
#	arch/i386/mm/hugetlbpage.c	1.33    -> 1.35   
#	drivers/sbus/char/cpwatchdog.c	1.8     -> 1.10   
#	arch/i386/kernel/i8259.c	1.21    -> 1.22   
#	  sound/oss/mpu401.c	1.11    -> 1.12   
#	include/asm-v850/irq.h	1.2     -> 1.3    
#	arch/arm/nwfpe/fpmodule.inl	1.3     -> 1.4    
#	 drivers/char/misc.c	1.16    -> 1.18   
#	 net/sched/sch_sfq.c	1.8     -> 1.9    
#	arch/sparc64/kernel/irq.c	1.28    -> 1.29   
#	drivers/net/arcnet/Kconfig	1.3     -> 1.4    
#	    net/irda/irlap.c	1.17    -> 1.18   
#	drivers/net/tulip/tulip.h	1.13    -> 1.14   
#	arch/sparc/kernel/trampoline.S	1.3     -> 1.4    
#	 net/ipv6/addrconf.c	1.35    -> 1.38   
#	sound/pci/ali5451/ali5451.c	1.23    -> 1.26   
#	drivers/char/applicom.c	1.8     -> 1.9    
#	arch/ia64/kernel/perfmon.c	1.39    -> 1.41   
#	drivers/char/drm/radeon_irq.c	1.8     -> 1.10   
#	drivers/usb/input/usbmouse.c	1.24    -> 1.25   
#	drivers/scsi/3w-xxxx.c	1.28    -> 1.31   
#	 sound/pci/als4000.c	1.10    -> 1.12   
#	 drivers/char/moxa.c	1.14    -> 1.17   
#	drivers/bluetooth/hci_usb.c	1.21    -> 1.26   
#	drivers/char/drm/i810_drv.h	1.8     -> 1.10   
#	drivers/isdn/hisax/diva.c	1.40    -> 1.41   
#	drivers/char/watchdog/wafer5823wdt.c	1.5     -> 1.6    
#	arch/v850/kernel/memcons.c	1.2     -> 1.3    
#	arch/ppc/kernel/smp.c	1.31    -> 1.32   
#	drivers/usb/Makefile	1.40    -> 1.41   
#	 net/atm/resources.c	1.7     -> 1.8    
#	drivers/isdn/hisax/hfcscard.c	1.16    -> 1.17   
#	drivers/net/tokenring/madgemc.c	1.12    -> 1.13   
#	arch/sparc64/kernel/sunos_ioctl32.c	1.3     -> 1.4    
#	arch/ppc/kernel/setup.c	1.35    -> 1.37   
#	 drivers/mca/Kconfig	1.2     -> 1.3    
#	   arch/ia64/Kconfig	1.19    -> 1.20   
#	drivers/net/pcmcia/3c589_cs.c	1.13    -> 1.16   
#	arch/m68k/kernel/setup.c	1.18    -> 1.19   
#	drivers/scsi/BusLogic.c	1.15    -> 1.17   
#	drivers/isdn/hisax/ipac.h	1.6     -> 1.7    
#	drivers/net/wan/pc300_drv.c	1.9     -> 1.10   
#	drivers/char/n_r3964.c	1.11    -> 1.12   
#	drivers/scsi/nsp32_io.h	1.1     -> 1.3    
#	include/asm-arm/sizes.h	1.2     -> 1.3    
#	  sound/pci/cs4281.c	1.23    -> 1.26   
#	 include/pcmcia/ss.h	1.10    -> 1.11   
#	    net/x25/af_x25.c	1.23    -> 1.24   
#	drivers/video/cg14.c	1.4     -> 1.5    
#	arch/sparc64/solaris/misc.c	1.13    -> 1.14   
#	include/asm-sparc64/pgalloc.h	1.18    -> 1.20   
#	net/decnet/dn_route.c	1.13    -> 1.14   
#	drivers/atm/iphase.c	1.17    -> 1.18   
#	arch/ppc/platforms/pplus_setup.c	1.13    -> 1.15   
#	drivers/video/pmag-ba-fb.c	1.16    -> 1.17   
#	drivers/isdn/capi/capi.c	1.38    -> 1.40   
#	drivers/usb/input/usbkbd.c	1.27    -> 1.28   
#	drivers/input/tsdev.c	1.7     -> 1.10   
#	drivers/char/sh-sci.c	1.14    -> 1.18   
#	   drivers/pci/bus.c	1.2     -> 1.3    
#	include/asm-x86_64/vsyscall.h	1.4     -> 1.5    
#	drivers/video/acornfb.c	1.22    -> 1.23   
#	arch/arm/nwfpe/single_cpdo.c	1.4     -> 1.9    
#	drivers/serial/68360serial.c	1.8     -> 1.12   
#	drivers/net/sungem.c	1.33    -> 1.34   
#	arch/i386/kernel/cpu/amd.c	1.12    -> 1.13   
#	drivers/acpi/namespace/nsaccess.c	1.20    -> 1.21   
#	      fs/cifs/misc.c	1.6     -> 1.7    
#	arch/parisc/kernel/setup.c	1.6     -> 1.7    
#	 drivers/net/sonic.c	1.4     -> 1.5    
#	arch/arm/nwfpe/fpa11_cpdt.c	1.4     -> 1.7    
#	net/bridge/br_netfilter.c	1.5     -> 1.9    
#	arch/sparc/lib/Makefile	1.4     -> 1.5    
#	drivers/char/drm/i810_drv.c	1.7     -> 1.8    
#	include/asm-sparc64/upa.h	1.2     -> 1.3    
#	include/net/if_inet6.h	1.4     -> 1.6    
#	drivers/video/radeonfb.c	1.25    -> 1.26   
#	drivers/block/cciss.c	1.79    -> 1.81   
#	          fs/quota.c	1.13    -> 1.14   
#	drivers/net/ns83820.c	1.20    -> 1.21   
#	include/asm-parisc/pgalloc.h	1.6     -> 1.8    
#	  sound/sound_core.c	1.16    -> 1.17   
#	drivers/parport/parport_pc.c	1.37    -> 1.38   
#	drivers/macintosh/macserial.c	1.14    -> 1.20   
#	drivers/usb/serial/io_ti.c	1.15    -> 1.16   
#	drivers/net/wan/comx-hw-mixcom.c	1.8     -> 1.9    
#	sound/isa/ad1848/ad1848_lib.c	1.12    -> 1.14   
#	drivers/net/isa-skeleton.c	1.9     -> 1.10   
#	drivers/serial/68328serial.c	1.4     -> 1.8    
#	sound/oss/emu10k1/main.c	1.14    -> 1.15   
#	drivers/block/paride/pcd.c	1.33    -> 1.34   
#	drivers/net/wireless/netwave_cs.c	1.13    -> 1.15   
#	drivers/isdn/hisax/hscx_irq.c	1.18    -> 1.19   
#	 drivers/net/de600.c	1.16    -> 1.17   
#	drivers/video/offb.c	1.25    -> 1.26   
#	arch/sparc/kernel/tick14.c	1.3     -> 1.4    
#	drivers/net/hamradio/mkiss.c	1.8     -> 1.9    
#	drivers/isdn/hisax/sedlbauer.c	1.34    -> 1.35   
#	drivers/net/via-rhine.c	1.38    -> 1.40   
#	 drivers/net/ewrk3.c	1.23    -> 1.24   
#	arch/sparc64/kernel/pci_sabre.c	1.22    -> 1.23   
#	drivers/video/S3triofb.c	1.13    -> 1.14   
#	net/decnet/dn_nsp_out.c	1.6     -> 1.7    
#	 sound/isa/opl3sa2.c	1.16    -> 1.18   
#	drivers/usb/class/audio.c	1.34    -> 1.36   
#	net/wanrouter/af_wanpipe.c	1.19    -> 1.21   
#	include/asm-x86_64/processor.h	1.14    -> 1.15   
#	drivers/acpi/dispatcher/dswexec.c	1.18    -> 1.19   
#	drivers/char/ftape/lowlevel/ftape-ctl.c	1.5     -> 1.6    
#	arch/sparc64/kernel/ptrace.c	1.19    -> 1.20   
#	  net/llc/llc_c_ac.c	1.19    -> 1.20   
#	include/asm-arm/arch-tbox/irqs.h	1.1     -> 1.2    
#	arch/sparc/mm/iommu.c	1.10    -> 1.11   
#	drivers/md/dm-table.c	1.13    -> 1.14   
#	drivers/scsi/qlogicisp.c	1.18    -> 1.19   
#	drivers/usb/serial/empeg.c	1.36    -> 1.37   
#	     net/ipv4/igmp.c	1.20    -> 1.22   
#	net/ipv4/ip_output.c	1.31    -> 1.34   
#	    arch/ppc/Kconfig	1.19    -> 1.20   
#	drivers/scsi/pcmcia/nsp_cs.c	1.19    -> 1.20   
#	  drivers/scsi/esp.c	1.23    -> 1.24   
#	drivers/acpi/namespace/nsxfeval.c	1.10    -> 1.11   
#	sound/isa/sb/sb_common.c	1.9     -> 1.10   
#	drivers/net/tokenring/3c359.c	1.7     -> 1.8    
#	include/asm-ia64/irq.h	1.3     -> 1.4    
#	net/bridge/netfilter/ebtable_nat.c	1.4     -> 1.5    
#	drivers/scsi/wd7000.c	1.20    -> 1.22   
#	drivers/ieee1394/Makefile	1.17    -> 1.18   
#	arch/sparc/kernel/ioport.c	1.10    -> 1.11   
#	drivers/parport/parport_cs.c	1.6     -> 1.7    
#	arch/mips/kernel/gdb-stub.c	1.4     -> 1.5    
#	include/linux/vmalloc.h	1.8     -> 1.9    
#	 net/sched/sch_red.c	1.5     -> 1.7    
#	drivers/bluetooth/btuart_cs.c	1.4.1.1 -> 1.7    
#	  net/bridge/br_if.c	1.8     -> 1.11   
#	          fs/inode.c	1.91    -> 1.93   
#	drivers/pcmcia/pci_socket.c	1.15    -> 1.16   
#	     arch/sh/Kconfig	1.8     -> 1.9    
#	drivers/serial/sunzilog.c	1.27    -> 1.30   
#	drivers/media/video/zr36067.c	1.15    -> 1.18   
#	include/linux/nfsd/syscall.h	1.6     -> 1.7    
#	    net/ipv4/route.c	1.45    -> 1.46   
#	   sound/pci/rme32.c	1.16    -> 1.17   
#	sound/oss/cs4281/cs4281m.c	1.18    -> 1.21   
#	drivers/base/class.c	1.25    -> 1.26   
#	drivers/bluetooth/bt3c_cs.c	1.10    -> 1.12   
#	net/bluetooth/hci_conn.c	1.7     -> 1.8    
#	drivers/sbus/char/uctrl.c	1.9     -> 1.10   
#	include/asm-sparc64/bpp.h	1.1     -> 1.2    
#	  sound/oss/es1370.c	1.21    -> 1.24   
#	include/asm-alpha/irq.h	1.6     -> 1.7    
#	drivers/macintosh/macio-adb.c	1.3     -> 1.4    
#	include/linux/slab.h	1.18    -> 1.20   
#	drivers/atm/fore200e.c	1.12    -> 1.13   
#	   drivers/net/atp.c	1.13    -> 1.14   
#	drivers/acpi/resources/rsirq.c	1.14    -> 1.15   
#	include/asm-arm/arch-sa1100/graphicsclient.h	1.3     -> 1.4    
#	include/linux/dcache.h	1.30    -> 1.31   
#	drivers/base/memblk.c	1.6     -> 1.7    
#	drivers/block/scsi_ioctl.c	1.22    -> 1.24   
#	drivers/block/umem.c	1.36    -> 1.39   
#	include/asm-sparc/processor.h	1.12    -> 1.13   
#	drivers/scsi/qla1280.h	1.13    -> 1.14   
#	arch/parisc/kernel/syscall.S	1.11    -> 1.12   
#	 arch/i386/pci/irq.c	1.22    -> 1.23   
#	 net/appletalk/ddp.c	1.18    -> 1.19   
#	   fs/proc/generic.c	1.20    -> 1.21   
#	drivers/scsi/sym53c8xx_2/sym53c8xx.h	1.7     -> 1.8    
#	  net/core/profile.c	1.4     -> 1.5    
#	include/asm-ppc64/irq.h	1.2     -> 1.3    
#	     kernel/printk.c	1.24    -> 1.25   
#	drivers/net/hamachi.c	1.23    -> 1.24   
#	include/linux/isdn.h	1.80    -> 1.81   
#	     net/802/psnap.c	1.7     -> 1.8    
#	include/asm-arm/arch-adifcc/time.h	1.1     -> 1.2    
#	drivers/usb/core/file.c	1.6     -> 1.7    
#	arch/ppc/platforms/sandpoint_setup.c	1.11    -> 1.13   
#	drivers/char/amiserial.c	1.15    -> 1.19   
#	arch/sparc64/kernel/sbus.c	1.12    -> 1.14   
#	arch/ppc64/kernel/ioctl32.c	1.25    -> 1.27   
#	drivers/scsi/qla1280.c	1.31    -> 1.32   
#	arch/arm/mach-integrator/irq.c	1.3     -> 1.4    
#	 drivers/net/3c505.c	1.21    -> 1.22   
#	drivers/usb/misc/speedtch.c	1.77    -> 1.80   
#	drivers/isdn/hisax/teleint.c	1.20    -> 1.21   
#	drivers/scsi/qlogicfas.c	1.18    -> 1.20   
#	arch/sparc/kernel/etrap.S	1.3     -> 1.4    
#	      sound/oss/os.h	1.6     -> 1.7    
#	net/ipv6/xfrm6_input.c	1.8     -> 1.9    
#	    fs/ntfs/attrib.c	1.85.1.1 -> 1.89   
#	drivers/usb/media/usbvideo.c	1.33    -> 1.35   
#	drivers/net/wan/sdla.c	1.8     -> 1.9    
#	drivers/char/tty_ioctl.c	1.7     -> 1.8    
#	include/asm-arm/arch-iop3xx/iop321.h	1.1     -> 1.2    
#	drivers/video/pm2fb.c	1.18    -> 1.19   
#	drivers/char/drm/r128_drv.h	1.13    -> 1.14   
#	drivers/pcmcia/i82092.c	1.15    -> 1.17   
#	drivers/acpi/namespace/nsnames.c	1.17    -> 1.18   
#	    sound/ppc/pmac.c	1.12    -> 1.13   
#	drivers/isdn/hisax/avm_a1p.c	1.25    -> 1.26   
#	drivers/net/wireless/orinoco.c	1.22    -> 1.23   
#	     sound/oss/pss.c	1.9     -> 1.10   
#	  drivers/net/slip.c	1.11    -> 1.13   
#	drivers/usb/serial/bus.c	1.6     -> 1.7    
#	include/asm-arm/irq.h	1.5     -> 1.6    
#	include/asm-sparc64/auxio.h	1.3     -> 1.4    
#	arch/arm/nwfpe/softfloat.c	1.3     -> 1.5    
#	     net/ipv4/ipip.c	1.27    -> 1.28   
#	      fs/block_dev.c	1.126   -> 1.131  
#	drivers/char/ip2main.c	1.24    -> 1.28   
#	arch/arm/mm/Makefile	1.17    -> 1.18   
#	drivers/scsi/aacraid/rx.c	1.1     -> 1.3    
#	net/ipv4/netfilter/ip_queue.c	1.12    -> 1.13   
#	drivers/scsi/53c7xx.c	1.16    -> 1.17   
#	drivers/scsi/sun3_scsi_vme.c	1.4     -> 1.5    
#	arch/i386/mm/pgtable.c	1.9     -> 1.10   
#	arch/ppc/platforms/4xx/redwood.h	1.6     -> 1.7    
#	net/core/rtnetlink.c	1.9     -> 1.10   
#	include/asm-m68k/motorola_pgalloc.h	1.9     -> 1.10   
#	drivers/video/stifb.c	1.14    -> 1.15   
#	drivers/char/drm/r128_irq.c	1.2     -> 1.4    
#	 sound/isa/sgalaxy.c	1.12    -> 1.13   
#	   net/sctp/socket.c	1.48    -> 1.49   
#	 drivers/video/ffb.c	1.4     -> 1.5    
#	drivers/usb/serial/usb-serial.h	1.27    -> 1.29   
#	drivers/scsi/sym53c8xx_2/sym_glue.c	1.16    -> 1.18   
#	drivers/scsi/tmscsim.c	1.17    -> 1.18   
#	include/linux/videodev.h	1.16    -> 1.18   
#	drivers/net/sk_g16.c	1.11    -> 1.12   
#	               (new)	        -> 1.4     drivers/net/ixgb/ixgb_hw.h
#	               (new)	        -> 1.1     include/asm-arm/arch-iop3xx/iop310-irqs.h
#	               (new)	        -> 1.1     include/asm-ppc/xmon.h
#	               (new)	        -> 1.1     init/do_mounts_initrd.c
#	               (new)	        -> 1.1     drivers/scsi/dc395x.c
#	               (new)	        -> 1.1     drivers/char/drm/drm_memory_debug.h
#	               (new)	        -> 1.1     arch/arm/mm/cache-v4wt.S
#	               (new)	        -> 1.4     drivers/net/ixgb/ixgb_main.c
#	               (new)	        -> 1.1     fs/partitions/devfs.h
#	               (new)	        -> 1.3     drivers/net/ixgb/ixgb.h
#	               (new)	        -> 1.1     drivers/net/ixgb/Makefile
#	               (new)	        -> 1.1     arch/arm/mm/cache-v4.S
#	               (new)	        -> 1.4     drivers/net/ixgb/ixgb_ee.c
#	               (new)	        -> 1.2     drivers/net/ixgb/ixgb_param.c
#	               (new)	        -> 1.1     arch/sparc/lib/bitext.c
#	               (new)	        -> 1.2     drivers/net/ixgb/ixgb_ids.h
#	               (new)	        -> 1.3     drivers/net/ixgb/ixgb_ee.h
#	               (new)	        -> 1.1     arch/arm/mm/cache-v4wb.S
#	               (new)	        -> 1.3     drivers/net/ixgb/ixgb_osdep.h
#	               (new)	        -> 1.4     drivers/net/ixgb/ixgb_hw.c
#	               (new)	        -> 1.1     Documentation/networking/ixgb.txt
#	               (new)	        -> 1.1     include/asm-sparc/bitext.h
#	               (new)	        -> 1.1     arch/arm/mm/cache-v3.S
#	               (new)	        -> 1.3     arch/arm/mm/proc-sa1100.S
#	               (new)	        -> 1.3     drivers/i2c/chips/it87.c
#	               (new)	        -> 1.1     include/linux/8250_pci.h
#	               (new)	        -> 1.3     drivers/net/ixgb/ixgb_ethtool.c
#	               (new)	        -> 1.2     include/linux/initrd.h
#	               (new)	        -> 1.1     include/linux/compat_ioctl.h
#	               (new)	        -> 1.1     drivers/scsi/dc395x.h
#	               (new)	        -> 1.1     Documentation/scsi/ChangeLog.megaraid
#	               (new)	        -> 1.1     drivers/block/initrd.c
#	               (new)	        -> 1.2     fs/partitions/devfs.c
#	               (new)	        -> 1.1     Documentation/scsi/dc395x.txt
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/04/19	torvalds@home.transmeta.com	1.1118.1.6
# Linux 2.5.68
# --------------------------------------------
# 03/04/19	davem@nuts.ninka.net	1.1118.1.7
# Merge nuts.ninka.net:/home/davem/src/BK/network-2.5
# into nuts.ninka.net:/home/davem/src/BK/net-2.5
# --------------------------------------------
# 03/04/19	yoshfuji@linux-ipv6.org	1.1118.1.8
# [IPSEC]: nexthdr in xfrm6_input needs to be int.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.9
# [PKT_SCHED]: Proper module refcounting for packet classifiers.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.10
# [PKT_SCHED]: Proper module refcounting for packet schedulers.
# --------------------------------------------
# 03/04/20	jgarzik@redhat.com	1.1118.3.1
# Modernize rcpci45 I2O LAN driver (#204):
# * Convert to PCI DMA mapping API (Francios Romieu).  Gets driver
#   compiling again.  Fixes bugzilla bug #204.
# * use SET_MODULE_OWNER
# * remove MOD_*_USE_COUNT from all but one place
#   (and add FIXME to that one place)
# * fix printk in rclanmtl.c, though more work is needed
# --------------------------------------------
# 03/04/20	jgarzik@redhat.com	1.1118.3.2
# [rcpci45] typo fix: s/virual/virtual/
# --------------------------------------------
# 03/04/20	torvalds@home.transmeta.com	1.1118.4.1
# Fix-ups for i830 from Arjan
# --------------------------------------------
# 03/04/20	torvalds@home.transmeta.com	1.1118.4.2
# Interrupt handlers should return whether the interrupt
# was for them or not, so that the irq subsystem can properly
# handle screaming shared interrupts.
# 
# So change the irq handlers to return a "irqretval_t", which
# is either IRQ_HANDLED or IRQ_NONE.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.1
# [PATCH] 3c574_cs fixes
# 
# - It was doing spin_lock_irqsave()/spin_unlock()
# 
# - Can't free the skb inside local_irq_save(): kfree_skb ends up running
#   local_bh_enable(), which enables interrupts.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.2
# [PATCH] Fix nc98 partition parser link error
# 
# Fix this:
# 
# fs/partitions/nec98.c:169: undefined reference to `parse_bsd'
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.3
# [PATCH] dmfe: don't free skb with local interrupts disabled
# 
# dev_kfree_skb() can end up calling local_bh_enable() which goes BUG if local
# interrupts are disabled.  Apparently it can deadlock.
# 
# So move the skb freeing outside the lock in the dmfe driver.  It will
# decrease the lock hold time as well.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.4
# [PATCH] dentry_stat accounting fix
# 
# From: Maneesh Soni <maneesh@in.ibm.com>
# 
# This patch the corrects the dentry_stat.nr_unused calculation.
# 
# In select_parent() and shrink_dcache_anon() we were not doing any adjustments
# to the nr_unused count after manipulating the dentry_unused list.  Now the
# nr_unused count is decremented if the dentry is on dentry_unused list and is
# removed from there.
# 
# Further in the same routines, we have to adjust the nr_unused count again if
# the dentry is moved to the end of d_lru list for pruning.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.5
# [PATCH] Fix and clean up DCACHE_REFERENCED usage
# 
# From: Maneesh Soni <maneesh@in.ibm.com>
# 
# This patch changes the way DCACHE_REFERENCED flag is used. It
# got messed up in dcache_rcu iterations. I hope this will be ok now.
# 
# The flag was meant to be advisory flag which is used while
# prune_dcache() so as not to free dentries which have recently
# entered d_lru list. At first pass in prune_dcache the dentries
# marked DCACHE_REFERENCED are left with the flag reset. and they
# are freed in the next pass.
# 
# So, now we mark the dentry as DCACHE_REFERENCED when it is first
# entering the d_lru list in dput() and resetthe flag in prune_dcache().
# If the flag remains reset in the next call to prune_dcache(), the
# dentry is then freed.
# 
# Also I don't think any file system have to use this flag as it is taken
# care by the dcache layer. The patch removes such code from a few of file
# systems. Moreover these filesystems were anyway doing worng thing as they
# were changing the flag out of dcache_lock.
# 
# Changes:
# o dput() marks dentry DCACHE_REFERENCED when it is added to the dentry_unused
#   list
# o no need to set the flag in dget, dget_locked, d_lookup as these guys anyway
#   increments the ref count.
# o check the ref count in prune_dcache and use DCACHE_REFERENCED flag just for
#   two stage aging.
# o remove code for setting DACACHE_REFERENCED from reiserfs, fat, xfs and
#   exportfs.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.6
# [PATCH] Fix POSIX timers to give CLOCK_MONOTONIC full
# 
# The POSIX CLOCK_MONOTONIC currently has only 1/HZ resolution.  Further, it is
# tied to jiffies (i.e.  is a restatment of jiffies) rather than "xtime" or the
# gettimeofday() clock.
# 
# This patch changes CLOCK_MONOTONIC to be a restatment of gettimeofday() plus
# an offset to remove any clock setting activity from CLOCK_MONOTONIC.  An
# offset is kept that represents the difference between CLOCK_MONOTONIC and
# gettimeofday().  This offset is updated when ever the gettimeofday() clock is
# set to back the clock setting change out of CLOCK_MONOTONIC (which by the
# standard, can not be set).
# 
# With this change CLOCK_REALTIME (a direct restatement of gettimeofday()),
# CLOCK_MONOTONIC and gettimeofday() will all tick at the same time and with
# the same rate.  And all will be affected by NTP adjustments (save those which
# actually set the time).
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.7
# [PATCH] Fix jiffies_to_time[spec | val] and converse to use
# 
# From: george anzinger <george@mvista.com>
# 
# In the current system (2.5.67) time_spec to jiffies, time_val to
# jiffies and the converse (jiffies to time_val and jiffies to
# time_spec) all use 1/HZ as the measure of a jiffie.  Because of the
# inability of the PIT to actually generate an accurate 1/HZ interrupt,
# the wall clock is updated with a more accurate value (999848
# nanoseconds per jiffie for HZ = 1000).  This causes a 1/HZ
# interpretation of jiffies based timing to run faster than the wall
# clock, thus causing sleeps and timers to expire short of the requested
# time.  Try, for example:
# 
# time sleep 60
# 
# This patch changes the conversion routines to use the same value as
# the wall clock update code to do the conversions.
# 
# The actual math is almost all done at compile time.  The run time
# conversions require little if any more execution time.
# 
# This patch must be applied after the patch I posted earlier today
# which fixed the CLOCK_MONOTONIC resolution issue.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.8
# [PATCH] get_offset_pit and do_timer_overflow vs IRQ locking
# 
# From: john stultz <johnstul@us.ibm.com>, Alexander Atanasov <alex@ssi.bg>
# 
# We want to make sure we update jiffies_p and count_p atomically.  So I'm
# inserting the spin_unlock_irqrestore() after we update count_p, rather then
# just before.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.9
# [PATCH] detect_lost_tick locking fixes
# 
# From: john stultz <johnstul@us.ibm.com>
# 
# This patch fixes a race in the timer_interrupt code caused by
# detect_lost_tick().  Since we're doing lost-tick compensation outside
# timer->mark_offset, time can pass between time-source reads which can cause
# gettimeofday inconsistencies.
# 
# Additionally detect_lost_tick() was broken for the PIT case, since the whole
# point of detect_lost_tick() is to interpolate between two time sources to
# find inconsistencies.  Additionally this could cause xtime_lock seq_lock
# reader starvation which has been causing machine hangs for SMP boxes that use
# the PIT as a time source.
# 
# This patch fixes the described race by removing detect_lost_tick() and
# instead implementing the lost tick detection code inside mark_offset().
# 
# Some of the divs and mods being added here might concern folks, but by not
# calling timer->get_offset() in detect_lost_tick() we eliminate much of the
# same math.  I did some simple cycle counting and the new code comes out on
# average equivalent or faster.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.10
# [PATCH] Minor fix for driver/serial/core.c
# 
# From: Jean Tourrilhes <jt@bougret.hpl.hp.com>
# 
# 	The following command will do nothing at all on 2.5.X :
# 		setserial /dev/ttyS0 uart none
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.11
# [PATCH] keyboard.c Fix SAK in raw mode
# 
# From: Chris Heath <chris@heathens.co.nz>
# 
# Trivial fix to get the SAK key working in raw and medium raw modes.  Patch is
# against kernel 2.5.67.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.12
# [PATCH] Make PCI scanning order the same as 2.4
# 
# From: Chuck Ebbert <76306.1226@compuserve.com>
# 
# 2.4 builds its global PCI device list in breadth-first order.
# 
# 2.5 is doing the scan that way but defers the construction of the global list
# until later and then does it depth-first.  This causes devices to found in
# different order by drivers.  The below fixed that problem for me.
# 
# Russell King has acked this change.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.13
# [PATCH] Turn on NUMA rebalancing
# 
# From: "Martin J. Bligh" <mbligh@aracnet.com>
# 
# I'd forgotten that I'd set this to only fire every 20s in the past, because
# it would rebalance too agressively.  That seems to be fixed now, so we should
# turn it back on.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.14
# [PATCH] Move __set_page_dirty_buffers to fs/buffer.c
# 
# From: William Lee Irwin III <wli@holomorphy.com>
# 
# Move __set_page_dirty_buffers() to fs/buffer.c, as per the FIXME.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.15
# [PATCH] Clean up various buffer-head dependencies
# 
# From: William Lee Irwin III <wli@holomorphy.com>
# 
# Remove page_has_buffers() from various functions, document the dependencies
# on buffer_head.h from other files besides filemap.c, and s/this file/core VM/
# in filemap.c
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.16
# [PATCH] follow_hugetlb_page fix
# 
# From: William Lee Irwin III <wli@holomorphy.com>
# 
# follow_hugetlb_page() drops out of the loop prematurely and fails to take the
# appropriate refcounts if its starting address was not hugepage-aligned.
# 
# It looked a bit unclean too, so I rewrote it.  This fixes a bug, and more
# importantly, makes the thing readable by something other than a compiler
# (e.g.  programmers).
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.17
# [PATCH] hugetlb math overflow fix
# 
# From: William Lee Irwin III <wli@holomorphy.com>
# 
# And this one fixes an overflow when there is more than 4GB of hugetlb.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.18
# [PATCH] ATI Mach64 build fix
# 
# From: Geert Uytterhoeven <geert@linux-m68k.org>
# 
# Atyfb: Add missing parts of reversal of Mobility changes, allowing ATI Mach64
# GX support to compile again.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.19
# [PATCH] quotactl(): sync all quotas
# 
# From: Jan Kara <jack@suse.cz>
# 
#   I'm resending a patch which implements quotactl(2) call for syncing
# all devices. Particulary it allows the caller not to specify the device
# for syncing and in that case quotas on all the devices are written.
# The patch is rather trivial (mostly moving the code).
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.20
# [PATCH] AIO mmap fix
# 
# From: Badari Pulavarty <pbadari@us.ibm.com>
# 
# Here is a small bug fix for AIO. get_user_pages() takes number
# of pages to map as argument. (not in bytes)
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.21
# [PATCH] shmdt() speedup
# 
# From: William Lee Irwin III <wli@holomorphy.com>
# 
# Micro-optimize sys_shmdt(). There are methods of exploiting knowledge
# of the vma's being searched to restrict the search space. These are:
# 
# (1) shm mappings always start their lives at file offset 0, so only
# 	vma's above shmaddr need be considered. find_vma() can be used
# 	to seek to the proper position in mm->mmap in O(lg(n)) time.
# 
# (2) The search is for a vma which could be a fragment of a broken-up
# 	shm mapping, which would have been created starting at shmaddr
# 	with vm_pgoff 0 and then continued no further into userspace
# 	than shmaddr + size. So after having found an initial vma, find
# 	the size of the shm segment it maps to calculate an upper bound
# 	to the virtualspace that needs to be searched.
# 
# (3) mremap() would have caused the original checks to miss vma's mapping
# 	the shm segment if shmaddr were the original address at which
# 	the shm segments were attached. This does no better and no worse
# 	than the original code in that situation.
# 
# (4) If the chain of references in vma->vm_file->f_dentry->d_inode->i_size
# 	is not guaranteed by refcounting and/or the shm code then this is
# 	oopsable; AFAICT an inode is always allocated.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.22
# [PATCH] implement __GFP_REPEAT, __GFP_NOFAIL, __GFP_NORETRY
# 
# This is a cleanup patch.
# 
# There are quite a lot of places in the kernel which will infinitely retry a
# memory allocation.
# 
# Generally, they get it wrong.  Some do yield(), the semantics of which have
# changed over time.  Some do schedule(), which can lock up if the caller is
# SCHED_FIFO/RR.  Some do schedule_timeout(), etc.
# 
# And often it is unnecessary, because the page allocator will do the retry
# internally anyway.  But we cannot rely on that - this behaviour may change
# (-aa and -rmap kernels do not do this, for instance).
# 
# So it is good to formalise and to centralise this operation.  If an
# allocation specifies __GFP_REPEAT then the page allocator must infinitely
# retry the allocation.
# 
# The semantics of __GFP_REPEAT are "try harder".  The allocation _may_ fail
# (the 2.4 -aa and -rmap VM's do not retry infinitely by default).
# 
# The semantics of __GFP_NOFAIL are "cannot fail".  It is a no-op in this VM,
# but needs to be honoured (or fix up the callers) if the VM ischanged to not
# retry infinitely by default.
# 
# The semantics of __GFP_NOREPEAT are "try once, don't loop".  This isn't used
# at present (although perhaps it should be, in swapoff).  It is mainly for
# completeness.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.23
# [PATCH] make alloc_buffer_head take gfp_flags
# 
# - alloc_buffer_head() should take the allocation mode as an arg, and not
#   assume.
# 
# - Use __GFP_NOFAIL in JBD's call to alloc_buffer_head().
# 
# - Remove all the retry code from jbd_kmalloc() - do it via page allocator
#   controls.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.24
# [PATCH] use __GFP_REPEAT in pte_alloc_one()
# 
# Remove all the open-coded retry loops in various architectures, use
# __GFP_REPEAT.
# 
# It could be that at some time in the future we change __GFP_REPEAT to give up
# after ten seconds or so, so all the checks for failed allocations are
# retained.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.25
# [PATCH] use __GFP_REPEAT in pmd_alloc_one()
# 
# Convert all pmd_alloc_one() implementations to use __GFP_REPEAT
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.26
# [PATCH] Disallow swapoff if there is insufficient memory
# 
# From: Hugh Dickins <hugh@veritas.com>
# 
# First of three small "stop swapoff" patches based on 2.5.67-mm3:
# 
# stop swapoff 1/3 vm_enough_memory?
# 
# Before embarking upon swapoff, check vm_enough_memory.  Mainly
# for consistency in the overcommit_memory 2 (strict accounting) case:
# fail with -ENOMEM if it wouldn't let the amount removed be committed.
# 
# Will always succeed in the overcommit_memory 1 case, as it should in
# root-shoot-foot mode.  In the overcommit_memory 0 case, well, I don't
# care much either way, so opted for the simplest code: no special case.
# Which means it could now fail at the start; but that's unlikely (case 0
# is over-generous) and only when it would have got stuck later on anyway.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.27
# [PATCH] Permit interruption of swapoff
# 
# From: Hugh Dickins <hugh@veritas.com>
# 
# Sometimes you start a swapoff and, seeing how long it takes, wish you had
# not: allow signal to interrupt and stop swapoff.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.28
# [PATCH] oom-kill: preferentially kill swapoff
# 
# From: Hugh Dickins <hugh@veritas.com>
# 
# The current behaviour is that once swapoff has filled memory, other tasks get
# OOMkilled one by one until swapoff completes, or more likely hangs.  It is
# better that swapoff be the first choice for OOMkill.
# 
# The patch changes the oom-killer so that it will kill off any
# currently-running swapoff instance before killing any other task.
# 
# (Bit kludgy, couldn't think of a better way)
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.29
# [PATCH] DAC960: add call to blk_queue_bounce_limit
# 
# From: Dave Olien <dmo@osdl.org>
# 
# The following patch adds a call to blk_queue_bounce_limit to the DAC960
# driver.  Otherwise, it uses bounce buffering more than it needs to.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.30
# [PATCH] shm_get_stat-handle-hugetlb-pages.patch
# 
# From: William Lee Irwin III <wli@holomorphy.com>
# 
# shm_get_stat() didn't know about hugetlbpage-backed shm.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.31
# [PATCH] Allocate hd_structs dynamically
# 
# From: Badari Pulavarty <pbadari@us.ibm.com>
# 
# Here is the patch to allocate hd_struct dynamically as we find
# partitions.
# 
# There are 3 things I didn't like in the patch.
# 
# 1) The patch allocates 15 pointers instead of 15 hd_structs.  (incase of
#    s= csi).  I was really hoping to get rid of "15" and make it really
#    dynamic.  (In ca= se if we ever want to support more than 15 partitions
#    per disk etc..).=20 I was thought about making it a linked list, but
#    blk_partition_remap() needs to get to hd_struct for a given partition
#    everytime we do IO.  So linked list would be bad, we really need direct
#    access to partition in= fo.
# 
# 2) I had to add "partno" to hd_struct, since part_dev_read() used to calc=
#    ulate partition number from the address before.
# 
# 3) kmalloc() failure in add_partition() will be silently ignored.
# 
# It saves 2048 bytes per disk.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.32
# [PATCH] fix CONFIG_NOMMU mismerges
# 
# From: Christoph Hellwig <hch@lst.de>
# 
# we already have better stubs in nommu.c, the additional inlines in mm.h only
# cause compile failures.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.33
# [PATCH] Extend map_vm_area()/get_vm_area()
# 
# From: Christoph Hellwig <hch@infradead.org> and David M-T
# 
# The ia64 port can use vmap(), but needs to be able to specify the protection
# flags and the resulting vma's vm_flags.
# 
# The patch adds the two extra args to vmap(), updates the two callers and
# fixes some comment spellos.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.34
# [PATCH] don't shrink slab for highmem allocations
# 
# From: William Lee Irwin III <wli@holomorphy.com>
# 
# If one's goal is to free highmem pages, shrink_slab() is an ineffective
# method of recovering them, as slab pages are all ZONE_NORMAL or ZONE_DMA.
# Hence, this "FIXME: do not do for zone highmem".  Presumably this is a
# question of policy, as highmem allocations may be satisfied by reaping slab
# pages and handing them back; but the FIXME says what we should do.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.35
# [PATCH] prepare device mapper for larger dev_t
# 
# From: Joe Thornber <thornber@sistina.com>
# 
# The only other thing that will need changing in dm to cope with 64bit
# dev_t concerns the bitset I'm using to keep track of allocated minor
# numbers.  A trivial patch like this would work for now:
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.36
# [PATCH] smbfs: larger dev_t preparation
# 
# Discard fewer bits of the device number recd with smb.
# This does not depend on anything else.
# 
# Andries
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.37
# [PATCH] Fix nfsctl for larger dev_t
# 
# From: Andries.Brouwer@cwi.nl
# 
# The old NFS control interface passes dev_t's in from userspace.  This patch
# keeps it working when the size of dev_t changes.
# 
# This is a deprecated interface - new nfs-utils uses an ascii representation
# in exportfs.
# 
# Acked by Neil.
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.38
# [PATCH] Aggregated disk statistics
# 
# From: Rick Lindsley <ricklind@us.ibm.com>
# 
# To access all the system's disk statitics we currently need to access one
# sysfs file per disk.  This clearly will not be acceptable with thousands of
# disks.
# 
# The patch aggregates the system-wide statistics in real time and exposes them
# via /proc/diskstats
# --------------------------------------------
# 03/04/20	akpm@digeo.com	1.1118.5.39
# [PATCH] fbdev build fix
# 
# - fb_prepare_logo() is calling the undefined find_logo().  I think it wants
#   fb_find_logo().
# 
# - fb_prepare_logo is not __init, therefore fb_find_logo() cannot be __init.
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.1
# [PATCH] devfs: input
# 
# Make sure input always uses devfs_remove.  While at it I've also
# remove lots of code duplication - every upper input driver contained
# the code surrounding devfs_unregister in two identical copies.
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.2
# [PATCH] devfs: dvb
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.3
# [PATCH] devfs: usb
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.4
# [PATCH] devfs: sound
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.5
# [PATCH] devfs: videodev
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.6
# [PATCH] devfs: miscdev
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.7
# [PATCH] devfs: s390
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.8
# [PATCH] devfs: ipmi
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.9
# [PATCH] devfs: swim3
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.10
# [PATCH] devfs: uml
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.11
# [PATCH] devfs: remove devfs_unregister
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.12
# [PATCH] devfs: switch over ubd to ->devfs_name
# 
# Duh, ubd is partitioned.
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.13
# [PATCH] devfs: remove dead devfs code in dasd
# 
# Dasd is partitioned - all devfs stuff is handled by the gendisk layer.
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.14
# [PATCH] devfs: superflous devfs_remove in scsi
# 
# Already handled by the gendisk layer.
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.15
# [PATCH] devfs: introduce devfs_mk_bdev
# 
# Replaces devfs_register for block devices.  Note that we do NOT pass in
# an operaion vector here - it was unused in devfs_register already
# and our block device code fundamentally ties the operations to the
# gendisk.  There will be only very few callers of this one anyway..
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.16
# [PATCH] devfs: gendisk.devfs_name updates
# 
# Previously gendisk.devfs_name was used only for partitioned devices
# or CDroms, and for the latter it was slightly broken.  Fix it to
# work genericly for all gendisks.
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.17
# [PATCH] devfs: loop
# 
# This and the next patches switches over drivers to gendisk.devfs_name.
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.18
# [PATCH] devfs: nbd
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.19
# [PATCH] devfs: rd
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.20
# [PATCH] devfs: swim3
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.21
# [PATCH] devfs: aztcd
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.22
# [PATCH] devfs: gscd
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.23
# [PATCH] devfs: optcd
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.24
# [PATCH] devfs: sjcd
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.25
# [PATCH] devfs: sonycd
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.26
# [PATCH] devfs: mtdblock
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.27
# [PATCH] devfs: xpram
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.28
# [PATCH] devfs: floppy
# 
# The following patches switch the few drivers that have to register
# devfs entries independand of gendisks to devfs_mk_bdev.
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.29
# [PATCH] devfs: device-mapper
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.30
# [PATCH] devfs: md
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.31
# [PATCH] devfs: kill devfs_register_partition
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.32
# [PATCH] devfs: warn on block modes in devfs_register
# --------------------------------------------
# 03/04/20	torvalds@penguin.transmeta.com	1.1118.4.3
# Update ensoniq driver to return whether the interrupt was for it
# or not.
# --------------------------------------------
# 03/04/20	torvalds@home.transmeta.com	1.1118.4.4
# Merge home.transmeta.com:/home/torvalds/v2.5/akpm
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.33
# [PATCH] initrd.h
# 
# split the initrd stuff out of blk.h, it's only needed in the boot code
# and the ramdisk driver.
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.34
# [PATCH] rename end_request in floppy() and raid1
# 
# In preparation of getting rid of the LOCAL_END_REQUEST mess.
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.35
# [PATCH] replace __blk_run_queue with blk_run_queue
# 
# All callers of __blk_run_queue are of the form
# 
# 	spin_lock_irqsave(q->queue_lock, flags);
# 	__blk_run_queue(q);
# 	spin_unlock_irqrestore(q->queue_lock, flags);
# 
# Replace it with a blk_run_queue that does the locking itself.
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.36
# [PATCH] remove dasd_get_kdev
# 
# Al pointed out that it's unused after my last series of devfs patches.
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.37
# [PATCH] remove some junk from hd98.c's ioctl implementation
# 
# Also pointed out by Al.
# --------------------------------------------
# 03/04/20	hch@lst.de	1.1118.6.38
# [PATCH] remove a tiny bit of kdev_t abuse from the floppy driver
# --------------------------------------------
# 03/04/20	torvalds@home.transmeta.com	1.1118.4.5
# Merge
# --------------------------------------------
# 03/04/20	torvalds@home.transmeta.com	1.1118.1.11
# Merge bk://kernel.bkbits.net/davem/net-2.5
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/20	rddunlap@osdl.org	1.1118.1.12
# [PATCH] replace URLs in Kconfig
# 
# This is a patch from Robert P.J. Day that replaces www.linuxdoc.org
# (which is outdated and unspported according to www.tldp.org)
# with www.tldp.org in lots of Kconfig files.
# --------------------------------------------
# 03/04/20	torvalds@home.transmeta.com	1.1118.1.13
# Fix IO-APIC vector allocation boundary case - we never want to
# allocate FIRST_SYSTEM_VECTOR as an external interrupt. It's unlikely,
# but could happen if we have a _ton_ of interrupt sources.
# 
# Found by Chuck Ebbert.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.14
# [SPARC64]: A few missing pgtable __GFP_REPEAT.
# --------------------------------------------
# 03/04/20	jgarzik@redhat.com	1.1118.7.1
# Merge redhat.com:/garz/repo/linus-2.5
# into redhat.com:/garz/repo/net-drivers-2.5
# --------------------------------------------
# 03/04/21	jgarzik@redhat.com	1.1118.7.2
# net driver cleanup, volume 1:
# 
# Mostly updating to new irqreturn_t, but also includes some needed
# SET_MODULE_OWNER and set_bit cleanups as well.
# 
# Affects: 8390, dgrs, eepro100, epic100, pcnet32, rcpci45,
# sis900, tlan
# --------------------------------------------
# 03/04/21	jgarzik@redhat.com	1.1118.7.3
# net driver cleanup, volume 2
# 
# morq irqreturn_t,
# some s/long flags/unsigned long flags/,
# more set_bit-on-something-other-than-long cleanups
# 
# Affected drivers: epic100, fealnx, natsemi, ns83820, starfire,
# sundance, via-rhine, yellowfin.  (and also include/linux/eeprom.h)
# 
# Several changes contributed by Andrew Morton.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.15
# [SPARC]: Rename signal macros SV_foo --> _SV_foo.
# --------------------------------------------
# 03/04/21	jgarzik@redhat.com	1.1118.7.4
# net driver cleanup, volume 3
# 
# Affected drivers: 8139cp, 8139too, 82596, b44, cs89x0, dl2k, r8169
# 
# Vast majority of changes contributed by Andrew Morton.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.8.1
# [NET]: In sock_alloc_send_pskb, add __GFP_REPEAT when __GFP_WAIT.
# --------------------------------------------
# 03/04/21	jgarzik@redhat.com	1.1118.7.5
# net driver cleanup, volume 4
# 
# Affected drivers: 3c501, 3c507, 3c509, 3c5154, 3c59x, amd8111e,
# at1700, e1000, hp100, lance, smc9194, de2104x, de4x5, tulip,
# typhoon.
# 
# 98% contributed by Andrew Morton.
# --------------------------------------------
# 03/04/21	jgarzik@redhat.com	1.1118.7.6
# net driver cleanup, volume 5
# 
# Affected drivers: 3c505 (notably), depca, ni5010, ni52, ni65,
# dmfe, winbond-840.
# 
# 3c505 included quite a few s/int timeout/unsigned long timeout/
# changes as well, for proper jiffies comparison typing.
# 
# 98% contributed by Andrew Morton.
# --------------------------------------------
# 03/04/21	jgarzik@redhat.com	1.1118.7.7
# net driver cleanup, volume 6
# 
# Affected drivers: atp, de600, de620, eepro, eexpress, lp486e, 
# 3c589_cs, axnet_cs, fmvj18x_cs, nmclan_cs, pcnet_cs, smc91c92_cs,
# xirc2ps_cs, sk98lin, xircom_cb, xircom_tulip_cb, airo, arlan,
# netwave_cs, orinoco, ray_cs, wavelan, znet
# 
# 98% contributed by Andrew Morton
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.16
# [SPARC]: setup.c needs linux/initrd.h
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.17
# [SOUND SPARC]: Update for irqreturn_t.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.18
# [SPARC]: Fix dumb typo in sun4c mm code.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.19
# [SPARC]: Platform code changes for irqreturn_t.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.20
# [SERIAL SPARC]: Update for irqreturn_t.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.21
# [SOUND]: mpu401.h needs linux/interrupt.h
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.22
# [CHAR SPARC]: Update for irqreturn_t.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.23
# [RTC]: Update for irqreturn_t.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.24
# [FC4 SPARC]: Update for irqreturn_t.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.25
# [MESSAGE FUSION]: Update for irqreturn_t.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.26
# [SCSI ESP]: Update for irqreturn_t.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.27
# [SCSI QLOGICFC]: Update for irqreturn_t.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.28
# [SCSI QLOGICISP]: Update for irqreturn_t.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.29
# [SCSI QLOGICPTI]: Update for irqreturn_t.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.30
# [SCSI AIC7XXX_OLD]: Update for irqreturn_t.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.31
# [SCSI SYM53C8XX_2]: Update for irqreturn_t.
# --------------------------------------------
# 03/04/20	davem@nuts.ninka.net	1.1118.1.32
# [TG3]: Update to irqreturn_t.
# --------------------------------------------
# 03/04/21	davem@nuts.ninka.net	1.1118.1.33
# [NET SUN]: Update for irqreturn_t.
# --------------------------------------------
# 03/04/21	davem@nuts.ninka.net	1.1118.1.34
# [MYRI_SBUS]: Update for irqreturn_t.
# --------------------------------------------
# 03/04/21	davem@nuts.ninka.net	1.1118.1.35
# [SOUND PCI]: Update several drivers for irqreturn_t.
# --------------------------------------------
# 03/04/21	davem@nuts.ninka.net	1.1118.1.36
# [SOUND TRIDENT]: Update for irqreturn_t.
# --------------------------------------------
# 03/04/21	shaggy@shaggy.austin.ibm.com	1.1118.9.1
# Merge jfs@jfs.bkbits.net:linux-2.5
# into shaggy.austin.ibm.com:/shaggy/bk/jfs-2.5
# --------------------------------------------
# 03/04/21	jejb@raven.il.steeleye.com	1.1118.10.1
# Merge raven.il.steeleye.com:/home/jejb/BK/scsi-misc-old-2.5
# into raven.il.steeleye.com:/home/jejb/BK/scsi-misc-2.5
# --------------------------------------------
# 03/04/21	jejb@raven.il.steeleye.com	1.1118.10.2
# Merge raven.il.steeleye.com:/home/jejb/BK/scsi-megaraid-2.5
# into raven.il.steeleye.com:/home/jejb/BK/scsi-misc-2.5
# --------------------------------------------
# 03/04/21	hch@lst.de	1.1118.10.3
# [PATCH] scsi_scan.c coding style fixes
# 
# Just some random styleups I made while walking over the file
# for the devfs work.
# --------------------------------------------
# 03/04/21	hch@lst.de	1.1118.10.4
# [PATCH] unexport scsi_host_get_next
# 
# No drivers are using it anymore, and having this private to the
# midlayer should make proper shost refcounting easier.
# --------------------------------------------
# 03/04/21	hch@lst.de	1.1118.10.5
# [PATCH] kill ASSERT_LOCK
# 
# There's just one user left, and that one is in aha152x.c and thus
# clearly bogus..
# --------------------------------------------
# 03/04/21	dougg@torque.net	1.1118.10.6
# scsi_mid_low_api.txt update for 2.5.67
# --------------------------------------------
# 03/04/21	eli.carter@com.rmk.(none)	1.1118.11.1
# [ARM PATCH] 1508/1: use #define's for iq80321
# 
# Patch from Eli Carter
# 
# # Thu Apr 17 16:37:58 CDT 2003 ejc@rnd-linux-c84
# # iq80321-use-addr-defines
# #
# # Use #define's instead of hard-coded numbers for the device locations for the
# # iq80321 board.
# #
# # Diffed against linux-2.5.65-rmk1+1472-4+1502-3+1506
# # Applies cleanly to linux-2.5.67-rmk1+1502-3+1506
# #
# #  arch/arm/mach-iop3xx/mm-321.c |    4 ++--
# #  1 files changed, 2 insertions(+), 2 deletions(-)
# #
# --------------------------------------------
# 03/04/21	eli.carter@com.rmk.(none)	1.1118.11.2
# [ARM PATCH] 1511/1: iop321 #define cleanup
# 
# Patch from Eli Carter
# 
# # Mon Apr 21 11:20:06 CDT 2003 ejc@rnd-linux-c84
# # pci-io-mem-size-defines
# #
# # Rename the IOP321_PCI_WINDOW_SIZE #defines to use
# # IOP321_PCI_{IO,MEM}_{BASE,SIZE} instead.  This makes the #defines a bit more
# # consistent.  No functional change, though it does bring up the question of
# # whether res[].end should be BASE+SIZE-1 or BASE+SIZE.
# #
# # Diffed against linux-2.5.67-rmk1+1501-3+1506+1508-10
# #
# #  arch/arm/mach-iop3xx/iop321-pci.c    |    8 ++++----
# #  include/asm-arm/arch-iop3xx/iop321.h |   10 ++++------
# #  2 files changed, 8 insertions(+), 10 deletions(-)
# #
# --------------------------------------------
# 03/04/21	eli.carter@com.rmk.(none)	1.1118.11.3
# [ARM PATCH] 1510/1: use a #define for asm jump address
# 
# Patch from Eli Carter
# 
# # Mon Apr 21 11:11:41 CDT 2003 ejc@rnd-linux-c84
# # use-physoffset-define
# #
# # Use the PHYS_OFFSET #define instead of a hard-coded value.
# #
# # Diffed against linux-2.5.67-rmk1+1501-3+1506
# #
# #  arch/arm/boot/compressed/head-xscale.S |    2 +-
# #  1 files changed, 1 insertion(+), 1 deletion(-)
# #
# --------------------------------------------
# 03/04/21	akpm@digeo.com	1.1118.12.1
# [PATCH] irqs: drivers/block
# 
# update drivers/block for new IRQ API.
# --------------------------------------------
# 03/04/21	akpm@digeo.com	1.1118.12.2
# [PATCH] irqs: sym2
# 
# update sym2 for new IRQ API
# --------------------------------------------
# 03/04/21	akpm@digeo.com	1.1118.12.3
# [PATCH] irqs: rtc
# 
# update rtc driver to new IRQ API
# --------------------------------------------
# 03/04/21	akpm@digeo.com	1.1118.12.4
# [PATCH] irqs in sound/
# 
# Updates all sound drivers to the new IRQ API.
# 
# The patch also fixes
# 
# - a return-with-lock-held
# 
# - a bunch of warnings and 64-bit bugs (CPU flags must be held in an
#   unsigned long)
# 
# - jiffies must use unsigned longs
# 
# - two functions returning uninitialised values
# --------------------------------------------
# 03/04/21	akpm@digeo.com	1.1118.12.5
# [PATCH] irqs: ipmi driver
# 
# Update the ipmi driver to the new IRQ API
# --------------------------------------------
# 03/04/21	akpm@digeo.com	1.1118.12.6
# [PATCH] irqs: watchdog drivers
# 
# Update the watchdog drivers to the new IRQ API.
# 
# Also, give a couple of irq handlers static scope.
# --------------------------------------------
# 03/04/21	akpm@digeo.com	1.1118.12.7
# [PATCH] irqs: various char drivers
# 
# Fix up a bunch of char drivers for the new IRQ API.
# --------------------------------------------
# 03/04/21	akpm@digeo.com	1.1118.12.8
# [PATCH] irqs: multimedia drivers
# 
# Update a couple of media drivers to the new IRQ API.
# 
# Some stuff in there doesn't link btw:
# 
# drivers/built-in.o: In function `rds_waitread':
# drivers/built-in.o(.text+0x6c152): undefined reference to `aci_port'
# drivers/built-in.o: In function `rds_rawwrite':
# drivers/built-in.o(.text+0x6c1a3): undefined reference to `aci_port'
# --------------------------------------------
# 03/04/21	akpm@digeo.com	1.1118.12.9
# [PATCH] irqs: video drivers
# 
# Update video drivers to the new IRQ API.
# 
# Almost none of them compile, so it was done on-spec.
# --------------------------------------------
# 03/04/21	akpm@digeo.com	1.1118.12.10
# [PATCH] irqs: 1394
# 
# Update 1394 to the new IRQ API
# --------------------------------------------
# 03/04/21	akpm@digeo.com	1.1118.12.11
# [PATCH] parport_serial fix
# 
# parport_serial is calling a couple of 8250 driver functions with no prototypes
# in scope.
# 
# Turns out it was calling them with too many args, too.
# --------------------------------------------
# 03/04/21	akpm@digeo.com	1.1118.12.12
# [PATCH] ax25 build fix
# 
# spin_lock() does not take a spinlock_t**
# --------------------------------------------
# 03/04/21	akpm@digeo.com	1.1118.12.13
# [PATCH] irqs: IRDA
# 
# Update the IRDA drivers to the new IRQ API.
# --------------------------------------------
# 03/04/21	akpm@digeo.com	1.1118.12.14
# [PATCH] irqs: ISDN
# 
# Update ISDN for the new IRQ API.
# --------------------------------------------
# 03/04/21	akpm@digeo.com	1.1118.12.15
# [PATCH] irqs: input drivers
# 
# Update the input and joystick drivers to the new IRQ API.
# --------------------------------------------
# 03/04/21	akpm@digeo.com	1.1118.1.37
# [PATCH] irqs: hotplug drivers
# 
# Update hotplug and pcmcia drivers to the new IRQ API.
# --------------------------------------------
# 03/04/21	torvalds@home.transmeta.com	1.1118.1.38
# Resolve differences between Davem and Andrew on irq updates
# --------------------------------------------
# 03/04/21	torvalds@home.transmeta.com	1.1118.1.39
# Merge bk://kernel.bkbits.net/jgarzik/net-drivers-2.5
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/21	jgarzik@pobox.com	1.1118.1.40
# [PATCH] fix printk when an irq doesn't get responded to
# --------------------------------------------
# 03/04/21	mzyngier@freesurf.fr	1.1118.1.41
# [PATCH] Convert Alpha to the new 2.5 IRQ API
# 
# This converts the Alpha architecture to the new IRQ API.  Tested on
# Jensen.
# --------------------------------------------
# 03/04/21	torvalds@home.transmeta.com	1.1118.1.42
# Return IRQ_NONE for ieee1394 driver when the interrupt was for
# somebody else.
# --------------------------------------------
# 03/04/21	bcollins@debian.org	1.1118.1.43
# [PATCH] 1394 updates
# 
# - New irq handler prototypes.
# - Lots of un-enumurated locking fixes/cleanups (thanks in large part to
#   spinlock debug compile options in the kernel).
# - Other various trivial fixes.
# --------------------------------------------
# 03/04/21	paulkf@microgate.com	1.1118.1.44
# [PATCH] synclink update
# 
# - Remove MODULE_USE_COUNT macros
# - Add owner member
# - Add tiocmget/tiocmset tty callbacks
# --------------------------------------------
# 03/04/21	paulkf@microgate.com	1.1118.1.45
# [PATCH] synclinkmp update
# 
# - Remove MODULE_USE_COUNT macros
# - Add owner member
# - Add tiocmget/tiocmset tty callbacks
# --------------------------------------------
# 03/04/21	paulkf@microgate.com	1.1118.1.46
# [PATCH] synclink_cs update
# 
# - Remove MODULE_USE_COUNT macros
# - Add owner member
# - Add tiocmget/tiocmset tty callbacks
# --------------------------------------------
# 03/04/21	jejb@raven.il.steeleye.com	1.1118.10.7
# scsi_scan.c: cope with second inquiry failure
# 
# If the second (and longer inquiry) in scsi_scan.c fails for any
# reason, we should fall back to the original (and successful)
# 36 byte inquiry rather than not configuring the device.
# --------------------------------------------
# 03/04/21	paulkf@microgate.com	1.1118.1.47
# [PATCH] n_hdlc update
# 
# With suggestions from Chritoph Hellwig
# 
# - Remove MODULE_USE_COUNT macros
# - Add owner member to struct tty_ldisc
# - Init tty_ldisc at compile time
# - make some functions static
# --------------------------------------------
# 03/04/21	torvalds@penguin.transmeta.com	1.1118.1.48
# Allow gcc to generate better code for irq handling.
# 
# Ok, now that most drivers have been converted to the new
# irqreturn_t, we can remove the fascist type-checks and just
# use a regular integer type which has a simpler calling
# convention.
# --------------------------------------------
# 03/04/21	rml@tech9.net	1.1118.13.1
# [PATCH] trivial task_prio() fix
# 
# Here is a trivial fix for task_prio() in the case MAX_RT_PRIO !=
# MAX_USER_RT_PRIO.  In this case, all priorities are skewed by
# (MAX_RT_PRIO - MAX_USER_RT_PRIO).
# 
# The fix is to subtract the full MAX_RT_PRIO value from p->prio, not just
# MAX_USER_RT_PRIO.  This makes sense, as the full priority range is
# unrelated to the maximum user value.  Only the real maximum RT value
# matters.
# 
# This has been in Andrew's tree for awhile, with no issue.  Also, Ingo
# acked it.
# --------------------------------------------
# 03/04/21	torvalds@penguin.transmeta.com	1.1118.1.49
# Merge home:v2.5/linux
# into penguin.transmeta.com:/home/penguin/torvalds/repositories/kernel/linux
# --------------------------------------------
# 03/04/21	greg@kroah.com	1.1118.14.1
# Merge kroah.com:/home/greg/linux/BK/bleed-2.5
# into kroah.com:/home/greg/linux/BK/gregkh-2.5
# --------------------------------------------
# 03/04/21	jejb@raven.il.steeleye.com	1.1118.10.8
# irqreturn_t fixup for 53c700
# --------------------------------------------
# 03/04/21	elenstev@com.rmk.(none)	1.1118.11.4
# [ARM] spelling fixes for arm
# 
# Patch from Steven Cole.
# 
# Here are some spelling fixes for arm.
# This was diffed against the current 2.5 tree.
# --------------------------------------------
# 03/04/22	rmk@flint.arm.linux.org.uk	1.1118.15.1
# Merge flint.arm.linux.org.uk:/usr/src/linux-bk-2.5/linux-2.5
# into flint.arm.linux.org.uk:/usr/src/linux-bk-2.5/linux-2.5-rmk
# --------------------------------------------
# 03/04/21	akpm@digeo.com	1.1118.1.50
# [PATCH] More careful about VMA merging
# 
# The VMA merging code can merge vmas which have a ->vm_ops->close() handler.
# But this means that per-VMA resources in one of the merged VMAs will not be
# freed.
# 
# Fix that up by just refusing to merge any VMA's which look "complex": they
# have special flags set or they have a ->close handler.
# --------------------------------------------
# 03/04/21	ak@muc.de	1.1118.1.51
# [PATCH] Runtime memory barrier patching
# 
# This implements automatic code patching of memory barriers based
# on the CPU capabilities. Normally lock ; addl $0,(%esp) barriers
# are used, but these are a bit slow on the Pentium 4.
# 
# Linus proposed this a few weeks ago after the support for SSE1/SSE2
# barriers was introduced. I now got around to implement it.
# 
# The main advantage is that it allows distributors to ship less binary
# kernels but still get fast kernels. In particular it avoids the
# need of a special Pentium 4 kernel.
# 
# The patching code is quite generic and could be used to patch
# other instructions (like prefetches or specific other critical
# instructions) too.
# Thanks to Rusty's in kernel loader it also works seamlessly for modules.
# 
# The patching is done before other CPUs start to avoid potential
# erratas with self modifying code on SMP systems. It makes no
# attempt to automatically handle assymetric systems (an secondary
# CPU having less capabilities than the boot CPU). In this
# case just boot with "noreplacement"
# --------------------------------------------
# 03/04/21	patmans@us.ibm.com	1.1118.10.9
# [PATCH] fix ppa locking and oops
# 
# We no longer hold the host_lock while calling the detect function, so
# re-acquiring the lock while (without even unlocking it) in ppa_detect is
# very wrong. References to the possibly NULL value hreg can also cause
# oopses.
# --------------------------------------------
# 03/04/21	torvalds@home.transmeta.com	1.1118.1.52
# Add the Xeon variations (Pentium-III and P4-based) to the list
# of Intel CPU optimizations. From Andi Kleen.
# --------------------------------------------
# 03/04/21	torvalds@home.transmeta.com	1.1118.1.53
# Merge bk://bk.arm.linux.org.uk/linux-2.5-rmk
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/21	linux-bt.adm@hostme.bitkeeper.com	1.1118.16.1
# Merge bk://linux.bkbits.net/linux-2.5
# into hostme.bitkeeper.com:/ua/repos/l/linux-bt/bt-2.5
# --------------------------------------------
# 03/04/21	davem@nuts.ninka.net	1.1118.1.54
# Merge nuts.ninka.net:/home/davem/src/BK/network-2.5
# into nuts.ninka.net:/home/davem/src/BK/net-2.5
# --------------------------------------------
# 03/04/21	acme@conectiva.com.br	1.1118.17.1
# o rtnetlink: use C99 struct init style
# --------------------------------------------
# 03/04/22	acme@conectiva.com.br	1.1118.17.2
# o atm/lec.c: use C99 struct init style
# --------------------------------------------
# 03/04/22	acme@conectiva.com.br	1.1118.17.3
# o rtnetlink_dev: use C99 struct init style
# --------------------------------------------
# 03/04/21	torvalds@home.transmeta.com	1.1118.18.1
# Fix irq event debug print-out, and add stack dump which can
# give a clue about what the context was that might have caused
# the spurious interrupt.
# --------------------------------------------
# 03/04/21	elenstev@mesatop.com	1.1118.19.1
# [SPARC64]: Spelling fixes.
# --------------------------------------------
# 03/04/21	davem@nuts.ninka.net	1.1118.1.55
# Merge bk://kernel.bkbits.net/acme/net-2.5
# into nuts.ninka.net:/home/davem/src/BK/net-2.5
# --------------------------------------------
# 03/04/21	davem@nuts.ninka.net	1.1118.19.2
# [SPARC64]: Update defconfig.
# --------------------------------------------
# 03/04/22	davem@nuts.ninka.net	1.1118.1.56
# [NETLINK]: Fix minor numbers in netlink_dev.c
# --------------------------------------------
# 03/04/22	davem@nuts.ninka.net	1.1118.19.3
# [SPARC]: CLOCK_MONOTONIC fixes, from x86.
# --------------------------------------------
# 03/04/22	davem@nuts.ninka.net	1.1118.19.4
# [SPARC64]: Add LOOP_{GET,SET}_STATUS64 to ioctl32.
# --------------------------------------------
# 03/04/22	shemminger@osdl.org	1.1118.1.57
# [BRIDGE]: New maintainership.
# --------------------------------------------
# 03/04/22	steve@gw.chygwyn.com	1.1118.1.58
# [IP_GRE]: Kill duplicate update_pmtu call.
# --------------------------------------------
# 03/04/22	davem@kernel.bkbits.net	1.1118.18.2
# Merge davem@nuts.ninka.net:/home/davem/src/BK/sparc-2.5
# into kernel.bkbits.net:/home/davem/sparc-2.5
# --------------------------------------------
# 03/04/22	davem@kernel.bkbits.net	1.1118.1.59
# Merge davem@nuts.ninka.net:/home/davem/src/BK/net-2.5
# into kernel.bkbits.net:/home/davem/net-2.5
# --------------------------------------------
# 03/04/22	shaggy@shaggy.austin.ibm.com	1.1118.20.1
# Merge jfs@jfs.bkbits.net:linux-2.5
# into shaggy.austin.ibm.com:/shaggy/bk/jfs-2.5
# --------------------------------------------
# 03/04/22	mikenc@us.ibm.com	1.1118.10.10
# [PATCH] fixes compile errors in psi240i.c
# 
# The attached patch fixes the compile errors in psi240i.c described in
# Bugzilla bug #468 at http://bugme.osdl.org/show_bug.cgi?id=468. It was
# built against 2.5.68. I do not have the hardware, so I have only
# verified that it compiles correctly.
# --------------------------------------------
# 03/04/22	jejb@raven.il.steeleye.com	1.1118.10.11
# Add irqreturn_t to scsi/psi240i
# --------------------------------------------
# 03/04/22	axboe@suse.de	1.1118.21.1
# [PATCH] request structure stack corruption
# 
# This fixes a problem with drivers that have request on the stack for
# some operations, like IDE.  If we wake before releasing the request, the
# stack may have already disappeared beneath us when the rest of
# end_that_request_last() is run.
# 
# Fix by making sure the completion is done _last_.
# --------------------------------------------
# 03/04/22	torvalds@home.transmeta.com	1.1118.20.2
# Merge http://jfs.bkbits.net/linux-2.5
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/22	neilb@cse.unsw.edu.au	1.1118.20.3
# [PATCH] Update umem to new request_irq interface
# 
# request_irq requires a handler that returns irqreturn_t,
# so mm_interrupt now returns the appropriate value
# --------------------------------------------
# 03/04/22	neilb@cse.unsw.edu.au	1.1118.20.4
# [PATCH] Update umem driver for newer cards.
# --------------------------------------------
# 03/04/22	torvalds@home.transmeta.com	1.1118.18.3
# Merge bk://kernel.bkbits.net/davem/sparc-2.5
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/22	torvalds@home.transmeta.com	1.1118.1.60
# Merge bk://kernel.bkbits.net/davem/net-2.5
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/22	lkml@shemesh.biz	1.1118.1.61
# [PATCH] Fix IRDA irq handler prototype
# 
# This fixes a mismatch in declaration between "irport_interrupt" in the
# header files (returning void) and in the definition (returning
# irqreturn_t).
# --------------------------------------------
# 03/04/22	aia21@cantab.net	1.971.48.3
# NTFS: Fix typo and release 2.1.3.
# --------------------------------------------
# 03/04/22	aia21@cantab.net	1.1118.22.1
# Merge cantab.net:/home/aia21/bklinux-2.5
# into cantab.net:/home/aia21/ntfs-2.5
# --------------------------------------------
# 03/04/22	ahaas@airmail.net	1.1118.10.12
# [PATCH] C99 initializers for drivers/scsi
# 
# This set of 4 patches convert files to use C99 initializers. The patches
# are against the current BK.
# --------------------------------------------
# 03/04/22	jejb@raven.il.steeleye.com	1.1118.10.13
# Fix ncr53c8xx for PA-RISC Zalon SCSI driver
# 
# Although this driver is ancient and unmaintained, it is still used
# by the 53c700 based PA-RISC zalon.  The changes are:
# 
# - Add slave_configure entry for zalon
# - Moved to new error handling
# - changed to irqreturn_t for interrupt handler
# --------------------------------------------
# 03/04/22	jejb@raven.il.steeleye.com	1.1118.10.14
# Compile fix for 53c700 on PA-RISC
# --------------------------------------------
# 03/04/22	jejb@raven.il.steeleye.com	1.1118.1.62
# Merge raven.il.steeleye.com:/home/jejb/BK/scsi-misc-2.5
# into raven.il.steeleye.com:/home/jejb/BK/scsi-for-linus-2.5
# --------------------------------------------
# 03/04/22	zaitcev@redhat.com	1.1118.23.1
# [SPARC]: Colin Gibbs gcc-3.x support.
# --------------------------------------------
# 03/04/22	ebrower@usa.net	1.1118.23.2
# [SPARC]: Refactor AUXIO support.
# --------------------------------------------
# 03/04/23	acme@conectiva.com.br	1.1118.24.1
# o net: module refcounting for sk_alloc/sk_free
# 
# I had to move the rtnetlink_init and init_netlink calls to af_netlink init time, so that
# the sk_alloc called down the rtnetlink_init callchain is done after the PF_NETLINK
# net_proto_family is sock_registered, and because of that the af_netlink init function
# call had to be moved to earlier by means of subsys_initcall (DaveM's suggestion).
# --------------------------------------------
# 03/04/22	davem@nuts.ninka.net	1.1118.24.2
# [NET]: Do not let GCC reload pointers after NULL checks.
# --------------------------------------------
# 03/04/22	davem@nuts.ninka.net	1.1118.23.3
# [SPARC64]: Kill unnecessary MOD_{INC,DEC}_USE_COUNT in cpwatchdog and envctrl drivers.
# --------------------------------------------
# 03/04/22	dlstevens@us.ibm.com	1.1118.24.3
# [IGMPv3/MPDv2]: Bug fixes and ipv4 multiprotocol API.
# --------------------------------------------
# 03/04/22	dlstevens@us.ibm.com	1.1118.24.4
# [IGMP]: Fix bug in broadcast handling.
# --------------------------------------------
# 03/04/22	whydoubt@yahoo.com	1.1118.24.5
# [NETFILTER IPV4]: Fix typo in Kconfig.
# --------------------------------------------
# 03/04/22	yoshfuji@linux-ipv6.org	1.1118.24.6
# [IPV6]: dst_alloc() clean-up.
# --------------------------------------------
# 03/04/23	rob@osinvestor.com	1.1118.23.4
# [SPARC]: Kill initialize_secondary, unused.
# --------------------------------------------
# 03/04/23	davem@nuts.ninka.net	1.1118.24.7
# [NET]: SG without checksum support is illegal.
# --------------------------------------------
# 03/04/23	marcel@holtmann.org	1.971.23.3
# [Bluetooth] Fix L2CAP binding to local address
# 
# In the function l2cap_connect_ind() we compare the bounded
# address with the address of an incoming connection, but we
# have to compare it with the local address of the HCI device.
# --------------------------------------------
# 03/04/23	stevef@steveft21.ltcsamba	1.1120
# fix hang in truncate setting file size
# --------------------------------------------
# 03/04/23	torvalds@home.transmeta.com	1.1118.25.1
# Never merge vma's that have mapping-private data.
# --------------------------------------------
# 03/04/23	aia21@cantab.net	1.1118.26.1
# Merge cantab.net:/home/aia21/bklinux-2.5
# into cantab.net:/home/aia21/ntfs-2.5
# --------------------------------------------
# 03/04/23	maxk@qualcomm.com	1.1118.16.2
# Merge bk://linux-bt.bkbits.net/marcel-2.5
# into qualcomm.com:/home/kernel/bt-2.5
# --------------------------------------------
# 03/04/23	agrover@groveronline.com	1.971.119.3
# ACPI: Add missing include
# --------------------------------------------
# 03/04/23	agrover@groveronline.com	1.1118.25.2
# Merge groveronline.com:/root/bk/linux-2.5
# into groveronline.com:/root/bk/linux-acpi
# --------------------------------------------
# 03/04/23	agrover@groveronline.com	1.1118.25.3
# ACPI: Indicate whether we handled the interrupt or not
# --------------------------------------------
# 03/04/23	hch@lst.de	1.1118.27.1
# [PATCH] i2c: remove dead junk from i2c-sensors.h
# --------------------------------------------
# 03/04/23	hch@lst.de	1.1118.27.2
# [PATCH] i2c: remove dead code from adm1021
# 
# Enough testing :)  This is the last user of some junk in i2c-sensors.h,
# so it should better go away sooner than later..
# --------------------------------------------
# 03/04/23	hch@lst.de	1.1118.27.3
# [PATCH] i2c: remove dead init code from i2c-sensors.c
# --------------------------------------------
# 03/04/23	hch@lst.de	1.1118.27.4
# [PATCH] i2c: bring i2c-viapro uptodate with the style guide
# --------------------------------------------
# 03/04/23	linux-bt.adm@hostme.bitkeeper.com	1.1118.28.1
# Merge bk://linux.bkbits.net/linux-2.5
# into hostme.bitkeeper.com:/ua/repos/l/linux-bt/bt-2.5
# --------------------------------------------
# 03/04/23	akpm@digeo.com	1.1118.14.2
# [PATCH] usb: minor usb stuff
# 
# - nail a couple of warnings
# 
# - usbnet is not compilable with gcc-2.95.3.  Fix.
# --------------------------------------------
# 03/04/23	david-b@pacbell.net	1.1118.14.3
# [PATCH] USB: hcd-pci.c catch up to dev_printk changes
# 
# The preceding patch to fix this was incomplete, since
# it didn't work for the pure debug messages.  And that
# was because the DEBUG-vs-CONFIG_USB_DEBUG stuff changed
# somewhere.
# --------------------------------------------
# 03/04/23	david-b@pacbell.net	1.1118.14.4
# [PATCH] usb: fix (rare?) disconnect
# 
# It's not good to dereference pointers before checking
# them for null.  Seen once on a faulty device init,
# which I don't think I'd ever seen before "in the wild".
# (Caused by some other 2.5.68 strangeness.)
# --------------------------------------------
# 03/04/23	baldrick@wanadoo.fr	1.1118.14.5
# [PATCH] USB speedtouch: bump the version number
# --------------------------------------------
# 03/04/23	baldrick@wanadoo.fr	1.1118.14.6
# [PATCH] USB speedtouch: crc optimization
# --------------------------------------------
# 03/04/23	baldrick@wanadoo.fr	1.1118.14.7
# [PATCH] USB speedtouch: compile fix
# 
# The rx_inuse field no longer exists.
# --------------------------------------------
# 03/04/23	marcel@holtmann.org	1.1118.28.2
# [Bluetooth] Correction of the HCI USB driver description
# 
# This patch reverts the module description and other comments.
# --------------------------------------------
# 03/04/23	torvalds@home.transmeta.com	1.1118.23.5
# Merge bk://kernel.bkbits.net/davem/sparc-2.5
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/23	torvalds@home.transmeta.com	1.1118.23.6
# Merge bk://kernel.bkbits.net/davem/net-2.5
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/23	proski@org.rmk.(none)	1.1118.29.1
# [PCMCIA] Fix compilation of cardmgr
# 
# Patch from Pavel Roskin
# 
# ds.h should not be including linux/device.h when compiling userspace
# code.
# --------------------------------------------
# 03/04/23	hch@de.rmk.(none)	1.1118.29.2
# [PCMCIA] remove unused files
# 
# From Christoph Hellwig
# 
# There's no need to keep the stubs around.
# --------------------------------------------
# 03/04/23	proski@org.rmk.(none)	1.1118.29.3
# [PCMCIA] Fix oops in validate_mem when CONFIG_PCMCIA_PROBE=n
# 
# If I compile a recent 2.5.x kernel without CONFIG_ISA defined, I get
# an oops in validate_mem().  Stack trace contains 0x6b6b6b6 - a clear
# sign that freed memory is being accessed.
# 
# It's the second validate_mem() in drivers/pcmcia/rsrc_mgr.c - the one
# used when CONFIG_PCMCIA_PROBE is not defined.  It turns out the memory
# is freed in do_mem_probe() when it's called from validate_mem().
# 
# The solution is to use the same trick as in the first validate_mem().
# This problem is quite serious and it's not specific to the plx9052
# driver. I see it with yenta_socket as well.
# --------------------------------------------
# 03/04/23	rmk@flint.arm.linux.org.uk	1.1118.29.4
# [PCMCIA] Don't cache CIS bytes found to be invalid.
# 
# Several PCMCIA cards I have here do not work correctly over a
# suspend/resume cycle; the PCMCIA code believes that the card has
# been changed in the slot, and therefore performs a remove/insert
# cycle.
# 
# This seems to be because the card returns more or less random data
# when reading memory space, leading to the CIS cache mismatching
# the card data.  This in turn is caused because we try to read CIS
# data from both the attribute and memory spaces, and we add the result
# to the CIS cache whether or not the returned data was valid.
# 
# We therefore convert the CIS cache to use a linked list, and provide
# a way to remove cached data from that list.  We also replace the
# "s->cis_used=0;" construct with a function "destroy_cis_cache(s)"
# which clearly describes what we're doing.
# --------------------------------------------
# 03/04/23	rmk@flint.arm.linux.org.uk	1.1118.29.5
# [PCMCIA] Make cb_release_cis_mem() local to cardbus.c
# 
# The cardbus CIS parsing code does not use the PCMCIA resource
# subsystem, so there isn't any point in freeing its memory when
# we remove PCMCIA memory resources.  We also free CIS resources
# immediately prior to calling cb_free().  We might as well move
# the function call into cb_free(), thereby making all references
# to cb_release_cis_mem() local to cardbus.c
# --------------------------------------------
# 03/04/23	torvalds@home.transmeta.com	1.1118.23.7
# Merge bk://bk.arm.linux.org.uk/linux-2.5-pcmcia
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/23	linux-bt.adm@hostme.bitkeeper.com	1.1118.30.1
# Merge bk://linux.bkbits.net/linux-2.5
# into hostme.bitkeeper.com:/ua/repos/l/linux-bt/bt-2.5
# --------------------------------------------
# 03/04/23	maxk@qualcomm.com	1.1118.30.2
# Merge bk://linux-bt@linux-bt.bkbits.net/bt-2.5
# into qualcomm.com:/home/kernel/bt-2.5
# --------------------------------------------
# 03/04/23	greg@kroah.com	1.1118.14.8
# [PATCH] USB: cdc-acm: add support for new tty tiocmget and tiocmset functions.
# --------------------------------------------
# 03/04/23	greg@kroah.com	1.1118.14.9
# [PATCH] USB: usb-serial core: add support for new tty tiocmget and tiocmset functions.
# --------------------------------------------
# 03/04/23	greg@kroah.com	1.1118.14.10
# [PATCH] USB: belkin_sa: add support for new tty tiocmget and tiocmset functions.
# --------------------------------------------
# 03/04/23	greg@kroah.com	1.1118.14.11
# [PATCH] USB: digi_acceleport: add support for new tty tiocmget and tiocmset functions.
# --------------------------------------------
# 03/04/23	greg@kroah.com	1.1118.14.12
# [PATCH] USB: ftdi_sio: add support for new tty tiocmget and tiocmset functions.
# --------------------------------------------
# 03/04/23	greg@kroah.com	1.1118.14.13
# [PATCH] USB: keyspan_pda: add support for new tty tiocmget and tiocmset functions.
# --------------------------------------------
# 03/04/23	greg@kroah.com	1.1118.14.14
# [PATCH] USB: kl5kusb105: add support for new tty tiocmget and tiocmset functions.
# --------------------------------------------
# 03/04/23	greg@kroah.com	1.1118.14.15
# [PATCH] USB: kobil_sct: add support for new tty tiocmget and tiocmset functions.
# --------------------------------------------
# 03/04/23	greg@kroah.com	1.1118.14.16
# [PATCH] USB: mct_u232: add support for new tty tiocmget and tiocmset functions.
# --------------------------------------------
# 03/04/23	greg@kroah.com	1.1118.14.17
# [PATCH] USB: pl2303: add support for new tty tiocmget and tiocmset functions.
# --------------------------------------------
# 03/04/23	greg@kroah.com	1.1118.14.18
# [PATCH] USB: whiteheat: add support for new tty tiocmget and tiocmset functions.
# --------------------------------------------
# 03/04/23	bcollins@debian.org	1.1118.23.8
# [PATCH] IEEE1394/Firewire updates
# 
# - Workaround possible reset loop trying to get IRM sanity
# - Logical Unit DIrectory (LUN) support for sbp2(scsi) devices.
# - Fix hostnum allocation.
# - Whitespace and formatting sync with 2.4 branch.
# - Make pcilynx return IRQ_NONE for no interrupts to handle.
# --------------------------------------------
# 03/04/23	pavel@ucw.cz	1.1118.23.9
# [PATCH] Fix SWSUSP & !SWAP
# 
# Swsusp without swap makes no sense, and leads to compilation
# failure.  So make the dependency clear in the config files.
# --------------------------------------------
# 03/04/23	elenstev@mesatop.com	1.1118.23.10
# [PATCH] Avast there ye swabs, prepare to fire a broadside!
# 
# Chuck Ebbert notes that kernel developers are apparently pirates in the
# _original_ meaning of the word, and like to "cannonicalize".
# 
# I prepared a patch in case anyone cares enough about this.  I tested on
# i386 by building and booting.
# --------------------------------------------
# 03/04/23	ahaas@airmail.net	1.1118.23.11
# [PATCH] C99 initializers for drivers/block/genhd.c
# --------------------------------------------
# 03/04/23	ahaas@airmail.net	1.1118.23.12
# [PATCH] Fix C99 initializers in fs/nfs/nfs4proc.c
# --------------------------------------------
# 03/04/23	ahaas@airmail.net	1.1118.23.13
# [PATCH] C99 initializers for fs/proc/proc_misc.c
# --------------------------------------------
# 03/04/23	viro@www.linux.org.uk	1.1118.23.14
# [PATCH] tty cleanups (1/12)
# 
# 	Christoph's fix for devfs problems with pty.
# --------------------------------------------
# 03/04/23	viro@www.linux.org.uk	1.1118.23.15
# [PATCH] tty cleanups (2/12)
# 
# 	Instead of copying tty_driver into tty_struct we put a reference
# in there.  tty->driver turned into a pointer, users updated.  Large, but
# trivial
# --------------------------------------------
# 03/04/23	viro@www.linux.org.uk	1.1118.23.16
# [PATCH] tty cleanups (3/12)
# 
# 	/proc/tty/drivers converted to seq_file
# --------------------------------------------
# 03/04/23	viro@www.linux.org.uk	1.1118.23.17
# [PATCH] tty cleanups (4/12)
# 
# 	Instead of registering "drivers" for /dev/tty, /dev/vc/0, /dev/ptmx
# and /dev/console (they are never looked up since tty_open() special-cases
# them and they should not be looked up - these devices are remapped on open)
# we register corresponding chrdev ranges and devfs nodes directly.
# 	/proc/tty/drivers code updated to keep the contents unchanged
# --------------------------------------------
# 03/04/23	viro@www.linux.org.uk	1.1118.23.18
# [PATCH] tty cleanups (5/12)
# 
# 	new field - tty->tty_name;
# 	initialized to <driver->name><tty index+driver->base_name>
# when we allocate tty_struct.  Drivers code switched to use of that
# beast (in debugging printks, mostly).  Large, but trivial.
# --------------------------------------------
# 03/04/23	viro@www.linux.org.uk	1.1118.23.19
# [PATCH] tty cleanups (6/12)
# 
# 	tty->tty_index added; we initialize it with minor(tty->device) -
# tty->driver->minor_start.  Majority of remaining tty->device uses had
# that form and are switched to use of tty->index.
# --------------------------------------------
# 03/04/23	viro@www.linux.org.uk	1.1118.23.20
# [PATCH] tty cleanups (7/12)
# 
# 	sanitized driver->driver_name initialization and use
# --------------------------------------------
# 03/04/23	viro@www.linux.org.uk	1.1118.23.21
# [PATCH] tty cleanups (8/12)
# 
# 	* generic_serial.c typo fix (->driver used instead of correct
# ->driver_data)
# 	* tubio cleaned up
# --------------------------------------------
# 03/04/23	viro@www.linux.org.uk	1.1118.23.22
# [PATCH] tty cleanups (9/12)
# 
# 	* drivers/char/rio/* supports up to 4 boards, each with up to 128
# lines.  It used to share termios for 1st/3rd and 2nd/4th boards,  Fixed.
# 	* cleanups and kdev_t removals - we pass tty instead of tty->device
# in a couple of helper functions and instead of comparisons on major(tty->device)
# we check where does tty->driver point to.
# --------------------------------------------
# 03/04/23	viro@www.linux.org.uk	1.1118.23.23
# [PATCH] tty cleanups (10/12)
# 
# Preparations to cleanup:
# 	* call of get_tty_driver() moved from init_dev() to its callers
# 	* instead of kdev_t dev we pass struct tty_struct *driver and int index
# --------------------------------------------
# 03/04/23	viro@www.linux.org.uk	1.1118.23.24
# [PATCH] tty cleanups (11/12)
# 
# 	tty->device switched to dev_t
# 	There are very few uses of tty->device left by now; most of
# them actually want dev_t (process accounting, proc/<pid>/stat, several
# ioctls, slip.c logics, etc.) and the rest will go away shortly.
# --------------------------------------------
# 03/04/23	viro@www.linux.org.uk	1.1118.23.25
# [PATCH] tty cleanups (12/12)
# 
# 	* we allow tty_driver to cover more than 256 devices
# 	* pty.c cleaned up - now we only one driver for UNIX98 masters and
# only one driver for UNIX98 slaves, so a lot of ugliness can be killed.
# 	* get_tty_driver() became an analog of get_gendisk() - it does
# a lookup by device number and gives (pointer to tty_driver,index).
# 	* registration/unregistration of tty_driver updated
# 	* /proc/tty/drivers code updated (now one structure can be responsible
# for several lines)
# --------------------------------------------
# 03/04/23	torvalds@home.transmeta.com	1.1118.23.26
# Since "apply_alternatives()" also runs at module load time it must
# not be marked __init.
# 
# Noted by Petr Vandrovec
# --------------------------------------------
# 03/04/23	hch@lst.de	1.1118.23.27
# [PATCH] split initrd from ramdisk driver
# 
# They don't have any code in common, so the initrd support can
# go into a separate file and not require ramdisk support.
# 
# Lots of ifdefs gone and smaller kernel images for initrd users.
# --------------------------------------------
# 03/04/23	hch@lst.de	1.1118.23.28
# [PATCH] kill LOCAL_END_REQUEST
# 
# And uninline end_request - it's calling to many functions to be useful
# inline.
# --------------------------------------------
# 03/04/23	hch@lst.de	1.1118.23.29
# [PATCH] don't use mem_map_reserve/mem_map_unreserve
# 
# They are obsfucating aliases for SetPageReserved/ClearPageReserved.
# And once they're gone we can nuke <linux/wrapper.h>
# --------------------------------------------
# 03/04/23	hch@lst.de	1.1118.23.30
# [PATCH] don't include devfs_fs_kernel.h in global headers
# 
# Now that devfs_handle_t is gone from all structs there is no
# reason to include it in headers.
# 
# Fix the fallout by including previously implicit headers and fixing
# the drivers that didn't include devfs_fs_kernel.h explicitly.
# --------------------------------------------
# 03/04/23	hch@lst.de	1.1118.23.31
# [PATCH] fix devfs_mk_dir prototype
# 
# Return an error code instead of a devfs_handle_t.  The handle isn't
# useful for anything and the !CONFIG_DEVFS_FS stub in fact returned
# NULL which made it entirely useless.  Thus only one driver is actually
# checking the retval in the current tree..
# --------------------------------------------
# 03/04/23	hch@lst.de	1.1118.23.32
# [PATCH] update s390 tape_block for 2.5 APIs
# 
# It looks like no one even tried to use it on 2.5..
# --------------------------------------------
# 03/04/23	hch@lst.de	1.1118.23.33
# [PATCH] remove a wrong invalidate_bdev from ide-disk.c
# 
# This one probably crept in during an ide merge from 2.4..
# --------------------------------------------
# 03/04/23	hch@lst.de	1.1118.23.34
# [PATCH] fix dasd open/release
# 
# The invalidate_buffers in ->release is wrong, get a reference to the
# discipline in the beginning of ->open.
# --------------------------------------------
# 03/04/23	akpm@digeo.com	1.1118.23.35
# [PATCH] print IRQ handler addresses
# 
# - Fix printk bug in the diagnostic code.
# 
# - If an error occurs, print the address of all the offending action
#   handlers.  Also the symbol name if CONFIG_KALLSYMS.
# --------------------------------------------
# 03/04/23	akpm@digeo.com	1.1118.23.36
# [PATCH] warning fixes
# 
# Fix some warnings from the new code-patching stuff.
# --------------------------------------------
# 03/04/23	akpm@digeo.com	1.1118.23.37
# [PATCH] fix typo in m68k mm code
# 
# Looks like my finger fell off the control key..
# --------------------------------------------
# 03/04/23	jgarzik@redhat.com	1.1118.31.1
# [netdrvr tg3] detect shared (and screaming) interrupts
# --------------------------------------------
# 03/04/23	jgarzik@redhat.com	1.1118.23.38
# Merge redhat.com:/garz/repo/linus-2.5
# into redhat.com:/garz/repo/net-drivers-2.5
# --------------------------------------------
# 03/04/23	jgarzik@redhat.com	1.1118.23.39
# [netdrvr tg3] fix omission in board shutdown sequence
# --------------------------------------------
# 03/04/24	shemminger@osdl.org	1.1118.32.1
# [BRIDGE]: Missing unlocks in ioctl error paths.
# --------------------------------------------
# 03/04/24	shemminger@osdl.org	1.1118.32.2
# [BRIDGE]: Bridge confuses kernel user HZ.
# --------------------------------------------
# 03/04/24	hch@lst.de	1.1118.1.63
# [PATCH] remove proc_print_scsidevice abuse from drivers
# 
# proc_print_scsidevice is used for the scsi device listing in
# /proc/scsi/scsi, but in addition two drivers (advansys and eata_pio)
# are using it to duplicate the same information in their proc_info
# method.  Remove that output and make the function static to
# scsi_proc.c.  Also remove proc_scsi from the public headers - it
# should really be private to the scsi midlayer but I don't think
# we can shange the sg procfs name anymore.
# --------------------------------------------
# 03/04/24	patmans@us.ibm.com	1.1118.1.64
# [PATCH] scsi-misc-2.5 fix repeat_inquiry bflags setting
# 
# James -
# 
# The new printk for BLIST_INQUIRY_36 is getting a warning, and the
# repeat_inquiry code is not quite right, since we reset *bflags after
# getting the first INQUIRY.
# 
# Get rid of the warning, change the or-ing of the bflags settings, and get
# rid of an extraneous BUG_ON.
# 
# ===== drivers/scsi/scsi_scan.c 1.78 vs edited =====
# --------------------------------------------
# 03/04/24	dmo@osdl.org	1.1118.1.65
# [PATCH] 2.5.68 scsi/gdth compile warnings and stack usage
# 
# James Bottomley, please apply this patch.  It was sent out on
# linux-scsi last week and drew no responses.
# 
# This is a patch for the scsi/gdth driver.  It was originally
# done in 2.5.67, but the patch applies to 2.5.68.
# 
# There are two components to this patch.  The first component fixes
# with compilation warnings (which did uncover real bugs).  The other component
# (by Randy Dunlap) reduces stack size usage in gdth_ioctl().
# 
# The compilation warnings occur only when CONFIG_HIGHMEM=y in the kernel
# configuration file (enable either 4gig or 64gig memory support).  This
# changes the size of the dma_addr_t from u32 to u64.
# The calls to pci_alloc_consistent return a value of type dma_addr_t.
# But the code was casting a pointer to what was ony a 32-bit memory location.
# 
# This seonc component of the patch reduces stack size in
# scsi/gdth.c::gdth_ioctl() by making each separate ioctl have its own
# handler function, so that several large data structs are all declared on
# the stack at the same time.
# 
# patch_name:     gdth-stack_warnings.patch
# patch_version:  2003-04-14.16:31:30
# author:         Randy.Dunlap <rddunlap@osdl.org>, Dave.Olien<dmo@osdl.org)
# description:    reduce stack usage in drivers/scsi/gdth.c::gdth_ioctl()
#                 from 0xb50 to 0x5c (on P4, gcc 2.96); the large (ioctl)
#                 function sizes in gdth.o now are:
#                         150 ioc_event
#                         178 ioc_resetdrv
#                         190 ioc_general
#                         30c ioc_hdrlist
#                         324 ioc_rescan
#                 so the largest cumulative size of calling gdth_ioctl() +
#                 a specific ioctl is 0x5c + 0x324 = 0x380.
# 		Fix compilation warnings in calls to pci_alloc_consistent()
# 		that occur only when CONFIG_HIGHMEM=y.  The compiler
# 		warnings result from dma_addr_t changing in size from u32
# 		to u64.
# product:        Linux
# product_versions: 2.5.67
# changelog:      make each ioctl that uses large stack space into its own
#                 function;
#                 mostly moving lines of code around;
#                 duplicates some local data in multiple functions;
# 		fix compiler warnings by adding intermediate dma_addr_t local
# 		variables to hold returns from pci_alloc_consistent.
# maintainer:     Achim Leubner (achim.leubner@intel.com)
# diffstat:	=
#  drivers/scsi/gdth.c      |  664 ++++++++++++++++++++++++++---------------------
#  drivers/scsi/gdth_proc.c |    5
#  2 files changed, 374 insertions(+), 295 deletions(-)
# 
# FYI:  The killer data structs in gdth_ioctl() (on x86, P4, gcc 2.96) are:
#                 sizeof gdth_cmd_str: 336 bytes
#                 sizeof gdth_ioctl_general: 356 bytes
#                 sizeof gdth_ioctl_event: 308 bytes
#                 sizeof gdth_ioctl_lockdrv: 204 bytes
#                 sizeof gdth_ioctl_rescan: 406 bytes
# 
# ###
# --------------------------------------------
# 03/04/24	akpm@digeo.com	1.1118.1.66
# [PATCH] irqs: scsi
# 
# Update SCSI drivers for the new IRQ API.  Also fix warnings and compilation
# errors as encountered.
# --------------------------------------------
# 03/04/24	jejb@mulgrave.(none)	1.1118.1.67
# convert Megaraid to irqreturn_t
# --------------------------------------------
# 03/04/24	florin@iucha.net	1.1118.27.5
# [PATCH] i2c: added it87 driver
# --------------------------------------------
# 03/04/24	B.Zolnierkiewicz@elka.pw.edu.pl	1.1118.33.1
# [PATCH] fix init_irq
# 
# The patch is obviously correct and has been floating on lkml for some time.
# 
# From Manfred Spraul:
#  "My init_irq cleanup introduced a bug: on error, the function must return 1."
# --------------------------------------------
# 03/04/24	hch@lst.de	1.1118.33.2
# [PATCH] Fix devfs botch in IDE naming
# 
# Linus, could you please apply this patch so all thos poor devfs
# users get their disks back?
# --------------------------------------------
# 03/04/24	greg@kroah.com	1.1118.27.6
# [PATCH] i2c: fix up it87.c check_region mess.
# --------------------------------------------
# 03/04/24	greg@kroah.com	1.1118.27.7
# [PATCH] i2c: removed unused flags paramater in found_proc callback.
# --------------------------------------------
# 03/04/24	greg@kroah.com	1.1118.27.8
# [PATCH] i2c: fix up the media drivers due to removing flags paramater of callback function
# --------------------------------------------
# 03/04/24	greg@kroah.com	1.1118.27.9
# [PATCH] i2c: removed unneeded typedef from i2c-sensor.h
# --------------------------------------------
# 03/04/24	davem@nuts.ninka.net	1.1118.33.3
# Merge nuts.ninka.net:/home/davem/src/BK/network-2.5
# into nuts.ninka.net:/home/davem/src/BK/net-2.5
# --------------------------------------------
# 03/04/24	davem@nuts.ninka.net	1.1118.33.4
# [USB INPUT]: hiddev.c needs dev_fs_kernel.h
# --------------------------------------------
# 03/04/24	greg@kroah.com	1.1118.27.10
# [PATCH] i2c: remove a lot of dupliated macros from i2c-sensor.h and use the current values in i2c.h
# --------------------------------------------
# 03/04/24	greg@kroah.com	1.1118.14.19
# [PATCH] USB: add error reporting functionality to the pl2303 driver.
# --------------------------------------------
# 03/04/24	greg@kroah.com	1.1118.33.5
# Merge kroah.com:/home/greg/linux/BK/bleed-2.5
# into kroah.com:/home/greg/linux/BK/gregkh-2.5
# --------------------------------------------
# 03/04/24	greg@kroah.com	1.1118.33.6
# [PATCH] tty: let tiocmset pass TIOCM_LOOP changes to the tty drivers.
# --------------------------------------------
# 03/04/24	greg@kroah.com	1.1118.34.1
# Merge kroah.com:/home/greg/linux/BK/bleed-2.5
# into kroah.com:/home/greg/linux/BK/i2c-2.5
# --------------------------------------------
# 03/04/24	torvalds@home.transmeta.com	1.1118.33.7
# Merge bk://kernel.bkbits.net/gregkh/linux/i2c-2.5
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/24	ak@muc.de	1.1118.33.8
# [PATCH] Minor 32bit Opteron fixes
# 
# Don't disable the Northbridge Machine Check.
# 
# Use the unrolled "INTEL_USERCOPY" too.
# --------------------------------------------
# 03/04/24	viro@parcelfarce.linux.theplanet.co.uk	1.1118.33.9
# [PATCH] console cleanup (1/2)
# 
# 	Preparation to console->device() cleanup: serial drivers converted
# to common helper for their ->device() methods.
# --------------------------------------------
# 03/04/24	viro@parcelfarce.linux.theplanet.co.uk	1.1118.33.10
# [PATCH] console cleanup (2/2)
# 
# 	Console drivers cleanup.  In current tree interaction between
# console and tty layer sits in the ->device() method of struct console.
# It takes a pointer to console and returns device number of its tty
# device.  open(2) on /dev/console goes through the list of registered
# consoles, picks the first one that has ->device() and remaps the device
# number to console->device(console).  Then it proceeds with normal
# opening of tty.  This is the only caller of ->device().
# 
# 	Cleanup: let ->device() return a pair (pointer to tty_driver, index
# of tty in question) instead of device number.  Note that
# 	a) the first thing tty_open() does with remapped device number is
# conversion to such pair.
# 	b) console driver _knows_ which tty_driver we want - one that
# implements tty interface to the same physical device (i.e. the part of
# the same driver).
# 	c) current code expects the result of ->device() to be a device
# number of tty device - anything else is immediate -ENODEV from tty_open();
# might as well have NULL ->device in that driver.
# 
# 	Console drivers converted, (the only) caller updated.
# --------------------------------------------
# 03/04/24	viro@parcelfarce.linux.theplanet.co.uk	1.1118.33.11
# [PATCH] fbdev cleanup
# 
# 	fbdev.node converted from kdev_t to int - all of its users
# have register_framebuffer() which sets .node to mk_kdev(FB_MAJOR, index)
# already called and all of them start with applying minor().  IOW, what
# they actually want is framebuffer number.
# 
# 	* type of ->node changed to int
# 	* register_framebuffer() sets it to index instead of mk_kdev(...)
# 	* users converted from minor(foo.node) to foo.node
# 	* useless assignments (typically to NODEV) removed - we never
# look at that field before register_framebuffer() overwrites it and thus
# any assignments prior to register_framebuffer() call are dead code.
# --------------------------------------------
# 03/04/24	viro@parcelfarce.linux.theplanet.co.uk	1.1118.33.12
# [PATCH] capifs cleanup
# 
# 	capifs switched to ramfs-style tree and cleaned up; it's the same
# changes that had been done its prototype (devpts) + stuff needed to
# deal with unload (devpts is non-modular and always internally mounted).
# --------------------------------------------
# 03/04/24	viro@parcelfarce.linux.theplanet.co.uk	1.1118.33.13
# [PATCH] invalidate_device()/check_disk_change() fixes
# 
# 	* bogus calls of invalidate_buffers() gone from floppy_open()
# 	* invalidate_buffers() killed.
# 
# 	* new helper - __invalidate_device(bdev, do_sync).  invalidate_device()
# is calling it.
# 
# 	* fixed races between floppy_open()/floppy_open and
# floppy_open()/set_geometry():
# 	a) floppy_open()/floppy_release() is done under a semaphore.  That
# closes the races between simultaneous open() on /dev/fd0foo and /dev/fd0bar.
# 	b) pointer to struct block_device is kept as long as floppy is
# opened (per-drive, non-NULL when number of openers is non-zero, does not
# contribute to block_device refcount).
# 	c) set_geometry() grabs the same semaphore and invalidates the
# devices directly instead of messing with setting fake "it had changed"
# and calling __check_disk_change().
# 
# 	* __check_disk_change() killed - no remaining callers
# 	* full_check_disk_change() killed - ditto.
# --------------------------------------------
# 03/04/24	viro@parcelfarce.linux.theplanet.co.uk	1.1118.33.14
# [PATCH] ppc boot device selection cleanup
# 
# 	PPC logics for choice of default boot device number switched to
# dev_t.  Rationale: it belongs to userland; we notice partitions with
# certain properties and choose one of them as the best candidate for
# being a root fs; then we put the resulting device number into ROOT_DEV,
# which has only one use - it's passed to mknod(2) to create a device node
# on rootfs and allow mount(2) get us the final root.
# 
# 	IOW, all that code has nothing whatsoever with kernel internals
# of any description - the value we are generating will be passed to
# mknod(2) anyway.  Switched to dev_t.
# 
# 	Note: that code should eventually be moved to early userland.
# --------------------------------------------
# 03/04/24	anton@samba.org	1.1118.33.15
# [PATCH] ppc64 needs setup-bus.c
# --------------------------------------------
# 03/04/24	hch@lst.de	1.1118.33.16
# [PATCH] kill <linux/wrapper.h>
# 
# Kill one user of mem_map_reserve/mem_map_unreserve I missed the
# last time and it can go away.
# --------------------------------------------
# 03/04/24	hch@lst.de	1.1118.33.17
# [PATCH] use file->private_data in ide-tape
# 
# So we don't have to lookup the private data everytime.
# --------------------------------------------
# 03/04/24	axboe@suse.de	1.1118.33.18
# [PATCH] cleanup bio_map_user and helper
# 
# Bart did this patch, I changed it a bit. Basically it cleans the mapping
# interface up a bit, and adds a little helper to set up the request from
# the bio.
# 
# In addition, it fixes a long standing bug where bio_map_user() would
# call blk_queue_bounce() without the direction bit being set, auch.
# 
#  - Abstract out bio request preparation
#  - Have bio_map_user() set data direction (fixes bug where blk_queue_bounce()
#    is called without it set)
#  - Split bio_map_user() in two
# --------------------------------------------
# 03/04/24	B.Zolnierkiewicz@elka.pw.edu.pl	1.1118.33.19
# [PATCH] fix mismatched access_ok() checks in sg_io()
# 
# I found this while doing bio_map_user() changes.
# 
# Acked by Jens.
# --------------------------------------------
# 03/04/24	akpm@digeo.com	1.1118.33.20
# [PATCH] Fix IRQ_NONE clash
# 
# Several scsi drivers are already using an IRQ_NONE.  Rename that to
# SCSI_IRQ_NONE.
# --------------------------------------------
# 03/04/24	akpm@digeo.com	1.1118.33.21
# [PATCH] irqs: ATM
# 
# Update ATM drivers to new IRQ API
# --------------------------------------------
# 03/04/24	akpm@digeo.com	1.1118.33.22
# [PATCH] irqs: drivers/block
# 
# Mop up various block and cdrom drivers.  Also fix a bunch of warnings and
# compilation failures.
# --------------------------------------------
# 03/04/24	akpm@digeo.com	1.1118.33.23
# [PATCH] irqs: char drivers
# 
# Fix up various char drivers for the IRQ API change.  Also IDE, ISDN and i2o
# bits.  Fix various warnings and compilation errors.
# --------------------------------------------
# 03/04/24	akpm@digeo.com	1.1118.33.24
# [PATCH] irqs: scsi
# 
# Update SCSI drivers for the new IRQ API.  Also fix warnings and compilation
# errors as encountered.
# --------------------------------------------
# 03/04/24	akpm@digeo.com	1.1118.33.25
# [PATCH] sound driver fixes
# 
# All these drivers have a return hidden in a macro and I missed the lot in the
# first pass due to some config option not begin set.
# --------------------------------------------
# 03/04/24	akpm@digeo.com	1.1118.33.26
# [PATCH] CPU flags fixes
# 
# teach various drivers that the CPU flags require unsigned long
# --------------------------------------------
# 03/04/24	akpm@digeo.com	1.1118.33.27
# [PATCH] various irqreturn_t fixes
# 
# Basically a mop-up of missed bits.  Also fix various warnings and compilation
# errors.
# --------------------------------------------
# 03/04/24	akpm@digeo.com	1.1118.33.28
# [PATCH] parkbd.c jiffies fix
# 
# - jiffies is unsigned long
# 
# - don't zero-init BSS.
# --------------------------------------------
# 03/04/24	akpm@digeo.com	1.1118.33.29
# [PATCH] watchdog driver compile fixes
# 
# The header file cleanups bite.  All these watchdog drivers need fs.h for
# struct inode, struct file, etc.
# --------------------------------------------
# 03/04/24	akpm@digeo.com	1.1118.33.30
# [PATCH] bttv warning fix
# 
# Fix a bttv compile warning
# --------------------------------------------
# 03/04/24	akpm@digeo.com	1.1118.33.31
# [PATCH] jiffy type warning fixes
# 
# Fix various places which aren't using unsigned long for jiffies.
# 
# Also other warnings and compilation errors as encountered.
# --------------------------------------------
# 03/04/25	hunold@convergence.de	1.1118.33.32
# [PATCH] Fix mxb.c stack usage
# 
# This does the following:
#  - make initialization data for helper chipsets (saa7111 and saa7740)
#    static and with file scope
# 
# Additionally fixes:
#  - don't use irq driven i2c transfer when saa7740 is present (this screws
#    up the i2c bus and may hang the computer)
#  - add MODULE_DEVICE_TABLE to allow /sbin/hotplug to handle the device
# --------------------------------------------
# 03/04/25	l.s.r@web.de	1.1118.33.33
# [PATCH] Remove unused function from fs/isofs/rock.c
# 
# find_rock_ridge_relocation() has been unused since 2.4.0-test11 -- time
# to bury it.
# 
# Acked by Peter Anvin.
# --------------------------------------------
# 03/04/25	torvalds@home.transmeta.com	1.1118.33.34
# Merge with DRI CVS tree: remove stale old context switching code and
# DMA histogramming. Be more careful about DMA page-list allocations,
# and remove old and broken (not SMP-safe, and unused) DRM read(), write()
# and poll() support.
# --------------------------------------------
# 03/04/25	torvalds@penguin.transmeta.com	1.1118.33.35
# 'hw_status_page' looks like a pointer, quacks like a pointer and
# walks like a pointer. It _is_ a pointer. So make it one, and remove
# a lot of silly casts.
# --------------------------------------------
# 03/04/25	jgarzik@redhat.com	1.1118.33.36
# s/#if/#ifdef/ for a few CONFIG_SMP tests in public headers
# 
# Headers touched: linux/interrupt.h, linux/sched.h, linux/timer.h
# --------------------------------------------
# 03/04/25	jgarzik@redhat.com	1.1118.23.40
# Merge redhat.com:/garz/repo/linus-2.5
# into redhat.com:/garz/repo/net-drivers-2.5
# --------------------------------------------
# 03/04/25	riel@redhat.com	1.1118.23.41
# [wireless airo] make end-of-array test more portable
# 
# FYI statsLabels[] is an array of char*, so the fix below
# is pretty obvious.
# --------------------------------------------
# 03/04/25	edward_peng@dlink.com.tw	1.1118.23.42
# [netdrvr via-rhine] fix promisc mode
# 
# I found a via-rhine bug, it can't receive BPDU (mac: 0180c2000000)
# in promiscuous mode. 
# Fill all "1" in hash table to fix this problem in promiscuous mode.
# (RCR remain 0x1c, write it as 0x1f don't work)
# --------------------------------------------
# 03/04/25	pixi@burble.org	1.1118.33.37
# [quota] provide no-op sync_dquots_dev, one .config case wants it
# --------------------------------------------
# 03/04/25	jgarzik@redhat.com	1.1118.33.38
# [hw_random] fix bug, bump version
# 
# Fix ugly bug in read(2) path for odd buffer sizes.
# Noticed by Joseph Chan @ Via.
# 
# Bump version to 1.0.0.
# --------------------------------------------
# 03/04/25	edward_peng@dlink.com.tw	1.1118.23.43
# [netdrvr sundance] bug fixes, VLAN support
# 
#     - Fix tx bugs in big-endian machines
#     - Remove unused max_interrupt_work module parameter, the new 
#       NAPI-like rx scheme doesn't need it.
#     - Remove redundancy get_stats() in intr_handler(), those 
#       I/O access could affect performance in ARM-based system
#     - Add Linux software VLAN support
#     - Fix bug of custom mac address 
#     (StationAddr register only accept word write) 
# --------------------------------------------
# 03/04/25	Valdis.Kletnieks@vt.edu	1.1118.33.39
# cpp cleanups for ia32/io_apic.c, sound/oss/trident.c
# --------------------------------------------
# 03/04/25	Valdis.Kletnieks@vt.edu	1.1118.33.40
# cpp cleanups: use KERNEL_VERSION macro from linux/version.h
# 
# Updated ncr53c8xx and sym53c8xx scsi drivers.
# --------------------------------------------
# 03/04/25	yoshfuji@linux-ipv6.org	1.1118.35.1
# [IPV6]: SNMP6 clean-up.
# --------------------------------------------
# 03/04/26	Valdis.Kletnieks@vt.edu	1.1118.23.44
# [netdrvr typhoon] s/#if/#ifdef/ for a CONFIG_ var
# --------------------------------------------
# 03/04/25	yoshfuji@linux-ipv6.org	1.1118.35.2
# [IPV6]: Per-interface statistics infrastructure.
# --------------------------------------------
# 03/04/25	rddunlap@osdl.org	1.1118.35.3
# [IPV6]: Per-interfave icmpv6 statistics support.
# --------------------------------------------
# 03/04/25	davem@nuts.ninka.net	1.1118.35.4
# [SCTP]: ICMP6 per-device changes for sctp.
# --------------------------------------------
# 03/04/25	torvalds@home.transmeta.com	1.1118.23.45
# Merge bk://kernel.bkbits.net/jgarzik/net-drivers-2.5
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/25	davem@nuts.ninka.net	1.1118.35.5
# [IPV6]: Export in6_dev_finish_destroy.
# --------------------------------------------
# 03/04/25	shemminger@osdl.org	1.1118.35.6
# [BRIDGE]: Get write lock in config PDU processing.
# --------------------------------------------
# 03/04/25	shemminger@osdl.org	1.1118.35.7
# [BRIDGE]: Possible race with timer on shutdown.
# --------------------------------------------
# 03/04/25	shemminger@osdl.org	1.1118.35.8
# [BRIDGE]: Use list macros for ports.
# --------------------------------------------
# 03/04/25	shemminger@osdl.org	1.1118.35.9
# [BRIDGE]: Use RCU for port table.
# --------------------------------------------
# 03/04/25	davem@nuts.ninka.net	1.1118.35.10
# [BRIDGE]: br_if.c needs linux/init.h
# --------------------------------------------
# 03/04/25	zaitcev@redhat.com	1.1118.36.1
# [SPARC]: Openprom drivers needs linux/fs.h
# --------------------------------------------
# 03/04/26	jejb@raven.il.steeleye.com	1.1118.1.68
# Merge akpm/jejb changes
# --------------------------------------------
# 03/04/26	hch@de.rmk.(none)	1.1118.37.1
# [PCMCIA] consolidate cs_error()
# 
# I don't think having a copy of this in about every pcmcia driver is
# a good idea.
# --------------------------------------------
# 03/04/26	torvalds@home.transmeta.com	1.1118.23.46
# Merge bk://kernel.bkbits.net/davem/net-2.5
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/26	torvalds@home.transmeta.com	1.1118.23.47
# Merge bk://kernel.bkbits.net/davem/sparc-2.5
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/26	patmans@us.ibm.com	1.1118.1.69
# [PATCH] scsi-misc-2.5 remove scsi_scan.c EVPD code
# 
# Patch against current scsi-misc-2.5 tree.
# 
# Remove the scsi EVPD code.
# 
# Set the sysfs name to the form "SCSI scsi-type".
# --------------------------------------------
# 03/04/26	hch@lst.de	1.1118.38.1
# [PATCH] de-uglify scsi.c
# 
# It's the last file of the scsi core that needed to be converted from
# the old scsi style.
# --------------------------------------------
# 03/04/26	jejb@raven.il.steeleye.com	1.1118.1.70
# Merge
# --------------------------------------------
# 03/04/26	torvalds@home.transmeta.com	1.1118.23.48
# Fix up some mixing of ramdisk/initrd. They have nothing in common,
# but the build was confused by the fact that they did share some files.
# 
# Move INITRD code from do_mounts_rd.c to new file do_mounts_initrd.c.
# --------------------------------------------
# 03/04/26	torvalds@home.transmeta.com	1.1118.23.49
# Avoid warning: print out hw_status_page as the pointer it now is.
# --------------------------------------------
# 03/04/26	jejb@raven.il.steeleye.com	1.1118.1.71
# Fix mismerge in megaraid.c
# --------------------------------------------
# 03/04/26	oliver@oenone.homelinux.org	1.1118.39.1
# - add DC395 SCSI driver
# --------------------------------------------
# 03/04/26	jmorris@intercode.com.au	1.1118.23.50
# [IPSEC]: allow only tunnel mode in xfrm4_tunnels.
# --------------------------------------------
# 03/04/26	torvalds@home.transmeta.com	1.1118.40.1
# Automerge
# --------------------------------------------
# 03/04/26	torvalds@home.transmeta.com	1.1118.1.72
# Merge http://linux-scsi.bkbits.net/scsi-for-linus-2.5
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/26	maxk@qualcomm.com	1.1118.1.73
# Merge bk://linux.bkbits.net/linux-2.5
# into qualcomm.com:/home/kernel/bt-2.5
# --------------------------------------------
# 03/04/26	torvalds@home.transmeta.com	1.1118.41.1
# scsi.c needs <linux/interrupt.h>. Somebody was a bit over-eager
# at cleanups.
# --------------------------------------------
# 03/04/26	willy@debian.org	1.1118.41.2
# [PATCH] fix iomem_resource
# 
# Every 64-bit architecture changes the end of iomem_resources. Some more
# gracefully than others. This patch does away with all that by making
# it end at ~0UL by default.
# --------------------------------------------
# 03/04/27	stevef@smfhome1.austin.rr.com	1.1121
# Fix delete of files with readonly attribute. Reflect setting of
# readonly dos attribute in mode when server does not support
# CIFS Unix extensions.  Fix abbreviated readdir to servers that
# do support CIFS Unix extensions.
# --------------------------------------------
# 03/04/27	paulus@samba.org	1.1118.42.1
# Merge bk://ppc@ppc.bkbits.net/for-linus-ppc
# into samba.org:/home/paulus/kernel/for-linus-ppc
# --------------------------------------------
# 03/04/27	paulus@samba.org	1.1118.41.3
# Merge samba.org:/home/paulus/kernel/linux-2.5
# into samba.org:/home/paulus/kernel/for-linus-ppc
# --------------------------------------------
# 03/04/27	torvalds@home.transmeta.com	1.1122
# Merge bk://cifs.bkbits.net/linux-2.5cifs
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/27	paulus@samba.org	1.1118.41.4
# PPC32: Change interrupt handlers to return irqreturn_t.
# --------------------------------------------
# 03/04/27	paulus@samba.org	1.1118.41.5
# PPC32: Reduce __MAX_NDELAY a little to avoid compiler warnings.
# --------------------------------------------
# 03/04/27	benh@kernel.crashing.org	1.1118.41.6
# PPC32: Handle CPUs that have extra BAT (block address translation) registers
# --------------------------------------------
# 03/04/27	acme@conectiva.com.br	1.1123
# o net/socket: make sys_accept bump the net proto family module usage count
#   
# Thanks to Max Krasnyansky for spotting this.
# --------------------------------------------
# 03/04/27	eli.carter@com.rmk.(none)	1.1118.43.1
# [ARM PATCH] 1513/1: iq80310 fix missing header
# 
# Patch from Eli Carter
# 
# # Tue Apr 22 10:26:15 CDT 2003 ejc@rnd-linux-c84
# # e42-fix-missing-iop-header
# #
# # Add in the missing iop310-irq.h header file.
# #
# # Diffed against linux-2.5.59-rmk1-ec0
# # Applies cleanly to 2.5.67-rmk1, 2.5.68-rmk1
# #
# #  include/asm-arm/arch-iop3xx/iop310-irqs.h |   80 ++++++++++++++++++++++++++++++
# #  1 files changed, 80 insertions(+)
# #
# --------------------------------------------
# 03/04/27	eli.carter@com.rmk.(none)	1.1118.43.2
# [ARM PATCH] 1514/1: iq80321 MTD C99 fix
# 
# Patch from Eli Carter
# 
# # Tue Apr 22 14:28:13 CDT 2003 ejc@rnd-linux-c84
# # e45-iq80321-mtd-c99-fix
# #
# # I didn't test my C99 fix for the iq80321 MTD mapping.  "If you didn't test it,
# # it's broken."  This fixes that (embarrasing) blunder.
# #
# # Diffed against linux-2.5.68-rmk1+1513
# #
# #  drivers/mtd/maps/iq80321.c |   22 +++++++++++-----------
# #  1 files changed, 11 insertions(+), 11 deletions(-)
# #
# --------------------------------------------
# 03/04/27	alexander.schulz@com.rmk.(none)	1.1118.43.3
# [ARM PATCH] 1517/1: Shark: new defconfig
# 
# Patch from Alexander Schulz
# 
# This updates the defconfig for the Shark
# --------------------------------------------
# 03/04/27	acme@conectiva.com.br	1.1124
# o ipx: remove MOD_{INC,DEC}_USE_COUNT
# 
# Now the core networking infrastructure will (finally) do that for the net protocol
# families, its just a matter of setting the ->owner field in the registered struct
# net_proto_family to THIS_MODULE.
# --------------------------------------------
# 03/04/27	alexander.schulz@com.rmk.(none)	1.1118.43.4
# [ARM PATCH] 1518/1: Shark: cyberpro broken by machine_is_netwinder
# 
# Patch from Alexander Schulz
# 
# I cannot compile the file cyber2000fb.c because of an undifined 
# reference to machine_is_netwinder(). This patch makes it compile again.
# --------------------------------------------
# 03/04/27	rmk@flint.arm.linux.org.uk	1.1118.43.5
# [ARM] Fix two makefile problems
# 
# Saner selection of architecture build flags (for Xscale)
# Make asm-offsets.s depend on the selected platform
# --------------------------------------------
# 03/04/27	rmk@flint.arm.linux.org.uk	1.1118.43.6
# [ARM] Bypass cache cleaning if cache/mmu was disabled.
# --------------------------------------------
# 03/04/27	rmk@flint.arm.linux.org.uk	1.1118.43.7
# [ARM] Fix another case of looking at task_struct instead of thread_info
# --------------------------------------------
# 03/04/27	acme@conectiva.com.br	1.1125
# o llc: remove MOD_{INC,DEC}_USE_COUNT
# 
# Now the core networking infrastructure will (finally) do that for the net
# protocol families, its just a matter of setting the ->owner field in the
# registered struct net_proto_family to THIS_MODULE.
# --------------------------------------------
# 03/04/27	acme@conectiva.com.br	1.1126
# o af_llc: initialize ->owner in llc_ui_family_ops
# 
# The previous changeset for llc was enough when the BSD sockets interface
# for AF_LLC was not selected, but this changeset is needed when it is
# selected.
# --------------------------------------------
# 03/04/27	rmk@flint.arm.linux.org.uk	1.1118.43.8
# [ARM] Provide more early command line parsing.
# 
# We need to parse the command line arguments not only for the memory
# parameters, but also CPU cache policies.  Rather than extending the
# early parsing in arch/arm/kernel/setup.c, we make this a generic
# feature.  The parameters and their parsing function can now be
# placed along side the code which makes use of the parsed information.
# --------------------------------------------
# 03/04/27	rmk@flint.arm.linux.org.uk	1.1118.43.9
# [ARM] lock up() functions should be memory barriers.
# --------------------------------------------
# 03/04/27	rmk@flint.arm.linux.org.uk	1.1118.43.10
# [ARM] Ensure gcc does not assume asm() is conditional.
# 
# Prevent all gcc's from assuming that assembly within asm() may be
# conditional.
# --------------------------------------------
# 03/04/27	acme@conectiva.com.br	1.1127
# o appletalk: remove MOD_{INC,DEC}_USE_COUNT
# 
# Now the core networking infrastructure will (finally) do that for the net
# protocol families, its just a matter of setting the ->owner field in the
# registered struct net_proto_family to THIS_MODULE.
# --------------------------------------------
# 03/04/27	rmk@flint.arm.linux.org.uk	1.1118.43.11
# [ARM] Fix integrator cpufreq build errors
# --------------------------------------------
# 03/04/27	acme@conectiva.com.br	1.1128
# o af_llc: add missing include module.h
# --------------------------------------------
# 03/04/27	paulus@samba.org	1.1122.1.1
# [PATCH] drivers/macintosh irq handler type
# 
# This patch changes the interrupt handler routines in four of the
# macintosh-specific drivers to return an irqreturn_t value.
# --------------------------------------------
# 03/04/27	rmk@flint.arm.linux.org.uk	1.1118.43.12
# [ARM] Fix includes
# 
# fault-common.c included unnecessary headers.
# mach-integrator.c needed list.h included.
# --------------------------------------------
# 03/04/27	rmk@flint.arm.linux.org.uk	1.1118.43.13
# [ARM] Make tlb_start_vma() flush the cache
# --------------------------------------------
# 03/04/27	rmk@flint.arm.linux.org.uk	1.1118.43.14
# [ARM] Inline PMD entry cache handling
# 
# The common case is building a kernel for one CPU type, and we are
# able to allow GCC to optimise any the PMD entry cache handling
# assembly which will never be used.
# --------------------------------------------
# 03/04/27	anton@samba.org	1.1122.2.1
# [netdrvr 8139cp] enable MWI via pci_set_mwi, rather than manually
# --------------------------------------------
# 03/04/27	hch@lst.de	1.1122.2.2
# [netdrvr pcmcia] switch drivers to using pcmcia_register_driver
# 
# Affected drivers: 3c574_cs, 3c589_cs, axnet_cs, com20020_cs,
# fmvj18x_cs, ibmtr_cs, nmclan_cs, smc91c92_cs, xir2ps_cs
# --------------------------------------------
# 03/04/27	romieu@fr.zoreil.com	1.1122.2.3
# [wan dscc4] irqreturn_t update
# --------------------------------------------
# 03/04/27	rmk@flint.arm.linux.org.uk	1.1118.43.15
# [ARM] Clean up ARM cache handling interfaces (part 1)
# 
# This starts to move the ARM cache handling interface towards a
# purpose-defined rather than functionality-defined interface.
# This is necessary so we are able to support a wide range of ARM
# CPUs.
# --------------------------------------------
# 03/04/28	paulus@samba.org	1.1122.1.2
# Merge samba.org:/home/paulus/kernel/linux-2.5
# into samba.org:/home/paulus/kernel/for-linus-ppc
# --------------------------------------------
# 03/04/27	B.Zolnierkiewicz@elka.pw.edu.pl	1.1122.3.1
# [PATCH] fix DMA for taskfile IO
# 
# Fix handling of read/write DMA in do_rw_taskfile(),
# it was broken because default return value is ide_stopped.
# --------------------------------------------
# 03/04/27	B.Zolnierkiewicz@elka.pw.edu.pl	1.1122.3.2
# [PATCH] fix compilation of taskfile IO
# 
# Fix compilation of CONFIG_IDE_TASKFILE_IO, but don't expose this config
# option yet.
# --------------------------------------------
# 03/04/27	B.Zolnierkiewicz@elka.pw.edu.pl	1.1122.3.3
# [PATCH] remove duplicated defines from ide.h
# 
# [trivia] Remove duplicated defines of PRD_BYTES and PRD_ENTRIES.
# --------------------------------------------
# 03/04/28	rmk@flint.arm.linux.org.uk	1.1118.43.16
# [ARM] Part 2 in the cache API changes.
# 
# This is the new API; we now have methods for handling DMA which are
# separate from those handling the TLB consistency issues, which are
# in turn separate from the methods handling the cache coherency
# issues.
# 
# Implementations are, however, free to alias these methods internally.
# --------------------------------------------
# 03/04/28	rmk@flint.arm.linux.org.uk	1.1118.43.17
# [ARM] Remove check_bugs()
# 
# check_bugs() has never been used to detect buggy ARM CPUs.  Therefore
# is no point in passing it to the per-cpu support code.
# --------------------------------------------
# 03/04/27	maxk@qualcomm.com	1.1118.1.74
# [Bluetooth] Improved RFCOMM TTY TX buffer management. 
# Don't buffer more data than we have credits for.
# 
# Patch from David Woodhouse <dwmw2@infradead.org>
# --------------------------------------------
# 03/04/28	rmk@flint.arm.linux.org.uk	1.1118.43.18
# [ARM] set_pgd is confusing; rename it switch_mm
# 
# set_pgd implies that we're setting a pgd entry.  We aren't; we're
# switching the MMU page table pointer.  Call it switch_mm instead.
# --------------------------------------------
# 03/04/27	maxk@qualcomm.com	1.1118.1.75
# [Bluetooth] Fix race condition in RFCOMM session and dcl scheduler. 
# This fixes random RFCOMM freezes reported by some people.
# --------------------------------------------
# 03/04/27	torvalds@home.transmeta.com	1.1122.3.4
# Merge bk://bk.arm.linux.org.uk/linux-2.5-rmk
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/27	viro@parcelfarce.linux.theplanet.co.uk	1.1122.3.5
# [PATCH] simple_fill_super()
# 
# 	New libfs.c helper - simple_fill_super().  Abstracted from
# nfsd/nfsctl.c, couple of filesystems converted to it (nfsctl, binfmt_misc).
# 
# 	Function takes an array of triples (name, file_operations, mode),
# superblock and value for its ->s_magic.  It acts as fill_super() - populates
# superblock or fails.  We get a ramfs-style flat tree - root directory and
# a bunch of files in it.
# 
# 	That animal allows to put together a simple filesystem without
# touching any directory-related stuff - now it's as easy as implementing
# file_operations for files you want to have and telling what to call them.
# --------------------------------------------
# 03/04/27	viro@parcelfarce.linux.theplanet.co.uk	1.1122.3.6
# [PATCH] pin_fs/release_fs
# 
# 	A couple of helpers - simple_pin_fs() and simple_release_fs().
# My fault - that code should've been put into libfs.c from the very
# beginning.  As it is, it got copied all over the place (binfmt_misc,
# capifs, usbfs, usbdevfs, rpc_pipefs).
# 	Taken to libfs.c and cleaned up.
# --------------------------------------------
# 03/04/27	viro@parcelfarce.linux.theplanet.co.uk	1.1122.3.7
# [PATCH] open_by_devnum()
# 
# 	New helper - open_by_devnum().  Opens block_device by device number;
# for use in situations when we really have nothing better than dev_t (i.e.
# had received it from stupid userland API).
# --------------------------------------------
# 03/04/27	viro@parcelfarce.linux.theplanet.co.uk	1.1122.3.8
# [PATCH] blkmtd init cleanup
# 
# 	Obvious cleanup of the code in init_blkmtd().  Killed code duplication,
# replaced opening underlying block device manually with use of appropriate
# helpers.
# --------------------------------------------
# 03/04/27	viro@parcelfarce.linux.theplanet.co.uk	1.1122.3.9
# [PATCH] bdget_disk()
# 
# 	New helper - bdget_disk(gendisk, partition)
# 	invalidate_device() replaced with invalidate_partition(disk, part)
# --------------------------------------------
# 03/04/27	viro@parcelfarce.linux.theplanet.co.uk	1.1122.3.10
# [PATCH] ataflop.c cleanup
# 
# 	Somewhat cleaned up, sanitized the module init/exit code (BTW,
# built-in case was b0rken for quite a while - somebody forgot to add
# initcall there; converted the bugger to module_init/module_exit)
# --------------------------------------------
# 03/04/27	viro@parcelfarce.linux.theplanet.co.uk	1.1122.3.11
# [PATCH] hd98 compile fixes
# 
# 	hd98 had missed a lot of required block device patches (e.g.
# it used BLK_DEFAULT_QUEUE and that had been gone for ~ half a year).
# Reproduced the changes done to hd.c.
# --------------------------------------------
# 03/04/27	davem@nuts.ninka.net	1.1122.4.1
# Merge nuts.ninka.net:/home/davem/src/BK/network-2.5
# into nuts.ninka.net:/home/davem/src/BK/net-2.5
# --------------------------------------------
# 03/04/27	davem@nuts.ninka.net	1.1127.1.1
# Merge bk://kernel.bkbits.net/acme/net-2.5
# into nuts.ninka.net:/home/davem/src/BK/net-2.5
# --------------------------------------------
# 03/04/27	bdschuym@pandora.be	1.1127.1.2
# [NETFILTER]: Add ipt_physdev extension.
# --------------------------------------------
# 03/04/27	mulix@mulix.org	1.1127.1.3
# [NETFILTER]: ip_queue memory leaks
# --------------------------------------------
# 03/04/27	kaber@trash.net	1.1127.1.4
# [NETFILTER]: Multiple ipt_REJECT fixes.
# - fix tcp-rst routing
# - fix memory leak
# - remove unecessary "struct in_device" declaration
# - remove RTO_CONN
# --------------------------------------------
# 03/04/27	davem@nuts.ninka.net	1.1129
# Merge bk://kernel.bkbits.net/acme/net-2.5
# into nuts.ninka.net:/home/davem/src/BK/net-2.5
# --------------------------------------------
# 03/04/27	laforge@netfilter.org	1.1130
# [NETFILTER]: Makefile and build fixes.
# --------------------------------------------
# 03/04/27	acme@conectiva.com.br	1.1128.1.1
# o af_unix: remove MOD_{INC,DEC}_USE_COUNT
# 
# Now the core networking infrastructure will (finally) do that for the net
# protocol families, its just a matter of setting the ->owner field in the
# registered struct net_proto_family to THIS_MODULE.
# --------------------------------------------
# 03/04/27	acme@conectiva.com.br	1.1128.1.2
# o wireless: make the ioctl tables more resilient to errors using C99 style init
# --------------------------------------------
# 03/04/27	davem@nuts.ninka.net	1.1131
# Merge bk://kernel.bkbits.net/acme/net-2.5
# into nuts.ninka.net:/home/davem/src/BK/net-2.5
# --------------------------------------------
# 03/04/27	akpm@digeo.com	1.1122.2.4
# net driver cleanup, volume 7
# 
# 100% irqreturn_t cleanups
# 
# Affected drivers: 3c523, 527, 68360enet, 7990, a2065, am79c961a,
# appletalk/{ltpc,cops}, ariadne, {lotsa}lance, au1000_eth, eth16i,
# ewrk3, gt96100eth, hamradio/several, ibmlana, ioc3-eth, *-skeleton,
# lasi_82596, mac89x0, pcmcia/3c574_cs, rrunner, sb1000, sb1250-mac,
# sgiseeq, sk_g16, sk_mca, skfddi, sonic, sun3_82586, tc35815,
# tokenring/several, wan/several
# --------------------------------------------
# 03/04/27	jgarzik@redhat.com	1.1122.3.12
# Merge redhat.com:/garz/repo/linus-2.5
# into redhat.com:/garz/repo/net-drivers-2.5
# --------------------------------------------
# 03/04/27	scott.feldman@intel.com	1.1122.3.13
# [netdrvr e1000] mark e1000 NAPI feature not-experimental
# --------------------------------------------
# 03/04/27	scott.feldman@intel.com	1.1122.3.14
# [netdrvr e1000] add a bit of source cross-version compat
# 
# * Wrap TSO support with NETIF_F_TSO to keep same driver
#   source between 2.4 and 2.5.
# 
# --------------------------------------------
# 03/04/28	ganesh.venkatesan@intel.com	1.1122.3.15
# [netdrvr ixgb] add new driver for Intel's 10 gig ethernet
# --------------------------------------------
# 03/04/28	jgarzik@redhat.com	1.1122.3.16
# [netdrvr ixgb] Lindent, then fix up obvious indent uglies by hand
# --------------------------------------------
# 03/04/28	jgarzik@redhat.com	1.1122.3.17
# [netdrvr ixgb] use standard kernel u8/u16/u32 types
# --------------------------------------------
# 03/04/27	maxk@qualcomm.com	1.1118.1.76
# [Bluetooth] USB drivers cannot call usb_unlink_urb() under spin lock.
# --------------------------------------------
# 03/04/28	jgarzik@redhat.com	1.1122.3.18
# [netdrvr ixgb] more cleanups
# 
# - support new 2.5 irqreturn_t
# - s/usec_delay/udelay/
# - remove two stored-but-never-used members of struct ixgb_hw
# - read PCI vendor/device ids from struct pci_dev, not h/w
# - remove some unused wrappers from ixgb_osdep.h
# --------------------------------------------
# 03/04/27	maxk@qualcomm.com	1.1118.1.77
# [Bluetooth] Initialize net_proto_family->owner field. This covers only HCI sockets. 
# Other protocols cannot be fixes at this point because current net_proto_family
# code does not support "family owner != socket owner" case.
# --------------------------------------------
# 03/04/27	maxk@qualcomm.com	1.1118.1.78
# [Bluetooth] Initialize ->owner field of the RFCOMM tty driver. 
# In order to fix all MOD_INC/DECs in the RFCOMM code we need __module_get().
# --------------------------------------------
# 03/04/27	davem@nuts.ninka.net	1.1132
# Merge bk://kernel.bkbits.net/acme/net-2.5
# into nuts.ninka.net:/home/davem/src/BK/net-2.5
# --------------------------------------------
# 03/04/28	davem@nuts.ninka.net	1.1133
# [EBTABLES]: Make ebt_vlan.c use correct printf format for size_t.
# --------------------------------------------
# 03/04/28	davem@nuts.ninka.net	1.1134
# [DECNET]: Kill warning with gcc-3.x in dn_route.c
# --------------------------------------------
# 03/04/28	davem@nuts.ninka.net	1.1135
# [NETFILTER]: Make ip_conntrack_core.c use correct printf format for size_t.
# --------------------------------------------
# 03/04/28	rmk@flint.arm.linux.org.uk	1.889.310.24
# [ARM] Clean up nwfpe makefile.
# --------------------------------------------
# 03/04/28	davem@nuts.ninka.net	1.1122.5.1
# [SPARC64]: Update defconfig.
# --------------------------------------------
# 03/04/28	rusty@rustcorp.com.au	1.1136
# [NETFILTER]: Add owner field to nf_hook_ops.
# Adds an owner field to nf_hook_ops, and use it to hold the hook in place
# for queued packets.
# --------------------------------------------
# 03/04/28	davem@nuts.ninka.net	1.1137
# [NETFILTER]: Kill unused var in nf_reinject.
# --------------------------------------------
# 03/04/28	davem@nuts.ninka.net	1.1138
# [NETFILTER]: Use proper size_t printf format in ip6t_LOG.c
# --------------------------------------------
# 03/04/28	davem@kernel.bkbits.net	1.1139
# Merge davem@nuts.ninka.net:/home/davem/src/BK/net-2.5
# into kernel.bkbits.net:/home/davem/net-2.5
# --------------------------------------------
# 03/04/28	acme@conectiva.com.br	1.1128.1.3
# o af_ax25: remove MOD_{INC,DEC}_USE_COUNT
# 
# Now the core networking infrastructure will (finally) do that for the net
# protocol families, its just a matter of setting the ->owner field in the
# registered struct net_proto_family to THIS_MODULE.
# --------------------------------------------
# 03/04/28	acme@conectiva.com.br	1.1128.1.4
# o af_econet: remove MOD_{INC,DEC}_USE_COUNT
# 
# Now the core networking infrastructure will (finally) do that for the net
# protocol families, its just a matter of setting the ->owner field in the
# registered struct net_proto_family to THIS_MODULE.
# --------------------------------------------
# 03/04/28	acme@conectiva.com.br	1.1128.1.5
# o af_irda: remove MOD_{INC,DEC}_USE_COUNT
# 
# Now the core networking infrastructure will (finally) do that for the net
# protocol families, its just a matter of setting the ->owner field in the
# registered struct net_proto_family to THIS_MODULE.
# --------------------------------------------
# 03/04/28	acme@conectiva.com.br	1.1128.1.6
# o af_key: remove MOD_{INC,DEC}_USE_COUNT
# 
# Now the core networking infrastructure will (finally) do that for the net
# protocol families, its just a matter of setting the ->owner field in the
# registered struct net_proto_family to THIS_MODULE.
# --------------------------------------------
# 03/04/28	acme@conectiva.com.br	1.1128.1.7
# o af_netrom: remove MOD_{INC,DEC}_USE_COUNT
# 
# Now the core networking infrastructure will (finally) do that for the net
# protocol families, its just a matter of setting the ->owner field in the
# registered struct net_proto_family to THIS_MODULE.
# --------------------------------------------
# 03/04/28	acme@conectiva.com.br	1.1128.1.8
# o af_packet: remove MOD_{INC,DEC}_USE_COUNT
# 
# Now the core networking infrastructure will (finally) do that for the net
# protocol families, its just a matter of setting the ->owner field in the
# registered struct net_proto_family to THIS_MODULE.
# --------------------------------------------
# 03/04/28	acme@conectiva.com.br	1.1128.1.9
# o af_rose: remove MOD_{INC,DEC}_USE_COUNT
# 
# Now the core networking infrastructure will (finally) do that for the net
# protocol families, its just a matter of setting the ->owner field in the
# registered struct net_proto_family to THIS_MODULE.
# --------------------------------------------
# 03/04/28	acme@conectiva.com.br	1.1128.1.10
# o af_wanpipe: remove MOD_{INC,DEC}_USE_COUNT
# 
# Now the core networking infrastructure will (finally) do that for the net
# protocol families, its just a matter of setting the ->owner field in the
# registered struct net_proto_family to THIS_MODULE.
# --------------------------------------------
# 03/04/28	acme@conectiva.com.br	1.1128.1.11
# o af_x25: remove MOD_{INC,DEC}_USE_COUNT
# 
# Now the core networking infrastructure will (finally) do that for the net
# protocol families, its just a matter of setting the ->owner field in the
# registered struct net_proto_family to THIS_MODULE.
# --------------------------------------------
# 03/04/28	acme@conectiva.com.br	1.1128.1.12
# o netrom/nr_dev: use SET_MODULE_OWNER, removing calls to MOD_{INC,DEC}_USE_COUNT
# --------------------------------------------
# 03/04/28	acme@conectiva.com.br	1.1128.1.13
# o rose/rose_dev: use SET_MODULE_OWNER, removing calls to MOD_{INC,DEC}_USE_COUNT
# --------------------------------------------
# 03/04/28	davem@nuts.ninka.net	1.1138.1.1
# Merge bk://kernel.bkbits.net/acme/net-2.5
# into nuts.ninka.net:/home/davem/src/BK/net-2.5
# --------------------------------------------
# 03/04/28	aia21@cantab.net	1.1122.6.1
# Merge cantab.net:/home/aia21/bklinux-2.5
# into cantab.net:/home/aia21/ntfs-2.5
# --------------------------------------------
# 03/04/28	acme@conectiva.com.br	1.1128.1.14
# o net: several C99 struct init style conversions and cleanups
# --------------------------------------------
# 03/04/28	acme@conectiva.com.br	1.1128.1.15
# o net: save some more bytes in the kernel image moving global zero inits to .bss
# --------------------------------------------
# 03/04/28	acme@conectiva.com.br	1.1128.1.16
# o af_decnet: remove MOD_{INC,DEC}_USE_COUNT
#   
# Now the core networking infrastructure will (finally) do that for the net
# protocol families, its just a matter of setting the ->owner field in the
# registered struct net_proto_family to THIS_MODULE.
# --------------------------------------------
# 03/04/28	rmk@flint.arm.linux.org.uk	1.1140
# Merge flint.arm.linux.org.uk:/usr/src/linux-bk-2.5/linux-2.5-nwfpe
# into flint.arm.linux.org.uk:/usr/src/linux-bk-2.5/linux-2.5-rmk
# --------------------------------------------
# 03/04/28	rmk@flint.arm.linux.org.uk	1.1141
# [ARM] Don't allow FPE modules to be built as a module.
# --------------------------------------------
# 03/04/28	rmk@flint.arm.linux.org.uk	1.1142
# [ARM] Remove unused msleep() function in h3600.c
# --------------------------------------------
# 03/04/28	rmk@flint.arm.linux.org.uk	1.1143
# [ARM] Switch to SVC mode using read/modify/write.
# --------------------------------------------
# 03/04/29	paulus@samba.org	1.1139.1.1
# Merge samba.org:/home/paulus/kernel/linux-2.5
# into samba.org:/home/paulus/kernel/for-linus-ppc
# --------------------------------------------
# 03/04/28	rmk@flint.arm.linux.org.uk	1.1144
# [ARM] Fix a collection of missed changes from cache API changes.
# --------------------------------------------
# 03/04/28	rmk@flint.arm.linux.org.uk	1.1145
# [ARM] Fix elf_fpregset_t
# 
# This is a fix from eons ago, which apparantly has been in the old
# Rebel.com netwinder CVS for several years, and has never been
# submitted upstream.
# 
# This fix allows FP registers to be correctly written to ELF core
# files, as well as preventing corruption of other parts of ELF core
# files caused by data on the kernel stack being overwritten.
# --------------------------------------------
# 03/04/28	jgarzik@redhat.com	1.1139.2.1
# Merge redhat.com:/garz/repo/linus-2.5
# into redhat.com:/garz/repo/net-drivers-2.5
# --------------------------------------------
# 03/04/28	rmk@flint.arm.linux.org.uk	1.1146
# [ARM] Update mach-types to latest version.
# --------------------------------------------
# 03/04/28	davem@nuts.ninka.net	1.1139.3.1
# Merge nuts.ninka.net:/home/davem/src/BK/network-2.5
# into nuts.ninka.net:/home/davem/src/BK/net-2.5
# --------------------------------------------
# 03/04/28	torvalds@home.transmeta.com	1.1147
# Merge bk://bk.arm.linux.org.uk/linux-2.5-rmk
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/28	davem@nuts.ninka.net	1.1139.3.2
# Merge bk://kernel.bkbits.net/acme/net-2.5
# into nuts.ninka.net:/home/davem/src/BK/net-2.5
# --------------------------------------------
# 03/04/28	torvalds@home.transmeta.com	1.1148
# Merge bk://linux-bt.bkbits.net/bt-2.5
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/28	torvalds@home.transmeta.com	1.1149
# DRI CVS merge: move more gamma-only functions away from
# generic dri files and into gamma driver files.
# --------------------------------------------
# 03/04/28	acme@conectiva.com.br	1.1128.1.17
# o ipx: several simple cleanups
# 
# . use switch/case alignment at the same column, 
#   more common in the kernel sources
# . remove outdated module refcounting comments
# . have just one exit (return) in the ioctl functions
# . use 'rc' for return variables, not ret or err, for
#   consistency on naming.
# --------------------------------------------
# 03/04/28	torvalds@home.transmeta.com	1.1150
# Previous DRI CVS merge improperly removed some sparc-only
# support. Add it back in now that DRI is synched up again.
# --------------------------------------------
# 03/04/28	torvalds@home.transmeta.com	1.1151
# Remove old (disabled) debugging code.
# --------------------------------------------
# 03/04/28	torvalds@home.transmeta.com	1.1152
# DRI CVS merge: make sure to clean up irq and DMA on final close.
# --------------------------------------------
# 03/04/28	torvalds@home.transmeta.com	1.1153
# DRI CVS merge: only free pages when we _have_ pages to free.
# Cleanups.
# --------------------------------------------
# 03/04/28	torvalds@home.transmeta.com	1.1154
# DRI CVS merge: make sure the device is properly initialized
# before opening it.
# --------------------------------------------
# 03/04/28	torvalds@home.transmeta.com	1.1155
# DRI CVS merge: memory barrier updates
# --------------------------------------------
# 03/04/28	davem@nuts.ninka.net	1.1139.3.3
# Merge bk://kernel.bkbits.net/acme/net-2.5
# into nuts.ninka.net:/home/davem/src/BK/net-2.5
# --------------------------------------------
# 03/04/29	acme@conectiva.com.br	1.1128.1.18
# o pppox: simple code cleanups
# 
# . rename proto to pppox_protos, even being static this is too generic a name
# . use rc as the name for result variables, just for consistency with other
#   net sources
# 
# This is in preparation for having a proper net family module level modules
# infrastructure, with the top level (af_pppox) doing the module refcounting
# before calling any functions registered by the lower level protocol modules
# (in this case just PPPOE for now).
# --------------------------------------------
# 03/04/28	davem@nuts.ninka.net	1.1139.3.4
# Merge bk://kernel.bkbits.net/acme/net-2.5
# into nuts.ninka.net:/home/davem/src/BK/net-2.5
# --------------------------------------------
# 03/04/28	greg@kroah.com	1.1156
# kobject: kobj_lock needs to be grabed using spinlock_irq
# 
# This is because some subsystems (cough, usb...) can grab a kobject from irq context.
# This lock can be completely removed once the sysfs_init() code is cleaned up.
# 
# Patch originally by Andrew Morton.
# --------------------------------------------
# 03/04/29	acme@conectiva.com.br	1.1128.1.19
# o af_pppox: create module infrastructure for protocol modules
# 
# With this the pppox module is protected by the networking core and
# the pppox "core" protects modules for specific pppox protocols (pppoe,
# for instance), while doing it removed some not needed struct sock
# member initializations in pppoe_create that are done by sock_init_data.
# --------------------------------------------
# 03/04/28	greg@kroah.com	1.1157
# driver core: rework driver class structures and logic
# 
# Removes the device_class, devclass_attribute, and device_interface structures
# and replaces them with class, class_device, and class_interface structures.
# 
# This allows us to have multiple class_device structures per device structures
# which mirrors the ways things really are within the kernel.  It also allows 
# class_device structures to be created later than struct devices as they
# are naturally created much later in the initialization process of a device.
# --------------------------------------------
# 03/04/28	greg@kroah.com	1.1158
# driver core: fix up cpu.c, memblk.c, and node.c due to the class changes
# --------------------------------------------
# 03/04/28	greg@kroah.com	1.1159
# driver core: fix up the input_class logic due to the class changes.
# --------------------------------------------
# 03/04/28	greg@kroah.com	1.1160
# driver core: fix up cpufreq code to work with new class changes.
# --------------------------------------------
# 03/04/28	greg@kroah.com	1.1161
# driver core: fix up tty code to work with the new class changes.
# 
# Note, tty_class will be flushed out in the future, this is just to
# get things building again properly.
# --------------------------------------------
# 03/04/29	davem@nuts.ninka.net	1.1139.3.5
# Merge bk://kernel.bkbits.net/acme/net-2.5
# into nuts.ninka.net:/home/davem/src/BK/net-2.5
# --------------------------------------------
# 03/04/29	greg@kroah.com	1.1162
# driver core: fix up scsi code to compile due to the class changes.
# 
# Yes, this patch is not logically correct, in that the scsi-host class
# no longer works, but Mike Anderson has a patch that will be submitted
# that fixes all of these problems.
# --------------------------------------------
# 03/04/29	greg@kroah.com	1.1163
# driver core: fix up the pcmcia code to work with the new class changes.
# 
# This isn't the optimal fix, but things still work properly for me with
# my hardware and this patch.
# 
# Dominik Brodowski has stated he will be fixing up this code a lot more
# after the class changes are in the main tree.
# --------------------------------------------
# 03/04/29	greg@kroah.com	1.1164
# driver core: removed drivers/base/fs/*, drivers/base/intf.c and drivers/base/hotplug.c
# 
# These files are no longer needed due to class changes.
# --------------------------------------------
# 03/04/29	acme@conectiva.com.br	1.1128.1.20
# o af_pppox: return -EPROTONOSUPPORT if try_module_get fails at pppox_create
# 
# Thanks to Rusty for spotting this one, if the protocol module is not there
# anymore (or is going away at that time) it is not supported, not busy.
# --------------------------------------------
# 03/04/29	acme@conectiva.com.br	1.1128.1.21
# o net/socket: return -EAFNOSUPPORT if net_family_get fails at sock_create and sys_accept
# 
# Thanks to Rusty for spotting this one, if the net family module is not there
# anymore (or is going away at that time) it is not supported, not busy.
# --------------------------------------------
# 03/04/29	davem@nuts.ninka.net	1.1139.3.6
# Merge bk://kernel.bkbits.net/acme/net-2.5
# into nuts.ninka.net:/home/davem/src/BK/net-2.5
# --------------------------------------------
# 03/04/29	scole@zianet.com	1.1139.3.7
# [NET]: Spelling fixes for net/
# --------------------------------------------
# 03/04/29	shemminger@osdl.org	1.1139.3.8
# [BRIDGE]: Use C99 initializers for netfilter bridge.
# --------------------------------------------
# 03/04/29	bdschuym@pandora.be	1.1139.3.9
# [BRIDGE]: Always set BRNF_BRIDGED mask when bridging.
# --------------------------------------------
# 03/04/29	shemminger@osdl.org	1.1139.3.10
# [NETFILTER]: Use Read Copy Update.
# --------------------------------------------
# 03/04/29	shemminger@osdl.org	1.1139.3.11
# [BRIDGE]: Inline and _rcu change.
# * Need _rcu on the list_for_each_entry in br_get_port because called in
#   read path for some ioctls
# * Move two small functions is_root_bridge and is_designated_port into
#   inlines because they are so short.
# --------------------------------------------
# 03/04/29	shemminger@osdl.org	1.1139.3.12
# [BRIDGE}: More user hz conversions.
# --------------------------------------------
# 03/04/29	davem@nuts.ninka.net	1.1139.3.13
# [IPV6]: Kill unused vars in mcast procfs code.
# --------------------------------------------
# 03/04/29	davem@kernel.bkbits.net	1.1155.1.1
# Merge davem@nuts.ninka.net:/home/davem/src/BK/net-2.5
# into kernel.bkbits.net:/home/davem/net-2.5
# --------------------------------------------
# 03/04/29	mzyngier@freesurf.fr	1.1155.2.1
# [PATCH] EISA/sysfs update
# 
# The included patch cleans up the EISA code :
# 
# - Documentation update,
# - Remove i386 EISA ID reservation (handled in the generic code),
# - Add some preliminary support for EISA-like VLB cards (Adaptec 287x),
# - Add some stricter dependancies for EISA_VIRTUAL_ROOT
# - Preliminary support for EISA DMA,
# - Much more conservative probing,
# - EISA IDs list update (Compaq stuff).
# --------------------------------------------
# 03/04/29	torvalds@home.transmeta.com	1.1155.1.2
# Merge bk://kernel.bkbits.net/davem/net-2.5
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/29	aia21@cantab.net	1.1155.2.2
# Merge cantab.net:/home/aia21/bklinux-2.5
# into cantab.net:/home/aia21/ntfs-2.5
# --------------------------------------------
# 03/04/29	alex_williamson@com.rmk.(none)	1.1155.3.1
# [PATCH] 8250_pci include offset in iomap_base
# 
#    This one-liner is required for PCI serial ports that have multiple
# MMIO ports off a single PCI BAR.  Calls to request_mem_resource() fail
# after the first one otherwise.  Patch against 2.5.67.  Thanks,
# --------------------------------------------
# 03/04/29	hch@lst.de	1.1155.1.3
# [PATCH] fix devfs_register_tape stub
# 
# this fixes a harmless but annoying warning when compiling one of the
# tape drivers without devfs.
# --------------------------------------------
# 03/04/29	hch@lst.de	1.1155.1.4
# [PATCH] update dcache documentation
# 
# Update the dcache section in Documentation/filesystems/Locking to match
# reality.  Note that there's other parts of this file that are badly out
# of date - I'll look into it later.
# --------------------------------------------
# 03/04/29	greg@kroah.com	1.1165
# Merge kroah.com:/home/greg/linux/BK/bleed-2.5
# into kroah.com:/home/greg/linux/BK/class-2.5
# --------------------------------------------
# 03/04/29	greg@kroah.com	1.1166
# [PATCH] USB: fix CHECKER found bug in the empeg.c driver
# --------------------------------------------
# 03/04/29	greg@kroah.com	1.1167
# [PATCH] USB: fix CHECKER found bug in the io_edgeport.c driver
# --------------------------------------------
# 03/04/29	greg@kroah.com	1.1168
# [PATCH] USB: fix CHECKER found bug in the ipaq.c driver
# --------------------------------------------
# 03/04/29	greg@kroah.com	1.1169
# [PATCH] USB: fix CHECKER found bug in the keyspan.c driver
# --------------------------------------------
# 03/04/29	greg@kroah.com	1.1170
# USB: create usb_init_urb() for those people who like to live dangerously (like the bluetooth stack.)
# --------------------------------------------
# 03/04/29	stern@rowland.harvard.edu	1.1171
# [PATCH] USB: Minor patch for uhci-hcd.c
# --------------------------------------------
# 03/04/29	david-b@pacbell.net	1.1172
# [PATCH] USB: usbnet, config changes for CDC Ether
# 
# This patch changes how usbnet and CDC Ether get configured,
# switching to the newer implementation with that CDC model
# (using a "minidriver" for "usbnet").
# 
#   - Removes "cdc-ether" from Kconfig and Makefile.
#     Once everything flies, "cdc-ether.c" can be
#     removed from the kernel.
# 
#   - Makes all the "minidriver" options in "usbnet"
#     explicit in Kconfig, defaulting to "y" for most
#     cases.  So folk expecting a CDC Ether option in
#     Kconfig will still have one, and during config
#     a list of hardware (cables, PDAs, etc) using the
#     "usbnet" driver is now available.  (It's possible
#     to save a few pages of code by configuring out
#     drivers that use custom framing.)
# 
#   - Since now it's possible to create broken configs,
#     this checks for them.  The two basic errors being
#     configuring "usbnet" with no minidrivers, and
#     needing to blacklist Zaurus in CDC-only configs.
# 
#   - Zaurus shouldn't do full CDC style init, since it
#     doesn't uniquify the Ethernet address it reports;
#     and it still shouldn't come up as an "eth%d" link.
# 
# The CDC support is still "experimental", since I want
# to see a few interop reports for commercial products
# before changing that.
# --------------------------------------------
# 03/04/29	joe@perches.com	1.1173
# [PATCH] USB: fix up usbnet's macros for older compilers
# --------------------------------------------
# 03/04/29	joe@perches.com	1.1174
# [PATCH] USB: fix up usb_serial.h's dbg macro to take up less space
# --------------------------------------------
# 03/04/29	joe@perches.com	1.1175
# [PATCH] USB: fix up usb.h's dbg macro to take up less space
# --------------------------------------------
# 03/04/29	torvalds@home.transmeta.com	1.1165.1.1
# Merge bk://bk.arm.linux.org.uk/linux-2.5-pcmcia
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/29	torvalds@home.transmeta.com	1.1165.1.2
# Merge bk://bk.arm.linux.org.uk/linux-2.5-serial
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/29	linux-usb@gemeinhardt.info	1.1176
# [PATCH] USB: add support for Mello MP3 Player
# --------------------------------------------
# 03/04/29	greg@kroah.com	1.1177
# [PATCH] USB: added support for Sony DSC-P8
# 
# Thanks to David Kimdon <David_Kimdon@alumni.hmc.edu> for the information.
# --------------------------------------------
# 03/04/29	greg@kroah.com	1.1178
# [PATCH] USB: add comment to storage/unusual_devs.h that specifies how to add new entries.
# --------------------------------------------
# 03/04/30	paulus@samba.org	1.1165.1.3
# Merge samba.org:/home/paulus/kernel/linux-2.5
# into samba.org:/home/paulus/kernel/for-linus-ppc
# --------------------------------------------
# 03/04/30	acme@conectiva.com.br	1.1165.2.1
# o net/llc: simple cleanups
# 
# . align switch with its cases
# . fit some lines in 80 columns
# --------------------------------------------
# 03/04/30	acme@conectiva.com.br	1.1165.2.2
# o net/sched: some trivial code cleanups, making some code smaller
# 
# Smaller by not calling write_unlock two times.
# --------------------------------------------
# 03/04/29	robert.olsson@data.slu.se	1.1165.2.3
# [NET]: Remove skb_head_pool.
# --------------------------------------------
# 03/04/30	shemminger@osdl.org	1.1165.3.1
# Replace br_lock() in snap with Read Copy Update.
# 
# Straightforward since SNAP uses list macros already.
# 
# Tested by bringing up/down Appletalk on SMP system and making sure packets
# get through.
# 
# This is the last subsystem that depends on br_lock before IPV4,IPV6
# can be converted.
# --------------------------------------------
# 03/04/30	davem@nuts.ninka.net	1.1165.2.4
# Merge bk://kernel.bkbits.net/acme/net-2.5
# into nuts.ninka.net:/home/davem/src/BK/net-2.5
# --------------------------------------------
# 03/04/30	shemminger@osdl.org	1.1165.2.5
# [BRIDGE}: Change bridge forwarding table to use hlist.
# --------------------------------------------
# 03/04/30	bdschuym@pandora.be	1.1165.2.6
# [NETFILTER]: Possible use of freed skbuff in netfilter.c
# --------------------------------------------
# 03/04/30	davem@nuts.ninka.net	1.1165.4.1
# Merge nuts.ninka.net:/home/davem/src/BK/sparcwork-2.5
# into nuts.ninka.net:/home/davem/src/BK/sparc-2.5
# --------------------------------------------
# 03/04/30	zaitcev@redhat.com	1.1165.4.2
# [SPARC]: The iommu rewrite.
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.2.7
# [NETFILTER]: Put back missing list_head iterator local var.
# --------------------------------------------
# 03/04/30	davem@nuts.ninka.net	1.1165.2.8
# [IPV4]: Use dst_pmtu not dev->mtu to determine if fragmentation is needed.
# --------------------------------------------
# 03/04/30	davem@nuts.ninka.net	1.1165.2.9
# [IPV4]: Fix typos in ipip.c commented out code.
# --------------------------------------------
# 03/04/30	davem@nuts.ninka.net	1.1165.2.10
# [PKT SCHED]; Missing semicolon in acme cleanups.
# --------------------------------------------
# 03/04/30	aia21@cantab.net	1.1165.5.1
# Merge cantab.net:/home/aia21/bklinux-2.5
# into cantab.net:/home/aia21/ntfs-2.5
# --------------------------------------------
# 03/04/30	benh@kernel.crashing.org	1.1165.1.4
# PPC32: flush the cache more thoroughly on sleep.
# --------------------------------------------
# 03/04/30	paulus@samba.org	1.1165.1.5
# PPC32: Move xmon declarations to their own header file.
# --------------------------------------------
# 03/04/30	benh@kernel.crashing.org	1.1165.1.6
# PPC32: Updates for newer PowerMac/PowerBook machines.
# --------------------------------------------
# 03/04/30	benh@kernel.crashing.org	1.1165.1.7
# PPC32: Fix for older SMP powermacs.
# --------------------------------------------
# 03/04/30	aia21@cantab.net	1.1165.5.2
# NTFS: 2.1.4 release - Reduce compiler requirements.
# - Remove all uses of unnamed structs and unions in the driver to make
#   old and newer gcc versions happy. Makes it a bit uglier IMO but at
#   least people will stop hassling me
# --------------------------------------------
# 03/04/30	rusty@rustcorp.com.au	1.1165.6.1
# [PATCH] complete modinfo section
# 
# Restores .modinfo section, and uses it to store license and vermagic.
# --------------------------------------------
# 03/04/30	rusty@rustcorp.com.au	1.1165.6.2
# [PATCH] __module_get
# 
# Introduces __module_get for places where we know we already hold
# a reference and ignoring the fact that the module is being "rmmod --wait"ed
# is simpler.
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.3
# [PATCH] irqs: i2c
# 
# IRQ API udpate in i2c-elektor.c
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.4
# [PATCH] irqs: IRDA
# 
# Some IRQ udpates for IRDA which seemed to get lost.
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.5
# [PATCH] Fix slab-vs-gfp bitflag clash
# 
# Fixes a bug spotted by Alexey Mahotkin <alexm@hsys.msk.ru>: the slab-internal
# SLAB_NO_GROW bit clashes with __GFP_NORETRY.
# 
# Fix that up so it won't happen again by moving the bit layout into gfp.h.
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.6
# [PATCH] irqs: bttv
# 
# Update bttv driver to the new IRQ API.
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.7
# [PATCH] APM locking fix
# 
# From: Manfred Spraul <manfred@colorfullife.com>
# 
# apm.c:suspend() calls set_system_power_state() under (effectively)
# spin_lock_irq(i8253_lock).
# 
# But set_system_power_state() unconditionally enables interrupts, in
# apm_bios_call_simple().  This generates nasty warnings from the uniprocessor
# spinlock debugging code, and would be deadlocky if APM worked on SMP.
# 
# So drop the locks around the set_system_power_state() call.
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.8
# [PATCH] Fix warnings in xd.c
# 
# Fix a few unused var warnings in drivers/block/xd.c
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.9
# [PATCH] DAC960 patch to entry points with a new fix
# 
# From: Dave Olien <dmo@osdl.org>
# 
# Christoph submitted a patch to linus last week fixing up some DAC960 driver
# entry points.  That patch will OOPS during boot on version 2 controller
# types.  Christoph's version of the disk_size() function was dereferencing
# a NULL pointer in it's "else" clause.
# 
# Christoph's patch hasn't appeared in linus's BK tree yet.  So, I'm
# resending Christoph's orignal patch with my fix to disk_size() included.
# This patch can be applied to the driver in Linus's BK tree from April 28.
# 
# Here's Christoph's original description of his patch:
# 
# Some grepping showed that DAC960's open routine was duplicating parts
# of check_disk_change().  I went on fixing this by implementing a
# media_changed method and making DAC960_Open use it.  While looking
# at the surrounding code I noticed that
# 
#   (a) all methods weren't using the private data the upperlayer
#       hands to it properly, but instead using kdev_t-based indexes
#   (b) DAC960_Open/DAC960_Release was keeping never used counters
#   (c) DAC960_Open was doing tons of checks the upperlayer already does
#   (d) DAC960_Release was entirely superflous.
# 
# The patch below corrects that and rewrites the block entry points
# into readable code - 100 LOC are gone and the same amount replaced
# by readable code.
# --------------------------------------------
# 03/04/30	ak@muc.de	1.1165.6.10
# [PATCH] Update alt_instr to handle SSE2 prefetch and better nops
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.11
# [PATCH] allow modular JBD
# 
# From: Paul Clements <Paul.Clements@SteelEye.com>
# 
# Currently, when I build ext3 as a module, jbd gets built into the kernel
# proper.  This trivial patch allows jbd to be built as a module when ext3 is
# also modular.  I believe this is the intention, as this is how it works in
# 2.4.  I've built and tested with modular jbd and ext3 on 2.5.68.
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.12
# [PATCH] generic HDLC module API update
# 
# From: Krzysztof Halasa <khc@pm.waw.pl>
# 
# Updates the HDLC drivers to the approved module API.
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.13
# [PATCH] proc_file_read fix
# 
# From: Miklos.Szeredi@eth.ericsson.se (Miklos Szeredi)
# 
# This fixes a problem with method 0 of proc_file_read (when the whole file
# is copied to the page).  The calculation of the final bytecount is wrong,
# and hence smaller then page size reads will give a truncated file.
# 
# Current 2.4 kernels do it this way as well.
# --------------------------------------------
# 03/04/30	hch@lst.de	1.1165.6.14
# [PATCH] improved bdevname
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.15
# [PATCH] buffer.c unused vars
# 
# - Remove dead variable from block_read_full_page (Oleg Drokin)
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.16
# [PATCH] simple mwave code cleanup
# 
# From: Paul B Schroeder <paulsch@haywired.net>
# 
# The following patch simply moves the 'nr_registered_attrs' and
# 'device_registered' variables in mwavedd.c into the MWAVE_DEVICE_DATA struct
# which is defined in mwavedd.h..
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.17
# [PATCH] fs/ext3/super.c fix for orphan recovery error path
# 
# From: Ernie Petrides <petrides@redhat.com>
# 
# The problem resolved by this patch is that if a root file system has an
# error recorded from a previous mount, and then (when rebooting) the orphan
# recovery procedure is initiated, the recovery is correctly skipped but the
# file system is incorrectly left in a writable state.
# 
# This causes the subsequent fsck to fail due to the root file system
# being dirty, and then requires manual intervention to get the system
# fully booted.
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.18
# [PATCH] update nr_threads commentary
# 
# From: Manfred Spraul <manfred@colorfullife.com>
# 
# Update some no-longer-true comments around nr_threads locking.
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.19
# [PATCH] lost_tick fixes
# 
# From: john stultz <johnstul@us.ibm.com>
# 
# - Whitespace fixes
# 
# - Fix for the case where HZ != 1000 (pointed out by Mika Penttila).
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.20
# [PATCH] zone accounting race fix
# 
# Fix a bug identified by Nikita Danilov: refill_inactive_zone() is deferring
# the update of zone->nr_inactive and zone->nr_active for too long - it needs
# to be consistent whenever zone->lock is not held.
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.21
# [PATCH] aio support for block devices
# 
# From: Janet Morgan <janetmor@us.ibm.com>
# 
# Here's a small patch that adds aio_read and aio_write methods to the
# block device driver.
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.22
# [PATCH] percpu counters cause UML compilation errors in with SMP
# 
# The percpu counters break UML SMP compilation (in current 2.5.58 bk snapshot)
# (first NR_CPUS undeclared in header, then dereference of incomplete structure
# in .c file)
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.23
# [PATCH] config menu cleanups
# 
# From Robert Day, through "Randy.Dunlap" <rddunlap@osdl.org>
# 
# This is a patch from Robert Day that does the following:
# 
# 1) shift menu item in "Processor type and features" menu
# 2) clean up "Bus options" menu so it's actually hierarchical
# 
# Part of it (moving X86_IO_APIC around) looked a little odd to me,
# so I asked Roman Zippel about it, and he replied:
# 
# "It's correct, although I wouldn't call it a 'design quirk'. :)
# It forces one to group options which belong logically together and in this
# case X86_IO_APIC is really a bit misplaced, even if it's not visible."
# 
# I have tested it (on 2.5.68-plain) and it does indeed make the menus
# more hierarchical.
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1165.6.24
# [PATCH] oom-killer locking fix
# 
# From: William Lee Irwin III <wli@holomorphy.com>, Robert Love
# 
# Add some spinlock protection around the oom-killer state.
# --------------------------------------------
# 03/04/30	torvalds@home.transmeta.com	1.1165.2.11
# Merge bk://kernel.bkbits.net/davem/net-2.5
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/30	torvalds@home.transmeta.com	1.1165.2.12
# Merge bk://kernel.bkbits.net/davem/sparc-2.5
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/30	torvalds@home.transmeta.com	1.1165.2.13
# Merge http://linux-ntfs.bkbits.net/ntfs-2.5
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/30	torvalds@home.transmeta.com	1.1165.1.8
# Merge bk://ppc.bkbits.net/for-linus-ppc
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/30	hch@lst.de	1.1165.1.9
# [PATCH] use .devfs_name in struct miscdevice
# 
# There's three drivers in the tree that workaround the suboptimal
# devfs name choice of the misc device layer (/dev/misc/<foo>) using
# devfs_mk_symlink.    Switch them to set miscdev.devfs_name instead
# to get the right name from the very beginning.
# --------------------------------------------
# 03/04/30	pavel@ucw.cz	1.1165.1.10
# [PATCH] ioctl32 cleanups
# 
# ioctl32 cleanups are pretty neccessary (we have 6+ copies of 600+
# lines tables, all getting slightly out of sync, not speaking about
# surrounding code produced by cut-and-paste).
# --------------------------------------------
# 03/04/30	hch@lst.de	1.1165.1.11
# [PATCH] remove devfs hack from misc_register
# 
# There's an (fortunately unused) devfs in misc_register currently,
# when the name of the miscdevice contains a slash the name is used
# as devfs name instead of misc/<name>.  Kill if as we have .devfs_name
# for this kind of stuff now.
# --------------------------------------------
# 03/04/30	hch@lst.de	1.1165.1.12
# [PATCH] add an missing prototype to initrd.h
# --------------------------------------------
# 03/04/30	B.Zolnierkiewicz@elka.pw.edu.pl	1.1165.1.13
# [PATCH] Remove duplication of generic ide funcs from ide-taskfile.c.
# 
# They are unused, not needed and identical to generic ones so kill 'em:
#     task_read_24(),
#     task_try_to_flush_leftover_data(),
#     taskfile_dump_status(),
#     taskfile_error().
# --------------------------------------------
# 03/04/30	B.Zolnierkiewicz@elka.pw.edu.pl	1.1165.1.14
# [PATCH] Kill dups of read_24(), rename it to ide_read_24().
# 
#  - kill dups in ide.c and ide-disk.c
#  - read_24() is exported so rename it to ide_read_24()
#  - add it ide.h
# --------------------------------------------
# 03/04/30	gj@pointblue.com.pl	1.1179
# [PATCH] USB: fix usbkbd.c compilation error
# --------------------------------------------
# 03/04/30	randy.dunlap@verizon.net	1.1180
# [PATCH] sidewinder: reduce stack usage
# 
# reduce stack usage in sw_connect() from 0x490 to 0x98 on P4 SMP (gcc 3.2);
# --------------------------------------------
# 03/04/30	randy.dunlap@verizon.net	1.1181
# [PATCH] uinput.c: reduce stack usage
# 
# drivers/input/misc/uinput.c::uinput_alloc_device(): reduce stack size
# from 0x480 to 0x24;
# --------------------------------------------
# 03/04/30	ccheney@cheney.cx	1.1182
# [PATCH] USB: vicam.c copyright patches
# 
# Here are two vicam.c patches to clean up and restore copyright notices
# for 2.4.21-rc1 and 2.5.68-bk9. At some point in time Pavel and my
# copyrights were remove inadvertenly from the code.
# --------------------------------------------
# 03/04/30	James@superbug.demon.co.uk	1.1183
# [PATCH] USB: Add support for Pentax Still Camera to linux kernel
# --------------------------------------------
# 03/04/30	pavel@ucw.cz	1.1165.1.15
# [PATCH] ioctl32: leftovers
# 
# Missed parts of the ioctl32 compatibility patch: a few ioctls from
# PA-RISC, and missing <linux/compat_ioctl.h> file.
# --------------------------------------------
# 03/04/30	greg@kroah.com	1.1184
# Merge kroah.com:/home/linux/linux/BK/bleed-2.5
# into kroah.com:/home/linux/linux/BK/gregkh-2.5
# --------------------------------------------
# 03/04/30	bcollins@debian.org	1.1165.1.16
# [PATCH] Merge to current SVN repo (r915)
# 
# Changes:
# 
#   - Convert to a static highlevel handle for all drivers. Gets rid of
#     a kmalloc for each driver and consolidates the highlevel handle and
#     highlevel ops. Reduces points of failure as well.
#   - Move host number allocation to hosts.c, giving all drivers access to
#     it.
#   - Implemented S800 changes for core and sbp2. Thanks to TI and LaCie
#     for hardware to test this. 1394b support coming soon.
#   - Convert nodemgr to using a similar device classification hack as
#     usb. The old class_num hack I had in place was broken do to its
#     removal. This is a much cleaner solution.
# --------------------------------------------
# 03/04/30	torvalds@home.transmeta.com	1.1185
# Merge bk://kernel.bkbits.net/gregkh/linux/linus-2.5
# into home.transmeta.com:/home/torvalds/v2.5/linux
# --------------------------------------------
# 03/04/30	akpm@digeo.com	1.1186
# [PATCH] cs46xx: fix incomplete search-and-replace
# 
# Leftovers from the mem_map_reserve-removal patch.
# --------------------------------------------
# 03/04/30	ak@muc.de	1.1187
# [PATCH] Fix prefetch patching in 2.5-bk
# 
# Brown paperbag time. I forgot to take the modrm byte in account
# with the prefetch patch replacement.  With 3.2 it worked because
# it used the right registers in my configuration.
# 
# But gcc 2.96 uses a different register in __dpath and the prefetch becomes
# 4 bytes with modrm and the original nop needs to be as long as that too.
# --------------------------------------------
# 03/04/30	ak@muc.de	1.1188
# [PATCH] x86-64 update
# 
# Just make x86-64/amd64 compile again.  Only architecture specific
# changes.
# 
# And a workaround for the Opteron prefetch bug.
# 
# Also remove the obsolete LVM1 ioctl emulation code.
# --------------------------------------------
# 03/04/30	ak@muc.de	1.1189
# [PATCH] discontigmem fix
# 
# Try to avoid calling "pfn_to_page()" on invalid pfn's.  It used to be
# legal, but the CONFIG_DISCONTIGMEM people want us to try to avoid it,
# since they do magic stuff in their "pfn_to_page" translations.
# --------------------------------------------
#
diff -Nru a/Documentation/eisa.txt b/Documentation/eisa.txt
--- a/Documentation/eisa.txt	Wed Apr 30 22:28:11 2003
+++ b/Documentation/eisa.txt	Wed Apr 30 22:28:11 2003
@@ -79,8 +79,9 @@
 };
 
 id_table	: an array of NULL terminated EISA id strings,
-		  followed by an empty string. Each string can be
-		  paired with a driver-dependant value (driver_data).
+		  followed by an empty string. Each string can
+		  optionnaly be paired with a driver-dependant value
+		  (driver_data).
 
 driver		: a generic driver, such as described in
 		  Documentation/driver-model/driver.txt. Only .name,
@@ -88,19 +89,19 @@
 
 An example is the 3c509 driver :
 
-struct eisa_device_id el3_eisa_ids[] = {
-        { "TCM5092" },
-        { "TCM5093" },
-        { "" }
+static struct eisa_device_id vortex_eisa_ids[] = {
+	{ "TCM5920", EISA_3C592_OFFSET },
+	{ "TCM5970", EISA_3C597_OFFSET },
+	{ "" }
 };
 
-struct eisa_driver el3_eisa_driver = {
-        .id_table = el3_eisa_ids,
-        .driver   = {
-                .name    = "3c509",
-                .probe   = el3_eisa_probe,
-                .remove  = __devexit_p (el3_device_remove)
-        }
+static struct eisa_driver vortex_eisa_driver = {
+	.id_table = vortex_eisa_ids,
+	.driver   = {
+		.name    = "3c59x",
+		.probe   = vortex_eisa_probe,
+		.remove  = vortex_eisa_remove
+	}
 };
 
 ** Device :
diff -Nru a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
--- a/Documentation/filesystems/Locking	Wed Apr 30 22:28:16 2003
+++ b/Documentation/filesystems/Locking	Wed Apr 30 22:28:16 2003
@@ -18,13 +18,13 @@
 
 locking rules:
 	none have BKL
-		dcache_lock	may block
-d_revalidate:	no		yes
-d_hash		no		yes
-d_compare:	no		no 
-d_delete:	yes		no
-d_release:	no		yes
-d_iput:		no		yes
+		dcache_lock	rename_lock	->d_lock	may block
+d_revalidate:	no		no		no		yes
+d_hash		no		no		no		yes
+d_compare:	no		yes		no		no 
+d_delete:	yes		no		yes		no
+d_release:	no		no		no		yes
+d_iput:		no		no		no		yes
 
 --------------------------- inode_operations --------------------------- 
 prototypes:
diff -Nru a/Documentation/filesystems/ntfs.txt b/Documentation/filesystems/ntfs.txt
--- a/Documentation/filesystems/ntfs.txt	Wed Apr 30 22:28:09 2003
+++ b/Documentation/filesystems/ntfs.txt	Wed Apr 30 22:28:09 2003
@@ -247,6 +247,19 @@
 
 Note, a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog.
 
+2.1.4:
+	- Minor update allowing compilation with all gcc versions (well, the
+	  ones the kernel can be compiled with anyway).
+2.1.3:
+	- Major bug fixes for reading files and volumes in corner cases which
+	  were being hit by Windows 2k/XP users.
+2.1.2:
+	- Major bug fixes aleviating the hangs in statfs experienced by some
+	  users.
+2.1.1:
+	- Update handling of compressed files so people no longer get the
+	  frequently reported warning messages about initialized_size !=
+	  data_size.
 2.1.0:
 	- Add configuration option for developmental write support.
 	- Initial implementation of file overwriting. (Writes to resident files
diff -Nru a/Documentation/networking/ixgb.txt b/Documentation/networking/ixgb.txt
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/Documentation/networking/ixgb.txt	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,226 @@
+Linux* Base Driver for the Intel(R) PRO/10GbE Family of Adapters
+================================================================
+
+January 06, 2003
+
+
+Contents
+========
+
+- In This Release
+- Supported Adapters
+- Command Line Parameters
+- Improving Performance
+- Support
+
+
+In This Release
+===============
+
+This file describes the Linux* Base Driver for the Intel(R) PRO/10GbE Family 
+of Adapters, version 1.0.x. This driver is intended for 2.4.x kernels; it is 
+known to build properly on 2.4.x kernels through 2.4.18. Intel focused 
+testing on Intel architectures running kernels 2.4.18. This driver includes 
+support for Itanium(TM)-based systems.
+
+For questions related to hardware requirements, refer to the documentation 
+supplied with your Intel PRO/10GbE adapter. All hardware requirements listed 
+apply to use with Linux.
+
+
+Supported Adapters
+==================
+
+The following Intel network adapters are compatible with the drivers in this 
+release:
+
+   Controller  Adapter Name                           Board IDs
+   ----------  ------------                           ---------
+
+   82597EX     Intel(R) PRO/10GbE LR Server Adapter   A82505-xxx
+
+
+To verify your Intel adapter is supported, find the board ID number on the 
+adapter. Look for a label that has a barcode and a number in the format  
+A12345-001. Match this to the list of numbers above.
+
+For more information on how to identify your adapter, go to the Adapter & 
+Driver ID Guide at:
+
+    http://support.intel.com/support/network/adapter/pro100/21397.htm
+
+For the latest Intel network drivers for Linux, go to:
+
+    http://downloadfinder.intel.com/scripts-df/support_intel.asp
+
+Command Line Parameters
+=======================
+
+If the driver is built as a module, the  following optional parameters are 
+used by entering them on the command line with the modprobe or insmod command
+using this syntax:
+
+     modprobe ixgb [<option>=<VAL1>,<VAL2>,...]
+
+     insmod ixgb [<option>=<VAL1>,<VAL2>,...]
+
+For example, with two PRO/10GbE PCI adapters, entering:
+
+    insmod ixgb TxDescriptors=80,128
+
+loads the ixgb driver with 80 TX resources for the first adapter and 128 TX 
+resources for the second adapter.
+
+The default value for each parameter is generally the recommended setting,
+unless otherwise noted.
+
+
+FlowControl
+Valid Range: 0-3 (0=none, 1=Rx only, 2=Tx only, 3=Rx&Tx)
+Default: Read from the EEPROM
+         If EEPROM is not detected, default is 3
+    This parameter controls the automatic generation(Tx) and response(Rx) to 
+    Ethernet PAUSE frames.
+
+RxDescriptors
+Valid Range: 64-4096
+Default Value: 1024
+    This value is the number of receive descriptors allocated by the driver. 
+    Increasing this value allows the driver to buffer more incoming packets. 
+    Each descriptor is 16 bytes.  A receive buffer is also allocated for 
+    each descriptor and can be either 2048, 4056, 8192, or 16384 bytes, 
+    depending on the MTU setting. When the MTU size is 1500 or less, the 
+    receive buffer size is 2048 bytes. When the MTU is greater than 1500 the
+    receive buffer size will be either 4056, 8192, or 16384 bytes. The 
+    maximum MTU size is 16114.
+
+RxIntDelay
+Valid Range: 0-65535 (0=off)
+Default Value: 6
+    This value delays the generation of receive interrupts in units of 
+    0.8192 microseconds.  Receive interrupt reduction can improve CPU 
+    efficiency if properly tuned for specific network traffic. Increasing 
+    this value adds extra latency to frame reception and can end up 
+    decreasing the throughput of TCP traffic. If the system is reporting 
+    dropped receives, this value may be set too high, causing the driver to 
+    run out of available receive descriptors.
+
+TxDescriptors
+Valid Range: 64-4096
+Default Value: 256
+    This value is the number of transmit descriptors allocated by the driver.
+    Increasing this value allows the driver to queue more transmits. Each 
+    descriptor is 16 bytes.
+
+XsumRX
+Valid Range: 0-1
+Default Value: 1
+    A value of '1' indicates that the driver should enable IP checksum
+    offload for received packets (both UDP and TCP) to the adapter hardware.
+
+XsumTX
+Valid Range: 0-1
+Default Value: 1
+    A value of '1' indicates that the driver should enable IP checksum
+    offload for transmitted packets (both UDP and TCP) to the adapter 
+    hardware.
+
+
+Improving Performance
+=====================
+
+With the Intel PRO/10 GbE adapter, the default Linux configuration will very 
+likely limit the total available throughput artificially.  There is a set of 
+things that when applied together increase the ability of Linux to transmit 
+and receive data.  The following enhancements were originally acquired from
+settings published at http://www.spec.org/web99 for various submitted results 
+using Linux.
+
+NOTE: These changes are only suggestions, and serve as a starting point for 
+tuning your network performance.
+
+The changes are made in three major ways, listed in order of greatest effect:
+- Use ifconfig to modify the mtu (maximum transmission unit) and the txqueuelen 
+  parameter.
+- Use sysctl to modify /proc parameters (essentially kernel tuning)
+- Use setpci to modify the MMRBC field in PCI-X configuration space to increase 
+  transmit burst lengths on the bus.
+
+NOTE: setpci modifies the adapter's configuration registers to allow it to read 
+up to 4k bytes at a time (for transmits).  However, for some systems the 
+behavior after modifying this register may be undefined (possibly errors of some 
+kind). A power-cycle, hard reset or explicitly setting the e6 register back to 
+22 (setpci -d 8086:1048 e6.b=22) may be required to get back to a stable 
+configuration.
+
+- COPY these lines and paste them into ixgb_perf.sh:
+#!/bin/bash
+echo "configuring network performance , edit this file to change the interface"
+# set mmrbc to 4k reads, modify only Intel 10GbE device IDs
+setpci -d 8086:1048 e6.b=2e
+# set the MTU (max transmission unit) - it requires your switch and clients to change too!
+# set the txqueuelen
+# your ixgb adapter should be loaded as eth1 for this to work, change if needed
+ifconfig eth1 mtu 9000 txqueuelen 1000 up
+# call the sysctl utility to modify /proc/sys entries 
+sysctl -p ./sysctl_ixgb.conf 
+- END ixgb_perf.sh
+
+- COPY these lines and paste them into sysctl_ixgb.conf:
+# some of the defaults may be different for your kernel
+# call this file with sysctl -p <this file>
+# these are just suggested values that worked well to increase throughput in
+# several network benchmark tests, your mileage may vary
+
+### IPV4 specific settings
+net.ipv4.tcp_timestamps = 0 # turns TCP timestamp support off, default 1, reduces CPU use
+net.ipv4.tcp_sack = 0 # turn SACK support off, default on
+# on systems with a VERY fast bus -> memory interface this is the big gainer 
+net.ipv4.tcp_rmem = 10000000 10000000 10000000 # sets min/default/max TCP read buffer, default 4096 87380 174760
+net.ipv4.tcp_wmem = 10000000 10000000 10000000 # sets min/pressure/max TCP write buffer, default 4096 16384 131072
+net.ipv4.tcp_mem = 10000000 10000000 10000000 # sets min/pressure/max TCP buffer space, default 31744 32256 32768
+
+### CORE settings (mostly for socket and UDP effect)
+net.core.rmem_max = 524287 # maximum receive socket buffer size, default 131071
+net.core.wmem_max = 524287 # maximum send socket buffer size, default 131071
+net.core.rmem_default = 524287 # default receive socket buffer size, default 65535
+net.core.wmem_default = 524287 # default send socket buffer size, default 65535
+net.core.optmem_max = 524287 # maximum amount of option memory buffers, default 10240
+net.core.netdev_max_backlog = 300000 # number of unprocessed input packets before kernel starts dropping them, default 300
+- END sysctl_ixgb.conf
+
+Edit the ixgb_perf.sh script if necessary to change eth1 to whatever interface 
+your ixgb driver is using.
+
+NOTE: Unless these scripts are added to the boot process, these changes will 
+only last only until the next system reboot.
+
+
+Resolving Slow UDP Traffic
+--------------------------
+
+If your server does not seem to be able to receive UDP traffic as fast as it 
+can receive TCP traffic, it could be because Linux, by default, does not set 
+the network stack buffers as large as they need to be to support high UDP 
+transfer rates. One way to alleviate this problem is to allow more memory to 
+be used by the IP stack to store incoming data. 
+
+For instance, use the commands: 
+    sysctl -w net.core.rmem_max=262143
+and
+    sysctl -w net.core.rmem_default=262143
+to increase the read buffer memory max and default to 262143 (256k - 1) from 
+defaults of max=131071 (128k - 1) and default=65535 (64k - 1). These variables 
+will increase the amount of memory used by the network stack for receives, and 
+can be increased significantly more if necessary for your application.
+
+Support
+=======
+
+For general information and support, go to the Intel support website at:
+
+    http://support.intel.com
+
+If an issue is identified with the released source code on the supported
+kernel with a supported adapter, email the specific information related to 
+the issue to linux.nics@intel.com.
diff -Nru a/Documentation/scsi/ChangeLog.megaraid b/Documentation/scsi/ChangeLog.megaraid
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/Documentation/scsi/ChangeLog.megaraid	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,42 @@
+### Version 2.00.3
+Wed Jan 29 09:13:44 EST 200 - Atul Mukker <atulm@lsil.com>
+i.	Change the handshake in ISR while acknowledging interrupts. Write the
+	valid interrupt pattern 0x10001234 as soon as it is read from the
+	outdoor register. In existing driver and on certain platform, invalid
+	command ids were being returned.
+
+	Also, do not wait on status be become 0xFF, since FW can return this
+	status in certain circumstances.
+
+	Initialize the numstatus field of mailbox to 0xFF so that we can wait
+	on this wait in next interrupt. Firmware does not change its value
+	unless there are some status to be posted
+
+ii.	Specify the logical drive number while issuing the RESERVATION_STATUS
+
+iii.	Reduce the default mailbox busy wait time from 300us to 10us. This is
+	done to avaoid a possible deadlock in FW because of longer bust waits.
+
+iv.	The max outstanding commands are reduced to 126 because that't the
+	safest value on all FW.
+
+v.	Number of sectors per IO are reduced to 128 (64kb), becuase FW needs
+	resources in special circumstances like check consistency, rebuilds
+	etc.
+
+vi.	max_commands is no longer a module parameter because of iv.
+
+### Version: 2.00.2
+i.	Intermediate release with kernel specific code
+
+
+### Version: 2.00.1i
+Wed Dec  4 14:34:51 EST 2002 - Atul Mukker <atulm@lsil.com>
+i.	Making the older IO based controllers to work with this driver
+
+
+### Version 2.00.1
+Fri Nov 15 10:59:44 EST 2002 - Atul Mukker <atulm@lsil.com>
+i.	Release host lock before issuing internal command to reset
+	reservations in megaraid_reset() and reacquire after internal command
+	is completed.
diff -Nru a/Documentation/scsi/dc395x.txt b/Documentation/scsi/dc395x.txt
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/Documentation/scsi/dc395x.txt	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,72 @@
+README file for the dc395x SCSI driver
+==========================================
+
+Status
+------
+The driver has been tested with CD-R and CD-R/W drives. These should
+be safe to use. Testing with hard disks has not been done to any
+great degree and caution should be exercised if you want to attempt
+to use this driver with hard disks.
+
+This is a 2.5 only driver. For a 2.4 driver please see the original
+driver (which this driver started from) at
+http://www.garloff.de/kurt/linux/dc395/
+
+Problems, questions and patches should be submitted to the mailing
+list. Details on the list, including archives, are available at
+http://lists.twibble.org/mailman/listinfo/dc395x/
+
+Parameters
+----------
+The driver uses the settings from the EEPROM set in the SCSI BIOS 
+setup. If there is no EEPROM, the driver uses default values.
+Both can be overriden by command line parameters (module or kernel
+parameters).
+
+The syntax is as follows:
+ dc395x = AdapterID, SpeedIdx, DevMode, AdaptMode, Tags, DelayReset
+
+AdapterID : Host Adapter SCSI ID
+SpeedIdx  : 0,1,...7 = 20,13.3,10,8,6.7,5.8,5,4 MHz               [ 7]
+DevMode   : Bitmap for Dev Cfg                                    [63]
+AdaptMode : Bitmap for Adapter Cfg                                [47]
+Tags      : The number of tags is 1<<x, if x has been specified   [ 4]
+DelayReset: The seconds to not accept commands after a SCSI Reset [ 1]
+
+DevMode bit definition:
+   Bit Val(hex) Val(dec)  Meaning
+   *0	 0x01	    1	  Parity check
+   *1	 0x02	    2	  Synchronous Negotiation
+   *2	 0x04	    4	  Disconnection
+   *3	 0x08	    8	  Send Start command on startup. (Not used)
+   *4	 0x10	   16	  Tagged Command Queueing
+   *5	 0x20	   32	  Wide Negotiation
+
+AdaptMode bit definition
+   Bit Val(hex) Val(dec)  Meaning
+   *0	 0x01	    1	  Support more than two drives. (Not used)
+   *1	 0x02	    2	  Use DOS compatible mapping for HDs greater than 1GB.
+   *2	 0x04	    4	  Reset SCSI Bus on startup.
+   *3	 0x08	    8	  Active Negation: Improves SCSI Bus noise immunity.
+    4	 0x10	   16	  Immediate return on BIOS seek command. (Not used)
+ (*)5	 0x20	   32	  Check for LUNs >= 1.
+
+If you set AdapterID to -1, the adapter will use conservative
+("safe") default settings instead; more precisely, dc395x=-1 is a
+shortcut for dc395x=7,4,9,15,2,10
+
+If you specify -2 for a value, it will be ignored. You don't need to
+specify all six parameters.
+
+Copyright
+---------
+The driver is free software. It is protected by the GNU General Public
+License (GPL). Please read it, before using this driver. It should be
+included in your kernel sources and with your distribution. It carries the
+filename COPYING. If you don't have it, please ask me to send you one by
+email.
+Note: The GNU GPL says also something about warranty and liability. 
+Please be aware the following: While we do my best to provide a working and
+reliable driver, there is a chance, that it will kill your valuable data. 
+We refuse to take any responsibility for that. The driver is provided as-is
+and YOU USE IT AT YOUR OWN RESPONSIBILITY.
diff -Nru a/Documentation/scsi/scsi_mid_low_api.txt b/Documentation/scsi/scsi_mid_low_api.txt
--- a/Documentation/scsi/scsi_mid_low_api.txt	Wed Apr 30 22:28:14 2003
+++ b/Documentation/scsi/scsi_mid_low_api.txt	Wed Apr 30 22:28:14 2003
@@ -16,13 +16,13 @@
 (SPI) controllers based on that company's 7xxx chip series. The aic7xxx
 LLD can be built into the kernel or loaded as a module. There can only be
 one aic7xxx LLD running in a Linux system but it may be controlling many 
-HBAs. These HBAs might be either on PCI daughterboards or built into 
+HBAs. These HBAs might be either on PCI daughter-boards or built into 
 the motherboard (or both). Like most modern HBAs, each aic7xxx host
-has its own PCI device address. [The one-to-one correspondance between
+has its own PCI device address. [The one-to-one correspondence between
 a SCSI host and a PCI device is common but not required (e.g. with
 ISA or MCA adapters).]
 
-This version of the document roughly matches linux kernel version 2.5.63 .
+This version of the document roughly matches linux kernel version 2.5.67 .
 
 Documentation
 =============
@@ -33,14 +33,15 @@
 (e.g. aic7xxx.txt). The SCSI mid-level is briefly described in scsi.txt
 (with a url to a document describing the SCSI subsystem in the lk 2.4
 series). Two upper level drivers have documents in that directory:
-st.txt (SCSI tape driver) and scsi-generic.txt .
+st.txt (SCSI tape driver) and scsi-generic.txt (for the sg driver).
 
 Some documentation (or urls) for LLDs may be in the C source code or
-in the same directory. For example to find a url about the USB mass
-storage driver see the /usr/src/linux/drivers/usb/storage directory.
+in the same directory as the C source code. For example to find a url
+about the USB mass storage driver see the 
+/usr/src/linux/drivers/usb/storage directory.
 
 The Linux kernel source Documentation/DocBook/scsidrivers.tmpl file
-refers to this file. With the appropriate DocBook toolset, this permits
+refers to this file. With the appropriate DocBook tool-set, this permits
 users to generate html, ps and pdf renderings of information within this
 file (e.g. the interface functions).
 
@@ -49,17 +50,15 @@
 Traditionally a LLD for the SCSI subsystem has been at least two files in
 the drivers/scsi directory. For example, a driver called "xyz" has a header
 file "xyz.h" and a source file "xyz.c". [Actually there is no good reason
-why this couldn't all be in one file.] Some drivers that have been ported
-to several operating systems have more than two files. For example the
-aic7xxx driver has separate files for generic and OS-specific code
-(e.g. FreeBSD and Linux). Such drivers tend to have their own directory
-under the drivers/scsi directory.
+why this couldn't all be in one file; the header file is superfluous.] Some
+drivers that have been ported to several operating systems have more than
+two files. For example the aic7xxx driver has separate files for generic 
+and OS-specific code (e.g. FreeBSD and Linux). Such drivers tend to have
+their own directory under the drivers/scsi directory.
 
 When a new LLD is being added to Linux, the following files (found in the
-drivers/scsi directory) will need some attention: Makefile, Config.help and
-Config.in . SCSI documentation is found in the Documentation/scsi directory
-of the kernel source tree. It is probably best to study how existing LLDs 
-are organized.
+drivers/scsi directory) will need some attention: Makefile and Kconfig .
+It is probably best to study how existing LLDs are organized.
 
 As the 2.5 series development kernels evolve, changes are being
 introduced into this interface. An example of this is driver
@@ -78,7 +77,8 @@
   a) directly invoking functions supplied by the mid level
   b) passing a set of function pointers to a registration function
      supplied by the mid level. The mid level will then invoke these
-     functions at some point in the future
+     functions at some point in the future. The LLD will supply
+     implementations of these functions.
   c) direct access to instances of well known data structures maintained
      by the mid level
 
@@ -86,7 +86,7 @@
 supplied functions" below.
 
 Those functions in group b) are listed in a section entitled "Interface
-functions" below. The function pointers are placed in the members of
+functions" below. Their function pointers are placed in the members of
 "struct SHT", an instance of which is passed to scsi_register() [or
 scsi_register_host() in the passive initialization model]. Those interface
 functions that are not mandatory and that the LLD does not wish to supply
@@ -97,34 +97,42 @@
 Those instances in group c) are slowly being removed as they tend to be
 "racy" especially in a hotplug environment.
 
+All functions defined within a LLD and all data defined at file scope
+should be static. For example the slave_alloc() function in a LLD
+called "xxx" could be defined as 
+"static int xxx_slave_alloc(struct scsi_device * sdev) { /* code */ }"
+
 
 Hotplug initialization model
 ============================
 In this model a LLD controls when SCSI hosts are introduced and removed
 from the SCSI subsystem. Hosts can be introduced as early as driver
 initialization and removed as late as driver shutdown. Typically a driver
-will respond to a sysfs probe() callback that indicates a HBA is present
-(e.g. a PCI device). After confirming it is a device that it wants to
-control, it will initialize the HBA and then register a new host with the
-SCSI mid level.
+will respond to a sysfs probe() callback that indicates a HBA has been
+detected. After confirming that the new device is one that the LLD wants
+to control, the LLD will initialize the HBA and then register a new host
+with the SCSI mid level.
 
 Hot unplugging a HBA that controls a disk which is processing SCSI
 commands on a mounted file system is an ugly situation. Issues with
 this scenario are still being worked through. The primary concern is
 the stability of the kernel (specifically the block and SCSI subsystems)
 since the effected disk can be "cleaned up" the next time it is seen.
+In the sysfs model, a remove() callback indicates a HBA has disappeared.
 
 During LLD initialization the driver should register itself with the
 appropriate IO bus on which it expects to find HBA(s) (e.g. the PCI bus).
 This can probably be done via sysfs. Any driver parameters (especially
-those that are writeable after the driver is loaded) could also be
-registered with sysfs at this point. At the end of driver initialization
-the SCSI mid level is typically not aware of its presence.
+those that are writable after the driver is loaded) could also be
+registered with sysfs at this point. The SCSI mid level first becomes
+aware of a LLD when that LLD registers its first HBA.
 
 At some later time, the LLD becomes aware of a HBA and what follows
 is a typical sequence of calls between the LLD and the mid level.
-This example shows 3 devices being found and 1 device not being found:
+This example shows the mid level scanning the newly introduced HBA for 3 
+scsi devices of which only the first 2 respond:
 
+[HBA PROBE]
 LLD                   mid level                    LLD
 ---                   ---------                    ---
 scsi_register()  -->
@@ -136,9 +144,6 @@
 		    slave_alloc()
                     slave_configure() -->  scsi_adjust_queue_depth()
 			 |
-		    slave_alloc()
-                    slave_configure() -->  scsi_adjust_queue_depth()
-			 |
 		    slave_alloc()   **
                     slave_destroy() **
 
@@ -150,21 +155,40 @@
 Here is the corresponding sequence when a host (HBA) is being
 removed:
 
-LLD                   mid level  
----                   ---------
-scsi_remove_host()  -----+
-                         |
-                    slave_destroy() 
-                    slave_destroy()
-                    slave_destroy()
-scsi_unregister()  -->
+[HBA REMOVE]
+LLD                      mid level                 LLD
+---                      ---------                 ---
+scsi_remove_host() ---------+
+                            |
+                     slave_destroy()
+                     slave_destroy()
+                        release()     -->     scsi_unregister()
 
 It is practical for a LLD to keep track of struct Scsi_Host instances
 (a pointer is returned by scsi_register() ) and struct scsi_device
 instances (a pointer is passed as the parameter to slave_alloc() and
 slave_configure() ). Both classes of instances are "owned" by the 
 mid-level. struct scsi_device instances are freed after slave_destroy().
-struct Scsi_Host instances are freed after scsi_unregister().
+struct Scsi_Host instances are freed within scsi_unregister().
+
+TODO:
+Descriptions, are the following correct?
+[DEVICE hotplug]
+LLD                   mid level                    LLD
+---                   ---------                    ---
+scsi_add_device()  ------+
+                         |
+		    slave_alloc()
+                    slave_configure() -->  scsi_adjust_queue_depth()
+
+[DEVICE unplug]
+LLD                      mid level                 LLD
+---                      ---------                 ---
+scsi_set_device_offline()
+scsi_remove_device() -------+
+                            |
+                     slave_destroy()
+
 
 
 Passive initialization model
@@ -226,8 +250,7 @@
                      slave_destroy()
                         release()   -->   scsi_unregister()
 
-Both slave_destroy() and release() are optional. If they are not supplied
-the mid level supplies default actions.
+slave_destroy() is optional. 
 
 The shortcoming of the "passive initialization model" is that host
 registration and de-registration are (typically) tied to LLD initialization
@@ -238,39 +261,97 @@
 
 Conventions
 ===========
-First Linus's thoughts on C coding found in file Documentation/CodingStyle . 
+First, Linus's thoughts on C coding can be found in the file 
+Documentation/CodingStyle . 
 
-Next there is a movement to "outlaw" typedefs introducing synonyms for 
+Next, there is a movement to "outlaw" typedefs introducing synonyms for 
 struct tags. Both can be still found in the SCSI subsystem, for example: 
 "typedef struct SHT { ...} Scsi_Host_Template;" in hosts.h . In this
-case "struct SHT" is preferred to "Scsi_Host_Template".
+case "struct SHT" is preferred to "Scsi_Host_Template". [The poor naming
+example was chosen with malevolent intent.]
 
-Also C99 additions are encouraged to the extent they are supported
+Also, C99 enhancements are encouraged to the extent they are supported
 by the relevant gcc compilers. So "//" style comments are encouraged
 were appropriate as are C99 style structure and array initializers.
+Don't go too far, VLAs are not properly supported yet.
+
+Well written, tested and documented code, need not be re-formatted to
+comply with the above conventions. For example, the aic7xxx driver
+comes to Linux from FreeBSD and Adaptec's own labs. No doubt FreeBSD
+and Adaptec have their own coding conventions.
 
 
 Mid level supplied functions
 ============================
 These functions are supplied by the SCSI mid level for use by LLDs.
-The names (i.e. entry points) of these functions are exported
-so a LLD that is a module can access them when the SCSI
-mid level is built into the kernel. The kernel will arrange for the
-SCSI mid level to be loaded and initialized before any LLD
+The names (i.e. entry points) of these functions are exported (in 
+scsi_syms.c) so a LLD that is a module can access them. The kernel will
+arrange for the SCSI mid level to be loaded and initialized before any LLD
 is initialized. The functions below are listed alphabetically and their
 names all start with "scsi_".
 
+Summary:
+   scsi_add_device - creates new scsi device (lu) instance
+   scsi_add_host - perform sysfs registration and SCSI bus scan.
+   scsi_add_timer - (re-)start timer on a SCSI command.
+   scsi_adjust_queue_depth - change the queue depth on a SCSI device
+   scsi_assign_lock - replace default host_lock with given lock
+   scsi_bios_ptable - return copy of block device's partition table
+   scsi_block_requests - prevent further commands being queued to given host
+   scsi_delete_timer - cancel timer on a SCSI command.
+   scsi_partsize - parse partition table into cylinders, heads + sectors
+   scsi_register - create and register a scsi host adapter instance.
+   scsi_register_host - register a low level host driver
+   scsi_remove_device - detach and remove a SCSI device
+   scsi_remove_host - detach and remove all SCSI devices owned by host
+   scsi_report_bus_reset - report scsi _bus_ reset observed
+   scsi_set_device - place device reference in host structure
+   scsi_set_device_offline - set device offline then flush its queue
+   scsi_to_pci_dma_dir - convert SCSI subsystem direction flag to PCI
+   scsi_to_sbus_dma_dir - convert SCSI subsystem direction flag to SBUS
+   scsi_track_queue_full - track successive QUEUE_FULL events 
+   scsi_unblock_requests - allow further commands to be queued to given host
+   scsi_unregister - unregister and free memory used by host instance
+   scsi_unregister_host - unregister a low level host adapter driver
+
+Details:
+
+/**
+ * scsi_add_device - creates new scsi device (lu) instance
+ * @shost:   pointer to scsi host instance
+ * @channel: channel number (rarely other than 0)
+ * @id:      target id number
+ * @lun:     logical unit number
+ *
+ *      Returns pointer to new struct scsi_device instance or 
+ *	ERR_PTR(-ENODEV) (or some other bent pointer) if something is
+ *	wrong (e.g. no lu responds at given address)
+ *
+ *	Notes: This call is usually performed internally during a scsi
+ *	bus scan when a HBA is added (i.e. scsi_add_host()). So it
+ *	should only be called if the HBA becomes aware of a new scsi
+ *	device (lu) after scsi_add_host() has completed. If successful
+ *	this call we lead to slave_alloc() and slave_configure() callbacks
+ *	into the LLD.
+ *
+ *	Defined in: drivers/scsi/scsi_scan.c
+ **/
+struct scsi_device * scsi_add_device(struct Scsi_Host *shost, 
+                                     unsigned int channel,
+                                     unsigned int id, unsigned int lun)
+
+
 /**
  * scsi_add_host - perform sysfs registration and SCSI bus scan.
  * @shost:   pointer to scsi host instance
- * @dev:     pointer to struct device host instance of class type scsi
- *           (or related)
+ * @dev:     pointer to struct device host instance
  *
  *      Returns 0 on success, negative errno of failure (e.g. -ENOMEM)
  *
  *	Notes: Only required in "hotplug initialization model" after a
  *	successful call to scsi_register().
- *	Defined in drivers/scsi/hosts.c
+ *
+ *	Defined in: drivers/scsi/hosts.c
  **/
 int scsi_add_host(struct Scsi_Host *shost, struct device * dev)
 
@@ -283,10 +364,12 @@
  *
  *      Returns nothing
  *
- *	Notes: All commands issued by upper levels already have a timeout
- *	associated with them. A LLD can use this function to change
+ *	Notes: Each scsi command has its own timer, and as it is added
+ *	to the queue, we set up the timer. When the command completes, 
+ *      we cancel the timer. A LLD can use this function to change
  *	the existing timeout value.
- *	Defined in drivers/scsi/scsi_error.c
+ *
+ *	Defined in: drivers/scsi/scsi_error.c
  **/
 void scsi_add_timer(Scsi_Cmnd *scmd, int timeout, void (*complete)
                     (Scsi_Cmnd *))
@@ -295,10 +378,10 @@
 /**
  * scsi_adjust_queue_depth - change the queue depth on a SCSI device
  * @SDpnt:	pointer to SCSI device to change queue depth on
- * @tagged:	0 - no tagged queueing
- *		MSG_SIMPLE_TAG - simple (unordered) tagged queueing
- *		MSG_ORDERED_TAG - ordered tagged queueing
- * @tags	Number of tags allowed if tagged queueing enabled,
+ * @tagged:	0 - no tagged queuing
+ *		MSG_SIMPLE_TAG - simple (unordered) tagged queuing
+ *		MSG_ORDERED_TAG - ordered tagged queuing
+ * @tags	Number of tags allowed if tagged queuing enabled,
  *		or number of commands the LLD can queue up
  *		in non-tagged mode (as per cmd_per_lun).
  *
@@ -309,7 +392,8 @@
  *	slave_destroy().] Can safely be invoked from interrupt code. Actual
  *	queue depth change may be delayed until the next command is being
  *	processed.
- *	Defined in drivers/scsi/scsi.c [see source code for more notes]
+ *
+ *	Defined in: drivers/scsi/scsi.c [see source code for more notes]
  *
  **/
 void scsi_adjust_queue_depth(struct scsi_device * SDpnt, int tagged, 
@@ -323,7 +407,7 @@
  *
  *      Returns nothing
  *
- *      Notes: Defined in drivers/scsi/hosts.h .
+ *      Defined in: drivers/scsi/hosts.h .
  **/
 void scsi_assign_lock(struct Scsi_Host *shost, spinlock_t *lock)
 
@@ -332,10 +416,11 @@
  * scsi_bios_ptable - return copy of block device's partition table
  * @dev:	pointer to block device
  *
- *	Returns pointer to partition table, or NULL or failure
+ *	Returns pointer to partition table, or NULL for failure
  *
  *	Notes: Caller owns memory returned (free with kfree() )
- *	Defined in drivers/scsi/scsicam.c
+ *
+ *	Defined in: drivers/scsi/scsicam.c
  **/
 unsigned char *scsi_bios_ptable(struct block_device *dev)
 
@@ -349,7 +434,8 @@
  *
  * 	Notes: There is no timer nor any other means by which the requests
  *	get unblocked other than the LLD calling scsi_unblock_requests().
- *	Defined in drivers/scsi/scsi_lib.c
+ *
+ *	Defined in: drivers/scsi/scsi_lib.c
 **/
 void scsi_block_requests(struct Scsi_Host * SHpnt)
 
@@ -364,7 +450,8 @@
  *	Notes: All commands issued by upper levels already have a timeout
  *	associated with them. A LLD can use this function to cancel the
  *	timer.
- *	Defined in drivers/scsi/scsi_error.c
+ *
+ *	Defined in: drivers/scsi/scsi_error.c
  **/
 int scsi_delete_timer(Scsi_Cmnd *scmd)
 
@@ -380,10 +467,11 @@
  *	Returns 0 on success, -1 on failure
  *
  *	Notes: Caller owns memory returned (free with kfree() )
- *	Defined in drivers/scsi/scsicam.c
+ *
+ *	Defined in: drivers/scsi/scsicam.c
  **/
 int scsi_partsize(unsigned char *buf, unsigned long capacity,
-               unsigned int *cyls, unsigned int *hds, unsigned int *secs)
+                  unsigned int *cyls, unsigned int *hds, unsigned int *secs)
 
 
 /**
@@ -398,7 +486,8 @@
  *	this host has _not_ yet been done.
  *	The hostdata array (by default zero length) is a per host scratch 
  *	area for the LLD.
- *	Defined in drivers/scsi/hosts.c .
+ *
+ *	Defined in: drivers/scsi/hosts.c .
  **/
 struct Scsi_Host * scsi_register(struct SHT *, int xtr_bytes)
 
@@ -415,12 +504,30 @@
  *	function by including the scsi_module.c file.
  *	This function is deprecated, use the "hotplug initialization
  *	model" instead.
- *	Defined in drivers/scsi/hosts.c .
+ *
+ *	Defined in: drivers/scsi/hosts.c .
  **/
 int scsi_register_host(Scsi_Host_Template *shost_tp)
 
 
 /**
+ * scsi_remove_device - detach and remove a SCSI device
+ * @sdev:      a pointer to a scsi device instance
+ *
+ *	Returns value: 0 on success, -EINVAL if device not attached
+ *
+ *      Notes: If a LLD becomes aware that a scsi device (lu) has
+ *	been removed but its host is still present then it can request
+ *	the removal of that scsi device. If successful this call will
+ *	lead to the slave_destroy() callback being invoked. sdev is an 
+ *	invalid pointer after this call.
+ *
+ *	Defined in: drivers/scsi/scsi_scan.c .
+ **/
+int scsi_remove_device(struct scsi_device *sdev)
+
+
+/**
  * scsi_remove_host - detach and remove all SCSI devices owned by host
  * @shost:      a pointer to a scsi host instance
  *
@@ -429,7 +536,8 @@
  *      Notes: Should only be invoked if the "hotplug initialization
  *	model" is being used. It should be called _prior_ to  
  *	scsi_unregister().
- *	Defined in drivers/scsi/hosts.c .
+ *
+ *	Defined in: drivers/scsi/hosts.c .
  **/
 int scsi_remove_host(struct Scsi_Host *shost)
 
@@ -446,7 +554,8 @@
  *	mid level itself don't need to call this, but there should be 
  *	no harm.  The main purpose of this is to make sure that a
  *	CHECK_CONDITION is properly treated.
- *	Defined in drivers/scsi/scsi_lib.c .
+ *
+ *	Defined in: drivers/scsi/scsi_lib.c .
  **/
 void scsi_report_bus_reset(struct Scsi_Host * shost, int channel)
 
@@ -458,12 +567,27 @@
  *
  *	Returns nothing
  *
- *      Notes: Defined in drivers/scsi/hosts.h .
+ *      Defined in: drivers/scsi/hosts.h .
  **/
 void scsi_set_device(struct Scsi_Host * shost, struct device * dev)
 
 
 /**
+ * scsi_set_device_offline - set device offline then flush its queue
+ * @sdev: a pointer to a scsi device instance to be set offline
+ *
+ *	Returns nothing
+ *
+ *      Notes: Commands that are currently active on the scsi device have 
+ *	       their timers cancelled and are transferred to the host's
+ *	       "eh" list for cancellation. 
+
+ *	Defined in: drivers/scsi/scsi.c .
+ **/
+void scsi_set_device_offline(struct scsi_device * sdev)
+
+
+/**
  * scsi_to_pci_dma_dir - convert SCSI subsystem direction flag to PCI
  * @scsi_data_direction: SCSI subsystem direction flag
  *
@@ -472,12 +596,26 @@
  *		PCI_DMA_BIDIRECTIONAL given SCSI_DATA_UNKNOWN
  *		else returns PCI_DMA_NONE
  *
- *      Notes: Defined in drivers/scsi/scsi.h .
+ *      Defined in: drivers/scsi/scsi.h .
  **/
 int scsi_to_pci_dma_dir(unsigned char scsi_data_direction)
 
 
 /**
+ * scsi_to_sbus_dma_dir - convert SCSI subsystem direction flag to SBUS
+ * @scsi_data_direction: SCSI subsystem direction flag
+ *
+ *	Returns SBUS_DMA_TODEVICE given SCSI_DATA_WRITE,
+ *		SBUS_DMA_FROMDEVICE given SCSI_DATA_READ
+ *		SBUS_DMA_BIDIRECTIONAL given SCSI_DATA_UNKNOWN
+ *		else returns SBUS_DMA_NONE
+ *
+ *      Defined in: drivers/scsi/scsi.h .
+ **/
+int scsi_to_sbus_dma_dir(unsigned char scsi_data_direction)
+
+
+/**
  * scsi_track_queue_full - track successive QUEUE_FULL events on given
  *			device to determine if and when there is a need
  *			to adjust the queue depth on the device.
@@ -492,7 +630,8 @@
  *
  *      Notes: LLDs may call this at any time and we will do "The Right
  *		Thing"; interrupt context safe. 
- *		Defined in drivers/scsi/scsi.c .
+ *
+ *	Defined in: drivers/scsi/scsi.c .
  **/
 int scsi_track_queue_full(Scsi_Device *SDptr, int depth)
 
@@ -504,22 +643,22 @@
  *
  *	Returns nothing
  *
- * 	Notes: Defined in drivers/scsi/scsi_lib.c .
+ * 	Defined in: drivers/scsi/scsi_lib.c .
 **/
 void scsi_unblock_requests(struct Scsi_Host * SHpnt)
 
 
 /**
- * scsi_unregister - unregister and free host
+ * scsi_unregister - unregister and free memory used by host instance
  * @shp:	pointer to scsi host instance to unregister.
- *		N.B. shp points to freed memory on return
  *
  *	Returns nothing
  *
  *      Notes: Should only be invoked if the "hotplug initialization
  *	model" is being used. It should be called _after_  
- *	scsi_remove_host().
- *	Defined in drivers/scsi/hosts.c .
+ *	scsi_remove_host(). The shp pointer is invalid after this call.
+ *
+ *	Defined in: drivers/scsi/hosts.c .
  **/
 void scsi_unregister(struct Scsi_Host * shp)
 
@@ -532,11 +671,13 @@
  *
  *      Notes: Should only be invoked if the "passive initialization
  *	model" is being used. Notice this is a _driver_ rather than 
- *	HBA deregistration function. Most older drivers call this
- *	function by including the scsi_module.c file.
- *	This function is deprecated, use the "hotplug initialization
+ *	HBA deregistration function. So if there are multiple HBAs
+ *	associated with the given template, they are each removed. Most 
+ *	older drivers call this function by including the scsi_module.c
+ *	file. This function is deprecated, use the "hotplug initialization
  *	model" instead.
- *	Defined in drivers/scsi/hosts.c .
+ *
+ *	Defined in: drivers/scsi/hosts.c .
  **/
 int scsi_unregister_host(Scsi_Host_Template *shost_tp)
 
@@ -567,6 +708,25 @@
 
 The interface functions are listed below in alphabetical order.
 
+Summary:
+   bios_param - fetch head, sector, cylinder info for a disk
+   command - send scsi command to device, wait for reply
+   detect - detects HBAs this driver wants to control
+   eh_abort_handler - abort given command
+   eh_bus_reset_handler - issue SCSI bus reset
+   eh_device_reset_handler - issue SCSI device reset
+   eh_host_reset_handler - reset host (host bus adapter)
+   eh_strategy_handler - driver supplied alternate to scsi_unjam_host()
+   info - supply information about given host
+   ioctl - driver can respond to ioctls
+   proc_info - supports /proc/scsi/{driver_name}/{host_no}
+   queuecommand - queue scsi command, invoke 'done' on completion
+   release - release all resources associated with given host
+   slave_alloc - prior to any commands being sent to a new device 
+   slave_configure - driver fine tuning for given device after attach
+   slave_destroy - given device is about to be shut down
+
+Details:
 
 /**
  *      bios_param - fetch head, sector, cylinder info for a disk
@@ -588,6 +748,8 @@
  *      if this function is not provided. The params array is
  *      pre-initialized with made up values just in case this function 
  *      doesn't output anything.
+ *
+ *	Defined in: LLD
  **/
     int bios_param(struct scsi_device * sdev, struct block_device *bdev,
     		   sector_t capacity, int params[3]);
@@ -609,6 +771,8 @@
  *
  *      Notes: Drivers tend to be dropping support for this function and
  *      supporting queuecommand() instead.
+ *
+ *	Defined in: LLD
  **/
     int command(struct scsi_cmnd * scp);
 
@@ -629,6 +793,8 @@
  *      driver. Upper level drivers (e.g. sd) may not (yet) be present.
  *      For each host found, this method should call scsi_register() 
  *      [see hosts.c].
+ *
+ *	Defined in: LLD
  **/
     int detect(struct SHT * shtp);
 
@@ -646,42 +812,48 @@
  *
  *      Notes: Invoked from scsi_eh thread. No other commands will be
  *      queued on current host during eh.
+ *
+ *	Defined in: LLD
  **/
      int eh_abort_handler(struct scsi_cmnd * scp);
 
 
 /**
- *      eh_device_reset_handler - issue SCSI device reset
- *      @scp: identifies SCSI device to be reset
+ *      eh_bus_reset_handler - issue SCSI bus reset
+ *      @scp: SCSI bus that contains this device should be reset
  *
  *      Returns SUCCESS if command aborted else FAILED
  *
  *      Required: no
  *
- *      Locks: struct Scsi_Host::host_lock held (with irqsave) on entry
+ *      Locks: struct Scsi_Host::host_lock held (with irqsave) on entry 
  *	and assumed to be held on return.
  *
  *      Notes: Invoked from scsi_eh thread. No other commands will be
  *      queued on current host during eh.
+ *
+ *	Defined in: LLD
  **/
-     int eh_device_reset_handler(struct scsi_cmnd * scp);
+     int eh_bus_reset_handler(struct scsi_cmnd * scp);
 
 
 /**
- *      eh_bus_reset_handler - issue SCSI bus reset
- *      @scp: SCSI bus that contains this device should be reset
+ *      eh_device_reset_handler - issue SCSI device reset
+ *      @scp: identifies SCSI device to be reset
  *
  *      Returns SUCCESS if command aborted else FAILED
  *
  *      Required: no
  *
- *      Locks: struct Scsi_Host::host_lock held (with irqsave) on entry 
+ *      Locks: struct Scsi_Host::host_lock held (with irqsave) on entry
  *	and assumed to be held on return.
  *
  *      Notes: Invoked from scsi_eh thread. No other commands will be
  *      queued on current host during eh.
+ *
+ *	Defined in: LLD
  **/
-     int eh_bus_reset_handler(struct scsi_cmnd * scp);
+     int eh_device_reset_handler(struct scsi_cmnd * scp);
 
 
 /**
@@ -701,6 +873,8 @@
  *      _device_reset_, _bus_reset_ or this eh handler function are 
  *      defined (or they all return FAILED) then the device in question 
  *      will be set offline whenever eh is invoked.
+ *
+ *	Defined in: LLD
  **/
      int eh_host_reset_handler(struct scsi_cmnd * scp);
 
@@ -717,6 +891,8 @@
  *
  *      Notes: Invoked from scsi_eh thread. Driver supplied alternate to 
  *      scsi_unjam_host() found in scsi_error.c
+ *
+ *	Defined in: LLD
  **/
      int eh_strategy_handler(struct Scsi_Host * shp);
 
@@ -745,6 +921,8 @@
  *      each host's "info" (or name) for the driver it is registering.
  *      Also if proc_info() is not supplied, the output of this function
  *      is used instead.
+ *
+ *	Defined in: LLD
  **/
     const char * info(struct Scsi_Host * shp);
 
@@ -776,6 +954,8 @@
  *      numbers when this function is not supplied by the driver.
  *      Unfortunately some applications expect -EINVAL and react badly
  *	when -ENOTTY is returned; stick with -EINVAL.
+ *
+ *	Defined in: LLD
  **/
     int ioctl(struct scsi_device *sdp, int cmd, void *arg);
 
@@ -803,6 +983,8 @@
  *      Locks: none held
  *
  *      Notes: Driven from scsi_proc.c which interfaces to proc_fs
+ *
+ *	Defined in: LLD
  **/
 int proc_info(char * buffer, char ** start, off_t offset, 
               int length, int hostno, int writeto1_read0);
@@ -840,6 +1022,8 @@
  *	'done' callback is invoked, then the LLD driver should 
  *	perform autosense and fill in the struct scsi_cmnd::sense_buffer
  *	array.
+ *
+ *	Defined in: LLD
  **/
     int queuecommand(struct scsi_cmnd * scp, 
 		     void (*done)(struct scsi_cmnd *));
@@ -849,16 +1033,20 @@
  *      release - release all resources associated with given host
  *      @shp: host to be released.
  *
- *      Return value ignored.
+ *      Return value ignored (could soon be a function returning void).
  *
- *      Required: no
+ *      Required: yes (see notes)
  *
- *      Locks: lock_kernel() active on entry and expected to be active
- *      on return.
+ *      Locks: none held
  *
  *      Notes: Invoked from mid level's scsi_unregister_host().
- *      This function should call scsi_unregister(shp) [found in hosts.c]
- *      prior to returning.
+ *      LLD's implementation of this function should call 
+ *	scsi_unregister(shp) prior to returning.
+ *	If not supplied mid-level [in hosts.c] supplies its own
+ *	implementation (see scsi_host_legacy_release()) which is for old
+ *	ISA adapters so it is best not to use it.
+ *
+ *	Defined in: LLD
  **/
     int release(struct Scsi_Host * shp);
 
@@ -882,12 +1070,14 @@
  *	slave_configure() will be called while if a device is not found
  *	slave_destroy() is called.
  *      For more details see the hosts.h file.
+ *
+ *	Defined in: LLD
  **/
     int slave_alloc(struct scsi_device *sdp);
 
 
 /**
- *      slave_configure - driver fine tuning for give device just after it
+ *      slave_configure - driver fine tuning for given device just after it
  *		       has been first scanned (i.e. it responded to an
  *		       INQUIRY)
  *      @sdp: device that has just been attached
@@ -908,6 +1098,8 @@
  *	value on behalf of the given device. If this function is
  *	supplied then its implementation must call
  *	scsi_adjust_queue_depth(). 	
+ *
+ *	Defined in: LLD
  **/
     int slave_configure(struct scsi_device *sdp);
 
@@ -930,6 +1122,8 @@
  *	could be re-attached in the future in which case a new instance
  *	of struct scsi_device would be supplied by future slave_alloc()
  *	and slave_configure() calls.]
+ *
+ *	Defined in: LLD
  **/
     void slave_destroy(struct scsi_device *sdp);
 
@@ -943,14 +1137,20 @@
 typically initialized as a file scope static in a driver's header file. That
 way members that are not explicitly initialized will be set to 0 or NULL.
 Member of interest:
-    name         - name of driver (should only use characters that are
-                   permitted in a unix file name)
-    proc_name    - name used in "/proc/scsi/<proc_name>/<host_no>"
+    name         - name of driver (may contain spaces, please limit to
+                   less than 80 characters)
+    proc_name    - name used in "/proc/scsi/<proc_name>/<host_no>" and
+                   by sysfs in one of its "drivers" directories. Hence
+                   "proc_name" should only contain characters acceptable
+                   to a Unix file name.
+   (*release)()  - should be defined by all LLDs as the default (legacy)
+                   implementation is only appropriate for ISA adapters).
 The structure is defined and commented in hosts.h
 
 *** In extreme situations a single driver may have several instances
     if it controls several different classes of hardware (e.g. the
-    advansys driver handles both ISA and PCI cards).
+    advansys driver handles both ISA and PCI cards and has a separate
+    instance of struct SHT for each).
 
 struct Scsi_Host
 ----------------
@@ -982,24 +1182,29 @@
                    0->use bounce buffers if data is in high memory
     hostt        - pointer to driver's struct SHT from which this
                    struct Scsi_Host instance was spawned
-    host_queue   - deceptively named pointer to the start of a double linked
-                   list of struct scsi_device instances that belong to this
-		   host.
+    sh_list      - a double linked list of pointers to all struct Scsi_Host
+                   instances (currently ordered by ascending host_no)
+    my_devices   - a double linked list of pointers to struct scsi_device 
+		   instances that belong to this host.
+    hostdata[0]  - area reserved for LLD at end of struct Scsi_Host. Size
+                   is set by the second argument (named 'xtr_bytes') to
+                   scsi_register().
 The structure is defined in hosts.h
 
 struct scsi_device
 ------------------
 Generally, there is one instance of this structure for each SCSI logical unit
 on a host. Scsi devices are uniquely identified within a host by bus number,
-target id and logical unit number (lun).
+cahnnel number, target id and logical unit number (lun).
 The structure is defined in scsi.h
 
 struct scsi_cmnd
 ----------------
-Instances of this structure convey SCSI commands to the LLD.
-Each SCSI device has a pool of struct scsi_cmnd instances whose size
-is determined by scsi_adjust_queue_depth() (or struct Scsi_Host::cmd_per_lun).
-There will be at least one instance of struct scsi_cmnd for each SCSI device.
+Instances of this structure convey SCSI commands to the LLD and responses
+back to the mid level. The SCSI mid level will ensure that no more SCSI 
+commands become queued against the LLD than are indicated by 
+scsi_adjust_queue_depth() (or struct Scsi_Host::cmd_per_lun). There will 
+be at least one instance of struct scsi_cmnd available for each SCSI device. 
 The structure is defined in scsi.h
 
 
@@ -1033,9 +1238,9 @@
 
 Either way, the mid level decides whether the LLD has 
 performed autosense by checking struct scsi_cmnd::sense_buffer[0] . If this
-byte has an upper nibble of 7 then autosense is assumed to have taken 
-place. If it has another value (and this byte is initialized to 0 before
-each command) then the mid level will issue a REQUEST SENSE command.
+byte has an upper nibble of 7 (or 0xf) then autosense is assumed to have 
+taken place. If it has another value (and this byte is initialized to 0
+before each command) then the mid level will issue a REQUEST SENSE command.
 
 In the presence of queued commands the "nexus" that maintains sense
 buffer data from the command that failed until a following REQUEST SENSE
@@ -1076,4 +1281,4 @@
 
 Douglas Gilbert
 dgilbert@interlog.com
-21st February 2003
+19th April 2003
diff -Nru a/MAINTAINERS b/MAINTAINERS
--- a/MAINTAINERS	Wed Apr 30 22:28:11 2003
+++ b/MAINTAINERS	Wed Apr 30 22:28:11 2003
@@ -505,6 +505,17 @@
 L:	linux-hams@vger.kernel.org
 S:	Maintained
 
+DC395x SCSI driver
+P:	Oliver Neukum
+M:	oliver@neukum.name
+P:	Ali Akcaagac
+M:	aliakc@web.de
+P:	Jamie Lenehan
+M:	lenehan@twibble.org
+W:	http://twibble.org/dist/dc395x/
+L:	http://lists.twibble.org/mailman/listinfo/dc395x/
+S:	Maintained
+
 DC390/AM53C974 SCSI driver
 P:	Kurt Garloff
 M:	garloff@suse.de
@@ -651,9 +662,11 @@
 S:	Maintained
 
 ETHERNET BRIDGE
+P:	Stephen Hemminger
+M:	shemminger@osdl.org
 L:	bridge@math.leidenuniv.nl
 W:	http://bridge.sourceforge.net/
-S:	Unmaintained
+S:	Maintained
 
 ETHERTEAM 16I DRIVER
 P:	Mika Kuoppala
@@ -928,6 +941,13 @@
 P:	Scott Feldman
 M:	scott.feldman@intel.com
 W:	http://sourceforge.net/projects/e1000/
+S:	Supported
+
+INTEL PRO/10GbE SUPPORT
+P:	Ganesh Venkatesan
+M:	Ganesh.Venkatesan@intel.com
+P:	Scott Feldman
+M:	scott.feldman@intel.com
 S:	Supported
 
 INTERMEZZO FILE SYSTEM
diff -Nru a/arch/alpha/Kconfig b/arch/alpha/Kconfig
--- a/arch/alpha/Kconfig	Wed Apr 30 22:28:14 2003
+++ b/arch/alpha/Kconfig	Wed Apr 30 22:28:14 2003
@@ -291,7 +291,7 @@
 	  VESA. If you have PCI, say Y, otherwise N.
 
 	  The PCI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, contains valuable
+	  <http://www.tldp.org/docs.html#howto>, contains valuable
 	  information about which PCI hardware does work under Linux and which
 	  doesn't.
 
@@ -514,7 +514,7 @@
 	  See also the <file:Documentation/smp.tex>,
 	  <file:Documentation/smp.txt>, <file:Documentation/i386/IO-APIC.txt>,
 	  <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you don't know what to do here, say N.
 
@@ -688,7 +688,7 @@
 	  want to say Y here.
 
 	  Information about ELF is contained in the ELF HOWTO available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you find that after upgrading from Linux kernel 1.2 and saying Y
 	  here, you still can't run any ELF binaries (they just crash), then
@@ -710,7 +710,7 @@
 	  programs that need an interpreter to run like Java, Python or
 	  Emacs-Lisp. It's also useful if you often run DOS executables under
 	  the Linux DOS emulator DOSEMU (read the DOSEMU-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>). Once you have
+	  <http://www.tldp.org/docs.html#howto>). Once you have
 	  registered such a binary class with the kernel, you can start one of
 	  those programs simply by typing in its name at a shell prompt; Linux
 	  will automatically feed it to the correct interpreter.
@@ -862,7 +862,7 @@
 	---help---
 	  If you have a CD-ROM drive that is neither SCSI nor IDE/ATAPI, say Y
 	  here, otherwise N. Read the CD-ROM-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  Note that the answer to this question doesn't directly affect the
 	  kernel: saying N will just cause the configurator to skip all
@@ -912,7 +912,7 @@
 	  interrupt and DMA channel), because you will be asked for it.
 
 	  You want to read the Sound-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. General information about
+	  <http://www.tldp.org/docs.html#howto>. General information about
 	  the modular sound system is contained in the files
 	  <file:Documentation/sound/Introduction>.  The file
 	  <file:Documentation/sound/README.OSS> contains some slightly
diff -Nru a/arch/alpha/kernel/core_irongate.c b/arch/alpha/kernel/core_irongate.c
--- a/arch/alpha/kernel/core_irongate.c	Wed Apr 30 22:28:12 2003
+++ b/arch/alpha/kernel/core_irongate.c	Wed Apr 30 22:28:12 2003
@@ -14,6 +14,7 @@
 #include <linux/pci.h>
 #include <linux/sched.h>
 #include <linux/init.h>
+#include <linux/initrd.h>
 
 #include <asm/ptrace.h>
 #include <asm/system.h>
diff -Nru a/arch/alpha/kernel/core_marvel.c b/arch/alpha/kernel/core_marvel.c
--- a/arch/alpha/kernel/core_marvel.c	Wed Apr 30 22:28:04 2003
+++ b/arch/alpha/kernel/core_marvel.c	Wed Apr 30 22:28:04 2003
@@ -452,7 +452,6 @@
 
 	/* With multiple PCI busses, we play with I/O as physical addrs.  */
 	ioport_resource.end = ~0UL;
-	iomem_resource.end = ~0UL;
 
 	/* PCI DMA Direct Mapping is 1GB at 2GB.  */
 	__direct_map_base = 0x80000000;
diff -Nru a/arch/alpha/kernel/core_mcpcia.c b/arch/alpha/kernel/core_mcpcia.c
--- a/arch/alpha/kernel/core_mcpcia.c	Wed Apr 30 22:28:11 2003
+++ b/arch/alpha/kernel/core_mcpcia.c	Wed Apr 30 22:28:11 2003
@@ -407,7 +407,6 @@
 {
 	/* With multiple PCI busses, we play with I/O as physical addrs.  */
 	ioport_resource.end = ~0UL;
-	iomem_resource.end = ~0UL;
 
 	/* Allocate hose 0.  That's the one that all the ISA junk hangs
 	   off of, from which we'll be registering stuff here in a bit.
diff -Nru a/arch/alpha/kernel/core_titan.c b/arch/alpha/kernel/core_titan.c
--- a/arch/alpha/kernel/core_titan.c	Wed Apr 30 22:28:06 2003
+++ b/arch/alpha/kernel/core_titan.c	Wed Apr 30 22:28:06 2003
@@ -412,7 +412,6 @@
 
 	/* With multiple PCI busses, we play with I/O as physical addrs.  */
 	ioport_resource.end = ~0UL;
-	iomem_resource.end = ~0UL;
 
 	/* PCI DMA Direct Mapping is 1GB at 2GB.  */
 	__direct_map_base = 0x80000000;
diff -Nru a/arch/alpha/kernel/core_tsunami.c b/arch/alpha/kernel/core_tsunami.c
--- a/arch/alpha/kernel/core_tsunami.c	Wed Apr 30 22:28:07 2003
+++ b/arch/alpha/kernel/core_tsunami.c	Wed Apr 30 22:28:07 2003
@@ -390,7 +390,6 @@
 #endif
 	/* With multiple PCI busses, we play with I/O as physical addrs.  */
 	ioport_resource.end = ~0UL;
-	iomem_resource.end = ~0UL;
 
 	/* Find how many hoses we have, and initialize them.  TSUNAMI
 	   and TYPHOON can have 2, but might only have 1 (DS10).  */
diff -Nru a/arch/alpha/kernel/core_wildfire.c b/arch/alpha/kernel/core_wildfire.c
--- a/arch/alpha/kernel/core_wildfire.c	Wed Apr 30 22:28:03 2003
+++ b/arch/alpha/kernel/core_wildfire.c	Wed Apr 30 22:28:03 2003
@@ -309,7 +309,6 @@
 
 	/* With multiple PCI buses, we play with I/O as physical addrs.  */
 	ioport_resource.end = ~0UL;
-	iomem_resource.end = ~0UL;
 
 
 	/* Probe the hardware for info about configuration. */
diff -Nru a/arch/alpha/kernel/irq.c b/arch/alpha/kernel/irq.c
--- a/arch/alpha/kernel/irq.c	Wed Apr 30 22:28:15 2003
+++ b/arch/alpha/kernel/irq.c	Wed Apr 30 22:28:15 2003
@@ -45,7 +45,10 @@
  * Special irq handlers.
  */
 
-void no_action(int cpl, void *dev_id, struct pt_regs *regs) { }
+irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs)
+{
+	return IRQ_NONE;
+}
 
 /*
  * Generic no controller code
@@ -414,7 +417,7 @@
 }
 
 int
-request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
+request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_regs *),
 	    unsigned long irqflags, const char * devname, void *dev_id)
 {
 	int retval;
diff -Nru a/arch/alpha/kernel/proto.h b/arch/alpha/kernel/proto.h
--- a/arch/alpha/kernel/proto.h	Wed Apr 30 22:28:05 2003
+++ b/arch/alpha/kernel/proto.h	Wed Apr 30 22:28:05 2003
@@ -1,4 +1,5 @@
 #include <linux/config.h>
+#include <linux/interrupt.h>
 
 
 /* Prototypes of functions used across modules here in this directory.  */
@@ -128,7 +129,7 @@
 /* extern void reset_for_srm(void); */
 
 /* time.c */
-extern void timer_interrupt(int irq, void *dev, struct pt_regs * regs);
+extern irqreturn_t timer_interrupt(int irq, void *dev, struct pt_regs * regs);
 extern void common_init_rtc(void);
 extern unsigned long est_cycle_freq;
 
diff -Nru a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c
--- a/arch/alpha/kernel/setup.c	Wed Apr 30 22:28:05 2003
+++ b/arch/alpha/kernel/setup.c	Wed Apr 30 22:28:05 2003
@@ -32,11 +32,7 @@
 #include <linux/pci.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
-
-#ifdef CONFIG_BLK_DEV_INITRD
-#include <linux/blk.h>
-#endif
-
+#include <linux/initrd.h>
 #ifdef CONFIG_MAGIC_SYSRQ
 #include <linux/sysrq.h>
 #include <linux/reboot.h>
diff -Nru a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c
--- a/arch/alpha/kernel/srmcons.c	Wed Apr 30 22:28:16 2003
+++ b/arch/alpha/kernel/srmcons.c	Wed Apr 30 22:28:16 2003
@@ -318,11 +318,11 @@
 	spin_unlock_irqrestore(&srmcons_callback_lock, flags);
 }
 
-static kdev_t
-srm_console_device(struct console *co)
+static struct tty_driver *
+srm_console_device(struct console *co, int *index)
 {
-	return mk_kdev(srmcons_driver.major,
-		       srmcons_driver.minor_start + co->index);
+	*index = co->index;
+	return &srmcons_driver;
 }
 
 static int __init
diff -Nru a/arch/alpha/kernel/time.c b/arch/alpha/kernel/time.c
--- a/arch/alpha/kernel/time.c	Wed Apr 30 22:28:09 2003
+++ b/arch/alpha/kernel/time.c	Wed Apr 30 22:28:09 2003
@@ -94,7 +94,7 @@
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "do_timer()" routine every clocktick
  */
-void timer_interrupt(int irq, void *dev, struct pt_regs * regs)
+irqreturn_t timer_interrupt(int irq, void *dev, struct pt_regs * regs)
 {
 	unsigned long delta;
 	__u32 now;
@@ -139,6 +139,7 @@
 	}
 
 	write_sequnlock(&xtime_lock);
+	return IRQ_HANDLED;
 }
 
 void
diff -Nru a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
--- a/arch/alpha/mm/init.c	Wed Apr 30 22:28:16 2003
+++ b/arch/alpha/mm/init.c	Wed Apr 30 22:28:16 2003
@@ -66,19 +66,9 @@
 pte_t *
 pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
 {
-	pte_t *pte;
-	long timeout = 10;
-
- retry:
-	pte = (pte_t *) __get_free_page(GFP_KERNEL);
+	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (pte)
 		clear_page(pte);
-	else if (--timeout >= 0) {
-		current->state = TASK_UNINTERRUPTIBLE;
-		schedule_timeout(HZ);
-		goto retry;
-	}
-
 	return pte;
 }
 
diff -Nru a/arch/alpha/mm/numa.c b/arch/alpha/mm/numa.c
--- a/arch/alpha/mm/numa.c	Wed Apr 30 22:28:03 2003
+++ b/arch/alpha/mm/numa.c	Wed Apr 30 22:28:03 2003
@@ -12,9 +12,7 @@
 #include <linux/mm.h>
 #include <linux/bootmem.h>
 #include <linux/swap.h>
-#ifdef CONFIG_BLK_DEV_INITRD
-#include <linux/blk.h>
-#endif
+#include <linux/initrd.h>
 
 #include <asm/hwrpb.h>
 #include <asm/pgalloc.h>
diff -Nru a/arch/arm/Kconfig b/arch/arm/Kconfig
--- a/arch/arm/Kconfig	Wed Apr 30 22:28:10 2003
+++ b/arch/arm/Kconfig	Wed Apr 30 22:28:10 2003
@@ -445,7 +445,7 @@
 	  VESA. If you have PCI, say Y, otherwise N.
 
 	  The PCI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, contains valuable
+	  <http://www.tldp.org/docs.html#howto>, contains valuable
 	  information about which PCI hardware does work under Linux and which
 	  doesn't.
 
@@ -459,7 +459,7 @@
 	  VESA. If you have PCI, say Y, otherwise N.
 
 	  The PCI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, contains valuable
+	  <http://www.tldp.org/docs.html#howto>, contains valuable
 	  information about which PCI hardware does work under Linux and which
 	  doesn't.
 
@@ -613,23 +613,30 @@
 comment "At least one math emulation must be selected"
 
 config FPE_NWFPE
-	tristate "NWFPE math emulation"
+	bool "NWFPE math emulation"
 	---help---
 	  Say Y to include the NWFPE floating point emulator in the kernel.
 	  This is necessary to run most binaries. Linux does not currently
 	  support floating point hardware so you need to say Y here even if
 	  your machine has an FPA or floating point co-processor podule.
 
-	  It is also possible to say M to build the emulator as a module
-	  (nwfpe) or indeed to leave it out altogether. However, unless you
-	  know what you are doing this can easily render your machine
-	  unbootable. Saying Y is the safe option.
-
 	  You may say N here if you are going to load the Acorn FPEmulator
 	  early in the bootup.
 
+config FPE_NWFPE_XP
+	bool "Support extended precision"
+	depends on FPE_NWFPE
+	help
+	  Say Y to include 80-bit support in the kernel floating-point
+	  emulator.  Otherwise, only 32 and 64-bit support is compiled in.
+	  Note that gcc does not generate 80-bit operations by default,
+	  so in most cases this option only enlarges the size of the
+	  floating point emulator without any good reason.
+
+	  You almost surely want to say N here.
+
 config FPE_FASTFPE
-	tristate "FastFPE math emulation (EXPERIMENTAL)"
+	bool "FastFPE math emulation (EXPERIMENTAL)"
 	depends on !CPU_26 && !CPU_32v3 && EXPERIMENTAL
 	---help---
 	  Say Y here to include the FAST floating point emulator in the kernel.
@@ -642,11 +649,6 @@
 	  If you do not feel you need a faster FP emulation you should better
 	  choose NWFPE.
 
-	  It is also possible to say M to build the emulator as a module
-	  (fastfpe).  But keep in mind that you should only load the FP
-	  emulator early in the bootup.  You should never change from NWFPE to
-	  FASTFPE or vice versa in an active system!
-
 choice
 	prompt "Kernel core (/proc/kcore) format"
 	default KCORE_ELF
@@ -717,7 +719,7 @@
 	  want to say Y here.
 
 	  Information about ELF is contained in the ELF HOWTO available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you find that after upgrading from Linux kernel 1.2 and saying Y
 	  here, you still can't run any ELF binaries (they just crash), then
@@ -739,7 +741,7 @@
 	  programs that need an interpreter to run like Java, Python or
 	  Emacs-Lisp. It's also useful if you often run DOS executables under
 	  the Linux DOS emulator DOSEMU (read the DOSEMU-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>). Once you have
+	  <http://www.tldp.org/docs.html#howto>). Once you have
 	  registered such a binary class with the kernel, you can start one of
 	  those programs simply by typing in its name at a shell prompt; Linux
 	  will automatically feed it to the correct interpreter.
@@ -770,7 +772,7 @@
 	  page on the WWW at
 	  <http://www.cs.utexas.edu/users/kharker/linux-laptop/> and the
 	  Battery Powered Linux mini-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  Note that, even if you say N here, Linux on the x86 architecture
 	  will issue the hlt instruction if nothing is to be done, thereby
@@ -809,7 +811,7 @@
 	  In order to use APM, you will need supporting software. For location
 	  and more information, read <file:Documentation/pm.txt> and the
 	  Battery Powered Linux mini-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver does not spin down disk drives (see the hdparm(8)
 	  manpage ("man 8 hdparm") for that), and it doesn't turn off
@@ -1063,7 +1065,7 @@
 	  interrupt and DMA channel), because you will be asked for it.
 
 	  You want to read the Sound-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. General information about
+	  <http://www.tldp.org/docs.html#howto>. General information about
 	  the modular sound system is contained in the files
 	  <file:Documentation/sound/Introduction>.  The file
 	  <file:Documentation/sound/README.OSS> contains some slightly
diff -Nru a/arch/arm/Makefile b/arch/arm/Makefile
--- a/arch/arm/Makefile	Wed Apr 30 22:28:07 2003
+++ b/arch/arm/Makefile	Wed Apr 30 22:28:07 2003
@@ -31,13 +31,15 @@
 apcs-$(CONFIG_CPU_26)		:=-mapcs-26 -mcpu=arm3
 
 # 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-$(CONFIG_CPU_32v3)		:=-D__LINUX_ARM_ARCH__=3 -march=armv3
+# Note that GCC does not numerically define an architecture version
+# macro, but instead defines a whole series of macros which makes
+# testing for a specific architecture or later rather impossible.
+#
+# Note - GCC does accept -march=armv5te, but someone messed up the assembler or the
+# gcc specs file - this needs fixing properly - ie in gcc and/or binutils.
+arch-$(CONFIG_CPU_32v5)		:=-D__LINUX_ARM_ARCH__=5 -march=armv5t
 arch-$(CONFIG_CPU_32v4)		:=-D__LINUX_ARM_ARCH__=4 -march=armv4
-arch-$(CONFIG_CPU_32v5)		:=-D__LINUX_ARM_ARCH__=5 -march=armv5te
-arch-$(CONFIG_CPU_XSCALE)	:=-D__LINUX_ARM_ARCH__=5 -march=armv4 -Wa,-mxscale #-march=armv5te
+arch-$(CONFIG_CPU_32v3)		:=-D__LINUX_ARM_ARCH__=3 -march=armv3
 
 # This selects how we optimise for the processor.
 tune-$(CONFIG_CPU_ARM610)	:=-mtune=arm610
@@ -48,13 +50,13 @@
 tune-$(CONFIG_CPU_ARM926T)	:=-mtune=arm9tdmi
 tune-$(CONFIG_CPU_SA110)	:=-mtune=strongarm110
 tune-$(CONFIG_CPU_SA1100)	:=-mtune=strongarm1100
-tune-$(CONFIG_CPU_XSCALE)	:=-mtune=strongarm #-mtune=xscale
+tune-$(CONFIG_CPU_XSCALE)	:=-mtune=strongarm -Wa,-mxscale #-mtune=xscale
 
 # Force -mno-fpu to be passed to the assembler.  Some versions of gcc don't
 # do this with -msoft-float
 CFLAGS_BOOT	:=$(apcs-y) $(arch-y) $(tune-y) -mshort-load-bytes -msoft-float -Wa,-mno-fpu -Uarm
 CFLAGS		+=$(apcs-y) $(arch-y) $(tune-y) -mshort-load-bytes -msoft-float -Wa,-mno-fpu -Uarm
-AFLAGS		+=$(apcs-y) $(arch-y) -mno-fpu -msoft-float -Wa,-mno-fpu
+AFLAGS		+=$(apcs-y) $(arch-y) $(tune-y) -mno-fpu -msoft-float -Wa,-mno-fpu
 
 #Default value
 DATAADDR	:= .
@@ -208,6 +210,7 @@
 	)
 
 arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \
+				   include/asm-arm/.arch include/asm-arm/.proc \
 				   include/config/MARKER
 
 include/asm-$(ARCH)/constants.h: arch/$(ARCH)/kernel/asm-offsets.s
diff -Nru a/arch/arm/boot/compressed/head-sa1100.S b/arch/arm/boot/compressed/head-sa1100.S
--- a/arch/arm/boot/compressed/head-sa1100.S	Wed Apr 30 22:28:04 2003
+++ b/arch/arm/boot/compressed/head-sa1100.S	Wed Apr 30 22:28:04 2003
@@ -50,6 +50,10 @@
 10:
 #endif
 
+		mrc	p15, 0, r0, c1, c0, 0	@ read control reg
+		ands	r0, r0, #0x0d
+		beq	99f
+
 		@ Data cache might be active.
 		@ Be sure to flush kernel binary out of the cache,
 		@ whatever state it is, before it is turned off.
@@ -68,11 +72,4 @@
 		bic	r0, r0, #0x0d		@ clear WB, DC, MMU
 		bic	r0, r0, #0x1000		@ clear Icache
 		mcr	p15, 0, r0, c1, c0, 0
-
-/*
- * Pause for a short time so that we give enough time
- * for the host to start a terminal up.
- */
-		mov	r0, #0x00200000
-1:		subs	r0, r0, #1
-		bne	1b
+99:
diff -Nru a/arch/arm/boot/compressed/head-xscale.S b/arch/arm/boot/compressed/head-xscale.S
--- a/arch/arm/boot/compressed/head-xscale.S	Wed Apr 30 22:28:06 2003
+++ b/arch/arm/boot/compressed/head-xscale.S	Wed Apr 30 22:28:06 2003
@@ -35,7 +35,7 @@
 		mcr	p15, 0, r0, c1, c0, 0
 
 #ifdef	CONFIG_ARCH_IQ80321
-		orr	pc, pc, #0xa0000000
+		orr	pc, pc, #PHYS_OFFSET	@ jump to physical memory if we are not there.
 		nop
 		mov	r7, #MACH_TYPE_IQ80321
 #endif
diff -Nru a/arch/arm/def-configs/shark b/arch/arm/def-configs/shark
--- a/arch/arm/def-configs/shark	Wed Apr 30 22:28:11 2003
+++ b/arch/arm/def-configs/shark	Wed Apr 30 22:28:11 2003
@@ -2,14 +2,9 @@
 # Automatically generated make config: don't edit
 #
 CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
+CONFIG_MMU=y
 CONFIG_UID16=y
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
-# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
-# CONFIG_GENERIC_BUST_SPINLOCK is not set
-# CONFIG_GENERIC_ISA_DMA is not set
 
 #
 # Code maturity level options
@@ -19,15 +14,19 @@
 #
 # General setup
 #
-CONFIG_NET=y
+CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
+CONFIG_LOG_BUF_SHIFT=14
 
 #
 # Loadable module support
 #
 CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
 CONFIG_KMOD=y
 
@@ -58,112 +57,41 @@
 #
 # Archimedes/A5000 Implementations (select only ONE)
 #
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
 
 #
-# Footbridge Implementations
+# CLPS711X/EP721X Implementations
 #
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
 
 #
-# SA11x0 Implementations
+# Epxa10db
 #
-# CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_ADSBITSY is not set
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_H3100 is not set
-# CONFIG_SA1100_H3600 is not set
-# CONFIG_SA1100_H3800 is not set
-# CONFIG_SA1100_H3XXX is not set
-# CONFIG_SA1100_EXTENEX1 is not set
-# CONFIG_SA1100_FLEXANET is not set
-# CONFIG_SA1100_FREEBIRD is not set
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_GRAPHICSMASTER is not set
-# CONFIG_SA1100_BADGE4 is not set
-# CONFIG_SA1100_JORNADA720 is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_ITSY is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_OMNIMETER is not set
-# CONFIG_SA1100_PANGOLIN is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_PT_SYSTEM3 is not set
-# CONFIG_SA1100_SHANNON is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_SIMPAD is not set
-# CONFIG_SA1100_PFS168 is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
-# CONFIG_SA1100_STORK is not set
-# CONFIG_SA1100_USB is not set
-# CONFIG_SA1100_USB_NETLINK is not set
-# CONFIG_SA1100_USB_CHAR is not set
-# CONFIG_H3600_SLEEVE is not set
 
 #
-# Intel PXA250/210 Implementations
+# Footbridge Implementations
 #
-# CONFIG_ARCH_LUBBOCK is not set
-# CONFIG_ARCH_PXA_IDP is not set
 
 #
-# CLPS711X/EP721X Implementations
+# IOP310 Implementation Options
 #
-# CONFIG_ARCH_AUTCPU12 is not set
-# CONFIG_ARCH_CDB89712 is not set
-# CONFIG_ARCH_CLEP7312 is not set
-# CONFIG_ARCH_EDB7211 is not set
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_FORTUNET is not set
-# CONFIG_ARCH_EP7211 is not set
-# CONFIG_ARCH_EP7212 is not set
 
 #
-# IOP310 Implementation Options
+# IOP310 Chipset Features
 #
-# CONFIG_ARCH_IQ80310 is not set
 
 #
-# IOP310 Chipset Features
+# Intel PXA250/210 Implementations
+#
+
+#
+# SA11x0 Implementations
 #
-# CONFIG_IOP310_AAU is not set
-# CONFIG_IOP310_DMA is not set
-# CONFIG_IOP310_MU is not set
-# CONFIG_IOP310_PMON is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
 
 #
 # Processor Type
 #
-# CONFIG_CPU_32v3 is not set
-CONFIG_CPU_32v4=y
-# CONFIG_CPU_32v5 is not set
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
-# CONFIG_CPU_ARM720T is not set
-# CONFIG_CPU_ARM920T is not set
-# CONFIG_CPU_ARM922T is not set
-# CONFIG_CPU_ARM926T is not set
-# CONFIG_CPU_ARM1020 is not set
+CONFIG_CPU_32=y
 CONFIG_CPU_SA110=y
-# CONFIG_CPU_SA1100 is not set
-# CONFIG_CPU_XSCALE is not set
-# CONFIG_XSCALE_PMU is not set
+CONFIG_CPU_32v4=y
 
 #
 # Processor Features
@@ -172,19 +100,16 @@
 #
 # General setup
 #
-# CONFIG_DISCONTIGMEM is not set
 CONFIG_PCI=y
-# CONFIG_PCI_HOST_PLX90X0 is not set
 CONFIG_PCI_HOST_VIA82C505=y
 CONFIG_ISA=y
 CONFIG_ISA_DMA=y
-# CONFIG_FIQ is not set
 # CONFIG_ZBOOT_ROM is not set
-CONFIG_ZBOOT_ROM_TEXT=0
-CONFIG_ZBOOT_ROM_BSS=0
+CONFIG_ZBOOT_ROM_TEXT=0x0
+CONFIG_ZBOOT_ROM_BSS=0x0
+CONFIG_PCI_LEGACY_PROC=y
 # CONFIG_PCI_NAMES is not set
 # CONFIG_HOTPLUG is not set
-# CONFIG_PCMCIA is not set
 
 #
 # At least one math emulation must be selected
@@ -198,7 +123,6 @@
 # CONFIG_BINFMT_MISC is not set
 # CONFIG_PM is not set
 # CONFIG_PREEMPT is not set
-# CONFIG_APM is not set
 # CONFIG_ARTHUR is not set
 CONFIG_CMDLINE=""
 CONFIG_LEDS=y
@@ -216,11 +140,6 @@
 # CONFIG_PARPORT_PC_FIFO is not set
 # CONFIG_PARPORT_PC_SUPERIO is not set
 # CONFIG_PARPORT_ARC is not set
-# CONFIG_PARPORT_AMIGA is not set
-# CONFIG_PARPORT_MFC3 is not set
-# CONFIG_PARPORT_ATARI is not set
-# CONFIG_PARPORT_GSC is not set
-# CONFIG_PARPORT_SUNBPP is not set
 # CONFIG_PARPORT_OTHER is not set
 # CONFIG_PARPORT_1284 is not set
 
@@ -230,11 +149,9 @@
 # CONFIG_MTD is not set
 
 #
-# Plug and Play configuration
+# Plug and Play support
 #
 # CONFIG_PNP is not set
-# CONFIG_ISAPNP is not set
-# CONFIG_PNPBIOS is not set
 
 #
 # Block devices
@@ -244,7 +161,6 @@
 # CONFIG_PARIDE is not set
 # CONFIG_BLK_CPQ_DA is not set
 # CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_CISS_SCSI_TAPE is not set
 # CONFIG_BLK_DEV_DAC960 is not set
 # CONFIG_BLK_DEV_UMEM is not set
 CONFIG_BLK_DEV_LOOP=y
@@ -257,13 +173,11 @@
 # Multi-device support (RAID and LVM)
 #
 # CONFIG_MD is not set
-# CONFIG_BLK_DEV_MD is not set
-# CONFIG_MD_LINEAR is not set
-# CONFIG_MD_RAID0 is not set
-# CONFIG_MD_RAID1 is not set
-# CONFIG_MD_RAID5 is not set
-# CONFIG_MD_MULTIPATH is not set
-# CONFIG_BLK_DEV_LVM is not set
+
+#
+# Networking support
+#
+CONFIG_NET=y
 
 #
 # Networking options
@@ -272,8 +186,8 @@
 # CONFIG_PACKET_MMAP is not set
 # CONFIG_NETLINK_DEV is not set
 # CONFIG_NETFILTER is not set
-CONFIG_FILTER=y
 CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
 CONFIG_INET=y
 # CONFIG_IP_MULTICAST is not set
 # CONFIG_IP_ADVANCED_ROUTER is not set
@@ -283,25 +197,23 @@
 # CONFIG_ARPD is not set
 # CONFIG_INET_ECN is not set
 # CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
 # CONFIG_IPV6 is not set
-# CONFIG_ATM is not set
-# CONFIG_VLAN_8021Q is not set
-
-#
-#  
-#
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
+# CONFIG_XFRM_USER is not set
 
 #
-# Appletalk devices
+# SCTP Configuration (EXPERIMENTAL)
 #
-# CONFIG_DEV_APPLETALK is not set
+CONFIG_IPV6_SCTP__=y
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_LLC is not set
 # CONFIG_DECNET is not set
 # CONFIG_BRIDGE is not set
 # CONFIG_X25 is not set
 # CONFIG_LAPB is not set
-# CONFIG_LLC is not set
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
@@ -314,8 +226,9 @@
 # CONFIG_NET_SCHED is not set
 
 #
-# Network device support
+# Network testing
 #
+# CONFIG_NET_PKTGEN is not set
 CONFIG_NETDEVICES=y
 
 #
@@ -332,47 +245,43 @@
 # Ethernet (10 or 100Mbit)
 #
 CONFIG_NET_ETHERNET=y
-# CONFIG_ARM_AM79C961A is not set
-# CONFIG_SUNLANCE is not set
+# CONFIG_MII is not set
 # CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNBMAC is not set
-# CONFIG_SUNQE is not set
 # CONFIG_SUNGEM is not set
 # CONFIG_NET_VENDOR_3COM is not set
 # CONFIG_LANCE is not set
 # CONFIG_NET_VENDOR_SMC is not set
 # CONFIG_NET_VENDOR_RACAL is not set
+
+#
+# Tulip family network device support
+#
+# CONFIG_NET_TULIP is not set
 # CONFIG_AT1700 is not set
 # CONFIG_DEPCA is not set
 # CONFIG_HP100 is not set
 # CONFIG_NET_ISA is not set
 CONFIG_NET_PCI=y
 # CONFIG_PCNET32 is not set
+# CONFIG_AMD8111_ETH is not set
 # CONFIG_ADAPTEC_STARFIRE is not set
 # CONFIG_AC3200 is not set
 # CONFIG_APRICOT is not set
+# CONFIG_B44 is not set
 CONFIG_CS89x0=y
 # CONFIG_DGRS is not set
 # CONFIG_EEPRO100 is not set
 # CONFIG_E100 is not set
-# CONFIG_LNE390 is not set
 # CONFIG_FEALNX is not set
 # CONFIG_NATSEMI is not set
 # CONFIG_NE2K_PCI is not set
-# CONFIG_NE3210 is not set
-# CONFIG_ES3210 is not set
 # CONFIG_8139CP is not set
 # CONFIG_8139TOO is not set
-# CONFIG_8139TOO_PIO is not set
-# CONFIG_8139TOO_TUNE_TWISTER is not set
-# CONFIG_8139TOO_8129 is not set
-# CONFIG_8139_NEW_RX_RESET is not set
 # CONFIG_SIS900 is not set
 # CONFIG_EPIC100 is not set
 # CONFIG_SUNDANCE is not set
 # CONFIG_TLAN is not set
 # CONFIG_VIA_RHINE is not set
-# CONFIG_VIA_RHINE_MMIO is not set
 # CONFIG_NET_POCKET is not set
 
 #
@@ -381,10 +290,10 @@
 # CONFIG_ACENIC is not set
 # CONFIG_DL2K is not set
 # CONFIG_E1000 is not set
-# CONFIG_MYRI_SBUS is not set
 # CONFIG_NS83820 is not set
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
+# CONFIG_R8169 is not set
 # CONFIG_SK98LIN is not set
 # CONFIG_TIGON3 is not set
 # CONFIG_FDDI is not set
@@ -399,9 +308,8 @@
 # CONFIG_NET_RADIO is not set
 
 #
-# Token Ring devices
+# Token Ring devices (depends on LLC=y)
 #
-# CONFIG_TR is not set
 # CONFIG_NET_FC is not set
 # CONFIG_RCPCI is not set
 # CONFIG_SHAPER is not set
@@ -412,9 +320,9 @@
 # CONFIG_WAN is not set
 
 #
-# Tulip family network device support
+# IrDA (infrared) support
 #
-# CONFIG_NET_TULIP is not set
+# CONFIG_IRDA is not set
 
 #
 # Amateur Radio support
@@ -422,75 +330,32 @@
 # CONFIG_HAMRADIO is not set
 
 #
-# IrDA (infrared) support
+# ATA/ATAPI/MFM/RLL support
 #
-# CONFIG_IRDA is not set
+CONFIG_IDE=y
 
 #
-# ATA/ATAPI/MFM/RLL support
+# IDE, ATA and ATAPI Block devices
 #
-CONFIG_IDE=y
 CONFIG_BLK_DEV_IDE=y
-# CONFIG_BLK_DEV_HD_IDE is not set
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
 # CONFIG_IDEDISK_STROKE is not set
-CONFIG_ATAPI=y
 CONFIG_BLK_DEV_IDECD=y
-# CONFIG_BLK_DEV_IDETAPE is not set
 CONFIG_BLK_DEV_IDEFLOPPY=y
 # CONFIG_BLK_DEV_IDESCSI is not set
-# CONFIG_BLK_DEV_IDECS is not set
+# CONFIG_IDE_TASK_IOCTL is not set
 
 #
-# ATA host controller support
+# IDE chipset support/bugfixes
 #
-# CONFIG_BLK_DEV_RZ1000 is not set
-# CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
-# CONFIG_BLK_DEV_ISAPNP is not set
-
-#
-#   PCI host controller support
-#
-# CONFIG_BLK_DEV_OFFBOARD is not set
-# CONFIG_IDEPCI_SHARE_IRQ is not set
-# CONFIG_BLK_DEV_IDEDMA_PCI is not set
-# CONFIG_IDEDMA_PCI_AUTO is not set
-# CONFIG_IDEDMA_ONLYDISK is not set
-# CONFIG_BLK_DEV_IDEDMA is not set
-# CONFIG_BLK_DEV_IDE_TCQ is not set
-# CONFIG_BLK_DEV_IDE_TCQ_DEFAULT is not set
-# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
-# CONFIG_BLK_DEV_AEC62XX is not set
-# CONFIG_AEC6280_BURST is not set
-# CONFIG_BLK_DEV_ALI15X3 is not set
-# CONFIG_WDC_ALI15X3 is not set
-# CONFIG_BLK_DEV_AMD74XX is not set
-# CONFIG_BLK_DEV_CMD64X is not set
-# CONFIG_BLK_DEV_CY82C693 is not set
-# CONFIG_BLK_DEV_CS5530 is not set
-# CONFIG_BLK_DEV_HPT34X is not set
-# CONFIG_HPT34X_AUTODMA is not set
-# CONFIG_BLK_DEV_HPT366 is not set
-# CONFIG_BLK_DEV_PIIX is not set
-# CONFIG_BLK_DEV_NS87415 is not set
-# CONFIG_BLK_DEV_OPTI621 is not set
-# CONFIG_BLK_DEV_PDC202XX is not set
-# CONFIG_PDC202XX_BURST is not set
-# CONFIG_PDC202XX_FORCE is not set
-# CONFIG_BLK_DEV_SVWKS is not set
-# CONFIG_BLK_DEV_SIS5513 is not set
-# CONFIG_BLK_DEV_TRM290 is not set
-# CONFIG_BLK_DEV_VIA82CXXX is not set
-# CONFIG_BLK_DEV_SL82C105 is not set
+# CONFIG_BLK_DEV_IDEPCI is not set
 # CONFIG_IDE_CHIPSETS is not set
-# CONFIG_IDEDMA_IVB is not set
-# CONFIG_IDEDMA_AUTO 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
 
 #
 # SCSI support
@@ -501,12 +366,10 @@
 # SCSI support type (disk, tape, CD-ROM)
 #
 CONFIG_BLK_DEV_SD=m
-CONFIG_SD_EXTRA_DEVS=40
 CONFIG_CHR_DEV_ST=m
 # CONFIG_CHR_DEV_OSST is not set
 CONFIG_BLK_DEV_SR=m
 # CONFIG_BLK_DEV_SR_VENDOR is not set
-CONFIG_SR_EXTRA_DEVS=2
 CONFIG_CHR_DEV_SG=m
 
 #
@@ -525,8 +388,10 @@
 # CONFIG_SCSI_ACARD is not set
 # CONFIG_SCSI_AHA152X is not set
 # CONFIG_SCSI_AHA1542 is not set
+# CONFIG_SCSI_AACRAID is not set
 # CONFIG_SCSI_AIC7XXX is not set
 # CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_AIC79XX is not set
 # CONFIG_SCSI_DPT_I2O is not set
 # CONFIG_SCSI_ADVANSYS is not set
 # CONFIG_SCSI_IN2000 is not set
@@ -537,11 +402,11 @@
 # CONFIG_SCSI_DMX3191D is not set
 # CONFIG_SCSI_DTC3280 is not set
 # CONFIG_SCSI_EATA is not set
-# CONFIG_SCSI_EATA_DMA is not set
 # CONFIG_SCSI_EATA_PIO is not set
 # CONFIG_SCSI_FUTURE_DOMAIN is not set
 # CONFIG_SCSI_GDTH is not set
 # CONFIG_SCSI_GENERIC_NCR5380 is not set
+# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
 # CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 # CONFIG_SCSI_PPA is not set
@@ -559,11 +424,11 @@
 # CONFIG_SCSI_QLOGIC_ISP is not set
 # CONFIG_SCSI_QLOGIC_FC is not set
 # CONFIG_SCSI_QLOGIC_1280 is not set
-# CONFIG_SCSI_SIM710 is not set
 # CONFIG_SCSI_SYM53C416 is not set
 # CONFIG_SCSI_DC390T is not set
 # CONFIG_SCSI_T128 is not set
 # CONFIG_SCSI_U14_34F is not set
+# CONFIG_SCSI_NSP32 is not set
 # CONFIG_SCSI_DEBUG is not set
 
 #
@@ -575,11 +440,6 @@
 # I2O device support
 #
 # CONFIG_I2O is not set
-# CONFIG_I2O_PCI is not set
-# CONFIG_I2O_BLOCK is not set
-# CONFIG_I2O_LAN is not set
-# CONFIG_I2O_SCSI is not set
-# CONFIG_I2O_PROC is not set
 
 #
 # ISDN subsystem
@@ -589,47 +449,55 @@
 #
 # Input device support
 #
-# CONFIG_INPUT is not set
+CONFIG_INPUT=y
 
 #
 # Userland interfaces
 #
-# CONFIG_INPUT_KEYBDEV is not set
-# CONFIG_INPUT_MOUSEDEV is not set
-# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
 # CONFIG_INPUT_JOYDEV is not set
 # CONFIG_INPUT_TSDEV is not set
 # CONFIG_INPUT_TSLIBDEV is not set
 # CONFIG_INPUT_EVDEV is not set
 # CONFIG_INPUT_EVBUG is not set
-# CONFIG_INPUT_UINPUT is not set
 
 #
 # Input I/O drivers
 #
 # CONFIG_GAMEPORT is not set
 CONFIG_SOUND_GAMEPORT=y
-# CONFIG_GAMEPORT_NS558 is not set
-# CONFIG_GAMEPORT_L4 is not set
-# CONFIG_GAMEPORT_EMU10K1 is not set
-# CONFIG_GAMEPORT_VORTEX is not set
-# CONFIG_GAMEPORT_FM801 is not set
-# CONFIG_GAMEPORT_CS461x is not set
-# CONFIG_SERIO is not set
-# CONFIG_SERIO_I8042 is not set
+CONFIG_SERIO=y
+CONFIG_SERIO_I8042=y
 # CONFIG_SERIO_SERPORT is not set
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PARKBD is not set
+# CONFIG_SERIO_PCIPS2 is not set
 
 #
 # Input Device Drivers
 #
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+# CONFIG_MOUSE_SERIAL is not set
+# CONFIG_MOUSE_INPORT is not set
+# CONFIG_MOUSE_LOGIBM is not set
+# CONFIG_MOUSE_PC110PAD is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
 
 #
 # Character devices
 #
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
+# CONFIG_VT is not set
 # CONFIG_SERIAL_NONSTANDARD is not set
 
 #
@@ -637,33 +505,12 @@
 #
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_CS is not set
 # CONFIG_SERIAL_8250_EXTENDED is not set
-# CONFIG_SERIAL_8250_MANY_PORTS is not set
-# CONFIG_SERIAL_8250_SHARE_IRQ is not set
-# CONFIG_SERIAL_8250_DETECT_IRQ is not set
-# CONFIG_SERIAL_8250_MULTIPORT is not set
-# CONFIG_SERIAL_8250_RSA is not set
 
 #
 # Non-8250 serial port support
 #
-# CONFIG_ATOMWIDE_SERIAL is not set
-# CONFIG_DUALSP_SERIAL is not set
-# CONFIG_SERIAL_ANAKIN is not set
-# CONFIG_SERIAL_ANAKIN_CONSOLE is not set
-# CONFIG_SERIAL_AMBA is not set
-# CONFIG_SERIAL_AMBA_CONSOLE is not set
-# CONFIG_SERIAL_CLPS711X is not set
-# CONFIG_SERIAL_CLPS711X_CONSOLE is not set
-# CONFIG_SERIAL_CLPS711X_OLD_NAME is not set
-# CONFIG_SERIAL_21285 is not set
-# CONFIG_SERIAL_21285_OLD is not set
-# CONFIG_SERIAL_21285_CONSOLE is not set
-# CONFIG_SERIAL_UART00 is not set
-# CONFIG_SERIAL_UART00_CONSOLE is not set
-# CONFIG_SERIAL_SA1100 is not set
-# CONFIG_SERIAL_SA1100_CONSOLE is not set
+# CONFIG_SERIAL_DZ is not set
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 CONFIG_UNIX98_PTYS=y
@@ -671,6 +518,7 @@
 CONFIG_PRINTER=m
 # CONFIG_LP_CONSOLE is not set
 # CONFIG_PPDEV is not set
+# CONFIG_TIPAR is not set
 
 #
 # I2C support
@@ -678,26 +526,30 @@
 # CONFIG_I2C is not set
 
 #
-# L3 serial bus support
+# I2C Hardware Sensors Mainboard support
 #
-# CONFIG_L3 is not set
-# CONFIG_L3_ALGOBIT is not set
-# CONFIG_L3_BIT_SA1100_GPIO is not set
 
 #
-# Other L3 adapters
+# I2C Hardware Sensors Chip support
 #
-# CONFIG_L3_SA1111 is not set
-# CONFIG_BIT_SA1100_GPIO is not set
+
+#
+# L3 serial bus support
+#
+# CONFIG_L3 is not set
 
 #
 # Mice
 #
 # CONFIG_BUSMOUSE is not set
-CONFIG_PSMOUSE=y
 # CONFIG_QIC02_TAPE is not set
 
 #
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
 # Watchdog Cards
 #
 # CONFIG_WATCHDOG is not set
@@ -714,6 +566,7 @@
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
+# CONFIG_HANGCHECK_TIMER is not set
 
 #
 # Multimedia devices
@@ -723,84 +576,83 @@
 #
 # File systems
 #
-# CONFIG_QUOTA is not set
-# CONFIG_QFMT_V1 is not set
-# CONFIG_QFMT_V2 is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_REISERFS_CHECK is not set
-# CONFIG_REISERFS_PROC_INFO is not set
-# CONFIG_ADFS_FS is not set
-# CONFIG_ADFS_FS_RW is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_BFS_FS is not set
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
 CONFIG_EXT3_FS=y
+CONFIG_EXT3_FS_XATTR=y
+# CONFIG_EXT3_FS_POSIX_ACL is not set
 CONFIG_JBD=y
 # CONFIG_JBD_DEBUG is not set
-CONFIG_FAT_FS=y
-CONFIG_MSDOS_FS=y
-# CONFIG_UMSDOS_FS is not set
-CONFIG_VFAT_FS=y
-# CONFIG_EFS_FS is not set
-# CONFIG_JFFS_FS is not set
-# CONFIG_JFFS2_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_TMPFS is not set
-CONFIG_RAMFS=y
+CONFIG_FS_MBCACHE=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
 CONFIG_ISO9660_FS=y
 CONFIG_JOLIET=y
 # CONFIG_ZISOFS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_JFS_DEBUG is not set
-# CONFIG_JFS_STATISTICS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_VXFS_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
 # CONFIG_NTFS_FS is not set
-# CONFIG_NTFS_DEBUG is not set
-# CONFIG_NTFS_RW is not set
-# CONFIG_HPFS_FS is not set
+
+#
+# Pseudo filesystems
+#
 CONFIG_PROC_FS=y
 CONFIG_DEVFS_FS=y
 CONFIG_DEVFS_MOUNT=y
 # CONFIG_DEVFS_DEBUG is not set
 # CONFIG_DEVPTS_FS is not set
+# CONFIG_TMPFS is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
 # CONFIG_QNX4FS_FS is not set
-# CONFIG_QNX4FS_RW is not set
-# CONFIG_ROMFS_FS is not set
-CONFIG_EXT2_FS=y
 # CONFIG_SYSV_FS is not set
-# CONFIG_UDF_FS is not set
-# CONFIG_UDF_RW is not set
 # CONFIG_UFS_FS is not set
-# CONFIG_UFS_FS_WRITE is not set
 
 #
 # Network File Systems
 #
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
 CONFIG_NFS_FS=y
 # CONFIG_NFS_V3 is not set
-# CONFIG_ROOT_NFS is not set
+# CONFIG_NFS_V4 is not set
 # CONFIG_NFSD is not set
-# CONFIG_NFSD_V3 is not set
-# CONFIG_NFSD_TCP is not set
-CONFIG_SUNRPC=y
 CONFIG_LOCKD=y
 # CONFIG_EXPORTFS is not set
+CONFIG_SUNRPC=y
+# CONFIG_SUNRPC_GSS is not set
 # CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
-# CONFIG_NCPFS_PACKET_SIGNING is not set
-# CONFIG_NCPFS_IOCTL_LOCKING is not set
-# CONFIG_NCPFS_STRONG is not set
-# CONFIG_NCPFS_NFS_NS is not set
-# CONFIG_NCPFS_OS2_NS is not set
-# CONFIG_NCPFS_SMALLDOS is not set
-# CONFIG_NCPFS_NLS is not set
-# CONFIG_NCPFS_EXTRAS is not set
-# CONFIG_ZISOFS_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
+# CONFIG_AFS_FS is not set
 
 #
 # Partition Types
@@ -817,11 +669,11 @@
 # CONFIG_SOLARIS_X86_PARTITION is not set
 # CONFIG_UNIXWARE_DISKLABEL is not set
 # CONFIG_LDM_PARTITION is not set
+# CONFIG_NEC98_PARTITION is not set
 # CONFIG_SGI_PARTITION is not set
 # CONFIG_ULTRIX_PARTITION is not set
 # CONFIG_SUN_PARTITION is not set
 # CONFIG_EFI_PARTITION is not set
-# CONFIG_SMB_NLS is not set
 CONFIG_NLS=y
 
 #
@@ -867,28 +719,18 @@
 # CONFIG_NLS_UTF8 is not set
 
 #
-# Console drivers
-#
-# CONFIG_VGA_CONSOLE is not set
-
-#
-# Frame-buffer support
+# Graphics support
 #
 CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_CLGEN is not set
+# CONFIG_FB_CIRRUS is not set
 # CONFIG_FB_PM2 is not set
-# CONFIG_FB_PM3 is not set
-# CONFIG_FB_ACORN is not set
-# CONFIG_FB_ANAKIN is not set
-# CONFIG_FB_CLPS711X is not set
-# CONFIG_FB_SA1100 is not set
 CONFIG_FB_CYBER2000=y
+# CONFIG_FB_IMSTT is not set
 # CONFIG_FB_RIVA is not set
 # CONFIG_FB_MATROX is not set
-# CONFIG_FB_ATY is not set
 # CONFIG_FB_RADEON is not set
 # CONFIG_FB_ATY128 is not set
+# CONFIG_FB_ATY is not set
 # CONFIG_FB_SIS is not set
 # CONFIG_FB_NEOMAGIC is not set
 # CONFIG_FB_3DFX is not set
@@ -896,14 +738,11 @@
 # CONFIG_FB_TRIDENT is not set
 # CONFIG_FB_PM3 is not set
 # CONFIG_FB_VIRTUAL is not set
-# CONFIG_FBCON_ADVANCED is not set
-CONFIG_FBCON_CFB8=y
-CONFIG_FBCON_CFB16=y
-CONFIG_FBCON_CFB24=y
-# CONFIG_FBCON_FONTWIDTH8_ONLY is not set
-# CONFIG_FBCON_FONTS is not set
-CONFIG_FONT_8x8=y
-CONFIG_FONT_8x16=y
+
+#
+# Logo configuration
+#
+# CONFIG_LOGO is not set
 
 #
 # Sound
@@ -911,13 +750,17 @@
 CONFIG_SOUND=m
 
 #
+# Advanced Linux Sound Architecture
+#
+# CONFIG_SND is not set
+
+#
 # Open Sound System
 #
 CONFIG_SOUND_PRIME=m
 # CONFIG_SOUND_BT878 is not set
 # CONFIG_SOUND_CMPCI is not set
 # CONFIG_SOUND_EMU10K1 is not set
-# CONFIG_MIDI_EMU10K1 is not set
 # CONFIG_SOUND_FUSION is not set
 # CONFIG_SOUND_CS4281 is not set
 # CONFIG_SOUND_ES1370 is not set
@@ -932,7 +775,6 @@
 # CONFIG_SOUND_MSNDCLAS is not set
 # CONFIG_SOUND_MSNDPIN is not set
 # CONFIG_SOUND_VIA82CXXX is not set
-# CONFIG_MIDI_VIA82CXXX is not set
 CONFIG_SOUND_OSS=m
 # CONFIG_SOUND_TRACEINIT is not set
 # CONFIG_SOUND_DMAP is not set
@@ -950,7 +792,6 @@
 # CONFIG_SOUND_NM256 is not set
 # CONFIG_SOUND_MAD16 is not set
 # CONFIG_SOUND_PAS is not set
-# CONFIG_PAS_JOYSTICK is not set
 # CONFIG_SOUND_PSS is not set
 CONFIG_SOUND_SB=m
 # CONFIG_SOUND_AWE32_SYNTH is not set
@@ -960,32 +801,22 @@
 # CONFIG_SOUND_OPL3SA1 is not set
 # CONFIG_SOUND_OPL3SA2 is not set
 # CONFIG_SOUND_YMFPCI is not set
-# CONFIG_SOUND_YMFPCI_LEGACY is not set
 # CONFIG_SOUND_UART6850 is not set
 # CONFIG_SOUND_AEDSP16 is not set
-# CONFIG_SOUND_WAVEARTIST is not set
-# CONFIG_SOUND_TVMIXER is not set
 
 #
-# Advanced Linux Sound Architecture
+# Misc devices
 #
-# CONFIG_SND is not set
 
 #
 # Multimedia Capabilities Port drivers
 #
 # CONFIG_MCP is not set
-# CONFIG_MCP_SA1100 is not set
-# CONFIG_MCP_UCB1200 is not set
-# CONFIG_MCP_UCB1200_AUDIO is not set
-# CONFIG_MCP_UCB1200_TS is not set
 
 #
 # Console Switches
 #
 # CONFIG_SWITCHES is not set
-# CONFIG_SWITCHES_SA1100 is not set
-# CONFIG_SWITCHES_UCB1X00 is not set
 
 #
 # USB support
@@ -1004,24 +835,18 @@
 CONFIG_DEBUG_USER=y
 # CONFIG_DEBUG_INFO is not set
 # CONFIG_DEBUG_KERNEL is not set
-# CONFIG_DEBUG_SLAB is not set
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_WAITQ is not set
-# CONFIG_DEBUG_BUGVERBOSE is not set
-# CONFIG_DEBUG_ERRORS is not set
-# CONFIG_DEBUG_LL is not set
-# CONFIG_DEBUG_DC21285_PORT is not set
-# CONFIG_DEBUG_CLPS711X_UART2 is not set
 
 #
 # Security options
 #
-CONFIG_SECURITY_CAPABILITIES=y
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
 
 #
 # Library routines
 #
 CONFIG_CRC32=y
-# CONFIG_ZLIB_INFLATE is not set
-# CONFIG_ZLIB_DEFLATE is not set
diff -Nru a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
--- a/arch/arm/kernel/entry-armv.S	Wed Apr 30 22:28:07 2003
+++ b/arch/arm/kernel/entry-armv.S	Wed Apr 30 22:28:07 2003
@@ -1093,8 +1093,10 @@
 		@
 		@ now branch to the relevant MODE handling routine
 		@
-		mov	r13, #PSR_I_BIT | MODE_SVC
-		msr	spsr_c, r13			@ switch to SVC_32 mode
+		mrs	r13, cpsr
+		bic	r13, r13, #MODE_MASK
+		orr	r13, r13, #MODE_SVC
+		msr	spsr, r13			@ switch to SVC_32 mode
 
 		and	lr, lr, #15
 		ldr	lr, [pc, lr, lsl #2]
@@ -1135,8 +1137,10 @@
 		@
 		@ now branch to the relevant MODE handling routine
 		@
-		mov	r13, #PSR_I_BIT | MODE_SVC
-		msr	spsr_c, r13			@ switch to SVC_32 mode
+		mrs	r13, cpsr
+		bic	r13, r13, #MODE_MASK
+		orr	r13, r13, #MODE_SVC
+		msr	spsr, r13			@ switch to SVC_32 mode
 
 		ands	lr, lr, #15
 		ldr	lr, [pc, lr, lsl #2]
@@ -1176,8 +1180,10 @@
 		@
 		@ now branch to the relevant MODE handling routine
 		@
-		mov	r13, #PSR_I_BIT | MODE_SVC
-		msr	spsr_c, r13			@ switch to SVC_32 mode
+		mrs	r13, cpsr
+		bic	r13, r13, #MODE_MASK
+		orr	r13, r13, #MODE_SVC
+		msr	spsr, r13			@ switch to SVC_32 mode
 
 		and	lr, lr, #15
 		ldr	lr, [pc, lr, lsl #2]
diff -Nru a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
--- a/arch/arm/kernel/process.c	Wed Apr 30 22:28:16 2003
+++ b/arch/arm/kernel/process.c	Wed Apr 30 22:28:16 2003
@@ -2,7 +2,7 @@
  *  linux/arch/arm/kernel/process.c
  *
  *  Copyright (C) 1996-2000 Russell King - Converted to ARM.
- *  Origional Copyright (C) 1995  Linus Torvalds
+ *  Original Copyright (C) 1995  Linus Torvalds
  *
  * 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
@@ -418,7 +418,7 @@
 	if (!p || p == current || p->state == TASK_RUNNING)
 		return 0;
 
-	stack_page = 4096 + (unsigned long)p;
+	stack_page = 4096 + (unsigned long)p->thread_info;
 	fp = thread_saved_fp(p);
 	do {
 		if (fp < stack_page || fp > 4092+stack_page)
diff -Nru a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
--- a/arch/arm/kernel/setup.c	Wed Apr 30 22:28:10 2003
+++ b/arch/arm/kernel/setup.c	Wed Apr 30 22:28:10 2003
@@ -13,7 +13,7 @@
 #include <linux/ioport.h>
 #include <linux/delay.h>
 #include <linux/utsname.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/bootmem.h>
 #include <linux/seq_file.h>
@@ -74,6 +74,9 @@
 #ifdef MULTI_USER
 struct cpu_user_fns cpu_user;
 #endif
+#ifdef MULTI_CACHE
+struct cpu_cache_fns cpu_cache;
+#endif
 
 unsigned char aux_device_present;
 char elf_platform[ELF_PLATFORM_SIZE];
@@ -282,6 +285,9 @@
 #ifdef MULTI_USER
 	cpu_user = *list->user;
 #endif
+#ifdef MULTI_CACHE
+	cpu_cache = *list->cache;
+#endif
 
 	printk("CPU: %s [%08x] revision %d (ARMv%s)\n",
 	       cpu_name, processor_id, (int)processor_id & 15,
@@ -323,58 +329,77 @@
 	return list;
 }
 
+static void __init early_initrd(char **p)
+{
+	unsigned long start, size;
+
+	start = memparse(*p, p);
+	if (**p == ',') {
+		size = memparse((*p) + 1, p);
+
+		phys_initrd_start = start;
+		phys_initrd_size = size;
+	}
+}
+__early_param("initrd=", early_initrd);
+
 /*
- * Initial parsing of the command line.  We need to pick out the
- * memory size.  We look for mem=size@start, where start and size
- * are "size[KkMm]"
+ * Pick out the memory size.  We look for mem=size@start,
+ * where start and size are "size[KkMm]"
  */
-static void __init
-parse_cmdline(struct meminfo *mi, char **cmdline_p, char *from)
+static void __init early_mem(char **p)
 {
-	char c = ' ', *to = command_line;
-	int usermem = 0, len = 0;
-
-	for (;;) {
-		if (c == ' ' && !memcmp(from, "mem=", 4)) {
-			unsigned long size, start;
+	static int usermem __initdata = 0;
+	unsigned long size, start;
 
-			if (to != command_line)
-				to -= 1;
+	/*
+	 * If the user specifies memory size, we
+	 * blow away any automatically generated
+	 * size.
+	 */
+	if (usermem == 0) {
+		usermem = 1;
+		meminfo.nr_banks = 0;
+	}
 
-			/*
-			 * If the user specifies memory size, we
-			 * blow away any automatically generated
-			 * size.
-			 */
-			if (usermem == 0) {
-				usermem = 1;
-				mi->nr_banks = 0;
-			}
+	start = PHYS_OFFSET;
+	size  = memparse(*p, p);
+	if (**p == '@')
+		start = memparse(*p + 1, p);
+
+	meminfo.bank[meminfo.nr_banks].start = start;
+	meminfo.bank[meminfo.nr_banks].size  = size;
+	meminfo.bank[meminfo.nr_banks].node  = PHYS_TO_NID(start);
+	meminfo.nr_banks += 1;
+}
+__early_param("mem=", early_mem);
 
-			start = PHYS_OFFSET;
-			size  = memparse(from + 4, &from);
-			if (*from == '@')
-				start = memparse(from + 1, &from);
-
-			mi->bank[mi->nr_banks].start = start;
-			mi->bank[mi->nr_banks].size  = size;
-			mi->bank[mi->nr_banks].node  = PHYS_TO_NID(start);
-			mi->nr_banks += 1;
-		} else if (c == ' ' && !memcmp(from, "initrd=", 7)) {
-			unsigned long start, size;
-
-			/*
-			 * Remove space character
-			 */
-			if (to != command_line)
-				to -= 1;
-
-			start = memparse(from + 7, &from);
-			if (*from == ',') {
-				size = memparse(from + 1, &from);
+/*
+ * Initial parsing of the command line.
+ */
+static void __init parse_cmdline(char **cmdline_p, char *from)
+{
+	char c = ' ', *to = command_line;
+	int len = 0;
 
-				phys_initrd_start = start;
-				phys_initrd_size = size;
+	for (;;) {
+		if (c == ' ') {
+			extern struct early_params __early_begin, __early_end;
+			struct early_params *p;
+
+			for (p = &__early_begin; p < &__early_end; p++) {
+				int len = strlen(p->arg);
+
+				if (memcmp(from, p->arg, len) == 0) {
+					if (to != command_line)
+						to -= 1;
+					from += len;
+					p->fn(&from);
+
+					while (*from != ' ' && *from != '\0')
+						from++;
+					break;
+				}
 			}
 		}
 		c = *from++;
@@ -536,6 +561,8 @@
 
 static int __init parse_tag_initrd(const struct tag *tag)
 {
+	printk(KERN_WARNING "ATAG_INITRD is deprecated; "
+		"please update your bootloader.\n");
 	phys_initrd_start = __virt_to_phys(tag->u.initrd.start);
 	phys_initrd_size = tag->u.initrd.size;
 	return 0;
@@ -668,7 +695,7 @@
 
 	memcpy(saved_command_line, from, COMMAND_LINE_SIZE);
 	saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
-	parse_cmdline(&meminfo, cmdline_p, from);
+	parse_cmdline(cmdline_p, from);
 	bootmem_init(&meminfo);
 	paging_init(&meminfo, mdesc);
 	request_standard_resources(&meminfo, mdesc);
diff -Nru a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
--- a/arch/arm/kernel/signal.c	Wed Apr 30 22:28:03 2003
+++ b/arch/arm/kernel/signal.c	Wed Apr 30 22:28:03 2003
@@ -362,8 +362,8 @@
 		 * Ensure that the instruction cache sees
 		 * the return code written onto the stack.
 		 */
-		cpu_icache_invalidate_range((unsigned long)rc,
-					    (unsigned long)(rc + 1));
+		flush_icache_range((unsigned long)rc,
+				   (unsigned long)(rc + 1));
 
 		retcode = ((unsigned long)rc) + thumb;
 	}
@@ -569,6 +569,9 @@
 				put_user(0xef000000 | __NR_restart_syscall, &usp[1]);
 				/* ldr	pc, [sp], #12 */
 				put_user(0xe49df00c, &usp[2]);
+
+				flush_icache_range((unsigned long)usp,
+						   (unsigned long)(usp + 3));
 
 				regs->ARM_pc = regs->ARM_sp + 4;
 			}
diff -Nru a/arch/arm/mach-clps711x/fortunet.c b/arch/arm/mach-clps711x/fortunet.c
--- a/arch/arm/mach-clps711x/fortunet.c	Wed Apr 30 22:28:11 2003
+++ b/arch/arm/mach-clps711x/fortunet.c	Wed Apr 30 22:28:11 2003
@@ -22,7 +22,7 @@
 #include <linux/config.h>
 #include <linux/types.h>
 #include <linux/init.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 
 #include <asm/hardware.h>
 #include <asm/irq.h>
diff -Nru a/arch/arm/mach-integrator/cpu.c b/arch/arm/mach-integrator/cpu.c
--- a/arch/arm/mach-integrator/cpu.c	Wed Apr 30 22:28:09 2003
+++ b/arch/arm/mach-integrator/cpu.c	Wed Apr 30 22:28:09 2003
@@ -12,6 +12,7 @@
  * CPU support functions
  */
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/cpufreq.h>
@@ -173,9 +174,9 @@
 	return 0;
 }
 
-static int integrator_cpufreq_init(struct cpufreq *policy)
+static int integrator_cpufreq_init(struct cpufreq_policy *policy)
 {
-	unsigned long cus_allowed;
+	unsigned long cpus_allowed;
 	unsigned int cpu = policy->cpu;
 	u_int cm_osc, cm_stat, mem_freq_khz;
 	struct vco vco;
diff -Nru a/arch/arm/mach-integrator/irq.c b/arch/arm/mach-integrator/irq.c
--- a/arch/arm/mach-integrator/irq.c	Wed Apr 30 22:28:20 2003
+++ b/arch/arm/mach-integrator/irq.c	Wed Apr 30 22:28:20 2003
@@ -18,6 +18,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include <linux/init.h>
+#include <linux/list.h>
 
 #include <asm/hardware.h>
 #include <asm/irq.h>
diff -Nru a/arch/arm/mach-iop3xx/iop321-pci.c b/arch/arm/mach-iop3xx/iop321-pci.c
--- a/arch/arm/mach-iop3xx/iop321-pci.c	Wed Apr 30 22:28:15 2003
+++ b/arch/arm/mach-iop3xx/iop321-pci.c	Wed Apr 30 22:28:15 2003
@@ -212,13 +212,13 @@
 
 	switch (nr) {
 	case 0:
-		res[0].start = IOP321_PCI_LOWER_IO + 0x6e000000;
-		res[0].end   = IOP321_PCI_LOWER_IO + 0x6e00ffff;
+		res[0].start = IOP321_PCI_IO_BASE + 0x6e000000;
+		res[0].end   = IOP321_PCI_IO_BASE + IOP321_PCI_IO_SIZE-1 + 0x6e000000;
 		res[0].name  = "PCI IO Primary";
 		res[0].flags = IORESOURCE_IO;
 
-		res[1].start = IOP321_PCI_LOWER_MEM;
-		res[1].end   = IOP321_PCI_LOWER_MEM + IOP321_PCI_WINDOW_SIZE;
+		res[1].start = IOP321_PCI_MEM_BASE;
+		res[1].end   = IOP321_PCI_MEM_BASE + IOP321_PCI_MEM_SIZE;
 		res[1].name  = "PCI Memory Primary";
 		res[1].flags = IORESOURCE_MEM;
 		break;
diff -Nru a/arch/arm/mach-iop3xx/iq80310-time.c b/arch/arm/mach-iop3xx/iq80310-time.c
--- a/arch/arm/mach-iop3xx/iq80310-time.c	Wed Apr 30 22:28:13 2003
+++ b/arch/arm/mach-iop3xx/iq80310-time.c	Wed Apr 30 22:28:13 2003
@@ -101,7 +101,7 @@
 	 *
 	 * Since the timer interrupt is cascaded through the CPLD and
 	 * the 80312 and the demux code calls do_IRQ, the irq count is
-	 * going to be atleast 2 when we get here and this will cause the
+	 * going to be at least 2 when we get here and this will cause the
 	 * kernel to increment the system tick counter even if we're
 	 * idle. This causes it to look like there's always 100% system
 	 * time, which is not the case.  To get around it, we just decrement
diff -Nru a/arch/arm/mach-iop3xx/mm-321.c b/arch/arm/mach-iop3xx/mm-321.c
--- a/arch/arm/mach-iop3xx/mm-321.c	Wed Apr 30 22:28:09 2003
+++ b/arch/arm/mach-iop3xx/mm-321.c	Wed Apr 30 22:28:09 2003
@@ -1,7 +1,7 @@
 /*
  * linux/arch/arm/mach-iop3xx/mm.c
  *
- * Low level memory intialization for IOP321 based systems
+ * Low level memory initialization for IOP321 based systems
  *
  * Author: Rory Bolt <rorybolt@pacbell.net>
  * Copyright (C) 2002 Rory Bolt
@@ -31,7 +31,7 @@
  /* virtual     physical      length      type */
 
  /* mem mapped registers */
- { 0xfff00000,  0xffffe000,   0x00002000,  MT_DEVICE },
+ { IOP321_VIRT_MEM_BASE,  IOP321_PHY_MEM_BASE,   0x00002000,  MT_DEVICE },
 
  /* PCI IO space */
  { 0xfe000000,  0x90000000,   0x00020000,  MT_DEVICE }
@@ -52,7 +52,7 @@
  /* virtual     physical      length        type */
 
  /* on-board devices */
- { 0xfe800000,  0xfe800000,   0x00100000,   MT_DEVICE }
+ { 0xfe800000,  IQ80321_UART1,   0x00100000,   MT_DEVICE }
 };
 
 void __init iq80321_map_io(void)
diff -Nru a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c
--- a/arch/arm/mach-pxa/generic.c	Wed Apr 30 22:28:06 2003
+++ b/arch/arm/mach-pxa/generic.c	Wed Apr 30 22:28:06 2003
@@ -13,7 +13,7 @@
  *
  * Since this file should be linked before any other machine specific file,
  * the __initcall() here will be executed first.  This serves as default
- * initialization stuff for PXA machines which can be overriden later if
+ * initialization stuff for PXA machines which can be overridden later if
  * need be.
  */
 #include <linux/config.h>
diff -Nru a/arch/arm/mach-pxa/sleep.S b/arch/arm/mach-pxa/sleep.S
--- a/arch/arm/mach-pxa/sleep.S	Wed Apr 30 22:28:16 2003
+++ b/arch/arm/mach-pxa/sleep.S	Wed Apr 30 22:28:16 2003
@@ -95,7 +95,7 @@
  *       This is to allow sleep_save_sp to be accessed with a relative load
  *       while we can't rely on any MMU translation.  We could have put
  *       sleep_save_sp in the .text section as well, but some setups might
- *       insist on it to be truely read-only.
+ *       insist on it to be truly read-only.
  */
 
 	.data
diff -Nru a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c
--- a/arch/arm/mach-sa1100/assabet.c	Wed Apr 30 22:28:03 2003
+++ b/arch/arm/mach-sa1100/assabet.c	Wed Apr 30 22:28:03 2003
@@ -15,6 +15,7 @@
 #include <linux/kernel.h>
 #include <linux/tty.h>
 #include <linux/module.h>
+#include <linux/mm.h>
 #include <linux/errno.h>
 #include <linux/serial_core.h>
 #include <linux/delay.h>
@@ -25,6 +26,7 @@
 #include <asm/setup.h>
 #include <asm/page.h>
 #include <asm/pgtable.h>
+#include <asm/tlbflush.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
diff -Nru a/arch/arm/mach-sa1100/h3600.c b/arch/arm/mach-sa1100/h3600.c
--- a/arch/arm/mach-sa1100/h3600.c	Wed Apr 30 22:28:05 2003
+++ b/arch/arm/mach-sa1100/h3600.c	Wed Apr 30 22:28:05 2003
@@ -51,12 +51,6 @@
 struct ipaq_model_ops ipaq_model_ops;
 EXPORT_SYMBOL(ipaq_model_ops);
 
-static void msleep(unsigned int msec)
-{
-	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout((msec * HZ + 999) / 1000);
-}
-
 /*
  * low-level UART features
  */
diff -Nru a/arch/arm/mach-sa1100/sleep.S b/arch/arm/mach-sa1100/sleep.S
--- a/arch/arm/mach-sa1100/sleep.S	Wed Apr 30 22:28:15 2003
+++ b/arch/arm/mach-sa1100/sleep.S	Wed Apr 30 22:28:15 2003
@@ -54,7 +54,7 @@
 	str	r0, [r1]
 
 	@ clean data cache and invalidate WB
-	bl	cpu_sa1100_cache_clean_invalidate_all
+	bl	v4wb_flush_kern_cache_all
 
 	@ disable clock switching
 	mcr	p15, 0, r1, c15, c2, 2
@@ -171,7 +171,7 @@
  *       This is to allow sleep_save_sp to be accessed with a relative load
  *       while we can't rely on any MMU translation.  We could have put
  *       sleep_save_sp in the .text section as well, but some setups might
- *       insist on it to be truely read-only.
+ *       insist on it to be truly read-only.
  */
 
 	.data
diff -Nru a/arch/arm/mm/Makefile b/arch/arm/mm/Makefile
--- a/arch/arm/mm/Makefile	Wed Apr 30 22:28:20 2003
+++ b/arch/arm/mm/Makefile	Wed Apr 30 22:28:20 2003
@@ -20,16 +20,16 @@
 p-$(CONFIG_CPU_26)	+= proc-arm2_3.o
 
 # ARMv3
-p-$(CONFIG_CPU_ARM610)	+= proc-arm6_7.o  tlb-v3.o    copypage-v3.o
-p-$(CONFIG_CPU_ARM710)	+= proc-arm6_7.o  tlb-v3.o    copypage-v3.o
+p-$(CONFIG_CPU_ARM610)	+= proc-arm6_7.o  tlb-v3.o    cache-v3.o    copypage-v3.o
+p-$(CONFIG_CPU_ARM710)	+= proc-arm6_7.o  tlb-v3.o    cache-v3.o    copypage-v3.o
 
 # ARMv4
-p-$(CONFIG_CPU_ARM720T)	+= proc-arm720.o  tlb-v4.o    copypage-v4wt.o abort-lv4t.o
-p-$(CONFIG_CPU_ARM920T)	+= proc-arm920.o  tlb-v4wbi.o copypage-v4wb.o abort-ev4t.o
-p-$(CONFIG_CPU_ARM922T)	+= proc-arm922.o  tlb-v4wbi.o copypage-v4wb.o abort-ev4t.o
-p-$(CONFIG_CPU_ARM1020)	+= proc-arm1020.o tlb-v4wbi.o copypage-v4wb.o abort-ev4t.o
-p-$(CONFIG_CPU_SA110)	+= proc-sa110.o   tlb-v4wb.o  copypage-v4wb.o abort-ev4.o   minicache.o
-p-$(CONFIG_CPU_SA1100)	+= proc-sa110.o   tlb-v4wb.o  copypage-v4mc.o abort-ev4.o   minicache.o
+p-$(CONFIG_CPU_ARM720T)	+= proc-arm720.o  tlb-v4.o    cache-v4.o    copypage-v4wt.o abort-lv4t.o
+p-$(CONFIG_CPU_ARM920T)	+= proc-arm920.o  tlb-v4wbi.o cache-v4wt.o  copypage-v4wb.o abort-ev4t.o
+p-$(CONFIG_CPU_ARM922T)	+= proc-arm922.o  tlb-v4wbi.o cache-v4wt.o  copypage-v4wb.o abort-ev4t.o
+p-$(CONFIG_CPU_ARM1020)	+= proc-arm1020.o tlb-v4wbi.o cache-v4wt.o  copypage-v4wb.o abort-ev4t.o
+p-$(CONFIG_CPU_SA110)	+= proc-sa110.o   tlb-v4wb.o  cache-v4wb.o  copypage-v4wb.o abort-ev4.o
+p-$(CONFIG_CPU_SA1100)	+= proc-sa1100.o  tlb-v4wb.o  cache-v4wb.o  copypage-v4mc.o abort-ev4.o   minicache.o
 
 # ARMv5
 p-$(CONFIG_CPU_ARM926T)	+= proc-arm926.o  tlb-v4wbi.o copypage-v4wb.o abort-ev5tej.o
diff -Nru a/arch/arm/mm/cache-v3.S b/arch/arm/mm/cache-v3.S
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/arch/arm/mm/cache-v3.S	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,118 @@
+/*
+ *  linux/arch/arm/mm/cache-v3.S
+ *
+ *  Copyright (C) 1997-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.
+ */
+#include <linux/linkage.h>
+#include <asm/hardware.h>
+#include <asm/page.h>
+#include "proc-macros.S"
+
+/*
+ *	flush_user_cache_all()
+ *
+ *	Invalidate all cache entries in a particular address
+ *	space.
+ *
+ *	- mm	- mm_struct describing address space
+ */
+ENTRY(v3_flush_user_cache_all)
+	/* FALLTHROUGH */
+/*
+ *	flush_kern_cache_all()
+ *
+ *	Clean and invalidate the entire cache.
+ */
+ENTRY(v3_flush_kern_cache_all)
+	/* FALLTHROUGH */
+
+/*
+ *	flush_user_cache_range(start, end, vm_flags)
+ *
+ *	Invalidate a range of cache entries in the specified
+ *	address space.
+ *
+ *	- start - start address (may not be aligned)
+ *	- end	- end address (exclusive, may not be aligned)
+ *	- vma	- vma_area_struct describing address space
+ */
+ENTRY(v3_flush_user_cache_range)
+	mov	ip, #0
+	mcreq	p15, 0, ip, c7, c0, 0		@ flush ID cache
+	mov	pc, lr
+
+/*
+ *	coherent_kern_range(start, end)
+ *
+ *	Ensure coherency between the Icache and the Dcache in the
+ *	region described by start.  If you have non-snooping
+ *	Harvard caches, you need to implement this function.
+ *
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
+ */
+ENTRY(v3_coherent_kern_range)
+	mov	pc, lr
+
+/*
+ *	flush_kern_dcache_page(void *page)
+ *
+ *	Ensure no D cache aliasing occurs, either with itself or
+ *	the I cache
+ *
+ *	- addr	- page aligned address
+ */
+ENTRY(v3_flush_kern_dcache_page)
+	/* FALLTHROUGH */
+
+/*
+ *	dma_inv_range(start, end)
+ *
+ *	Invalidate (discard) the specified virtual address range.
+ *	May not write back any entries.  If 'start' or 'end'
+ *	are not cache line aligned, those lines must be written
+ *	back.
+ *
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
+ */
+ENTRY(v3_dma_inv_range)
+	/* FALLTHROUGH */
+
+/*
+ *	dma_flush_range(start, end)
+ *
+ *	Clean and invalidate the specified virtual address range.
+ *
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
+ */
+ENTRY(v3_dma_flush_range)
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c0, 0		@ flush ID cache
+	/* FALLTHROUGH */
+
+/*
+ *	dma_clean_range(start, end)
+ *
+ *	Clean (write back) the specified virtual address range.
+ *
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
+ */
+ENTRY(v3_dma_clean_range)
+	mov	pc, lr
+
+ENTRY(v3_cache_fns)
+	.long	v3_flush_kern_cache_all
+	.long	v3_flush_user_cache_all
+	.long	v3_flush_user_cache_range
+	.long	v3_coherent_kern_range
+	.long	v3_flush_kern_dcache_page
+	.long	v3_dma_inv_range
+	.long	v3_dma_clean_range
+	.long	v3_dma_flush_range
diff -Nru a/arch/arm/mm/cache-v4.S b/arch/arm/mm/cache-v4.S
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/arch/arm/mm/cache-v4.S	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,120 @@
+/*
+ *  linux/arch/arm/mm/cache-v4.S
+ *
+ *  Copyright (C) 1997-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.
+ */
+#include <linux/linkage.h>
+#include <asm/hardware.h>
+#include <asm/page.h>
+#include "proc-macros.S"
+
+/*
+ *	flush_user_cache_all()
+ *
+ *	Invalidate all cache entries in a particular address
+ *	space.
+ *
+ *	- mm	- mm_struct describing address space
+ */
+ENTRY(v4_flush_user_cache_all)
+	/* FALLTHROUGH */
+/*
+ *	flush_kern_cache_all()
+ *
+ *	Clean and invalidate the entire cache.
+ */
+ENTRY(v4_flush_kern_cache_all)
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c7, 0		@ flush ID cache
+	mov	pc, lr
+
+/*
+ *	flush_user_cache_range(start, end, vma)
+ *
+ *	Invalidate a range of cache entries in the specified
+ *	address space.
+ *
+ *	- start - start address (may not be aligned)
+ *	- end	- end address (exclusive, may not be aligned)
+ *	- vma	- vma_area_struct describing address space
+ */
+ENTRY(v4_flush_user_cache_range)
+	mov	ip, #0
+	mcreq	p15, 0, ip, c7, c7, 0		@ flush ID cache
+	mov	pc, lr
+
+/*
+ *	coherent_kern_range(start, end)
+ *
+ *	Ensure coherency between the Icache and the Dcache in the
+ *	region described by start.  If you have non-snooping
+ *	Harvard caches, you need to implement this function.
+ *
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
+ */
+ENTRY(v4_coherent_kern_range)
+	mov	pc, lr
+
+/*
+ *	flush_kern_dcache_page(void *page)
+ *
+ *	Ensure no D cache aliasing occurs, either with itself or
+ *	the I cache
+ *
+ *	- addr	- page aligned address
+ */
+ENTRY(v4_flush_kern_dcache_page)
+	/* FALLTHROUGH */
+
+/*
+ *	dma_inv_range(start, end)
+ *
+ *	Invalidate (discard) the specified virtual address range.
+ *	May not write back any entries.  If 'start' or 'end'
+ *	are not cache line aligned, those lines must be written
+ *	back.
+ *
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
+ */
+ENTRY(v4_dma_inv_range)
+	/* FALLTHROUGH */
+
+/*
+ *	dma_flush_range(start, end)
+ *
+ *	Clean and invalidate the specified virtual address range.
+ *
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
+ */
+ENTRY(v4_dma_flush_range)
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c7, 0		@ flush ID cache
+	/* FALLTHROUGH */
+
+/*
+ *	dma_clean_range(start, end)
+ *
+ *	Clean (write back) the specified virtual address range.
+ *
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
+ */
+ENTRY(v4_dma_clean_range)
+	mov	pc, lr
+
+ENTRY(v4_cache_fns)
+	.long	v4_flush_kern_cache_all
+	.long	v4_flush_user_cache_all
+	.long	v4_flush_user_cache_range
+	.long	v4_coherent_kern_range
+	.long	v4_flush_kern_dcache_page
+	.long	v4_dma_inv_range
+	.long	v4_dma_clean_range
+	.long	v4_dma_flush_range
diff -Nru a/arch/arm/mm/cache-v4wb.S b/arch/arm/mm/cache-v4wb.S
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/arch/arm/mm/cache-v4wb.S	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,196 @@
+/*
+ *  linux/arch/arm/mm/cache-v4wb.S
+ *
+ *  Copyright (C) 1997-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.
+ */
+#include <linux/linkage.h>
+#include <asm/hardware.h>
+#include <asm/page.h>
+#include "proc-macros.S"
+
+/*
+ * The size of one data cache line.
+ */
+#define CACHE_DLINESIZE	32
+
+/*
+ * The total size of the data cache.
+ */
+#if defined(CONFIG_CPU_SA110)
+# define CACHE_DSIZE	16384
+#elif defined(CONFIG_CPU_SA1100)
+# define CACHE_DSIZE	8192
+#else
+# error Unknown cache size
+#endif
+
+/*
+ * This is the size at which it becomes more efficient to
+ * clean the whole cache, rather than using the individual
+ * cache line maintainence instructions.
+ *
+ *  Size  Clean (ticks) Dirty (ticks)
+ *   4096   21  20  21    53  55  54
+ *   8192   40  41  40   106 100 102
+ *  16384   77  77  76   140 140 138
+ *  32768  150 149 150   214 216 212 <---
+ *  65536  296 297 296   351 358 361
+ * 131072  591 591 591   656 657 651
+ *  Whole  132 136 132   221 217 207 <---
+ */
+#define CACHE_DLIMIT	(CACHE_DSIZE * 4)
+
+/*
+ *	flush_user_cache_all()
+ *
+ *	Clean and invalidate all cache entries in a particular address
+ *	space.
+ */
+ENTRY(v4wb_flush_user_cache_all)
+	/* FALLTHROUGH */
+/*
+ *	flush_kern_cache_all()
+ *
+ *	Clean and invalidate the entire cache.
+ */
+ENTRY(v4wb_flush_kern_cache_all)
+	mov	ip, #0
+	mcr	p15, 0, ip, c7, c5, 0		@ invalidate I cache
+__flush_whole_cache:
+	mov	r0, #FLUSH_BASE
+	add	r1, r0, #CACHE_DSIZE
+1:	ldr	r2, [r0], #32
+	cmp	r0, r1
+	blo	1b
+	mcr	p15, 0, ip, c7, c10, 4		@ drain write buffer
+	mov	pc, lr
+
+/*
+ *	flush_user_cache_range(start, end, vm_flags)
+ *
+ *	Invalidate a range of cache entries in the specified
+ *	address space.
+ *
+ *	- start - start address (inclusive, page aligned)
+ *	- end	- end address (exclusive, page aligned)
+ *	- vma	- vma_area_struct describing address space
+ */
+ENTRY(v4wb_flush_user_cache_range)
+	sub	r3, r1, r0			@ calculate total size
+	tst	r2, #VM_EXEC			@ executable region?
+	mcrne	p15, 0, ip, c7, c5, 0		@ invalidate I cache
+
+	cmp	r3, #CACHE_DLIMIT		@ total size >= limit?
+	bhs	__flush_whole_cache		@ flush whole D cache
+
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
+	tst	r2, #VM_EXEC
+	mcrne	p15, 0, ip, c7, c10, 4		@ drain write buffer
+	mov	pc, lr
+
+/*
+ *	flush_kern_dcache_page(void *page)
+ *
+ *	Ensure no D cache aliasing occurs, either with itself or
+ *	the I cache
+ *
+ *	- addr	- page aligned address
+ */
+ENTRY(v4wb_flush_kern_dcache_page)
+	add	r1, r0, #PAGE_SZ
+	/* fall through */
+
+/*
+ *	coherent_kern_range(start, end)
+ *
+ *	Ensure coherency between the Icache and the Dcache in the
+ *	region described by start.  If you have non-snooping
+ *	Harvard caches, you need to implement this function.
+ *
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
+ */
+ENTRY(v4wb_coherent_kern_range)
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
+	mov	ip, #0
+	mcr	p15, 0, ip, c7, c5, 0		@ invalidate I cache
+	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
+	mov	pc, lr
+
+
+/*
+ *	dma_inv_range(start, end)
+ *
+ *	Invalidate (discard) the specified virtual address range.
+ *	May not write back any entries.  If 'start' or 'end'
+ *	are not cache line aligned, those lines must be written
+ *	back.
+ *
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
+ */
+ENTRY(v4wb_dma_inv_range)
+	tst	r0, #CACHE_DLINESIZE - 1
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+	mcrne	p15, 0, r0, c7, c10, 1		@ clean D entry
+	tst	r1, #CACHE_DLINESIZE - 1
+	mcrne	p15, 0, r1, c7, c10, 1		@ clean D entry
+1:	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
+	mcr	p15, 0, r0, c7, c10, 4		@ drain write buffer
+	mov	pc, lr
+
+/*
+ *	dma_clean_range(start, end)
+ *
+ *	Clean (write back) the specified virtual address range.
+ *
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
+ */
+ENTRY(v4wb_dma_clean_range)
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
+	mcr	p15, 0, r0, c7, c10, 4		@ drain write buffer
+	mov	pc, lr
+
+/*
+ *	dma_flush_range(start, end)
+ *
+ *	Clean and invalidate the specified virtual address range.
+ *
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
+ *
+ *	This is actually the same as v4wb_coherent_kern_range()
+ */
+	.globl	v4wb_dma_flush_range
+	.set	v4wb_dma_flush_range, v4wb_coherent_kern_range
+
+ENTRY(v4wb_cache_fns)
+	.long	v4wb_flush_kern_cache_all
+	.long	v4wb_flush_user_cache_all
+	.long	v4wb_flush_user_cache_range
+	.long	v4wb_coherent_kern_range
+	.long	v4wb_flush_kern_dcache_page
+	.long	v4wb_dma_inv_range
+	.long	v4wb_dma_clean_range
+	.long	v4wb_dma_flush_range
diff -Nru a/arch/arm/mm/cache-v4wt.S b/arch/arm/mm/cache-v4wt.S
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/arch/arm/mm/cache-v4wt.S	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,170 @@
+/*
+ *  linux/arch/arm/mm/cache-v4wt.S
+ *
+ *  Copyright (C) 1997-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.
+ *
+ *  ARMv4 write through cache operations support.
+ *
+ *  We assume that the write buffer is not enabled.
+ */
+#include <linux/linkage.h>
+#include <asm/hardware.h>
+#include <asm/page.h>
+#include "proc-macros.S"
+
+/*
+ * The size of one data cache line.
+ */
+#define CACHE_DLINESIZE	32
+
+/*
+ * The number of data cache segments.
+ */
+#define CACHE_DSEGMENTS	8
+
+/*
+ * The number of lines in a cache segment.
+ */
+#define CACHE_DENTRIES	64
+
+/*
+ * This is the size at which it becomes more efficient to
+ * clean the whole cache, rather than using the individual
+ * cache line maintainence instructions.
+ *
+ * *** This needs benchmarking
+ */
+#define CACHE_DLIMIT	16384
+
+/*
+ *	flush_user_cache_all()
+ *
+ *	Invalidate all cache entries in a particular address
+ *	space.
+ */
+ENTRY(v4wt_flush_user_cache_all)
+	/* FALLTHROUGH */
+/*
+ *	flush_kern_cache_all()
+ *
+ *	Clean and invalidate the entire cache.
+ */
+ENTRY(v4wt_flush_kern_cache_all)
+	mov	r2, #VM_EXEC
+	mov	ip, #0
+__flush_whole_cache:
+	tst	r2, #VM_EXEC
+	mcrne	p15, 0, ip, c7, c5, 0		@ invalidate I cache
+	mcr	p15, 0, ip, c7, c6, 0		@ invalidate D cache
+	mov	pc, lr
+
+/*
+ *	flush_user_cache_range(start, end, vm_flags)
+ *
+ *	Clean and invalidate a range of cache entries in the specified
+ *	address space.
+ *
+ *	- start - start address (inclusive, page aligned)
+ *	- end	- end address (exclusive, page aligned)
+ *	- vma	- vma_area_struct describing address space
+ */
+ENTRY(v4wt_flush_user_cache_range)
+	sub	r3, r1, r0			@ calculate total size
+	cmp	r3, #CACHE_DLIMIT
+	bhs	__flush_whole_cache
+
+1:	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
+	tst	r2, #VM_EXEC
+	mcrne	p15, 0, r0, c7, c5, 1		@ invalidate I entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
+	mov	pc, lr
+
+/*
+ *	coherent_kern_range(start, end)
+ *
+ *	Ensure coherency between the Icache and the Dcache in the
+ *	region described by start.  If you have non-snooping
+ *	Harvard caches, you need to implement this function.
+ *
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
+ */
+ENTRY(v4wt_coherent_kern_range)
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+1:	mcr	p15, 0, r0, c7, c5, 1		@ invalidate I entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
+	mov	pc, lr
+
+/*
+ *	flush_kern_dcache_page(void *page)
+ *
+ *	Ensure no D cache aliasing occurs, either with itself or
+ *	the I cache
+ *
+ *	- addr	- page aligned address
+ */
+ENTRY(v4wt_flush_kern_dcache_page)
+	mov	r2, #0
+	mcr	p15, 0, r2, c7, c5, 0		@ invalidate I cache
+	add	r1, r0, #PAGE_SZ
+	/* fallthrough */
+
+/*
+ *	dma_inv_range(start, end)
+ *
+ *	Invalidate (discard) the specified virtual address range.
+ *	May not write back any entries.  If 'start' or 'end'
+ *	are not cache line aligned, those lines must be written
+ *	back.
+ *
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
+ */
+ENTRY(v4wt_dma_inv_range)
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+1:	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
+	/* FALLTHROUGH */
+
+/*
+ *	dma_clean_range(start, end)
+ *
+ *	Clean the specified virtual address range.
+ *
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
+ */
+ENTRY(v4wt_dma_clean_range)
+	mov	pc, lr
+
+/*
+ *	dma_flush_range(start, end)
+ *
+ *	Clean and invalidate the specified virtual address range.
+ *
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
+ */
+	.globl	v4wt_dma_flush_range
+	.equ	v4wt_dma_flush_range, v4wt_dma_inv_range
+
+ENTRY(v4wt_cache_fns)
+	.long	v4wt_flush_kern_cache_all
+	.long	v4wt_flush_user_cache_all
+	.long	v4wt_flush_user_cache_range
+	.long	v4wt_coherent_kern_range
+	.long	v4wt_flush_kern_dcache_page
+	.long	v4wt_dma_inv_range
+	.long	v4wt_dma_clean_range
+	.long	v4wt_dma_flush_range
+
diff -Nru a/arch/arm/mm/consistent.c b/arch/arm/mm/consistent.c
--- a/arch/arm/mm/consistent.c	Wed Apr 30 22:28:15 2003
+++ b/arch/arm/mm/consistent.c	Wed Apr 30 22:28:15 2003
@@ -161,11 +161,11 @@
 
 	/*
 	 * Invalidate any data that might be lurking in the
-	 * kernel direct-mapped region.
+	 * kernel direct-mapped region for device DMA.
 	 */
 	{
 		unsigned long kaddr = (unsigned long)page_address(page);
-		invalidate_dcache_range(kaddr, kaddr + size);
+		dmac_inv_range(kaddr, kaddr + size);
 	}
 
 	/*
@@ -330,7 +330,7 @@
 core_initcall(consistent_init);
 
 /*
- * make an area consistent.
+ * make an area consistent for devices.
  */
 void consistent_sync(void *vaddr, size_t size, int direction)
 {
@@ -339,13 +339,13 @@
 
 	switch (direction) {
 	case DMA_FROM_DEVICE:		/* invalidate only */
-		invalidate_dcache_range(start, end);
+		dmac_inv_range(start, end);
 		break;
 	case DMA_TO_DEVICE:		/* writeback only */
-		clean_dcache_range(start, end);
+		dmac_clean_range(start, end);
 		break;
 	case DMA_BIDIRECTIONAL:		/* writeback and invalidate */
-		flush_dcache_range(start, end);
+		dmac_flush_range(start, end);
 		break;
 	default:
 		BUG();
diff -Nru a/arch/arm/mm/discontig.c b/arch/arm/mm/discontig.c
--- a/arch/arm/mm/discontig.c	Wed Apr 30 22:28:16 2003
+++ b/arch/arm/mm/discontig.c	Wed Apr 30 22:28:16 2003
@@ -20,7 +20,7 @@
 #endif
 
 /*
- * Our node_data structure for discontigous memory.
+ * Our node_data structure for discontiguous memory.
  */
 
 static bootmem_data_t node_bootmem_data[NR_NODES];
diff -Nru a/arch/arm/mm/fault-armv.c b/arch/arm/mm/fault-armv.c
--- a/arch/arm/mm/fault-armv.c	Wed Apr 30 22:28:06 2003
+++ b/arch/arm/mm/fault-armv.c	Wed Apr 30 22:28:06 2003
@@ -184,9 +184,8 @@
 {
 	struct mm_struct *mm = current->active_mm;
 	struct list_head *l;
-	unsigned long kaddr = (unsigned long)page_address(page);
 
-	cpu_cache_clean_invalidate_range(kaddr, kaddr + PAGE_SIZE, 0);
+	__cpuc_flush_dcache_page(page_address(page));
 
 	if (!page->mapping)
 		return;
@@ -291,10 +290,9 @@
 	page = pfn_to_page(pfn);
 	if (page->mapping) {
 		int dirty = test_and_clear_bit(PG_dcache_dirty, &page->flags);
-		unsigned long kaddr = (unsigned long)page_address(page);
 
 		if (dirty)
-			cpu_cache_clean_invalidate_range(kaddr, kaddr + PAGE_SIZE, 0);
+			__cpuc_flush_dcache_page(page_address(page));
 
 		make_coherent(vma, addr, page, dirty);
 	}
diff -Nru a/arch/arm/mm/fault-common.c b/arch/arm/mm/fault-common.c
--- a/arch/arm/mm/fault-common.c	Wed Apr 30 22:28:10 2003
+++ b/arch/arm/mm/fault-common.c	Wed Apr 30 22:28:10 2003
@@ -12,19 +12,15 @@
 #include <linux/module.h>
 #include <linux/signal.h>
 #include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
 #include <linux/string.h>
-#include <linux/types.h>
 #include <linux/ptrace.h>
-#include <linux/mman.h>
 #include <linux/mm.h>
 #include <linux/interrupt.h>
-#include <linux/proc_fs.h>
 #include <linux/init.h>
 
 #include <asm/system.h>
 #include <asm/pgtable.h>
+#include <asm/tlbflush.h>
 #include <asm/uaccess.h>
 
 #include "fault.h"
diff -Nru a/arch/arm/mm/init.c b/arch/arm/mm/init.c
--- a/arch/arm/mm/init.c	Wed Apr 30 22:28:04 2003
+++ b/arch/arm/mm/init.c	Wed Apr 30 22:28:04 2003
@@ -20,7 +20,7 @@
 #include <linux/smp.h>
 #include <linux/init.h>
 #include <linux/bootmem.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 
 #include <asm/segment.h>
 #include <asm/mach-types.h>
diff -Nru a/arch/arm/mm/mm-armv.c b/arch/arm/mm/mm-armv.c
--- a/arch/arm/mm/mm-armv.c	Wed Apr 30 22:28:11 2003
+++ b/arch/arm/mm/mm-armv.c	Wed Apr 30 22:28:11 2003
@@ -24,30 +24,82 @@
 
 #include <asm/mach/map.h>
 
+static unsigned int cachepolicy __initdata = PMD_SECT_WB;
+static unsigned int ecc_mask __initdata = 0;
+
+struct cachepolicy {
+	char		*policy;
+	unsigned int	cr_mask;
+	unsigned int	pmd;
+};
+
+static struct cachepolicy cache_policies[] __initdata = {
+	{ "uncached",		CR1_W|CR1_C,	PMD_SECT_UNCACHED },
+	{ "buffered",		CR1_C,		PMD_SECT_BUFFERED },
+	{ "writethrough",	0,		PMD_SECT_WT       },
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
+	{ "writeback",		0,		PMD_SECT_WB       },
+	{ "writealloc",		0,		PMD_SECT_WBWA     }
+#endif
+};
+
 /*
  * These are useful for identifing cache coherency
  * problems by allowing the cache or the cache and
  * writebuffer to be turned off.  (Note: the write
  * buffer should not be on and the cache off).
  */
-static int __init nocache_setup(char *__unused)
+static void __init early_cachepolicy(char **p)
 {
-	cr_alignment &= ~CR1_C;
-	cr_no_alignment &= ~CR1_C;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(cache_policies); i++) {
+		int len = strlen(cache_policies[i].policy);
+
+		if (memcmp(*p, cache_policies[i].policy, len) == 0) {
+			cachepolicy = cache_policies[i].pmd;
+			cr_alignment &= ~cache_policies[i].cr_mask;
+			cr_no_alignment &= ~cache_policies[i].cr_mask;
+			*p += len;
+			break;
+		}
+	}
+	if (i == ARRAY_SIZE(cache_policies))
+		printk(KERN_ERR "ERROR: unknown or unsupported cache policy\n");
 	flush_cache_all();
 	set_cr(cr_alignment);
-	return 1;
 }
 
-static int __init nowrite_setup(char *__unused)
+static void __init early_nocache(char **__unused)
 {
-	cr_alignment &= ~(CR1_W|CR1_C);
-	cr_no_alignment &= ~(CR1_W|CR1_C);
-	flush_cache_all();
-	set_cr(cr_alignment);
-	return 1;
+	char *p = "buffered";
+	printk(KERN_WARNING "nocache is deprecated; use cachepolicy=%s\n", p);
+	early_cachepolicy(&p);
+}
+
+static void __init early_nowrite(char **__unused)
+{
+	char *p = "uncached";
+	printk(KERN_WARNING "nowb is deprecated; use cachepolicy=%s\n", p);
+	early_cachepolicy(&p);
 }
 
+static void __init early_ecc(char **p)
+{
+	if (memcmp(*p, "on", 2) == 0) {
+		ecc_mask = PMD_PROTECTION;
+		*p += 2;
+	} else if (memcmp(*p, "off", 3) == 0) {
+		ecc_mask = 0;
+		*p += 3;
+	}
+}
+
+__early_param("nocache", early_nocache);
+__early_param("nowb", early_nowrite);
+__early_param("cachepolicy=", early_cachepolicy);
+__early_param("ecc=", early_ecc);
+
 static int __init noalign_setup(char *__unused)
 {
 	cr_alignment &= ~CR1_A;
@@ -57,8 +109,6 @@
 }
 
 __setup("noalign", noalign_setup);
-__setup("nocache", nocache_setup);
-__setup("nowb", nowrite_setup);
 
 #define FIRST_KERNEL_PGD_NR	(FIRST_USER_PGD_NR + USER_PTRS_PER_PGD)
 
@@ -197,7 +247,7 @@
 		pmdval = __pa(ptep) | prot_l1;
 		pmdp[0] = __pmd(pmdval);
 		pmdp[1] = __pmd(pmdval + 256 * sizeof(pte_t));
-		cpu_flush_pmd(pmdp);
+		flush_pmd_entry(pmdp);
 	}
 	ptep = pte_offset_kernel(pmdp, virt);
 
@@ -231,32 +281,20 @@
 		.domain    = DOMAIN_IO,
 	},
 	[MT_CACHECLEAN] = {
-		.prot_pte  = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
-				L_PTE_CACHEABLE | L_PTE_BUFFERABLE,
-		.prot_l1   = PMD_TYPE_TABLE | PMD_BIT4,
 		.prot_sect = PMD_TYPE_SECT | PMD_BIT4,
 		.domain    = DOMAIN_KERNEL,
 	},
 	[MT_MINICLEAN] = {
-		.prot_pte  = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
-				L_PTE_CACHEABLE,
-		.prot_l1   = PMD_TYPE_TABLE | PMD_BIT4,
 		.prot_sect = PMD_TYPE_SECT | PMD_BIT4 | PMD_SECT_MINICACHE,
 		.domain    = DOMAIN_KERNEL,
 	},
 	[MT_VECTORS] = {
 		.prot_pte  = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
-				L_PTE_CACHEABLE | L_PTE_BUFFERABLE |
 				L_PTE_EXEC,
 		.prot_l1   = PMD_TYPE_TABLE | PMD_BIT4,
-		.prot_sect = PMD_TYPE_SECT | PMD_BIT4,
 		.domain    = DOMAIN_USER,
 	},
 	[MT_MEMORY] = {
-		.prot_pte  = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
-				L_PTE_CACHEABLE | L_PTE_BUFFERABLE |
-				L_PTE_EXEC | L_PTE_WRITE,
-		.prot_l1   = PMD_TYPE_TABLE | PMD_BIT4,
 		.prot_sect = PMD_TYPE_SECT | PMD_BIT4 | PMD_SECT_AP_WRITE,
 		.domain    = DOMAIN_KERNEL,
 	}
@@ -268,37 +306,50 @@
 static void __init build_mem_type_table(void)
 {
 	int cpu_arch = cpu_architecture();
-#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
-	int writethrough = 1;
-#else
-	int writethrough = 0;
-#endif
-	int writealloc = 0, ecc = 0;
+	const char *policy;
 
-	if (cpu_arch < CPU_ARCH_ARMv5) {
-		writealloc = 0;
-		ecc = 0;
+	/*
+	 * ARMv5 can use ECC memory.
+	 */
+	if (cpu_arch == CPU_ARCH_ARMv5) {
+		mem_types[MT_VECTORS].prot_l1 |= ecc_mask;
+		mem_types[MT_MEMORY].prot_sect |= ecc_mask;
+	} else {
 		mem_types[MT_MINICLEAN].prot_sect &= ~PMD_SECT_TEX(1);
+		if (cachepolicy == PMD_SECT_WBWA)
+			cachepolicy = PMD_SECT_WB;
+		ecc_mask = 0;
 	}
 
-	if (writethrough) {
+	mem_types[MT_MEMORY].prot_sect |= cachepolicy;
+
+	switch (cachepolicy) {
+	default:
+	case PMD_SECT_UNCACHED:
+		policy = "uncached";
+		break;
+	case PMD_SECT_BUFFERED:
+		mem_types[MT_VECTORS].prot_pte |= PTE_BUFFERABLE;
+		policy = "buffered";
+		break;
+	case PMD_SECT_WT:
+		mem_types[MT_VECTORS].prot_pte |= PTE_BUFFERABLE|PTE_CACHEABLE;
 		mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_WT;
-		mem_types[MT_VECTORS].prot_sect |= PMD_SECT_WT;
-		mem_types[MT_MEMORY].prot_sect |= PMD_SECT_WT;
-	} else {
+		policy = "write through";
+		break;
+	case PMD_SECT_WB:
+		mem_types[MT_VECTORS].prot_pte |= PTE_BUFFERABLE|PTE_CACHEABLE;
 		mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_WB;
-		mem_types[MT_VECTORS].prot_sect |= PMD_SECT_WB;
-
-		if (writealloc)
-			mem_types[MT_MEMORY].prot_sect |= PMD_SECT_WBWA;
-		else
-			mem_types[MT_MEMORY].prot_sect |= PMD_SECT_WB;
-	}
-
-	if (ecc) {
-		mem_types[MT_VECTORS].prot_sect |= PMD_PROTECTION;
-		mem_types[MT_MEMORY].prot_sect |= PMD_PROTECTION;
+		policy = "write back";
+		break;
+	case PMD_SECT_WBWA:
+		mem_types[MT_VECTORS].prot_pte |= PTE_BUFFERABLE|PTE_CACHEABLE;
+		mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_WB;
+		policy = "write back, write allocate";
+		break;
 	}
+	printk("Memory policy: ECC %sabled, Data cache %s\n",
+		ecc_mask ? "en" : "dis", policy);
 }
 
 /*
@@ -329,6 +380,14 @@
 	virt   = md->virtual;
 	off    = md->physical - virt;
 	length = md->length;
+
+	if (mem_types[md->type].prot_l1 == 0 &&
+	    (virt & 0xfffff || (virt + off) & 0xfffff || (virt + length) & 0xfffff)) {
+		printk(KERN_WARNING "MM: map for 0x%08lx at 0x%08lx can not "
+		       "be mapped using pages, ignoring.\n",
+		       md->physical, md->virtual);
+		return;
+	}
 
 	while ((virt & 0xfffff || (virt + off) & 0xfffff) && length >= PAGE_SIZE) {
 		alloc_init_page(virt, virt + off, prot_l1, prot_pte);
diff -Nru a/arch/arm/mm/proc-arm1020.S b/arch/arm/mm/proc-arm1020.S
--- a/arch/arm/mm/proc-arm1020.S	Wed Apr 30 22:28:04 2003
+++ b/arch/arm/mm/proc-arm1020.S	Wed Apr 30 22:28:04 2003
@@ -43,27 +43,29 @@
 #define MAX_AREA_SIZE	32768
 
 /*
- * the cache line size of the I and D cache
+ * The size of one data cache line.
  */
-#define DCACHELINESIZE	32
-#define ICACHELINESIZE	32
+#define CACHE_DLINESIZE	32
 
 /*
- * and the page size
+ * The number of data cache segments.
  */
-#define PAGESIZE	4096
+#define CACHE_DSEGMENTS	16
 
-	.text
 /*
- * cpu_arm1020_check_bugs()
+ * The number of lines in a cache segment.
  */
-ENTRY(cpu_arm1020_check_bugs)
-	mrs	ip, cpsr
-	bic	ip, ip, #PSR_F_BIT
-	msr	cpsr, ip
-	mov	pc, lr
+#define CACHE_DENTRIES	64
 
 /*
+ * This is the size at which it becomes more efficient to
+ * clean the whole cache, rather than using the individual
+ * cache line maintainence instructions.
+ */
+#define CACHE_DLIMIT	32768
+
+	.text
+/*
  * cpu_arm1020_proc_init()
  */
 ENTRY(cpu_arm1020_proc_init)
@@ -114,230 +116,233 @@
 
 /* ================================= CACHE ================================ */
 
-
+	.align	5
 /*
- * cpu_arm1020_cache_clean_invalidate_all()
+ *	flush_user_cache_all()
  *
- * clean and invalidate all cache lines
+ *	Invalidate all cache entries in a particular address
+ *	space.
+ */
+ENTRY(arm1020_flush_user_cache_all)
+	/* FALLTHROUGH */
+/*
+ *	flush_kern_cache_all()
  *
- * Note:
- *  1. we should preserve r0 at all times
+ *	Clean and invalidate the entire cache.
  */
-	.align	5
-ENTRY(cpu_arm1020_cache_clean_invalidate_all)
-	mov	r2, #1
-cpu_arm1020_cache_clean_invalidate_all_r2:
+ENTRY(arm1020_flush_kern_cache_all)
+	mov	r2, #VM_EXEC
+	mov	ip, #0
+__flush_whole_cache:
 #ifndef CONFIG_CPU_DCACHE_DISABLE
-	mcr	p15, 0, ip, c7, c10, 4
-
-	mov	r1, #0xf			@ 16 segments
-1:	mov	r3, #0x3F			@ 64 entries
-2:	mov	ip, r3, LSL #26 		@ shift up entry
-	orr	ip, ip, r1, LSL #5		@ shift in/up index
-	mcr	p15, 0, ip, c7, c14, 2		@ Clean & Inval DCache entry
-	mcr	p15, 0, ip, c7, c10, 4		@ drain WB 
-	subs	r3, r3, #1
-	cmp	r3, #0
-	bge	2b				@ entries 3F to 0
-	subs	r1, r1, #1
-	cmp	r1, #0
-	bge	1b				@ segments 7 to 0
+	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
+	mov	r1, #(CACHE_DSEGMENTS - 1) << 5	@ 16 segments
+1:	orr	r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
+2:	mcr	p15, 0, r3, c7, c14, 2		@ clean+invalidate D index
+	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
+	subs	r3, r3, #1 << 26
+	bcs	2b				@ entries 63 to 0
+	subs	r1, r1, #1 << 5
+	bcs	1b				@ segments 15 to 0
 #endif
+	tst	r2, #VM_EXEC
 #ifndef CONFIG_CPU_ICACHE_DISABLE
-	teq	r2, #0
 	mcrne	p15, 0, ip, c7, c5, 0		@ invalidate I cache
 #endif
-	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
+	mcrne	p15, 0, ip, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
 /*
- * cpu_arm1020_cache_clean_invalidate_range(start, end, flags)
+ *	flush_user_cache_range(start, end, flags)
  *
- * clean and invalidate all cache lines associated with this area of memory
+ *	Invalidate a range of cache entries in the specified
+ *	address space.
  *
- * start: Area start address
- * end:   Area end address
- * flags: nonzero for I cache as well
+ *	- start	- start address (inclusive)
+ *	- end	- end address (exclusive)
+ *	- flags	- vm_flags for this space
  */
-	.align	5
-ENTRY(cpu_arm1020_cache_clean_invalidate_range)
-	bic	r0, r0, #DCACHELINESIZE - 1
-	sub	r3, r1, r0
-	cmp	r3, #MAX_AREA_SIZE
-	bgt	cpu_arm1020_cache_clean_invalidate_all_r2
-	mcr	p15, 0, r3, c7, c10, 4
+ENTRY(arm1020_flush_user_cache_range)
+	mov	ip, #0
+	sub	r3, r1, r0			@ calculate total size
+	cmp	r3, #CACHE_DLIMIT
+	bhs	__flush_whole_cache
+
 #ifndef CONFIG_CPU_DCACHE_DISABLE
-1:	mcr	p15, 0, r0, c7, c14, 1		@ clean and invalidate D entry
-	mcr	p15, 0, r3, c7, c10, 4		@ drain WB
-	add	r0, r0, #DCACHELINESIZE
-	mcr	p15, 0, r0, c7, c14, 1		@ clean and invalidate D entry
-	mcr	p15, 0, r3, c7, c10, 4		@ drain WB
-	add	r0, r0, #DCACHELINESIZE
+	mcr	p15, 0, ip, c7, c10, 4
+1:	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
+	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
+	add	r0, r0, #CACHE_DLINESIZE
 	cmp	r0, r1
-	blt	1b
+	blo	1b
 #endif
-
+	tst	r2, #VM_EXEC
 #ifndef CONFIG_CPU_ICACHE_DISABLE
-	teq	r2, #0
-	movne	r0, #0
-	mcrne	p15, 0, r0, c7, c5, 0		@ invalidate I cache
+	mcrne	p15, 0, ip, c7, c5, 0		@ invalidate I cache
 #endif
+	mcrne	p15, 0, ip, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
-/* ================================ D-CACHE =============================== */
-
 /*
- * cpu_arm1020_dcache_invalidate_range(start, end)
+ *	coherent_kern_range(start, end)
  *
- * throw away all D-cached data in specified region without an obligation
- * to write them back.	Note however that we must clean the D-cached entries
- * around the boundaries if the start and/or end address are not cache
- * aligned.
+ *	Ensure coherency between the Icache and the Dcache in the
+ *	region described by start.  If you have non-snooping
+ *	Harvard caches, you need to implement this function.
  *
- * start: virtual start address
- * end:   virtual end address
+ *	- start	- virtual start address
+ *	- end	- virtual end address
  */
-	.align	5
-ENTRY(cpu_arm1020_dcache_invalidate_range)
+ENTRY(arm1020_coherent_kern_range)
+	mov	ip, #0
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+	mcr	p15, 0, ip, c7, c10, 4
+1:
 #ifndef CONFIG_CPU_DCACHE_DISABLE
-	/* D cache are on */
-	tst	r0, #DCACHELINESIZE - 1
-	bic	r0, r0, #DCACHELINESIZE - 1
-	mcrne	p15, 0, r0, c7, c10, 4
-	mcrne	p15, 0, r0, c7, c10, 1		@ clean D entry at start
-	mcrne	p15, 0, r0, c7, c10, 4		@ drain WB
-	tst	r1, #DCACHELINESIZE - 1
-	mcrne	p15, 0, r1, c7, c10, 4
-	mcrne	p15, 0, r1, c7, c10, 1		@ clean D entry at end
-	mcrne	p15, 0, r1, c7, c10, 4		@ drain WB
-        
-1:	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
-	add	r0, r0, #DCACHELINESIZE
-	cmp	r0, r1
-	blt	1b
-#else
-	/* D cache off, but still drain the write buffer */
-	mcr	p15, 0, r0, c7, c10, 4		@ Drain write buffer
+	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
 #endif
+#ifndef CONFIG_CPU_ICACHE_DISABLE
+	mcr	p15, 0, r0, c7, c5, 1		@ invalidate I entry
+#endif
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
+	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
 /*
- * cpu_arm1020_dcache_clean_range(start, end)
+ *	flush_kern_dcache_page(void *page)
  *
- * For the specified virtual address range, ensure that all caches contain
- * clean data, such that peripheral accesses to the physical RAM fetch
- * correct data.
+ *	Ensure no D cache aliasing occurs, either with itself or
+ *	the I cache
  *
- * start: virtual start address
- * end:   virtual end address
+ *	- page	- page aligned address
  */
-	.align	5
-ENTRY(cpu_arm1020_dcache_clean_range)
-	bic	r0, r0, #DCACHELINESIZE - 1
-	sub	r3, r1, r0
-	cmp	r3, #MAX_AREA_SIZE
-	bgt	cpu_arm1020_cache_clean_invalidate_all_r2
-	mcr	p15, 0, r3, c7, c10, 4
+ENTRY(arm1020_flush_kern_dcache_page)
+	mov	ip, #0
 #ifndef CONFIG_CPU_DCACHE_DISABLE
-1:	mcr	p15, 0, r0, c7, c14, 1		@ clean and invalidate D entry
-	mcr	p15, 0, r3, c7, c10, 4		@ drain WB
-	add	r0, r0, #DCACHELINESIZE
-	mcr	p15, 0, r0, c7, c14, 1		@ clean and invalidate D entry
-	mcr	p15, 0, r3, c7, c10, 4		@ drain WB
-	add	r0, r0, #DCACHELINESIZE
+	add	r1, r0, #PAGE_SZ
+1:	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
+	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
+	add	r0, r0, #CACHE_DLINESIZE
 	cmp	r0, r1
-	blt	1b
+	blo	1b
 #endif
+	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
 /*
- * cpu_arm1020_dcache_clean_page(page)
+ *	dma_inv_range(start, end)
  *
- * Cleans a single page of dcache so that if we have any future aliased
- * mappings, they will be consistent at the time that they are created.
+ *	Invalidate (discard) the specified virtual address range.
+ *	May not write back any entries.  If 'start' or 'end'
+ *	are not cache line aligned, those lines must be written
+ *	back.
  *
- * page: virtual address of page to clean from dcache
+ *	- start	- virtual start address
+ *	- end	- virtual end address
  *
- * Note:
- *  1. we don't need to flush the write buffer in this case.
- *  2. we don't invalidate the entries since when we write the page
- *     out to disk, the entries may get reloaded into the cache.
+ * (same as v4wb)
  */
-	.align	5
-ENTRY(cpu_arm1020_dcache_clean_page)
-	mov	r1, #PAGESIZE
-	mcr	p15, 0, r0, c7, c10, 4
+ENTRY(arm1020_dma_inv_range)
+	mov	ip, #0
 #ifndef CONFIG_CPU_DCACHE_DISABLE
-1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry  (drain is done by TLB fns)
-	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
-	add	r0, r0, #DCACHELINESIZE
-	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
-	add	r0, r0, #DCACHELINESIZE
-	subs	r1, r1, #2 * DCACHELINESIZE
-	bhi	1b
+	tst	r0, #CACHE_DLINESIZE - 1
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+	mcrne	p15, 0, ip, c7, c10, 4
+	mcrne	p15, 0, r0, c7, c10, 1		@ clean D entry
+	mcrne	p15, 0, ip, c7, c10, 4		@ drain WB
+	tst	r1, #CACHE_DLINESIZE - 1
+	mcrne	p15, 0, ip, c7, c10, 4
+	mcrne	p15, 0, r1, c7, c10, 1		@ clean D entry
+	mcrne	p15, 0, ip, c7, c10, 4		@ drain WB
+1:	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
 #endif
+	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
 /*
- * cpu_arm1020_dcache_clean_entry(addr)
+ *	dma_clean_range(start, end)
+ *
+ *	Clean the specified virtual address range.
  *
- * Clean the specified entry of any caches such that the MMU
- * translation fetches will obtain correct data.
+ *	- start	- virtual start address
+ *	- end	- virtual end address
  *
- * addr: cache-unaligned virtual address
+ * (same as v4wb)
  */
-	.align	5
-ENTRY(cpu_arm1020_dcache_clean_entry)
-	mov	r1, #0
-	mcr	p15, 0, r1, c7, c10, 4
+ENTRY(arm1020_dma_clean_range)
+	mov	ip, #0
 #ifndef CONFIG_CPU_DCACHE_DISABLE
-	mcr	p15, 0, r0, c7, c10, 1		@ clean single D entry
-	mcr	p15, 0, r1, c7, c10, 4		@ drain WB
-#endif
-#ifndef CONFIG_CPU_ICACHE_DISABLE
-	mcr	p15, 0, r1, c7, c5, 1		@ invalidate I entry
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
 #endif
+	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
-/* ================================ I-CACHE =============================== */
-
 /*
- * cpu_arm1020_icache_invalidate_range(start, end)
+ *	dma_flush_range(start, end)
  *
- * invalidate a range of virtual addresses from the Icache
+ *	Clean and invalidate the specified virtual address range.
  *
- * start: virtual start address
- * end:   virtual end address
+ *	- start	- virtual start address
+ *	- end	- virtual end address
  */
-	.align	5
-ENTRY(cpu_arm1020_icache_invalidate_range)
-1:	mcr	p15, 0, r0, c7, c10, 4
+ENTRY(arm1020_dma_flush_range)
+	mov	ip, #0
 #ifndef CONFIG_CPU_DCACHE_DISABLE
-	mcr	p15, 0, r0, c7, c10, 1		@ Clean D entry
-	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
-	add	r0, r0, #DCACHELINESIZE
-	mcr	p15, 0, r0, c7, c10, 1		@ Clean D entry
-	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
-#endif
-	add	r0, r0, #DCACHELINESIZE
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+	mcr	p15, 0, ip, c7, c10, 4
+1:	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
+	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
+	add	r0, r0, #CACHE_DLINESIZE
 	cmp	r0, r1
 	blo	1b
-ENTRY(cpu_arm1020_icache_invalidate_page)
-	mcr	p15, 0, r0, c7, c5, 0		@ invalidate I cache
+#endif
+	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
+	mov	pc, lr
+
+ENTRY(arm1020_cache_fns)
+	.long	arm1020_flush_kern_cache_all
+	.long	arm1020_flush_user_cache_all
+	.long	arm1020_flush_user_cache_range
+	.long	arm1020_coherent_kern_range
+	.long	arm1020_flush_kern_dcache_page
+	.long	arm1020_dma_inv_range
+	.long	arm1020_dma_clean_range
+	.long	arm1020_dma_flush_range
+
+	.align	5
+ENTRY(cpu_arm1020_dcache_clean_area)
+#ifndef CONFIG_CPU_DCACHE_DISABLE
+	mov	ip, #0
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
+	add	r0, r0, #CACHE_DLINESIZE
+	subs	r1, r1, #CACHE_DLINESIZE
+	bhi	1b
+#endif
 	mov	pc, lr
 
 /* =============================== PageTable ============================== */
 
 /*
- * cpu_arm1020_set_pgd(pgd)
+ * cpu_arm1020_switch_mm(pgd)
  *
  * Set the translation base pointer to be as described by pgd.
  *
  * pgd: new page tables
  */
 	.align	5
-ENTRY(cpu_arm1020_set_pgd)
+ENTRY(cpu_arm1020_switch_mm)
 #ifndef CONFIG_CPU_DCACHE_DISABLE
 	mcr	p15, 0, r3, c7, c10, 4
 	mov	r1, #0xF			@ 16 segments
@@ -365,23 +370,6 @@
 	mov	pc, lr
         
 /*
- * cpu_arm1020_flush_pmd(pmdp)
- *
- * Set a level 1 translation table entry, and clean it out of
- * any caches such that the MMUs can load it correctly.
- *
- * pmdp: pointer to PMD entry
- */
-	.align	5
-ENTRY(cpu_arm1020_flush_pmd)
-#ifndef CONFIG_CPU_DCACHE_DISABLE
-	mcr	p15, 0, r0, c7, c10, 4
-	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry  (drain is done by TLB fns)
-#endif
-	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
-	mov	pc, lr
-
-/*
  * cpu_arm1020_set_pte(ptep, pte)
  *
  * Set a PTE and flush it out
@@ -396,7 +384,7 @@
 	bic	r2, r2, #3
 	orr	r2, r2, #HPTE_TYPE_SMALL
 
-	tst	r1, #LPTE_USER | LPTE_EXEC	@ User or Exec?
+	tst	r1, #LPTE_USER			@ User?
 	orrne	r2, r2, #HPTE_AP_READ
 
 	tst	r1, #LPTE_WRITE | LPTE_DIRTY	@ Write and Dirty?
@@ -489,29 +477,12 @@
 	.type	arm1020_processor_functions, #object
 arm1020_processor_functions:
 	.word	v4t_early_abort
-	.word	cpu_arm1020_check_bugs
 	.word	cpu_arm1020_proc_init
 	.word	cpu_arm1020_proc_fin
 	.word	cpu_arm1020_reset
 	.word	cpu_arm1020_do_idle
-
-	/* cache */
-	.word	cpu_arm1020_cache_clean_invalidate_all
-	.word	cpu_arm1020_cache_clean_invalidate_range
-
-	/* dcache */
-	.word	cpu_arm1020_dcache_invalidate_range
-	.word	cpu_arm1020_dcache_clean_range
-	.word	cpu_arm1020_dcache_clean_page
-	.word	cpu_arm1020_dcache_clean_entry
-
-	/* icache */
-	.word	cpu_arm1020_icache_invalidate_range
-	.word	cpu_arm1020_icache_invalidate_page
-
-	/* pgtable */
-	.word	cpu_arm1020_set_pgd
-	.word	cpu_arm1020_flush_pmd
+	.word	cpu_arm1020_dcache_clean_area
+	.word	cpu_arm1020_switch_mm
 	.word	cpu_arm1020_set_pte
 
 	.size	arm1020_processor_functions, . - arm1020_processor_functions
@@ -542,4 +513,5 @@
 	.long	arm1020_processor_functions
 	.long	v4wbi_tlb_fns
 	.long	v4wb_user_fns
+	.long	arm1020_cache_fns
 	.size	__arm1020_proc_info, . - __arm1020_proc_info
diff -Nru a/arch/arm/mm/proc-arm2_3.S b/arch/arm/mm/proc-arm2_3.S
--- a/arch/arm/mm/proc-arm2_3.S	Wed Apr 30 22:28:09 2003
+++ b/arch/arm/mm/proc-arm2_3.S	Wed Apr 30 22:28:09 2003
@@ -162,7 +162,7 @@
  * and inaccessible (0x01f00000).
  * Params  : r0 = page table pointer
  */
-clear_tables:	ldr	r1, _arm3_set_pgd - 4
+clear_tables:	ldr	r1, _arm3_switch_mm - 4
 		ldr	r2, [r1]
 		sub	r1, r0, #256 * 4		@ start of MEMC tables
 		add	r2, r1, r2, lsl #2		@ end of tables
@@ -186,14 +186,16 @@
 		mov	pc, lr
 
 /*
- * Function: *_set_pgd(pgd_t *pgd)
+ * Function: *_switch_mm(pgd_t *pgd)
  * Params  : pgd	New page tables/MEMC mapping
  * Purpose : update MEMC hardware with new mapping
  */
 		.word	page_nr
-_arm3_set_pgd:	mcr	p15, 0, r1, c1, c0, 0		@ flush cache
-_arm2_set_pgd:	stmfd	sp!, {lr}
-		ldr	r1, _arm3_set_pgd - 4
+_arm3_switch_mm:
+		mcr	p15, 0, r1, c1, c0, 0		@ flush cache
+_arm2_switch_mm:
+		stmfd	sp!, {lr}
+		ldr	r1, _arm3_switch_mm - 4
 		ldr	r2, [r1]
 		sub	r0, r0, #256 * 4		@ start of MEMC tables
 		add	r1, r0, r2, lsl #2		@ end of tables
@@ -273,9 +275,6 @@
 _arm3_xchg_4:	swp	r0, r0, [r1]
 		movs	pc, lr
 
-_arm2_3_check_bugs:
-		bics	pc, lr, #0x04000000		@ Clear FIQ disable bit
-
 cpu_arm2_name:
 		.asciz	"ARM 2"
 cpu_arm250_name:
@@ -290,28 +289,25 @@
  */
 		.globl	arm2_processor_functions
 arm2_processor_functions:
-		.word	_arm2_3_check_bugs
 		.word	_arm2_proc_init
 		.word	_arm2_proc_fin
-		.word	_arm2_set_pgd
+		.word	_arm2_switch_mm
 		.word	_arm2_xchg_1
 		.word	_arm2_xchg_4
 
 		.globl	arm250_processor_functions
 arm250_processor_functions:
-		.word	_arm2_3_check_bugs
 		.word	_arm2_proc_init
 		.word	_arm2_proc_fin
-		.word	_arm2_set_pgd
+		.word	_arm2_switch_mm
 		.word	_arm3_xchg_1
 		.word	_arm3_xchg_4
 
 		.globl	arm3_processor_functions
 arm3_processor_functions:
-		.word	_arm2_3_check_bugs
 		.word	_arm3_proc_init
 		.word	_arm3_proc_fin
-		.word	_arm3_set_pgd
+		.word	_arm3_switch_mm
 		.word	_arm3_xchg_1
 		.word	_arm3_xchg_4
 
@@ -334,6 +330,7 @@
 		.long	arm2_processor_functions
 		.long	0
 		.long	0
+		.long	0
 
 		.long	0x41560250
 		.long	0xfffffff0
@@ -346,6 +343,7 @@
 		.long	arm250_processor_functions
 		.long	0
 		.long	0
+		.long	0
 
 		.long	0x41560300
 		.long	0xfffffff0
@@ -356,6 +354,7 @@
 		.long	0
 		.long	cpu_arm3_name
 		.long	arm3_processor_functions
+		.long	0
 		.long	0
 		.long	0
 
diff -Nru a/arch/arm/mm/proc-arm6_7.S b/arch/arm/mm/proc-arm6_7.S
--- a/arch/arm/mm/proc-arm6_7.S	Wed Apr 30 22:28:14 2003
+++ b/arch/arm/mm/proc-arm6_7.S	Wed Apr 30 22:28:14 2003
@@ -16,192 +16,162 @@
 #include <asm/constants.h>
 #include <asm/procinfo.h>
 
-/*
- * Function: arm6_7_cache_clean_invalidate_all (void)
- *	   : arm6_7_cache_clean_invalidate_page (unsigned long address, int size, int flags)
- *
- * Params  : address	Area start address
- *	   : size	size of area
- *	   : flags	b0 = I cache as well
- *
- * Purpose : Flush all cache lines
- */
-ENTRY(cpu_arm6_cache_clean_invalidate_all)
-ENTRY(cpu_arm7_cache_clean_invalidate_all)
-ENTRY(cpu_arm6_cache_clean_invalidate_range)
-ENTRY(cpu_arm7_cache_clean_invalidate_range)
-ENTRY(cpu_arm6_icache_invalidate_range)
-ENTRY(cpu_arm7_icache_invalidate_range)
-ENTRY(cpu_arm6_icache_invalidate_page)
-ENTRY(cpu_arm7_icache_invalidate_page)
-ENTRY(cpu_arm6_dcache_clean_range)
-ENTRY(cpu_arm7_dcache_clean_range)
-ENTRY(cpu_arm6_dcache_invalidate_range)
-ENTRY(cpu_arm7_dcache_invalidate_range)
-		mov	r0, #0
-		mcr	p15, 0, r0, c7, c0, 0		@ flush cache
-ENTRY(cpu_arm6_dcache_clean_page)
-ENTRY(cpu_arm7_dcache_clean_page)
-ENTRY(cpu_arm6_dcache_clean_entry)
-ENTRY(cpu_arm7_dcache_clean_entry)
+ENTRY(cpu_arm6_dcache_clean_area)
+ENTRY(cpu_arm7_dcache_clean_area)
 		mov	pc, lr
 
 /*
  * Function: arm6_7_data_abort ()
  *
- * Params  : r0 = address of aborted instruction
+ * Params  : r2 = address of aborted instruction
+ *	   : sp = pointer to registers
  *
  * Purpose : obtain information about current aborted instruction
  *
  * Returns : r0 = address of abort
- *	   : r1 != 0 if writing
- *	   : r3 = FSR
- *	   : sp = pointer to registers
+ *	   : r1 = FSR
  */
 
-ENTRY(cpu_arm6_data_abort)
-		ldr	r4, [r0]			@ read instruction causing problem
-		tst	r4, r4, lsr #21			@ C = bit 20
-		sbc	r1, r1, r1			@ r1 = C - 1
-		and	r2, r4, #14 << 24
-		teq	r2, #8 << 24			@ was it ldm/stm
-		bne	Ldata_simple
-
-Ldata_ldmstm:	tst	r4, #1 << 21			@ check writeback bit
-		beq	Ldata_simple
-		mov	r7, #0x11
-		orr	r7, r7, r7, lsl #8
-		and	r0, r4, r7
-		and	r2, r4, r7, lsl #1
-		add	r0, r0, r2, lsr #1
-		and	r2, r4, r7, lsl #2
-		add	r0, r0, r2, lsr #2
-		and	r2, r4, r7, lsl #3
-		add	r0, r0, r2, lsr #3
-		add	r0, r0, r0, lsr #8
-		add	r0, r0, r0, lsr #4
-		and	r7, r0, #15			@ r7 = no. of registers to transfer.
-		and	r5, r4, #15 << 16		@ Get Rn
-		ldr	r0, [sp, r5, lsr #14]		@ Get register
-		tst	r4, #1 << 23			@ U bit
-		subne	r7, r0, r7, lsl #2
-		addeq	r7, r0, r7, lsl #2		@ Do correction (signed)
-Ldata_saver7:	str	r7, [sp, r5, lsr #14]		@ Put register
-Ldata_simple:	mrc	p15, 0, r0, c6, c0, 0		@ get FAR
-		mrc	p15, 0, r3, c5, c0, 0		@ get FSR
-		and	r3, r3, #255
-		mov	pc, lr
-
 ENTRY(cpu_arm7_data_abort)
-		ldr	r4, [r0]			@ read instruction causing problem
-		tst	r4, r4, lsr #21			@ C = bit 20
-		sbc	r1, r1, r1			@ r1 = C - 1
-		and	r2, r4, #15 << 24
-		add	pc, pc, r2, lsr #22		@ Now branch to the relevant processing routine
-		movs	pc, lr
-
-		b	Ldata_unknown
-		b	Ldata_unknown
-		b	Ldata_unknown
-		b	Ldata_unknown
-		b	Ldata_lateldrpostconst		@ ldr	rd, [rn], #m
-		b	Ldata_lateldrpreconst		@ ldr	rd, [rn, #m]	@ RegVal
-		b	Ldata_lateldrpostreg		@ ldr	rd, [rn], rm
-		b	Ldata_lateldrprereg		@ ldr	rd, [rn, rm]
-		b	Ldata_ldmstm			@ ldm*a	rn, <rlist>
-		b	Ldata_ldmstm			@ ldm*b	rn, <rlist>
-		b	Ldata_unknown
-		b	Ldata_unknown
-		b	Ldata_simple			@ ldc	rd, [rn], #m	@ Same as ldr	rd, [rn], #m
-		b	Ldata_simple			@ ldc	rd, [rn, #m]
-		b	Ldata_unknown
-Ldata_unknown:	@ Part of jumptable
-		mov	r0, r2
-		mov	r1, r4
-		mov	r2, r3
-		bl	baddataabort
-		b	ret_from_exception
-
-Ldata_lateldrpreconst:
-		tst	r4, #1 << 21			@ check writeback bit
-		beq	Ldata_simple
-Ldata_lateldrpostconst:
-		movs	r2, r4, lsl #20			@ Get offset
-		beq	Ldata_simple
-		and	r5, r4, #15 << 16		@ Get Rn
-		ldr	r0, [sp, r5, lsr #14]
-		tst	r4, #1 << 23			@ U bit
-		subne	r7, r0, r2, lsr #20
-		addeq	r7, r0, r2, lsr #20
-		b	Ldata_saver7
-
-Ldata_lateldrprereg:
-		tst	r4, #1 << 21			@ check writeback bit
-		beq	Ldata_simple
-Ldata_lateldrpostreg:
-		and	r5, r4, #15
-		ldr	r2, [sp, r5, lsl #2]		@ Get Rm
-		mov	r3, r4, lsr #7
-		ands	r3, r3, #31
-		and	r6, r4, #0x70
-		orreq	r6, r6, #8
-		add	pc, pc, r6
-		mov	r0, r0
-
-		mov	r2, r2, lsl r3			@ 0: LSL #!0
-		b	1f
-		b	1f				@ 1: LSL #0
-		mov	r0, r0
-		b	1f				@ 2: MUL?
-		mov	r0, r0
-		b	1f				@ 3: MUL?
-		mov	r0, r0
-		mov	r2, r2, lsr r3			@ 4: LSR #!0
-		b	1f
-		mov	r2, r2, lsr #32			@ 5: LSR #32
-		b	1f
-		b	1f				@ 6: MUL?
-		mov	r0, r0
-		b	1f				@ 7: MUL?
-		mov	r0, r0
-		mov	r2, r2, asr r3			@ 8: ASR #!0
-		b	1f
-		mov	r2, r2, asr #32			@ 9: ASR #32
-		b	1f
-		b	1f				@ A: MUL?
-		mov	r0, r0
-		b	1f				@ B: MUL?
-		mov	r0, r0
-		mov	r2, r2, ror r3			@ C: ROR #!0
-		b	1f
-		mov	r2, r2, rrx			@ D: RRX
-		b	1f
-		mov	r0, r0				@ E: MUL?
-		mov	r0, r0
-		mov	r0, r0				@ F: MUL?
-
-
-1:		and	r5, r4, #15 << 16		@ Get Rn
-		ldr	r0, [sp, r5, lsr #14]
-		tst	r4, #1 << 23			@ U bit
-		subne	r7, r0, r2
-		addeq	r7, r0, r2
-		b	Ldata_saver7
+	mrc	p15, 0, r1, c5, c0, 0		@ get FSR
+	mrc	p15, 0, r0, c6, c0, 0		@ get FAR
+	ldr	r8, [r0]			@ read arm instruction
+	tst	r8, #1 << 20			@ L = 1 -> write?
+	orreq	r1, r1, #1 << 8			@ yes.
+	and	r7, r8, #15 << 24
+	add	pc, pc, r7, lsr #22		@ Now branch to the relevant processing routine
+	nop
+
+/* 0 */	b	.data_unknown
+/* 1 */	mov	pc, lr				@ swp
+/* 2 */	b	.data_unknown
+/* 3 */	b	.data_unknown
+/* 4 */	b	.data_arm_lateldrpostconst	@ ldr	rd, [rn], #m
+/* 5 */	b	.data_arm_lateldrpreconst	@ ldr	rd, [rn, #m]
+/* 6 */	b	.data_arm_lateldrpostreg	@ ldr	rd, [rn], rm
+/* 7 */	b	.data_arm_lateldrprereg		@ ldr	rd, [rn, rm]
+/* 8 */	b	.data_arm_ldmstm		@ ldm*a	rn, <rlist>
+/* 9 */	b	.data_arm_ldmstm		@ ldm*b	rn, <rlist>
+/* a */	b	.data_unknown
+/* b */	b	.data_unknown
+/* c */	mov	pc, lr				@ ldc	rd, [rn], #m	@ Same as ldr	rd, [rn], #m
+/* d */	mov	pc, lr				@ ldc	rd, [rn, #m]
+/* e */	b	.data_unknown
+/* f */
+.data_unknown:	@ Part of jumptable
+	mov	r0, r2
+	mov	r1, r8
+	mov	r2, sp
+	bl	baddataabort
+	b	ret_from_exception
+
+ENTRY(cpu_arm6_data_abort)
+	mrc	p15, 0, r1, c5, c0, 0		@ get FSR
+	mrc	p15, 0, r0, c6, c0, 0		@ get FAR
+	ldr	r8, [r2]			@ read arm instruction
+	tst	r8, #1 << 20			@ L = 1 -> write?
+	orreq	r1, r1, #1 << 8			@ yes.
+	and	r7, r8, #14 << 24
+	teq	r7, #8 << 24			@ was it ldm/stm
+	movne	pc, lr
+
+.data_arm_ldmstm:
+	tst	r8, #1 << 21			@ check writeback bit
+	moveq	pc, lr				@ no writeback -> no fixup
+	mov	r7, #0x11
+	orr	r7, r7, #0x1100
+	and	r6, r8, r7
+	and	r2, r8, r7, lsl #1
+	add	r6, r6, r2, lsr #1
+	and	r2, r8, r7, lsl #2
+	add	r6, r6, r2, lsr #2
+	and	r2, r8, r7, lsl #3
+	add	r6, r6, r2, lsr #3
+	add	r6, r6, r6, lsr #8
+	add	r6, r6, r6, lsr #4
+	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
+	addeq	r7, r7, r6, lsl #2		@ Undo decrement
+	str	r7, [sp, r5, lsr #14]		@ Put register 'Rn'
+	mov	pc, lr
+
+.data_arm_apply_r6_and_rn:
+	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			@ Undo incrmenet
+	addeq	r7, r7, r6			@ Undo decrement
+	str	r7, [sp, r5, lsr #14]		@ Put register 'Rn'
+	mov	pc, lr
+
+.data_arm_lateldrpreconst:
+	tst	r8, #1 << 21			@ check writeback bit
+	moveq	pc, lr				@ no writeback -> no fixup
+.data_arm_lateldrpostconst:
+	movs	r2, r8, lsl #20			@ Get offset
+	moveq	pc, lr				@ zero -> no fixup
+	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, r2, lsr #20		@ Undo increment
+	addeq	r7, r7, r2, lsr #20		@ Undo decrement
+	str	r7, [sp, r5, lsr #14]		@ Put register 'Rn'
+	mov	pc, lr
+
+.data_arm_lateldrprereg:
+	tst	r8, #1 << 21			@ check writeback bit
+	moveq	pc, lr				@ no writeback -> no fixup
+.data_arm_lateldrpostreg:
+	and	r7, r8, #15			@ Extract 'm' from instruction
+	ldr	r6, [sp, r7, lsl #2]		@ Get register 'Rm'
+	mov	r5, r8, lsr #7			@ get shift count
+	ands	r5, r5, #31
+	and	r7, r8, #0x70			@ get shift type
+	orreq	r7, r7, #8			@ shift count = 0
+	add	pc, pc, r7
+	nop
+
+	mov	r6, r6, lsl r5			@ 0: LSL #!0
+	b	.data_arm_apply_r6_and_rn
+	b	.data_arm_apply_r6_and_rn	@ 1: LSL #0
+	nop
+	b	.data_unknown			@ 2: MUL?
+	nop
+	b	.data_unknown			@ 3: MUL?
+	nop
+	mov	r6, r6, lsr r5			@ 4: LSR #!0
+	b	.data_arm_apply_r6_and_rn
+	mov	r6, r6, lsr #32			@ 5: LSR #32
+	b	.data_arm_apply_r6_and_rn
+	b	.data_unknown			@ 6: MUL?
+	nop
+	b	.data_unknown			@ 7: MUL?
+	nop
+	mov	r6, r6, asr r5			@ 8: ASR #!0
+	b	.data_arm_apply_r6_and_rn
+	mov	r6, r6, asr #32			@ 9: ASR #32
+	b	.data_arm_apply_r6_and_rn
+	b	.data_unknown			@ A: MUL?
+	nop
+	b	.data_unknown			@ B: MUL?
+	nop
+	mov	r6, r6, ror r5			@ C: ROR #!0
+	b	.data_arm_apply_r6_and_rn
+	mov	r6, r6, rrx			@ D: RRX
+	b	.data_arm_apply_r6_and_rn
+	b	.data_unknown			@ E: MUL?
+	nop
+	b	.data_unknown			@ F: MUL?
 
 /*
- * Function: arm6_7_check_bugs (void)
- *	   : arm6_7_proc_init (void)
+ * Function: arm6_7_proc_init (void)
  *	   : arm6_7_proc_fin (void)
  *
  * Notes   : This processor does not require these
  */
-ENTRY(cpu_arm6_check_bugs)
-ENTRY(cpu_arm7_check_bugs)
-		mrs	ip, cpsr
-		bic	ip, ip, #PSR_F_BIT
-		msr	cpsr, ip
-		mov	pc, lr
-
 ENTRY(cpu_arm6_proc_init)
 ENTRY(cpu_arm7_proc_init)
 		mov	pc, lr
@@ -216,17 +186,16 @@
 
 ENTRY(cpu_arm6_do_idle)
 ENTRY(cpu_arm7_do_idle)
-		mov	r0, #-EINVAL
 		mov	pc, lr
 
 /*
- * Function: arm6_7_set_pgd(unsigned long pgd_phys)
+ * Function: arm6_7_switch_mm(unsigned long pgd_phys)
  * Params  : pgd_phys	Physical address of page table
  * Purpose : Perform a task switch, saving the old processes state, and restoring
  *	     the new.
  */
-ENTRY(cpu_arm6_set_pgd)
-ENTRY(cpu_arm7_set_pgd)
+ENTRY(cpu_arm6_switch_mm)
+ENTRY(cpu_arm7_switch_mm)
 		mov	r1, #0
 		mcr	p15, 0, r1, c7, c0, 0		@ flush cache
 		mcr	p15, 0, r0, c2, c0, 0		@ update page table ptr
@@ -234,17 +203,6 @@
 		mov	pc, lr
 
 /*
- * Function: arm6_flush_pmd(pmdp)
- *
- * Params  : r0 = Address to set
- *
- * Purpose : Set a PMD and flush it out of any WB cache
- */
-ENTRY(cpu_arm6_flush_pmd)
-ENTRY(cpu_arm7_flush_pmd)
-		mov	pc, lr
-
-/*
  * Function: arm6_7_set_pte(pte_t *ptep, pte_t pte)
  * Params  : r0 = Address to set
  *	   : r1 = value to set
@@ -324,31 +282,13 @@
 		.type	arm6_processor_functions, #object
 ENTRY(arm6_processor_functions)
 		.word	cpu_arm6_data_abort
-		.word	cpu_arm6_check_bugs
 		.word	cpu_arm6_proc_init
 		.word	cpu_arm6_proc_fin
 		.word	cpu_arm6_reset
 		.word	cpu_arm6_do_idle
-
-		/* cache */
-		.word	cpu_arm6_cache_clean_invalidate_all
-		.word	cpu_arm6_cache_clean_invalidate_range
-
-		/* dcache */
-		.word	cpu_arm6_dcache_invalidate_range
-		.word	cpu_arm6_dcache_clean_range
-		.word	cpu_arm6_dcache_clean_page
-		.word	cpu_arm6_dcache_clean_entry
-
-		/* icache */
-		.word	cpu_arm6_icache_invalidate_range
-		.word	cpu_arm6_icache_invalidate_page
-
-		/* pgtable */
-		.word	cpu_arm6_set_pgd
-		.word	cpu_arm6_flush_pmd
+		.word	cpu_arm6_dcache_clean_area
+		.word	cpu_arm6_switch_mm
 		.word	cpu_arm6_set_pte
-
 		.size	arm6_processor_functions, . - arm6_processor_functions
 
 /*
@@ -358,31 +298,13 @@
 		.type	arm7_processor_functions, #object
 ENTRY(arm7_processor_functions)
 		.word	cpu_arm7_data_abort
-		.word	cpu_arm7_check_bugs
 		.word	cpu_arm7_proc_init
 		.word	cpu_arm7_proc_fin
 		.word	cpu_arm7_reset
 		.word	cpu_arm7_do_idle
-
-		/* cache */
-		.word	cpu_arm7_cache_clean_invalidate_all
-		.word	cpu_arm7_cache_clean_invalidate_range
-
-		/* dcache */
-		.word	cpu_arm7_dcache_invalidate_range
-		.word	cpu_arm7_dcache_clean_range
-		.word	cpu_arm7_dcache_clean_page
-		.word	cpu_arm7_dcache_clean_entry
-
-		/* icache */
-		.word	cpu_arm7_icache_invalidate_range
-		.word	cpu_arm7_icache_invalidate_page
-
-		/* pgtable */
-		.word	cpu_arm7_set_pgd
-		.word	cpu_arm7_flush_pmd
+		.word	cpu_arm7_dcache_clean_area
+		.word	cpu_arm7_switch_mm
 		.word	cpu_arm7_set_pte
-
 		.size	arm7_processor_functions, . - arm7_processor_functions
 
 		.type	cpu_arch_name, #object
@@ -409,6 +331,7 @@
 		.long	arm6_processor_functions
 		.long	v3_tlb_fns
 		.long	v3_user_fns
+		.long	v3_cache_fns
 		.size	__arm6_proc_info, . - __arm6_proc_info
 
 		.type	__arm610_proc_info, #object
@@ -424,6 +347,7 @@
 		.long	arm6_processor_functions
 		.long	v3_tlb_fns
 		.long	v3_user_fns
+		.long	v3_cache_fns
 		.size	__arm610_proc_info, . - __arm610_proc_info
 
 		.type	__arm7_proc_info, #object
@@ -439,6 +363,7 @@
 		.long	arm7_processor_functions
 		.long	v3_tlb_fns
 		.long	v3_user_fns
+		.long	v3_cache_fns
 		.size	__arm7_proc_info, . - __arm7_proc_info
 
 		.type	__arm710_proc_info, #object
@@ -454,4 +379,5 @@
 		.long	arm7_processor_functions
 		.long	v3_tlb_fns
 		.long	v3_user_fns
+		.long	v3_cache_fns
 		.size	__arm710_proc_info, . - __arm710_proc_info
diff -Nru a/arch/arm/mm/proc-arm720.S b/arch/arm/mm/proc-arm720.S
--- a/arch/arm/mm/proc-arm720.S	Wed Apr 30 22:28:11 2003
+++ b/arch/arm/mm/proc-arm720.S	Wed Apr 30 22:28:11 2003
@@ -38,47 +38,12 @@
 #include <asm/hardware.h>
 
 /*
- * Function: arm720_cache_clean_invalidate_all (void)
- *	   : arm720_cache_clean_invalidate_page (unsigned long address, int size,
- *                                    int flags)
- *
- * Params  : address	Area start address
- *	   : size	size of area
- *	   : flags	b0 = I cache as well
- *
- * Purpose : Flush all cache lines
- */
-ENTRY(cpu_arm720_cache_clean_invalidate_all)
-ENTRY(cpu_arm720_cache_clean_invalidate_range)
-ENTRY(cpu_arm720_icache_invalidate_range)
-ENTRY(cpu_arm720_icache_invalidate_page)
-ENTRY(cpu_arm720_dcache_invalidate_range)
-		mov	r0, #0
-		mcr	p15, 0, r0, c7, c7, 0		@ flush cache
-		mov	pc, lr
-
-/*
- * These just expect cache lines to be cleaned.  Since we have a writethrough
- * cache, we never have any dirty cachelines to worry about.
- */
-ENTRY(cpu_arm720_dcache_clean_range)
-ENTRY(cpu_arm720_dcache_clean_page)
-ENTRY(cpu_arm720_dcache_clean_entry)
-		mov	pc, lr
-
-/*
- * Function: arm720_check_bugs (void)
- *	   : arm720_proc_init (void)
+ * Function: arm720_proc_init (void)
  *	   : arm720_proc_fin (void)
  *
  * Notes   : This processor does not require these
  */
-ENTRY(cpu_arm720_check_bugs)
-		mrs	ip, cpsr
-		bic	ip, ip, #PSR_F_BIT
-		msr	cpsr, ip
-		mov	pc, lr
-
+ENTRY(cpu_arm720_dcache_clean_area)
 ENTRY(cpu_arm720_proc_init)
 		mov	pc, lr
 
@@ -102,12 +67,12 @@
 		mov	pc, lr
 
 /*
- * Function: arm720_set_pgd(unsigned long pgd_phys)
+ * Function: arm720_switch_mm(unsigned long pgd_phys)
  * Params  : pgd_phys	Physical address of page table
  * Purpose : Perform a task switch, saving the old process' state and restoring
  *	     the new.
  */
-ENTRY(cpu_arm720_set_pgd)
+ENTRY(cpu_arm720_switch_mm)
 		mov	r1, #0
 		mcr	p15, 0, r1, c7, c7, 0		@ invalidate cache
 		mcr	p15, 0, r0, c2, c0, 0		@ update page table ptr
@@ -115,16 +80,6 @@
 		mov	pc, lr
 
 /*
- * Function: arm720_flush_pmd(pmdp)
- *
- * Params  : r0 = Address to set
- *
- * Purpose : Set a PMD and flush it out of any WB cache
- */
-ENTRY(cpu_arm720_flush_pmd)
-		mov	pc, lr
-
-/*
  * Function: arm720_set_pte(pte_t *ptep, pte_t pte)
  * Params  : r0 = Address to set
  *	   : r1 = value to set
@@ -140,7 +95,7 @@
 		bic	r2, r2, #3
 		orr	r2, r2, #HPTE_TYPE_SMALL
 
-		tst	r1, #LPTE_USER | LPTE_EXEC	@ User or Exec?
+		tst	r1, #LPTE_USER			@ User?
 		orrne	r2, r2, #HPTE_AP_READ
 
 		tst	r1, #LPTE_WRITE | LPTE_DIRTY	@ Write and Dirty?
@@ -194,31 +149,13 @@
 		.type	arm720_processor_functions, #object
 ENTRY(arm720_processor_functions)
 		.word	v4t_late_abort
-		.word	cpu_arm720_check_bugs
 		.word	cpu_arm720_proc_init
 		.word	cpu_arm720_proc_fin
 		.word	cpu_arm720_reset
 		.word	cpu_arm720_do_idle
-
-		/* cache */
-		.word	cpu_arm720_cache_clean_invalidate_all
-		.word	cpu_arm720_cache_clean_invalidate_range
-
-		/* dcache */
-		.word	cpu_arm720_dcache_invalidate_range
-		.word	cpu_arm720_dcache_clean_range
-		.word	cpu_arm720_dcache_clean_page
-		.word	cpu_arm720_dcache_clean_entry
-
-		/* icache */
-		.word	cpu_arm720_icache_invalidate_range
-		.word	cpu_arm720_icache_invalidate_page
-
-		/* pgtable */
-		.word	cpu_arm720_set_pgd
-		.word	cpu_arm720_flush_pmd
+		.word	cpu_arm720_dcache_clean_area
+		.word	cpu_arm720_switch_mm
 		.word	cpu_arm720_set_pte
-
 		.size	arm720_processor_functions, . - arm720_processor_functions
 
 		.type	cpu_arch_name, #object
@@ -249,4 +186,5 @@
 		.long	arm720_processor_functions
 		.long	v4_tlb_fns
 		.long	v4wt_user_fns
+		.long	v4_cache_fns
 		.size	__arm720_proc_info, . - __arm720_proc_info
diff -Nru a/arch/arm/mm/proc-arm920.S b/arch/arm/mm/proc-arm920.S
--- a/arch/arm/mm/proc-arm920.S	Wed Apr 30 22:28:03 2003
+++ b/arch/arm/mm/proc-arm920.S	Wed Apr 30 22:28:03 2003
@@ -28,41 +28,35 @@
 #include <linux/config.h>
 #include <linux/init.h>
 #include <asm/assembler.h>
-#include <asm/constants.h>
 #include <asm/procinfo.h>
 #include <asm/hardware.h>
+#include <asm/page.h>
+#include "proc-macros.S"
 
 /*
- * This is the maximum size of an area which will be invalidated
- * using the single invalidate entry instructions.  Anything larger
- * than this, and we go for the whole cache.
- *
- * This value should be chosen such that we choose the cheapest
- * alternative.
+ * The size of one data cache line.
  */
-#define MAX_AREA_SIZE	16384
+#define CACHE_DLINESIZE	32
 
 /*
- * the cache line size of the I and D cache
+ * The number of data cache segments.
  */
-#define DCACHELINESIZE	32
-#define ICACHELINESIZE	32
+#define CACHE_DSEGMENTS	8
 
 /*
- * and the page size
+ * The number of lines in a cache segment.
  */
-#define PAGESIZE	4096
+#define CACHE_DENTRIES	64
 
-	.text
 /*
- * cpu_arm920_check_bugs()
+ * This is the size at which it becomes more efficient to
+ * clean the whole cache, rather than using the individual
+ * cache line maintainence instructions.
  */
-ENTRY(cpu_arm920_check_bugs)
-	mrs	ip, cpsr
-	bic	ip, ip, #PSR_F_BIT
-	msr	cpsr, ip
-	mov	pc, lr
+#define CACHE_DLIMIT	65536
 
+
+	.text
 /*
  * cpu_arm920_proc_init()
  */
@@ -76,7 +70,11 @@
 	stmfd	sp!, {lr}
 	mov	ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
 	msr	cpsr_c, ip
-	bl	cpu_arm920_cache_clean_invalidate_all
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
+	bl	arm920_flush_kern_cache_all
+#else
+	bl	v4wt_flush_kern_cache_all
+#endif
 	mrc	p15, 0, r0, c1, c0, 0		@ ctrl register
 	bic	r0, r0, #0x1000			@ ...i............
 	bic	r0, r0, #0x000e			@ ............wca.
@@ -112,249 +110,207 @@
 	mcr	p15, 0, r0, c7, c0, 4		@ Wait for interrupt
 	mov	pc, lr
 
-/* ================================= CACHE ================================ */
 
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
 
 /*
- * cpu_arm920_cache_clean_invalidate_all()
+ *	flush_user_cache_all()
  *
- * clean and invalidate all cache lines
- *
- * Note:
- *  1. we should preserve r0 at all times
+ *	Invalidate all cache entries in a particular address
+ *	space.
  */
-	.align	5
-ENTRY(cpu_arm920_cache_clean_invalidate_all)
-	mov	r2, #1
-cpu_arm920_cache_clean_invalidate_all_r2:
-	mov	ip, #0
-#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
-	mcr	p15, 0, ip, c7, c6, 0		@ invalidate D cache
-#else
+ENTRY(arm920_flush_user_cache_all)
+	/* FALLTHROUGH */
+
 /*
- * 'Clean & Invalidate whole DCache'
- * Re-written to use Index Ops.
- * Uses registers r1, r3 and ip
+ *	flush_kern_cache_all()
+ *
+ *	Clean and invalidate the entire cache.
  */
-	mov	r1, #7 << 5			@ 8 segments
-1:	orr	r3, r1, #63 << 26		@ 64 entries
-2:	mcr	p15, 0, r3, c7, c14, 2		@ clean & invalidate D index
+ENTRY(arm920_flush_kern_cache_all)
+	mov	r2, #VM_EXEC
+	mov	ip, #0
+__flush_whole_cache:
+	mov	r1, #(CACHE_DSEGMENTS - 1) << 5	@ 8 segments
+1:	orr	r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
+2:	mcr	p15, 0, r3, c7, c14, 2		@ clean+invalidate D index
 	subs	r3, r3, #1 << 26
 	bcs	2b				@ entries 63 to 0
 	subs	r1, r1, #1 << 5
 	bcs	1b				@ segments 7 to 0
-#endif
-	teq	r2, #0
+	tst	r2, #VM_EXEC
 	mcrne	p15, 0, ip, c7, c5, 0		@ invalidate I cache
-	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
+	mcrne	p15, 0, ip, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
 /*
- * cpu_arm920_cache_clean_invalidate_range(start, end, flags)
+ *	flush_user_cache_range(start, end, flags)
  *
- * clean and invalidate all cache lines associated with this area of memory
+ *	Invalidate a range of cache entries in the specified
+ *	address space.
  *
- * start: Area start address
- * end:   Area end address
- * flags: nonzero for I cache as well
- */
-		.align	5
-ENTRY(cpu_arm920_cache_clean_invalidate_range)
-	bic	r0, r0, #DCACHELINESIZE - 1	@ && added by PGM
-	bic	r1, r1, #DCACHELINESIZE - 1     @ && added by DHM
-	sub	r3, r1, r0
-	cmp	r3, #MAX_AREA_SIZE
-	bgt	cpu_arm920_cache_clean_invalidate_all_r2
-1:	teq	r2, #0
-#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
-	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
-	mcrne	p15, 0, r0, c7, c5, 1		@ invalidate I entry
-	add	r0, r0, #DCACHELINESIZE
-	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
-	mcrne	p15, 0, r0, c7, c5, 1		@ invalidate I entry
-	add	r0, r0, #DCACHELINESIZE
-#else
-	mcr	p15, 0, r0, c7, c14, 1		@ clean and invalidate D entry
-	mcrne	p15, 0, r0, c7, c5, 1		@ invalidate I entry
-	add	r0, r0, #DCACHELINESIZE
-	mcr	p15, 0, r0, c7, c14, 1		@ clean and invalidate D entry
+ *	- start	- start address (inclusive)
+ *	- end	- end address (exclusive)
+ *	- flags	- vm_flags for address space
+ */
+ENTRY(arm920_flush_user_cache_range)
+	mov	ip, #0
+	sub	r3, r1, r0			@ calculate total size
+	cmp	r3, #CACHE_DLIMIT
+	bhs	__flush_whole_cache
+
+1:	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
+	tst	r2, #VM_EXEC
 	mcrne	p15, 0, r0, c7, c5, 1		@ invalidate I entry
-	add	r0, r0, #DCACHELINESIZE
-#endif
+	add	r0, r0, #CACHE_DLINESIZE
 	cmp	r0, r1
-	blt	1b
-
-	mcr	p15, 0, r1, c7, c10, 4		@ drain WB
+	blo	1b
+	tst	r2, #VM_EXEC
+	mcrne	p15, 0, ip, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
-/* ================================ D-CACHE =============================== */
-
 /*
- * cpu_arm920_dcache_invalidate_range(start, end)
+ *	coherent_kern_range(start, end)
  *
- * throw away all D-cached data in specified region without an obligation
- * to write them back.  Note however that we must clean the D-cached entries
- * around the boundaries if the start and/or end address are not cache
- * aligned.
+ *	Ensure coherency between the Icache and the Dcache in the
+ *	region described by start, end.  If you have non-snooping
+ *	Harvard caches, you need to implement this function.
  *
- * start: virtual start address
- * end:   virtual end address
+ *	- start	- virtual start address
+ *	- end	- virtual end address
  */
-	.align	5
-ENTRY(cpu_arm920_dcache_invalidate_range)
-#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
-	tst	r0, #DCACHELINESIZE - 1
-	mcrne	p15, 0, r0, c7, c10, 1		@ clean D entry
-	tst	r1, #DCACHELINESIZE - 1
-	mcrne	p15, 0, r1, c7, c10, 1		@ clean D entry
-#endif		@ clean D entry
-	bic	r0, r0, #DCACHELINESIZE - 1
-	bic	r1, r1, #DCACHELINESIZE - 1
-1:	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
-	add	r0, r0, #DCACHELINESIZE
+ENTRY(arm920_coherent_kern_range)
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	mcr	p15, 0, r0, c7, c5, 1		@ invalidate I entry
+	add	r0, r0, #CACHE_DLINESIZE
 	cmp	r0, r1
-	blt	1b
+	blo	1b
+	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
 /*
- * cpu_arm920_dcache_clean_range(start, end)
+ *	flush_kern_dcache_page(void *page)
  *
- * For the specified virtual address range, ensure that all caches contain
- * clean data, such that peripheral accesses to the physical RAM fetch
- * correct data.
+ *	Ensure no D cache aliasing occurs, either with itself or
+ *	the I cache
  *
- * start: virtual start address
- * end:   virtual end address
+ *	- addr	- page aligned address
  */
-	.align	5
-ENTRY(cpu_arm920_dcache_clean_range)
-#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
-	bic	r0, r0, #DCACHELINESIZE - 1
-	sub	r1, r1, r0
-	cmp	r1, #MAX_AREA_SIZE
-	mov	r2, #0
-	bgt	cpu_arm920_cache_clean_invalidate_all_r2
-
-	bic	r1, r1, #DCACHELINESIZE -1
-	add	r1, r1, #DCACHELINESIZE
-
-1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	add	r0, r0, #DCACHELINESIZE
-	subs	r1, r1, #DCACHELINESIZE
-	bpl	1b
-#endif
-	mcr	p15, 0, r2, c7, c10, 4		@ drain WB
+ENTRY(arm920_flush_kern_dcache_page)
+	add	r1, r0, #PAGE_SZ
+1:	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c5, 0		@ invalidate I cache
+	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
 /*
- * cpu_arm920_dcache_clean_page(page)
+ *	dma_inv_range(start, end)
  *
- * Cleans a single page of dcache so that if we have any future aliased
- * mappings, they will be consistent at the time that they are created.
+ *	Invalidate (discard) the specified virtual address range.
+ *	May not write back any entries.  If 'start' or 'end'
+ *	are not cache line aligned, those lines must be written
+ *	back.
  *
- * page: virtual address of page to clean from dcache
+ *	- start	- virtual start address
+ *	- end	- virtual end address
  *
- * Note:
- *  1. we don't need to flush the write buffer in this case.
- *  2. we don't invalidate the entries since when we write the page
- *     out to disk, the entries may get reloaded into the cache.
+ * (same as v4wb)
  */
-	.align	5
-ENTRY(cpu_arm920_dcache_clean_page)
-#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
-	mov	r1, #PAGESIZE
-1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	add	r0, r0, #DCACHELINESIZE
-	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	add	r0, r0, #DCACHELINESIZE
-	subs	r1, r1, #2 * DCACHELINESIZE
-	bne	1b
-#endif
+ENTRY(arm920_dma_inv_range)
+	tst	r0, #CACHE_DLINESIZE - 1
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+	mcrne	p15, 0, r0, c7, c10, 1		@ clean D entry
+	tst	r1, #CACHE_DLINESIZE - 1
+	mcrne	p15, 0, r1, c7, c10, 1		@ clean D entry
+1:	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
+	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
 /*
- * cpu_arm920_dcache_clean_entry(addr)
+ *	dma_clean_range(start, end)
  *
- * Clean the specified entry of any caches such that the MMU
- * translation fetches will obtain correct data.
+ *	Clean the specified virtual address range.
  *
- * addr: cache-unaligned virtual address
+ *	- start	- virtual start address
+ *	- end	- virtual end address
+ *
+ * (same as v4wb)
  */
-	.align	5
-ENTRY(cpu_arm920_dcache_clean_entry)
-#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
-	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-#endif
+ENTRY(arm920_dma_clean_range)
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
 	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
-/* ================================ I-CACHE =============================== */
-
 /*
- * cpu_arm920_icache_invalidate_range(start, end)
- *
- * invalidate a range of virtual addresses from the Icache
+ *	dma_flush_range(start, end)
  *
- * This is a little misleading, it is not intended to clean out
- * the i-cache but to make sure that any data written to the
- * range is made consistent.  This means that when we execute code
- * in that region, everything works as we expect.
+ *	Clean and invalidate the specified virtual address range.
  *
- * This generally means writing back data in the Dcache and
- * write buffer and flushing the Icache over that region
- *
- * start: virtual start address
- * end:   virtual end address
- *
- * NOTE: ICACHELINESIZE == DCACHELINESIZE (so we don't need to
- * loop twice, once for i-cache, once for d-cache)
+ *	- start	- virtual start address
+ *	- end	- virtual end address
  */
-	.align	5
-ENTRY(cpu_arm920_icache_invalidate_range)
-	bic	r0, r0, #ICACHELINESIZE - 1	@ Safety check
-	sub	r1, r1, r0
-	cmp	r1, #MAX_AREA_SIZE
-	bgt	cpu_arm920_cache_clean_invalidate_all_r2
-
-	bic	r1, r1, #ICACHELINESIZE - 1
-	add	r1, r1, #ICACHELINESIZE
-
-1:	mcr	p15, 0, r0, c7, c5, 1		@ Clean I entry
-	mcr	p15, 0, r0, c7, c10, 1		@ Clean D entry
-	add	r0, r0, #ICACHELINESIZE
-	subs	r1, r1, #ICACHELINESIZE
-	bne	1b
-
-	mov	r0, #0
+ENTRY(arm920_dma_flush_range)
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+1:	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
 	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
-ENTRY(cpu_arm920_icache_invalidate_page)
-	mcr	p15, 0, r0, c7, c5, 0		@ invalidate I cache
+ENTRY(arm920_cache_fns)
+	.long	arm920_flush_kern_cache_all
+	.long	arm920_flush_user_cache_all
+	.long	arm920_flush_user_cache_range
+	.long	arm920_coherent_kern_range
+	.long	arm920_flush_kern_dcache_page
+	.long	arm920_dma_inv_range
+	.long	arm920_dma_clean_range
+	.long	arm920_dma_flush_range
+
+#endif
+
+
+ENTRY(cpu_arm920_dcache_clean_area)
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	subs	r1, r1, #CACHE_DLINESIZE
+	bhi	1b
 	mov	pc, lr
 
 /* =============================== PageTable ============================== */
 
 /*
- * cpu_arm920_set_pgd(pgd)
+ * cpu_arm920_switch_mm(pgd)
  *
  * Set the translation base pointer to be as described by pgd.
  *
  * pgd: new page tables
  */
 	.align	5
-ENTRY(cpu_arm920_set_pgd)
+ENTRY(cpu_arm920_switch_mm)
 	mov	ip, #0
 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
-	/* Any reason why we don't use mcr p15, 0, r0, c7, c7, 0 here? --rmk */
 	mcr	p15, 0, ip, c7, c6, 0		@ invalidate D cache
 #else
 @ && 'Clean & Invalidate whole DCache'
 @ && Re-written to use Index Ops.
 @ && Uses registers r1, r3 and ip
 
-	mov	r1, #7 << 5			@ 8 segments
-1:	orr	r3, r1, #63 << 26		@ 64 entries
+	mov	r1, #(CACHE_DSEGMENTS - 1) << 5	@ 8 segments
+1:	orr	r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
 2:	mcr	p15, 0, r3, c7, c14, 2		@ clean & invalidate D index
 	subs	r3, r3, #1 << 26
 	bcs	2b				@ entries 63 to 0
@@ -368,28 +324,12 @@
 	mov	pc, lr
 
 /*
- * cpu_arm920_flush_pmd(pmdp)
- *
- * Set a level 1 translation table entry, and clean it out of
- * any caches such that the MMUs can load it correctly.
- *
- * pmdp: pointer to PMD entry
- */
-	.align	5
-ENTRY(cpu_arm920_flush_pmd)
-	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
-	mov	pc, lr
-
-/*
  * cpu_arm920_set_pte(ptep, pte)
  *
  * Set a PTE and flush it out
  */
 	.align	5
 ENTRY(cpu_arm920_set_pte)
-	tst	r0, #2048
-	streq	r0, [r0, -r0]			@ BUG_ON
 	str	r1, [r0], #-2048		@ linux version
 
 	eor	r1, r1, #LPTE_PRESENT | LPTE_YOUNG | LPTE_WRITE | LPTE_DIRTY
@@ -398,7 +338,7 @@
 	bic	r2, r2, #3
 	orr	r2, r2, #HPTE_TYPE_SMALL
 
-	tst	r1, #LPTE_USER | LPTE_EXEC	@ User or Exec?
+	tst	r1, #LPTE_USER			@ User or Exec?
 	orrne	r2, r2, #HPTE_AP_READ
 
 	tst	r1, #LPTE_WRITE | LPTE_DIRTY	@ Write and Dirty?
@@ -477,31 +417,13 @@
 	.type	arm920_processor_functions, #object
 arm920_processor_functions:
 	.word	v4t_early_abort
-	.word	cpu_arm920_check_bugs
 	.word	cpu_arm920_proc_init
 	.word	cpu_arm920_proc_fin
 	.word	cpu_arm920_reset
 	.word   cpu_arm920_do_idle
-
-	/* cache */
-	.word	cpu_arm920_cache_clean_invalidate_all
-	.word	cpu_arm920_cache_clean_invalidate_range
-
-	/* dcache */
-	.word	cpu_arm920_dcache_invalidate_range
-	.word	cpu_arm920_dcache_clean_range
-	.word	cpu_arm920_dcache_clean_page
-	.word	cpu_arm920_dcache_clean_entry
-
-	/* icache */
-	.word	cpu_arm920_icache_invalidate_range
-	.word	cpu_arm920_icache_invalidate_page
-
-	/* pgtable */
-	.word	cpu_arm920_set_pgd
-	.word	cpu_arm920_flush_pmd
+	.word	cpu_arm920_dcache_clean_area
+	.word	cpu_arm920_switch_mm
 	.word	cpu_arm920_set_pte
-
 	.size	arm920_processor_functions, . - arm920_processor_functions
 
 	.type	cpu_arch_name, #object
@@ -530,4 +452,9 @@
 	.long	arm920_processor_functions
 	.long	v4wbi_tlb_fns
 	.long	v4wb_user_fns
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
+	.long	arm920_cache_fns
+#else
+	.long	v4wt_cache_fns
+#endif
 	.size	__arm920_proc_info, . - __arm920_proc_info
diff -Nru a/arch/arm/mm/proc-arm922.S b/arch/arm/mm/proc-arm922.S
--- a/arch/arm/mm/proc-arm922.S	Wed Apr 30 22:28:16 2003
+++ b/arch/arm/mm/proc-arm922.S	Wed Apr 30 22:28:16 2003
@@ -29,41 +29,36 @@
 #include <linux/config.h>
 #include <linux/init.h>
 #include <asm/assembler.h>
-#include <asm/constants.h>
 #include <asm/procinfo.h>
 #include <asm/hardware.h>
+#include <asm/page.h>
+#include "proc-macros.S"
 
 /*
- * This is the maximum size of an area which will be invalidated
- * using the single invalidate entry instructions.  Anything larger
- * than this, and we go for the whole cache.
- *
- * This value should be chosen such that we choose the cheapest
- * alternative.
+ * The size of one data cache line.
  */
-#define MAX_AREA_SIZE	8192
+#define CACHE_DLINESIZE	32
 
 /*
- * the cache line size of the I and D cache
+ * The number of data cache segments.
  */
-#define DCACHELINESIZE	32
-#define ICACHELINESIZE	32
+#define CACHE_DSEGMENTS	4
 
 /*
- * and the page size
+ * The number of lines in a cache segment.
  */
-#define PAGESIZE	4096
+#define CACHE_DENTRIES	64
 
-	.text
 /*
- * cpu_arm922_check_bugs()
+ * This is the size at which it becomes more efficient to
+ * clean the whole cache, rather than using the individual
+ * cache line maintainence instructions.  (I think this should
+ * be 32768).
  */
-ENTRY(cpu_arm922_check_bugs)
-	mrs	ip, cpsr
-	bic	ip, ip, #PSR_F_BIT
-	msr	cpsr, ip
-	mov	pc, lr
+#define CACHE_DLIMIT	8192
 
+
+	.text
 /*
  * cpu_arm922_proc_init()
  */
@@ -77,7 +72,11 @@
 	stmfd	sp!, {lr}
 	mov	ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
 	msr	cpsr_c, ip
-	bl	cpu_arm922_cache_clean_invalidate_all
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
+	bl	arm922_flush_kern_cache_all
+#else
+	bl	v4wt_flush_kern_cache_all
+#endif
 	mrc	p15, 0, r0, c1, c0, 0		@ ctrl register
 	bic	r0, r0, #0x1000			@ ...i............
 	bic	r0, r0, #0x000e			@ ............wca.
@@ -113,249 +112,209 @@
 	mcr	p15, 0, r0, c7, c0, 4		@ Wait for interrupt
 	mov	pc, lr
 
-/* ================================= CACHE ================================ */
 
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
 
 /*
- * cpu_arm922_cache_clean_invalidate_all()
+ *	flush_user_cache_all()
  *
- * clean and invalidate all cache lines
- *
- * Note:
- *  1. we should preserve r0 at all times
+ *	Clean and invalidate all cache entries in a particular
+ *	address space.
  */
-	.align	5
-ENTRY(cpu_arm922_cache_clean_invalidate_all)
-	mov	r2, #1
-cpu_arm922_cache_clean_invalidate_all_r2:
-	mov	ip, #0
-#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
-	mcr	p15, 0, ip, c7, c6, 0		@ invalidate D cache
-#else
+ENTRY(arm922_flush_user_cache_all)
+	/* FALLTHROUGH */
+
 /*
- * 'Clean & Invalidate whole DCache'
- * Re-written to use Index Ops.
- * Uses registers r1, r3 and ip
+ *	flush_kern_cache_all()
+ *
+ *	Clean and invalidate the entire cache.
  */
-	mov	r1, #3 << 5			@ 4 segments
-1:	orr	r3, r1, #63 << 26		@ 64 entries
-2:	mcr	p15, 0, r3, c7, c14, 2		@ clean & invalidate D index
+ENTRY(arm922_flush_kern_cache_all)
+	mov	r2, #VM_EXEC
+	mov	ip, #0
+__flush_whole_cache:
+	mov	r1, #(CACHE_DSEGMENTS - 1) << 5	@ 8 segments
+1:	orr	r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
+2:	mcr	p15, 0, r3, c7, c14, 2		@ clean+invalidate D index
 	subs	r3, r3, #1 << 26
 	bcs	2b				@ entries 63 to 0
 	subs	r1, r1, #1 << 5
 	bcs	1b				@ segments 7 to 0
-#endif
-	teq	r2, #0
+	tst	r2, #VM_EXEC
 	mcrne	p15, 0, ip, c7, c5, 0		@ invalidate I cache
-	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
+	mcrne	p15, 0, ip, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
 /*
- * cpu_arm922_cache_clean_invalidate_range(start, end, flags)
+ *	flush_user_cache_range(start, end, flags)
  *
- * clean and invalidate all cache lines associated with this area of memory
+ *	Clean and invalidate a range of cache entries in the
+ *	specified address range.
  *
- * start: Area start address
- * end:   Area end address
- * flags: nonzero for I cache as well
- */
-		.align	5
-ENTRY(cpu_arm922_cache_clean_invalidate_range)
-	bic	r0, r0, #DCACHELINESIZE - 1	@ && added by PGM
-	bic	r1, r1, #DCACHELINESIZE - 1     @ && added by DHM
-	sub	r3, r1, r0
-	cmp	r3, #MAX_AREA_SIZE
-	bgt	cpu_arm922_cache_clean_invalidate_all_r2
-1:	teq	r2, #0
-#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
-	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
-	mcrne	p15, 0, r0, c7, c5, 1		@ invalidate I entry
-	add	r0, r0, #DCACHELINESIZE
-	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
-	mcrne	p15, 0, r0, c7, c5, 1		@ invalidate I entry
-	add	r0, r0, #DCACHELINESIZE
-#else
-	mcr	p15, 0, r0, c7, c14, 1		@ clean and invalidate D entry
-	mcrne	p15, 0, r0, c7, c5, 1		@ invalidate I entry
-	add	r0, r0, #DCACHELINESIZE
-	mcr	p15, 0, r0, c7, c14, 1		@ clean and invalidate D entry
+ *	- start	- start address (inclusive)
+ *	- end	- end address (exclusive)
+ *	- flags	- vm_flags describing address space
+ */
+ENTRY(arm922_flush_user_cache_range)
+	mov	ip, #0
+	sub	r3, r1, r0			@ calculate total size
+	cmp	r3, #CACHE_DLIMIT
+	bhs	__flush_whole_cache
+
+1:	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
+	tst	r2, #VM_EXEC
 	mcrne	p15, 0, r0, c7, c5, 1		@ invalidate I entry
-	add	r0, r0, #DCACHELINESIZE
-#endif
+	add	r0, r0, #CACHE_DLINESIZE
 	cmp	r0, r1
-	blt	1b
-
-	mcr	p15, 0, r1, c7, c10, 4		@ drain WB
+	blo	1b
+	tst	r2, #VM_EXEC
+	mcrne	p15, 0, ip, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
-/* ================================ D-CACHE =============================== */
-
 /*
- * cpu_arm922_dcache_invalidate_range(start, end)
+ *	coherent_kern_range(start, end)
  *
- * throw away all D-cached data in specified region without an obligation
- * to write them back.  Note however that we must clean the D-cached entries
- * around the boundaries if the start and/or end address are not cache
- * aligned.
+ *	Ensure coherency between the Icache and the Dcache in the
+ *	region described by start, end.  If you have non-snooping
+ *	Harvard caches, you need to implement this function.
  *
- * start: virtual start address
- * end:   virtual end address
+ *	- start	- virtual start address
+ *	- end	- virtual end address
  */
-	.align	5
-ENTRY(cpu_arm922_dcache_invalidate_range)
-#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
-	tst	r0, #DCACHELINESIZE - 1
-	mcrne	p15, 0, r0, c7, c10, 1		@ clean D entry
-	tst	r1, #DCACHELINESIZE - 1
-	mcrne	p15, 0, r1, c7, c10, 1		@ clean D entry
-#endif		@ clean D entry
-	bic	r0, r0, #DCACHELINESIZE - 1
-	bic	r1, r1, #DCACHELINESIZE - 1
-1:	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
-	add	r0, r0, #DCACHELINESIZE
+ENTRY(arm922_coherent_kern_range)
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	mcr	p15, 0, r0, c7, c5, 1		@ invalidate I entry
+	add	r0, r0, #CACHE_DLINESIZE
 	cmp	r0, r1
-	blt	1b
+	blo	1b
+	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
 /*
- * cpu_arm922_dcache_clean_range(start, end)
+ *	flush_kern_dcache_page(void *page)
  *
- * For the specified virtual address range, ensure that all caches contain
- * clean data, such that peripheral accesses to the physical RAM fetch
- * correct data.
+ *	Ensure no D cache aliasing occurs, either with itself or
+ *	the I cache
  *
- * start: virtual start address
- * end:   virtual end address
+ *	- addr	- page aligned address
  */
-	.align	5
-ENTRY(cpu_arm922_dcache_clean_range)
-#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
-	bic	r0, r0, #DCACHELINESIZE - 1
-	sub	r1, r1, r0
-	cmp	r1, #MAX_AREA_SIZE
-	mov	r2, #0
-	bgt	cpu_arm922_cache_clean_invalidate_all_r2
-
-	bic	r1, r1, #DCACHELINESIZE -1
-	add	r1, r1, #DCACHELINESIZE
-
-1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	add	r0, r0, #DCACHELINESIZE
-	subs	r1, r1, #DCACHELINESIZE
-	bpl	1b
-#endif
-	mcr	p15, 0, r2, c7, c10, 4		@ drain WB
+ENTRY(arm922_flush_kern_dcache_page)
+	add	r1, r0, #PAGE_SZ
+1:	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c5, 0		@ invalidate I cache
+	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
 /*
- * cpu_arm922_dcache_clean_page(page)
+ *	dma_inv_range(start, end)
  *
- * Cleans a single page of dcache so that if we have any future aliased
- * mappings, they will be consistent at the time that they are created.
+ *	Invalidate (discard) the specified virtual address range.
+ *	May not write back any entries.  If 'start' or 'end'
+ *	are not cache line aligned, those lines must be written
+ *	back.
  *
- * page: virtual address of page to clean from dcache
+ *	- start	- virtual start address
+ *	- end	- virtual end address
  *
- * Note:
- *  1. we don't need to flush the write buffer in this case.
- *  2. we don't invalidate the entries since when we write the page
- *     out to disk, the entries may get reloaded into the cache.
+ * (same as v4wb)
  */
-	.align	5
-ENTRY(cpu_arm922_dcache_clean_page)
-#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
-	mov	r1, #PAGESIZE
-1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	add	r0, r0, #DCACHELINESIZE
-	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	add	r0, r0, #DCACHELINESIZE
-	subs	r1, r1, #2 * DCACHELINESIZE
-	bne	1b
-#endif
+ENTRY(arm922_dma_inv_range)
+	tst	r0, #CACHE_DLINESIZE - 1
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+	mcrne	p15, 0, r0, c7, c10, 1		@ clean D entry
+	tst	r1, #CACHE_DLINESIZE - 1
+	mcrne	p15, 0, r1, c7, c10, 1		@ clean D entry
+1:	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
+	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
 /*
- * cpu_arm922_dcache_clean_entry(addr)
+ *	dma_clean_range(start, end)
+ *
+ *	Clean the specified virtual address range.
  *
- * Clean the specified entry of any caches such that the MMU
- * translation fetches will obtain correct data.
+ *	- start	- virtual start address
+ *	- end	- virtual end address
  *
- * addr: cache-unaligned virtual address
+ * (same as v4wb)
  */
-	.align	5
-ENTRY(cpu_arm922_dcache_clean_entry)
-#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
-	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-#endif
+ENTRY(arm922_dma_clean_range)
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
 	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
-/* ================================ I-CACHE =============================== */
-
 /*
- * cpu_arm922_icache_invalidate_range(start, end)
- *
- * invalidate a range of virtual addresses from the Icache
- *
- * This is a little misleading, it is not intended to clean out
- * the i-cache but to make sure that any data written to the
- * range is made consistent.  This means that when we execute code
- * in that region, everything works as we expect.
+ *	dma_flush_range(start, end)
  *
- * This generally means writing back data in the Dcache and
- * write buffer and flushing the Icache over that region
+ *	Clean and invalidate the specified virtual address range.
  *
- * start: virtual start address
- * end:   virtual end address
- *
- * NOTE: ICACHELINESIZE == DCACHELINESIZE (so we don't need to
- * loop twice, once for i-cache, once for d-cache)
+ *	- start	- virtual start address
+ *	- end	- virtual end address
  */
-	.align	5
-ENTRY(cpu_arm922_icache_invalidate_range)
-	bic	r0, r0, #ICACHELINESIZE - 1	@ Safety check
-	sub	r1, r1, r0
-	cmp	r1, #MAX_AREA_SIZE
-	bgt	cpu_arm922_cache_clean_invalidate_all_r2
-
-	bic	r1, r1, #ICACHELINESIZE - 1
-	add	r1, r1, #ICACHELINESIZE
-
-1:	mcr	p15, 0, r0, c7, c5, 1		@ Clean I entry
-	mcr	p15, 0, r0, c7, c10, 1		@ Clean D entry
-	add	r0, r0, #ICACHELINESIZE
-	subs	r1, r1, #ICACHELINESIZE
-	bne	1b
-
-	mov	r0, #0
+ENTRY(arm922_dma_flush_range)
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+1:	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
 	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
-ENTRY(cpu_arm922_icache_invalidate_page)
-	mcr	p15, 0, r0, c7, c5, 0		@ invalidate I cache
+ENTRY(arm922_cache_fns)
+	.long	arm922_flush_kern_cache_all
+	.long	arm922_flush_user_cache_all
+	.long	arm922_flush_user_cache_range
+	.long	arm922_coherent_kern_range
+	.long	arm922_flush_kern_dcache_page
+	.long	arm922_dma_inv_range
+	.long	arm922_dma_clean_range
+	.long	arm922_dma_flush_range
+
+#endif
+
+
+ENTRY(cpu_arm922_dcache_clean_area)
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	subs	r1, r1, #CACHE_DLINESIZE
+	bhi	1b
+#endif
 	mov	pc, lr
 
 /* =============================== PageTable ============================== */
 
 /*
- * cpu_arm922_set_pgd(pgd)
+ * cpu_arm922_switch_mm(pgd)
  *
  * Set the translation base pointer to be as described by pgd.
  *
  * pgd: new page tables
  */
 	.align	5
-ENTRY(cpu_arm922_set_pgd)
+ENTRY(cpu_arm922_switch_mm)
 	mov	ip, #0
 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
-	/* Any reason why we don't use mcr p15, 0, r0, c7, c7, 0 here? --rmk */
 	mcr	p15, 0, ip, c7, c6, 0		@ invalidate D cache
 #else
 @ && 'Clean & Invalidate whole DCache'
 @ && Re-written to use Index Ops.
 @ && Uses registers r1, r3 and ip
 
-	mov	r1, #3 << 5			@ 4 segments
-1:	orr	r3, r1, #63 << 26		@ 64 entries
+	mov	r1, #(CACHE_DSEGMENTS - 1) << 5	@ 4 segments
+1:	orr	r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
 2:	mcr	p15, 0, r3, c7, c14, 2		@ clean & invalidate D index
 	subs	r3, r3, #1 << 26
 	bcs	2b				@ entries 63 to 0
@@ -369,20 +328,6 @@
 	mov	pc, lr
 
 /*
- * cpu_arm922_flush_pmd(pmdp)
- *
- * Set a level 1 translation table entry, and clean it out of
- * any caches such that the MMUs can load it correctly.
- *
- * pmdp: pointer to PMD entry
- */
-	.align	5
-ENTRY(cpu_arm922_flush_pmd)
-	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
-	mov	pc, lr
-
-/*
  * cpu_arm922_set_pte(ptep, pte)
  *
  * Set a PTE and flush it out
@@ -397,7 +342,7 @@
 	bic	r2, r2, #3
 	orr	r2, r2, #HPTE_TYPE_SMALL
 
-	tst	r1, #LPTE_USER | LPTE_EXEC	@ User or Exec?
+	tst	r1, #LPTE_USER			@ User?
 	orrne	r2, r2, #HPTE_AP_READ
 
 	tst	r1, #LPTE_WRITE | LPTE_DIRTY	@ Write and Dirty?
@@ -476,31 +421,13 @@
 	.type	arm922_processor_functions, #object
 arm922_processor_functions:
 	.word	v4t_early_abort
-	.word	cpu_arm922_check_bugs
 	.word	cpu_arm922_proc_init
 	.word	cpu_arm922_proc_fin
 	.word	cpu_arm922_reset
 	.word   cpu_arm922_do_idle
-
-	/* cache */
-	.word	cpu_arm922_cache_clean_invalidate_all
-	.word	cpu_arm922_cache_clean_invalidate_range
-
-	/* dcache */
-	.word	cpu_arm922_dcache_invalidate_range
-	.word	cpu_arm922_dcache_clean_range
-	.word	cpu_arm922_dcache_clean_page
-	.word	cpu_arm922_dcache_clean_entry
-
-	/* icache */
-	.word	cpu_arm922_icache_invalidate_range
-	.word	cpu_arm922_icache_invalidate_page
-
-	/* pgtable */
-	.word	cpu_arm922_set_pgd
-	.word	cpu_arm922_flush_pmd
+	.word	cpu_arm922_dcache_clean_area
+	.word	cpu_arm922_switch_mm
 	.word	cpu_arm922_set_pte
-
 	.size	arm922_processor_functions, . - arm922_processor_functions
 
 	.type	cpu_arch_name, #object
@@ -529,4 +456,9 @@
 	.long	arm922_processor_functions
 	.long	v4wbi_tlb_fns
 	.long	v4wb_user_fns
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
+	.long	arm922_cache_fns
+#else
+	.long	v4wt_cache_fns
+#endif
 	.size	__arm922_proc_info, . - __arm922_proc_info
diff -Nru a/arch/arm/mm/proc-arm926.S b/arch/arm/mm/proc-arm926.S
--- a/arch/arm/mm/proc-arm926.S	Wed Apr 30 22:28:10 2003
+++ b/arch/arm/mm/proc-arm926.S	Wed Apr 30 22:28:10 2003
@@ -28,9 +28,10 @@
 #include <linux/config.h>
 #include <linux/init.h>
 #include <asm/assembler.h>
-#include <asm/constants.h>
 #include <asm/procinfo.h>
 #include <asm/hardware.h>
+#include <asm/page.h>
+#include "proc-macros.S"
 
 /*
  * This is the maximum size of an area which will be invalidated
@@ -40,30 +41,14 @@
  * This value should be chosen such that we choose the cheapest
  * alternative.
  */
-#define MAX_AREA_SIZE	16384
+#define CACHE_DLIMIT	16384
 
 /*
  * the cache line size of the I and D cache
  */
-#define DCACHELINESIZE	32
-#define ICACHELINESIZE	32
-
-/*
- * and the page size
- */
-#define PAGESIZE	4096
+#define CACHE_DLINESIZE	32
 
 	.text
-
-/*
- * cpu_arm926_check_bugs()
- */
-ENTRY(cpu_arm926_check_bugs)
-	mrs	ip, cpsr
-	bic	ip, ip, #PSR_F_BIT
-	msr	cpsr, ip
-	mov	pc, lr
-
 /*
  * cpu_arm926_proc_init()
  */
@@ -77,17 +62,17 @@
 	stmfd	sp!, {lr}
 	mov	ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
 	msr	cpsr_c, ip
-	bl	cpu_arm926_cache_clean_invalidate_all
+	bl	arm926_flush_kern_cache_all
 	mrc	p15, 0, r0, c1, c0, 0		@ ctrl register
-	bic	r0, r0, #0x1000 		@ ...i............
-	bic	r0, r0, #0x000e 		@ ............wca.
+	bic	r0, r0, #0x1000			@ ...i............
+	bic	r0, r0, #0x000e			@ ............wca.
 	mcr	p15, 0, r0, c1, c0, 0		@ disable caches
 	ldmfd	sp!, {pc}
 
 /*
  * cpu_arm926_reset(loc)
  *
- * Perform a soft reset of the system.	Put the CPU into the
+ * Perform a soft reset of the system.  Put the CPU into the
  * same state as it would be if it had been reset, and branch
  * to what would be the reset vector.
  *
@@ -100,243 +85,236 @@
 	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
 	mcr	p15, 0, ip, c8, c7, 0		@ invalidate I & D TLBs
 	mrc	p15, 0, ip, c1, c0, 0		@ ctrl register
-	bic	ip, ip, #0x000f 		@ ............wcam
-	bic	ip, ip, #0x1100 		@ ...i...s........
+	bic	ip, ip, #0x000f			@ ............wcam
+	bic	ip, ip, #0x1100			@ ...i...s........
 	mcr	p15, 0, ip, c1, c0, 0		@ ctrl register
 	mov	pc, r0
 
 /*
  * cpu_arm926_do_idle()
+ *
+ * Called with IRQs disabled
  */
-	.align	5
+	.align	10
 ENTRY(cpu_arm926_do_idle)
+	mov	r0, #0
+	mrc	p15, 0, r1, c1, c0, 0		@ Read control register
+	mcr	p15, 0, r0, c7, c10, 4		@ Drain write buffer
+	bic	r2, r1, #1 << 12
+	mcr	p15, 0, r2, c1, c0, 0		@ Disable I cache
 	mcr	p15, 0, r0, c7, c0, 4		@ Wait for interrupt
+	mcr	p15, 0, r1, c1, c0, 0		@ Restore ICache enable
 	mov	pc, lr
 
-/* ================================= CACHE ================================ */
-
-
 /*
- * cpu_arm926_cache_clean_invalidate_all()
+ *	flush_user_cache_all()
  *
- * clean and invalidate all cache lines
+ *	Clean and invalidate all cache entries in a particular
+ *	address space.
+ */
+ENTRY(arm926_flush_user_cache_all)
+	/* FALLTHROUGH */
+
+/*
+ *	flush_kern_cache_all()
  *
- * Note:
- *  1. we should preserve r0 at all times
+ *	Clean and invalidate the entire cache.
  */
-	.align	5
-ENTRY(cpu_arm926_cache_clean_invalidate_all)
-	mov	r2, #1
-cpu_arm926_cache_clean_invalidate_all_r2:
+ENTRY(arm926_flush_kern_cache_all)
+	mov	r2, #VM_EXEC
 	mov	ip, #0
+__flush_whole_cache:
 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
 	mcr	p15, 0, ip, c7, c6, 0		@ invalidate D cache
 #else
 1:	mrc	p15, 0, r15, c7, c14, 3 	@ test,clean,invalidate
 	bne	1b
 #endif
-	teq	r2, #0
+	tst	r2, #VM_EXEC
 	mcrne	p15, 0, ip, c7, c5, 0		@ invalidate I cache
-	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
+	mcrne	p15, 0, ip, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
 /*
- * cpu_arm926_cache_clean_invalidate_range(start, end, flags)
+ *	flush_user_cache_range(start, end, flags)
  *
- * clean and invalidate all cache lines associated with this area of memory
+ *	Clean and invalidate a range of cache entries in the
+ *	specified address range.
  *
- * This is a little misleading, it is not intended to clean out
- * the i-cache but to make sure that any data written to the
- * range is made consistent.  This means that when we execute code
- * in that region, everything works as we expect.
- *
- * This generally means writing back data in the Dcache and
- * write buffer and flushing the Icache over that region
- * start: Area start address
- * end:   Area end address
- * flags: nonzero for I cache as well
+ *	- start	- start address (inclusive)
+ *	- end	- end address (exclusive)
+ *	- flags	- vm_flags describing address space
  */
-	.align	5
-ENTRY(cpu_arm926_cache_clean_invalidate_range)
-	bic	r0, r0, #DCACHELINESIZE - 1	@ && added by PGM
-	bic	r1, r1, #DCACHELINESIZE - 1	@ && added by DHM
-	sub	r3, r1, r0
-	cmp	r3, #MAX_AREA_SIZE
-	bgt	cpu_arm926_cache_clean_invalidate_all_r2
-
-1:	teq	r2, #0
+ENTRY(arm926_flush_user_cache_range)
+	mov	ip, #0
+	sub	r3, r1, r0			@ calculate total size
+	cmp	r3, #CACHE_DLIMIT
+	bgt	__flush_whole_cache
+1:	tst	r2, #VM_EXEC
 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
 	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
 	mcrne	p15, 0, r0, c7, c5, 1		@ invalidate I entry
-	add	r0, r0, #DCACHELINESIZE
+	add	r0, r0, #CACHE_DLINESIZE
 	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
 	mcrne	p15, 0, r0, c7, c5, 1		@ invalidate I entry
-	add	r0, r0, #DCACHELINESIZE
+	add	r0, r0, #CACHE_DLINESIZE
 #else
 	mcr	p15, 0, r0, c7, c14, 1		@ clean and invalidate D entry
 	mcrne	p15, 0, r0, c7, c5, 1		@ invalidate I entry
-	add	r0, r0, #DCACHELINESIZE
+	add	r0, r0, #CACHE_DLINESIZE
 	mcr	p15, 0, r0, c7, c14, 1		@ clean and invalidate D entry
 	mcrne	p15, 0, r0, c7, c5, 1		@ invalidate I entry
-	add	r0, r0, #DCACHELINESIZE
+	add	r0, r0, #CACHE_DLINESIZE
 #endif
-        
 	cmp	r0, r1
-	blt	1b
-
-	mcr	p15, 0, r1, c7, c10, 4		@ drain WB
-
+	blo	1b
+	tst	r2, #VM_EXEC
+	mcrne	p15, 0, ip, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
-/* ================================ D-CACHE =============================== */
-
 /*
- * cpu_arm926_dcache_invalidate_range(start, end)
+ *	coherent_kern_range(start, end)
  *
- * throw away all D-cached data in specified region without an obligation
- * to write them back.	Note however that we must clean the D-cached entries
- * around the boundaries if the start and/or end address are not cache
- * aligned.
+ *	Ensure coherency between the Icache and the Dcache in the
+ *	region described by start, end.  If you have non-snooping
+ *	Harvard caches, you need to implement this function.
  *
- * start: virtual start address
- * end:   virtual end address
+ *	- start	- virtual start address
+ *	- end	- virtual end address
  */
-	.align	5
-ENTRY(cpu_arm926_dcache_invalidate_range)
-#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
-	tst	r0, #DCACHELINESIZE - 1
-	mcrne	p15, 0, r0, c7, c10, 1		@ clean D entry
-	tst	r1, #DCACHELINESIZE - 1
-	mcrne	p15, 0, r1, c7, c10, 1
-#endif		@ clean D entry
-	bic	r0, r0, #DCACHELINESIZE - 1
-	bic	r1, r1, #DCACHELINESIZE - 1
-1:	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
-	add	r0, r0, #DCACHELINESIZE
+ENTRY(arm926_coherent_kern_range)
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	mcr	p15, 0, r0, c7, c5, 1		@ invalidate I entry
+	add	r0, r0, #CACHE_DLINESIZE
 	cmp	r0, r1
-	blt	1b
+	blo	1b
+	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
 /*
- * cpu_arm926_dcache_clean_range(start, end)
+ *	flush_kern_dcache_page(void *page)
  *
- * For the specified virtual address range, ensure that all caches contain
- * clean data, such that peripheral accesses to the physical RAM fetch
- * correct data.
+ *	Ensure no D cache aliasing occurs, either with itself or
+ *	the I cache
  *
- * start: virtual start address
- * end:   virtual end address
+ *	- addr	- page aligned address
  */
-	.align	5
-ENTRY(cpu_arm926_dcache_clean_range)
-#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
-	bic	r0, r0, #DCACHELINESIZE - 1
-	sub	r1, r1, r0
-	cmp	r1, #MAX_AREA_SIZE
-	mov	r2, #0
-	bgt	cpu_arm926_cache_clean_invalidate_all_r2
-
-	bic	r1, r1, #DCACHELINESIZE -1
-	add	r1, r1, #DCACHELINESIZE
-
-1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	add	r0, r0, #DCACHELINESIZE
-	subs	r1, r1, #DCACHELINESIZE
-	bpl	1b
-#endif
-	mcr	p15, 0, r2, c7, c10, 4		@ drain WB
+ENTRY(arm926_flush_kern_dcache_page)
+	add	r1, r0, #PAGE_SZ
+1:	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c5, 0		@ invalidate I cache
+	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
 /*
- * cpu_arm926_dcache_clean_page(page)
+ *	dma_inv_range(start, end)
  *
- * Cleans a single page of dcache so that if we have any future aliased
- * mappings, they will be consistent at the time that they are created.
+ *	Invalidate (discard) the specified virtual address range.
+ *	May not write back any entries.  If 'start' or 'end'
+ *	are not cache line aligned, those lines must be written
+ *	back.
  *
- * page: virtual address of page to clean from dcache
+ *	- start	- virtual start address
+ *	- end	- virtual end address
  *
- * Note:
- *  1. we don't need to flush the write buffer in this case.
- *  2. we don't invalidate the entries since when we write the page
- *     out to disk, the entries may get reloaded into the cache.
+ * (same as v4wb)
  */
-	.align	5
-ENTRY(cpu_arm926_dcache_clean_page)
+ENTRY(arm926_dma_inv_range)
 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
-	mov	r1, #PAGESIZE
-1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	add	r0, r0, #DCACHELINESIZE
-	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	add	r0, r0, #DCACHELINESIZE
-	subs	r1, r1, #2 * DCACHELINESIZE
-	bne	1b
+	tst	r0, #CACHE_DLINESIZE - 1
+	mcrne	p15, 0, r0, c7, c10, 1		@ clean D entry
+	tst	r1, #CACHE_DLINESIZE - 1
+	mcrne	p15, 0, r1, c7, c10, 1		@ clean D entry
 #endif
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+1:	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
+	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
 /*
- * cpu_arm926_dcache_clean_entry(addr)
+ *	dma_clean_range(start, end)
  *
- * Clean the specified entry of any caches such that the MMU
- * translation fetches will obtain correct data.
+ *	Clean the specified virtual address range.
  *
- * addr: cache-unaligned virtual address
+ *	- start	- virtual start address
+ *	- end	- virtual end address
+ *
+ * (same as v4wb)
  */
-	.align	5
-ENTRY(cpu_arm926_dcache_clean_entry)
+ENTRY(arm926_dma_clean_range)
 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
-	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
 #endif
 	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
-/* ================================ I-CACHE =============================== */
-
 /*
- * cpu_arm926_icache_invalidate_range(start, end)
+ *	dma_flush_range(start, end)
  *
- * invalidate a range of virtual addresses from the Icache
+ *	Clean and invalidate the specified virtual address range.
  *
- * start: virtual start address
- * end:   virtual end address
+ *	- start	- virtual start address
+ *	- end	- virtual end address
  */
-	.align	5
-ENTRY(cpu_arm926_icache_invalidate_range)
-	bic	r0, r0, #DCACHELINESIZE - 1	@ Safety check
-	sub	r1, r1, r0
-	cmp	r1, #MAX_AREA_SIZE
-	bgt	cpu_arm926_cache_clean_invalidate_all_r2
-
-	bic	r1, r1, #DCACHELINESIZE - 1
-	add	r1, r1, #DCACHELINESIZE
-
-1:	mcr	p15, 0, r0, c7, c5, 1		@ clean I entries
-	add	r0, r0, #DCACHELINESIZE
-	subs	r1, r1, #DCACHELINESIZE
-	bne	1b
-
-	mov	r0, #0
+ENTRY(arm926_dma_flush_range)
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+1:
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
+	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
+#else
+	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+#endif
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
 	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
 	mov	pc, lr
 
-ENTRY(cpu_arm926_icache_invalidate_page)
-	mcr	p15, 0, r0, c7, c5, 0		@ invalidate I cache
-	mov	pc, lr
+ENTRY(arm926_cache_fns)
+	.long	arm926_flush_kern_cache_all
+	.long	arm926_flush_user_cache_all
+	.long	arm926_flush_user_cache_range
+	.long	arm926_coherent_kern_range
+	.long	arm926_flush_kern_dcache_page
+	.long	arm926_dma_inv_range
+	.long	arm926_dma_clean_range
+	.long	arm926_dma_flush_range
 
+ENTRY(cpu_arm926_dcache_clean_area)
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	subs	r1, r1, #CACHE_DLINESIZE
+	bhi	1b
+#endif
+	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
+	mov	pc, lr
 
 /* =============================== PageTable ============================== */
 
 /*
- * cpu_arm926_set_pgd(pgd)
+ * cpu_arm926_switch_mm(pgd)
  *
  * Set the translation base pointer to be as described by pgd.
  *
  * pgd: new page tables
  */
 	.align	5
-ENTRY(cpu_arm926_set_pgd)
+ENTRY(cpu_arm926_switch_mm)
 	mov	ip, #0
 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
-	/* Any reason why we don't use mcr p15, 0, r0, c7, c7, 0 here? --rmk */
 	mcr	p15, 0, ip, c7, c6, 0		@ invalidate D cache
 #else
 @ && 'Clean & Invalidate whole DCache'
@@ -350,22 +328,6 @@
 	mov	pc, lr
 
 /*
- * cpu_arm926_flush_pmd(pmdp)
- *
- * Set a level 1 translation table entry, and clean it out of
- * any caches such that the MMUs can load it correctly.
- *
- * pmdp: pointer to PMD entry
- */
-	.align	5
-ENTRY(cpu_arm926_flush_pmd)
-#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
-	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-#endif
-	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
-	mov	pc, lr
-
-/*
  * cpu_arm926_set_pte(ptep, pte)
  *
  * Set a PTE and flush it out
@@ -380,7 +342,7 @@
 	bic	r2, r2, #3
 	orr	r2, r2, #HPTE_TYPE_SMALL
 
-	tst	r1, #LPTE_USER | LPTE_EXEC	@ User or Exec?
+	tst	r1, #LPTE_USER			@ User?
 	orrne	r2, r2, #HPTE_AP_READ
 
 	tst	r1, #LPTE_WRITE | LPTE_DIRTY	@ Write and Dirty?
@@ -447,21 +409,21 @@
 	bic	r0, r0, #0x0e00
 	bic	r0, r0, #0x0002
 	bic	r0, r0, #0x000c
-	bic	r0, r0, #0x1000 		@ ...0 000. .... 000.
+	bic	r0, r0, #0x1000			@ ...0 000. .... 000.
 /*
  * Turn on what we want
  */
 	orr	r0, r0, #0x0031
-	orr	r0, r0, #0x2100 		@ ..1. ...1 ..11 ...1
+	orr	r0, r0, #0x2100			@ ..1. ...1 ..11 ...1
 
 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
-	orr	r0, r0, #0x4000 		@ .1.. .... .... ....
+	orr	r0, r0, #0x4000			@ .1.. .... .... ....
 #endif
 #ifndef CONFIG_CPU_DCACHE_DISABLE
-	orr	r0, r0, #0x0004 		@ .... .... .... .1..
+	orr	r0, r0, #0x0004			@ .... .... .... .1..
 #endif
 #ifndef CONFIG_CPU_ICACHE_DISABLE
-	orr	r0, r0, #0x1000 		@ ...1 .... .... ....
+	orr	r0, r0, #0x1000			@ ...1 .... .... ....
 #endif
 	mov	pc, lr
 
@@ -474,31 +436,13 @@
 	.type	arm926_processor_functions, #object
 arm926_processor_functions:
 	.word	v5tej_early_abort
-	.word	cpu_arm926_check_bugs
 	.word	cpu_arm926_proc_init
 	.word	cpu_arm926_proc_fin
 	.word	cpu_arm926_reset
 	.word	cpu_arm926_do_idle
-
-	/* cache */
-	.word	cpu_arm926_cache_clean_invalidate_all
-	.word	cpu_arm926_cache_clean_invalidate_range
-
-	/* dcache */
-	.word	cpu_arm926_dcache_invalidate_range
-	.word	cpu_arm926_dcache_clean_range
-	.word	cpu_arm926_dcache_clean_page
-	.word	cpu_arm926_dcache_clean_entry
-
-	/* icache */
-	.word	cpu_arm926_icache_invalidate_range
-	.word	cpu_arm926_icache_invalidate_page
-
-	/* pgtable */
-	.word	cpu_arm926_set_pgd
-	.word	cpu_arm926_flush_pmd
+	.word	cpu_arm926_dcache_clean_area
+	.word	cpu_arm926_switch_mm
 	.word	cpu_arm926_set_pte
-
 	.size	arm926_processor_functions, . - arm926_processor_functions
 
 	.type	cpu_arch_name, #object
@@ -522,10 +466,10 @@
 	b	__arm926_setup
 	.long	cpu_arch_name
 	.long	cpu_elf_name
-	.long	HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB | \
-		HWCAP_FAST_MULT | HWCAP_JAVA
+	.long	HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB | HWCAP_FAST_MULT | HWCAP_JAVA
 	.long	cpu_arm926_name
 	.long	arm926_processor_functions
 	.long	v4wbi_tlb_fns
 	.long	v4wb_user_fns
+	.long	arm926_cache_fns
 	.size	__arm926_proc_info, . - __arm926_proc_info
diff -Nru a/arch/arm/mm/proc-sa110.S b/arch/arm/mm/proc-sa110.S
--- a/arch/arm/mm/proc-sa110.S	Wed Apr 30 22:28:09 2003
+++ b/arch/arm/mm/proc-sa110.S	Wed Apr 30 22:28:09 2003
@@ -10,12 +10,7 @@
  *  MMU functions for SA110
  *
  *  These are the low level assembler for performing cache and TLB
- *  functions on the StrongARM-110, StrongARM-1100 and StrongARM-1110.
- * 
- *  Note that SA1100 and SA1110 share everything but their name and CPU ID.
- *
- *  12-jun-2000, Erik Mouw (J.A.K.Mouw@its.tudelft.nl):
- *    Flush the read buffer at context switches
+ *  functions on the StrongARM-110.
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
@@ -25,71 +20,32 @@
 #include <asm/hardware.h>
 #include <asm/proc/pgtable.h>
 
-/* This is the maximum size of an area which will be flushed.  If the area
- * is larger than this, then we flush the whole cache
- */
-#define MAX_AREA_SIZE	32768
-
 /*
  * the cache line size of the I and D cache
  */
 #define DCACHELINESIZE	32
-
-/*
- * and the page size
- */
-#define PAGESIZE	4096
-
 #define FLUSH_OFFSET	32768
 
-		.macro flush_110_dcache	rd, ra, re
-		ldr	\rd, =flush_base
-		ldr	\ra, [\rd]
-		eor	\ra, \ra, #FLUSH_OFFSET
-		str	\ra, [\rd]
-		add	\re, \ra, #16384		@ only necessary for 16k
-1001:		ldr	\rd, [\ra], #DCACHELINESIZE
-		teq	\re, \ra
-		bne	1001b
-		.endm
-
-		.macro flush_1100_dcache	rd, ra, re
-		ldr	\rd, =flush_base
-		ldr	\ra, [\rd]
-		eor	\ra, \ra, #FLUSH_OFFSET
-		str	\ra, [\rd]
-		add	\re, \ra, #8192			@ only necessary for 8k
-1001:		ldr	\rd, [\ra], #DCACHELINESIZE
-		teq	\re, \ra
-		bne	1001b
-#ifdef FLUSH_BASE_MINICACHE
-		add	\ra, \ra, #FLUSH_BASE_MINICACHE - FLUSH_BASE
-		add	\re, \ra, #512			@ only 512 bytes
-1002:		ldr	\rd, [\ra], #DCACHELINESIZE
-		teq	\re, \ra
-		bne	1002b
-#endif
-		.endm
-
-		.data
-flush_base:	.long	FLUSH_BASE
-		.text
-
-/*
- * cpu_sa110_check_bugs()
- */
-ENTRY(cpu_sa110_check_bugs)
-ENTRY(cpu_sa1100_check_bugs)
-	mrs	ip, cpsr
-	bic	ip, ip, #PSR_F_BIT
-	msr	cpsr, ip
-	mov	pc, lr
+	.macro flush_110_dcache	rd, ra, re
+	ldr	\rd, =flush_base
+	ldr	\ra, [\rd]
+	eor	\ra, \ra, #FLUSH_OFFSET
+	str	\ra, [\rd]
+	add	\re, \ra, #16384		@ only necessary for 16k
+1001:	ldr	\rd, [\ra], #DCACHELINESIZE
+	teq	\re, \ra
+	bne	1001b
+	.endm
+
+	.data
+flush_base:
+	.long	FLUSH_BASE
+	.text
 
 /*
  * cpu_sa110_proc_init()
  */
 ENTRY(cpu_sa110_proc_init)
-ENTRY(cpu_sa1100_proc_init)
 	mov	r0, #0
 	mcr	p15, 0, r0, c15, c1, 2		@ Enable clock switching
 	mov	pc, lr
@@ -101,7 +57,7 @@
 	stmfd	sp!, {lr}
 	mov	ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
 	msr	cpsr_c, ip
-	bl	cpu_sa110_cache_clean_invalidate_all	@ clean caches
+	bl	v4wb_flush_kern_cache_all	@ clean caches
 1:	mov	r0, #0
 	mcr	p15, 0, r0, c15, c2, 2		@ Disable clock switching
 	mrc	p15, 0, r0, c1, c0, 0		@ ctrl register
@@ -110,13 +66,6 @@
 	mcr	p15, 0, r0, c1, c0, 0		@ disable caches
 	ldmfd	sp!, {pc}
 
-ENTRY(cpu_sa1100_proc_fin)
-	stmfd	sp!, {lr}
-	mov	ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
-	msr	cpsr_c, ip
-	bl	cpu_sa1100_cache_clean_invalidate_all	@ clean caches
-	b	1b
-
 /*
  * cpu_sa110_reset(loc)
  *
@@ -128,7 +77,6 @@
  */
 	.align	5
 ENTRY(cpu_sa110_reset)
-ENTRY(cpu_sa1100_reset)
 	mov	ip, #0
 	mcr	p15, 0, ip, c7, c7, 0		@ invalidate I,D caches
 	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
@@ -151,204 +99,25 @@
  *   3 = switch to fast processor clock
  */
 	.align	5
-idle:	mcr	p15, 0, r0, c15, c8, 2		@ Wait for interrupt, cache aligned
-	mov	r0, r0				@ safety
-	mov	pc, lr
 
 ENTRY(cpu_sa110_do_idle)
-	mov	ip, #0
-	cmp	r0, #4
-	addcc	pc, pc, r0, lsl #2
-	mov	pc, lr
-
-	b	idle
-	b	idle
-	b	slow_clock
-	b	fast_clock
-
-fast_clock:
-	mcr	p15, 0, ip, c15, c1, 2		@ enable clock switching
-	mov	pc, lr
-
-slow_clock:
 	mcr	p15, 0, ip, c15, c2, 2		@ disable clock switching
 	ldr	r1, =UNCACHEABLE_ADDR		@ load from uncacheable loc
 	ldr	r1, [r1, #0]			@ force switch to MCLK
-	mov	pc, lr
-
-	.align	5
-ENTRY(cpu_sa1100_do_idle)
-	mov	r0, r0				@ 4 nop padding
-	mov	r0, r0
-	mov	r0, r0
-	mov	r0, #0
-	ldr	r1, =UNCACHEABLE_ADDR		@ ptr to uncacheable address
-	mrs	r2, cpsr
-	orr	r3, r2, #192			@ disallow interrupts
-	msr	cpsr_c, r3
-	@ --- aligned to a cache line
-	mcr	p15, 0, r0, c15, c2, 2		@ disable clock switching
-	ldr	r1, [r1, #0]			@ force switch to MCLK
-	mcr	p15, 0, r0, c15, c8, 2		@ wait for interrupt
+	mov	r0, r0				@ safety
+	mov	r0, r0				@ safety
+	mov	r0, r0				@ safety
+	mcr	p15, 0, r0, c15, c8, 2		@ Wait for interrupt, cache aligned
+	mov	r0, r0				@ safety
+	mov	r0, r0				@ safety
 	mov	r0, r0				@ safety
 	mcr	p15, 0, r0, c15, c1, 2		@ enable clock switching
-	msr	cpsr_c, r2			@ allow interrupts
 	mov	pc, lr
 
 /* ================================= CACHE ================================ */
 
-
-/*
- * cpu_sa110_cache_clean_invalidate_all (void)
- *
- * clean and invalidate all cache lines
- *
- * Note:
- *  1. we should preserve r0 at all times
- */
-	.align	5
-ENTRY(cpu_sa110_cache_clean_invalidate_all)
-	mov	r2, #1
-cpu_sa110_cache_clean_invalidate_all_r2:
-	flush_110_dcache	r3, ip, r1
-	mov	ip, #0
-	teq	r2, #0
-	mcrne	p15, 0, ip, c7, c5, 0		@ invalidate I cache
-	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
-	mov	pc, lr
-
-	.align	5
-ENTRY(cpu_sa1100_cache_clean_invalidate_all)
-	mov	r2, #1
-cpu_sa1100_cache_clean_invalidate_all_r2:
-	flush_1100_dcache	r3, ip, r1
-	mov	ip, #0
-	teq	r2, #0
-	mcrne	p15, 0, ip, c7, c5, 0		@ invalidate I cache
-	mcr	p15, 0, r1, c9, c0, 0		@ invalidate RB
-	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
-	mov	pc, lr
-
-/*
- * cpu_sa110_cache_clean_invalidate_range(start, end, flags)
- *
- * clean and invalidate all cache lines associated with this area of memory
- *
- * start: Area start address
- * end:   Area end address
- * flags: nonzero for I cache as well
- */
-	.align	5
-ENTRY(cpu_sa110_cache_clean_invalidate_range)
-	bic	r0, r0, #DCACHELINESIZE - 1
-	sub	r3, r1, r0
-	cmp	r3, #MAX_AREA_SIZE
-	bhi	cpu_sa110_cache_clean_invalidate_all_r2
-1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
-	add	r0, r0, #DCACHELINESIZE
-	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
-	add	r0, r0, #DCACHELINESIZE
-	cmp	r0, r1
-	blo	1b
-	teq	r2, #0
-	movne	r0, #0
-	mcrne	p15, 0, r0, c7, c5, 0		@ invalidate I cache
-	mov	pc, lr
-
-ENTRY(cpu_sa1100_cache_clean_invalidate_range)
-	sub	r3, r1, r0
-	cmp	r3, #MAX_AREA_SIZE
-	bhi	cpu_sa1100_cache_clean_invalidate_all_r2
-	b	1b
-
-/* ================================ D-CACHE =============================== */
-
-/*
- * cpu_sa110_dcache_invalidate_range(start, end)
- *
- * throw away all D-cached data in specified region without an obligation
- * to write them back.  Note however that we must clean the D-cached entries
- * around the boundaries if the start and/or end address are not cache
- * aligned.
- *
- * start: virtual start address
- * end:   virtual end address
- */
-	.align	5
-ENTRY(cpu_sa110_dcache_invalidate_range)
-ENTRY(cpu_sa1100_dcache_invalidate_range)
-	tst	r0, #DCACHELINESIZE - 1
-	bic	r0, r0, #DCACHELINESIZE - 1
-	mcrne	p15, 0, r0, c7, c10, 1		@ clean D entry
-	tst	r1, #DCACHELINESIZE - 1
-	mcrne	p15, 0, r1, c7, c10, 1		@ clean D entry
-1:	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
-	add	r0, r0, #DCACHELINESIZE
-	cmp	r0, r1
-	blo	1b
-	mov	pc, lr
-
-/*
- * cpu_sa110_dcache_clean_range(start, end)
- *
- * For the specified virtual address range, ensure that all caches contain
- * clean data, such that peripheral accesses to the physical RAM fetch
- * correct data.
- *
- * start: virtual start address
- * end:   virtual end address
- */
-	.align	5
-ENTRY(cpu_sa110_dcache_clean_range)
-	bic	r0, r0, #DCACHELINESIZE - 1
-	sub	r1, r1, r0
-	cmp	r1, #MAX_AREA_SIZE
-	mov	r2, #0
-	bhi	cpu_sa110_cache_clean_invalidate_all_r2
-1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	add	r0, r0, #DCACHELINESIZE
-	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	add	r0, r0, #DCACHELINESIZE
-	subs	r1, r1, #2 * DCACHELINESIZE
-	bpl	1b
-	mcr	p15, 0, r2, c7, c10, 4		@ drain WB
-	mov	pc, lr
-
-ENTRY(cpu_sa1100_dcache_clean_range)
-	bic	r0, r0, #DCACHELINESIZE - 1
-	sub	r1, r1, r0
-	cmp	r1, #MAX_AREA_SIZE
-	mov	r2, #0
-	bhi	cpu_sa1100_cache_clean_invalidate_all_r2
-	b	1b
-
-/*
- * cpu_sa110_clean_dcache_page(page)
- *
- * Cleans a single page of dcache so that if we have any future aliased
- * mappings, they will be consistent at the time that they are created.
- *
- * Note:
- *  1. we don't need to flush the write buffer in this case.
- *  2. we don't invalidate the entries since when we write the page
- *     out to disk, the entries may get reloaded into the cache.
- */
-	.align	5
-ENTRY(cpu_sa110_dcache_clean_page)
-ENTRY(cpu_sa1100_dcache_clean_page)
-	mov	r1, #PAGESIZE
-1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	add	r0, r0, #DCACHELINESIZE
-	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	add	r0, r0, #DCACHELINESIZE
-	subs	r1, r1, #2 * DCACHELINESIZE
-	bne	1b
-	mov	pc, lr
-
 /*
- * cpu_sa110_dcache_clean_entry(addr)
+ * cpu_sa110_dcache_clean_area(addr,sz)
  *
  * Clean the specified entry of any caches such that the MMU
  * translation fetches will obtain correct data.
@@ -356,48 +125,24 @@
  * addr: cache-unaligned virtual address
  */
 	.align	5
-ENTRY(cpu_sa110_dcache_clean_entry)
-ENTRY(cpu_sa1100_dcache_clean_entry)
-	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
-	mov	pc, lr
-
-/* ================================ I-CACHE =============================== */
-
-/*
- * cpu_sa110_icache_invalidate_range(start, end)
- *
- * invalidate a range of virtual addresses from the Icache
- *
- * start: virtual start address
- * end:   virtual end address
- */
-	.align	5
-ENTRY(cpu_sa110_icache_invalidate_range)
-ENTRY(cpu_sa1100_icache_invalidate_range)
-	bic	r0, r0, #DCACHELINESIZE - 1
-1:	mcr	p15, 0, r0, c7, c10, 1		@ Clean D entry
+ENTRY(cpu_sa110_dcache_clean_area)
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
 	add	r0, r0, #DCACHELINESIZE
-	cmp	r0, r1
-	blo	1b
-	mov	r0, #0
-	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
-ENTRY(cpu_sa110_icache_invalidate_page)
-ENTRY(cpu_sa1100_icache_invalidate_page)
-	mcr	p15, 0, r0, c7, c5, 0		@ invalidate I cache
+	subs	r1, r1, #DCACHELINESIZE
+	bhi	1b
 	mov	pc, lr
 
 /* =============================== PageTable ============================== */
 
 /*
- * cpu_sa110_set_pgd(pgd)
+ * cpu_sa110_switch_mm(pgd)
  *
  * Set the translation base pointer to be as described by pgd.
  *
  * pgd: new page tables
  */
 	.align	5
-ENTRY(cpu_sa110_set_pgd)
+ENTRY(cpu_sa110_switch_mm)
 	flush_110_dcache	r3, ip, r1
 	mov	r1, #0
 	mcr	p15, 0, r1, c7, c5, 0		@ invalidate I cache
@@ -407,48 +152,12 @@
 	mov	pc, lr
 
 /*
- * cpu_sa1100_set_pgd(pgd)
- *
- * Set the translation base pointer to be as described by pgd.
- *
- * pgd: new page tables
- */
-	.align	5
-ENTRY(cpu_sa1100_set_pgd)
-	flush_1100_dcache	r3, ip, r1
-	mov	ip, #0
-	mcr	p15, 0, ip, c7, c5, 0		@ invalidate I cache
-	mcr	p15, 0, ip, c9, c0, 0		@ invalidate RB
-	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
-	mcr	p15, 0, r0, c2, c0, 0		@ load page table pointer
-	mcr	p15, 0, ip, c8, c7, 0		@ invalidate I & D TLBs
-	mov	pc, lr
-
-/*
- * cpu_sa110_flush_pmd(pmdp)
- *
- * Set a level 1 translation table entry, and clean it out of
- * any caches such that the MMUs can load it correctly.
- *
- * pmdp: pointer to PMD entry
- */
-	.align	5
-ENTRY(cpu_sa110_flush_pmd)
-ENTRY(cpu_sa1100_flush_pmd)
-	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
-	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
-	mov	pc, lr
-
-/*
  * cpu_sa110_set_pte(ptep, pte)
  *
  * Set a PTE and flush it out
  */
 	.align	5
 ENTRY(cpu_sa110_set_pte)
-ENTRY(cpu_sa1100_set_pte)
-	tst	r0, #2048
-	streq	r0, [r0, -r0]			@ BUG_ON
 	str	r1, [r0], #-2048		@ linux version
 
 	eor	r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
@@ -457,7 +166,7 @@
 	bic	r2, r2, #3
 	orr	r2, r2, #PTE_TYPE_SMALL
 
-	tst	r1, #L_PTE_USER | L_PTE_EXEC	@ User or Exec?
+	tst	r1, #L_PTE_USER			@ User or Exec?
 	orrne	r2, r2, #PTE_SMALL_AP_URO_SRW
 
 	tst	r1, #L_PTE_WRITE | L_PTE_DIRTY	@ Write and Dirty?
@@ -475,30 +184,16 @@
 
 cpu_sa110_name:
 	.asciz	"StrongARM-110"
-cpu_sa1100_name:
-	.asciz	"StrongARM-1100"
-cpu_sa1110_name:
-	.asciz	"StrongARM-1110"
 	.align
 
 	__INIT
 
-__sa1100_setup:	@ Allow read-buffer operations from userland
-	mcr	p15, 0, r0, c9, c0, 5
-	mrc	p15, 0, r0, c1, c0		@ get control register v4
-	bic	r0, r0, #0x0e00			@ ..VI ZFRS BLDP WCAM
-	bic	r0, r0, #0x0002			@ .... 000. .... ..0.
-	orr	r0, r0, #0x003d
-	orr	r0, r0, #0x3100			@ ..11 ...1 ..11 11.1
-	b	__setup_common
-
 __sa110_setup:
 	mrc	p15, 0, r0, c1, c0		@ get control register v4
 	bic	r0, r0, #0x2e00			@ ..VI ZFRS BLDP WCAM
 	bic	r0, r0, #0x0002			@ ..0. 000. .... ..0.
 	orr	r0, r0, #0x003d
 	orr	r0, r0, #0x1100			@ ...1 ...1 ..11 11.1
-__setup_common:
 	mov	r10, #0
 	mcr	p15, 0, r10, c7, c7		@ invalidate I,D caches on v4
 	mcr	p15, 0, r10, c7, c10, 4		@ drain write buffer on v4
@@ -518,66 +213,20 @@
 	.type	sa110_processor_functions, #object
 ENTRY(sa110_processor_functions)
 	.word	v4_early_abort
-	.word	cpu_sa110_check_bugs
 	.word	cpu_sa110_proc_init
 	.word	cpu_sa110_proc_fin
 	.word	cpu_sa110_reset
 	.word	cpu_sa110_do_idle
 
-	/* cache */
-	.word	cpu_sa110_cache_clean_invalidate_all
-	.word	cpu_sa110_cache_clean_invalidate_range
-
 	/* dcache */
-	.word	cpu_sa110_dcache_invalidate_range
-	.word	cpu_sa110_dcache_clean_range
-	.word	cpu_sa110_dcache_clean_page
-	.word	cpu_sa110_dcache_clean_entry
-
-	/* icache */
-	.word	cpu_sa110_icache_invalidate_range
-	.word	cpu_sa110_icache_invalidate_page
+	.word	cpu_sa110_dcache_clean_area
 
 	/* pgtable */
-	.word	cpu_sa110_set_pgd
-	.word	cpu_sa110_flush_pmd
+	.word	cpu_sa110_switch_mm
 	.word	cpu_sa110_set_pte
 
 	.size	sa110_processor_functions, . - sa110_processor_functions
 
-/*
- * SA1100 and SA1110 share the same function calls
- */
-	.type	sa1100_processor_functions, #object
-ENTRY(sa1100_processor_functions)
-	.word	v4_early_abort
-	.word	cpu_sa1100_check_bugs
-	.word	cpu_sa1100_proc_init
-	.word	cpu_sa1100_proc_fin
-	.word	cpu_sa1100_reset
-	.word	cpu_sa1100_do_idle
-
-	/* cache */
-	.word	cpu_sa1100_cache_clean_invalidate_all
-	.word	cpu_sa1100_cache_clean_invalidate_range
-
-	/* dcache */
-	.word	cpu_sa1100_dcache_invalidate_range
-	.word	cpu_sa1100_dcache_clean_range
-	.word	cpu_sa1100_dcache_clean_page
-	.word	cpu_sa1100_dcache_clean_entry
-
-	/* icache */
-	.word	cpu_sa1100_icache_invalidate_range
-	.word	cpu_sa1100_icache_invalidate_page
-
-	/* pgtable */
-	.word	cpu_sa1100_set_pgd
-	.word	cpu_sa1100_flush_pmd
-	.word	cpu_sa1100_set_pte
-
-	.size	sa1100_processor_functions, . - sa1100_processor_functions
-
 	.type	cpu_arch_name, #object
 cpu_arch_name:
 	.asciz	"armv4"
@@ -591,7 +240,6 @@
 
 	.section ".proc.info", #alloc, #execinstr
 
-#ifdef CONFIG_CPU_SA110
 	.type	__sa110_proc_info,#object
 __sa110_proc_info:
 	.long	0x4401a100
@@ -605,37 +253,5 @@
 	.long	sa110_processor_functions
 	.long	v4wb_tlb_fns
 	.long	v4wb_user_fns
+	.long	v4wb_cache_fns
 	.size	__sa110_proc_info, . - __sa110_proc_info
-#endif
-
-#ifdef CONFIG_CPU_SA1100
-	.type	__sa1100_proc_info,#object
-__sa1100_proc_info:
-	.long	0x4401a110
-	.long	0xfffffff0
-	.long	0x00000c0e
-	b	__sa1100_setup
-	.long	cpu_arch_name
-	.long	cpu_elf_name
-	.long	HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
-	.long	cpu_sa1100_name
-	.long	sa1100_processor_functions
-	.long	v4wb_tlb_fns
-	.long	v4_mc_user_fns
-	.size	__sa1100_proc_info, . - __sa1100_proc_info
-
-	.type	__sa1110_proc_info,#object
-__sa1110_proc_info:
-	.long	0x6901b110
-	.long	0xfffffff0
-	.long	0x00000c0e
-	b	__sa1100_setup
-	.long	cpu_arch_name
-	.long	cpu_elf_name
-	.long	HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
-	.long	cpu_sa1110_name
-	.long	sa1100_processor_functions
-	.long	v4wb_tlb_fns
-	.long	v4_mc_user_fns
-	.size	__sa1110_proc_info, . - __sa1110_proc_info
-#endif
diff -Nru a/arch/arm/mm/proc-sa1100.S b/arch/arm/mm/proc-sa1100.S
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/arch/arm/mm/proc-sa1100.S	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,297 @@
+/*
+ *  linux/arch/arm/mm/proc-sa110.S
+ *
+ *  Copyright (C) 1997-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.
+ *
+ *  MMU functions for SA110
+ *
+ *  These are the low level assembler for performing cache and TLB
+ *  functions on the StrongARM-1100 and StrongARM-1110.
+ *
+ *  Note that SA1100 and SA1110 share everything but their name and CPU ID.
+ *
+ *  12-jun-2000, Erik Mouw (J.A.K.Mouw@its.tudelft.nl):
+ *    Flush the read buffer at context switches
+ */
+#include <linux/linkage.h>
+#include <linux/init.h>
+#include <asm/assembler.h>
+#include <asm/constants.h>
+#include <asm/procinfo.h>
+#include <asm/hardware.h>
+#include <asm/proc/pgtable.h>
+
+/*
+ * the cache line size of the I and D cache
+ */
+#define DCACHELINESIZE	32
+#define FLUSH_OFFSET	32768
+
+	.macro flush_1100_dcache rd, ra, re
+	ldr	\rd, =flush_base
+	ldr	\ra, [\rd]
+	eor	\ra, \ra, #FLUSH_OFFSET
+	str	\ra, [\rd]
+	add	\re, \ra, #8192			@ only necessary for 8k
+1001:	ldr	\rd, [\ra], #DCACHELINESIZE
+	teq	\re, \ra
+	bne	1001b
+#ifdef FLUSH_BASE_MINICACHE
+	add	\ra, \ra, #FLUSH_BASE_MINICACHE - FLUSH_BASE
+	add	\re, \ra, #512			@ only 512 bytes
+1002:	ldr	\rd, [\ra], #DCACHELINESIZE
+	teq	\re, \ra
+	bne	1002b
+#endif
+	.endm
+
+	.data
+flush_base:
+	.long	FLUSH_BASE
+	.text
+
+	__INIT
+
+/*
+ * cpu_sa1100_proc_init()
+ */
+ENTRY(cpu_sa1100_proc_init)
+	mov	r0, #0
+	mcr	p15, 0, r0, c15, c1, 2		@ Enable clock switching
+	mcr	p15, 0, r0, c9, c0, 5		@ Allow read-buffer operations from userland
+	mov	pc, lr
+
+	.previous
+
+/*
+ * cpu_sa1100_proc_fin()
+ *
+ * Prepare the CPU for reset:
+ *  - Disable interrupts
+ *  - Clean and turn off caches.
+ */
+ENTRY(cpu_sa1100_proc_fin)
+	stmfd	sp!, {lr}
+	mov	ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
+	msr	cpsr_c, ip
+	flush_1100_dcache r0, r1, r2		@ clean caches
+	mov	r0, #0
+	mcr	p15, 0, r0, c15, c2, 2		@ Disable clock switching
+	mrc	p15, 0, r0, c1, c0, 0		@ ctrl register
+	bic	r0, r0, #0x1000			@ ...i............
+	bic	r0, r0, #0x000e			@ ............wca.
+	mcr	p15, 0, r0, c1, c0, 0		@ disable caches
+	ldmfd	sp!, {pc}
+
+/*
+ * cpu_sa1100_reset(loc)
+ *
+ * Perform a soft reset of the system.  Put the CPU into the
+ * same state as it would be if it had been reset, and branch
+ * to what would be the reset vector.
+ *
+ * loc: location to jump to for soft reset
+ */
+	.align	5
+ENTRY(cpu_sa1100_reset)
+	mov	ip, #0
+	mcr	p15, 0, ip, c7, c7, 0		@ invalidate I,D caches
+	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
+	mcr	p15, 0, ip, c8, c7, 0		@ invalidate I & D TLBs
+	mrc	p15, 0, ip, c1, c0, 0		@ ctrl register
+	bic	ip, ip, #0x000f			@ ............wcam
+	bic	ip, ip, #0x1100			@ ...i...s........
+	mcr	p15, 0, ip, c1, c0, 0		@ ctrl register
+	mov	pc, r0
+
+/*
+ * cpu_sa1100_do_idle(type)
+ *
+ * Cause the processor to idle
+ *
+ * type: call type:
+ *   0 = slow idle
+ *   1 = fast idle
+ *   2 = switch to slow processor clock
+ *   3 = switch to fast processor clock
+ */
+	.align	5
+ENTRY(cpu_sa1100_do_idle)
+	mov	r0, r0				@ 4 nop padding
+	mov	r0, r0
+	mov	r0, r0
+	mov	r0, r0				@ 4 nop padding
+	mov	r0, r0
+	mov	r0, r0
+	mov	r0, #0
+	ldr	r1, =UNCACHEABLE_ADDR		@ ptr to uncacheable address
+	@ --- aligned to a cache line
+	mcr	p15, 0, r0, c15, c2, 2		@ disable clock switching
+	ldr	r1, [r1, #0]			@ force switch to MCLK
+	mcr	p15, 0, r0, c15, c8, 2		@ wait for interrupt
+	mov	r0, r0				@ safety
+	mcr	p15, 0, r0, c15, c1, 2		@ enable clock switching
+	mov	pc, lr
+
+/* ================================= CACHE ================================ */
+
+/*
+ * cpu_sa1100_dcache_clean_area(addr,sz)
+ *
+ * Clean the specified entry of any caches such that the MMU
+ * translation fetches will obtain correct data.
+ *
+ * addr: cache-unaligned virtual address
+ */
+	.align	5
+ENTRY(cpu_sa1100_dcache_clean_area)
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	add	r0, r0, #DCACHELINESIZE
+	subs	r1, r1, #DCACHELINESIZE
+	bhi	1b
+	mov	pc, lr
+
+/* =============================== PageTable ============================== */
+
+/*
+ * cpu_sa1100_switch_mm(pgd)
+ *
+ * Set the translation base pointer to be as described by pgd.
+ *
+ * pgd: new page tables
+ */
+	.align	5
+ENTRY(cpu_sa1100_switch_mm)
+	flush_1100_dcache r3, ip, r1
+	mov	ip, #0
+	mcr	p15, 0, ip, c7, c5, 0		@ invalidate I cache
+	mcr	p15, 0, ip, c9, c0, 0		@ invalidate RB
+	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
+	mcr	p15, 0, r0, c2, c0, 0		@ load page table pointer
+	mcr	p15, 0, ip, c8, c7, 0		@ invalidate I & D TLBs
+	mov	pc, lr
+
+/*
+ * cpu_sa1100_set_pte(ptep, pte)
+ *
+ * Set a PTE and flush it out
+ */
+	.align	5
+ENTRY(cpu_sa1100_set_pte)
+	str	r1, [r0], #-2048		@ linux version
+
+	eor	r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
+
+	bic	r2, r1, #0xff0
+	bic	r2, r2, #3
+	orr	r2, r2, #PTE_TYPE_SMALL
+
+	tst	r1, #L_PTE_USER			@ User or Exec?
+	orrne	r2, r2, #PTE_SMALL_AP_URO_SRW
+
+	tst	r1, #L_PTE_WRITE | L_PTE_DIRTY	@ Write and Dirty?
+	orreq	r2, r2, #PTE_SMALL_AP_UNO_SRW
+
+	tst	r1, #L_PTE_PRESENT | L_PTE_YOUNG	@ Present and Young?
+	movne	r2, #0
+
+	str	r2, [r0]			@ hardware version
+	mov	r0, r0
+	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
+	mov	pc, lr
+
+
+cpu_sa1100_name:
+	.asciz	"StrongARM-1100"
+cpu_sa1110_name:
+	.asciz	"StrongARM-1110"
+	.align
+
+	__INIT
+
+__sa1100_setup:
+	mov	r10, #0
+	mcr	p15, 0, r10, c7, c7		@ invalidate I,D caches on v4
+	mcr	p15, 0, r10, c7, c10, 4		@ drain write buffer on v4
+	mcr	p15, 0, r10, c8, c7		@ invalidate I,D TLBs on v4
+	mov	r0, #0x1f			@ Domains 0, 1 = client
+	mcr	p15, 0, r0, c3, c0		@ load domain access register
+	mcr	p15, 0, r4, c2, c0		@ load page table pointer
+	mrc	p15, 0, r0, c1, c0		@ get control register v4
+	bic	r0, r0, #0x0e00			@ ..VI ZFRS BLDP WCAM
+	bic	r0, r0, #0x0002			@ .... 000. .... ..0.
+	orr	r0, r0, #0x003d
+	orr	r0, r0, #0x3100			@ ..11 ...1 ..11 11.1
+	mov	pc, lr
+
+	.text
+
+/*
+ * Purpose : Function pointers used to access above functions - all calls
+ *	     come through these
+ */
+
+/*
+ * SA1100 and SA1110 share the same function calls
+ */
+	.type	sa1100_processor_functions, #object
+ENTRY(sa1100_processor_functions)
+	.word	v4_early_abort
+	.word	cpu_sa1100_proc_init
+	.word	cpu_sa1100_proc_fin
+	.word	cpu_sa1100_reset
+	.word	cpu_sa1100_do_idle
+	.word	cpu_sa1100_dcache_clean_area
+	.word	cpu_sa1100_switch_mm
+	.word	cpu_sa1100_set_pte
+	.size	sa1100_processor_functions, . - sa1100_processor_functions
+
+	.type	cpu_arch_name, #object
+cpu_arch_name:
+	.asciz	"armv4"
+	.size	cpu_arch_name, . - cpu_arch_name
+
+	.type	cpu_elf_name, #object
+cpu_elf_name:
+	.asciz	"v4"
+	.size	cpu_elf_name, . - cpu_elf_name
+	.align
+
+	.section ".proc.info", #alloc, #execinstr
+
+	.type	__sa1100_proc_info,#object
+__sa1100_proc_info:
+	.long	0x4401a110
+	.long	0xfffffff0
+	.long	0x00000c0e
+	b	__sa1100_setup
+	.long	cpu_arch_name
+	.long	cpu_elf_name
+	.long	HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
+	.long	cpu_sa1100_name
+	.long	sa1100_processor_functions
+	.long	v4wb_tlb_fns
+	.long	v4_mc_user_fns
+	.long	v4wb_cache_fns
+	.size	__sa1100_proc_info, . - __sa1100_proc_info
+
+	.type	__sa1110_proc_info,#object
+__sa1110_proc_info:
+	.long	0x6901b110
+	.long	0xfffffff0
+	.long	0x00000c0e
+	b	__sa1100_setup
+	.long	cpu_arch_name
+	.long	cpu_elf_name
+	.long	HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
+	.long	cpu_sa1110_name
+	.long	sa1100_processor_functions
+	.long	v4wb_tlb_fns
+	.long	v4_mc_user_fns
+	.long	v4wb_cache_fns
+	.size	__sa1110_proc_info, . - __sa1110_proc_info
diff -Nru a/arch/arm/mm/proc-syms.c b/arch/arm/mm/proc-syms.c
--- a/arch/arm/mm/proc-syms.c	Wed Apr 30 22:28:08 2003
+++ b/arch/arm/mm/proc-syms.c	Wed Apr 30 22:28:08 2003
@@ -11,26 +11,26 @@
 #include <linux/mm.h>
 
 #include <asm/cacheflush.h>
-#include <asm/pgalloc.h>
 #include <asm/proc-fns.h>
 #include <asm/tlbflush.h>
 
 EXPORT_SYMBOL(__flush_dcache_page);
 
 #ifndef MULTI_CPU
-EXPORT_SYMBOL(cpu_cache_clean_invalidate_all);
-EXPORT_SYMBOL(cpu_cache_clean_invalidate_range);
-EXPORT_SYMBOL(cpu_dcache_clean_page);
-EXPORT_SYMBOL(cpu_dcache_clean_entry);
-EXPORT_SYMBOL(cpu_dcache_clean_range);
-EXPORT_SYMBOL(cpu_dcache_invalidate_range);
-EXPORT_SYMBOL(cpu_icache_invalidate_range);
-EXPORT_SYMBOL(cpu_icache_invalidate_page);
-EXPORT_SYMBOL(cpu_set_pgd);
-EXPORT_SYMBOL(cpu_flush_pmd);
+EXPORT_SYMBOL(cpu_dcache_clean_area);
 EXPORT_SYMBOL(cpu_set_pte);
 #else
 EXPORT_SYMBOL(processor);
+#endif
+
+#ifndef MULTI_CACHE
+EXPORT_SYMBOL_NOVERS(__cpuc_flush_kern_all);
+EXPORT_SYMBOL_NOVERS(__cpuc_flush_user_all);
+EXPORT_SYMBOL_NOVERS(__cpuc_flush_user_range);
+EXPORT_SYMBOL_NOVERS(__cpuc_coherent_kern_range);
+EXPORT_SYMBOL_NOVERS(__cpuc_flush_dcache_page);
+#else
+EXPORT_SYMBOL(cpu_cache);
 #endif
 
 /*
diff -Nru a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S
--- a/arch/arm/mm/proc-xscale.S	Wed Apr 30 22:28:16 2003
+++ b/arch/arm/mm/proc-xscale.S	Wed Apr 30 22:28:16 2003
@@ -23,10 +23,11 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 #include <asm/assembler.h>
-#include <asm/constants.h>
 #include <asm/procinfo.h>
 #include <asm/hardware.h>
 #include <asm/proc/pgtable.h>
+#include <asm/page.h>
+#include "proc-macros.S"
 
 /*
  * This is the maximum size of an area which will be flushed.  If the area
@@ -45,11 +46,6 @@
 #define CACHESIZE	32768
 
 /*
- * and the page size
- */
-#define PAGESIZE	4096
-
-/*
  * Virtual address used to allocate the cache when flushed
  *
  * This must be an address range which is _never_ used.  It should
@@ -112,15 +108,6 @@
 	.text
 
 /*
- * cpu_xscale_check_bugs()
- */
-ENTRY(cpu_xscale_check_bugs)
-	mrs	ip, cpsr
-	bic	ip, ip, #PSR_F_BIT
-	msr	cpsr, ip
-	mov	pc, lr
-
-/*
  * cpu_xscale_proc_init()
  *
  * Nothing too exciting at the moment
@@ -135,11 +122,11 @@
 	str	lr, [sp, #-4]!
 	mov	r0, #PSR_F_BIT|PSR_I_BIT|SVC_MODE
 	msr	cpsr_c, r0
+	bl	xscale_flush_kern_cache_all	@ clean caches
 	mrc	p15, 0, r0, c1, c0, 0		@ ctrl register
 	bic	r0, r0, #0x1800			@ ...IZ...........
 	bic	r0, r0, #0x0006			@ .............CA.
 	mcr	p15, 0, r0, c1, c0, 0		@ disable caches
-	bl	cpu_xscale_cache_clean_invalidate_all	@ clean caches
 	ldr	pc, [sp], #4
 
 /*
@@ -168,16 +155,10 @@
 	mov	pc, r0
 
 /*
- * cpu_xscale_do_idle(type)
+ * cpu_xscale_do_idle()
  *
  * Cause the processor to idle
  *
- * type:
- *   0 = slow idle
- *   1 = fast idle
- *   2 = switch to slow processor clock
- *   3 = switch to fast processor clock
- *
  * For now we do nothing but go to idle mode for every case
  *
  * XScale supports clock switching, but using idle mode support
@@ -193,226 +174,179 @@
 /* ================================= CACHE ================================ */
 
 /*
- * cpu_xscale_cache_clean_invalidate_all (void)
+ *	flush_user_cache_all()
  *
- * clean and invalidate all cache lines
+ *	Invalidate all cache entries in a particular address
+ *	space.
+ */
+ENTRY(xscale_flush_user_cache_all)
+	/* FALLTHROUGH */
+
+/*
+ *	flush_kern_cache_all()
  *
- * Note:
- *  1. We should preserve r0 at all times.
- *  2. Even if this function implies cache "invalidation" by its name,
- *     we don't need to actually use explicit invalidation operations
- *     since the goal is to discard all valid references from the cache
- *     and the cleaning of it already has that effect.
- *  3. Because of 2 above and the fact that kernel space memory is always
- *     coherent across task switches there is no need to worry about
- *     inconsistencies due to interrupts, ence no irq disabling.
+ *	Clean and invalidate the entire cache.
  */
-	.align	5
-ENTRY(cpu_xscale_cache_clean_invalidate_all)
-	mov	r2, #1
-cpu_xscale_cache_clean_invalidate_all_r2:
+ENTRY(xscale_flush_kern_cache_all)
+	mov	r2, #VM_EXEC
+	mov	ip, #0
+__flush_whole_cache:
 	clean_d_cache r0, r1
-	teq	r2, #0
+	tst	r2, #VM_EXEC
 	mcrne	p15, 0, ip, c7, c5, 0		@ Invalidate I cache & BTB
-	mcr	p15, 0, ip, c7, c10, 4		@ Drain Write (& Fill) Buffer
+	mcrne	p15, 0, ip, c7, c10, 4		@ Drain Write (& Fill) Buffer
 	mov	pc, lr
 
 /*
- * cpu_xscale_cache_clean_invalidate_range(start, end, flags)
+ *	flush_user_cache_range(start, end, vm_flags)
  *
- * clean and invalidate all cache lines associated with this area of memory
+ *	Invalidate a range of cache entries in the specified
+ *	address space.
  *
- * start: Area start address
- * end:   Area end address
- * flags: nonzero for I cache as well
+ *	- start - start address (may not be aligned)
+ *	- end	- end address (exclusive, may not be aligned)
+ *	- vma	- vma_area_struct describing address space
  */
 	.align	5
-ENTRY(cpu_xscale_cache_clean_invalidate_range)
-	bic	r0, r0, #CACHELINESIZE - 1	@ round down to cache line
-	sub	r3, r1, r0
+ENTRY(xscale_flush_user_cache_range)
+	mov	ip, #0
+	sub	r3, r1, r0			@ calculate total size
 	cmp	r3, #MAX_AREA_SIZE
-	bhi	cpu_xscale_cache_clean_invalidate_all_r2
-1:	mcr	p15, 0, r0, c7, c10, 1		@ Clean D cache line
+	bhs	__flush_whole_cache
+
+1:	tst	r2, #VM_EXEC
+	mcrne	p15, 0, r0, c7, c5, 1		@ Invalidate I cache line
+	mcr	p15, 0, r0, c7, c10, 1		@ Clean D cache line
 	mcr	p15, 0, r0, c7, c6, 1		@ Invalidate D cache line
 	add	r0, r0, #CACHELINESIZE
 	cmp	r0, r1
 	blo	1b
-	teq	r2, #0
-	mcr	p15, 0, ip, c7, c10, 4		@ Drain Write (& Fill) Buffer
-	moveq	pc, lr
-	sub	r0, r0, r3
-1:	mcr	p15, 0, r0, c7, c5, 1		@ Invalidate I cache line
-	add	r0, r0, #CACHELINESIZE
-	cmp	r0, r1
-	blo	1b
-	mcr	p15, 0, ip, c7, c5, 6		@ Invalidate BTB
+	tst	r2, #VM_EXEC
+	mcrne	p15, 0, ip, c7, c5, 6		@ Invalidate BTB
+	mcrne	p15, 0, ip, c7, c10, 4		@ Drain Write (& Fill) Buffer
 	mov	pc, lr
 
 /*
- * cpu_xscale_flush_ram_page(page)
+ *	coherent_kern_range(start, end)
  *
- * clean all cache lines associated with this memory page
+ *	Ensure coherency between the Icache and the Dcache in the
+ *	region described by start.  If you have non-snooping
+ *	Harvard caches, you need to implement this function.
  *
- * page: page to clean
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
  */
-	.align	5
-ENTRY(cpu_xscale_flush_ram_page)
-	mov	r1, #PAGESIZE
-1:	mcr	p15, 0, r0, c7, c10, 1		@ Clean D cache line
-	add	r0, r0, #CACHELINESIZE
-	mcr	p15, 0, r0, c7, c10, 1		@ Clean D cache line
+ENTRY(xscale_coherent_kern_range)
+	bic	r0, r0, #CACHELINESIZE - 1
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
 	add	r0, r0, #CACHELINESIZE
-	subs	r1, r1, #2 * CACHELINESIZE
-	bne	1b
-	mcr	p15, 0, ip, c7, c10, 4		@ Drain Write (& Fill) Buffer
+	cmp	r0, r1
+	blo	1b
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c5, 0		@ Invalidate I cache & BTB
+	mcr	p15, 0, r0, c7, c10, 4		@ Drain Write (& Fill) Buffer
 	mov	pc, lr
 
-/* ================================ D-CACHE =============================== */
-
 /*
- * cpu_xscale_dcache_invalidate_range(start, end)
+ *	flush_kern_dcache_page(void *page)
  *
- * throw away all D-cached data in specified region without an obligation
- * to write them back.  Note however that on XScale we must clean all
- * entries also due to hardware errata (80200 A0 & A1 only).
+ *	Ensure no D cache aliasing occurs, either with itself or
+ *	the I cache
  *
- * start: virtual start address
- * end:   virtual end address
+ *	- addr	- page aligned address
  */
-	.align	5
-ENTRY(cpu_xscale_dcache_invalidate_range)
-	mrc	p15, 0, r2, c0, c0, 0		@ Read part no.
-	eor	r2, r2, #0x69000000
-	eor	r2, r2, #0x00052000		@ 80200 XX part no.
-	bics	r2, r2, #0x1			@ Clear LSB in revision field
-	moveq	r2, #0
-	beq	cpu_xscale_cache_clean_invalidate_range	@ An 80200 A0 or A1
-
-	tst	r0, #CACHELINESIZE - 1
-	mcrne	p15, 0, r0, c7, c10, 1		@ Clean D cache line
-	tst	r1, #CACHELINESIZE - 1
-	mcrne	p15, 0, r1, c7, c10, 1		@ Clean D cache line
-	bic	r0, r0, #CACHELINESIZE - 1	@ round down to cache line
-1:	mcr	p15, 0, r0, c7, c6, 1		@ Invalidate D cache line
+ENTRY(xscale_flush_kern_dcache_page)
+	add	r1, r0, #PAGE_SZ
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
 	add	r0, r0, #CACHELINESIZE
 	cmp	r0, r1
 	blo	1b
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c5, 0		@ Invalidate I cache & BTB
+	mcr	p15, 0, r0, c7, c10, 4		@ Drain Write (& Fill) Buffer
 	mov	pc, lr
 
 /*
- * cpu_xscale_dcache_clean_range(start, end)
+ *	dma_inv_range(start, end)
  *
- * For the specified virtual address range, ensure that all caches contain
- * clean data, such that peripheral accesses to the physical RAM fetch
- * correct data.
+ *	Invalidate (discard) the specified virtual address range.
+ *	May not write back any entries.  If 'start' or 'end'
+ *	are not cache line aligned, those lines must be written
+ *	back.
  *
- * start: virtual start address
- * end:   virtual end address
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
  */
-	.align	5
-ENTRY(cpu_xscale_dcache_clean_range)
-	bic	r0, r0, #CACHELINESIZE - 1
-	sub	r2, r1, r0
-	cmp	r2, #MAX_AREA_SIZE
-	movhi	r2, #0
-	bhi	cpu_xscale_cache_clean_invalidate_all_r2
+ENTRY(xscale_dma_inv_range)
+	mrc	p15, 0, r2, c0, c0, 0		@ read ID
+	eor	r2, r2, #0x69000000
+	eor	r2, r2, #0x00052000
+	bics	r2, r2, #1
+	beq	xscale_dma_flush_range
 
-1:	mcr	p15, 0, r0, c7, c10, 1		@ Clean D cache line
-	add	r0, r0, #CACHELINESIZE
-	mcr	p15, 0, r0, c7, c10, 1		@ Clean D cache line
+	tst	r0, #CACHELINESIZE - 1
+	bic	r0, r0, #CACHELINESIZE - 1
+	mcrne	p15, 0, r0, c7, c10, 1		@ clean D entry
+	tst	r1, #CACHELINESIZE - 1
+	mcrne	p15, 0, r1, c7, c10, 1		@ clean D entry
+1:	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
 	add	r0, r0, #CACHELINESIZE
 	cmp	r0, r1
 	blo	1b
-	mcr	p15, 0, ip, c7, c10, 4		@ Drain Write (& Fill) Buffer
+	mcr	p15, 0, r0, c7, c10, 1		@ Drain Write (& Fill) Buffer
 	mov	pc, lr
 
 /*
- * cpu_xscale_clean_dcache_page(page)
+ *	dma_clean_range(start, end)
  *
- * Cleans a single page of dcache so that if we have any future aliased
- * mappings, they will be consistent at the time that they are created.
+ *	Clean the specified virtual address range.
  *
- * Note:
- *  1. we don't need to flush the write buffer in this case. [really? -Nico]
- *  2. we don't invalidate the entries since when we write the page
- *     out to disk, the entries may get reloaded into the cache.
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
  */
-	.align	5
-ENTRY(cpu_xscale_dcache_clean_page)
-	mov	r1, #PAGESIZE
-1:	mcr	p15, 0, r0, c7, c10, 1		@ Clean D cache line
-	add	r0, r0, #CACHELINESIZE
-	mcr	p15, 0, r0, c7, c10, 1		@ Clean D cache line
-	add	r0, r0, #CACHELINESIZE
-	mcr	p15, 0, r0, c7, c10, 1		@ Clean D cache line
-	add	r0, r0, #CACHELINESIZE
-	mcr	p15, 0, r0, c7, c10, 1		@ Clean D cache line
+ENTRY(xscale_dma_clean_range)
+	bic	r0, r0, #CACHELINESIZE - 1
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
 	add	r0, r0, #CACHELINESIZE
-	subs	r1, r1, #4 * CACHELINESIZE
-	bne	1b
-	mcr	p15, 0, ip, c7, c10, 4		@ Drain Write (& Fill) Buffer
-	mov	pc, lr
-
-/*
- * cpu_xscale_dcache_clean_entry(addr)
- *
- * Clean the specified entry of any caches such that the MMU
- * translation fetches will obtain correct data.
- *
- * addr: cache-unaligned virtual address
- */
-	.align	5
-ENTRY(cpu_xscale_dcache_clean_entry)
-	mcr	p15, 0, r0, c7, c10, 1		@ Clean D cache line
-	mcr	p15, 0, ip, c7, c10, 4		@ Drain Write (& Fill) Buffer
+	cmp	r0, r1
+	blo	1b
+	mcr	p15, 0, r0, c7, c10, 1		@ Drain Write (& Fill) Buffer
 	mov	pc, lr
 
-/* ================================ I-CACHE =============================== */
-
 /*
- * cpu_xscale_icache_invalidate_range(start, end)
- *
- * invalidate a range of virtual addresses from the Icache
+ *	dma_flush_range(start, end)
  *
- * start: virtual start address
- * end:   virtual end address
+ *	Clean and invalidate the specified virtual address range.
  *
- * Note: This is vaguely defined as supposed to bring the dcache and the
- *       icache in sync by the way this function is used.
+ *	- start  - virtual start address
+ *	- end	 - virtual end address
  */
-	.align	5
-ENTRY(cpu_xscale_icache_invalidate_range)
+ENTRY(xscale_dma_flush_range)
 	bic	r0, r0, #CACHELINESIZE - 1
-1:	mcr	p15, 0, r0, c7, c10, 1		@ Clean D cache line
-	mcr	p15, 0, r0, c7, c5, 1		@ Invalidate I cache line
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
 	add	r0, r0, #CACHELINESIZE
 	cmp	r0, r1
 	blo	1b
-	mcr	p15, 0, ip, c7, c5, 6		@ Invalidate BTB
-	mcr	p15, 0, ip, c7, c10, 4		@ Drain Write (& Fill) Buffer
+	mcr	p15, 0, r0, c7, c10, 1		@ Drain Write (& Fill) Buffer
 	mov	pc, lr
 
-/*
- * cpu_xscale_icache_invalidate_page(page)
- *
- * invalidate all Icache lines associated with this area of memory
- *
- * page: page to invalidate
- */
-	.align	5
-ENTRY(cpu_xscale_icache_invalidate_page)
-	mov	r1, #PAGESIZE
-1:	mcr	p15, 0, r0, c7, c5, 1		@ Invalidate I cache line
-	add	r0, r0, #CACHELINESIZE
-	mcr	p15, 0, r0, c7, c5, 1		@ Invalidate I cache line
-	add	r0, r0, #CACHELINESIZE
-	mcr	p15, 0, r0, c7, c5, 1		@ Invalidate I cache line
-	add	r0, r0, #CACHELINESIZE
-	mcr	p15, 0, r0, c7, c5, 1		@ Invalidate I cache line
+ENTRY(xscale_cache_fns)
+	.long	xscale_flush_kern_cache_all
+	.long	xscale_flush_user_cache_all
+	.long	xscale_flush_user_cache_range
+	.long	xscale_coherent_kern_range
+	.long	xscale_flush_kern_dcache_page
+	.long	xscale_dma_inv_range
+	.long	xscale_dma_clean_range
+	.long	xscale_dma_flush_range
+
+ENTRY(cpu_xscale_dcache_clean_area)
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
 	add	r0, r0, #CACHELINESIZE
-	subs	r1, r1, #4 * CACHELINESIZE
-	bne	1b
-	mcr	p15, 0, r0, c7, c5, 6		@ Invalidate BTB
+	subs	r1, r1, #CACHELINESIZE
+	bhi	1b
 	mov	pc, lr
 
 /* ================================ CACHE LOCKING============================
@@ -553,18 +487,17 @@
 
 /* =============================== PageTable ============================== */
 
-#define PMD_CACHE_WRITE_ALLOCATE 0
 #define PTE_CACHE_WRITE_ALLOCATE 0
 
 /*
- * cpu_xscale_set_pgd(pgd)
+ * cpu_xscale_switch_mm(pgd)
  *
  * Set the translation base pointer to be as described by pgd.
  *
  * pgd: new page tables
  */
 	.align	5
-ENTRY(cpu_xscale_set_pgd)
+ENTRY(cpu_xscale_switch_mm)
 	clean_d_cache r1, r2
 	mcr	p15, 0, ip, c7, c5, 0		@ Invalidate I cache & BTB
 	mcr	p15, 0, ip, c7, c10, 4		@ Drain Write (& Fill) Buffer
@@ -573,21 +506,6 @@
 	cpwait_ret lr, ip
 
 /*
- * cpu_xscale_flush_pmd(pmdp)
- *
- * Set a level 1 translation table entry, and clean it out of
- * any caches such that the MMUs can load it correctly.
- *
- * pmdp: pointer to PMD entry
- */
-	.align	5
-ENTRY(cpu_xscale_flush_pmd)
-	mov	ip, #0
-	mcr	p15, 0, r0, c7, c10, 1		@ Clean D cache line
-	mcr	p15, 0, ip, c7, c10, 4		@ Drain Write (& Fill) Buffer
-	mov	pc, lr
-
-/*
  * cpu_xscale_set_pte(ptep, pte)
  *
  * Set a PTE and flush it out
@@ -603,7 +521,7 @@
 
 	eor	r3, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
 
-	tst	r3, #L_PTE_USER | L_PTE_EXEC	@ User or Exec?
+	tst	r3, #L_PTE_USER			@ User?
 	orrne	r2, r2, #PTE_EXT_AP_URO_SRW	@ yes -> user r/o, system r/w
 
 	tst	r3, #L_PTE_WRITE | L_PTE_DIRTY	@ Write and Dirty?
@@ -631,12 +549,10 @@
 	@ Erratum 40: The B bit must be cleared for a user read-only
 	@ cacheable page.
 	@
-	@  B = B & ~((U|E) & C & ~W)
+	@  B = B & ~(U & C & ~W)
 	@
-	and	ip, r1, #L_PTE_USER | L_PTE_EXEC | L_PTE_WRITE | L_PTE_CACHEABLE
+	and	ip, r1, #L_PTE_USER | L_PTE_WRITE | L_PTE_CACHEABLE
 	teq	ip, #L_PTE_USER | L_PTE_CACHEABLE
-	teqne	ip, #L_PTE_EXEC | L_PTE_CACHEABLE
-	teqne	ip, #L_PTE_USER | L_PTE_EXEC | L_PTE_CACHEABLE
 	biceq	r2, r2, #PTE_BUFFERABLE
 
 	tst	r3, #L_PTE_PRESENT | L_PTE_YOUNG	@ Present and Young?
@@ -696,30 +612,12 @@
 	.type	xscale_processor_functions, #object
 ENTRY(xscale_processor_functions)
 	.word	xscale_abort
-	.word	cpu_xscale_check_bugs
 	.word	cpu_xscale_proc_init
 	.word	cpu_xscale_proc_fin
 	.word	cpu_xscale_reset
 	.word	cpu_xscale_do_idle
-
-	/* cache */
-	.word	cpu_xscale_cache_clean_invalidate_all
-	.word	cpu_xscale_cache_clean_invalidate_range
-	.word	cpu_xscale_flush_ram_page
-
-	/* dcache */
-	.word	cpu_xscale_dcache_invalidate_range
-	.word	cpu_xscale_dcache_clean_range
-	.word	cpu_xscale_dcache_clean_page
-	.word	cpu_xscale_dcache_clean_entry
-
-	/* icache */
-	.word	cpu_xscale_icache_invalidate_range
-	.word	cpu_xscale_icache_invalidate_page
-
-	/* pgtable */
-	.word	cpu_xscale_set_pgd
-	.word	cpu_xscale_flush_pmd
+	.word	cpu_xscale_dcache_clean_area
+	.word	cpu_xscale_switch_mm
 	.word	cpu_xscale_set_pte
 	.size	xscale_processor_functions, . - xscale_processor_functions
 
@@ -749,6 +647,7 @@
 	.long	xscale_processor_functions
 	.long	v4wbi_tlb_fns
 	.long	xscale_mc_user_fns
+	.long	xscale_cache_fns
 	.size	__80200_proc_info, . - __80200_proc_info
 
 	.type	__80321_proc_info,#object
@@ -780,6 +679,7 @@
 	.long	xscale_processor_functions
 	.long	v4wbi_tlb_fns
 	.long	xscale_mc_user_fns
+	.long	xscale_cache_fns
 	.size	__pxa250_proc_info, . - __pxa250_proc_info
 
 	.type	__pxa210_proc_info,#object
diff -Nru a/arch/arm/nwfpe/ChangeLog b/arch/arm/nwfpe/ChangeLog
--- a/arch/arm/nwfpe/ChangeLog	Wed Apr 30 22:28:09 2003
+++ b/arch/arm/nwfpe/ChangeLog	Wed Apr 30 22:28:09 2003
@@ -1,3 +1,11 @@
+2003-03-22  Ralph Siemsen <ralphs@netwinder.org>
+	* Reformat all but softfloat files to get a consistent coding style.
+	  Used "indent -kr -i8 -ts8 -sob -l132 -ss" and a few manual fixups.
+	* Removed dead code and fixed function protypes to match definitions.
+	* Consolidated use of (opcode && MASK_ARITHMETIC_OPCODE) >> 20.
+	* Make 80-bit precision a compile-time option. (1%)
+	* Only initialize FPE state once in repeat-FP situations. (6%)
+
 2002-01-19  Russell King <rmk@arm.linux.org.uk>
 
 	* fpa11.h - Add documentation
diff -Nru a/arch/arm/nwfpe/Makefile b/arch/arm/nwfpe/Makefile
--- a/arch/arm/nwfpe/Makefile	Wed Apr 30 22:28:03 2003
+++ b/arch/arm/nwfpe/Makefile	Wed Apr 30 22:28:03 2003
@@ -2,18 +2,12 @@
 # Copyright (C) 1998, 1999, 2001 Philip Blundell
 #
 
-obj-y			:=
-obj-m			:=
-obj-n			:=
+obj-$(CONFIG_FPE_NWFPE)		+= nwfpe.o
 
-obj-$(CONFIG_FPE_NWFPE)	+= nwfpe.o
+nwfpe-y				+= fpa11.o fpa11_cpdo.o fpa11_cpdt.o \
+				   fpa11_cprt.o fpmodule.o fpopcode.o \
+				   softfloat.o single_cpdo.o double_cpdo.o
 
-nwfpe-objs		:= fpa11.o fpa11_cpdo.o fpa11_cpdt.o fpa11_cprt.o \
-			   fpmodule.o fpopcode.o softfloat.o \
-			   single_cpdo.o double_cpdo.o extended_cpdo.o
-
-ifeq ($(CONFIG_CPU_26),y)
-nwfpe-objs		+= entry26.o
-else
-nwfpe-objs		+= entry.o
-endif
+nwfpe-$(CONFIG_FPE_NWFPE_XP)	+= extended_cpdo.o
+nwfpe-$(CONFIG_CPU_26)		+= entry26.o
+nwfpe-$(CONFIG_CPU_32)		+= entry.o
diff -Nru a/arch/arm/nwfpe/double_cpdo.c b/arch/arm/nwfpe/double_cpdo.c
--- a/arch/arm/nwfpe/double_cpdo.c	Wed Apr 30 22:28:03 2003
+++ b/arch/arm/nwfpe/double_cpdo.c	Wed Apr 30 22:28:03 2003
@@ -23,6 +23,11 @@
 #include "softfloat.h"
 #include "fpopcode.h"
 
+union float64_components {
+	float64 f64;
+	unsigned int i[2];
+};
+
 float64 float64_exp(float64 Fm);
 float64 float64_ln(float64 Fm);
 float64 float64_sin(float64 rFm);
@@ -32,257 +37,123 @@
 float64 float64_log(float64 rFm);
 float64 float64_tan(float64 rFm);
 float64 float64_arccos(float64 rFm);
-float64 float64_pow(float64 rFn,float64 rFm);
-float64 float64_pol(float64 rFn,float64 rFm);
+float64 float64_pow(float64 rFn, float64 rFm);
+float64 float64_pol(float64 rFn, float64 rFm);
 
-unsigned int DoubleCPDO(const unsigned int opcode)
+static float64 float64_rsf(float64 rFn, float64 rFm)
 {
-   FPA11 *fpa11 = GET_FPA11();
-   float64 rFm, rFn;
-   unsigned int Fd, Fm, Fn, nRc = 1;
-
-   //printk("DoubleCPDO(0x%08x)\n",opcode);
-   
-   Fm = getFm(opcode);
-   if (CONSTANT_FM(opcode))
-   {
-     rFm = getDoubleConstant(Fm);
-   }
-   else
-   {  
-     switch (fpa11->fType[Fm])
-     {
-        case typeSingle:
-          rFm = float32_to_float64(fpa11->fpreg[Fm].fSingle);
-        break;
-
-        case typeDouble:
-          rFm = fpa11->fpreg[Fm].fDouble;
-          break;
-
-        case typeExtended:
-            // !! patb
-	    //printk("not implemented! why not?\n");
-            //!! ScottB
-            // should never get here, if extended involved
-            // then other operand should be promoted then
-            // ExtendedCPDO called.
-            break;
-
-        default: return 0;
-     }
-   }
-
-   if (!MONADIC_INSTRUCTION(opcode))
-   {
-      Fn = getFn(opcode);
-      switch (fpa11->fType[Fn])
-      {
-        case typeSingle:
-          rFn = float32_to_float64(fpa11->fpreg[Fn].fSingle);
-        break;
-
-        case typeDouble:
-          rFn = fpa11->fpreg[Fn].fDouble;
-        break;
-        
-        default: return 0;
-      }
-   }
-
-   Fd = getFd(opcode);
-   /* !! this switch isn't optimized; better (opcode & MASK_ARITHMETIC_OPCODE)>>24, sort of */
-   switch (opcode & MASK_ARITHMETIC_OPCODE)
-   {
-      /* dyadic opcodes */
-      case ADF_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_add(rFn,rFm);
-      break;
-
-      case MUF_CODE:
-      case FML_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_mul(rFn,rFm);
-      break;
-
-      case SUF_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_sub(rFn,rFm);
-      break;
-
-      case RSF_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_sub(rFm,rFn);
-      break;
-
-      case DVF_CODE:
-      case FDV_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_div(rFn,rFm);
-      break;
-
-      case RDF_CODE:
-      case FRD_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_div(rFm,rFn);
-      break;
-
-#if 0
-      case POW_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_pow(rFn,rFm);
-      break;
-
-      case RPW_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_pow(rFm,rFn);
-      break;
-#endif
-
-      case RMF_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_rem(rFn,rFm);
-      break;
-
-#if 0
-      case POL_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_pol(rFn,rFm);
-      break;
-#endif
-
-      /* monadic opcodes */
-      case MVF_CODE:
-         fpa11->fpreg[Fd].fDouble = rFm;
-      break;
-
-      case MNF_CODE:
-      {
-         unsigned int *p = (unsigned int*)&rFm;
-         p[1] ^= 0x80000000;
-         fpa11->fpreg[Fd].fDouble = rFm;
-      }
-      break;
-
-      case ABS_CODE:
-      {
-         unsigned int *p = (unsigned int*)&rFm;
-         p[1] &= 0x7fffffff;
-         fpa11->fpreg[Fd].fDouble = rFm;
-      }
-      break;
-
-      case RND_CODE:
-      case URD_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_round_to_int(rFm);
-      break;
-
-      case SQT_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_sqrt(rFm);
-      break;
-
-#if 0
-      case LOG_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_log(rFm);
-      break;
-
-      case LGN_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_ln(rFm);
-      break;
-
-      case EXP_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_exp(rFm);
-      break;
-
-      case SIN_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_sin(rFm);
-      break;
-
-      case COS_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_cos(rFm);
-      break;
-
-      case TAN_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_tan(rFm);
-      break;
-
-      case ASN_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_arcsin(rFm);
-      break;
-
-      case ACS_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_arccos(rFm);
-      break;
-
-      case ATN_CODE:
-         fpa11->fpreg[Fd].fDouble = float64_arctan(rFm);
-      break;
-#endif
-
-      case NRM_CODE:
-      break;
-      
-      default:
-      {
-        nRc = 0;
-      }
-   }
-
-   if (0 != nRc) fpa11->fType[Fd] = typeDouble;
-   return nRc;
+	return float64_sub(rFm, rFn);
 }
 
-#if 0
-float64 float64_exp(float64 rFm)
+static float64 float64_rdv(float64 rFn, float64 rFm)
 {
-  return rFm;
-//series
+	return float64_div(rFm, rFn);
 }
 
-float64 float64_ln(float64 rFm)
-{
-  return rFm;
-//series
-}
+static float64 (*const dyadic_double[16])(float64 rFn, float64 rFm) = {
+	[ADF_CODE >> 20] = float64_add,
+	[MUF_CODE >> 20] = float64_mul,
+	[SUF_CODE >> 20] = float64_sub,
+	[RSF_CODE >> 20] = float64_rsf,
+	[DVF_CODE >> 20] = float64_div,
+	[RDF_CODE >> 20] = float64_rdv,
+	[RMF_CODE >> 20] = float64_rem,
 
-float64 float64_sin(float64 rFm)
-{
-  return rFm;
-//series
-}
+	/* strictly, these opcodes should not be implemented */
+	[FML_CODE >> 20] = float64_mul,
+	[FDV_CODE >> 20] = float64_div,
+	[FRD_CODE >> 20] = float64_rdv,
+};
 
-float64 float64_cos(float64 rFm)
+static float64 float64_mvf(float64 rFm)
 {
-   return rFm;
-   //series
+	return rFm;
 }
 
-#if 0
-float64 float64_arcsin(float64 rFm)
+static float64 float64_mnf(float64 rFm)
 {
-//series
-}
+	union float64_components u;
 
-float64 float64_arctan(float64 rFm)
-{
-  //series
-}
-#endif
+	u.f64 = rFm;
+	u.i[1] ^= 0x80000000;
 
-float64 float64_log(float64 rFm)
-{
-  return float64_div(float64_ln(rFm),getDoubleConstant(7));
+	return u.f64;
 }
 
-float64 float64_tan(float64 rFm)
+static float64 float64_abs(float64 rFm)
 {
-  return float64_div(float64_sin(rFm),float64_cos(rFm));
-}
+	union float64_components u;
 
-float64 float64_arccos(float64 rFm)
-{
-return rFm;
-   //return float64_sub(halfPi,float64_arcsin(rFm));
-}
+	u.f64 = rFm;
+	u.i[1] &= 0x7fffffff;
 
-float64 float64_pow(float64 rFn,float64 rFm)
-{
-  return float64_exp(float64_mul(rFm,float64_ln(rFn))); 
+	return u.f64;
 }
 
-float64 float64_pol(float64 rFn,float64 rFm)
+static float64 (*const monadic_double[16])(float64 rFm) = {
+	[MVF_CODE >> 20] = float64_mvf,
+	[MNF_CODE >> 20] = float64_mnf,
+	[ABS_CODE >> 20] = float64_abs,
+	[RND_CODE >> 20] = float64_round_to_int,
+	[URD_CODE >> 20] = float64_round_to_int,
+	[SQT_CODE >> 20] = float64_sqrt,
+	[NRM_CODE >> 20] = float64_mvf,
+};
+
+unsigned int DoubleCPDO(const unsigned int opcode, FPREG * rFd)
 {
-  return float64_arctan(float64_div(rFn,rFm)); 
+	FPA11 *fpa11 = GET_FPA11();
+	float64 rFm;
+	unsigned int Fm, opc_mask_shift;
+
+	Fm = getFm(opcode);
+	if (CONSTANT_FM(opcode)) {
+		rFm = getDoubleConstant(Fm);
+	} else {
+		switch (fpa11->fType[Fm]) {
+		case typeSingle:
+			rFm = float32_to_float64(fpa11->fpreg[Fm].fSingle);
+			break;
+
+		case typeDouble:
+			rFm = fpa11->fpreg[Fm].fDouble;
+			break;
+
+		default:
+			return 0;
+		}
+	}
+
+	opc_mask_shift = (opcode & MASK_ARITHMETIC_OPCODE) >> 20;
+	if (!MONADIC_INSTRUCTION(opcode)) {
+		unsigned int Fn = getFn(opcode);
+		float64 rFn;
+
+		switch (fpa11->fType[Fn]) {
+		case typeSingle:
+			rFn = float32_to_float64(fpa11->fpreg[Fn].fSingle);
+			break;
+
+		case typeDouble:
+			rFn = fpa11->fpreg[Fn].fDouble;
+			break;
+
+		default:
+			return 0;
+		}
+
+		if (dyadic_double[opc_mask_shift]) {
+			rFd->fDouble = dyadic_double[opc_mask_shift](rFn, rFm);
+		} else {
+			return 0;
+		}
+	} else {
+		if (monadic_double[opc_mask_shift]) {
+			rFd->fDouble = monadic_double[opc_mask_shift](rFm);
+		} else {
+			return 0;
+		}
+	}
+
+	return 1;
 }
-#endif
diff -Nru a/arch/arm/nwfpe/entry.S b/arch/arm/nwfpe/entry.S
--- a/arch/arm/nwfpe/entry.S	Wed Apr 30 22:28:03 2003
+++ b/arch/arm/nwfpe/entry.S	Wed Apr 30 22:28:03 2003
@@ -72,37 +72,37 @@
 
 	.globl	nwfpe_enter
 nwfpe_enter:
-        mov r4, lr			@ save the failure-return addresses
-	mov sl, sp
+	mov	r4, lr			@ save the failure-return addresses
+	mov	sl, sp			@ we access the registers via 'sl'
 
-        ldr r5, [sp, #60]	 	@ get contents of PC;
+	ldr	r5, [sp, #60]		@ get contents of PC;
 emulate:
-	bl EmulateAll			@ emulate the instruction
-   	cmp r0, #0			@ was emulation successful
-        moveq pc, r4			@ no, return failure
+	bl	EmulateAll		@ emulate the instruction
+	cmp	r0, #0			@ was emulation successful
+	moveq	pc, r4			@ no, return failure
 
 next:
-.Lx1:	ldrt r6, [r5], #4		@ get the next instruction and
+.Lx1:	ldrt	r6, [r5], #4		@ get the next instruction and
 					@ increment PC
 
-	and   r2, r6, #0x0F000000	@ test for FP insns
-        teq   r2, #0x0C000000
-        teqne r2, #0x0D000000
-        teqne r2, #0x0E000000
-        movne pc, r9			@ return ok if not a fp insn
-
-        str r5, [sp, #60]		@ update PC copy in regs
-
-        mov r0, r6			@ save a copy
-        ldr r1, [sp, #64]		@ fetch the condition codes
-   	bl  checkCondition		@ check the condition
-   	cmp r0, #0			@ r0 = 0 ==> condition failed
-
-        @ if condition code failed to match, next insn
-   	beq next			@ get the next instruction;
-   	    
-        mov r0, r6			@ prepare for EmulateAll()
-   	b emulate			@ if r0 != 0, goto EmulateAll
+	and	r2, r6, #0x0F000000	@ test for FP insns
+	teq	r2, #0x0C000000
+	teqne	r2, #0x0D000000
+	teqne	r2, #0x0E000000
+	movne	pc, r9			@ return ok if not a fp insn
+
+	str	r5, [sp, #60]		@ update PC copy in regs
+
+	mov	r0, r6			@ save a copy
+	ldr	r1, [sp, #64]		@ fetch the condition codes
+	bl	checkCondition		@ check the condition
+	cmp	r0, #0			@ r0 = 0 ==> condition failed
+
+	@ if condition code failed to match, next insn
+	beq	next			@ get the next instruction;
+
+	mov	r0, r6			@ prepare for EmulateAll()
+	b	emulate			@ if r0 != 0, goto EmulateAll
 
 	@ We need to be prepared for the instructions at .Lx1 and .Lx2 
 	@ to fault.  Emit the appropriate exception gunk to fix things up.
diff -Nru a/arch/arm/nwfpe/entry26.S b/arch/arm/nwfpe/entry26.S
--- a/arch/arm/nwfpe/entry26.S	Wed Apr 30 22:28:07 2003
+++ b/arch/arm/nwfpe/entry26.S	Wed Apr 30 22:28:07 2003
@@ -66,7 +66,6 @@
 	.globl	nwfpe_enter
 nwfpe_enter:
 	mov	sl, sp
-
 	ldr	r5, [sp, #60]		@ get contents of PC
 	bic	r5, r5, #0xfc000003
 	ldr	r0, [r5, #-4]		@ get actual instruction into r0
@@ -96,7 +95,7 @@
 
 	@ if condition code failed to match, next insn
 	beq	next			@ get the next instruction;
-	    
+
 	mov	r0, r6			@ prepare for EmulateAll()
 	adr	lr, 1b
 	orr	lr, lr, #3
diff -Nru a/arch/arm/nwfpe/extended_cpdo.c b/arch/arm/nwfpe/extended_cpdo.c
--- a/arch/arm/nwfpe/extended_cpdo.c	Wed Apr 30 22:28:10 2003
+++ b/arch/arm/nwfpe/extended_cpdo.c	Wed Apr 30 22:28:10 2003
@@ -32,242 +32,123 @@
 floatx80 floatx80_log(floatx80 rFm);
 floatx80 floatx80_tan(floatx80 rFm);
 floatx80 floatx80_arccos(floatx80 rFm);
-floatx80 floatx80_pow(floatx80 rFn,floatx80 rFm);
-floatx80 floatx80_pol(floatx80 rFn,floatx80 rFm);
+floatx80 floatx80_pow(floatx80 rFn, floatx80 rFm);
+floatx80 floatx80_pol(floatx80 rFn, floatx80 rFm);
 
-unsigned int ExtendedCPDO(const unsigned int opcode)
+static floatx80 floatx80_rsf(floatx80 rFn, floatx80 rFm)
 {
-   FPA11 *fpa11 = GET_FPA11();
-   floatx80 rFm, rFn;
-   unsigned int Fd, Fm, Fn, nRc = 1;
-
-   //printk("ExtendedCPDO(0x%08x)\n",opcode);
-   
-   Fm = getFm(opcode);
-   if (CONSTANT_FM(opcode))
-   {
-     rFm = getExtendedConstant(Fm);
-   }
-   else
-   {  
-     switch (fpa11->fType[Fm])
-     {
-        case typeSingle:
-          rFm = float32_to_floatx80(fpa11->fpreg[Fm].fSingle);
-        break;
-
-        case typeDouble:
-          rFm = float64_to_floatx80(fpa11->fpreg[Fm].fDouble);
-        break;
-        
-        case typeExtended:
-          rFm = fpa11->fpreg[Fm].fExtended;
-        break;
-        
-        default: return 0;
-     }
-   }
-   
-   if (!MONADIC_INSTRUCTION(opcode))
-   {
-      Fn = getFn(opcode);
-      switch (fpa11->fType[Fn])
-      {
-        case typeSingle:
-          rFn = float32_to_floatx80(fpa11->fpreg[Fn].fSingle);
-        break;
-
-        case typeDouble:
-          rFn = float64_to_floatx80(fpa11->fpreg[Fn].fDouble);
-        break;
-        
-        case typeExtended:
-          rFn = fpa11->fpreg[Fn].fExtended;
-        break;
-        
-        default: return 0;
-      }
-   }
-
-   Fd = getFd(opcode);
-   switch (opcode & MASK_ARITHMETIC_OPCODE)
-   {
-      /* dyadic opcodes */
-      case ADF_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_add(rFn,rFm);
-      break;
-
-      case MUF_CODE:
-      case FML_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_mul(rFn,rFm);
-      break;
-
-      case SUF_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_sub(rFn,rFm);
-      break;
-
-      case RSF_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_sub(rFm,rFn);
-      break;
-
-      case DVF_CODE:
-      case FDV_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_div(rFn,rFm);
-      break;
-
-      case RDF_CODE:
-      case FRD_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_div(rFm,rFn);
-      break;
-
-#if 0
-      case POW_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_pow(rFn,rFm);
-      break;
-
-      case RPW_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_pow(rFm,rFn);
-      break;
-#endif
-
-      case RMF_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_rem(rFn,rFm);
-      break;
-
-#if 0
-      case POL_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_pol(rFn,rFm);
-      break;
-#endif
-
-      /* monadic opcodes */
-      case MVF_CODE:
-         fpa11->fpreg[Fd].fExtended = rFm;
-      break;
-
-      case MNF_CODE:
-         rFm.high ^= 0x8000;
-         fpa11->fpreg[Fd].fExtended = rFm;
-      break;
-
-      case ABS_CODE:
-         rFm.high &= 0x7fff;
-         fpa11->fpreg[Fd].fExtended = rFm;
-      break;
-
-      case RND_CODE:
-      case URD_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_round_to_int(rFm);
-      break;
-
-      case SQT_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_sqrt(rFm);
-      break;
-
-#if 0
-      case LOG_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_log(rFm);
-      break;
-
-      case LGN_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_ln(rFm);
-      break;
-
-      case EXP_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_exp(rFm);
-      break;
-
-      case SIN_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_sin(rFm);
-      break;
-
-      case COS_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_cos(rFm);
-      break;
-
-      case TAN_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_tan(rFm);
-      break;
-
-      case ASN_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_arcsin(rFm);
-      break;
-
-      case ACS_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_arccos(rFm);
-      break;
-
-      case ATN_CODE:
-         fpa11->fpreg[Fd].fExtended = floatx80_arctan(rFm);
-      break;
-#endif
-
-      case NRM_CODE:
-      break;
-      
-      default:
-      {
-        nRc = 0;
-      }
-   }
-   
-   if (0 != nRc) fpa11->fType[Fd] = typeExtended;
-   return nRc;
+	return floatx80_sub(rFm, rFn);
 }
 
-#if 0
-floatx80 floatx80_exp(floatx80 Fm)
+static floatx80 floatx80_rdv(floatx80 rFn, floatx80 rFm)
 {
-//series
+	return floatx80_div(rFm, rFn);
 }
 
-floatx80 floatx80_ln(floatx80 Fm)
-{
-//series
-}
+static floatx80 (*const dyadic_extended[16])(floatx80 rFn, floatx80 rFm) = {
+	[ADF_CODE >> 20] = floatx80_add,
+	[MUF_CODE >> 20] = floatx80_mul,
+	[SUF_CODE >> 20] = floatx80_sub,
+	[RSF_CODE >> 20] = floatx80_rsf,
+	[DVF_CODE >> 20] = floatx80_div,
+	[RDF_CODE >> 20] = floatx80_rdv,
+	[RMF_CODE >> 20] = floatx80_rem,
 
-floatx80 floatx80_sin(floatx80 rFm)
-{
-//series
-}
+	/* strictly, these opcodes should not be implemented */
+	[FML_CODE >> 20] = floatx80_mul,
+	[FDV_CODE >> 20] = floatx80_div,
+	[FRD_CODE >> 20] = floatx80_rdv,
+};
 
-floatx80 floatx80_cos(floatx80 rFm)
+static floatx80 floatx80_mvf(floatx80 rFm)
 {
-//series
+	return rFm;
 }
 
-floatx80 floatx80_arcsin(floatx80 rFm)
+static floatx80 floatx80_mnf(floatx80 rFm)
 {
-//series
+	rFm.high ^= 0x8000;
+	return rFm;
 }
 
-floatx80 floatx80_arctan(floatx80 rFm)
+static floatx80 floatx80_abs(floatx80 rFm)
 {
-  //series
+	rFm.high &= 0x7fff;
+	return rFm;
 }
 
-floatx80 floatx80_log(floatx80 rFm)
-{
-  return floatx80_div(floatx80_ln(rFm),getExtendedConstant(7));
-}
+static floatx80 (*const monadic_extended[16])(floatx80 rFm) = {
+	[MVF_CODE >> 20] = floatx80_mvf,
+	[MNF_CODE >> 20] = floatx80_mnf,
+	[ABS_CODE >> 20] = floatx80_abs,
+	[RND_CODE >> 20] = floatx80_round_to_int,
+	[URD_CODE >> 20] = floatx80_round_to_int,
+	[SQT_CODE >> 20] = floatx80_sqrt,
+	[NRM_CODE >> 20] = floatx80_mvf,
+};
 
-floatx80 floatx80_tan(floatx80 rFm)
+unsigned int ExtendedCPDO(const unsigned int opcode, FPREG * rFd)
 {
-  return floatx80_div(floatx80_sin(rFm),floatx80_cos(rFm));
-}
+	FPA11 *fpa11 = GET_FPA11();
+	floatx80 rFm;
+	unsigned int Fm, opc_mask_shift;
 
-floatx80 floatx80_arccos(floatx80 rFm)
-{
-   //return floatx80_sub(halfPi,floatx80_arcsin(rFm));
-}
+	Fm = getFm(opcode);
+	if (CONSTANT_FM(opcode)) {
+		rFm = getExtendedConstant(Fm);
+	} else {
+		switch (fpa11->fType[Fm]) {
+		case typeSingle:
+			rFm = float32_to_floatx80(fpa11->fpreg[Fm].fSingle);
+			break;
 
-floatx80 floatx80_pow(floatx80 rFn,floatx80 rFm)
-{
-  return floatx80_exp(floatx80_mul(rFm,floatx80_ln(rFn))); 
-}
+		case typeDouble:
+			rFm = float64_to_floatx80(fpa11->fpreg[Fm].fDouble);
+			break;
 
-floatx80 floatx80_pol(floatx80 rFn,floatx80 rFm)
-{
-  return floatx80_arctan(floatx80_div(rFn,rFm)); 
+		case typeExtended:
+			rFm = fpa11->fpreg[Fm].fExtended;
+			break;
+
+		default:
+			return 0;
+		}
+	}
+
+	opc_mask_shift = (opcode & MASK_ARITHMETIC_OPCODE) >> 20;
+	if (!MONADIC_INSTRUCTION(opcode)) {
+		unsigned int Fn = getFn(opcode);
+		floatx80 rFn;
+
+		switch (fpa11->fType[Fn]) {
+		case typeSingle:
+			rFn = float32_to_floatx80(fpa11->fpreg[Fn].fSingle);
+			break;
+
+		case typeDouble:
+			rFn = float64_to_floatx80(fpa11->fpreg[Fn].fDouble);
+			break;
+
+		case typeExtended:
+			rFn = fpa11->fpreg[Fn].fExtended;
+			break;
+
+		default:
+			return 0;
+		}
+
+		if (dyadic_extended[opc_mask_shift]) {
+			rFd->fExtended = dyadic_extended[opc_mask_shift](rFn, rFm);
+		} else {
+			return 0;
+		}
+	} else {
+		if (monadic_extended[opc_mask_shift]) {
+			rFd->fExtended = monadic_extended[opc_mask_shift](rFm);
+		} else {
+			return 0;
+		}
+	}
+
+	return 1;
 }
-#endif
diff -Nru a/arch/arm/nwfpe/fpa11.c b/arch/arm/nwfpe/fpa11.c
--- a/arch/arm/nwfpe/fpa11.c	Wed Apr 30 22:28:08 2003
+++ b/arch/arm/nwfpe/fpa11.c	Wed Apr 30 22:28:08 2003
@@ -1,6 +1,7 @@
 /*
     NetWinder Floating Point Emulator
     (c) Rebel.COM, 1998,1999
+    (c) Philip Blundell, 2001
 
     Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
 
@@ -37,184 +38,105 @@
 /* Reset the FPA11 chip.  Called to initialize and reset the emulator. */
 static void resetFPA11(void)
 {
-  int i;
-  FPA11 *fpa11 = GET_FPA11();
-  
-  /* initialize the register type array */
-  for (i=0;i<=7;i++)
-  {
-    fpa11->fType[i] = typeNone;
-  }
-  
-  /* FPSR: set system id to FP_EMULATOR, set AC, clear all other bits */
-  fpa11->fpsr = FP_EMULATOR | BIT_AC;
-  
-  /* FPCR: set SB, AB and DA bits, clear all others */
-#if MAINTAIN_FPCR
-  fpa11->fpcr = MASK_RESET;
-#endif
+	int i;
+	FPA11 *fpa11 = GET_FPA11();
+
+	/* initialize the register type array */
+	for (i = 0; i <= 7; i++) {
+		fpa11->fType[i] = typeNone;
+	}
+
+	/* FPSR: set system id to FP_EMULATOR, set AC, clear all other bits */
+	fpa11->fpsr = FP_EMULATOR | BIT_AC;
 }
 
 void SetRoundingMode(const unsigned int opcode)
 {
-#if MAINTAIN_FPCR
-   FPA11 *fpa11 = GET_FPA11();
-   fpa11->fpcr &= ~MASK_ROUNDING_MODE;
-#endif   
-   switch (opcode & MASK_ROUNDING_MODE)
-   {
-      default:
-      case ROUND_TO_NEAREST:
-         float_rounding_mode = float_round_nearest_even;
-#if MAINTAIN_FPCR         
-         fpa11->fpcr |= ROUND_TO_NEAREST;
-#endif         
-      break;
-      
-      case ROUND_TO_PLUS_INFINITY:
-         float_rounding_mode = float_round_up;
-#if MAINTAIN_FPCR         
-         fpa11->fpcr |= ROUND_TO_PLUS_INFINITY;
-#endif         
-      break;
-      
-      case ROUND_TO_MINUS_INFINITY:
-         float_rounding_mode = float_round_down;
-#if MAINTAIN_FPCR         
-         fpa11->fpcr |= ROUND_TO_MINUS_INFINITY;
-#endif         
-      break;
-      
-      case ROUND_TO_ZERO:
-         float_rounding_mode = float_round_to_zero;
-#if MAINTAIN_FPCR         
-         fpa11->fpcr |= ROUND_TO_ZERO;
-#endif         
-      break;
-  }
+	switch (opcode & MASK_ROUNDING_MODE) {
+	default:
+	case ROUND_TO_NEAREST:
+		float_rounding_mode = float_round_nearest_even;
+		break;
+
+	case ROUND_TO_PLUS_INFINITY:
+		float_rounding_mode = float_round_up;
+		break;
+
+	case ROUND_TO_MINUS_INFINITY:
+		float_rounding_mode = float_round_down;
+		break;
+
+	case ROUND_TO_ZERO:
+		float_rounding_mode = float_round_to_zero;
+		break;
+	}
 }
 
 void SetRoundingPrecision(const unsigned int opcode)
 {
-#if MAINTAIN_FPCR
-   FPA11 *fpa11 = GET_FPA11();
-   fpa11->fpcr &= ~MASK_ROUNDING_PRECISION;
-#endif   
-   switch (opcode & MASK_ROUNDING_PRECISION)
-   {
-      case ROUND_SINGLE:
-         floatx80_rounding_precision = 32;
-#if MAINTAIN_FPCR         
-         fpa11->fpcr |= ROUND_SINGLE;
-#endif         
-      break;
-      
-      case ROUND_DOUBLE:
-         floatx80_rounding_precision = 64;
-#if MAINTAIN_FPCR         
-         fpa11->fpcr |= ROUND_DOUBLE;
-#endif         
-      break;
-      
-      case ROUND_EXTENDED:
-         floatx80_rounding_precision = 80;
-#if MAINTAIN_FPCR         
-         fpa11->fpcr |= ROUND_EXTENDED;
-#endif         
-      break;
-      
-      default: floatx80_rounding_precision = 80;
-  }
+#ifdef CONFIG_FPE_NWFPE_XP
+	switch (opcode & MASK_ROUNDING_PRECISION) {
+	case ROUND_SINGLE:
+		floatx80_rounding_precision = 32;
+		break;
+
+	case ROUND_DOUBLE:
+		floatx80_rounding_precision = 64;
+		break;
+
+	case ROUND_EXTENDED:
+		floatx80_rounding_precision = 80;
+		break;
+
+	default:
+		floatx80_rounding_precision = 80;
+	}
+#endif
 }
 
-void nwfpe_init(union fp_state *fp)
+void nwfpe_init_fpa(union fp_state *fp)
 {
-  FPA11 *fpa11 = (FPA11 *)fp;
-  memset(fpa11, 0, sizeof(FPA11));
-  resetFPA11();
-  SetRoundingMode(ROUND_TO_NEAREST);
-  SetRoundingPrecision(ROUND_EXTENDED);
-  fpa11->initflag = 1;
+	FPA11 *fpa11 = (FPA11 *)fp;
+#ifdef NWFPE_DEBUG
+	printk("NWFPE: setting up state.\n");
+#endif
+ 	memset(fpa11, 0, sizeof(FPA11));
+	resetFPA11();
+	SetRoundingMode(ROUND_TO_NEAREST);
+	SetRoundingPrecision(ROUND_EXTENDED);
+	fpa11->initflag = 1;
 }
 
 /* Emulate the instruction in the opcode. */
 unsigned int EmulateAll(unsigned int opcode)
 {
-  unsigned int nRc = 1, code;
-
-  code = opcode & 0x00000f00;
-  if (code == 0x00000100 || code == 0x00000200)
-  {
-    /* For coprocessor 1 or 2 (FPA11) */
-    code = opcode & 0x0e000000;
-    if (code == 0x0e000000)
-    {
-      if (opcode & 0x00000010)
-      {
-        /* Emulate conversion opcodes. */
-        /* Emulate register transfer opcodes. */
-        /* Emulate comparison opcodes. */
-        nRc = EmulateCPRT(opcode);
-      }
-      else
-      {
-        /* Emulate monadic arithmetic opcodes. */
-        /* Emulate dyadic arithmetic opcodes. */
-        nRc = EmulateCPDO(opcode);
-      }
-    }
-    else if (code == 0x0c000000)
-    {
-      /* Emulate load/store opcodes. */
-      /* Emulate load/store multiple opcodes. */
-      nRc = EmulateCPDT(opcode);
-    }
-    else
-    {
-      /* Invalid instruction detected.  Return FALSE. */
-      nRc = 0;
-    }
-  }
+	unsigned int code;
 
-  return(nRc);
-}
-
-#if 0
-unsigned int EmulateAll1(unsigned int opcode)
-{
-  switch ((opcode >> 24) & 0xf)
-  {
-     case 0xc:
-     case 0xd:
-       if ((opcode >> 20) & 0x1)
-       {
-          switch ((opcode >> 8) & 0xf)
-          {
-             case 0x1: return PerformLDF(opcode); break;
-             case 0x2: return PerformLFM(opcode); break;
-             default: return 0;
-          }
-       }
-       else
-       {
-          switch ((opcode >> 8) & 0xf)
-          {
-             case 0x1: return PerformSTF(opcode); break;
-             case 0x2: return PerformSFM(opcode); break;
-             default: return 0;
-          }
-      }
-     break;
-     
-     case 0xe: 
-       if (opcode & 0x10)
-         return EmulateCPDO(opcode);
-       else
-         return EmulateCPRT(opcode);
-     break;
-  
-     default: return 0;
-  }
-}
+#ifdef NWFPE_DEBUG
+	printk("NWFPE: emulating opcode %08x\n", opcode);
 #endif
+	code = opcode & 0x00000f00;
+	if (code == 0x00000100 || code == 0x00000200) {
+		/* For coprocessor 1 or 2 (FPA11) */
+		code = opcode & 0x0e000000;
+		if (code == 0x0e000000) {
+			if (opcode & 0x00000010) {
+				/* Emulate conversion opcodes. */
+				/* Emulate register transfer opcodes. */
+				/* Emulate comparison opcodes. */
+				return EmulateCPRT(opcode);
+			} else {
+				/* Emulate monadic arithmetic opcodes. */
+				/* Emulate dyadic arithmetic opcodes. */
+				return EmulateCPDO(opcode);
+			}
+		} else if (code == 0x0c000000) {
+			/* Emulate load/store opcodes. */
+			/* Emulate load/store multiple opcodes. */
+			return EmulateCPDT(opcode);
+		}
+	}
 
+	/* Invalid instruction detected.  Return FALSE. */
+	return 0;
+}
diff -Nru a/arch/arm/nwfpe/fpa11.h b/arch/arm/nwfpe/fpa11.h
--- a/arch/arm/nwfpe/fpa11.h	Wed Apr 30 22:28:08 2003
+++ b/arch/arm/nwfpe/fpa11.h	Wed Apr 30 22:28:08 2003
@@ -37,6 +37,7 @@
 
 /* includes */
 #include "fpsr.h"		/* FP control and status register definitions */
+#include "milieu.h"
 #include "softfloat.h"
 
 #define		typeNone		0x00
@@ -48,9 +49,13 @@
  * This must be no more and no less than 12 bytes.
  */
 typedef union tagFPREG {
-   floatx80 fExtended;
-   float64  fDouble;
-   float32  fSingle;
+	float32 fSingle;
+	float64 fDouble;
+#ifdef CONFIG_FPE_NWFPE_XP
+	floatx80 fExtended;
+#else
+	int padding[3];
+#endif
 } FPREG;
 
 /*
@@ -67,21 +72,21 @@
  * not initialise.
  */
 typedef struct tagFPA11 {
-/*   0 */  FPREG fpreg[8];		/* 8 floating point registers */
-/*  96 */  FPSR fpsr;			/* floating point status register */
-/* 100 */  FPCR fpcr;			/* floating point control register */
-/* 104 */  unsigned char fType[8];	/* type of floating point value held in
-					   floating point registers.  One of none
-					   single, double or extended. */
-/* 112 */  int initflag;		/* this is special.  The kernel guarantees
-					   to set it to 0 when a thread is launched,
-					   so we can use it to detect whether this
-					   instance of the emulator needs to be
-					   initialised. */
+/*   0 */ FPREG fpreg[8];	/* 8 floating point registers */
+/*  96 */ FPSR fpsr;		/* floating point status register */
+/* 100 */ FPCR fpcr;		/* floating point control register */
+/* 104 */ unsigned char fType[8];	/* type of floating point value held in
+					   floating point registers.  One of
+					   none, single, double or extended. */
+/* 112 */ int initflag;		/* this is special.  The kernel guarantees
+				   to set it to 0 when a thread is launched,
+				   so we can use it to detect whether this
+				   instance of the emulator needs to be
+				   initialised. */
 } FPA11;
 
 extern void SetRoundingMode(const unsigned int);
 extern void SetRoundingPrecision(const unsigned int);
-extern void nwfpe_init(union fp_state *fp);
+extern void nwfpe_init_fpa(union fp_state *fp);
 
 #endif
diff -Nru a/arch/arm/nwfpe/fpa11.inl b/arch/arm/nwfpe/fpa11.inl
--- a/arch/arm/nwfpe/fpa11.inl	Wed Apr 30 22:28:09 2003
+++ b/arch/arm/nwfpe/fpa11.inl	Wed Apr 30 22:28:09 2003
@@ -24,28 +24,28 @@
 /* Read and write floating point status register */
 extern __inline__ unsigned int readFPSR(void)
 {
-  FPA11 *fpa11 = GET_FPA11();
-  return(fpa11->fpsr);
+	FPA11 *fpa11 = GET_FPA11();
+	return (fpa11->fpsr);
 }
 
 extern __inline__ void writeFPSR(FPSR reg)
 {
-  FPA11 *fpa11 = GET_FPA11();
-  /* the sysid byte in the status register is readonly */
-  fpa11->fpsr = (fpa11->fpsr & MASK_SYSID) | (reg & ~MASK_SYSID);
+	FPA11 *fpa11 = GET_FPA11();
+	/* the sysid byte in the status register is readonly */
+	fpa11->fpsr = (fpa11->fpsr & MASK_SYSID) | (reg & ~MASK_SYSID);
 }
 
 /* Read and write floating point control register */
 extern __inline__ FPCR readFPCR(void)
 {
-  FPA11 *fpa11 = GET_FPA11();
-  /* clear SB, AB and DA bits before returning FPCR */
-  return(fpa11->fpcr & ~MASK_RFC);
+	FPA11 *fpa11 = GET_FPA11();
+	/* clear SB, AB and DA bits before returning FPCR */
+	return (fpa11->fpcr & ~MASK_RFC);
 }
 
 extern __inline__ void writeFPCR(FPCR reg)
 {
-  FPA11 *fpa11 = GET_FPA11();
-  fpa11->fpcr &= ~MASK_WFC;		/* clear SB, AB and DA bits */
-  fpa11->fpcr |= (reg & MASK_WFC);	/* write SB, AB and DA bits */
+	FPA11 *fpa11 = GET_FPA11();
+	fpa11->fpcr &= ~MASK_WFC;		/* clear SB, AB and DA bits */
+	fpa11->fpcr |= (reg & MASK_WFC);	/* write SB, AB and DA bits */
 }
diff -Nru a/arch/arm/nwfpe/fpa11_cpdo.c b/arch/arm/nwfpe/fpa11_cpdo.c
--- a/arch/arm/nwfpe/fpa11_cpdo.c	Wed Apr 30 22:28:13 2003
+++ b/arch/arm/nwfpe/fpa11_cpdo.c	Wed Apr 30 22:28:13 2003
@@ -1,6 +1,7 @@
 /*
     NetWinder Floating Point Emulator
     (c) Rebel.COM, 1998,1999
+    (c) Philip Blundell, 2001
 
     Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
 
@@ -22,96 +23,109 @@
 #include "fpa11.h"
 #include "fpopcode.h"
 
-unsigned int SingleCPDO(const unsigned int opcode);
-unsigned int DoubleCPDO(const unsigned int opcode);
-unsigned int ExtendedCPDO(const unsigned int opcode);
+unsigned int SingleCPDO(const unsigned int opcode, FPREG * rFd);
+unsigned int DoubleCPDO(const unsigned int opcode, FPREG * rFd);
+unsigned int ExtendedCPDO(const unsigned int opcode, FPREG * rFd);
 
 unsigned int EmulateCPDO(const unsigned int opcode)
 {
-   FPA11 *fpa11 = GET_FPA11();
-   unsigned int Fd, nType, nDest, nRc = 1;
-   
-   //printk("EmulateCPDO(0x%08x)\n",opcode);
-
-   /* Get the destination size.  If not valid let Linux perform
-      an invalid instruction trap. */
-   nDest = getDestinationSize(opcode);
-   if (typeNone == nDest) return 0;
-   
-   SetRoundingMode(opcode);
-     
-   /* Compare the size of the operands in Fn and Fm.
-      Choose the largest size and perform operations in that size,
-      in order to make use of all the precision of the operands. 
-      If Fm is a constant, we just grab a constant of a size 
-      matching the size of the operand in Fn. */
-   if (MONADIC_INSTRUCTION(opcode))
-     nType = nDest;
-   else
-     nType = fpa11->fType[getFn(opcode)];
-   
-   if (!CONSTANT_FM(opcode))
-   {
-     register unsigned int Fm = getFm(opcode);
-     if (nType < fpa11->fType[Fm])
-     {
-        nType = fpa11->fType[Fm];
-     }
-   }
-
-   switch (nType)
-   {
-      case typeSingle   : nRc = SingleCPDO(opcode);   break;
-      case typeDouble   : nRc = DoubleCPDO(opcode);   break;
-      case typeExtended : nRc = ExtendedCPDO(opcode); break;
-      default           : nRc = 0;
-   }
-
-   /* If the operation succeeded, check to see if the result in the
-      destination register is the correct size.  If not force it
-      to be. */
-   Fd = getFd(opcode);
-   nType = fpa11->fType[Fd];
-   if ((0 != nRc) && (nDest != nType))
-   {
-     switch (nDest)
-     {
-       case typeSingle:
-       {
-         if (typeDouble == nType)
-           fpa11->fpreg[Fd].fSingle = 
-              float64_to_float32(fpa11->fpreg[Fd].fDouble);
-         else
-           fpa11->fpreg[Fd].fSingle = 
-              floatx80_to_float32(fpa11->fpreg[Fd].fExtended);
-       }
-       break;
-          
-       case typeDouble:
-       {
-         if (typeSingle == nType)
-           fpa11->fpreg[Fd].fDouble = 
-              float32_to_float64(fpa11->fpreg[Fd].fSingle);
-         else
-           fpa11->fpreg[Fd].fDouble = 
-              floatx80_to_float64(fpa11->fpreg[Fd].fExtended);
-       }
-       break;
-          
-       case typeExtended:
-       {
-         if (typeSingle == nType)
-           fpa11->fpreg[Fd].fExtended = 
-              float32_to_floatx80(fpa11->fpreg[Fd].fSingle);
-         else
-           fpa11->fpreg[Fd].fExtended = 
-              float64_to_floatx80(fpa11->fpreg[Fd].fDouble);
-       }
-       break;
-     }
-     
-     fpa11->fType[Fd] = nDest;
-   }
-   
-   return nRc;
+	FPA11 *fpa11 = GET_FPA11();
+	FPREG *rFd;
+	unsigned int nType, nDest, nRc;
+
+	/* Get the destination size.  If not valid let Linux perform
+	   an invalid instruction trap. */
+	nDest = getDestinationSize(opcode);
+	if (typeNone == nDest)
+		return 0;
+
+	SetRoundingMode(opcode);
+
+	/* Compare the size of the operands in Fn and Fm.
+	   Choose the largest size and perform operations in that size,
+	   in order to make use of all the precision of the operands.
+	   If Fm is a constant, we just grab a constant of a size
+	   matching the size of the operand in Fn. */
+	if (MONADIC_INSTRUCTION(opcode))
+		nType = nDest;
+	else
+		nType = fpa11->fType[getFn(opcode)];
+
+	if (!CONSTANT_FM(opcode)) {
+		register unsigned int Fm = getFm(opcode);
+		if (nType < fpa11->fType[Fm]) {
+			nType = fpa11->fType[Fm];
+		}
+	}
+
+	rFd = &fpa11->fpreg[getFd(opcode)];
+
+	switch (nType) {
+	case typeSingle:
+		nRc = SingleCPDO(opcode, rFd);
+		break;
+	case typeDouble:
+		nRc = DoubleCPDO(opcode, rFd);
+		break;
+#ifdef CONFIG_FPE_NWFPE_XP
+	case typeExtended:
+		nRc = ExtendedCPDO(opcode, rFd);
+		break;
+#endif
+	default:
+		nRc = 0;
+	}
+
+	/* The CPDO functions used to always set the destination type
+	   to be the same as their working size. */
+
+	if (nRc != 0) {
+		/* If the operation succeeded, check to see if the result in the
+		   destination register is the correct size.  If not force it
+		   to be. */
+
+		fpa11->fType[getFd(opcode)] = nDest;
+
+#ifdef CONFIG_FPE_NWFPE_XP
+		if (nDest != nType) {
+			switch (nDest) {
+			case typeSingle:
+				{
+					if (typeDouble == nType)
+						rFd->fSingle = float64_to_float32(rFd->fDouble);
+					else
+						rFd->fSingle = floatx80_to_float32(rFd->fExtended);
+				}
+				break;
+
+			case typeDouble:
+				{
+					if (typeSingle == nType)
+						rFd->fDouble = float32_to_float64(rFd->fSingle);
+					else
+						rFd->fDouble = floatx80_to_float64(rFd->fExtended);
+				}
+				break;
+
+			case typeExtended:
+				{
+					if (typeSingle == nType)
+						rFd->fExtended = float32_to_floatx80(rFd->fSingle);
+					else
+						rFd->fExtended = float64_to_floatx80(rFd->fDouble);
+				}
+				break;
+			}
+		}
+#else
+		if (nDest != nType) {
+			if (nDest == typeSingle)
+				rFd->fSingle = float64_to_float32(rFd->fDouble);
+			else
+				rFd->fDouble = float32_to_float64(rFd->fSingle);
+		}
+#endif
+	}
+
+	return nRc;
 }
diff -Nru a/arch/arm/nwfpe/fpa11_cpdt.c b/arch/arm/nwfpe/fpa11_cpdt.c
--- a/arch/arm/nwfpe/fpa11_cpdt.c	Wed Apr 30 22:28:18 2003
+++ b/arch/arm/nwfpe/fpa11_cpdt.c	Wed Apr 30 22:28:18 2003
@@ -1,7 +1,7 @@
 /*
     NetWinder Floating Point Emulator
     (c) Rebel.com, 1998-1999
-    (c) Philip Blundell, 1998
+    (c) Philip Blundell, 1998, 2001
 
     Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
 
@@ -28,341 +28,354 @@
 
 #include <asm/uaccess.h>
 
-static inline
-void loadSingle(const unsigned int Fn,const unsigned int *pMem)
+static inline void loadSingle(const unsigned int Fn, const unsigned int *pMem)
 {
-   FPA11 *fpa11 = GET_FPA11();
-   fpa11->fType[Fn] = typeSingle;
-   get_user(fpa11->fpreg[Fn].fSingle, pMem);
-}
-
-static inline
-void loadDouble(const unsigned int Fn,const unsigned int *pMem)
-{
-   FPA11 *fpa11 = GET_FPA11();
-   unsigned int *p;
-   p = (unsigned int*)&fpa11->fpreg[Fn].fDouble;
-   fpa11->fType[Fn] = typeDouble;
-   get_user(p[0], &pMem[1]);
-   get_user(p[1], &pMem[0]); /* sign & exponent */
-}
-
-static inline
-void loadExtended(const unsigned int Fn,const unsigned int *pMem)
-{
-   FPA11 *fpa11 = GET_FPA11();
-   unsigned int *p;
-   p = (unsigned int*)&fpa11->fpreg[Fn].fExtended;
-   fpa11->fType[Fn] = typeExtended;
-   get_user(p[0], &pMem[0]);  /* sign & exponent */
-   get_user(p[1], &pMem[2]);  /* ls bits */
-   get_user(p[2], &pMem[1]);  /* ms bits */
-}
-
-static inline
-void loadMultiple(const unsigned int Fn,const unsigned int *pMem)
-{
-   FPA11 *fpa11 = GET_FPA11();
-   register unsigned int *p;
-   unsigned long x;
-
-   p = (unsigned int*)&(fpa11->fpreg[Fn]);
-   get_user(x, &pMem[0]);
-   fpa11->fType[Fn] = (x >> 14) & 0x00000003;
-
-   switch (fpa11->fType[Fn])
-   {
-      case typeSingle:
-      case typeDouble:
-      {
-         get_user(p[0], &pMem[2]);  /* Single */
-         get_user(p[1], &pMem[1]);  /* double msw */
-         p[2] = 0;        /* empty */
-      }
-      break;
-
-      case typeExtended:
-      {
-         get_user(p[1], &pMem[2]);
-         get_user(p[2], &pMem[1]);  /* msw */
-         p[0] = (x & 0x80003fff);
-      }
-      break;
-   }
-}
-
-static inline
-void storeSingle(const unsigned int Fn,unsigned int *pMem)
-{
-   FPA11 *fpa11 = GET_FPA11();
-   union
-   {
-     float32 f;
-     unsigned int i[1];
-   } val;
-
-   switch (fpa11->fType[Fn])
-   {
-      case typeDouble:
-         val.f = float64_to_float32(fpa11->fpreg[Fn].fDouble);
-      break;
-
-      case typeExtended:
-         val.f = floatx80_to_float32(fpa11->fpreg[Fn].fExtended);
-      break;
-
-      default: val.f = fpa11->fpreg[Fn].fSingle;
-   }
-
-   put_user(val.i[0], pMem);
-}
-
-static inline
-void storeDouble(const unsigned int Fn,unsigned int *pMem)
-{
-   FPA11 *fpa11 = GET_FPA11();
-   union
-   {
-     float64 f;
-     unsigned int i[2];
-   } val;
-
-   switch (fpa11->fType[Fn])
-   {
-      case typeSingle:
-         val.f = float32_to_float64(fpa11->fpreg[Fn].fSingle);
-      break;
-
-      case typeExtended:
-         val.f = floatx80_to_float64(fpa11->fpreg[Fn].fExtended);
-      break;
-
-      default: val.f = fpa11->fpreg[Fn].fDouble;
-   }
-
-   put_user(val.i[1], &pMem[0]);	/* msw */
-   put_user(val.i[0], &pMem[1]);	/* lsw */
-}
-
-static inline
-void storeExtended(const unsigned int Fn,unsigned int *pMem)
-{
-   FPA11 *fpa11 = GET_FPA11();
-   union
-   {
-     floatx80 f;
-     unsigned int i[3];
-   } val;
-
-   switch (fpa11->fType[Fn])
-   {
-      case typeSingle:
-         val.f = float32_to_floatx80(fpa11->fpreg[Fn].fSingle);
-      break;
-
-      case typeDouble:
-         val.f = float64_to_floatx80(fpa11->fpreg[Fn].fDouble);
-      break;
-
-      default: val.f = fpa11->fpreg[Fn].fExtended;
-   }
-
-   put_user(val.i[0], &pMem[0]); /* sign & exp */
-   put_user(val.i[1], &pMem[2]);
-   put_user(val.i[2], &pMem[1]); /* msw */
-}
-
-static inline
-void storeMultiple(const unsigned int Fn,unsigned int *pMem)
-{
-   FPA11 *fpa11 = GET_FPA11();
-   register unsigned int nType, *p;
-
-   p = (unsigned int*)&(fpa11->fpreg[Fn]);
-   nType = fpa11->fType[Fn];
-
-   switch (nType)
-   {
-      case typeSingle:
-      case typeDouble:
-      {
-	 put_user(p[0], &pMem[2]); /* single */
-	 put_user(p[1], &pMem[1]); /* double msw */
-	 put_user(nType << 14, &pMem[0]);
-      }
-      break;
-
-      case typeExtended:
-      {
-	 put_user(p[2], &pMem[1]); /* msw */
-	 put_user(p[1], &pMem[2]);
-	 put_user((p[0] & 0x80003fff) | (nType << 14), &pMem[0]);
-      }
-      break;
-   }
+	FPA11 *fpa11 = GET_FPA11();
+	fpa11->fType[Fn] = typeSingle;
+	get_user(fpa11->fpreg[Fn].fSingle, pMem);
 }
 
-unsigned int PerformLDF(const unsigned int opcode)
+static inline void loadDouble(const unsigned int Fn, const unsigned int *pMem)
+{
+	FPA11 *fpa11 = GET_FPA11();
+	unsigned int *p;
+	p = (unsigned int *) &fpa11->fpreg[Fn].fDouble;
+	fpa11->fType[Fn] = typeDouble;
+	get_user(p[0], &pMem[1]);
+	get_user(p[1], &pMem[0]);	/* sign & exponent */
+}
+
+#ifdef CONFIG_FPE_NWFPE_XP
+static inline void loadExtended(const unsigned int Fn, const unsigned int *pMem)
+{
+	FPA11 *fpa11 = GET_FPA11();
+	unsigned int *p;
+	p = (unsigned int *) &fpa11->fpreg[Fn].fExtended;
+	fpa11->fType[Fn] = typeExtended;
+	get_user(p[0], &pMem[0]);	/* sign & exponent */
+	get_user(p[1], &pMem[2]);	/* ls bits */
+	get_user(p[2], &pMem[1]);	/* ms bits */
+}
+#endif
+
+static inline void loadMultiple(const unsigned int Fn, const unsigned int *pMem)
 {
-   unsigned int *pBase, *pAddress, *pFinal, nRc = 1,
-     write_back = WRITE_BACK(opcode);
+	FPA11 *fpa11 = GET_FPA11();
+	register unsigned int *p;
+	unsigned long x;
+
+	p = (unsigned int *) &(fpa11->fpreg[Fn]);
+	get_user(x, &pMem[0]);
+	fpa11->fType[Fn] = (x >> 14) & 0x00000003;
+
+	switch (fpa11->fType[Fn]) {
+	case typeSingle:
+	case typeDouble:
+		{
+			get_user(p[0], &pMem[2]);	/* Single */
+			get_user(p[1], &pMem[1]);	/* double msw */
+			p[2] = 0;			/* empty */
+		}
+		break;
+
+#ifdef CONFIG_FPE_NWFPE_XP
+	case typeExtended:
+		{
+			get_user(p[1], &pMem[2]);
+			get_user(p[2], &pMem[1]);	/* msw */
+			p[0] = (x & 0x80003fff);
+		}
+		break;
+#endif
+	}
+}
 
-   //printk("PerformLDF(0x%08x), Fd = 0x%08x\n",opcode,getFd(opcode));
+static inline void storeSingle(const unsigned int Fn, unsigned int *pMem)
+{
+	FPA11 *fpa11 = GET_FPA11();
+	union {
+		float32 f;
+		unsigned int i[1];
+	} val;
+
+	switch (fpa11->fType[Fn]) {
+	case typeDouble:
+		val.f = float64_to_float32(fpa11->fpreg[Fn].fDouble);
+		break;
+
+#ifdef CONFIG_FPE_NWFPE_XP
+	case typeExtended:
+		val.f = floatx80_to_float32(fpa11->fpreg[Fn].fExtended);
+		break;
+#endif
 
-   pBase = (unsigned int*)readRegister(getRn(opcode));
-   if (REG_PC == getRn(opcode))
-   {
-     pBase += 2;
-     write_back = 0;
-   }
-
-   pFinal = pBase;
-   if (BIT_UP_SET(opcode))
-     pFinal += getOffset(opcode);
-   else
-     pFinal -= getOffset(opcode);
-
-   if (PREINDEXED(opcode)) pAddress = pFinal; else pAddress = pBase;
-
-   switch (opcode & MASK_TRANSFER_LENGTH)
-   {
-      case TRANSFER_SINGLE  : loadSingle(getFd(opcode),pAddress);   break;
-      case TRANSFER_DOUBLE  : loadDouble(getFd(opcode),pAddress);   break;
-      case TRANSFER_EXTENDED: loadExtended(getFd(opcode),pAddress); break;
-      default: nRc = 0;
-   }
+	default:
+		val.f = fpa11->fpreg[Fn].fSingle;
+	}
+
+	put_user(val.i[0], pMem);
+}
+
+static inline void storeDouble(const unsigned int Fn, unsigned int *pMem)
+{
+	FPA11 *fpa11 = GET_FPA11();
+	union {
+		float64 f;
+		unsigned int i[2];
+	} val;
+
+	switch (fpa11->fType[Fn]) {
+	case typeSingle:
+		val.f = float32_to_float64(fpa11->fpreg[Fn].fSingle);
+		break;
+
+#ifdef CONFIG_FPE_NWFPE_XP
+	case typeExtended:
+		val.f = floatx80_to_float64(fpa11->fpreg[Fn].fExtended);
+		break;
+#endif
 
-   if (write_back) writeRegister(getRn(opcode),(unsigned int)pFinal);
-   return nRc;
+	default:
+		val.f = fpa11->fpreg[Fn].fDouble;
+	}
+
+	put_user(val.i[1], &pMem[0]);	/* msw */
+	put_user(val.i[0], &pMem[1]);	/* lsw */
+}
+
+#ifdef CONFIG_FPE_NWFPE_XP
+static inline void storeExtended(const unsigned int Fn, unsigned int *pMem)
+{
+	FPA11 *fpa11 = GET_FPA11();
+	union {
+		floatx80 f;
+		unsigned int i[3];
+	} val;
+
+	switch (fpa11->fType[Fn]) {
+	case typeSingle:
+		val.f = float32_to_floatx80(fpa11->fpreg[Fn].fSingle);
+		break;
+
+	case typeDouble:
+		val.f = float64_to_floatx80(fpa11->fpreg[Fn].fDouble);
+		break;
+
+	default:
+		val.f = fpa11->fpreg[Fn].fExtended;
+	}
+
+	put_user(val.i[0], &pMem[0]);	/* sign & exp */
+	put_user(val.i[1], &pMem[2]);
+	put_user(val.i[2], &pMem[1]);	/* msw */
 }
+#endif
 
-unsigned int PerformSTF(const unsigned int opcode)
+static inline void storeMultiple(const unsigned int Fn, unsigned int *pMem)
+{
+	FPA11 *fpa11 = GET_FPA11();
+	register unsigned int nType, *p;
+
+	p = (unsigned int *) &(fpa11->fpreg[Fn]);
+	nType = fpa11->fType[Fn];
+
+	switch (nType) {
+	case typeSingle:
+	case typeDouble:
+		{
+			put_user(p[0], &pMem[2]);	/* single */
+			put_user(p[1], &pMem[1]);	/* double msw */
+			put_user(nType << 14, &pMem[0]);
+		}
+		break;
+
+#ifdef CONFIG_FPE_NWFPE_XP
+	case typeExtended:
+		{
+			put_user(p[2], &pMem[1]);	/* msw */
+			put_user(p[1], &pMem[2]);
+			put_user((p[0] & 0x80003fff) | (nType << 14), &pMem[0]);
+		}
+		break;
+#endif
+	}
+}
+
+unsigned int PerformLDF(const unsigned int opcode)
 {
-   unsigned int *pBase, *pAddress, *pFinal, nRc = 1,
-     write_back = WRITE_BACK(opcode);
+	unsigned int *pBase, *pAddress, *pFinal, nRc = 1,
+	    write_back = WRITE_BACK(opcode);
+
+	pBase = (unsigned int *) readRegister(getRn(opcode));
+	if (REG_PC == getRn(opcode)) {
+		pBase += 2;
+		write_back = 0;
+	}
+
+	pFinal = pBase;
+	if (BIT_UP_SET(opcode))
+		pFinal += getOffset(opcode);
+	else
+		pFinal -= getOffset(opcode);
+
+	if (PREINDEXED(opcode))
+		pAddress = pFinal;
+	else
+		pAddress = pBase;
+
+	switch (opcode & MASK_TRANSFER_LENGTH) {
+	case TRANSFER_SINGLE:
+		loadSingle(getFd(opcode), pAddress);
+		break;
+	case TRANSFER_DOUBLE:
+		loadDouble(getFd(opcode), pAddress);
+		break;
+#ifdef CONFIG_FPE_NWFPE_XP
+	case TRANSFER_EXTENDED:
+		loadExtended(getFd(opcode), pAddress);
+		break;
+#endif
+	default:
+		nRc = 0;
+	}
+
+	if (write_back)
+		writeRegister(getRn(opcode), (unsigned int) pFinal);
+	return nRc;
+}
 
-   //printk("PerformSTF(0x%08x), Fd = 0x%08x\n",opcode,getFd(opcode));
-   SetRoundingMode(ROUND_TO_NEAREST);
+unsigned int PerformSTF(const unsigned int opcode)
+{
+	unsigned int *pBase, *pAddress, *pFinal, nRc = 1,
+	    write_back = WRITE_BACK(opcode);
 
-   pBase = (unsigned int*)readRegister(getRn(opcode));
-   if (REG_PC == getRn(opcode))
-   {
-     pBase += 2;
-     write_back = 0;
-   }
-
-   pFinal = pBase;
-   if (BIT_UP_SET(opcode))
-     pFinal += getOffset(opcode);
-   else
-     pFinal -= getOffset(opcode);
-
-   if (PREINDEXED(opcode)) pAddress = pFinal; else pAddress = pBase;
-
-   switch (opcode & MASK_TRANSFER_LENGTH)
-   {
-      case TRANSFER_SINGLE  : storeSingle(getFd(opcode),pAddress);   break;
-      case TRANSFER_DOUBLE  : storeDouble(getFd(opcode),pAddress);   break;
-      case TRANSFER_EXTENDED: storeExtended(getFd(opcode),pAddress); break;
-      default: nRc = 0;
-   }
+	SetRoundingMode(ROUND_TO_NEAREST);
 
-   if (write_back) writeRegister(getRn(opcode),(unsigned int)pFinal);
-   return nRc;
+	pBase = (unsigned int *) readRegister(getRn(opcode));
+	if (REG_PC == getRn(opcode)) {
+		pBase += 2;
+		write_back = 0;
+	}
+
+	pFinal = pBase;
+	if (BIT_UP_SET(opcode))
+		pFinal += getOffset(opcode);
+	else
+		pFinal -= getOffset(opcode);
+
+	if (PREINDEXED(opcode))
+		pAddress = pFinal;
+	else
+		pAddress = pBase;
+
+	switch (opcode & MASK_TRANSFER_LENGTH) {
+	case TRANSFER_SINGLE:
+		storeSingle(getFd(opcode), pAddress);
+		break;
+	case TRANSFER_DOUBLE:
+		storeDouble(getFd(opcode), pAddress);
+		break;
+#ifdef CONFIG_FPE_NWFPE_XP
+	case TRANSFER_EXTENDED:
+		storeExtended(getFd(opcode), pAddress);
+		break;
+#endif
+	default:
+		nRc = 0;
+	}
+
+	if (write_back)
+		writeRegister(getRn(opcode), (unsigned int) pFinal);
+	return nRc;
 }
 
 unsigned int PerformLFM(const unsigned int opcode)
 {
-   unsigned int i, Fd, *pBase, *pAddress, *pFinal,
-     write_back = WRITE_BACK(opcode);
+	unsigned int i, Fd, *pBase, *pAddress, *pFinal,
+	    write_back = WRITE_BACK(opcode);
 
-   pBase = (unsigned int*)readRegister(getRn(opcode));
-   if (REG_PC == getRn(opcode))
-   {
-     pBase += 2;
-     write_back = 0;
-   }
-
-   pFinal = pBase;
-   if (BIT_UP_SET(opcode))
-     pFinal += getOffset(opcode);
-   else
-     pFinal -= getOffset(opcode);
-
-   if (PREINDEXED(opcode)) pAddress = pFinal; else pAddress = pBase;
-
-   Fd = getFd(opcode);
-   for (i=getRegisterCount(opcode);i>0;i--)
-   {
-     loadMultiple(Fd,pAddress);
-     pAddress += 3; Fd++;
-     if (Fd == 8) Fd = 0;
-   }
-
-   if (write_back) writeRegister(getRn(opcode),(unsigned int)pFinal);
-   return 1;
+	pBase = (unsigned int *) readRegister(getRn(opcode));
+	if (REG_PC == getRn(opcode)) {
+		pBase += 2;
+		write_back = 0;
+	}
+
+	pFinal = pBase;
+	if (BIT_UP_SET(opcode))
+		pFinal += getOffset(opcode);
+	else
+		pFinal -= getOffset(opcode);
+
+	if (PREINDEXED(opcode))
+		pAddress = pFinal;
+	else
+		pAddress = pBase;
+
+	Fd = getFd(opcode);
+	for (i = getRegisterCount(opcode); i > 0; i--) {
+		loadMultiple(Fd, pAddress);
+		pAddress += 3;
+		Fd++;
+		if (Fd == 8)
+			Fd = 0;
+	}
+
+	if (write_back)
+		writeRegister(getRn(opcode), (unsigned int) pFinal);
+	return 1;
 }
 
 unsigned int PerformSFM(const unsigned int opcode)
 {
-   unsigned int i, Fd, *pBase, *pAddress, *pFinal,
-     write_back = WRITE_BACK(opcode);
-
-   pBase = (unsigned int*)readRegister(getRn(opcode));
-   if (REG_PC == getRn(opcode))
-   {
-     pBase += 2;
-     write_back = 0;
-   }
-
-   pFinal = pBase;
-   if (BIT_UP_SET(opcode))
-     pFinal += getOffset(opcode);
-   else
-     pFinal -= getOffset(opcode);
-
-   if (PREINDEXED(opcode)) pAddress = pFinal; else pAddress = pBase;
-
-   Fd = getFd(opcode);
-   for (i=getRegisterCount(opcode);i>0;i--)
-   {
-     storeMultiple(Fd,pAddress);
-     pAddress += 3; Fd++;
-     if (Fd == 8) Fd = 0;
-   }
+	unsigned int i, Fd, *pBase, *pAddress, *pFinal,
+	    write_back = WRITE_BACK(opcode);
 
-   if (write_back) writeRegister(getRn(opcode),(unsigned int)pFinal);
-   return 1;
+	pBase = (unsigned int *) readRegister(getRn(opcode));
+	if (REG_PC == getRn(opcode)) {
+		pBase += 2;
+		write_back = 0;
+	}
+
+	pFinal = pBase;
+	if (BIT_UP_SET(opcode))
+		pFinal += getOffset(opcode);
+	else
+		pFinal -= getOffset(opcode);
+
+	if (PREINDEXED(opcode))
+		pAddress = pFinal;
+	else
+		pAddress = pBase;
+
+	Fd = getFd(opcode);
+	for (i = getRegisterCount(opcode); i > 0; i--) {
+		storeMultiple(Fd, pAddress);
+		pAddress += 3;
+		Fd++;
+		if (Fd == 8)
+			Fd = 0;
+	}
+
+	if (write_back)
+		writeRegister(getRn(opcode), (unsigned int) pFinal);
+	return 1;
 }
 
-#if 1
 unsigned int EmulateCPDT(const unsigned int opcode)
 {
-  unsigned int nRc = 0;
+	unsigned int nRc = 0;
 
-  //printk("EmulateCPDT(0x%08x)\n",opcode);
+	if (LDF_OP(opcode)) {
+		nRc = PerformLDF(opcode);
+	} else if (LFM_OP(opcode)) {
+		nRc = PerformLFM(opcode);
+	} else if (STF_OP(opcode)) {
+		nRc = PerformSTF(opcode);
+	} else if (SFM_OP(opcode)) {
+		nRc = PerformSFM(opcode);
+	} else {
+		nRc = 0;
+	}
 
-  if (LDF_OP(opcode))
-  {
-    nRc = PerformLDF(opcode);
-  }
-  else if (LFM_OP(opcode))
-  {
-    nRc = PerformLFM(opcode);
-  }
-  else if (STF_OP(opcode))
-  {
-    nRc = PerformSTF(opcode);
-  }
-  else if (SFM_OP(opcode))
-  {
-    nRc = PerformSFM(opcode);
-  }
-  else
-  {
-    nRc = 0;
-  }
-
-  return nRc;
+	return nRc;
 }
-#endif
diff -Nru a/arch/arm/nwfpe/fpa11_cprt.c b/arch/arm/nwfpe/fpa11_cprt.c
--- a/arch/arm/nwfpe/fpa11_cprt.c	Wed Apr 30 22:28:12 2003
+++ b/arch/arm/nwfpe/fpa11_cprt.c	Wed Apr 30 22:28:12 2003
@@ -1,7 +1,7 @@
 /*
     NetWinder Floating Point Emulator
     (c) Rebel.COM, 1998,1999
-    (c) Philip Blundell, 1999
+    (c) Philip Blundell, 1999, 2001
 
     Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
 
@@ -21,269 +21,348 @@
 */
 
 #include "fpa11.h"
-#include "milieu.h"
-#include "softfloat.h"
 #include "fpopcode.h"
 #include "fpa11.inl"
 #include "fpmodule.h"
 #include "fpmodule.inl"
 
+#ifdef CONFIG_FPE_NWFPE_XP
 extern flag floatx80_is_nan(floatx80);
-extern flag float64_is_nan( float64);
-extern flag float32_is_nan( float32);
+#endif
+extern flag float64_is_nan(float64);
+extern flag float32_is_nan(float32);
 
 void SetRoundingMode(const unsigned int opcode);
 
 unsigned int PerformFLT(const unsigned int opcode);
 unsigned int PerformFIX(const unsigned int opcode);
 
-static unsigned int
-PerformComparison(const unsigned int opcode);
+static unsigned int PerformComparison(const unsigned int opcode);
 
 unsigned int EmulateCPRT(const unsigned int opcode)
 {
-  unsigned int nRc = 1;
-
-  //printk("EmulateCPRT(0x%08x)\n",opcode);
 
-  if (opcode & 0x800000)
-  {
-     /* This is some variant of a comparison (PerformComparison will
-	sort out which one).  Since most of the other CPRT
-	instructions are oddball cases of some sort or other it makes
-	sense to pull this out into a fast path.  */
-     return PerformComparison(opcode);
-  }
-
-  /* Hint to GCC that we'd like a jump table rather than a load of CMPs */
-  switch ((opcode & 0x700000) >> 20)
-  {
-    case  FLT_CODE >> 20: nRc = PerformFLT(opcode); break;
-    case  FIX_CODE >> 20: nRc = PerformFIX(opcode); break;
-    
-    case  WFS_CODE >> 20: writeFPSR(readRegister(getRd(opcode))); break;
-    case  RFS_CODE >> 20: writeRegister(getRd(opcode),readFPSR()); break;
-
-#if 0    /* We currently have no use for the FPCR, so there's no point
-	    in emulating it. */
-    case  WFC_CODE >> 20: writeFPCR(readRegister(getRd(opcode)));
-    case  RFC_CODE >> 20: writeRegister(getRd(opcode),readFPCR()); break;
-#endif
+	if (opcode & 0x800000) {
+		/* This is some variant of a comparison (PerformComparison
+		   will sort out which one).  Since most of the other CPRT
+		   instructions are oddball cases of some sort or other it
+		   makes sense to pull this out into a fast path.  */
+		return PerformComparison(opcode);
+	}
+
+	/* Hint to GCC that we'd like a jump table rather than a load of CMPs */
+	switch ((opcode & 0x700000) >> 20) {
+	case FLT_CODE >> 20:
+		return PerformFLT(opcode);
+		break;
+	case FIX_CODE >> 20:
+		return PerformFIX(opcode);
+		break;
+
+	case WFS_CODE >> 20:
+		writeFPSR(readRegister(getRd(opcode)));
+		break;
+	case RFS_CODE >> 20:
+		writeRegister(getRd(opcode), readFPSR());
+		break;
+
+	default:
+		return 0;
+	}
 
-    default: nRc = 0;
-  }
-  
-  return nRc;
+	return 1;
 }
 
 unsigned int PerformFLT(const unsigned int opcode)
 {
-   FPA11 *fpa11 = GET_FPA11();
-   
-   unsigned int nRc = 1;
-   SetRoundingMode(opcode);
-
-   switch (opcode & MASK_ROUNDING_PRECISION)
-   {
-      case ROUND_SINGLE:
-      {
-        fpa11->fType[getFn(opcode)] = typeSingle;
-        fpa11->fpreg[getFn(opcode)].fSingle =
-	   int32_to_float32(readRegister(getRd(opcode)));
-      }
-      break;
-
-      case ROUND_DOUBLE:
-      {
-        fpa11->fType[getFn(opcode)] = typeDouble;
-        fpa11->fpreg[getFn(opcode)].fDouble =
-            int32_to_float64(readRegister(getRd(opcode)));
-      }
-      break;
-        
-      case ROUND_EXTENDED:
-      {
-        fpa11->fType[getFn(opcode)] = typeExtended;
-        fpa11->fpreg[getFn(opcode)].fExtended =
-	   int32_to_floatx80(readRegister(getRd(opcode)));
-      }
-      break;
-      
-      default: nRc = 0;
-  }
-  
-  return nRc;
+	FPA11 *fpa11 = GET_FPA11();
+	SetRoundingMode(opcode);
+	SetRoundingPrecision(opcode);
+
+	switch (opcode & MASK_ROUNDING_PRECISION) {
+	case ROUND_SINGLE:
+		{
+			fpa11->fType[getFn(opcode)] = typeSingle;
+			fpa11->fpreg[getFn(opcode)].fSingle = int32_to_float32(readRegister(getRd(opcode)));
+		}
+		break;
+
+	case ROUND_DOUBLE:
+		{
+			fpa11->fType[getFn(opcode)] = typeDouble;
+			fpa11->fpreg[getFn(opcode)].fDouble = int32_to_float64(readRegister(getRd(opcode)));
+		}
+		break;
+
+#ifdef CONFIG_FPE_NWFPE_XP
+	case ROUND_EXTENDED:
+		{
+			fpa11->fType[getFn(opcode)] = typeExtended;
+			fpa11->fpreg[getFn(opcode)].fExtended = int32_to_floatx80(readRegister(getRd(opcode)));
+		}
+		break;
+#endif
+
+	default:
+		return 0;
+	}
+
+	return 1;
 }
 
 unsigned int PerformFIX(const unsigned int opcode)
 {
-   FPA11 *fpa11 = GET_FPA11();
-   unsigned int nRc = 1;
-   unsigned int Fn = getFm(opcode);
-   
-   SetRoundingMode(opcode);
-
-   switch (fpa11->fType[Fn])
-   {
-      case typeSingle:
-      {
-         writeRegister(getRd(opcode),
-	               float32_to_int32(fpa11->fpreg[Fn].fSingle));
-      }
-      break;
-
-      case typeDouble:
-      {
-         writeRegister(getRd(opcode),
-	               float64_to_int32(fpa11->fpreg[Fn].fDouble));
-      }
-      break;
-      	               
-      case typeExtended:
-      {
-         writeRegister(getRd(opcode),
-	               floatx80_to_int32(fpa11->fpreg[Fn].fExtended));
-      }
-      break;
-      
-      default: nRc = 0;
-  }
-  
-  return nRc;
-}
+	FPA11 *fpa11 = GET_FPA11();
+	unsigned int Fn = getFm(opcode);
 
-   
-static unsigned int __inline__
-PerformComparisonOperation(floatx80 Fn, floatx80 Fm)
-{
-   unsigned int flags = 0;
+	SetRoundingMode(opcode);
 
-   /* test for less than condition */
-   if (floatx80_lt(Fn,Fm))
-   {
-      flags |= CC_NEGATIVE;
-   }
-  
-   /* test for equal condition */
-   if (floatx80_eq(Fn,Fm))
-   {
-      flags |= CC_ZERO;
-   }
-
-   /* test for greater than or equal condition */
-   if (floatx80_lt(Fm,Fn))
-   {
-      flags |= CC_CARRY;
-   }
-   
-   writeConditionCodes(flags);
-   return 1;
+	switch (fpa11->fType[Fn]) {
+	case typeSingle:
+		{
+			writeRegister(getRd(opcode), float32_to_int32(fpa11->fpreg[Fn].fSingle));
+		}
+		break;
+
+	case typeDouble:
+		{
+			writeRegister(getRd(opcode), float64_to_int32(fpa11->fpreg[Fn].fDouble));
+		}
+		break;
+
+#ifdef CONFIG_FPE_NWFPE_XP
+	case typeExtended:
+		{
+			writeRegister(getRd(opcode), floatx80_to_int32(fpa11->fpreg[Fn].fExtended));
+		}
+		break;
+#endif
+
+	default:
+		return 0;
+	}
+
+	return 1;
 }
 
 /* This instruction sets the flags N, Z, C, V in the FPSR. */
-   
 static unsigned int PerformComparison(const unsigned int opcode)
 {
-   FPA11 *fpa11 = GET_FPA11();
-   unsigned int Fn, Fm;
-   floatx80 rFn, rFm;
-   int e_flag = opcode & 0x400000;	/* 1 if CxFE */
-   int n_flag = opcode & 0x200000;	/* 1 if CNxx */
-   unsigned int flags = 0;
-
-   //printk("PerformComparison(0x%08x)\n",opcode);
-
-   Fn = getFn(opcode);
-   Fm = getFm(opcode);
-
-   /* Check for unordered condition and convert all operands to 80-bit
-      format.
-      ?? Might be some mileage in avoiding this conversion if possible.
-      Eg, if both operands are 32-bit, detect this and do a 32-bit
-      comparison (cheaper than an 80-bit one).  */
-   switch (fpa11->fType[Fn])
-   {
-      case typeSingle: 
-        //printk("single.\n");
-	if (float32_is_nan(fpa11->fpreg[Fn].fSingle))
-	   goto unordered;
-        rFn = float32_to_floatx80(fpa11->fpreg[Fn].fSingle);
-      break;
-
-      case typeDouble: 
-        //printk("double.\n");
-	if (float64_is_nan(fpa11->fpreg[Fn].fDouble))
-	   goto unordered;
-        rFn = float64_to_floatx80(fpa11->fpreg[Fn].fDouble);
-      break;
-      
-      case typeExtended: 
-        //printk("extended.\n");
-	if (floatx80_is_nan(fpa11->fpreg[Fn].fExtended))
-	   goto unordered;
-        rFn = fpa11->fpreg[Fn].fExtended;
-      break;
-      
-      default: return 0;
-   }
-
-   if (CONSTANT_FM(opcode))
-   {
-     //printk("Fm is a constant: #%d.\n",Fm);
-     rFm = getExtendedConstant(Fm);
-     if (floatx80_is_nan(rFm))
-        goto unordered;
-   }
-   else
-   {
-     //printk("Fm = r%d which contains a ",Fm);
-      switch (fpa11->fType[Fm])
-      {
-         case typeSingle: 
-           //printk("single.\n");
-	   if (float32_is_nan(fpa11->fpreg[Fm].fSingle))
-	      goto unordered;
-           rFm = float32_to_floatx80(fpa11->fpreg[Fm].fSingle);
-         break;
-
-         case typeDouble: 
-           //printk("double.\n");
-	   if (float64_is_nan(fpa11->fpreg[Fm].fDouble))
-	      goto unordered;
-           rFm = float64_to_floatx80(fpa11->fpreg[Fm].fDouble);
-         break;
-      
-         case typeExtended: 
-           //printk("extended.\n");
-	   if (floatx80_is_nan(fpa11->fpreg[Fm].fExtended))
-	      goto unordered;
-           rFm = fpa11->fpreg[Fm].fExtended;
-         break;
-      
-         default: return 0;
-      }
-   }
-
-   if (n_flag)
-   {
-      rFm.high ^= 0x8000;
-   }
-
-   return PerformComparisonOperation(rFn,rFm);
-
- unordered:
-   /* ?? The FPA data sheet is pretty vague about this, in particular
-      about whether the non-E comparisons can ever raise exceptions.
-      This implementation is based on a combination of what it says in
-      the data sheet, observation of how the Acorn emulator actually
-      behaves (and how programs expect it to) and guesswork.  */
-   flags |= CC_OVERFLOW;
-   flags &= ~(CC_ZERO | CC_NEGATIVE);
+	FPA11 *fpa11 = GET_FPA11();
+	unsigned int Fn = getFn(opcode), Fm = getFm(opcode);
+	int e_flag = opcode & 0x400000;	/* 1 if CxFE */
+	int n_flag = opcode & 0x200000;	/* 1 if CNxx */
+	unsigned int flags = 0;
+
+#ifdef CONFIG_FPE_NWFPE_XP
+	floatx80 rFn, rFm;
+
+	/* Check for unordered condition and convert all operands to 80-bit
+	   format.
+	   ?? Might be some mileage in avoiding this conversion if possible.
+	   Eg, if both operands are 32-bit, detect this and do a 32-bit
+	   comparison (cheaper than an 80-bit one).  */
+	switch (fpa11->fType[Fn]) {
+	case typeSingle:
+		//printk("single.\n");
+		if (float32_is_nan(fpa11->fpreg[Fn].fSingle))
+			goto unordered;
+		rFn = float32_to_floatx80(fpa11->fpreg[Fn].fSingle);
+		break;
+
+	case typeDouble:
+		//printk("double.\n");
+		if (float64_is_nan(fpa11->fpreg[Fn].fDouble))
+			goto unordered;
+		rFn = float64_to_floatx80(fpa11->fpreg[Fn].fDouble);
+		break;
+
+	case typeExtended:
+		//printk("extended.\n");
+		if (floatx80_is_nan(fpa11->fpreg[Fn].fExtended))
+			goto unordered;
+		rFn = fpa11->fpreg[Fn].fExtended;
+		break;
+
+	default:
+		return 0;
+	}
+
+	if (CONSTANT_FM(opcode)) {
+		//printk("Fm is a constant: #%d.\n",Fm);
+		rFm = getExtendedConstant(Fm);
+		if (floatx80_is_nan(rFm))
+			goto unordered;
+	} else {
+		//printk("Fm = r%d which contains a ",Fm);
+		switch (fpa11->fType[Fm]) {
+		case typeSingle:
+			//printk("single.\n");
+			if (float32_is_nan(fpa11->fpreg[Fm].fSingle))
+				goto unordered;
+			rFm = float32_to_floatx80(fpa11->fpreg[Fm].fSingle);
+			break;
+
+		case typeDouble:
+			//printk("double.\n");
+			if (float64_is_nan(fpa11->fpreg[Fm].fDouble))
+				goto unordered;
+			rFm = float64_to_floatx80(fpa11->fpreg[Fm].fDouble);
+			break;
+
+		case typeExtended:
+			//printk("extended.\n");
+			if (floatx80_is_nan(fpa11->fpreg[Fm].fExtended))
+				goto unordered;
+			rFm = fpa11->fpreg[Fm].fExtended;
+			break;
+
+		default:
+			return 0;
+		}
+	}
+
+	if (n_flag)
+		rFm.high ^= 0x8000;
+
+	/* test for less than condition */
+	if (floatx80_lt(rFn, rFm))
+		flags |= CC_NEGATIVE;
+
+	/* test for equal condition */
+	if (floatx80_eq(rFn, rFm))
+		flags |= CC_ZERO;
+
+	/* test for greater than or equal condition */
+	if (floatx80_lt(rFm, rFn))
+		flags |= CC_CARRY;
+
+#else
+	if (CONSTANT_FM(opcode)) {
+		/* Fm is a constant.  Do the comparison in whatever precision
+		   Fn happens to be stored in.  */
+		if (fpa11->fType[Fn] == typeSingle) {
+			float32 rFm = getSingleConstant(Fm);
+			float32 rFn = fpa11->fpreg[Fn].fSingle;
+
+			if (float32_is_nan(rFn))
+				goto unordered;
+
+			if (n_flag)
+				rFm ^= 0x80000000;
+
+			/* test for less than condition */
+			if (float32_lt_nocheck(rFn, rFm))
+				flags |= CC_NEGATIVE;
+
+			/* test for equal condition */
+			if (float32_eq_nocheck(rFn, rFm))
+				flags |= CC_ZERO;
+
+			/* test for greater than or equal condition */
+			if (float32_lt_nocheck(rFm, rFn))
+				flags |= CC_CARRY;
+		} else {
+			float64 rFm = getDoubleConstant(Fm);
+			float64 rFn = fpa11->fpreg[Fn].fDouble;
+
+			if (float64_is_nan(rFn))
+				goto unordered;
+
+			if (n_flag)
+				rFm ^= 0x8000000000000000ULL;
+
+			/* test for less than condition */
+			if (float64_lt_nocheck(rFn, rFm))
+				flags |= CC_NEGATIVE;
+
+			/* test for equal condition */
+			if (float64_eq_nocheck(rFn, rFm))
+				flags |= CC_ZERO;
+
+			/* test for greater than or equal condition */
+			if (float64_lt_nocheck(rFm, rFn))
+				flags |= CC_CARRY;
+		}
+	} else {
+		/* Both operands are in registers.  */
+		if (fpa11->fType[Fn] == typeSingle
+		    && fpa11->fType[Fm] == typeSingle) {
+			float32 rFm = fpa11->fpreg[Fm].fSingle;
+			float32 rFn = fpa11->fpreg[Fn].fSingle;
+
+			if (float32_is_nan(rFn)
+			    || float32_is_nan(rFm))
+				goto unordered;
+
+			if (n_flag)
+				rFm ^= 0x80000000;
+
+			/* test for less than condition */
+			if (float32_lt_nocheck(rFn, rFm))
+				flags |= CC_NEGATIVE;
+
+			/* test for equal condition */
+			if (float32_eq_nocheck(rFn, rFm))
+				flags |= CC_ZERO;
+
+			/* test for greater than or equal condition */
+			if (float32_lt_nocheck(rFm, rFn))
+				flags |= CC_CARRY;
+		} else {
+			/* Promote 32-bit operand to 64 bits.  */
+			float64 rFm, rFn;
+
+			rFm = (fpa11->fType[Fm] == typeSingle) ?
+			    float32_to_float64(fpa11->fpreg[Fm].fSingle)
+			    : fpa11->fpreg[Fm].fDouble;
+
+			rFn = (fpa11->fType[Fn] == typeSingle) ?
+			    float32_to_float64(fpa11->fpreg[Fn].fSingle)
+			    : fpa11->fpreg[Fn].fDouble;
+
+			if (float64_is_nan(rFn)
+			    || float64_is_nan(rFm))
+				goto unordered;
+
+			if (n_flag)
+				rFm ^= 0x8000000000000000ULL;
+
+			/* test for less than condition */
+			if (float64_lt_nocheck(rFn, rFm))
+				flags |= CC_NEGATIVE;
+
+			/* test for equal condition */
+			if (float64_eq_nocheck(rFn, rFm))
+				flags |= CC_ZERO;
+
+			/* test for greater than or equal condition */
+			if (float64_lt_nocheck(rFm, rFn))
+				flags |= CC_CARRY;
+		}
+	}
+
+#endif
+
+	writeConditionCodes(flags);
+
+	return 1;
+
+      unordered:
+	/* ?? The FPA data sheet is pretty vague about this, in particular
+	   about whether the non-E comparisons can ever raise exceptions.
+	   This implementation is based on a combination of what it says in
+	   the data sheet, observation of how the Acorn emulator actually
+	   behaves (and how programs expect it to) and guesswork.  */
+	flags |= CC_OVERFLOW;
+	flags &= ~(CC_ZERO | CC_NEGATIVE);
 
-   if (BIT_AC & readFPSR()) flags |= CC_CARRY;
+	if (BIT_AC & readFPSR())
+		flags |= CC_CARRY;
 
-   if (e_flag) float_raise(float_flag_invalid);
+	if (e_flag)
+		float_raise(float_flag_invalid);
 
-   writeConditionCodes(flags);
-   return 1;
+	writeConditionCodes(flags);
+	return 1;
 }
diff -Nru a/arch/arm/nwfpe/fpmodule.c b/arch/arm/nwfpe/fpmodule.c
--- a/arch/arm/nwfpe/fpmodule.c	Wed Apr 30 22:28:08 2003
+++ b/arch/arm/nwfpe/fpmodule.c	Wed Apr 30 22:28:08 2003
@@ -42,11 +42,17 @@
 #include "fpa11.inl"
 
 /* kernel symbols required for signal handling */
+#ifdef CONFIG_FPE_NWFPE_XP
+#define NWFPE_BITS "extended"
+#else
+#define NWFPE_BITS "double"
+#endif
+
 #ifdef MODULE
 void fp_send_sig(unsigned long sig, struct task_struct *p, int priv);
 #if LINUX_VERSION_CODE > 0x20115
 MODULE_AUTHOR("Scott Bambrough <scottb@rebel.com>");
-MODULE_DESCRIPTION("NWFPE floating point emulator");
+MODULE_DESCRIPTION("NWFPE floating point emulator (" NWFPE_BITS " precision)");
 #endif
 
 #else
@@ -63,63 +69,45 @@
 extern void (*kern_fp_enter)(void);
 extern void (*fp_init)(union fp_state *);
 
-/* Original value of fp_enter from kernel before patched by fpe_init. */ 
+/* Original value of fp_enter from kernel before patched by fpe_init. */
 static void (*orig_fp_enter)(void);
 static void (*orig_fp_init)(union fp_state *);
 
 /* forward declarations */
 extern void nwfpe_enter(void);
 
-#ifdef MODULE
-/*
- * Return 0 if we can be unloaded.  This can only happen if
- * kern_fp_enter is still pointing at nwfpe_enter
- */
-static int fpe_unload(void)
-{
-  return (kern_fp_enter == nwfpe_enter) ? 0 : 1;
-}
-#endif
-
 static int __init fpe_init(void)
 {
-  if (sizeof(FPA11) > sizeof(union fp_state)) {
-    printk(KERN_ERR "nwfpe: bad structure size\n");
-    return -EINVAL;
-  }
-
-  if (sizeof(FPREG) != 12) {
-    printk(KERN_ERR "nwfpe: bad register size\n");
-    return -EINVAL;
-  }
+	if (sizeof(FPA11) > sizeof(union fp_state)) {
+		printk(KERN_ERR "nwfpe: bad structure size\n");
+		return -EINVAL;
+	}
+
+	if (sizeof(FPREG) != 12) {
+		printk(KERN_ERR "nwfpe: bad register size\n");
+		return -EINVAL;
+	}
+	if (fpe_type[0] && strcmp(fpe_type, "nwfpe"))
+		return 0;
+
+	/* Display title, version and copyright information. */
+	printk(KERN_WARNING "NetWinder Floating Point Emulator V0.97 ("
+	       NWFPE_BITS " precision)\n");
+
+	/* Save pointer to the old FP handler and then patch ourselves in */
+	orig_fp_enter = kern_fp_enter;
+	orig_fp_init = fp_init;
+	kern_fp_enter = nwfpe_enter;
+	fp_init = nwfpe_init_fpa;
 
-#ifdef MODULE
-  if (!mod_member_present(&__this_module, can_unload))
-    return -EINVAL;
-  __this_module.can_unload = fpe_unload;
-#else
-  if (fpe_type[0] && strcmp(fpe_type, "nwfpe"))
-    return 0;
-#endif
-
-  /* Display title, version and copyright information. */
-  printk(KERN_WARNING "NetWinder Floating Point Emulator V0.95 "
-	 "(c) 1998-1999 Rebel.com\n");
-
-  /* Save pointer to the old FP handler and then patch ourselves in */
-  orig_fp_enter = kern_fp_enter;
-  orig_fp_init = fp_init;
-  kern_fp_enter = nwfpe_enter;
-  fp_init = nwfpe_init;
-
-  return 0;
+	return 0;
 }
 
 static void __exit fpe_exit(void)
 {
-  /* Restore the values we saved earlier. */
-  kern_fp_enter = orig_fp_enter;
-  fp_init = orig_fp_init;
+	/* Restore the values we saved earlier. */
+	kern_fp_enter = orig_fp_enter;
+	fp_init = orig_fp_init;
 }
 
 /*
@@ -144,41 +132,42 @@
 
 void float_raise(signed char flags)
 {
-  register unsigned int fpsr, cumulativeTraps;
-  
+	register unsigned int fpsr, cumulativeTraps;
+
 #ifdef CONFIG_DEBUG_USER
-  printk(KERN_DEBUG "NWFPE: %s[%d] takes exception %08x at %p from %08x\n",
-	 current->comm, current->pid, flags,
-	 __builtin_return_address(0), GET_USERREG()[15]);
+	printk(KERN_DEBUG
+	       "NWFPE: %s[%d] takes exception %08x at %p from %08x\n",
+	       current->comm, current->pid, flags,
+	       __builtin_return_address(0), GET_USERREG()[15]);
 #endif
 
-  /* Keep SoftFloat exception flags up to date.  */
-  float_exception_flags |= flags;
+	/* Keep SoftFloat exception flags up to date.  */
+	float_exception_flags |= flags;
 
-  /* Read fpsr and initialize the cumulativeTraps.  */
-  fpsr = readFPSR();
-  cumulativeTraps = 0;
-  
-  /* For each type of exception, the cumulative trap exception bit is only
-     set if the corresponding trap enable bit is not set.  */
-  if ((!(fpsr & BIT_IXE)) && (flags & BIT_IXC))
-     cumulativeTraps |= BIT_IXC;  
-  if ((!(fpsr & BIT_UFE)) && (flags & BIT_UFC))
-     cumulativeTraps |= BIT_UFC;  
-  if ((!(fpsr & BIT_OFE)) && (flags & BIT_OFC))
-     cumulativeTraps |= BIT_OFC;  
-  if ((!(fpsr & BIT_DZE)) && (flags & BIT_DZC))
-     cumulativeTraps |= BIT_DZC;  
-  if ((!(fpsr & BIT_IOE)) && (flags & BIT_IOC))
-     cumulativeTraps |= BIT_IOC;  
-
-  /* Set the cumulative exceptions flags.  */
-  if (cumulativeTraps)
-    writeFPSR(fpsr | cumulativeTraps);
-
-  /* Raise an exception if necessary.  */
-  if (fpsr & (flags << 16))
-    fp_send_sig(SIGFPE, current, 1);
+	/* Read fpsr and initialize the cumulativeTraps.  */
+	fpsr = readFPSR();
+	cumulativeTraps = 0;
+
+	/* For each type of exception, the cumulative trap exception bit is only
+	   set if the corresponding trap enable bit is not set.  */
+	if ((!(fpsr & BIT_IXE)) && (flags & BIT_IXC))
+		cumulativeTraps |= BIT_IXC;
+	if ((!(fpsr & BIT_UFE)) && (flags & BIT_UFC))
+		cumulativeTraps |= BIT_UFC;
+	if ((!(fpsr & BIT_OFE)) && (flags & BIT_OFC))
+		cumulativeTraps |= BIT_OFC;
+	if ((!(fpsr & BIT_DZE)) && (flags & BIT_DZC))
+		cumulativeTraps |= BIT_DZC;
+	if ((!(fpsr & BIT_IOE)) && (flags & BIT_IOC))
+		cumulativeTraps |= BIT_IOC;
+
+	/* Set the cumulative exceptions flags.  */
+	if (cumulativeTraps)
+		writeFPSR(fpsr | cumulativeTraps);
+
+	/* Raise an exception if necessary.  */
+	if (fpsr & (flags << 16))
+		fp_send_sig(SIGFPE, current, 1);
 }
 
 module_init(fpe_init);
diff -Nru a/arch/arm/nwfpe/fpmodule.inl b/arch/arm/nwfpe/fpmodule.inl
--- a/arch/arm/nwfpe/fpmodule.inl	Wed Apr 30 22:28:17 2003
+++ b/arch/arm/nwfpe/fpmodule.inl	Wed Apr 30 22:28:17 2003
@@ -22,63 +22,64 @@
 extern __inline__
 unsigned int readRegister(const unsigned int nReg)
 {
-  /* Note: The CPU thinks it has dealt with the current instruction.  As
-           a result the program counter has been advanced to the next
-           instruction, and points 4 bytes beyond the actual instruction
-           that caused the invalid instruction trap to occur.  We adjust
-           for this in this routine.  LDF/STF instructions with Rn = PC
-           depend on the PC being correct, as they use PC+8 in their 
-           address calculations. */
-  unsigned int *userRegisters = GET_USERREG();
-  unsigned int val = userRegisters[nReg];
-  if (REG_PC == nReg) val -= 4;
-  return val;
+	/* Note: The CPU thinks it has dealt with the current instruction.
+	   As a result the program counter has been advanced to the next
+	   instruction, and points 4 bytes beyond the actual instruction
+	   that caused the invalid instruction trap to occur.  We adjust
+	   for this in this routine.  LDF/STF instructions with Rn = PC
+	   depend on the PC being correct, as they use PC+8 in their
+	   address calculations. */
+	unsigned int *userRegisters = GET_USERREG();
+	unsigned int val = userRegisters[nReg];
+	if (REG_PC == nReg)
+		val -= 4;
+	return val;
 }
 
 extern __inline__
 void writeRegister(const unsigned int nReg, const unsigned int val)
 {
-  unsigned int *userRegisters = GET_USERREG();
-  userRegisters[nReg] = val;
+	unsigned int *userRegisters = GET_USERREG();
+	userRegisters[nReg] = val;
 }
 
 extern __inline__
 unsigned int readCPSR(void)
 {
-  return(readRegister(REG_CPSR));
+	return (readRegister(REG_CPSR));
 }
 
 extern __inline__
 void writeCPSR(const unsigned int val)
 {
-  writeRegister(REG_CPSR,val);
+	writeRegister(REG_CPSR, val);
 }
 
 extern __inline__
 unsigned int readConditionCodes(void)
 {
 #ifdef __FPEM_TEST__
-   return(0);
+	return (0);
 #else
-   return(readCPSR() & CC_MASK);
+	return (readCPSR() & CC_MASK);
 #endif
 }
 
 extern __inline__
 void writeConditionCodes(const unsigned int val)
 {
-  unsigned int *userRegisters = GET_USERREG();
-  unsigned int rval;
-  /*
-   * Operate directly on userRegisters since
-   * the CPSR may be the PC register itself.
-   */
-  rval = userRegisters[REG_CPSR] & ~CC_MASK;
-  userRegisters[REG_CPSR] = rval | (val & CC_MASK);
+	unsigned int *userRegisters = GET_USERREG();
+	unsigned int rval;
+	/*
+	 * Operate directly on userRegisters since
+	 * the CPSR may be the PC register itself.
+	 */
+	rval = userRegisters[REG_CPSR] & ~CC_MASK;
+	userRegisters[REG_CPSR] = rval | (val & CC_MASK);
 }
 
 extern __inline__
 unsigned int readMemoryInt(unsigned int *pMem)
 {
-  return *pMem;
+	return *pMem;
 }
diff -Nru a/arch/arm/nwfpe/fpopcode.c b/arch/arm/nwfpe/fpopcode.c
--- a/arch/arm/nwfpe/fpopcode.c	Wed Apr 30 22:28:08 2003
+++ b/arch/arm/nwfpe/fpopcode.c	Wed Apr 30 22:28:08 2003
@@ -26,123 +26,64 @@
 #include "fpmodule.h"
 #include "fpmodule.inl"
 
+#ifdef CONFIG_FPE_NWFPE_XP
 const floatx80 floatx80Constant[] = {
-  { 0x0000, 0x0000000000000000ULL},	/* extended 0.0 */
-  { 0x3fff, 0x8000000000000000ULL},	/* extended 1.0 */
-  { 0x4000, 0x8000000000000000ULL},	/* extended 2.0 */
-  { 0x4000, 0xc000000000000000ULL},	/* extended 3.0 */
-  { 0x4001, 0x8000000000000000ULL},	/* extended 4.0 */
-  { 0x4001, 0xa000000000000000ULL},	/* extended 5.0 */
-  { 0x3ffe, 0x8000000000000000ULL},	/* extended 0.5 */
-  { 0x4002, 0xa000000000000000ULL}	/* extended 10.0 */
-};  
+	{0x0000, 0x0000000000000000ULL},	/* extended 0.0 */
+	{0x3fff, 0x8000000000000000ULL},	/* extended 1.0 */
+	{0x4000, 0x8000000000000000ULL},	/* extended 2.0 */
+	{0x4000, 0xc000000000000000ULL},	/* extended 3.0 */
+	{0x4001, 0x8000000000000000ULL},	/* extended 4.0 */
+	{0x4001, 0xa000000000000000ULL},	/* extended 5.0 */
+	{0x3ffe, 0x8000000000000000ULL},	/* extended 0.5 */
+	{0x4002, 0xa000000000000000ULL}		/* extended 10.0 */
+};
+#endif
 
 const float64 float64Constant[] = {
-  0x0000000000000000ULL,		/* double 0.0 */
-  0x3ff0000000000000ULL,		/* double 1.0 */
-  0x4000000000000000ULL,		/* double 2.0 */
-  0x4008000000000000ULL,		/* double 3.0 */
-  0x4010000000000000ULL,		/* double 4.0 */
-  0x4014000000000000ULL,		/* double 5.0 */
-  0x3fe0000000000000ULL,		/* double 0.5 */
-  0x4024000000000000ULL			/* double 10.0 */
-};  
+	0x0000000000000000ULL,	/* double 0.0 */
+	0x3ff0000000000000ULL,	/* double 1.0 */
+	0x4000000000000000ULL,	/* double 2.0 */
+	0x4008000000000000ULL,	/* double 3.0 */
+	0x4010000000000000ULL,	/* double 4.0 */
+	0x4014000000000000ULL,	/* double 5.0 */
+	0x3fe0000000000000ULL,	/* double 0.5 */
+	0x4024000000000000ULL	/* double 10.0 */
+};
 
 const float32 float32Constant[] = {
-  0x00000000,				/* single 0.0 */
-  0x3f800000,				/* single 1.0 */
-  0x40000000,				/* single 2.0 */
-  0x40400000,				/* single 3.0 */
-  0x40800000,				/* single 4.0 */
-  0x40a00000,				/* single 5.0 */
-  0x3f000000,				/* single 0.5 */
-  0x41200000				/* single 10.0 */
-};  
-
-unsigned int getTransferLength(const unsigned int opcode)
-{
-  unsigned int nRc;
-  
-  switch (opcode & MASK_TRANSFER_LENGTH)
-  {
-    case 0x00000000: nRc = 1; break; /* single precision */
-    case 0x00008000: nRc = 2; break; /* double precision */
-    case 0x00400000: nRc = 3; break; /* extended precision */
-    default: nRc = 0;
-  }
-  
-  return(nRc);
-}
-
-unsigned int getRegisterCount(const unsigned int opcode)
-{
-  unsigned int nRc;
-  
-  switch (opcode & MASK_REGISTER_COUNT)
-  {
-    case 0x00000000: nRc = 4; break;
-    case 0x00008000: nRc = 1; break;
-    case 0x00400000: nRc = 2; break;
-    case 0x00408000: nRc = 3; break;
-    default: nRc = 0;
-  }
-  
-  return(nRc);
-}
-
-unsigned int getRoundingPrecision(const unsigned int opcode)
-{
-  unsigned int nRc;
-  
-  switch (opcode & MASK_ROUNDING_PRECISION)
-  {
-    case 0x00000000: nRc = 1; break;
-    case 0x00000080: nRc = 2; break;
-    case 0x00080000: nRc = 3; break;
-    default: nRc = 0;
-  }
-  
-  return(nRc);
-}
-
-unsigned int getDestinationSize(const unsigned int opcode)
-{
-  unsigned int nRc;
-  
-  switch (opcode & MASK_DESTINATION_SIZE)
-  {
-    case 0x00000000: nRc = typeSingle; break;
-    case 0x00000080: nRc = typeDouble; break;
-    case 0x00080000: nRc = typeExtended; break;
-    default: nRc = typeNone;
-  }
-  
-  return(nRc);
-}
+	0x00000000,		/* single 0.0 */
+	0x3f800000,		/* single 1.0 */
+	0x40000000,		/* single 2.0 */
+	0x40400000,		/* single 3.0 */
+	0x40800000,		/* single 4.0 */
+	0x40a00000,		/* single 5.0 */
+	0x3f000000,		/* single 0.5 */
+	0x41200000		/* single 10.0 */
+};
 
 /* condition code lookup table
  index into the table is test code: EQ, NE, ... LT, GT, AL, NV
  bit position in short is condition code: NZCV */
 static const unsigned short aCC[16] = {
-    0xF0F0, // EQ == Z set
-    0x0F0F, // NE
-    0xCCCC, // CS == C set
-    0x3333, // CC
-    0xFF00, // MI == N set
-    0x00FF, // PL
-    0xAAAA, // VS == V set
-    0x5555, // VC
-    0x0C0C, // HI == C set && Z clear
-    0xF3F3, // LS == C clear || Z set
-    0xAA55, // GE == (N==V)
-    0x55AA, // LT == (N!=V)
-    0x0A05, // GT == (!Z && (N==V))
-    0xF5FA, // LE == (Z || (N!=V))
-    0xFFFF, // AL always
-    0 // NV
+	0xF0F0,			// EQ == Z set
+	0x0F0F,			// NE
+	0xCCCC,			// CS == C set
+	0x3333,			// CC
+	0xFF00,			// MI == N set
+	0x00FF,			// PL
+	0xAAAA,			// VS == V set
+	0x5555,			// VC
+	0x0C0C,			// HI == C set && Z clear
+	0xF3F3,			// LS == C clear || Z set
+	0xAA55,			// GE == (N==V)
+	0x55AA,			// LT == (N!=V)
+	0x0A05,			// GT == (!Z && (N==V))
+	0xF5FA,			// LE == (Z || (N!=V))
+	0xFFFF,			// AL always
+	0			// NV
 };
 
 unsigned int checkCondition(const unsigned int opcode, const unsigned int ccodes)
 {
-  return (aCC[opcode>>28] >> (ccodes>>28)) & 1;
+	return (aCC[opcode >> 28] >> (ccodes >> 28)) & 1;
 }
diff -Nru a/arch/arm/nwfpe/fpopcode.h b/arch/arm/nwfpe/fpopcode.h
--- a/arch/arm/nwfpe/fpopcode.h	Wed Apr 30 22:28:07 2003
+++ b/arch/arm/nwfpe/fpopcode.h	Wed Apr 30 22:28:07 2003
@@ -1,6 +1,7 @@
 /*
     NetWinder Floating Point Emulator
     (c) Rebel.COM, 1998,1999
+    (c) Philip Blundell, 2001
 
     Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
 
@@ -186,7 +187,7 @@
 #define BIT_LOAD	0x00100000
 
 /* masks for load/store */
-#define MASK_CPDT		0x0c000000  /* data processing opcode */
+#define MASK_CPDT		0x0c000000	/* data processing opcode */
 #define MASK_OFFSET		0x000000ff
 #define MASK_TRANSFER_LENGTH	0x00408000
 #define MASK_REGISTER_COUNT	MASK_TRANSFER_LENGTH
@@ -236,7 +237,7 @@
 #define MONADIC_INSTRUCTION(opcode)	((opcode & BIT_MONADIC) != 0)
 
 /* instruction identification masks */
-#define MASK_CPDO		0x0e000000  /* arithmetic opcode */
+#define MASK_CPDO		0x0e000000	/* arithmetic opcode */
 #define MASK_ARITHMETIC_OPCODE	0x00f08000
 #define MASK_DESTINATION_SIZE	0x00080080
 
@@ -282,7 +283,7 @@
 ===
 */
 
-#define MASK_CPRT		0x0e000010  /* register transfer opcode */
+#define MASK_CPRT		0x0e000010	/* register transfer opcode */
 #define MASK_CPRT_CODE		0x00f00000
 #define FLT_CODE		0x00000000
 #define FIX_CODE		0x00100000
@@ -366,25 +367,111 @@
 /* Get the rounding mode from the opcode. */
 #define getRoundingMode(opcode)		((opcode & MASK_ROUNDING_MODE) >> 5)
 
+#ifdef CONFIG_FPE_NWFPE_XP
 static inline const floatx80 getExtendedConstant(const unsigned int nIndex)
 {
-   extern const floatx80 floatx80Constant[];
-   return floatx80Constant[nIndex];
-} 
+	extern const floatx80 floatx80Constant[];
+	return floatx80Constant[nIndex];
+}
+#endif
 
 static inline const float64 getDoubleConstant(const unsigned int nIndex)
 {
-   extern const float64 float64Constant[];
-   return float64Constant[nIndex];
-} 
+	extern const float64 float64Constant[];
+	return float64Constant[nIndex];
+}
 
 static inline const float32 getSingleConstant(const unsigned int nIndex)
 {
-   extern const float32 float32Constant[];
-   return float32Constant[nIndex];
-} 
+	extern const float32 float32Constant[];
+	return float32Constant[nIndex];
+}
 
-extern unsigned int getRegisterCount(const unsigned int opcode);
-extern unsigned int getDestinationSize(const unsigned int opcode);
+static inline unsigned int getTransferLength(const unsigned int opcode)
+{
+	unsigned int nRc;
+
+	switch (opcode & MASK_TRANSFER_LENGTH) {
+	case 0x00000000:
+		nRc = 1;
+		break;		/* single precision */
+	case 0x00008000:
+		nRc = 2;
+		break;		/* double precision */
+	case 0x00400000:
+		nRc = 3;
+		break;		/* extended precision */
+	default:
+		nRc = 0;
+	}
+
+	return (nRc);
+}
+
+static inline unsigned int getRegisterCount(const unsigned int opcode)
+{
+	unsigned int nRc;
+
+	switch (opcode & MASK_REGISTER_COUNT) {
+	case 0x00000000:
+		nRc = 4;
+		break;
+	case 0x00008000:
+		nRc = 1;
+		break;
+	case 0x00400000:
+		nRc = 2;
+		break;
+	case 0x00408000:
+		nRc = 3;
+		break;
+	default:
+		nRc = 0;
+	}
+
+	return (nRc);
+}
+
+static inline unsigned int getRoundingPrecision(const unsigned int opcode)
+{
+	unsigned int nRc;
+
+	switch (opcode & MASK_ROUNDING_PRECISION) {
+	case 0x00000000:
+		nRc = 1;
+		break;
+	case 0x00000080:
+		nRc = 2;
+		break;
+	case 0x00080000:
+		nRc = 3;
+		break;
+	default:
+		nRc = 0;
+	}
+
+	return (nRc);
+}
+
+static inline unsigned int getDestinationSize(const unsigned int opcode)
+{
+	unsigned int nRc;
+
+	switch (opcode & MASK_DESTINATION_SIZE) {
+	case 0x00000000:
+		nRc = typeSingle;
+		break;
+	case 0x00000080:
+		nRc = typeDouble;
+		break;
+	case 0x00080000:
+		nRc = typeExtended;
+		break;
+	default:
+		nRc = typeNone;
+	}
+
+	return (nRc);
+}
 
 #endif
diff -Nru a/arch/arm/nwfpe/fpsr.h b/arch/arm/nwfpe/fpsr.h
--- a/arch/arm/nwfpe/fpsr.h	Wed Apr 30 22:28:05 2003
+++ b/arch/arm/nwfpe/fpsr.h	Wed Apr 30 22:28:05 2003
@@ -38,12 +38,12 @@
 ------------
 Note: the system id byte is read only  */
 
-typedef unsigned int FPSR;  /* type for floating point status register */
-typedef unsigned int FPCR;  /* type for floating point control register */
+typedef unsigned int FPSR;	/* type for floating point status register */
+typedef unsigned int FPCR;	/* type for floating point control register */
 
 #define MASK_SYSID		0xff000000
 #define BIT_HARDWARE		0x80000000
-#define FP_EMULATOR		0x01000000	/* System ID for emulator */ 
+#define FP_EMULATOR		0x01000000	/* System ID for emulator */
 #define FP_ACCELERATOR		0x81000000	/* System ID for FPA11 */
 
 /* EXCEPTION TRAP ENABLE BYTE
@@ -51,11 +51,11 @@
 
 #define MASK_TRAP_ENABLE	0x00ff0000
 #define MASK_TRAP_ENABLE_STRICT	0x001f0000
-#define BIT_IXE		0x00100000   /* inexact exception enable */
-#define BIT_UFE		0x00080000   /* underflow exception enable */
-#define BIT_OFE		0x00040000   /* overflow exception enable */
-#define BIT_DZE		0x00020000   /* divide by zero exception enable */
-#define BIT_IOE		0x00010000   /* invalid operation exception enable */
+#define BIT_IXE		0x00100000	/* inexact exception enable */
+#define BIT_UFE		0x00080000	/* underflow exception enable */
+#define BIT_OFE		0x00040000	/* overflow exception enable */
+#define BIT_DZE		0x00020000	/* divide by zero exception enable */
+#define BIT_IOE		0x00010000	/* invalid operation exception enable */
 
 /* SYSTEM CONTROL BYTE
 ---------------------- */
diff -Nru a/arch/arm/nwfpe/single_cpdo.c b/arch/arm/nwfpe/single_cpdo.c
--- a/arch/arm/nwfpe/single_cpdo.c	Wed Apr 30 22:28:18 2003
+++ b/arch/arm/nwfpe/single_cpdo.c	Wed Apr 30 22:28:18 2003
@@ -1,6 +1,7 @@
 /*
     NetWinder Floating Point Emulator
     (c) Rebel.COM, 1998,1999
+    (c) Philip Blundell, 2001
 
     Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
 
@@ -32,224 +33,92 @@
 float32 float32_log(float32 rFm);
 float32 float32_tan(float32 rFm);
 float32 float32_arccos(float32 rFm);
-float32 float32_pow(float32 rFn,float32 rFm);
-float32 float32_pol(float32 rFn,float32 rFm);
+float32 float32_pow(float32 rFn, float32 rFm);
+float32 float32_pol(float32 rFn, float32 rFm);
 
-unsigned int SingleCPDO(const unsigned int opcode)
+static float32 float32_rsf(float32 rFn, float32 rFm)
 {
-   FPA11 *fpa11 = GET_FPA11();
-   float32 rFm, rFn;
-   unsigned int Fd, Fm, Fn, nRc = 1;
-
-   Fm = getFm(opcode);
-   if (CONSTANT_FM(opcode))
-   {
-     rFm = getSingleConstant(Fm);
-   }
-   else
-   {  
-     switch (fpa11->fType[Fm])
-     {
-        case typeSingle:
-          rFm = fpa11->fpreg[Fm].fSingle;
-        break;
-        
-        default: return 0;
-     }
-   }
-
-   if (!MONADIC_INSTRUCTION(opcode))
-   {
-      Fn = getFn(opcode);
-      switch (fpa11->fType[Fn])
-      {
-        case typeSingle:
-          rFn = fpa11->fpreg[Fn].fSingle;
-        break;
-
-        default: return 0;
-      }
-   }
-
-   Fd = getFd(opcode);
-   switch (opcode & MASK_ARITHMETIC_OPCODE)
-   {
-      /* dyadic opcodes */
-      case ADF_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_add(rFn,rFm);
-      break;
-
-      case MUF_CODE:
-      case FML_CODE:
-        fpa11->fpreg[Fd].fSingle = float32_mul(rFn,rFm);
-      break;
-
-      case SUF_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_sub(rFn,rFm);
-      break;
-
-      case RSF_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_sub(rFm,rFn);
-      break;
-
-      case DVF_CODE:
-      case FDV_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_div(rFn,rFm);
-      break;
-
-      case RDF_CODE:
-      case FRD_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_div(rFm,rFn);
-      break;
-
-#if 0
-      case POW_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_pow(rFn,rFm);
-      break;
-
-      case RPW_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_pow(rFm,rFn);
-      break;
-#endif
-
-      case RMF_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_rem(rFn,rFm);
-      break;
-
-#if 0
-      case POL_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_pol(rFn,rFm);
-      break;
-#endif
-
-      /* monadic opcodes */
-      case MVF_CODE:
-         fpa11->fpreg[Fd].fSingle = rFm;
-      break;
-
-      case MNF_CODE:
-         rFm ^= 0x80000000;
-         fpa11->fpreg[Fd].fSingle = rFm;
-      break;
-
-      case ABS_CODE:
-         rFm &= 0x7fffffff;
-         fpa11->fpreg[Fd].fSingle = rFm;
-      break;
-
-      case RND_CODE:
-      case URD_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_round_to_int(rFm);
-      break;
-
-      case SQT_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_sqrt(rFm);
-      break;
-
-#if 0
-      case LOG_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_log(rFm);
-      break;
-
-      case LGN_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_ln(rFm);
-      break;
-
-      case EXP_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_exp(rFm);
-      break;
-
-      case SIN_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_sin(rFm);
-      break;
-
-      case COS_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_cos(rFm);
-      break;
-
-      case TAN_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_tan(rFm);
-      break;
-
-      case ASN_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_arcsin(rFm);
-      break;
-
-      case ACS_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_arccos(rFm);
-      break;
-
-      case ATN_CODE:
-         fpa11->fpreg[Fd].fSingle = float32_arctan(rFm);
-      break;
-#endif
-
-      case NRM_CODE:
-      break;
-      
-      default:
-      {
-        nRc = 0;
-      }
-   }
-
-   if (0 != nRc) fpa11->fType[Fd] = typeSingle;
-   return nRc;
+	return float32_sub(rFm, rFn);
 }
 
-#if 0
-float32 float32_exp(float32 Fm)
+static float32 float32_rdv(float32 rFn, float32 rFm)
 {
-//series
+	return float32_div(rFm, rFn);
 }
 
-float32 float32_ln(float32 Fm)
-{
-//series
-}
+static float32 (*const dyadic_single[16])(float32 rFn, float32 rFm) = {
+	[ADF_CODE >> 20] = float32_add,
+	[MUF_CODE >> 20] = float32_mul,
+	[SUF_CODE >> 20] = float32_sub,
+	[RSF_CODE >> 20] = float32_rsf,
+	[DVF_CODE >> 20] = float32_div,
+	[RDF_CODE >> 20] = float32_rdv,
+	[RMF_CODE >> 20] = float32_rem,
 
-float32 float32_sin(float32 rFm)
-{
-//series
-}
+	[FML_CODE >> 20] = float32_mul,
+	[FDV_CODE >> 20] = float32_div,
+	[FRD_CODE >> 20] = float32_rdv,
+};
 
-float32 float32_cos(float32 rFm)
+static float32 float32_mvf(float32 rFm)
 {
-//series
+	return rFm;
 }
 
-float32 float32_arcsin(float32 rFm)
+static float32 float32_mnf(float32 rFm)
 {
-//series
+	return rFm ^ 0x80000000;
 }
 
-float32 float32_arctan(float32 rFm)
+static float32 float32_abs(float32 rFm)
 {
-  //series
+	return rFm & 0x7fffffff;
 }
 
-float32 float32_arccos(float32 rFm)
-{
-   //return float32_sub(halfPi,float32_arcsin(rFm));
-}
+static float32 (*const monadic_single[16])(float32 rFm) = {
+	[MVF_CODE >> 20] = float32_mvf,
+	[MNF_CODE >> 20] = float32_mnf,
+	[ABS_CODE >> 20] = float32_abs,
+	[RND_CODE >> 20] = float32_round_to_int,
+	[URD_CODE >> 20] = float32_round_to_int,
+	[SQT_CODE >> 20] = float32_sqrt,
+	[NRM_CODE >> 20] = float32_mvf,
+};
 
-float32 float32_log(float32 rFm)
+unsigned int SingleCPDO(const unsigned int opcode, FPREG * rFd)
 {
-  return float32_div(float32_ln(rFm),getSingleConstant(7));
-}
+	FPA11 *fpa11 = GET_FPA11();
+	float32 rFm;
+	unsigned int Fm, opc_mask_shift;
 
-float32 float32_tan(float32 rFm)
-{
-  return float32_div(float32_sin(rFm),float32_cos(rFm));
-}
+	Fm = getFm(opcode);
+	if (CONSTANT_FM(opcode)) {
+		rFm = getSingleConstant(Fm);
+	} else if (fpa11->fType[Fm] == typeSingle) {
+		rFm = fpa11->fpreg[Fm].fSingle;
+	} else {
+		return 0;
+	}
 
-float32 float32_pow(float32 rFn,float32 rFm)
-{
-  return float32_exp(float32_mul(rFm,float32_ln(rFn))); 
-}
+	opc_mask_shift = (opcode & MASK_ARITHMETIC_OPCODE) >> 20;
+	if (!MONADIC_INSTRUCTION(opcode)) {
+		unsigned int Fn = getFn(opcode);
+		float32 rFn;
 
-float32 float32_pol(float32 rFn,float32 rFm)
-{
-  return float32_arctan(float32_div(rFn,rFm)); 
+		if (fpa11->fType[Fn] == typeSingle &&
+		    dyadic_single[opc_mask_shift]) {
+			rFn = fpa11->fpreg[Fn].fSingle;
+			rFd->fSingle = dyadic_single[opc_mask_shift](rFn, rFm);
+		} else {
+			return 0;
+		}
+	} else {
+		if (monadic_single[opc_mask_shift]) {
+			rFd->fSingle = monadic_single[opc_mask_shift](rFm);
+		} else {
+			return 0;
+		}
+	}
+
+	return 1;
 }
-#endif
diff -Nru a/arch/arm/nwfpe/softfloat.c b/arch/arm/nwfpe/softfloat.c
--- a/arch/arm/nwfpe/softfloat.c	Wed Apr 30 22:28:20 2003
+++ b/arch/arm/nwfpe/softfloat.c	Wed Apr 30 22:28:20 2003
@@ -29,8 +29,8 @@
 */
 
 #include "fpa11.h"
-#include "milieu.h"
-#include "softfloat.h"
+//#include "milieu.h"
+//#include "softfloat.h"
 
 /*
 -------------------------------------------------------------------------------
@@ -142,12 +142,14 @@
 Returns the sign bit of the single-precision floating-point value `a'.
 -------------------------------------------------------------------------------
 */
+#if 0	/* in softfloat.h */
 INLINE flag extractFloat32Sign( float32 a )
 {
 
     return a>>31;
 
 }
+#endif
 
 /*
 -------------------------------------------------------------------------------
@@ -184,9 +186,9 @@
 {
 #if 0
    float32 f;
-   __asm__("@ packFloat32;		\n\
-   	    mov %0, %1, asl #31;	\n\
-   	    orr %0, %2, asl #23;	\n\
+   __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)
@@ -321,12 +323,14 @@
 Returns the sign bit of the double-precision floating-point value `a'.
 -------------------------------------------------------------------------------
 */
+#if 0	/* in softfloat.h */
 INLINE flag extractFloat64Sign( float64 a )
 {
 
     return a>>63;
 
 }
+#endif
 
 /*
 -------------------------------------------------------------------------------
diff -Nru a/arch/arm/nwfpe/softfloat.h b/arch/arm/nwfpe/softfloat.h
--- a/arch/arm/nwfpe/softfloat.h	Wed Apr 30 22:28:04 2003
+++ b/arch/arm/nwfpe/softfloat.h	Wed Apr 30 22:28:04 2003
@@ -40,7 +40,9 @@
 input or output the `floatx80' type will be defined.
 -------------------------------------------------------------------------------
 */
+#ifdef CONFIG_FPE_NWFPE_XP
 #define FLOATX80
+#endif
 
 /*
 -------------------------------------------------------------------------------
@@ -228,5 +230,47 @@
 char floatx80_is_signaling_nan( floatx80 );
 
 #endif
+
+static inline flag extractFloat32Sign(float32 a)
+{
+	return a >> 31;
+}
+
+static inline flag float32_eq_nocheck(float32 a, float32 b)
+{
+	return (a == b) || ((bits32) ((a | b) << 1) == 0);
+}
+
+static inline flag float32_lt_nocheck(float32 a, float32 b)
+{
+	flag aSign, bSign;
+
+	aSign = extractFloat32Sign(a);
+	bSign = extractFloat32Sign(b);
+	if (aSign != bSign)
+		return aSign && ((bits32) ((a | b) << 1) != 0);
+	return (a != b) && (aSign ^ (a < b));
+}
+
+static inline flag extractFloat64Sign(float64 a)
+{
+	return a >> 63;
+}
+
+static inline flag float64_eq_nocheck(float64 a, float64 b)
+{
+	return (a == b) || ((bits64) ((a | b) << 1) == 0);
+}
+
+static inline flag float64_lt_nocheck(float64 a, float64 b)
+{
+	flag aSign, bSign;
+
+	aSign = extractFloat64Sign(a);
+	bSign = extractFloat64Sign(b);
+	if (aSign != bSign)
+		return aSign && ((bits64) ((a | b) << 1) != 0);
+	return (a != b) && (aSign ^ (a < b));
+}
 
 #endif
diff -Nru a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types
--- a/arch/arm/tools/mach-types	Wed Apr 30 22:28:09 2003
+++ b/arch/arm/tools/mach-types	Wed Apr 30 22:28:09 2003
@@ -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: Tue Mar 25 16:34:29 2003
+# Last update: Sat Apr 26 11:41:41 2003
 #
 # machine_is_xxx	CONFIG_xxxx		MACH_TYPE_xxx		number
 #
@@ -313,3 +313,18 @@
 armmodul		ARCH_ARMMODUL		ARMMODUL		302
 ketop			SA1100_KETOP		KETOP			303
 av7200			ARCH_AV7200		AV7200			304
+arch_ti925		ARCH_ARCH_TI925		ARCH_TI925		305
+acq200			ARCH_ACQ200		ACQ200			306
+pt_dafit		SA1100_PT_DAFIT		PT_DAFIT		307
+ihba			ARCH_IHBA		IHBA			308
+quinque			ARCH_QUINQUE		QUINQUE			309
+nimbraone		ARCH_NIMBRAONE		NIMBRAONE		310
+nimbra29x		ARCH_NIMBRA29X		NIMBRA29X		311
+nimbra210		ARCH_NIMBRA210		NIMBRA210		312
+hhp_d95xx		ARCH_HHP_D95XX		HHP_D95XX		313
+labarm			ARCH_LABARM		LABARM			314
+m825xx			ARCH_M825XX		M825XX			315
+m7100			SA1100_M7100		M7100			316
+nipc2			ARCH_NIPC2		NIPC2			317
+fu7202			ARCH_FU7202		FU7202			318
+adsagx			ARCH_ADSAGX		ADSAGX			319
diff -Nru a/arch/arm/vmlinux-armv.lds.in b/arch/arm/vmlinux-armv.lds.in
--- a/arch/arm/vmlinux-armv.lds.in	Wed Apr 30 22:28:07 2003
+++ b/arch/arm/vmlinux-armv.lds.in	Wed Apr 30 22:28:07 2003
@@ -35,6 +35,9 @@
 		__setup_start = .;
 			*(.init.setup)
 		__setup_end = .;
+		__early_begin = .;
+			*(__early_param)
+		__early_end = .;
 		__start___param = .;
 			*(__param)
 		__stop___param = .;
diff -Nru a/arch/cris/Kconfig b/arch/cris/Kconfig
--- a/arch/cris/Kconfig	Wed Apr 30 22:28:17 2003
+++ b/arch/cris/Kconfig	Wed Apr 30 22:28:17 2003
@@ -40,7 +40,7 @@
 	  want to say Y here.
 
 	  Information about ELF is contained in the ELF HOWTO available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you find that after upgrading from Linux kernel 1.2 and saying Y
 	  here, you still can't run any ELF binaries (they just crash), then
@@ -615,7 +615,7 @@
 	---help---
 	  If you have a CD-ROM drive that is neither SCSI nor IDE/ATAPI, say Y
 	  here, otherwise N. Read the CD-ROM-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  Note that the answer to this question doesn't directly affect the
 	  kernel: saying N will just cause the configurator to skip all
@@ -667,7 +667,7 @@
 	  interrupt and DMA channel), because you will be asked for it.
 
 	  You want to read the Sound-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. General information about
+	  <http://www.tldp.org/docs.html#howto>. General information about
 	  the modular sound system is contained in the files
 	  <file:Documentation/sound/Introduction>.  The file
 	  <file:Documentation/sound/README.OSS> contains some slightly
diff -Nru a/arch/cris/drivers/Kconfig b/arch/cris/drivers/Kconfig
--- a/arch/cris/drivers/Kconfig	Wed Apr 30 22:28:05 2003
+++ b/arch/cris/drivers/Kconfig	Wed Apr 30 22:28:05 2003
@@ -30,7 +30,7 @@
 	  If your Linux machine will be connected to an Ethernet and you have
 	  an Ethernet network interface card (NIC) installed in your computer,
 	  say Y here and read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. You will then also have
+	  <http://www.tldp.org/docs.html#howto>. You will then also have
 	  to say Y to the driver for your particular NIC.
 
 	  Note that the answer to this question won't directly affect the
@@ -392,7 +392,7 @@
 	  box (as opposed to using a serial printer; if the connector at the
 	  printer has 9 or 25 holes ["female"], then it's serial), say Y.
 	  Also read the Printing-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  It is possible to share one parallel port among several devices
 	  (e.g. printer and ZIP drive) and it is safe to compile the
@@ -485,7 +485,7 @@
 	  topics, is contained in <file:Documentation/ide.txt>. For detailed
 	  information about hard drives, consult the Disk-HOWTO and the
 	  Multi-Disk-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  To fine-tune ATA/IDE drive/interface parameters for improved
 	  performance, look for the hdparm package at
diff -Nru a/arch/cris/drivers/serial.c b/arch/cris/drivers/serial.c
--- a/arch/cris/drivers/serial.c	Wed Apr 30 22:28:12 2003
+++ b/arch/cris/drivers/serial.c	Wed Apr 30 22:28:12 2003
@@ -1402,7 +1402,7 @@
 
 	if (!E100_RTS_GET(info) &&
 	    CIRC_SPACE(info->recv.head, info->recv.tail, SERIAL_RECV_SIZE) < TTY_THROTTLE_LIMIT)
-		info->tty->driver.throttle(info->tty);
+		info->tty->driver->throttle(info->tty);
 	
 	START_FLUSH_FAST_TIMER(info, "receive_chars");
 
@@ -1658,7 +1658,7 @@
 	/* unthrottle if we have throttled */
 	if (E100_RTS_GET(info) &&
 	    CIRC_SPACE(info->recv.head, info->recv.tail, SERIAL_RECV_SIZE) > TTY_THROTTLE_LIMIT)
-		tty->driver.unthrottle(info->tty);
+		tty->driver->unthrottle(info->tty);
 }
 
 static _INLINE_ void
@@ -3049,8 +3049,8 @@
 #endif
 
 	shutdown(info);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -3169,7 +3169,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		if (info->flags & ASYNC_NORMAL_ACTIVE)
 			return -EBUSY;
 		if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
@@ -3289,7 +3289,7 @@
 
 	/* find which port we want to open */
 
-	line = MINOR(tty->device) - tty->driver.minor_start;
+	line = tty->index;
   
 	if (line < 0 || line >= NR_PORTS)
 		return -ENODEV;
@@ -3302,8 +3302,7 @@
 		return -ENODEV; 
   
 #ifdef SERIAL_DEBUG_OPEN
-	printk("[%d] rs_open %s%d, count = %d\n", current->pid,
-	       tty->driver.name, info->line,
+	printk("[%d] rs_open %s, count = %d\n", current->pid, tty->name,
 	       info->count);
 #endif
 
@@ -3359,7 +3358,7 @@
 	}
 
 	if ((info->count == 1) && (info->flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->normal_termios;
 		else 
 			*tty->termios = info->callout_termios;
diff -Nru a/arch/h8300/Kconfig b/arch/h8300/Kconfig
--- a/arch/h8300/Kconfig	Wed Apr 30 22:28:14 2003
+++ b/arch/h8300/Kconfig	Wed Apr 30 22:28:14 2003
@@ -181,7 +181,7 @@
 	  telephone line with a modem either via UUCP (UUCP is a protocol to
 	  forward mail and news between unix hosts over telephone lines; read
 	  the UUCP-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>) or dialing up a shell
+	  <http://www.tldp.org/docs.html#howto>) or dialing up a shell
 	  account or a BBS, even using term (term is a program which gives you
 	  almost full Internet connectivity if you have a regular dial up
 	  shell account on some Internet connected Unix computer. Read
@@ -201,7 +201,7 @@
 
 	  Make sure to read the NET-3-HOWTO. Eventually, you will have to read
 	  Olaf Kirch's excellent and free book "Network Administrator's
-	  Guide", to be found in <http://www.linuxdoc.org/docs.html#guide>. If
+	  Guide", to be found in <http://www.tldp.org/docs.html#guide>. If
 	  unsure, say Y.
 
 endmenu
diff -Nru a/arch/i386/Kconfig b/arch/i386/Kconfig
--- a/arch/i386/Kconfig	Wed Apr 30 22:28:05 2003
+++ b/arch/i386/Kconfig	Wed Apr 30 22:28:05 2003
@@ -183,7 +183,7 @@
 	  optimizations.
 
 config MPENTIUMIII
-	bool "Pentium-III/Celeron(Coppermine)"
+	bool "Pentium-III/Celeron(Coppermine)/Pentium-III Xeon"
 	help
 	  Select this for Intel chips based on the Pentium-III and
 	  Celeron-Coppermine core.  This option enables use of some
@@ -191,7 +191,7 @@
 	  extensions.
 
 config MPENTIUM4
-	bool "Pentium-4/Celeron(P4-based)"
+	bool "Pentium-4/Celeron(P4-based)/Xeon"
 	help
 	  Select this for Intel Pentium 4 chips.  This includes both
 	  the Pentium 4 and P4-based Celeron chips.  This option
@@ -273,6 +273,13 @@
 
 endchoice
 
+config X86_GENERIC
+       bool "Generic x86 support" 
+       help
+       	  Including some tuning for non selected x86 CPUs too.
+	  when it has moderate overhead. This is intended for generic 
+	  distributions kernels.
+
 #
 # Define implied options from the CPU selection here
 #
@@ -288,10 +295,10 @@
 
 config X86_L1_CACHE_SHIFT
 	int
+	default "7" if MPENTIUM4 || X86_GENERIC
 	default "4" if MELAN || M486 || M386
 	default "5" if MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCRUSOE || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2
 	default "6" if MK7 || MK8
-	default "7" if MPENTIUM4
 
 config RWSEM_GENERIC_SPINLOCK
 	bool
@@ -345,7 +352,7 @@
 
 config X86_INTEL_USERCOPY
 	bool
-	depends on MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M586MMX
+	depends on MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7
 	default y
 
 config X86_USE_PPRO_CHECKSUM
@@ -363,16 +370,6 @@
 	depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6
 	default y
 
-config X86_PREFETCH
-	bool
-	depends on MPENTIUMIII || MPENTIUM4 || MVIAC3_2
-	default y
-
-config X86_SSE2
-	bool
-	depends on MK8 || MPENTIUM4
-	default y
-
 config HUGETLB_PAGE
 	bool "Huge TLB Page Support"
 	help
@@ -409,10 +406,22 @@
 	  See also the <file:Documentation/smp.tex>,
 	  <file:Documentation/smp.txt>, <file:Documentation/i386/IO-APIC.txt>,
 	  <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you don't know what to do here, say N.
 
+config NR_CPUS
+	int "Maximum number of CPUs (2-32)"
+	depends on SMP
+	default "32"
+	help
+	  This allows you to specify the maximum number of CPUs which this
+	  kernel will support.  The maximum supported value is 32 and the
+	  minimum value which makes sense is 2.
+
+	  This is purely to save memory - each supported CPU adds
+	  approximately eight kilobytes to the kernel image.
+
 config PREEMPT
 	bool "Preemptible Kernel"
 	help
@@ -465,18 +474,6 @@
 	depends on !SMP && X86_UP_IOAPIC
 	default y
 
-config NR_CPUS
-	int "Maximum number of CPUs (2-32)"
-	depends on SMP
-	default "32"
-	help
-	  This allows you to specify the maximum number of CPUs which this
-	  kernel will support.  The maximum supported value is 32 and the
-	  minimum value which makes sense is 2.
-
-	  This is purely to save memory - each supported CPU adds
-	  approximately eight kilobytes to the kernel image.
-
 config X86_TSC
 	bool
 	depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2) && !X86_NUMAQ
@@ -790,7 +787,7 @@
 	  page on the WWW at
 	  <http://www.cs.utexas.edu/users/kharker/linux-laptop/> and the
 	  Battery Powered Linux mini-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  Note that, even if you say N here, Linux on the x86 architecture
 	  will issue the hlt instruction if nothing is to be done, thereby
@@ -798,7 +795,7 @@
 
 config SOFTWARE_SUSPEND
 	bool "Software Suspend (EXPERIMENTAL)"
-	depends on EXPERIMENTAL && PM
+	depends on EXPERIMENTAL && PM && SWAP
 	---help---
 	  Enable the possibilty of suspendig machine. It doesn't need APM.
 	  You may suspend your machine by 'swsusp' or 'shutdown -z <time>' 
@@ -847,7 +844,7 @@
 	  In order to use APM, you will need supporting software. For location
 	  and more information, read <file:Documentation/pm.txt> and the
 	  Battery Powered Linux mini-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver does not spin down disk drives (see the hdparm(8)
 	  manpage ("man 8 hdparm") for that), and it doesn't turn off
@@ -989,6 +986,11 @@
 	depends on (X86_VISWS || SMP) && !X86_VOYAGER
 	default y
 
+config X86_IO_APIC
+	bool
+	depends on SMP && !(X86_VISWS || X86_VOYAGER)
+	default y
+
 config PCI
 	bool "PCI support" if !X86_VISWS
 	depends on !X86_VOYAGER
@@ -1000,15 +1002,10 @@
 	  VESA. If you have PCI, say Y, otherwise N.
 
 	  The PCI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, contains valuable
+	  <http://www.tldp.org/docs.html#howto>, contains valuable
 	  information about which PCI hardware does work under Linux and which
 	  doesn't.
 
-config X86_IO_APIC
-	bool
-	depends on SMP && !(X86_VISWS || X86_VOYAGER)
-	default y
-
 choice
 	prompt "PCI access mode"
 	depends on PCI && !X86_VISWS
@@ -1048,18 +1045,6 @@
  	depends on PCI && ((PCI_GODIRECT || PCI_GOANY) || X86_VISWS)
 	default y
 
-config SCx200
-	tristate "NatSemi SCx200 support"
-	depends on !X86_VOYAGER
-	help
-	  This provides basic support for the National Semiconductor SCx200 
-	  processor.  Right now this is just a driver for the GPIO pins.
-
-	  If you don't know what to do here, say N.
-
-	  This support is also available as a module.  If compiled as a
-	  module, it will be called scx200.
-
 source "drivers/pci/Kconfig"
 
 config ISA
@@ -1105,6 +1090,18 @@
 
 source "drivers/mca/Kconfig"
 
+config SCx200
+	tristate "NatSemi SCx200 support"
+	depends on !X86_VOYAGER
+	help
+	  This provides basic support for the National Semiconductor SCx200 
+	  processor.  Right now this is just a driver for the GPIO pins.
+
+	  If you don't know what to do here, say N.
+
+	  This support is also available as a module.  If compiled as a
+	  module, it will be called scx200.
+
 config HOTPLUG
 	bool "Support for hot-pluggable devices"
 	---help---
@@ -1203,7 +1200,7 @@
 	  want to say Y here.
 
 	  Information about ELF is contained in the ELF HOWTO available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you find that after upgrading from Linux kernel 1.2 and saying Y
 	  here, you still can't run any ELF binaries (they just crash), then
@@ -1225,7 +1222,7 @@
 	  programs that need an interpreter to run like Java, Python or
 	  Emacs-Lisp. It's also useful if you often run DOS executables under
 	  the Linux DOS emulator DOSEMU (read the DOSEMU-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>). Once you have
+	  <http://www.tldp.org/docs.html#howto>). Once you have
 	  registered such a binary class with the kernel, you can start one of
 	  those programs simply by typing in its name at a shell prompt; Linux
 	  will automatically feed it to the correct interpreter.
@@ -1341,7 +1338,7 @@
 	---help---
 	  If you have a CD-ROM drive that is neither SCSI nor IDE/ATAPI, say Y
 	  here, otherwise N. Read the CD-ROM-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  Note that the answer to this question doesn't directly affect the
 	  kernel: saying N will just cause the configurator to skip all
@@ -1412,7 +1409,7 @@
 	  interrupt and DMA channel), because you will be asked for it.
 
 	  You want to read the Sound-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. General information about
+	  <http://www.tldp.org/docs.html#howto>. General information about
 	  the modular sound system is contained in the files
 	  <file:Documentation/sound/Introduction>.  The file
 	  <file:Documentation/sound/README.OSS> contains some slightly
diff -Nru a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
--- a/arch/i386/kernel/apm.c	Wed Apr 30 22:28:04 2003
+++ b/arch/i386/kernel/apm.c	Wed Apr 30 22:28:04 2003
@@ -1205,7 +1205,17 @@
 	spin_lock(&i8253_lock);
 
 	get_time_diff();
+	/*
+	 * Irq spinlock must be dropped around set_system_power_state.
+	 * We'll undo any timer changes due to interrupts below.
+	 */
+	spin_unlock(&i8253_lock);
+	write_sequnlock_irq(&xtime_lock);
+
 	err = set_system_power_state(APM_STATE_SUSPEND);
+
+	write_seqlock_irq(&xtime_lock);
+	spin_lock(&i8253_lock);
 	reinit_timer();
 	set_time();
 	ignore_normal_resume = 1;
diff -Nru a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c
--- a/arch/i386/kernel/cpu/amd.c	Wed Apr 30 22:28:18 2003
+++ b/arch/i386/kernel/cpu/amd.c	Wed Apr 30 22:28:18 2003
@@ -178,6 +178,15 @@
 			break;
 	}
 
+	switch (c->x86) {
+	case 15:
+		set_bit(X86_FEATURE_K8, c->x86_capability);
+		break;
+	case 6:
+		set_bit(X86_FEATURE_K7, c->x86_capability); 
+		break;
+	}
+
 	display_cacheinfo(c);
 }
 
diff -Nru a/arch/i386/kernel/cpu/intel.c b/arch/i386/kernel/cpu/intel.c
--- a/arch/i386/kernel/cpu/intel.c	Wed Apr 30 22:28:06 2003
+++ b/arch/i386/kernel/cpu/intel.c	Wed Apr 30 22:28:06 2003
@@ -353,6 +353,11 @@
 		break;
 	}
 #endif
+
+	if (c->x86 == 15) 
+		set_bit(X86_FEATURE_P4, c->x86_capability);
+	if (c->x86 == 6) 
+		set_bit(X86_FEATURE_P3, c->x86_capability);
 }
 
 
diff -Nru a/arch/i386/kernel/cpu/mcheck/k7.c b/arch/i386/kernel/cpu/mcheck/k7.c
--- a/arch/i386/kernel/cpu/mcheck/k7.c	Wed Apr 30 22:28:10 2003
+++ b/arch/i386/kernel/cpu/mcheck/k7.c	Wed Apr 30 22:28:10 2003
@@ -82,9 +82,6 @@
 	nr_mce_banks = l & 0xff;
 
 	for (i=0; i<nr_mce_banks; i++) {
-		/* Don't enable northbridge MCE by default on Hammer */
-		if (boot_cpu_data.x86_model == 15 && i == 4) 
-			continue;
 		wrmsr (MSR_IA32_MC0_CTL+4*i, 0xffffffff, 0xffffffff);
 		wrmsr (MSR_IA32_MC0_STATUS+4*i, 0x0, 0x0);
 	}
diff -Nru a/arch/i386/kernel/i8259.c b/arch/i386/kernel/i8259.c
--- a/arch/i386/kernel/i8259.c	Wed Apr 30 22:28:17 2003
+++ b/arch/i386/kernel/i8259.c	Wed Apr 30 22:28:17 2003
@@ -325,15 +325,16 @@
  * =PC9800NOTE= In NEC PC-9800, we use irq8 instead of irq13!
  */
 
-static void math_error_irq(int cpl, void *dev_id, struct pt_regs *regs)
+static irqreturn_t math_error_irq(int cpl, void *dev_id, struct pt_regs *regs)
 {
 	extern void math_error(void *);
 #ifndef CONFIG_X86_PC9800
 	outb(0,0xF0);
 #endif
 	if (ignore_fpu_irq || !boot_cpu_data.hard_math)
-		return;
+		return IRQ_NONE;
 	math_error((void *)regs->eip);
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
--- a/arch/i386/kernel/io_apic.c	Wed Apr 30 22:28:07 2003
+++ b/arch/i386/kernel/io_apic.c	Wed Apr 30 22:28:07 2003
@@ -269,7 +269,7 @@
 # include <linux/slab.h>		/* kmalloc() */
 # include <linux/timer.h>	/* time_after() */
  
-# if CONFIG_BALANCED_IRQ_DEBUG
+# ifdef CONFIG_BALANCED_IRQ_DEBUG
 #  define TDprintk(x...) do { printk("<%ld:%s:%d>: ", jiffies, __FILE__, __LINE__); printk(x); } while (0)
 #  define Dprintk(x...) do { TDprintk(x); } while (0)
 # else
@@ -1117,7 +1117,7 @@
 	if (current_vector == SYSCALL_VECTOR)
 		goto next;
 
-	if (current_vector > FIRST_SYSTEM_VECTOR) {
+	if (current_vector >= FIRST_SYSTEM_VECTOR) {
 		offset = (offset + 1) & 7;
 		current_vector = FIRST_DEVICE_VECTOR + offset;
 	}
diff -Nru a/arch/i386/kernel/irq.c b/arch/i386/kernel/irq.c
--- a/arch/i386/kernel/irq.c	Wed Apr 30 22:28:04 2003
+++ b/arch/i386/kernel/irq.c	Wed Apr 30 22:28:04 2003
@@ -32,6 +32,7 @@
 #include <linux/irq.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/kallsyms.h>
 
 #include <asm/atomic.h>
 #include <asm/io.h>
@@ -74,7 +75,8 @@
  * Special irq handlers.
  */
 
-void no_action(int cpl, void *dev_id, struct pt_regs *regs) { }
+irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs)
+{ return IRQ_NONE; }
 
 /*
  * Generic no controller code
@@ -202,21 +204,46 @@
  * waste of time and is not what some drivers would
  * prefer.
  */
-int handle_IRQ_event(unsigned int irq, struct pt_regs * regs, struct irqaction * action)
+int handle_IRQ_event(unsigned int irq,
+		struct pt_regs *regs, struct irqaction *action)
 {
 	int status = 1;	/* Force the "do bottom halves" bit */
+	int retval = 0;
+	struct irqaction *first_action = action;
 
 	if (!(action->flags & SA_INTERRUPT))
 		local_irq_enable();
 
 	do {
 		status |= action->flags;
-		action->handler(irq, action->dev_id, regs);
+		retval |= action->handler(irq, action->dev_id, regs);
 		action = action->next;
 	} while (action);
 	if (status & SA_SAMPLE_RANDOM)
 		add_interrupt_randomness(irq);
 	local_irq_disable();
+	if (retval != 1) {
+		static int count = 100;
+		if (count) {
+			count--;
+			if (retval) {
+				printk("irq event %d: bogus retval mask %x\n",
+					irq, retval);
+			} else {
+				printk("irq %d: nobody cared!\n", irq);
+			}
+			dump_stack();
+			printk("handlers:\n");
+			action = first_action;
+			do {
+				printk("[<%p>]", action->handler);
+				print_symbol(" (%s)",
+					(unsigned long)action->handler);
+				printk("\n");
+				action = action->next;
+			} while (action);
+		}
+	}
 
 	return status;
 }
@@ -447,7 +474,7 @@
  */
  
 int request_irq(unsigned int irq, 
-		void (*handler)(int, void *, struct pt_regs *),
+		irqreturn_t (*handler)(int, void *, struct pt_regs *),
 		unsigned long irqflags, 
 		const char * devname,
 		void *dev_id)
diff -Nru a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c
--- a/arch/i386/kernel/microcode.c	Wed Apr 30 22:28:06 2003
+++ b/arch/i386/kernel/microcode.c	Wed Apr 30 22:28:06 2003
@@ -65,7 +65,6 @@
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/miscdevice.h>
-#include <linux/devfs_fs_kernel.h>
 #include <linux/spinlock.h>
 #include <linux/mm.h>
 
@@ -116,9 +115,10 @@
 };
 
 static struct miscdevice microcode_dev = {
-	.minor = MICROCODE_MINOR,
-	.name	= "microcode",
-	.fops	= &microcode_fops,
+	.minor		= MICROCODE_MINOR,
+	.name		= "microcode",
+	.devfs_name	= "cpu/microcode",
+	.fops		= &microcode_fops,
 };
 
 static int __init microcode_init(void)
@@ -127,26 +127,17 @@
 
 	error = misc_register(&microcode_dev);
 	if (error)
-		goto fail;
-	error = devfs_mk_symlink("cpu/microcode", "../misc/microcode");
-	if (error)
-		goto fail_deregister;
+		return error;
 
 	printk(KERN_INFO 
 		"IA-32 Microcode Update Driver: v%s <tigran@veritas.com>\n", 
 		MICROCODE_VERSION);
 	return 0;
-
-fail_deregister:
-	misc_deregister(&microcode_dev);
-fail:
-	return error;
 }
 
 static void __exit microcode_exit(void)
 {
 	misc_deregister(&microcode_dev);
-	devfs_remove("cpu/microcode");
 	kfree(mc_applied);
 	printk(KERN_INFO "IA-32 Microcode Update Driver v%s unregistered\n", 
 			MICROCODE_VERSION);
diff -Nru a/arch/i386/kernel/module.c b/arch/i386/kernel/module.c
--- a/arch/i386/kernel/module.c	Wed Apr 30 22:28:09 2003
+++ b/arch/i386/kernel/module.c	Wed Apr 30 22:28:09 2003
@@ -104,9 +104,22 @@
 	return -ENOEXEC;
 }
 
+extern void apply_alternatives(void *start, void *end); 
+
 int module_finalize(const Elf_Ehdr *hdr,
 		    const Elf_Shdr *sechdrs,
 		    struct module *me)
 {
+	const Elf_Shdr *s;
+	char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
+
+	/* look for .altinstructions to patch */ 
+	for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) { 
+		void *seg; 		
+		if (strcmp(".altinstructions", secstrings + s->sh_name))
+			continue;
+		seg = (void *)s->sh_addr; 
+		apply_alternatives(seg, seg + s->sh_size); 
+	} 	
 	return 0;
 }
diff -Nru a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c
--- a/arch/i386/kernel/mpparse.c	Wed Apr 30 22:28:07 2003
+++ b/arch/i386/kernel/mpparse.c	Wed Apr 30 22:28:07 2003
@@ -1089,11 +1089,15 @@
 	list_for_each(node, &acpi_prt.entries) {
 		entry = list_entry(node, struct acpi_prt_entry, node);
 
-		/* We're only interested in static (non-link) entries. */
-		if (entry->link.handle)
-			continue;
+		/* Need to get irq for dynamic entry */
+		if (entry->link.handle) {
+			irq = acpi_pci_link_get_irq(entry->link.handle, entry->link.index);
+			if (!irq)
+				continue;
+		}
+		else
+			irq = entry->link.index;
 
-		irq = entry->link.index;
 		ioapic = mp_find_ioapic(irq);
 		if (ioapic < 0)
 			continue;
diff -Nru a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
--- a/arch/i386/kernel/setup.c	Wed Apr 30 22:28:09 2003
+++ b/arch/i386/kernel/setup.c	Wed Apr 30 22:28:09 2003
@@ -29,9 +29,7 @@
 #include <linux/ioport.h>
 #include <linux/acpi.h>
 #include <linux/apm_bios.h>
-#ifdef CONFIG_BLK_DEV_RAM
-#include <linux/blk.h>
-#endif
+#include <linux/initrd.h>
 #include <linux/bootmem.h>
 #include <linux/seq_file.h>
 #include <linux/console.h>
@@ -796,6 +794,113 @@
 	if (low_mem_size > pci_mem_start)
 		pci_mem_start = low_mem_size;
 }
+
+/* Use inline assembly to define this because the nops are defined 
+   as inline assembly strings in the include files and we cannot 
+   get them easily into strings. */
+asm("intelnops: " 
+    GENERIC_NOP1 GENERIC_NOP2 GENERIC_NOP3 GENERIC_NOP4 GENERIC_NOP5 GENERIC_NOP6
+    GENERIC_NOP7 GENERIC_NOP8); 
+asm("k8nops: " 
+    K8_NOP1 K8_NOP2 K8_NOP3 K8_NOP4 K8_NOP5 K8_NOP6
+    K8_NOP7 K8_NOP8); 
+asm("k7nops: " 
+    K7_NOP1 K7_NOP2 K7_NOP3 K7_NOP4 K7_NOP5 K7_NOP6
+    K7_NOP7 K7_NOP8); 
+    
+extern unsigned char intelnops[], k8nops[], k7nops[];
+static unsigned char *intel_nops[ASM_NOP_MAX+1] = { 
+     NULL,
+     intelnops,
+     intelnops + 1,
+     intelnops + 1 + 2,
+     intelnops + 1 + 2 + 3,
+     intelnops + 1 + 2 + 3 + 4,
+     intelnops + 1 + 2 + 3 + 4 + 5,
+     intelnops + 1 + 2 + 3 + 4 + 5 + 6,
+     intelnops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
+}; 
+static unsigned char *k8_nops[ASM_NOP_MAX+1] = { 
+     NULL,
+     k8nops,
+     k8nops + 1,
+     k8nops + 1 + 2,
+     k8nops + 1 + 2 + 3,
+     k8nops + 1 + 2 + 3 + 4,
+     k8nops + 1 + 2 + 3 + 4 + 5,
+     k8nops + 1 + 2 + 3 + 4 + 5 + 6,
+     k8nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
+}; 
+static unsigned char *k7_nops[ASM_NOP_MAX+1] = { 
+     NULL,
+     k7nops,
+     k7nops + 1,
+     k7nops + 1 + 2,
+     k7nops + 1 + 2 + 3,
+     k7nops + 1 + 2 + 3 + 4,
+     k7nops + 1 + 2 + 3 + 4 + 5,
+     k7nops + 1 + 2 + 3 + 4 + 5 + 6,
+     k7nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
+}; 
+static struct nop { 
+     int cpuid; 
+     unsigned char **noptable; 
+} noptypes[] = { 
+     { X86_FEATURE_K8, k8_nops }, 
+     { X86_FEATURE_K7, k7_nops }, 
+     { -1, 0 }
+}; 
+
+/* Replace instructions with better alternatives for this CPU type.
+
+   This runs before SMP is initialized to avoid SMP problems with
+   self modifying code. This implies that assymetric systems where
+   APs have less capabilities than the boot processor are not handled. 
+   In this case boot with "noreplacement". */ 
+void apply_alternatives(void *start, void *end) 
+{ 
+	struct alt_instr *a; 
+	int diff, i, k;
+        unsigned char **noptable = intel_nops; 
+	for (i = 0; noptypes[i].cpuid >= 0; i++) { 
+		if (boot_cpu_has(noptypes[i].cpuid)) { 
+			noptable = noptypes[i].noptable;
+			break;
+		}
+	} 
+	for (a = start; (void *)a < end; a++) { 
+		if (!boot_cpu_has(a->cpuid))
+			continue;
+		BUG_ON(a->replacementlen > a->instrlen); 
+		memcpy(a->instr, a->replacement, a->replacementlen); 
+		diff = a->instrlen - a->replacementlen; 
+		/* Pad the rest with nops */
+		for (i = a->replacementlen; diff > 0; diff -= k, i += k) {
+			k = diff;
+			if (k > ASM_NOP_MAX)
+				k = ASM_NOP_MAX;
+			memcpy(a->instr + i, noptable[k], k); 
+		} 
+	}
+} 
+
+static int no_replacement __initdata = 0; 
+ 
+void __init alternative_instructions(void)
+{
+	extern struct alt_instr __alt_instructions[], __alt_instructions_end[];
+	if (no_replacement) 
+		return;
+	apply_alternatives(__alt_instructions, __alt_instructions_end);
+}
+
+static int __init noreplacement_setup(char *s)
+{ 
+     no_replacement = 1; 
+     return 0; 
+} 
+
+__setup("noreplacement", noreplacement_setup); 
 
 void __init setup_arch(char **cmdline_p)
 {
diff -Nru a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
--- a/arch/i386/kernel/time.c	Wed Apr 30 22:28:09 2003
+++ b/arch/i386/kernel/time.c	Wed Apr 30 22:28:09 2003
@@ -124,15 +124,28 @@
 	 * made, and then undo it!
 	 */
 	tv->tv_usec -= timer->get_offset();
-	tv->tv_usec -= (jiffies - wall_jiffies) * (1000000 / HZ);
+	tv->tv_usec -= (jiffies - wall_jiffies) * (USEC_PER_SEC / HZ);
 
 	while (tv->tv_usec < 0) {
-		tv->tv_usec += 1000000;
+		tv->tv_usec += USEC_PER_SEC;
 		tv->tv_sec--;
 	}
+	tv->tv_usec *= NSEC_PER_USEC;
+
+	wall_to_monotonic.tv_sec += xtime.tv_sec - tv->tv_sec;
+	wall_to_monotonic.tv_nsec += xtime.tv_nsec - tv->tv_usec;
+
+	if (wall_to_monotonic.tv_nsec > NSEC_PER_SEC) {
+		wall_to_monotonic.tv_nsec -= NSEC_PER_SEC;
+		wall_to_monotonic.tv_sec++;
+	}
+	if (wall_to_monotonic.tv_nsec < 0) {
+		wall_to_monotonic.tv_nsec += NSEC_PER_SEC;
+		wall_to_monotonic.tv_sec--;
+	}
 
 	xtime.tv_sec = tv->tv_sec;
-	xtime.tv_nsec = (tv->tv_usec * 1000);
+	xtime.tv_nsec = tv->tv_usec;
 	time_adjust = 0;		/* stop active adjtime() */
 	time_status |= STA_UNSYNC;
 	time_maxerror = NTP_PHASE_LIMIT;
@@ -228,46 +241,11 @@
 }
 
 /*
- * Lost tick detection and compensation
- */
-static inline void detect_lost_tick(void)
-{
-	/* read time since last interrupt */
-	unsigned long delta = timer->get_offset();
-	static unsigned long dbg_print;
-	
-	/* check if delta is greater then two ticks */
-	if(delta >= 2*(1000000/HZ)){
-
-		/*
-		 * only print debug info first 5 times
-		 */
-		/*
-		 * AKPM: disable this for now; it's nice, but irritating.
-		 */
-		if (0 && dbg_print < 5) {
-			printk(KERN_WARNING "\nWarning! Detected %lu "
-				"micro-second gap between interrupts.\n",
-				delta);
-			printk(KERN_WARNING "  Compensating for %lu lost "
-				"ticks.\n",
-				delta/(1000000/HZ)-1);
-			dump_stack();
-			dbg_print++;
-		}
-		/* calculate number of missed ticks */
-		delta = delta/(1000000/HZ)-1;
-		jiffies += delta;
-	}
-		
-}
-
-/*
  * This is the same as the above, except we _also_ save the current
  * Time Stamp Counter value at the time of the timer interrupt, so that
  * we later on can estimate the time of day more exactly.
  */
-void timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	/*
 	 * Here we are in the timer irq handler. We just have irqs locally
@@ -278,13 +256,12 @@
 	 */
 	write_seqlock(&xtime_lock);
 
-	detect_lost_tick();
 	timer->mark_offset();
  
 	do_timer_interrupt(irq, NULL, regs);
 
 	write_sequnlock(&xtime_lock);
-
+	return IRQ_HANDLED;
 }
 
 /* not static: needed by APM */
@@ -322,7 +299,9 @@
 {
 	
 	xtime.tv_sec = get_cmos_time();
-	xtime.tv_nsec = 0;
+	wall_to_monotonic.tv_sec = -xtime.tv_sec + INITIAL_JIFFIES / HZ;
+	xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
+	wall_to_monotonic.tv_nsec = 0;
 
 
 	timer = select_timer();
diff -Nru a/arch/i386/kernel/timers/timer_cyclone.c b/arch/i386/kernel/timers/timer_cyclone.c
--- a/arch/i386/kernel/timers/timer_cyclone.c	Wed Apr 30 22:28:12 2003
+++ b/arch/i386/kernel/timers/timer_cyclone.c	Wed Apr 30 22:28:12 2003
@@ -18,6 +18,7 @@
 #include <asm/fixmap.h>
 
 extern spinlock_t i8253_lock;
+extern unsigned long jiffies;
 extern unsigned long calibrate_tsc(void);
 
 /* Number of usecs that the last interrupt was delayed */
@@ -46,6 +47,8 @@
 
 static void mark_offset_cyclone(void)
 {
+	unsigned long lost, delay;
+	unsigned long delta = last_cyclone_low;
 	int count;
 	unsigned long long this_offset, last_offset;
 
@@ -62,6 +65,15 @@
 	count |= inb(0x40) << 8;
 	spin_unlock(&i8253_lock);
 
+	/* lost tick compensation */
+	delta = last_cyclone_low - delta;	
+	delta /= (CYCLONE_TIMER_FREQ/1000000);
+	delta += delay_at_last_interrupt;
+	lost = delta/(1000000/HZ);
+	delay = delta%(1000000/HZ);
+	if (lost >= 2)
+		jiffies += lost-1;
+	
 	/* update the monotonic base value */
 	this_offset = ((unsigned long long)last_cyclone_high<<32)|last_cyclone_low;
 	monotonic_base += (this_offset - last_offset) & CYCLONE_TIMER_MASK;
@@ -70,6 +82,14 @@
 	/* calculate delay_at_last_interrupt */
 	count = ((LATCH-1) - count) * TICK_SIZE;
 	delay_at_last_interrupt = (count + LATCH/2) / LATCH;
+
+
+	/* catch corner case where tick rollover occured 
+	 * between cyclone and pit reads (as noted when 
+	 * usec delta is > 90% # of usecs/tick)
+	 */
+	if (abs(delay - delay_at_last_interrupt) > (900000/HZ)) 
+		jiffies++;
 }
 
 static unsigned long get_offset_cyclone(void)
diff -Nru a/arch/i386/kernel/timers/timer_pit.c b/arch/i386/kernel/timers/timer_pit.c
--- a/arch/i386/kernel/timers/timer_pit.c	Wed Apr 30 22:28:15 2003
+++ b/arch/i386/kernel/timers/timer_pit.c	Wed Apr 30 22:28:15 2003
@@ -54,7 +54,7 @@
 }
 
 
-/* This function must be called with interrupts disabled 
+/* This function must be called with xtime_lock held.
  * It was inspired by Steve McCanne's microtime-i386 for BSD.  -- jrs
  * 
  * However, the pc-audio speaker driver changes the divisor so that
@@ -93,7 +93,7 @@
 	static unsigned long jiffies_p = 0;
 
 	/*
-	 * cache volatile jiffies temporarily; we have IRQs turned off. 
+	 * cache volatile jiffies temporarily; we have xtime_lock. 
 	 */
 	unsigned long jiffies_t;
 
@@ -119,8 +119,6 @@
                 count = LATCH - 1;
         }
 	
-	spin_unlock_irqrestore(&i8253_lock, flags);
-
 	/*
 	 * avoiding timer inconsistencies (they are rare, but they happen)...
 	 * there are two kinds of problems that must be avoided here:
@@ -130,7 +128,6 @@
 	 *     (see c't 95/10 page 335 for Neptun bug.)
 	 */
 
-
 	if( jiffies_t == jiffies_p ) {
 		if( count > count_p ) {
 			/* the nutcase */
@@ -140,6 +137,8 @@
 		jiffies_p = jiffies_t;
 
 	count_p = count;
+
+	spin_unlock_irqrestore(&i8253_lock, flags);
 
 	count = ((LATCH-1) - count) * TICK_SIZE;
 	count = (count + LATCH/2) / LATCH;
diff -Nru a/arch/i386/kernel/timers/timer_tsc.c b/arch/i386/kernel/timers/timer_tsc.c
--- a/arch/i386/kernel/timers/timer_tsc.c	Wed Apr 30 22:28:12 2003
+++ b/arch/i386/kernel/timers/timer_tsc.c	Wed Apr 30 22:28:12 2003
@@ -21,6 +21,7 @@
 int tsc_disable __initdata = 0;
 
 extern spinlock_t i8253_lock;
+extern unsigned long jiffies;
 
 static int use_tsc;
 /* Number of usecs that the last interrupt was delayed */
@@ -117,6 +118,8 @@
 
 static void mark_offset_tsc(void)
 {
+	unsigned long lost,delay;
+	unsigned long delta = last_tsc_low;
 	int count;
 	int countmp;
 	static int count1 = 0;
@@ -161,6 +164,23 @@
 		}
 	}
 
+	/* lost tick compensation */
+	delta = last_tsc_low - delta;
+	{
+		register unsigned long eax, edx;
+		eax = delta;
+		__asm__("mull %2"
+		:"=a" (eax), "=d" (edx)
+		:"rm" (fast_gettimeoffset_quotient),
+		 "0" (eax));
+		delta = edx;
+	}
+	delta += delay_at_last_interrupt;
+	lost = delta/(1000000/HZ);
+	delay = delta%(1000000/HZ);
+	if (lost >= 2)
+		jiffies += lost-1;
+
 	/* update the monotonic base value */
 	this_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
 	monotonic_base += cycles_2_ns(this_offset - last_offset);
@@ -169,6 +189,13 @@
 	/* calculate delay_at_last_interrupt */
 	count = ((LATCH-1) - count) * TICK_SIZE;
 	delay_at_last_interrupt = (count + LATCH/2) / LATCH;
+
+	/* catch corner case where tick rollover occured 
+	 * between tsc and pit reads (as noted when 
+	 * usec delta is > 90% # of usecs/tick)
+	 */
+	if (abs(delay - delay_at_last_interrupt) > (900000/HZ))
+		jiffies++;
 }
 
 static void delay_tsc(unsigned long loops)
diff -Nru a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
--- a/arch/i386/kernel/traps.c	Wed Apr 30 22:28:05 2003
+++ b/arch/i386/kernel/traps.c	Wed Apr 30 22:28:05 2003
@@ -833,7 +833,6 @@
 
 #ifdef CONFIG_EISA
 int EISA_bus;
-static struct resource eisa_id = { "EISA ID", 0xc80, 0xc83, IORESOURCE_BUSY };
 #endif
 
 void __init trap_init(void)
@@ -841,8 +840,6 @@
 #ifdef CONFIG_EISA
 	if (isa_readl(0x0FFFD9) == 'E'+('I'<<8)+('S'<<16)+('A'<<24)) {
 		EISA_bus = 1;
-		if (request_resource(&ioport_resource, &eisa_id) == -EBUSY)
-			printk ("EISA port was EBUSY :-(\n");
 	}
 #endif
 
diff -Nru a/arch/i386/kernel/vm86.c b/arch/i386/kernel/vm86.c
--- a/arch/i386/kernel/vm86.c	Wed Apr 30 22:28:04 2003
+++ b/arch/i386/kernel/vm86.c	Wed Apr 30 22:28:04 2003
@@ -695,7 +695,8 @@
 	| (1 << SIGUSR1) | (1 << SIGUSR2) | (1 << SIGIO)  | (1 << SIGURG) \
 	| (1 << SIGUNUSED) )
 	
-static void irq_handler(int intno, void *dev_id, struct pt_regs * regs) {
+static irqreturn_t irq_handler(int intno, void *dev_id, struct pt_regs * regs)
+{
 	int irq_bit;
 	unsigned long flags;
 
@@ -709,6 +710,7 @@
 	/* else user will poll for IRQs */
 out:
 	spin_unlock_irqrestore(&irqbits_lock, flags);	
+	return IRQ_NONE;
 }
 
 static inline void free_vm86_irq(int irqnumber)
@@ -742,7 +744,10 @@
 	bit = irqbits & (1 << irqnumber);
 	irqbits &= ~bit;
 	spin_unlock_irqrestore(&irqbits_lock, flags);	
-	return bit;
+	if (!bit)
+		return 0;
+	enable_irq(irqnumber);
+	return 1;
 }
 
 
diff -Nru a/arch/i386/mm/discontig.c b/arch/i386/mm/discontig.c
--- a/arch/i386/mm/discontig.c	Wed Apr 30 22:28:10 2003
+++ b/arch/i386/mm/discontig.c	Wed Apr 30 22:28:10 2003
@@ -27,9 +27,7 @@
 #include <linux/bootmem.h>
 #include <linux/mmzone.h>
 #include <linux/highmem.h>
-#ifdef CONFIG_BLK_DEV_RAM
-#include <linux/blk.h>
-#endif
+#include <linux/initrd.h>
 #include <asm/e820.h>
 #include <asm/setup.h>
 
diff -Nru a/arch/i386/mm/hugetlbpage.c b/arch/i386/mm/hugetlbpage.c
--- a/arch/i386/mm/hugetlbpage.c	Wed Apr 30 22:28:17 2003
+++ b/arch/i386/mm/hugetlbpage.c	Wed Apr 30 22:28:17 2003
@@ -129,37 +129,45 @@
 int
 follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
 		    struct page **pages, struct vm_area_struct **vmas,
-		    unsigned long *st, int *length, int i)
+		    unsigned long *position, int *length, int i)
 {
-	pte_t *ptep, pte;
-	unsigned long start = *st;
-	unsigned long pstart;
-	int len = *length;
-	struct page *page;
+	unsigned long vpfn, vaddr = *position;
+	int remainder = *length;
+
+	WARN_ON(!is_vm_hugetlb_page(vma));
 
-	do {
-		pstart = start;
-		ptep = huge_pte_offset(mm, start);
-		pte = *ptep;
+	vpfn = vaddr/PAGE_SIZE;
+	while (vaddr < vma->vm_end && remainder) {
 
-back1:
-		page = pte_page(pte);
 		if (pages) {
-			page += ((start & ~HPAGE_MASK) >> PAGE_SHIFT);
+			pte_t *pte;
+			struct page *page;
+
+			pte = huge_pte_offset(mm, vaddr);
+
+			/* hugetlb should be locked, and hence, prefaulted */
+			WARN_ON(!pte || pte_none(*pte));
+
+			page = &pte_page(*pte)[vpfn % (HPAGE_SIZE/PAGE_SIZE)];
+
+			WARN_ON(!PageCompound(page));
+
 			get_page(page);
 			pages[i] = page;
 		}
+
 		if (vmas)
 			vmas[i] = vma;
-		i++;
-		len--;
-		start += PAGE_SIZE;
-		if (((start & HPAGE_MASK) == pstart) && len &&
-				(start < vma->vm_end))
-			goto back1;
-	} while (len && start < vma->vm_end);
-	*length = len;
-	*st = start;
+
+		vaddr += PAGE_SIZE;
+		++vpfn;
+		--remainder;
+		++i;
+	}
+
+	*length = remainder;
+	*position = vaddr;
+
 	return i;
 }
 
@@ -474,9 +482,7 @@
 
 int is_hugepage_mem_enough(size_t size)
 {
-	if (size > (htlbpagemem << HPAGE_SHIFT))
-		return 0;
-	return 1;
+	return (size + ~HPAGE_MASK)/HPAGE_SIZE <= htlbpagemem;
 }
 
 /*
diff -Nru a/arch/i386/mm/pgtable.c b/arch/i386/mm/pgtable.c
--- a/arch/i386/mm/pgtable.c	Wed Apr 30 22:28:20 2003
+++ b/arch/i386/mm/pgtable.c	Wed Apr 30 22:28:20 2003
@@ -131,39 +131,23 @@
 
 pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
 {
-	int count = 0;
-	pte_t *pte;
-   
-   	do {
-		pte = (pte_t *) __get_free_page(GFP_KERNEL);
-		if (pte)
-			clear_page(pte);
-		else {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pte && (count++ < 10));
+	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
+	if (pte)
+		clear_page(pte);
 	return pte;
 }
 
 struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	int count = 0;
 	struct page *pte;
-   
-   	do {
+
 #if CONFIG_HIGHPTE
-		pte = alloc_pages(GFP_KERNEL | __GFP_HIGHMEM, 0);
+	pte = alloc_pages(GFP_KERNEL|__GFP_HIGHMEM|__GFP_REPEAT, 0);
 #else
-		pte = alloc_pages(GFP_KERNEL, 0);
+	pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
 #endif
-		if (pte)
-			clear_highpage(pte);
-		else {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pte && (count++ < 10));
+	if (pte)
+		clear_highpage(pte);
 	return pte;
 }
 
diff -Nru a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
--- a/arch/i386/pci/irq.c	Wed Apr 30 22:28:19 2003
+++ b/arch/i386/pci/irq.c	Wed Apr 30 22:28:19 2003
@@ -560,8 +560,9 @@
 	return NULL;
 }
 
-static void pcibios_test_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t pcibios_test_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
 {
+	return IRQ_NONE;
 }
 
 static int pcibios_lookup_irq(struct pci_dev *dev, int assign)
diff -Nru a/arch/i386/vmlinux.lds.S b/arch/i386/vmlinux.lds.S
--- a/arch/i386/vmlinux.lds.S	Wed Apr 30 22:28:05 2003
+++ b/arch/i386/vmlinux.lds.S	Wed Apr 30 22:28:05 2003
@@ -81,6 +81,11 @@
   __con_initcall_start = .;
   .con_initcall.init : { *(.con_initcall.init) }
   __con_initcall_end = .;
+  . = ALIGN(4);
+  __alt_instructions = .;
+  .altinstructions : { *(.altinstructions) } 
+  __alt_instructions_end = .; 
+ .altinstr_replacement : { *(.altinstr_replacement) }
   . = ALIGN(4096);
   __initramfs_start = .;
   .init.ramfs : { *(.init.ramfs) }
diff -Nru a/arch/ia64/Kconfig b/arch/ia64/Kconfig
--- a/arch/ia64/Kconfig	Wed Apr 30 22:28:17 2003
+++ b/arch/ia64/Kconfig	Wed Apr 30 22:28:17 2003
@@ -280,7 +280,7 @@
 	  page on the WWW at
 	  <http://www.cs.utexas.edu/users/kharker/linux-laptop/> and the
 	  Battery Powered Linux mini-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  Note that, even if you say N here, Linux on the x86 architecture
 	  will issue the hlt instruction if nothing is to be done, thereby
@@ -425,7 +425,7 @@
 
 	  See also the <file:Documentation/smp.tex>,
 	  <file:Documentation/smp.txt>, and the SMP-HOWTO available at
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you don't know what to do here, say N.
 
@@ -497,7 +497,7 @@
 	  systems. Saying Y here will enable your kernel to run ELF binaries.
 
 	  Information about ELF is contained in the ELF HOWTO available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 config BINFMT_MISC
 	tristate "Kernel support for MISC binaries"
@@ -535,7 +535,7 @@
 	  VESA. If you have PCI, say Y, otherwise N.
 
 	  The PCI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, contains valuable
+	  <http://www.tldp.org/docs.html#howto>, contains valuable
 	  information about which PCI hardware does work under Linux and which
 	  doesn't.
 
@@ -684,7 +684,7 @@
 	---help---
 	  If you have a CD-ROM drive that is neither SCSI nor IDE/ATAPI, say Y
 	  here, otherwise N. Read the CD-ROM-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  Note that the answer to this question doesn't directly affect the
 	  kernel: saying N will just cause the configurator to skip all
@@ -762,7 +762,7 @@
 	  interrupt and DMA channel), because you will be asked for it.
 
 	  You want to read the Sound-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. General information about
+	  <http://www.tldp.org/docs.html#howto>. General information about
 	  the modular sound system is contained in the files
 	  <file:Documentation/sound/Introduction>.  The file
 	  <file:Documentation/sound/README.OSS> contains some slightly
diff -Nru a/arch/ia64/hp/sim/hpsim_console.c b/arch/ia64/hp/sim/hpsim_console.c
--- a/arch/ia64/hp/sim/hpsim_console.c	Wed Apr 30 22:28:15 2003
+++ b/arch/ia64/hp/sim/hpsim_console.c	Wed Apr 30 22:28:15 2003
@@ -27,7 +27,7 @@
 
 static int simcons_init (struct console *, char *);
 static void simcons_write (struct console *, const char *, unsigned);
-static kdev_t simcons_console_device (struct console *);
+static struct tty_driver *simcons_console_device (struct console *, int *);
 
 struct console hpsim_cons = {
 	.name =		"simcons",
@@ -57,8 +57,9 @@
 	}
 }
 
-static kdev_t
-simcons_console_device (struct console *c)
+static struct tty_driver *simcons_console_device (struct console *c, int *index)
 {
-	return mk_kdev(TTY_MAJOR, 64 + c->index);
+	extern struct tty_driver hp_serial_driver;
+	*index = c->index;
+	return &hp_serial_driver;
 }
diff -Nru a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
--- a/arch/ia64/hp/sim/simserial.c	Wed Apr 30 22:28:09 2003
+++ b/arch/ia64/hp/sim/simserial.c	Wed Apr 30 22:28:09 2003
@@ -103,7 +103,7 @@
 	{ 0, 0}
 };
 
-static struct tty_driver serial_driver, callout_driver;
+static struct tty_driver hp_serial_driver, callout_driver;
 static int serial_refcount;
 
 static struct async_struct *IRQ_ports[NR_IRQS];
@@ -676,7 +676,7 @@
 	 * the line discipline to only process XON/XOFF characters.
 	 */
 	shutdown(info);
-	if (tty->driver.flush_buffer) tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer) tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer) tty->ldisc.flush_buffer(tty);
 	info->event = 0;
 	info->tty = 0;
@@ -879,7 +879,7 @@
 	unsigned long		page;
 
 	MOD_INC_USE_COUNT;
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if ((line < 0) || (line >= NR_PORTS)) {
 		MOD_DEC_USE_COUNT;
 		return -ENODEV;
@@ -893,8 +893,7 @@
 	info->tty = tty;
 
 #ifdef SIMSERIAL_DEBUG
-	printk("rs_open %s%d, count = %d\n", tty->driver.name, info->line,
-	       info->state->count);
+	printk("rs_open %s, count = %d\n", tty->name, info->state->count);
 #endif
 	info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
 
@@ -937,7 +936,7 @@
 
 	if ((info->state->count == 1) &&
 	    (info->flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->state->normal_termios;
 		else
 			*tty->termios = info->state->callout_termios;
@@ -1029,43 +1028,43 @@
 
 	/* Initialize the tty_driver structure */
 
-	memset(&serial_driver, 0, sizeof(struct tty_driver));
-	serial_driver.magic = TTY_DRIVER_MAGIC;
-	serial_driver.driver_name = "simserial";
-	serial_driver.name = "ttyS";
-	serial_driver.major = TTY_MAJOR;
-	serial_driver.minor_start = 64;
-	serial_driver.num = 1;
-	serial_driver.type = TTY_DRIVER_TYPE_SERIAL;
-	serial_driver.subtype = SERIAL_TYPE_NORMAL;
-	serial_driver.init_termios = tty_std_termios;
-	serial_driver.init_termios.c_cflag =
+	memset(&hp_serial_driver, 0, sizeof(struct tty_driver));
+	hp_serial_driver.magic = TTY_DRIVER_MAGIC;
+	hp_serial_driver.driver_name = "simserial";
+	hp_serial_driver.name = "ttyS";
+	hp_serial_driver.major = TTY_MAJOR;
+	hp_serial_driver.minor_start = 64;
+	hp_serial_driver.num = 1;
+	hp_serial_driver.type = TTY_DRIVER_TYPE_SERIAL;
+	hp_serial_driver.subtype = SERIAL_TYPE_NORMAL;
+	hp_serial_driver.init_termios = tty_std_termios;
+	hp_serial_driver.init_termios.c_cflag =
 		B9600 | CS8 | CREAD | HUPCL | CLOCAL;
-	serial_driver.flags = TTY_DRIVER_REAL_RAW;
-	serial_driver.refcount = &serial_refcount;
-	serial_driver.table = serial_table;
-	serial_driver.termios = serial_termios;
-	serial_driver.termios_locked = serial_termios_locked;
-
-	serial_driver.open = rs_open;
-	serial_driver.close = rs_close;
-	serial_driver.write = rs_write;
-	serial_driver.put_char = rs_put_char;
-	serial_driver.flush_chars = rs_flush_chars;
-	serial_driver.write_room = rs_write_room;
-	serial_driver.chars_in_buffer = rs_chars_in_buffer;
-	serial_driver.flush_buffer = rs_flush_buffer;
-	serial_driver.ioctl = rs_ioctl;
-	serial_driver.throttle = rs_throttle;
-	serial_driver.unthrottle = rs_unthrottle;
-	serial_driver.send_xchar = rs_send_xchar;
-	serial_driver.set_termios = rs_set_termios;
-	serial_driver.stop = rs_stop;
-	serial_driver.start = rs_start;
-	serial_driver.hangup = rs_hangup;
-	serial_driver.break_ctl = rs_break;
-	serial_driver.wait_until_sent = rs_wait_until_sent;
-	serial_driver.read_proc = rs_read_proc;
+	hp_serial_driver.flags = TTY_DRIVER_REAL_RAW;
+	hp_serial_driver.refcount = &serial_refcount;
+	hp_serial_driver.table = serial_table;
+	hp_serial_driver.termios = serial_termios;
+	hp_serial_driver.termios_locked = serial_termios_locked;
+
+	hp_serial_driver.open = rs_open;
+	hp_serial_driver.close = rs_close;
+	hp_serial_driver.write = rs_write;
+	hp_serial_driver.put_char = rs_put_char;
+	hp_serial_driver.flush_chars = rs_flush_chars;
+	hp_serial_driver.write_room = rs_write_room;
+	hp_serial_driver.chars_in_buffer = rs_chars_in_buffer;
+	hp_serial_driver.flush_buffer = rs_flush_buffer;
+	hp_serial_driver.ioctl = rs_ioctl;
+	hp_serial_driver.throttle = rs_throttle;
+	hp_serial_driver.unthrottle = rs_unthrottle;
+	hp_serial_driver.send_xchar = rs_send_xchar;
+	hp_serial_driver.set_termios = rs_set_termios;
+	hp_serial_driver.stop = rs_stop;
+	hp_serial_driver.start = rs_start;
+	hp_serial_driver.hangup = rs_hangup;
+	hp_serial_driver.break_ctl = rs_break;
+	hp_serial_driver.wait_until_sent = rs_wait_until_sent;
+	hp_serial_driver.read_proc = rs_read_proc;
 
 	/*
 	 * Let's have a little bit of fun !
@@ -1088,14 +1087,14 @@
 	 * The callout device is just like normal device except for
 	 * major number and the subtype code.
 	 */
-	callout_driver = serial_driver;
+	callout_driver = hp_serial_driver;
 	callout_driver.name = "cua";
 	callout_driver.major = TTYAUX_MAJOR;
 	callout_driver.subtype = SERIAL_TYPE_CALLOUT;
 	callout_driver.read_proc = 0;
 	callout_driver.proc_entry = 0;
 
-	if (tty_register_driver(&serial_driver))
+	if (tty_register_driver(&hp_serial_driver))
 		panic("Couldn't register simserial driver\n");
 
 	if (tty_register_driver(&callout_driver))
diff -Nru a/arch/ia64/ia32/ia32_entry.S b/arch/ia64/ia32/ia32_entry.S
--- a/arch/ia64/ia32/ia32_entry.S	Wed Apr 30 22:28:10 2003
+++ b/arch/ia64/ia32/ia32_entry.S	Wed Apr 30 22:28:10 2003
@@ -252,7 +252,7 @@
 	data8 sys_acct
 	data8 sys_umount	  /* recycled never used phys( */
 	data8 sys32_ni_syscall	  /* old lock syscall holder */
-	data8 sys32_ioctl
+	data8 compat_sys_ioctl
 	data8 compat_sys_fcntl	  /* 55 */
 	data8 sys32_ni_syscall	  /* old mpx syscall holder */
 	data8 sys_setpgid
diff -Nru a/arch/ia64/ia32/ia32_ioctl.c b/arch/ia64/ia32/ia32_ioctl.c
--- a/arch/ia64/ia32/ia32_ioctl.c	Wed Apr 30 22:28:14 2003
+++ b/arch/ia64/ia32/ia32_ioctl.c	Wed Apr 30 22:28:14 2003
@@ -293,221 +293,3 @@
 	}
 	return err;
 }
-
-asmlinkage long
-sys32_ioctl (unsigned int fd, unsigned int cmd, unsigned int arg)
-{
-	long ret;
-
-	switch (IOCTL_NR(cmd)) {
-	      case IOCTL_NR(VFAT_IOCTL_READDIR_SHORT):
-	      case IOCTL_NR(VFAT_IOCTL_READDIR_BOTH): {
-		      struct linux32_dirent *d32 = P(arg);
-		      struct dirent d[2];
-
-		      ret = DO_IOCTL(fd, _IOR('r', _IOC_NR(cmd),
-					      struct dirent [2]),
-				     (unsigned long) d);
-		      if (ret < 0)
-			  return ret;
-
-		      if (put_dirent32(d, d32) || put_dirent32(d + 1, d32 + 1))
-			  return -EFAULT;
-
-		      return ret;
-	      }
-		case IOCTL_NR(SIOCGIFCONF):
-		{
-			struct ifconf32 {
-				int		ifc_len;
-				unsigned int	ifc_ptr;
-			} ifconf32;
-			struct ifconf ifconf;
-			int i, n;
-			char *p32, *p64;
-			char buf[32];	/* sizeof IA32 ifreq structure */
-
-			if (copy_from_user(&ifconf32, P(arg), sizeof(ifconf32)))
-				return -EFAULT;
-			ifconf.ifc_len = ifconf32.ifc_len;
-			ifconf.ifc_req = P(ifconf32.ifc_ptr);
-			ret = DO_IOCTL(fd, SIOCGIFCONF, &ifconf);
-			ifconf32.ifc_len = ifconf.ifc_len;
-			if (copy_to_user(P(arg), &ifconf32, sizeof(ifconf32)))
-				return -EFAULT;
-			n = ifconf.ifc_len / sizeof(struct ifreq);
-			p32 = P(ifconf32.ifc_ptr);
-			p64 = P(ifconf32.ifc_ptr);
-			for (i = 0; i < n; i++) {
-				if (copy_from_user(buf, p64, sizeof(struct ifreq)))
-					return -EFAULT;
-				if (copy_to_user(p32, buf, sizeof(buf)))
-					return -EFAULT;
-				p32 += sizeof(buf);
-				p64 += sizeof(struct ifreq);
-			}
-			return ret;
-		}
-
-	      case IOCTL_NR(DRM_IOCTL_VERSION):
-	      {
-		      drm_version_t ver;
-		      struct {
-			      int	version_major;
-			      int	version_minor;
-			      int	version_patchlevel;
-			      unsigned int name_len;
-			      unsigned int name; /* pointer */
-			      unsigned int date_len;
-			      unsigned int date; /* pointer */
-			      unsigned int desc_len;
-			      unsigned int desc; /* pointer */
-		      } ver32;
-
-		      if (copy_from_user(&ver32, P(arg), sizeof(ver32)))
-			      return -EFAULT;
-		      ver.name_len = ver32.name_len;
-		      ver.name = P(ver32.name);
-		      ver.date_len = ver32.date_len;
-		      ver.date = P(ver32.date);
-		      ver.desc_len = ver32.desc_len;
-		      ver.desc = P(ver32.desc);
-		      ret = DO_IOCTL(fd, DRM_IOCTL_VERSION, &ver);
-		      if (ret >= 0) {
-			      ver32.version_major = ver.version_major;
-			      ver32.version_minor = ver.version_minor;
-			      ver32.version_patchlevel = ver.version_patchlevel;
-			      ver32.name_len = ver.name_len;
-			      ver32.date_len = ver.date_len;
-			      ver32.desc_len = ver.desc_len;
-			      if (copy_to_user(P(arg), &ver32, sizeof(ver32)))
-				      return -EFAULT;
-		      }
-		      return ret;
-	      }
-
-	      case IOCTL_NR(DRM_IOCTL_GET_UNIQUE):
-	      {
-		      drm_unique_t un;
-		      struct {
-			      unsigned int unique_len;
-			      unsigned int unique;
-		      } un32;
-
-		      if (copy_from_user(&un32, P(arg), sizeof(un32)))
-			      return -EFAULT;
-		      un.unique_len = un32.unique_len;
-		      un.unique = P(un32.unique);
-		      ret = DO_IOCTL(fd, DRM_IOCTL_GET_UNIQUE, &un);
-		      if (ret >= 0) {
-			      un32.unique_len = un.unique_len;
-			      if (copy_to_user(P(arg), &un32, sizeof(un32)))
-				      return -EFAULT;
-		      }
-		      return ret;
-	      }
-	      case IOCTL_NR(DRM_IOCTL_SET_UNIQUE):
-	      case IOCTL_NR(DRM_IOCTL_ADD_MAP):
-	      case IOCTL_NR(DRM_IOCTL_ADD_BUFS):
-	      case IOCTL_NR(DRM_IOCTL_MARK_BUFS):
-	      case IOCTL_NR(DRM_IOCTL_INFO_BUFS):
-	      case IOCTL_NR(DRM_IOCTL_MAP_BUFS):
-	      case IOCTL_NR(DRM_IOCTL_FREE_BUFS):
-	      case IOCTL_NR(DRM_IOCTL_ADD_CTX):
-	      case IOCTL_NR(DRM_IOCTL_RM_CTX):
-	      case IOCTL_NR(DRM_IOCTL_MOD_CTX):
-	      case IOCTL_NR(DRM_IOCTL_GET_CTX):
-	      case IOCTL_NR(DRM_IOCTL_SWITCH_CTX):
-	      case IOCTL_NR(DRM_IOCTL_NEW_CTX):
-	      case IOCTL_NR(DRM_IOCTL_RES_CTX):
-
-	      case IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE):
-	      case IOCTL_NR(DRM_IOCTL_AGP_RELEASE):
-	      case IOCTL_NR(DRM_IOCTL_AGP_ENABLE):
-	      case IOCTL_NR(DRM_IOCTL_AGP_INFO):
-	      case IOCTL_NR(DRM_IOCTL_AGP_ALLOC):
-	      case IOCTL_NR(DRM_IOCTL_AGP_FREE):
-	      case IOCTL_NR(DRM_IOCTL_AGP_BIND):
-	      case IOCTL_NR(DRM_IOCTL_AGP_UNBIND):
-
-		/* Mga specific ioctls */
-
-	      case IOCTL_NR(DRM_IOCTL_MGA_INIT):
-
-		/* I810 specific ioctls */
-
-	      case IOCTL_NR(DRM_IOCTL_I810_GETBUF):
-	      case IOCTL_NR(DRM_IOCTL_I810_COPY):
-
-	      case IOCTL_NR(MTIOCGET):
-	      case IOCTL_NR(MTIOCPOS):
-	      case IOCTL_NR(MTIOCGETCONFIG):
-	      case IOCTL_NR(MTIOCSETCONFIG):
-	      case IOCTL_NR(PPPIOCSCOMPRESS):
-	      case IOCTL_NR(PPPIOCGIDLE):
-	      case IOCTL_NR(NCP_IOC_GET_FS_INFO_V2):
-	      case IOCTL_NR(NCP_IOC_GETOBJECTNAME):
-	      case IOCTL_NR(NCP_IOC_SETOBJECTNAME):
-	      case IOCTL_NR(NCP_IOC_GETPRIVATEDATA):
-	      case IOCTL_NR(NCP_IOC_SETPRIVATEDATA):
-	      case IOCTL_NR(NCP_IOC_GETMOUNTUID2):
-	      case IOCTL_NR(CAPI_MANUFACTURER_CMD):
-	      case IOCTL_NR(VIDIOCGTUNER):
-	      case IOCTL_NR(VIDIOCSTUNER):
-	      case IOCTL_NR(VIDIOCGWIN):
-	      case IOCTL_NR(VIDIOCSWIN):
-	      case IOCTL_NR(VIDIOCGFBUF):
-	      case IOCTL_NR(VIDIOCSFBUF):
-	      case IOCTL_NR(MGSL_IOCSPARAMS):
-	      case IOCTL_NR(MGSL_IOCGPARAMS):
-	      case IOCTL_NR(ATM_GETNAMES):
-	      case IOCTL_NR(ATM_GETLINKRATE):
-	      case IOCTL_NR(ATM_GETTYPE):
-	      case IOCTL_NR(ATM_GETESI):
-	      case IOCTL_NR(ATM_GETADDR):
-	      case IOCTL_NR(ATM_RSTADDR):
-	      case IOCTL_NR(ATM_ADDADDR):
-	      case IOCTL_NR(ATM_DELADDR):
-	      case IOCTL_NR(ATM_GETCIRANGE):
-	      case IOCTL_NR(ATM_SETCIRANGE):
-	      case IOCTL_NR(ATM_SETESI):
-	      case IOCTL_NR(ATM_SETESIF):
-	      case IOCTL_NR(ATM_GETSTAT):
-	      case IOCTL_NR(ATM_GETSTATZ):
-	      case IOCTL_NR(ATM_GETLOOP):
-	      case IOCTL_NR(ATM_SETLOOP):
-	      case IOCTL_NR(ATM_QUERYLOOP):
-	      case IOCTL_NR(ENI_SETMULT):
-	      case IOCTL_NR(NS_GETPSTAT):
-		/* case IOCTL_NR(NS_SETBUFLEV): This is a duplicate case with ZATM_GETPOOLZ */
-	      case IOCTL_NR(ZATM_GETPOOLZ):
-	      case IOCTL_NR(ZATM_GETPOOL):
-	      case IOCTL_NR(ZATM_SETPOOL):
-	      case IOCTL_NR(ZATM_GETTHIST):
-	      case IOCTL_NR(IDT77105_GETSTAT):
-	      case IOCTL_NR(IDT77105_GETSTATZ):
-	      case IOCTL_NR(IXJCTL_TONE_CADENCE):
-	      case IOCTL_NR(IXJCTL_FRAMES_READ):
-	      case IOCTL_NR(IXJCTL_FRAMES_WRITTEN):
-	      case IOCTL_NR(IXJCTL_READ_WAIT):
-	      case IOCTL_NR(IXJCTL_WRITE_WAIT):
-	      case IOCTL_NR(IXJCTL_DRYBUFFER_READ):
-	      case IOCTL_NR(I2OHRTGET):
-	      case IOCTL_NR(I2OLCTGET):
-	      case IOCTL_NR(I2OPARMSET):
-	      case IOCTL_NR(I2OPARMGET):
-	      case IOCTL_NR(I2OSWDL):
-	      case IOCTL_NR(I2OSWUL):
-	      case IOCTL_NR(I2OSWDEL):
-	      case IOCTL_NR(I2OHTML):
-		break;
-	      default:
-		return sys_ioctl(fd, cmd, (unsigned long)arg);
-
-		case IOCTL_NR(SG_IO):
-			return(sg_ioctl_trans(fd, cmd, arg));
-
-	}
-	printk(KERN_ERR "%x:unimplemented IA32 ioctl system call\n", cmd);
-	return -EINVAL;
-}
diff -Nru a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
--- a/arch/ia64/ia32/sys_ia32.c	Wed Apr 30 22:28:11 2003
+++ b/arch/ia64/ia32/sys_ia32.c	Wed Apr 30 22:28:11 2003
@@ -3040,7 +3040,6 @@
 #define ca32_svc	u.u32_svc
 #define ca32_client	u.u32_client
 #define ca32_export	u.u32_export
-#define ca32_authd	u.u32_authd
 #define ca32_debug	u.u32_debug
 };
 
diff -Nru a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
--- a/arch/ia64/kernel/perfmon.c	Wed Apr 30 22:28:17 2003
+++ b/arch/ia64/kernel/perfmon.c	Wed Apr 30 22:28:17 2003
@@ -21,7 +21,6 @@
 #include <linux/proc_fs.h>
 #include <linux/init.h>
 #include <linux/vmalloc.h>
-#include <linux/wrapper.h>
 #include <linux/mm.h>
 #include <linux/sysctl.h>
 #include <linux/smp.h>
@@ -555,7 +554,7 @@
 		memset(mem, 0, size); /* Clear the ram out, no junk to the user */
 		adr=(unsigned long) mem;
 		while (size > 0) {
-			mem_map_reserve(vmalloc_to_page((void *)adr));
+			SetPageReserved(vmalloc_to_page((void *)adr));
 			adr+=PAGE_SIZE;
 			size-=PAGE_SIZE;
 		}
@@ -571,7 +570,7 @@
 	if (mem) {
 		adr=(unsigned long) mem;
 		while ((long) size > 0) {
-			mem_map_unreserve(vmalloc_to_page((void*)adr));
+			ClearPageReserved(vmalloc_to_page((void*)adr));
 			adr+=PAGE_SIZE;
 			size-=PAGE_SIZE;
 		}
diff -Nru a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
--- a/arch/ia64/kernel/setup.c	Wed Apr 30 22:28:05 2003
+++ b/arch/ia64/kernel/setup.c	Wed Apr 30 22:28:05 2003
@@ -31,6 +31,7 @@
 #include <linux/threads.h>
 #include <linux/tty.h>
 #include <linux/efi.h>
+#include <linux/initrd.h>
 
 #include <asm/ia32.h>
 #include <asm/page.h>
@@ -41,10 +42,6 @@
 #include <asm/system.h>
 #include <asm/mca.h>
 #include <asm/smp.h>
-
-#ifdef CONFIG_BLK_DEV_RAM
-# include <linux/blk.h>
-#endif
 
 #if defined(CONFIG_SMP) && (IA64_CPU_SIZE > PAGE_SIZE)
 # error "struct cpuinfo_ia64 too big!"
diff -Nru a/arch/ia64/sn/io/pci_bus_cvlink.c b/arch/ia64/sn/io/pci_bus_cvlink.c
--- a/arch/ia64/sn/io/pci_bus_cvlink.c	Wed Apr 30 22:28:14 2003
+++ b/arch/ia64/sn/io/pci_bus_cvlink.c	Wed Apr 30 22:28:14 2003
@@ -373,12 +373,6 @@
 #endif
 
 	/*
-	 * Set the root start and end for Mem Resource.
-	 */
-	iomem_resource.start = 0;
-	iomem_resource.end = 0xffffffffffffffff;
-
-	/*
 	 * Initialize the device vertex in the pci_dev struct.
 	 */
 	pci_for_each_dev(device_dev) {
diff -Nru a/arch/ia64/sn/io/sn2/pci_bus_cvlink.c b/arch/ia64/sn/io/sn2/pci_bus_cvlink.c
--- a/arch/ia64/sn/io/sn2/pci_bus_cvlink.c	Wed Apr 30 22:28:04 2003
+++ b/arch/ia64/sn/io/sn2/pci_bus_cvlink.c	Wed Apr 30 22:28:04 2003
@@ -323,12 +323,6 @@
 	ioport_resource.end =    0xcfffffffffffffff;
 
 	/*
-	 * Set the root start and end for Mem Resource.
-	 */
-	iomem_resource.start = 0;
-	iomem_resource.end = 0xffffffffffffffff;
-
-	/*
 	 * Initialize the device vertex in the pci_dev struct.
 	 */
 	pci_for_each_dev(device_dev) {
diff -Nru a/arch/m68k/Kconfig b/arch/m68k/Kconfig
--- a/arch/m68k/Kconfig	Wed Apr 30 22:28:10 2003
+++ b/arch/m68k/Kconfig	Wed Apr 30 22:28:10 2003
@@ -65,7 +65,7 @@
 	  To use your PC-cards, you will need supporting software from David
 	  Hinds' pcmcia-cs package (see the file <file:Documentation/Changes>
 	  for location).  Please also read the PCMCIA-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -106,7 +106,7 @@
 	  VESA. If you have PCI, say Y, otherwise N.
 
 	  The PCI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, contains valuable
+	  <http://www.tldp.org/docs.html#howto>, contains valuable
 	  information about which PCI hardware does work under Linux and which
 	  doesn't.
 
@@ -413,7 +413,7 @@
 	  want to say Y here.
 
 	  Information about ELF is contained in the ELF HOWTO available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you find that after upgrading from Linux kernel 1.2 and saying Y
 	  here, you still can't run any ELF binaries (they just crash), then
@@ -435,7 +435,7 @@
 	  programs that need an interpreter to run like Java, Python or
 	  Emacs-Lisp. It's also useful if you often run DOS executables under
 	  the Linux DOS emulator DOSEMU (read the DOSEMU-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>). Once you have
+	  <http://www.tldp.org/docs.html#howto>). Once you have
 	  registered such a binary class with the kernel, you can start one of
 	  those programs simply by typing in its name at a shell prompt; Linux
 	  will automatically feed it to the correct interpreter.
@@ -592,7 +592,7 @@
 	  box (as opposed to using a serial printer; if the connector at the
 	  printer has 9 or 25 holes ["female"], then it's serial), say Y.
 	  Also read the Printing-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  It is possible to share one parallel port among several devices
 	  (e.g. printer and ZIP drive) and it is safe to compile the
@@ -741,7 +741,7 @@
 	  If you want to use a SCSI hard disk or the SCSI or parallel port
 	  version of the IOMEGA ZIP drive under Linux, say Y and read the
 	  SCSI-HOWTO, the Disk-HOWTO and the Multi-Disk-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. This is NOT for SCSI
+	  <http://www.tldp.org/docs.html#howto>. This is NOT for SCSI
 	  CD-ROMs.
 
 	  This driver is also available as a module ( = code which can be
@@ -776,7 +776,7 @@
 	---help---
 	  If you want to use a SCSI tape drive under Linux, say Y and read the
 	  SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, and
+	  <http://www.tldp.org/docs.html#howto>, and
 	  <file:Documentation/scsi/st.txt> in the kernel source.  This is NOT for
 	  SCSI CD-ROMs.
 
@@ -809,7 +809,7 @@
 	---help---
 	  If you want to use a SCSI CD-ROM under Linux, say Y and read the
 	  SCSI-HOWTO and the CD-ROM-HOWTO at
-	  <http://www.linuxdoc.org/docs.html#howto>. Also make sure to say Y
+	  <http://www.tldp.org/docs.html#howto>. Also make sure to say Y
 	  or M to "ISO 9660 CD-ROM file system support" later.
 
 	  This driver is also available as a module ( = code which can be
@@ -1084,7 +1084,7 @@
 	  This is the NCR 5380 SCSI controller included on most of the 68030
 	  based Macintoshes.  If you have one of these say Y and read the
 	  SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 config SCSI_MAC_ESP
 	tristate "Macintosh NCR53c9[46] SCSI"
@@ -1093,7 +1093,7 @@
 	  This is the NCR 53c9x SCSI controller found on most of the 68040
 	  based Macintoshes.  If you have one of these say Y and read the
 	  SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -1201,7 +1201,7 @@
 	  Say Y here if you have dumb serial boards other than the four
 	  standard COM 1/2/3/4 ports. This may happen if you have an AST
 	  FourPort, Accent Async, Boca (read the Boca mini-HOWTO, available
-	  from <http://www.linuxdoc.org/docs.html#howto>), or other custom
+	  from <http://www.tldp.org/docs.html#howto>), or other custom
 	  serial port hardware which acts similar to standard serial port
 	  hardware. If you only use the standard COM 1/2/3/4 ports, you can
 	  say N here to save some memory. You can also say Y if you have an
diff -Nru a/arch/m68k/kernel/setup.c b/arch/m68k/kernel/setup.c
--- a/arch/m68k/kernel/setup.c	Wed Apr 30 22:28:17 2003
+++ b/arch/m68k/kernel/setup.c	Wed Apr 30 22:28:17 2003
@@ -23,6 +23,7 @@
 #include <linux/bootmem.h>
 #include <linux/seq_file.h>
 #include <linux/module.h>
+#include <linux/initrd.h>
 
 #include <asm/bootinfo.h>
 #include <asm/setup.h>
@@ -39,10 +40,6 @@
 #ifdef CONFIG_SUN3X
 #include <asm/dvma.h>
 extern void sun_serial_setup(void);
-#endif
-
-#ifdef CONFIG_BLK_DEV_INITRD
-#include <linux/blk.h>
 #endif
 
 unsigned long m68k_machtype;
diff -Nru a/arch/m68k/sun3x/prom.c b/arch/m68k/sun3x/prom.c
--- a/arch/m68k/sun3x/prom.c	Wed Apr 30 22:28:08 2003
+++ b/arch/m68k/sun3x/prom.c	Wed Apr 30 22:28:08 2003
@@ -90,16 +90,10 @@
 /* debug console - write-only */
 
 static struct console sun3x_debug = {
-	"debug",
-	sun3x_prom_write,  	/* write */
-	NULL,			/* read */
-	NULL,			/* device */
-	NULL,			/* unblank */
-	NULL,			/* setup */
-	CON_PRINTBUFFER,
-	-1,
-	0,
-	NULL
+	.name  =	"debug",
+	.write =	sun3x_prom_write,
+	.flags =	CON_PRINTBUFFER,
+	.index =	-1,
 };
 
 void sun3x_prom_init(void)
diff -Nru a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig
--- a/arch/m68knommu/Kconfig	Wed Apr 30 22:28:12 2003
+++ b/arch/m68knommu/Kconfig	Wed Apr 30 22:28:12 2003
@@ -563,7 +563,7 @@
 	---help---
 	  If you have a CD-ROM drive that is neither SCSI nor IDE/ATAPI, say Y
 	  here, otherwise N. Read the CD-ROM-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  Note that the answer to this question doesn't directly affect the
 	  kernel: saying N will just cause the configurator to skip all
@@ -635,7 +635,7 @@
 	  interrupt and DMA channel), because you will be asked for it.
 
 	  You want to read the Sound-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. General information about
+	  <http://www.tldp.org/docs.html#howto>. General information about
 	  the modular sound system is contained in the files
 	  <file:Documentation/sound/Introduction>.  The file
 	  <file:Documentation/sound/README.OSS> contains some slightly
diff -Nru a/arch/mips/Kconfig b/arch/mips/Kconfig
--- a/arch/mips/Kconfig	Wed Apr 30 22:28:09 2003
+++ b/arch/mips/Kconfig	Wed Apr 30 22:28:09 2003
@@ -35,7 +35,7 @@
 	  See also the <file:Documentation/smp.tex>,
 	  <file:Documentation/smp.txt>, <file:Documentation/i386/IO-APIC.txt>,
 	  <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you don't know what to do here, say N.
 
@@ -363,7 +363,7 @@
 	  VESA. If you have PCI, say Y, otherwise N.
 
 	  The PCI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, contains valuable
+	  <http://www.tldp.org/docs.html#howto>, contains valuable
 	  information about which PCI hardware does work under Linux and which
 	  doesn't.
 
@@ -740,7 +740,7 @@
 	  want to say Y here.
 
 	  Information about ELF is contained in the ELF HOWTO available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you find that after upgrading from Linux kernel 1.2 and saying Y
 	  here, you still can't run any ELF binaries (they just crash), then
@@ -762,7 +762,7 @@
 	  programs that need an interpreter to run like Java, Python or
 	  Emacs-Lisp. It's also useful if you often run DOS executables under
 	  the Linux DOS emulator DOSEMU (read the DOSEMU-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>). Once you have
+	  <http://www.tldp.org/docs.html#howto>). Once you have
 	  registered such a binary class with the kernel, you can start one of
 	  those programs simply by typing in its name at a shell prompt; Linux
 	  will automatically feed it to the correct interpreter.
@@ -931,7 +931,7 @@
 	---help---
 	  If you have a CD-ROM drive that is neither SCSI nor IDE/ATAPI, say Y
 	  here, otherwise N. Read the CD-ROM-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  Note that the answer to this question doesn't directly affect the
 	  kernel: saying N will just cause the configurator to skip all
@@ -1083,7 +1083,7 @@
 
 	  Although PS/2 mice are not technically bus mice, they are explained
 	  in detail in the Busmouse-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  When using a PS/2 mouse, you can get problems if you want to use the
 	  mouse both on the Linux console and under X. Using the "-R" option
@@ -1102,7 +1102,7 @@
 	  MouseSystem or Microsoft mouse (made by Logitech) that plugs into a
 	  COM port (rectangular with 9 or 25 pins). These people say N here.
 	  If you have something else, read the Busmouse-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. This HOWTO contains
+	  <http://www.tldp.org/docs.html#howto>. This HOWTO contains
 	  information about all non-serial mice, not just bus mice.
 
 	  If you have a laptop, you either have to check the documentation or
@@ -1139,7 +1139,7 @@
 	  interrupt and DMA channel), because you will be asked for it.
 
 	  You want to read the Sound-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. General information about
+	  <http://www.tldp.org/docs.html#howto>. General information about
 	  the modular sound system is contained in the files
 	  <file:Documentation/sound/Introduction>.  The file
 	  <file:Documentation/sound/README.OSS> contains some slightly
diff -Nru a/arch/mips/au1000/common/serial.c b/arch/mips/au1000/common/serial.c
--- a/arch/mips/au1000/common/serial.c	Wed Apr 30 22:28:07 2003
+++ b/arch/mips/au1000/common/serial.c	Wed Apr 30 22:28:07 2003
@@ -195,7 +195,7 @@
 
 #if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT)
 #define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \
- cdevname(tty->device), (info->flags), serial_refcount,info->count,tty->count,s)
+ tty->name, (info->flags), serial_refcount,info->count,tty->count,s)
 #else
 #define DBG_CNT(s)
 #endif
@@ -218,7 +218,7 @@
 
 
 static inline int serial_paranoia_check(struct async_struct *info,
-					kdev_t device, const char *routine)
+					char *name, const char *routine)
 {
 #ifdef SERIAL_PARANOIA_CHECK
 	static const char *badmagic =
@@ -227,11 +227,11 @@
 		"Warning: null async_struct for (%s) in %s\n";
 
 	if (!info) {
-		printk(badinfo, cdevname(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (info->magic != SERIAL_MAGIC) {
-		printk(badmagic, cdevname(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -273,7 +273,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_stop"))
+	if (serial_paranoia_check(info, tty->name, "rs_stop"))
 		return;
 	
 	save_flags(flags); cli();
@@ -289,7 +289,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_start"))
+	if (serial_paranoia_check(info, tty->name, "rs_start"))
 		return;
 	
 	save_flags(flags); cli();
@@ -1144,7 +1144,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_put_char"))
+	if (serial_paranoia_check(info, tty->name, "rs_put_char"))
 		return;
 
 	if (!tty || !info->xmit.buf)
@@ -1168,7 +1168,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_flush_chars"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
 		return;
 
 	if (info->xmit.head == info->xmit.tail
@@ -1190,7 +1190,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_write"))
+	if (serial_paranoia_check(info, tty->name, "rs_write"))
 		return 0;
 
 	if (!tty || !info->xmit.buf || !tmp_buf)
@@ -1264,7 +1264,7 @@
 {
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 
-	if (serial_paranoia_check(info, tty->device, "rs_write_room"))
+	if (serial_paranoia_check(info, tty->name, "rs_write_room"))
 		return 0;
 	return CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
 }
@@ -1273,7 +1273,7 @@
 {
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_chars_in_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
 		return 0;
 	return CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
 }
@@ -1283,7 +1283,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_flush_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
 		return;
 	save_flags(flags); cli();
 	info->xmit.head = info->xmit.tail = 0;
@@ -1305,7 +1305,7 @@
 {
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 
-	if (serial_paranoia_check(info, tty->device, "rs_send_char"))
+	if (serial_paranoia_check(info, tty->name, "rs_send_char"))
 		return;
 
 	info->x_char = ch;
@@ -1335,7 +1335,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_throttle"))
+	if (serial_paranoia_check(info, tty->name, "rs_throttle"))
 		return;
 	
 	if (I_IXOFF(tty))
@@ -1360,7 +1360,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_unthrottle"))
+	if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
 		return;
 	
 	if (I_IXOFF(tty)) {
@@ -1451,7 +1451,7 @@
 		goto check_and_exit;
 	}
 
-	new_serial.irq = irq_cannonicalize(new_serial.irq);
+	new_serial.irq = irq_canonicalize(new_serial.irq);
 
 	if ((new_serial.irq >= NR_IRQS) || (new_serial.irq < 0) || 
 	    (new_serial.baud_base < 9600)|| (new_serial.type < PORT_UNKNOWN) ||
@@ -1697,7 +1697,7 @@
 	struct async_struct * info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_break"))
+	if (serial_paranoia_check(info, tty->name, "rs_break"))
 		return;
 
 	if (!CONFIGURED_SERIAL_PORT(info))
@@ -1720,7 +1720,7 @@
 	struct serial_icounter_struct icount;
 	unsigned long flags;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_ioctl"))
+	if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
 		return -ENODEV;
 
 	if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
@@ -1887,7 +1887,7 @@
 	struct serial_state *state;
 	unsigned long flags;
 
-	if (!info || serial_paranoia_check(info, tty->device, "rs_close"))
+	if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
 		return;
 
 	state = info->state;
@@ -1962,8 +1962,8 @@
 		rs_wait_until_sent(tty, info->timeout);
 	}
 	shutdown(info);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -1991,7 +1991,7 @@
 	unsigned long orig_jiffies, char_time;
 	int lsr;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_wait_until_sent"))
+	if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
 		return;
 
 	if (info->state->type == PORT_UNKNOWN)
@@ -2055,7 +2055,7 @@
 	struct async_struct * info = (struct async_struct *)tty->driver_data;
 	struct serial_state *state = info->state;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_hangup"))
+	if (serial_paranoia_check(info, tty->name, "rs_hangup"))
 		return;
 
 	state = info->state;
@@ -2105,7 +2105,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		if (info->flags & ASYNC_NORMAL_ACTIVE)
 			return -EBUSY;
 		if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
@@ -2264,7 +2264,7 @@
 	unsigned long		page;
 
 	MOD_INC_USE_COUNT;
-	line = MINOR(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if ((line < 0) || (line >= NR_PORTS)) {
 		MOD_DEC_USE_COUNT;
 		return -ENODEV;
@@ -2276,14 +2276,13 @@
 	}
 	tty->driver_data = info;
 	info->tty = tty;
-	if (serial_paranoia_check(info, tty->device, "rs_open")) {
+	if (serial_paranoia_check(info, tty->name, "rs_open")) {
 		MOD_DEC_USE_COUNT;		
 		return -ENODEV;
 	}
 
 #ifdef SERIAL_DEBUG_OPEN
-	printk("rs_open %s%d, count = %d\n", tty->driver.name, info->line,
-	       info->state->count);
+	printk("rs_open %s, count = %d\n", tty->name, info->state->count);
 #endif
 	info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
 
@@ -2336,7 +2335,7 @@
 
 	if ((info->state->count == 1) &&
 	    (info->flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->state->normal_termios;
 		else 
 			*tty->termios = info->state->callout_termios;
@@ -2353,7 +2352,7 @@
 	info->pgrp = current->pgrp;
 
 #ifdef SERIAL_DEBUG_OPEN
-	printk("rs_open ttys%d successful...", info->line);
+	printk("rs_open %s successful...", tty->name);
 #endif
 	return 0;
 }
@@ -2589,7 +2588,7 @@
 	serial_driver.magic = TTY_DRIVER_MAGIC;
 	serial_driver.driver_name = "serial";
 #if (LINUX_VERSION_CODE > 0x2032D && defined(CONFIG_DEVFS_FS))
-	serial_driver.name = "tts/%d";
+	serial_driver.name = "tts/";
 #else
 	serial_driver.name = "ttyS";
 #endif
@@ -2633,7 +2632,7 @@
 	 */
 	callout_driver = serial_driver;
 #if (LINUX_VERSION_CODE > 0x2032D && defined(CONFIG_DEVFS_FS))
-	callout_driver.name = "cua/%d";
+	callout_driver.name = "cua/";
 #else
 	callout_driver.name = "cua";
 #endif
@@ -2662,7 +2661,7 @@
 		state->icount.rx = state->icount.tx = 0;
 		state->icount.frame = state->icount.parity = 0;
 		state->icount.overrun = state->icount.brk = 0;
-		state->irq = irq_cannonicalize(state->irq);
+		state->irq = irq_canonicalize(state->irq);
 		if (state->hub6)
 			state->io_type = SERIAL_IO_HUB6;
 		if (state->port && check_region(state->port,8)) {
@@ -2682,10 +2681,8 @@
 		       (state->flags & ASYNC_FOURPORT) ? " FourPort" : "",
 		       state->port, state->irq,
 		       uart_config[state->type].name);
-		tty_register_device(&serial_driver,
-				   serial_driver.minor_start + state->line);
-		tty_register_device(&callout_driver,
-				   callout_driver.minor_start + state->line);
+		tty_register_device(&serial_driver, state->line);
+		tty_register_device(&callout_driver, state->line);
 	}
 	return 0;
 }
@@ -2772,10 +2769,8 @@
 	      state->iomem_base ? "iomem" : "port",
 	      state->iomem_base ? (unsigned long)state->iomem_base :
 	      state->port, state->irq, uart_config[state->type].name);
-	tty_register_device(&serial_driver,
-			   serial_driver.minor_start + state->line); 
-	tty_register_device(&callout_driver,
-			   callout_driver.minor_start + state->line);
+	tty_register_device(&serial_driver, state->line); 
+	tty_register_device(&callout_driver, state->line);
 	return state->line + SERIAL_DEV_OFFSET;
 }
 
@@ -2801,10 +2796,8 @@
 	/* These will be hidden, because they are devices that will no longer
 	 * be available to the system. (ie, PCMCIA modems, once ejected)
 	 */
-	tty_unregister_device(&serial_driver,
-			     serial_driver.minor_start + state->line);
-	tty_unregister_device(&callout_driver,
-			     callout_driver.minor_start + state->line);
+	tty_unregister_device(&serial_driver, state->line);
+	tty_unregister_device(&callout_driver, state->line);
 	restore_flags(flags);
 }
 
@@ -2922,9 +2915,10 @@
 	serial_out(info, UART_IER, ier);
 }
 
-static kdev_t serial_console_device(struct console *c)
+static struct tty_driver *serial_console_device(struct console *c, int *index)
 {
-	return MKDEV(TTY_MAJOR, 64 + c->index);
+	*index = c->index - SERIAL_DEV_OFFSET;
+	return &serial_driver;
 }
 
 /*
diff -Nru a/arch/mips/baget/vacserial.c b/arch/mips/baget/vacserial.c
--- a/arch/mips/baget/vacserial.c	Wed Apr 30 22:28:11 2003
+++ b/arch/mips/baget/vacserial.c	Wed Apr 30 22:28:11 2003
@@ -29,7 +29,7 @@
   
 #if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT)
 #define DBG_CNT(s) baget_printk("(%s):[%x] refc=%d, serc=%d, ttyc=%d-> %s\n", \
-  cdevname(tty->device),(info->flags),serial_refcount,info->count,tty->count,s)
+  tty->name,(info->flags),serial_refcount,info->count,tty->count,s)
 #else
 #define DBG_CNT(s)
 #endif
@@ -164,7 +164,7 @@
 static DECLARE_MUTEX(tmp_buf_sem);
 
 static inline int serial_paranoia_check(struct async_struct *info,
-					kdev_t device, const char *routine)
+					char *name, const char *routine)
 {
 #ifdef SERIAL_PARANOIA_CHECK
 	static const char *badmagic =
@@ -173,11 +173,11 @@
 		"Warning: null async_struct for (%s) in %s\n";
 
 	if (!info) {
-		printk(badinfo, cdevname(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (info->magic != SERIAL_MAGIC) {
-		printk(badmagic, cdevname(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -266,7 +266,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_stop"))
+	if (serial_paranoia_check(info, tty->name, "rs_stop"))
 		return;
 	
 	save_flags(flags); cli();
@@ -282,7 +282,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_start"))
+	if (serial_paranoia_check(info, tty->name, "rs_start"))
 		return;
 	
 	save_flags(flags); cli();
@@ -1023,7 +1023,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_put_char"))
+	if (serial_paranoia_check(info, tty->name, "rs_put_char"))
 		return;
 
 	if (!tty || !info->xmit_buf)
@@ -1046,7 +1046,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_flush_chars"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
 		return;
 
 	if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
@@ -1066,7 +1066,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 		
-	if (serial_paranoia_check(info, tty->device, "rs_write"))
+	if (serial_paranoia_check(info, tty->name, "rs_write"))
 		return 0;
 
 	if (!tty || !info->xmit_buf || !tmp_buf)
@@ -1134,7 +1134,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	int	ret;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_write_room"))
+	if (serial_paranoia_check(info, tty->name, "rs_write_room"))
 		return 0;
 	ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
 	if (ret < 0)
@@ -1146,7 +1146,7 @@
 {
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_chars_in_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
 		return 0;
 	return info->xmit_cnt;
 }
@@ -1156,7 +1156,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	unsigned long flags; 
 				
-	if (serial_paranoia_check(info, tty->device, "rs_flush_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
 		return;
 
 	save_flags(flags); cli();
@@ -1177,7 +1177,7 @@
 {
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 
-	if (serial_paranoia_check(info, tty->device, "rs_send_char"))
+	if (serial_paranoia_check(info, tty->name, "rs_send_char"))
 		return;
 
 	info->x_char = ch;
@@ -1207,7 +1207,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_throttle"))
+	if (serial_paranoia_check(info, tty->name, "rs_throttle"))
 		return;
 	
 	if (I_IXOFF(tty))
@@ -1224,7 +1224,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_unthrottle"))
+	if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
 		return;
 	
 	if (I_IXOFF(tty)) {
@@ -1456,7 +1456,7 @@
 	struct async_struct * info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_break"))
+	if (serial_paranoia_check(info, tty->name, "rs_break"))
 		return;
 
 	if (!info->port)
@@ -1482,7 +1482,7 @@
 	struct serial_icounter_struct *p_cuser;	/* user space */
 	unsigned long flags; 
 
-	if (serial_paranoia_check(info, tty->device, "rs_ioctl"))
+	if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
 		return -ENODEV;
 
 	if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
@@ -1640,7 +1640,7 @@
 	struct serial_state *state;
 	unsigned long flags;
 
-	if (!info || serial_paranoia_check(info, tty->device, "rs_close"))
+	if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
 		return;
 
 	state = info->state;
@@ -1717,8 +1717,8 @@
 		rs_wait_until_sent(tty, info->timeout);
 	}
 	shutdown(info);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -1747,7 +1747,7 @@
 	unsigned long orig_jiffies, char_time;
 	int lsr;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_wait_until_sent"))
+	if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
 		return;
 
 	if (info->state->type == PORT_UNKNOWN)
@@ -1802,7 +1802,7 @@
 	struct async_struct * info = (struct async_struct *)tty->driver_data;
 	struct serial_state *state = info->state;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_hangup"))
+	if (serial_paranoia_check(info, tty->name, "rs_hangup"))
 		return;
 
 	state = info->state;
@@ -1850,7 +1850,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		if (info->flags & ASYNC_NORMAL_ACTIVE)
 			return -EBUSY;
 		if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
@@ -1997,7 +1997,7 @@
 	unsigned long		page;
 
 	MOD_INC_USE_COUNT; 
-	line = MINOR(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if ((line < 0) || (line >= NR_PORTS)) {
 		MOD_DEC_USE_COUNT; 
 		return -ENODEV;
@@ -2009,14 +2009,13 @@
 	}
         tty->driver_data = info;
         info->tty = tty;
-	if (serial_paranoia_check(info, tty->device, "rs_open")) {
+	if (serial_paranoia_check(info, tty->name, "rs_open")) {
 	        /* MOD_DEC_USE_COUNT; "info->tty" will cause this */ 
 		return -ENODEV;
 	}
 
 #ifdef SERIAL_DEBUG_OPEN
-	baget_printk("rs_open %s%d, count = %d\n", 
-		     tty->driver.name, info->line,
+	baget_printk("rs_open %s, count = %d\n", tty->name,
 		     info->state->count);
 #endif
 	info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
@@ -2071,7 +2070,7 @@
 
 	if ((info->state->count == 1) &&
 	    (info->flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->state->normal_termios;
 		else 
 			*tty->termios = info->state->callout_termios;
@@ -2088,7 +2087,7 @@
 	info->pgrp = current->pgrp;
 
 #ifdef SERIAL_DEBUG_OPEN
-	baget_printk("rs_open ttys%d successful...", info->line);
+	baget_printk("rs_open %s successful...", tty->name);
 #endif
 	return 0;
 }
@@ -2622,9 +2621,10 @@
 	serial_outp(&scr_info, VAC_UART_INT_MASK, ier);
 }
 
-static kdev_t serial_console_device(struct console *c)
+static struct tty_driver *serial_console_device(struct console *c, int *index)
 {
-	return MKDEV(TTY_MAJOR, 64 + c->index);
+	*index = c->index;
+	return &serial_driver;
 }
 
 /*
diff -Nru a/arch/mips/gt64120/momenco_ocelot/setup.c b/arch/mips/gt64120/momenco_ocelot/setup.c
--- a/arch/mips/gt64120/momenco_ocelot/setup.c	Wed Apr 30 22:28:09 2003
+++ b/arch/mips/gt64120/momenco_ocelot/setup.c	Wed Apr 30 22:28:09 2003
@@ -60,7 +60,7 @@
 #include <asm/mc146818rtc.h>
 #include <linux/version.h>
 #include <linux/bootmem.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <asm/gt64120/gt64120.h>
 #include "ocelot_pld.h"
 
diff -Nru a/arch/mips/kernel/gdb-stub.c b/arch/mips/kernel/gdb-stub.c
--- a/arch/mips/kernel/gdb-stub.c	Wed Apr 30 22:28:19 2003
+++ b/arch/mips/kernel/gdb-stub.c	Wed Apr 30 22:28:19 2003
@@ -942,11 +942,6 @@
 	}
 }
 
-static kdev_t gdb_console_dev(struct console *con)
-{
-	return MKDEV(1, 3); /* /dev/null */
-}
-
 static void gdb_console_write(struct console *con, const char *s, unsigned n)
 {
 	gdb_puts(s);
@@ -955,7 +950,6 @@
 static struct console gdb_console = {
 	.name	= "gdb",
 	.write	= gdb_console_write,
-	.device	= gdb_console_dev,
 	.flags	= CON_PRINTBUFFER,
 	.index	= -1
 };
diff -Nru a/arch/mips/kernel/irixioctl.c b/arch/mips/kernel/irixioctl.c
--- a/arch/mips/kernel/irixioctl.c	Wed Apr 30 22:28:12 2003
+++ b/arch/mips/kernel/irixioctl.c	Wed Apr 30 22:28:12 2003
@@ -48,8 +48,8 @@
 
 static struct tty_struct *get_real_tty(struct tty_struct *tp)
 {
-	if (tp->driver.type == TTY_DRIVER_TYPE_PTY &&
-	   tp->driver.subtype == PTY_TYPE_MASTER)
+	if (tp->driver->type == TTY_DRIVER_TYPE_PTY &&
+	   tp->driver->subtype == PTY_TYPE_MASTER)
 		return tp->link;
 	else
 		return tp;
diff -Nru a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
--- a/arch/mips/kernel/setup.c	Wed Apr 30 22:28:05 2003
+++ b/arch/mips/kernel/setup.c	Wed Apr 30 22:28:05 2003
@@ -26,7 +26,7 @@
 #include <linux/a.out.h>
 #include <linux/tty.h>
 #include <linux/bootmem.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/ide.h>
 #include <linux/timex.h>
 #include <linux/root_dev.h>
diff -Nru a/arch/mips64/Kconfig b/arch/mips64/Kconfig
--- a/arch/mips64/Kconfig	Wed Apr 30 22:28:06 2003
+++ b/arch/mips64/Kconfig	Wed Apr 30 22:28:06 2003
@@ -113,7 +113,7 @@
 	  See also the <file:Documentation/smp.tex>,
 	  <file:Documentation/smp.txt>, <file:Documentation/i386/IO-APIC.txt>,
 	  <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you don't know what to do here, say N.
 
@@ -145,7 +145,7 @@
 	  VESA. If you have PCI, say Y, otherwise N.
 
 	  The PCI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, contains valuable
+	  <http://www.tldp.org/docs.html#howto>, contains valuable
 	  information about which PCI hardware does work under Linux and which
 	  doesn't.
 
@@ -350,7 +350,7 @@
 	  want to say Y here.
 
 	  Information about ELF is contained in the ELF HOWTO available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you find that after upgrading from Linux kernel 1.2 and saying Y
 	  here, you still can't run any ELF binaries (they just crash), then
@@ -392,7 +392,7 @@
 	  programs that need an interpreter to run like Java, Python or
 	  Emacs-Lisp. It's also useful if you often run DOS executables under
 	  the Linux DOS emulator DOSEMU (read the DOSEMU-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>). Once you have
+	  <http://www.tldp.org/docs.html#howto>). Once you have
 	  registered such a binary class with the kernel, you can start one of
 	  those programs simply by typing in its name at a shell prompt; Linux
 	  will automatically feed it to the correct interpreter.
@@ -520,7 +520,7 @@
 	---help---
 	  If you have a CD-ROM drive that is neither SCSI nor IDE/ATAPI, say Y
 	  here, otherwise N. Read the CD-ROM-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  Note that the answer to this question doesn't directly affect the
 	  kernel: saying N will just cause the configurator to skip all
@@ -594,7 +594,7 @@
 	  interrupt and DMA channel), because you will be asked for it.
 
 	  You want to read the Sound-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. General information about
+	  <http://www.tldp.org/docs.html#howto>. General information about
 	  the modular sound system is contained in the files
 	  <file:Documentation/sound/Introduction>.  The file
 	  <file:Documentation/sound/README.OSS> contains some slightly
diff -Nru a/arch/mips64/kernel/ioctl32.c b/arch/mips64/kernel/ioctl32.c
--- a/arch/mips64/kernel/ioctl32.c	Wed Apr 30 22:28:09 2003
+++ b/arch/mips64/kernel/ioctl32.c	Wed Apr 30 22:28:09 2003
@@ -822,70 +822,3 @@
 
 #define NR_IOCTL32_HANDLERS	(sizeof(ioctl32_handler_table) /	\
 				 sizeof(ioctl32_handler_table[0]))
-
-static struct ioctl32_list *ioctl32_hash_table[1024];
-
-static inline int ioctl32_hash(unsigned int cmd)
-{
-	return ((cmd >> 6) ^ (cmd >> 4) ^ cmd) & 0x3ff;
-}
-
-int sys32_ioctl(unsigned int fd, unsigned int cmd, unsigned int arg)
-{
-	int (*handler)(unsigned int, unsigned int, unsigned long, struct file * filp);
-	struct file *filp;
-	struct ioctl32_list *l;
-	int error;
-
-	l = ioctl32_hash_table[ioctl32_hash(cmd)];
-
-	error = -EBADF;
-
-	filp = fget(fd);
-	if (!filp)
-		return error;
-
-	if (!filp->f_op || !filp->f_op->ioctl) {
-		error = sys_ioctl (fd, cmd, arg);
-		goto out;
-	}
-
-	while (l && l->handler.cmd != cmd)
-		l = l->next;
-
-	if (l) {
-		handler = (void *)l->handler.function;
-		error = handler(fd, cmd, arg, filp);
-	} else {
-		error = -EINVAL;
-		printk("unknown ioctl: %08x\n", cmd);
-	}
-out:
-	fput(filp);
-	return error;
-}
-
-static void ioctl32_insert(struct ioctl32_list *entry)
-{
-	int hash = ioctl32_hash(entry->handler.cmd);
-	if (!ioctl32_hash_table[hash])
-		ioctl32_hash_table[hash] = entry;
-	else {
-		struct ioctl32_list *l;
-		l = ioctl32_hash_table[hash];
-		while (l->next)
-			l = l->next;
-		l->next = entry;
-		entry->next = 0;
-	}
-}
-
-static int __init init_ioctl32(void)
-{
-	int i;
-	for (i = 0; i < NR_IOCTL32_HANDLERS; i++)
-		ioctl32_insert(&ioctl32_handler_table[i]);
-	return 0;
-}
-
-__initcall(init_ioctl32);
diff -Nru a/arch/mips64/kernel/scall_o32.S b/arch/mips64/kernel/scall_o32.S
--- a/arch/mips64/kernel/scall_o32.S	Wed Apr 30 22:28:14 2003
+++ b/arch/mips64/kernel/scall_o32.S	Wed Apr 30 22:28:14 2003
@@ -287,7 +287,7 @@
 	sys	sys_acct	0
 	sys	sys_umount	2
 	sys	sys_ni_syscall	0
-	sys	sys32_ioctl	3
+	sys	compat_sys_ioctl	3
 	sys	sys32_fcntl	3			/* 4055 */
 	sys	sys_ni_syscall	2
 	sys	sys_setpgid	2
diff -Nru a/arch/mips64/mm/init.c b/arch/mips64/mm/init.c
--- a/arch/mips64/mm/init.c	Wed Apr 30 22:28:12 2003
+++ b/arch/mips64/mm/init.c	Wed Apr 30 22:28:12 2003
@@ -21,9 +21,7 @@
 #include <linux/bootmem.h>
 #include <linux/highmem.h>
 #include <linux/swap.h>
-#ifdef CONFIG_BLK_DEV_INITRD
-#include <linux/blk.h>
-#endif
+#include <linux/initrd.h>
 
 #include <asm/bootinfo.h>
 #include <asm/cachectl.h>
diff -Nru a/arch/mips64/sgi-ip27/ip27-pci.c b/arch/mips64/sgi-ip27/ip27-pci.c
--- a/arch/mips64/sgi-ip27/ip27-pci.c	Wed Apr 30 22:28:14 2003
+++ b/arch/mips64/sgi-ip27/ip27-pci.c	Wed Apr 30 22:28:14 2003
@@ -149,7 +149,6 @@
 	int	i;
 
 	ioport_resource.end = ~0UL;
-	iomem_resource.end = ~0UL;
 
 	for (i=0; i<num_bridges; i++) {
 		printk("PCI: Probing PCI hardware on host bus %2d.\n", i);
diff -Nru a/arch/parisc/Kconfig b/arch/parisc/Kconfig
--- a/arch/parisc/Kconfig	Wed Apr 30 22:28:11 2003
+++ b/arch/parisc/Kconfig	Wed Apr 30 22:28:11 2003
@@ -136,7 +136,7 @@
 	  See also the <file:Documentation/smp.tex>,
 	  <file:Documentation/smp.txt>, <file:Documentation/nmi_watchdog.txt>
 	  and the SMP-HOWTO available at
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you don't know what to do here, say N.
 
@@ -184,7 +184,7 @@
 	  want to say Y here.
 
 	  Information about ELF is contained in the ELF HOWTO available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you find that after upgrading from Linux kernel 1.2 and saying Y
 	  here, you still can't run any ELF binaries (they just crash), then
@@ -206,7 +206,7 @@
 	  programs that need an interpreter to run like Java, Python or
 	  Emacs-Lisp. It's also useful if you often run DOS executables under
 	  the Linux DOS emulator DOSEMU (read the DOSEMU-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>). Once you have
+	  <http://www.tldp.org/docs.html#howto>). Once you have
 	  registered such a binary class with the kernel, you can start one of
 	  those programs simply by typing in its name at a shell prompt; Linux
 	  will automatically feed it to the correct interpreter.
@@ -309,7 +309,7 @@
 	  interrupt and DMA channel), because you will be asked for it.
 
 	  You want to read the Sound-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. General information about
+	  <http://www.tldp.org/docs.html#howto>. General information about
 	  the modular sound system is contained in the files
 	  <file:Documentation/sound/Introduction>.  The file
 	  <file:Documentation/sound/README.OSS> contains some slightly
diff -Nru a/arch/parisc/kernel/ioctl32.c b/arch/parisc/kernel/ioctl32.c
--- a/arch/parisc/kernel/ioctl32.c	Wed Apr 30 22:28:03 2003
+++ b/arch/parisc/kernel/ioctl32.c	Wed Apr 30 22:28:03 2003
@@ -9,9 +9,9 @@
  */
 
 #include <linux/config.h>
-#include <linux/types.h>
-#include "sys32.h"
 #include <linux/compat.h>
+#include <linux/ioctl.h>
+#include <linux/ioctl32.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/smp.h>
@@ -52,12 +52,7 @@
 #include <linux/rtc.h>
 #include <linux/pci.h>
 #include <linux/serial.h>
-#if defined(CONFIG_BLK_DEV_LVM) || defined(CONFIG_BLK_DEV_LVM_MODULE)
-/* Ugh. This header really is not clean */
-/* #define min min
-#define max max */
-#include <linux/lvm.h>
-#endif /* LVM */
+#include <linux/watchdog.h>
 
 #include <scsi/scsi.h>
 /* Ugly hack. */
@@ -97,7 +92,7 @@
 #include <linux/nbd.h>
 #include <linux/random.h>
 
-#include <asm/module.h>	/* get #define module_map() */
+#include <asm/ioctls.h>
 
 /* Use this to get at 32-bit user passed pointers. 
    See sys_sparc32.c for description about these. */
@@ -111,8 +106,6 @@
 #define EXT2_IOC32_GETVERSION             _IOR('v', 1, int)
 #define EXT2_IOC32_SETVERSION             _IOW('v', 2, int)
 
-extern asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
-
 static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
 	mm_segment_t old_fs = get_fs();
@@ -143,17 +136,6 @@
 	return err;
 }
 
-static int siocprivate(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
-	int err = sys_ioctl(fd, cmd, arg);
-	if ((unsigned) err > -4095)
-		printk(KERN_WARNING 
-			"ioctl(%d, 0x%x, %p) -- SIOCDEVPRIVATE-based ioctls aren't really\n"
-			"supported, though some will work by accident.\n",
-		    fd, cmd, (void *)arg);
-	return err;
-}
-
 static int do_ext2_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
 	/* These are just misnamed, they actually get/put from/to user an int */
@@ -1446,7 +1428,7 @@
 	if (tty_paranoia_check(tty, inode->i_rdev, "tty_ioctl"))
 		return -EINVAL;
 	                                                
-	if (tty->driver.ioctl != vt_ioctl)
+	if (tty->driver->ioctl != vt_ioctl)
 		return -EINVAL;
 	
 	/*
@@ -2900,669 +2882,36 @@
 	return ret;
 }
 
+int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
+{
+	int err = sys_ioctl(fd, cmd, arg);
+	if ((unsigned) err > -4095)
+		printk(KERN_WARNING 
+			"ioctl(%d, 0x%x, %p) -- SIOCDEVPRIVATE-based ioctls aren't really\n"
+			"supported, though some will work by accident.\n",
+		    fd, cmd, (void *)arg);
+	return err;
+}
 
-struct ioctl_trans {
-	unsigned long handler;
-	unsigned int cmd;
-	unsigned int next;
-};
-#define HANDLE_IOCTL(cmd, handler) asm volatile(".dword %1\n.word %0, 0" : : "i" (cmd), "i" (handler));
-
+#define HANDLE_IOCTL(cmd, handler) { cmd, (ioctl_trans_handler_t)handler, 0 },
 #define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL(cmd, sys_ioctl) 
 
-
-#define IOCTL_TABLE_START void ioctl32_foo(void) { asm volatile(".data\nioctl_translations:");
-#define IOCTL_TABLE_END asm volatile("\nioctl_translations_end:\n\t.previous"); }
+#define IOCTL_TABLE_START  struct ioctl_trans ioctl_start[] = {
+#define IOCTL_TABLE_END    }; struct ioctl_trans ioctl_end[0];
 
 IOCTL_TABLE_START
-/* List here exlicitly which ioctl's are known to have
- * compatible types passed or none at all...
- */
-/* Big T */
-COMPATIBLE_IOCTL(TCGETA)
-COMPATIBLE_IOCTL(TCSETA)
-COMPATIBLE_IOCTL(TCSETAW)
-COMPATIBLE_IOCTL(TCSETAF)
-COMPATIBLE_IOCTL(TCSBRK)
-COMPATIBLE_IOCTL(TCXONC)
-COMPATIBLE_IOCTL(TCFLSH)
-COMPATIBLE_IOCTL(TCGETS)
-COMPATIBLE_IOCTL(TCSETS)
-COMPATIBLE_IOCTL(TCSETSW)
-COMPATIBLE_IOCTL(TCSETSF)
-COMPATIBLE_IOCTL(TIOCLINUX)
+#include <linux/compat_ioctl.h>
+
+/* Might be moved to compat_ioctl.h with some ifdefs... */
 COMPATIBLE_IOCTL(TIOCSTART)
 COMPATIBLE_IOCTL(TIOCSTOP)
-/* Little t */
-COMPATIBLE_IOCTL(TIOCGETD)
-COMPATIBLE_IOCTL(TIOCSETD)
-COMPATIBLE_IOCTL(TIOCEXCL)
-COMPATIBLE_IOCTL(TIOCNXCL)
-COMPATIBLE_IOCTL(TIOCCONS)
-COMPATIBLE_IOCTL(TIOCGSOFTCAR)
-COMPATIBLE_IOCTL(TIOCSSOFTCAR)
-COMPATIBLE_IOCTL(TIOCSWINSZ)
-COMPATIBLE_IOCTL(TIOCGWINSZ)
-COMPATIBLE_IOCTL(TIOCMGET)
-COMPATIBLE_IOCTL(TIOCMBIC)
-COMPATIBLE_IOCTL(TIOCMBIS)
-COMPATIBLE_IOCTL(TIOCMSET)
-COMPATIBLE_IOCTL(TIOCPKT)
-COMPATIBLE_IOCTL(TIOCNOTTY)
-COMPATIBLE_IOCTL(TIOCSTI)
-COMPATIBLE_IOCTL(TIOCOUTQ)
-COMPATIBLE_IOCTL(TIOCSPGRP)
-COMPATIBLE_IOCTL(TIOCGPGRP)
-COMPATIBLE_IOCTL(TIOCSCTTY)
-COMPATIBLE_IOCTL(TIOCGPTN)
-COMPATIBLE_IOCTL(TIOCSPTLCK)
-COMPATIBLE_IOCTL(TIOCSSERIAL)
-COMPATIBLE_IOCTL(TIOCSERGETLSR)
 COMPATIBLE_IOCTL(TIOCSLTC)
-/* Big F */
-#if 0
-COMPATIBLE_IOCTL(FBIOGTYPE)
-COMPATIBLE_IOCTL(FBIOSATTR)
-COMPATIBLE_IOCTL(FBIOGATTR)
-COMPATIBLE_IOCTL(FBIOSVIDEO)
-COMPATIBLE_IOCTL(FBIOGVIDEO)
-COMPATIBLE_IOCTL(FBIOGCURSOR32)  /* This is not implemented yet. Later it should be converted... */
-COMPATIBLE_IOCTL(FBIOSCURPOS)
-COMPATIBLE_IOCTL(FBIOGCURPOS)
-COMPATIBLE_IOCTL(FBIOGCURMAX)
-#endif
-COMPATIBLE_IOCTL(FBIOGET_VSCREENINFO)
-COMPATIBLE_IOCTL(FBIOPUT_VSCREENINFO)
 
-COMPATIBLE_IOCTL(FBIOPAN_DISPLAY)
-COMPATIBLE_IOCTL(FBIOGET_CON2FBMAP)
-COMPATIBLE_IOCTL(FBIOPUT_CON2FBMAP)
-/* Little f */
-COMPATIBLE_IOCTL(FIOCLEX)
-COMPATIBLE_IOCTL(FIONCLEX)
-COMPATIBLE_IOCTL(FIOASYNC)
-COMPATIBLE_IOCTL(FIONBIO)
-COMPATIBLE_IOCTL(FIONREAD)  /* This is also TIOCINQ */
-/* 0x00 */
-COMPATIBLE_IOCTL(FIBMAP)
-COMPATIBLE_IOCTL(FIGETBSZ)
-/* 0x03 -- HD/IDE ioctl's used by hdparm and friends.
- *         Some need translations, these do not.
- */
-COMPATIBLE_IOCTL(HDIO_GET_IDENTITY)
-COMPATIBLE_IOCTL(HDIO_SET_DMA)
-COMPATIBLE_IOCTL(HDIO_SET_UNMASKINTR)
-COMPATIBLE_IOCTL(HDIO_SET_NOWERR)
-COMPATIBLE_IOCTL(HDIO_SET_32BIT)
-COMPATIBLE_IOCTL(HDIO_SET_MULTCOUNT)
-COMPATIBLE_IOCTL(HDIO_DRIVE_CMD)
-COMPATIBLE_IOCTL(HDIO_SET_PIO_MODE)
-COMPATIBLE_IOCTL(HDIO_SET_NICE)
-/* 0x02 -- Floppy ioctls */
-COMPATIBLE_IOCTL(FDMSGON)
-COMPATIBLE_IOCTL(FDMSGOFF)
-COMPATIBLE_IOCTL(FDSETEMSGTRESH)
-COMPATIBLE_IOCTL(FDFLUSH)
-COMPATIBLE_IOCTL(FDWERRORCLR)
-COMPATIBLE_IOCTL(FDSETMAXERRS)
-COMPATIBLE_IOCTL(FDGETMAXERRS)
-COMPATIBLE_IOCTL(FDGETDRVTYP)
-COMPATIBLE_IOCTL(FDEJECT)
-COMPATIBLE_IOCTL(FDCLRPRM)
-COMPATIBLE_IOCTL(FDFMTBEG)
-COMPATIBLE_IOCTL(FDFMTEND)
-COMPATIBLE_IOCTL(FDRESET)
-COMPATIBLE_IOCTL(FDTWADDLE)
-COMPATIBLE_IOCTL(FDFMTTRK)
-COMPATIBLE_IOCTL(FDRAWCMD)
-/* 0x12 */
-COMPATIBLE_IOCTL(BLKROSET)
-COMPATIBLE_IOCTL(BLKROGET)
-COMPATIBLE_IOCTL(BLKRRPART)
-COMPATIBLE_IOCTL(BLKFLSBUF)
-COMPATIBLE_IOCTL(BLKSECTSET)
-
-/* RAID */
-COMPATIBLE_IOCTL(RAID_VERSION)
-COMPATIBLE_IOCTL(GET_ARRAY_INFO)
-COMPATIBLE_IOCTL(GET_DISK_INFO)
-COMPATIBLE_IOCTL(PRINT_RAID_DEBUG)
-COMPATIBLE_IOCTL(RAID_AUTORUN)
-COMPATIBLE_IOCTL(CLEAR_ARRAY)
-COMPATIBLE_IOCTL(ADD_NEW_DISK)
-COMPATIBLE_IOCTL(HOT_REMOVE_DISK)
-COMPATIBLE_IOCTL(SET_ARRAY_INFO)
-COMPATIBLE_IOCTL(SET_DISK_INFO)
-COMPATIBLE_IOCTL(WRITE_RAID_INFO)
-COMPATIBLE_IOCTL(UNPROTECT_ARRAY)
-COMPATIBLE_IOCTL(PROTECT_ARRAY)
-COMPATIBLE_IOCTL(HOT_ADD_DISK)
-COMPATIBLE_IOCTL(SET_DISK_FAULTY)
-COMPATIBLE_IOCTL(HOT_GENERATE_ERROR)
-COMPATIBLE_IOCTL(RUN_ARRAY)
-COMPATIBLE_IOCTL(START_ARRAY)
-COMPATIBLE_IOCTL(STOP_ARRAY)
-COMPATIBLE_IOCTL(STOP_ARRAY_RO)
-COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
-
-/* DM */
-COMPATIBLE_IOCTL(DM_VERSION)
-COMPATIBLE_IOCTL(DM_REMOVE_ALL)
-COMPATIBLE_IOCTL(DM_DEV_CREATE)
-COMPATIBLE_IOCTL(DM_DEV_REMOVE)
-COMPATIBLE_IOCTL(DM_DEV_RELOAD)
-COMPATIBLE_IOCTL(DM_DEV_SUSPEND)
-COMPATIBLE_IOCTL(DM_DEV_RENAME)
-COMPATIBLE_IOCTL(DM_DEV_DEPS)
-COMPATIBLE_IOCTL(DM_DEV_STATUS)
-COMPATIBLE_IOCTL(DM_TARGET_STATUS)
-COMPATIBLE_IOCTL(DM_TARGET_WAIT)
-
-/* Big K */
-COMPATIBLE_IOCTL(PIO_FONT)
-COMPATIBLE_IOCTL(GIO_FONT)
-COMPATIBLE_IOCTL(KDSIGACCEPT)
-COMPATIBLE_IOCTL(KDGETKEYCODE)
-COMPATIBLE_IOCTL(KDSETKEYCODE)
-COMPATIBLE_IOCTL(KIOCSOUND)
-COMPATIBLE_IOCTL(KDMKTONE)
-COMPATIBLE_IOCTL(KDGKBTYPE)
-COMPATIBLE_IOCTL(KDSETMODE)
-COMPATIBLE_IOCTL(KDGETMODE)
-COMPATIBLE_IOCTL(KDSKBMODE)
-COMPATIBLE_IOCTL(KDGKBMODE)
-COMPATIBLE_IOCTL(KDSKBMETA)
-COMPATIBLE_IOCTL(KDGKBMETA)
-COMPATIBLE_IOCTL(KDGKBENT)
-COMPATIBLE_IOCTL(KDSKBENT)
-COMPATIBLE_IOCTL(KDGKBSENT)
-COMPATIBLE_IOCTL(KDSKBSENT)
-COMPATIBLE_IOCTL(KDGKBDIACR)
-COMPATIBLE_IOCTL(KDSKBDIACR)
-COMPATIBLE_IOCTL(KDGKBLED)
-COMPATIBLE_IOCTL(KDSKBLED)
-COMPATIBLE_IOCTL(KDGETLED)
-COMPATIBLE_IOCTL(KDSETLED)
-COMPATIBLE_IOCTL(GIO_SCRNMAP)
-COMPATIBLE_IOCTL(PIO_SCRNMAP)
-COMPATIBLE_IOCTL(GIO_UNISCRNMAP)
-COMPATIBLE_IOCTL(PIO_UNISCRNMAP)
-COMPATIBLE_IOCTL(PIO_FONTRESET)
-COMPATIBLE_IOCTL(PIO_UNIMAPCLR)
-/* Little k */
-#if 0
-COMPATIBLE_IOCTL(KIOCTYPE)
-COMPATIBLE_IOCTL(KIOCLAYOUT)
-COMPATIBLE_IOCTL(KIOCGTRANS)
-COMPATIBLE_IOCTL(KIOCTRANS)
-COMPATIBLE_IOCTL(KIOCCMD)
-COMPATIBLE_IOCTL(KIOCSDIRECT)
-COMPATIBLE_IOCTL(KIOCSLED)
-COMPATIBLE_IOCTL(KIOCGLED)
-COMPATIBLE_IOCTL(KIOCSRATE)
-COMPATIBLE_IOCTL(KIOCGRATE)
-#endif
-/* Big S */
-COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
-COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST)
-COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI)
-COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK)
-COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK)
-COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY)
-COMPATIBLE_IOCTL(SCSI_IOCTL_TAGGED_ENABLE)
-COMPATIBLE_IOCTL(SCSI_IOCTL_TAGGED_DISABLE)
-COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER)
-COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND)
-/* Big T */
-COMPATIBLE_IOCTL(TUNSETNOCSUM)
-COMPATIBLE_IOCTL(TUNSETDEBUG)
-COMPATIBLE_IOCTL(TUNSETIFF)
-COMPATIBLE_IOCTL(TUNSETPERSIST)
-COMPATIBLE_IOCTL(TUNSETOWNER)
-/* Big V */
-COMPATIBLE_IOCTL(VT_SETMODE)
-COMPATIBLE_IOCTL(VT_GETMODE)
-COMPATIBLE_IOCTL(VT_GETSTATE)
-COMPATIBLE_IOCTL(VT_OPENQRY)
-COMPATIBLE_IOCTL(VT_ACTIVATE)
-COMPATIBLE_IOCTL(VT_WAITACTIVE)
-COMPATIBLE_IOCTL(VT_RELDISP)
-COMPATIBLE_IOCTL(VT_DISALLOCATE)
-COMPATIBLE_IOCTL(VT_RESIZE)
-COMPATIBLE_IOCTL(VT_RESIZEX)
-COMPATIBLE_IOCTL(VT_LOCKSWITCH)
-COMPATIBLE_IOCTL(VT_UNLOCKSWITCH)
-/* Little v, the video4linux ioctls */
-COMPATIBLE_IOCTL(VIDIOCGCAP)
-COMPATIBLE_IOCTL(VIDIOCGCHAN)
-COMPATIBLE_IOCTL(VIDIOCSCHAN)
-COMPATIBLE_IOCTL(VIDIOCGPICT)
-COMPATIBLE_IOCTL(VIDIOCSPICT)
-COMPATIBLE_IOCTL(VIDIOCCAPTURE)
-COMPATIBLE_IOCTL(VIDIOCKEY)
-COMPATIBLE_IOCTL(VIDIOCGAUDIO)
-COMPATIBLE_IOCTL(VIDIOCSAUDIO)
-COMPATIBLE_IOCTL(VIDIOCSYNC)
-COMPATIBLE_IOCTL(VIDIOCMCAPTURE)
-COMPATIBLE_IOCTL(VIDIOCGMBUF)
-COMPATIBLE_IOCTL(VIDIOCGUNIT)
-COMPATIBLE_IOCTL(VIDIOCGCAPTURE)
-COMPATIBLE_IOCTL(VIDIOCSCAPTURE)
-/* BTTV specific... */
-COMPATIBLE_IOCTL(_IOW('v',  BASE_VIDIOCPRIVATE+0, char [256]))
-COMPATIBLE_IOCTL(_IOR('v',  BASE_VIDIOCPRIVATE+1, char [256]))
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int))
-COMPATIBLE_IOCTL(_IOW('v' , BASE_VIDIOCPRIVATE+3, char [16])) /* struct bttv_pll_info */
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+4, int))
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+5, int))
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+6, int))
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+7, int))
-/* Little m */
-COMPATIBLE_IOCTL(MTIOCTOP)
-/* Socket level stuff */
-COMPATIBLE_IOCTL(FIOSETOWN)
-COMPATIBLE_IOCTL(SIOCSPGRP)
-COMPATIBLE_IOCTL(FIOGETOWN)
-COMPATIBLE_IOCTL(SIOCGPGRP)
-COMPATIBLE_IOCTL(SIOCATMARK)
-COMPATIBLE_IOCTL(SIOCSIFLINK)
-COMPATIBLE_IOCTL(SIOCSIFENCAP)
-COMPATIBLE_IOCTL(SIOCGIFENCAP)
-COMPATIBLE_IOCTL(SIOCSIFBR)
-COMPATIBLE_IOCTL(SIOCGIFBR)
-COMPATIBLE_IOCTL(SIOCSARP)
-COMPATIBLE_IOCTL(SIOCGARP)
-COMPATIBLE_IOCTL(SIOCDARP)
-COMPATIBLE_IOCTL(SIOCSRARP)
-COMPATIBLE_IOCTL(SIOCGRARP)
-COMPATIBLE_IOCTL(SIOCDRARP)
-COMPATIBLE_IOCTL(SIOCADDDLCI)
-COMPATIBLE_IOCTL(SIOCDELDLCI)
-COMPATIBLE_IOCTL(SIOCGMIIPHY)
-COMPATIBLE_IOCTL(SIOCGMIIREG)
-COMPATIBLE_IOCTL(SIOCSMIIREG)
-COMPATIBLE_IOCTL(SIOCGIFVLAN)
-COMPATIBLE_IOCTL(SIOCSIFVLAN)
-COMPATIBLE_IOCTL(SIOCDELDLCI)
-/* SG stuff */
-COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
-COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
-COMPATIBLE_IOCTL(SG_EMULATED_HOST)
-COMPATIBLE_IOCTL(SG_SET_TRANSFORM)
-COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
-COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
-COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
-COMPATIBLE_IOCTL(SG_GET_SCSI_ID)
-COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA)
-COMPATIBLE_IOCTL(SG_GET_LOW_DMA)
-COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID)
-COMPATIBLE_IOCTL(SG_GET_PACK_ID)
-COMPATIBLE_IOCTL(SG_GET_NUM_WAITING)
-COMPATIBLE_IOCTL(SG_SET_DEBUG)
-COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE)
-COMPATIBLE_IOCTL(SG_GET_COMMAND_Q)
-COMPATIBLE_IOCTL(SG_SET_COMMAND_Q)
-COMPATIBLE_IOCTL(SG_GET_VERSION_NUM)
-COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN)
-COMPATIBLE_IOCTL(SG_SCSI_RESET)
-COMPATIBLE_IOCTL(SG_IO)
-COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE)
-COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
-COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
-/* PPP stuff */
-COMPATIBLE_IOCTL(PPPIOCGFLAGS)
-COMPATIBLE_IOCTL(PPPIOCSFLAGS)
-COMPATIBLE_IOCTL(PPPIOCGASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCSASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCGUNIT)
-COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCGMRU)
-COMPATIBLE_IOCTL(PPPIOCSMRU)
-COMPATIBLE_IOCTL(PPPIOCSMAXCID)
-COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP)
-COMPATIBLE_IOCTL(LPGETSTATUS)
-COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCXFERUNIT)
-COMPATIBLE_IOCTL(PPPIOCGNPMODE)
-COMPATIBLE_IOCTL(PPPIOCSNPMODE)
-COMPATIBLE_IOCTL(PPPIOCGDEBUG)
-COMPATIBLE_IOCTL(PPPIOCSDEBUG)
-COMPATIBLE_IOCTL(PPPIOCNEWUNIT)
-COMPATIBLE_IOCTL(PPPIOCATTACH)
-COMPATIBLE_IOCTL(PPPIOCDETACH)
-COMPATIBLE_IOCTL(PPPIOCSMRRU)
-COMPATIBLE_IOCTL(PPPIOCCONNECT)
-COMPATIBLE_IOCTL(PPPIOCDISCONN)
-COMPATIBLE_IOCTL(PPPIOCATTCHAN)
-/* PPPOX */
-COMPATIBLE_IOCTL(PPPOEIOCSFWD)
-COMPATIBLE_IOCTL(PPPOEIOCDFWD)
-/* CDROM stuff */
-COMPATIBLE_IOCTL(CDROMPAUSE)
-COMPATIBLE_IOCTL(CDROMRESUME)
-COMPATIBLE_IOCTL(CDROMPLAYMSF)
-COMPATIBLE_IOCTL(CDROMPLAYTRKIND)
-COMPATIBLE_IOCTL(CDROMREADTOCHDR)
-COMPATIBLE_IOCTL(CDROMREADTOCENTRY)
-COMPATIBLE_IOCTL(CDROMSTOP)
-COMPATIBLE_IOCTL(CDROMSTART)
-COMPATIBLE_IOCTL(CDROMEJECT)
-COMPATIBLE_IOCTL(CDROMVOLCTRL)
-COMPATIBLE_IOCTL(CDROMSUBCHNL)
-COMPATIBLE_IOCTL(CDROMEJECT_SW)
-COMPATIBLE_IOCTL(CDROMMULTISESSION)
-COMPATIBLE_IOCTL(CDROM_GET_MCN)
-COMPATIBLE_IOCTL(CDROMRESET)
-COMPATIBLE_IOCTL(CDROMVOLREAD)
-COMPATIBLE_IOCTL(CDROMSEEK)
-COMPATIBLE_IOCTL(CDROMPLAYBLK)
-COMPATIBLE_IOCTL(CDROMCLOSETRAY)
-COMPATIBLE_IOCTL(CDROM_SET_OPTIONS)
-COMPATIBLE_IOCTL(CDROM_CLEAR_OPTIONS)
-COMPATIBLE_IOCTL(CDROM_SELECT_SPEED)
-COMPATIBLE_IOCTL(CDROM_SELECT_DISC)
-COMPATIBLE_IOCTL(CDROM_MEDIA_CHANGED)
-COMPATIBLE_IOCTL(CDROM_DRIVE_STATUS)
-COMPATIBLE_IOCTL(CDROM_DISC_STATUS)
-COMPATIBLE_IOCTL(CDROM_CHANGER_NSLOTS)
-COMPATIBLE_IOCTL(CDROM_LOCKDOOR)
-COMPATIBLE_IOCTL(CDROM_DEBUG)
-COMPATIBLE_IOCTL(CDROM_GET_CAPABILITY)
-/* Big L */
-COMPATIBLE_IOCTL(LOOP_SET_FD)
-COMPATIBLE_IOCTL(LOOP_CLR_FD)
-/* Big Q for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC)
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_INFO)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_CTRLRATE)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_GETOUTCOUNT)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_GETINCOUNT)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_PERCMODE)
-COMPATIBLE_IOCTL(SNDCTL_FM_LOAD_INSTR)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_TESTMIDI)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_RESETSAMPLES)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_NRSYNTHS)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_NRMIDIS)
-COMPATIBLE_IOCTL(SNDCTL_MIDI_INFO)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_THRESHOLD)
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_MEMAVL)
-COMPATIBLE_IOCTL(SNDCTL_FM_4OP_ENABLE)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_PANIC)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_OUTOFBAND)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_GETTIME)
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_ID)
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_CONTROL)
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_REMOVESAMPLE)
-/* Big T for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_TMR_TIMEBASE)
-COMPATIBLE_IOCTL(SNDCTL_TMR_START)
-COMPATIBLE_IOCTL(SNDCTL_TMR_STOP)
-COMPATIBLE_IOCTL(SNDCTL_TMR_CONTINUE)
-COMPATIBLE_IOCTL(SNDCTL_TMR_TEMPO)
-COMPATIBLE_IOCTL(SNDCTL_TMR_SOURCE)
-COMPATIBLE_IOCTL(SNDCTL_TMR_METRONOME)
-COMPATIBLE_IOCTL(SNDCTL_TMR_SELECT)
-/* Little m for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_MIDI_PRETIME)
-COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUMODE)
-COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUCMD)
-/* Big P for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_DSP_RESET)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SYNC)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SPEED)
-COMPATIBLE_IOCTL(SNDCTL_DSP_STEREO)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETBLKSIZE)
-COMPATIBLE_IOCTL(SNDCTL_DSP_CHANNELS)
-COMPATIBLE_IOCTL(SOUND_PCM_WRITE_FILTER)
-COMPATIBLE_IOCTL(SNDCTL_DSP_POST)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SUBDIVIDE)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETFRAGMENT)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETFMTS)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETFMT)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETOSPACE)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETISPACE)
-COMPATIBLE_IOCTL(SNDCTL_DSP_NONBLOCK)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETCAPS)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETTRIGGER)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETTRIGGER)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETIPTR)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETOPTR)
-/* SNDCTL_DSP_MAPINBUF,  XXX needs translation */
-/* SNDCTL_DSP_MAPOUTBUF,  XXX needs translation */
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETSYNCRO)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETDUPLEX)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETODELAY)
-COMPATIBLE_IOCTL(SNDCTL_DSP_PROFILE)
-COMPATIBLE_IOCTL(SOUND_PCM_READ_RATE)
-COMPATIBLE_IOCTL(SOUND_PCM_READ_CHANNELS)
-COMPATIBLE_IOCTL(SOUND_PCM_READ_BITS)
-COMPATIBLE_IOCTL(SOUND_PCM_READ_FILTER)
-/* Big C for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_COPR_RESET)
-COMPATIBLE_IOCTL(SNDCTL_COPR_LOAD)
-COMPATIBLE_IOCTL(SNDCTL_COPR_RDATA)
-COMPATIBLE_IOCTL(SNDCTL_COPR_RCODE)
-COMPATIBLE_IOCTL(SNDCTL_COPR_WDATA)
-COMPATIBLE_IOCTL(SNDCTL_COPR_WCODE)
-COMPATIBLE_IOCTL(SNDCTL_COPR_RUN)
-COMPATIBLE_IOCTL(SNDCTL_COPR_HALT)
-COMPATIBLE_IOCTL(SNDCTL_COPR_SENDMSG)
-COMPATIBLE_IOCTL(SNDCTL_COPR_RCVMSG)
-/* Big M for sound/OSS */
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_VOLUME)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_BASS)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_TREBLE)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_SYNTH)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_PCM)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_SPEAKER)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_MIC)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_CD)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_IMIX)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_ALTPCM)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECLEV)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_IGAIN)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_OGAIN)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE1)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE2)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE3)
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL1))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL2))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL3))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEIN))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEOUT))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_VIDEO))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_RADIO))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_MONITOR))
-COMPATIBLE_IOCTL(SOUND_MIXER_MUTE)
-/* SOUND_MIXER_READ_ENHANCE,  same value as READ_MUTE */
-/* SOUND_MIXER_READ_LOUD,  same value as READ_MUTE */
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECSRC)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_DEVMASK)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECMASK)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_STEREODEVS)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_CAPS)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_VOLUME)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_BASS)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_TREBLE)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SYNTH)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_PCM)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SPEAKER)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MIC)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_CD)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IMIX)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_ALTPCM)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECLEV)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IGAIN)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_OGAIN)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE1)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE2)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE3)
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL1))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL2))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL3))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEIN))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEOUT))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_VIDEO))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_RADIO))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_MONITOR))
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MUTE)
-/* SOUND_MIXER_WRITE_ENHANCE,  same value as WRITE_MUTE */
-/* SOUND_MIXER_WRITE_LOUD,  same value as WRITE_MUTE */
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECSRC)
-COMPATIBLE_IOCTL(SOUND_MIXER_INFO)
-COMPATIBLE_IOCTL(SOUND_OLD_MIXER_INFO)
-COMPATIBLE_IOCTL(SOUND_MIXER_ACCESS)
-COMPATIBLE_IOCTL(SOUND_MIXER_AGC)
-COMPATIBLE_IOCTL(SOUND_MIXER_3DSE)
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE1)
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE2)
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE3)
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE4)
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
-COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
-COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
-COMPATIBLE_IOCTL(OSS_GETVERSION)
-/* AUTOFS */
-COMPATIBLE_IOCTL(AUTOFS_IOC_READY)
-COMPATIBLE_IOCTL(AUTOFS_IOC_FAIL)
-COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC)
-COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER)
-COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE)
-/* DEVFS */
-COMPATIBLE_IOCTL(DEVFSDIOC_GET_PROTO_REV)
-COMPATIBLE_IOCTL(DEVFSDIOC_SET_EVENT_MASK)
-COMPATIBLE_IOCTL(DEVFSDIOC_RELEASE_EVENT_QUEUE)
-COMPATIBLE_IOCTL(DEVFSDIOC_SET_DEBUG_MASK)
-/* Raw devices */
-COMPATIBLE_IOCTL(RAW_SETBIND)
-COMPATIBLE_IOCTL(RAW_GETBIND)
-/* SMB ioctls which do not need any translations */
-COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
-/* Little a */
-COMPATIBLE_IOCTL(ATMSIGD_CTRL)
-COMPATIBLE_IOCTL(ATMARPD_CTRL)
-COMPATIBLE_IOCTL(ATMLEC_CTRL)
-COMPATIBLE_IOCTL(ATMLEC_MCAST)
-COMPATIBLE_IOCTL(ATMLEC_DATA)
-COMPATIBLE_IOCTL(ATM_SETSC)
-COMPATIBLE_IOCTL(SIOCSIFATMTCP)
-COMPATIBLE_IOCTL(SIOCMKCLIP)
-COMPATIBLE_IOCTL(ATMARP_MKIP)
-COMPATIBLE_IOCTL(ATMARP_SETENTRY)
-COMPATIBLE_IOCTL(ATMARP_ENCAP)
-COMPATIBLE_IOCTL(ATMTCP_CREATE)
-COMPATIBLE_IOCTL(ATMTCP_REMOVE)
-COMPATIBLE_IOCTL(ATMMPC_CTRL)
-COMPATIBLE_IOCTL(ATMMPC_DATA)
-#if defined(CONFIG_BLK_DEV_LVM) || defined(CONFIG_BLK_DEV_LVM_MODULE)
-/* 0xfe - lvm */
-COMPATIBLE_IOCTL(VG_SET_EXTENDABLE)
-COMPATIBLE_IOCTL(VG_STATUS_GET_COUNT)
-COMPATIBLE_IOCTL(VG_STATUS_GET_NAMELIST)
-COMPATIBLE_IOCTL(VG_REMOVE)
-COMPATIBLE_IOCTL(VG_RENAME)
-COMPATIBLE_IOCTL(VG_REDUCE)
-COMPATIBLE_IOCTL(PE_LOCK_UNLOCK)
-COMPATIBLE_IOCTL(PV_FLUSH)
-COMPATIBLE_IOCTL(LVM_LOCK_LVM)
-COMPATIBLE_IOCTL(LVM_GET_IOP_VERSION)
-#ifdef LVM_TOTAL_RESET
-COMPATIBLE_IOCTL(LVM_RESET)
-#endif
-COMPATIBLE_IOCTL(LV_SET_ACCESS)
-COMPATIBLE_IOCTL(LV_SET_STATUS)
-COMPATIBLE_IOCTL(LV_SET_ALLOCATION)
-COMPATIBLE_IOCTL(LE_REMAP)
-COMPATIBLE_IOCTL(LV_BMAP)
-COMPATIBLE_IOCTL(LV_SNAPSHOT_USE_RATE)
-#endif /* LVM */
-#if defined(CONFIG_DRM) || defined(CONFIG_DRM_MODULE)
-COMPATIBLE_IOCTL(DRM_IOCTL_GET_MAGIC)
-COMPATIBLE_IOCTL(DRM_IOCTL_IRQ_BUSID)
-COMPATIBLE_IOCTL(DRM_IOCTL_AUTH_MAGIC)
-COMPATIBLE_IOCTL(DRM_IOCTL_BLOCK)
-COMPATIBLE_IOCTL(DRM_IOCTL_UNBLOCK)
-COMPATIBLE_IOCTL(DRM_IOCTL_CONTROL)
-COMPATIBLE_IOCTL(DRM_IOCTL_ADD_BUFS)
-COMPATIBLE_IOCTL(DRM_IOCTL_MARK_BUFS)
-COMPATIBLE_IOCTL(DRM_IOCTL_ADD_CTX)
-COMPATIBLE_IOCTL(DRM_IOCTL_RM_CTX)
-COMPATIBLE_IOCTL(DRM_IOCTL_MOD_CTX)
-COMPATIBLE_IOCTL(DRM_IOCTL_GET_CTX)
-COMPATIBLE_IOCTL(DRM_IOCTL_SWITCH_CTX)
-COMPATIBLE_IOCTL(DRM_IOCTL_NEW_CTX)
-COMPATIBLE_IOCTL(DRM_IOCTL_ADD_DRAW)
-COMPATIBLE_IOCTL(DRM_IOCTL_RM_DRAW)
-COMPATIBLE_IOCTL(DRM_IOCTL_LOCK)
-COMPATIBLE_IOCTL(DRM_IOCTL_UNLOCK)
-COMPATIBLE_IOCTL(DRM_IOCTL_FINISH)
-#endif /* DRM */
-/* Big R */
-COMPATIBLE_IOCTL(RNDGETENTCNT)
-COMPATIBLE_IOCTL(RNDADDTOENTCNT)
-COMPATIBLE_IOCTL(RNDGETPOOL)
-COMPATIBLE_IOCTL(RNDADDENTROPY)
-COMPATIBLE_IOCTL(RNDZAPENTCNT)
-COMPATIBLE_IOCTL(RNDCLEARPOOL)
-/* Bluetooth ioctls */
-COMPATIBLE_IOCTL(HCIDEVUP)
-COMPATIBLE_IOCTL(HCIDEVDOWN)
-COMPATIBLE_IOCTL(HCIDEVRESET)
-COMPATIBLE_IOCTL(HCIDEVRESTAT)
-COMPATIBLE_IOCTL(HCIGETDEVLIST)
-COMPATIBLE_IOCTL(HCIGETDEVINFO)
-COMPATIBLE_IOCTL(HCIGETCONNLIST)
-COMPATIBLE_IOCTL(HCIGETCONNINFO)
-COMPATIBLE_IOCTL(HCISETRAW)
-COMPATIBLE_IOCTL(HCISETSCAN)
-COMPATIBLE_IOCTL(HCISETAUTH)
-COMPATIBLE_IOCTL(HCISETENCRYPT)
-COMPATIBLE_IOCTL(HCISETPTYPE)
-COMPATIBLE_IOCTL(HCISETLINKPOL)
-COMPATIBLE_IOCTL(HCISETLINKMODE)
-COMPATIBLE_IOCTL(HCISETACLMTU)
-COMPATIBLE_IOCTL(HCISETSCOMTU)
-COMPATIBLE_IOCTL(HCIINQUIRY)
-/* Misc. */
-COMPATIBLE_IOCTL(0x41545900)		/* ATYIO_CLKR */
-COMPATIBLE_IOCTL(0x41545901)		/* ATYIO_CLKW */
-COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
-COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
-COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM)
-COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE)
-/* USB */
-COMPATIBLE_IOCTL(USBDEVFS_RESETEP)
-COMPATIBLE_IOCTL(USBDEVFS_SETINTERFACE)
-COMPATIBLE_IOCTL(USBDEVFS_SETCONFIGURATION)
-COMPATIBLE_IOCTL(USBDEVFS_GETDRIVER)
-COMPATIBLE_IOCTL(USBDEVFS_DISCARDURB)
-COMPATIBLE_IOCTL(USBDEVFS_CLAIMINTERFACE)
-COMPATIBLE_IOCTL(USBDEVFS_RELEASEINTERFACE)
-COMPATIBLE_IOCTL(USBDEVFS_CONNECTINFO)
-COMPATIBLE_IOCTL(USBDEVFS_HUB_PORTINFO)
-COMPATIBLE_IOCTL(USBDEVFS_RESET)
-COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
-/* MTD */
-COMPATIBLE_IOCTL(MEMGETINFO)
-COMPATIBLE_IOCTL(MEMERASE)
-COMPATIBLE_IOCTL(MEMLOCK)
-COMPATIBLE_IOCTL(MEMUNLOCK)
-COMPATIBLE_IOCTL(MEMGETREGIONCOUNT)
-COMPATIBLE_IOCTL(MEMGETREGIONINFO)
-/* NBD */
-COMPATIBLE_IOCTL(NBD_SET_SOCK)
-COMPATIBLE_IOCTL(NBD_SET_BLKSIZE)
-COMPATIBLE_IOCTL(NBD_SET_SIZE)
-COMPATIBLE_IOCTL(NBD_DO_IT)
-COMPATIBLE_IOCTL(NBD_CLEAR_SOCK)
-COMPATIBLE_IOCTL(NBD_CLEAR_QUE)
-COMPATIBLE_IOCTL(NBD_PRINT_DEBUG)
-COMPATIBLE_IOCTL(NBD_SET_SIZE_BLOCKS)
-COMPATIBLE_IOCTL(NBD_DISCONNECT)
+/* PA-specific ioctls */
+COMPATIBLE_IOCTL(PA_PERF_ON)
+COMPATIBLE_IOCTL(PA_PERF_OFF)
+COMPATIBLE_IOCTL(PA_PERF_VERSION)
+
 /* And these ioctls need translation */
 HANDLE_IOCTL(TIOCGSERIAL, do_tiocgserial)
 HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32)
@@ -3735,150 +3084,5 @@
 HANDLE_IOCTL(DRM32_IOCTL_DMA, drm32_dma);
 HANDLE_IOCTL(DRM32_IOCTL_RES_CTX, drm32_res_ctx);
 #endif /* DRM */
-COMPATIBLE_IOCTL(PA_PERF_ON)
-COMPATIBLE_IOCTL(PA_PERF_OFF)
-COMPATIBLE_IOCTL(PA_PERF_VERSION)
 IOCTL_TABLE_END
 
-unsigned int ioctl32_hash_table[1024];
-
-extern inline unsigned long ioctl32_hash(unsigned long cmd)
-{
-	return ((cmd >> 6) ^ (cmd >> 4) ^ cmd) & 0x3ff;
-}
-
-static void ioctl32_insert_translation(struct ioctl_trans *trans)
-{
-	unsigned long hash;
-	struct ioctl_trans *t;
-
-	hash = ioctl32_hash (trans->cmd);
-	if (!ioctl32_hash_table[hash])
-		ioctl32_hash_table[hash] = (u32)(long)trans;
-	else {
-		t = (struct ioctl_trans *)(long)ioctl32_hash_table[hash];
-		while (t->next)
-			t = (struct ioctl_trans *)(long)t->next;
-		trans->next = 0;
-		t->next = (u32)(long)trans;
-	}
-}
-
-static int __init init_sys32_ioctl(void)
-{
-	int i;
-	extern struct ioctl_trans ioctl_translations[], ioctl_translations_end[];
-
-	for (i = 0; &ioctl_translations[i] < &ioctl_translations_end[0]; i++)
-		ioctl32_insert_translation(&ioctl_translations[i]);
-	return 0;
-}
-
-__initcall(init_sys32_ioctl);
-
-static struct ioctl_trans *additional_ioctls;
-
-/* Always call these with kernel lock held! */
-
-int register_ioctl32_conversion(unsigned int cmd, int (*handler)(unsigned int, unsigned int, unsigned long, struct file *))
-{
-	int i;
-
-panic("register_ioctl32_conversion() is B0RKEN! Called by %p\n", __builtin_return_address(0));
-
-	if (!additional_ioctls) {
-		additional_ioctls = module_map(PAGE_SIZE);
-		if (!additional_ioctls)
-			return -ENOMEM;
-		memset(additional_ioctls, 0, PAGE_SIZE);
-	}
-	for (i = 0; i < PAGE_SIZE/sizeof(struct ioctl_trans); i++)
-		if (!additional_ioctls[i].cmd)
-			break;
-	if (i == PAGE_SIZE/sizeof(struct ioctl_trans))
-		return -ENOMEM;
-	additional_ioctls[i].cmd = cmd;
-	if (!handler)
-		additional_ioctls[i].handler = (u32)(long)sys_ioctl;
-	else
-		additional_ioctls[i].handler = (u32)(long)handler;
-	ioctl32_insert_translation(&additional_ioctls[i]);
-	return 0;
-}
-
-int unregister_ioctl32_conversion(unsigned int cmd)
-{
-	unsigned long hash = ioctl32_hash(cmd);
-	struct ioctl_trans *t, *t1;
-
-	t = (struct ioctl_trans *)(long)ioctl32_hash_table[hash];
-	if (!t) return -EINVAL;
-	if (t->cmd == cmd && t >= additional_ioctls &&
-	    (unsigned long)t < ((unsigned long)additional_ioctls) + PAGE_SIZE) {
-		ioctl32_hash_table[hash] = t->next;
-		t->cmd = 0;
-		return 0;
-	} else while (t->next) {
-		t1 = (struct ioctl_trans *)(long)t->next;
-		if (t1->cmd == cmd && t1 >= additional_ioctls &&
-		    (unsigned long)t1 < ((unsigned long)additional_ioctls) + PAGE_SIZE) {
-			t1->cmd = 0;
-			t->next = t1->next;
-			return 0;
-		}
-		t = t1;
-	}
-	return -EINVAL;
-}
-
-asmlinkage int sys32_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
-	struct file * filp;
-	int (*handler)(unsigned int, unsigned int, unsigned long, struct file * filp);
-	unsigned long pafnptr[4];
-	extern char __gp;
-	struct ioctl_trans *t;
-	int error = -EBADF;
-
-	filp = fget(fd);
-	if(!filp)
-		goto out2;
-
-	if (!filp->f_op || !filp->f_op->ioctl) {
-		error = sys_ioctl (fd, cmd, arg);
-		goto out;
-	}
-
-	/* intercept private networking ioctl() calls here since it is
-	 * an onerous task to figure out which ones of the HANDLE_IOCTL
-	 * list map to these values.
-	 */
-	if (cmd >= SIOCDEVPRIVATE && cmd <= SIOCDEVPRIVATE + 0xf) {
-		error = siocprivate(fd, cmd, arg);
-		goto out;
-	}
-
-	t = (struct ioctl_trans *)(long)ioctl32_hash_table [ioctl32_hash (cmd)];
-
-	while (t && t->cmd != cmd)
-		t = (struct ioctl_trans *)(long)t->next;
-	if (t) {
-		handler = (void *) pafnptr;
-		pafnptr[0] = pafnptr[1] = 0UL;
-		pafnptr[2] = (unsigned long) t->handler;
-		pafnptr[3] = A(&__gp);
-		error = handler(fd, cmd, arg, filp);
-	} else {
-		static int count = 0;
-		if (++count <= 20)
-			printk(KERN_WARNING
-				"sys32_ioctl: Unknown cmd fd(%d) "
-				"cmd(%08x) arg(%08x)\n",
-				(int)fd, (unsigned int)cmd, (unsigned int)arg);
-		error = -EINVAL;
-	}
-out:
-	fput(filp);
-out2:
-	return error;
-}
diff -Nru a/arch/parisc/kernel/irq.c b/arch/parisc/kernel/irq.c
--- a/arch/parisc/kernel/irq.c	Wed Apr 30 22:28:08 2003
+++ b/arch/parisc/kernel/irq.c	Wed Apr 30 22:28:08 2003
@@ -161,7 +161,7 @@
 
 	DBG_IRQ(irq, ("mask_irq(%d) %d+%d eiem 0x%lx\n", irq,
 				IRQ_REGION(irq), IRQ_OFFSET(irq), cpu_eiem));
-	irq = irq_cannonicalize(irq);
+	irq = irq_canonicalize(irq);
 	region = irq_region[IRQ_REGION(irq)];
 	if (region->ops.mask_irq)
 		region->ops.mask_irq(region->data.dev, IRQ_OFFSET(irq));
@@ -173,7 +173,7 @@
 
 	DBG_IRQ(irq, ("unmask_irq(%d) %d+%d eiem 0x%lx\n", irq,
 				IRQ_REGION(irq), IRQ_OFFSET(irq), cpu_eiem));
-	irq = irq_cannonicalize(irq);
+	irq = irq_canonicalize(irq);
 	region = irq_region[IRQ_REGION(irq)];
 	if (region->ops.unmask_irq)
 		region->ops.unmask_irq(region->data.dev, IRQ_OFFSET(irq));
@@ -185,7 +185,7 @@
 
 	DBG_IRQ(irq, ("disable_irq(%d) %d+%d eiem 0x%lx\n", irq,
 				IRQ_REGION(irq), IRQ_OFFSET(irq), cpu_eiem));
-	irq = irq_cannonicalize(irq);
+	irq = irq_canonicalize(irq);
 	region = irq_region[IRQ_REGION(irq)];
 	if (region->ops.disable_irq)
 		region->ops.disable_irq(region->data.dev, IRQ_OFFSET(irq));
@@ -199,7 +199,7 @@
 
 	DBG_IRQ(irq, ("enable_irq(%d) %d+%d eiem 0x%lx\n", irq,
 				IRQ_REGION(irq), IRQ_OFFSET(irq), cpu_eiem));
-	irq = irq_cannonicalize(irq);
+	irq = irq_canonicalize(irq);
 	region = irq_region[IRQ_REGION(irq)];
 
 	if (region->ops.enable_irq)
@@ -594,7 +594,7 @@
 	printk(KERN_INFO "request_irq(%d, %p, 0x%lx, %s, %p)\n",irq, handler, irqflags, devname, dev_id);
 #endif
 
-	irq = irq_cannonicalize(irq);
+	irq = irq_canonicalize(irq);
 	/* request_irq()/free_irq() may not be called from interrupt context. */
 	if (in_interrupt())
 		BUG();
@@ -654,7 +654,7 @@
 	struct irqaction *action, **p;
 
 	/* See comments in request_irq() about interrupt context */
-	irq = irq_cannonicalize(irq);
+	irq = irq_canonicalize(irq);
 	
 	if (in_interrupt()) BUG();
 
diff -Nru a/arch/parisc/kernel/setup.c b/arch/parisc/kernel/setup.c
--- a/arch/parisc/kernel/setup.c	Wed Apr 30 22:28:18 2003
+++ b/arch/parisc/kernel/setup.c	Wed Apr 30 22:28:18 2003
@@ -29,7 +29,7 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/blk.h>          /* for initrd_start and initrd_end */
+#include <linux/initrd.h>
 #include <linux/init.h>
 #include <linux/console.h>
 #include <linux/seq_file.h>
diff -Nru a/arch/parisc/kernel/sys_parisc32.c b/arch/parisc/kernel/sys_parisc32.c
--- a/arch/parisc/kernel/sys_parisc32.c	Wed Apr 30 22:28:07 2003
+++ b/arch/parisc/kernel/sys_parisc32.c	Wed Apr 30 22:28:07 2003
@@ -1131,7 +1131,7 @@
 struct nfsctl_export32 {
 	char		ex_client[NFSCLNT_IDMAX+1];
 	char		ex_path[NFS_MAXPATHLEN+1];
-	__kernel_dev_t	ex_dev;
+	__kernel_old_dev_t ex_dev;
 	compat_ino_t	ex_ino;
 	int		ex_flags;
 	__kernel_uid_t	ex_anon_uid;
diff -Nru a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
--- a/arch/parisc/kernel/syscall.S	Wed Apr 30 22:28:19 2003
+++ b/arch/parisc/kernel/syscall.S	Wed Apr 30 22:28:19 2003
@@ -407,8 +407,7 @@
 	ENTRY_SAME(umount)
 	/* struct sockaddr... */
 	ENTRY_SAME(getpeername)
-	/* This one's a huge ugly mess */
-	ENTRY_DIFF(ioctl)
+	ENTRY_COMP(ioctl)
 	ENTRY_COMP(fcntl)		/* 55 */
 	ENTRY_SAME(socketpair)
 	ENTRY_SAME(setpgid)
diff -Nru a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
--- a/arch/parisc/mm/init.c	Wed Apr 30 22:28:09 2003
+++ b/arch/parisc/mm/init.c	Wed Apr 30 22:28:09 2003
@@ -15,7 +15,7 @@
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/pci.h>		/* for hppa_dma_ops and pcxl_dma_ops */
-#include <linux/blk.h>          /* for initrd_start and initrd_end */
+#include <linux/initrd.h>
 #include <linux/swap.h>
 #include <linux/unistd.h>
 
@@ -194,11 +194,6 @@
 	}
 
 #endif /* __LP64__ */
-
-#if 1
-	/* KLUGE! this really belongs in kernel/resource.c! */
-	iomem_resource.end = ~0UL;
-#endif
 
 	sysram_resource_count = npmem_ranges;
 	for (i = 0; i < sysram_resource_count; i++) {
diff -Nru a/arch/ppc/4xx_io/serial_sicc.c b/arch/ppc/4xx_io/serial_sicc.c
--- a/arch/ppc/4xx_io/serial_sicc.c	Wed Apr 30 22:28:03 2003
+++ b/arch/ppc/4xx_io/serial_sicc.c	Wed Apr 30 22:28:03 2003
@@ -431,11 +431,7 @@
 }
 
 static void
-#ifdef SUPPORT_SYSRQ
 siccuart_rx_chars(struct SICC_info *info, struct pt_regs *regs)
-#else
-siccuart_rx_chars(struct SICC_info *info)
-#endif
 {
     struct tty_struct *tty = info->tty;
     unsigned int status, ch, rsr, flg, ignored = 0;
@@ -574,25 +570,19 @@
 }
 
 
-static void siccuart_int_rx(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t siccuart_int_rx(int irq, void *dev_id, struct pt_regs *regs)
 {
     struct SICC_info *info = dev_id;
-
-#ifdef SUPPORT_SYSRQ
-            siccuart_rx_chars(info, regs);
-#else
-            siccuart_rx_chars(info);
-#endif
-
-      //powerpcClearUicsrBits(0x00000400);
+    siccuart_rx_chars(info, regs);
+    return IRQ_HANDLED;
 }
 
 
-static void siccuart_int_tx(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t siccuart_int_tx(int irq, void *dev_id, struct pt_regs *regs)
 {
     struct SICC_info *info = dev_id;
     siccuart_tx_chars(info);
-
+    return IRQ_HANDLED;
 }
 
 static void siccuart_tasklet_action(unsigned long data)
@@ -1052,8 +1042,7 @@
     unsigned long flags;
 
 #if DEBUG
-    printk("siccuart_flush_buffer(%d) called\n",
-           MINOR(tty->device) - tty->driver.minor_start);
+    printk("siccuart_flush_buffer(%d) called\n", tty->index);
 #endif
     save_flags(flags); cli();
     info->xmit.head = info->xmit.tail = 0;
@@ -1482,7 +1471,7 @@
         state->count = 1;
     }
     if (--state->count < 0) {
-        printk("rs_close: bad serial port count for %s%d: %d\n", tty->driver.name, info->state->line, state->count);
+        printk("rs_close: bad serial port count for %s: %d\n", tty->name, state->count);
         state->count = 0;
     }
     if (state->count) {
@@ -1521,8 +1510,8 @@
         siccuart_wait_until_sent(tty, info->timeout);
     }
     siccuart_shutdown(info);
-    if (tty->driver.flush_buffer)
-        tty->driver.flush_buffer(tty);
+    if (tty->driver->flush_buffer)
+        tty->driver->flush_buffer(tty);
     if (tty->ldisc.flush_buffer)
         tty->ldisc.flush_buffer(tty);
     tty->closing = 0;
@@ -1580,7 +1569,7 @@
     expire = jiffies + timeout;
 #if DEBUG
     printk("siccuart_wait_until_sent(%d), jiff=%lu, expire=%lu  char_time=%lu...\n",
-           MINOR(tty->device) - tty->driver.minor_start, jiffies,
+           tty->index, jiffies,
            expire, char_time);
 #endif
     while ((readb(info->port->uart_base + BL_SICC_LSR) & _LSR_TX_ALL) != _LSR_TX_ALL) {
@@ -1634,7 +1623,7 @@
      * If this is a callout device, then just make sure the normal
      * device isn't being used.
      */
-    if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+    if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
         if (info->flags & ASYNC_NORMAL_ACTIVE)
             return -EBUSY;
         if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
@@ -1754,7 +1743,7 @@
 static int siccuart_open(struct tty_struct *tty, struct file *filp)
 {
     struct SICC_info *info;
-    int retval, line = MINOR(tty->device) - tty->driver.minor_start;
+    int retval, line = tty->index;
 
 
     // is this a line that we've got?
@@ -1814,7 +1803,7 @@
 
     if ((info->state->count == 1) &&
         (info->flags & ASYNC_SPLIT_TERMIOS)) {
-        if (tty->driver.subtype == SERIAL_TYPE_NORMAL) {
+        if (tty->driver->subtype == SERIAL_TYPE_NORMAL) {
             *tty->termios = info->state->normal_termios;
         }
         else  {
@@ -1991,11 +1980,11 @@
     return c;
 }
 
-static kdev_t siccuart_console_device(struct console *c)
+static struct tty_driver *siccuart_console_device(struct console *c, int *index)
 {
-    return MKDEV(SERIAL_SICC_MAJOR, SERIAL_SICC_MINOR + c->index);
+	*index = c->index;
+	return &siccnormal_driver;
 }
-
 
 static int __init siccuart_console_setup(struct console *co, char *options)
 {
diff -Nru a/arch/ppc/8260_io/enet.c b/arch/ppc/8260_io/enet.c
--- a/arch/ppc/8260_io/enet.c	Wed Apr 30 22:28:03 2003
+++ b/arch/ppc/8260_io/enet.c	Wed Apr 30 22:28:03 2003
@@ -122,7 +122,7 @@
 static int scc_enet_open(struct net_device *dev);
 static int scc_enet_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static int scc_enet_rx(struct net_device *dev);
-static void scc_enet_interrupt(int irq, void * dev_id, struct pt_regs * regs);
+static irqreturn_t scc_enet_interrupt(int irq, void *dev_id, struct pt_regs *);
 static int scc_enet_close(struct net_device *dev);
 static struct net_device_stats *scc_enet_get_stats(struct net_device *dev);
 static void set_multicast_list(struct net_device *dev);
@@ -272,7 +272,7 @@
 /* The interrupt handler.
  * This is called from the CPM handler, not the MPC core interrupt.
  */
-static void
+static irqreturn_t
 scc_enet_interrupt(int irq, void * dev_id, struct pt_regs * regs)
 {
 	struct	net_device *dev = dev_id;
@@ -403,7 +403,7 @@
 		printk("SCC ENET: BSY can't happen.\n");
 	}
 
-	return;
+	return IRQ_HANDLED;
 }
 
 /* During a receive, the cur_rx points to the current incoming buffer.
diff -Nru a/arch/ppc/8260_io/fcc_enet.c b/arch/ppc/8260_io/fcc_enet.c
--- a/arch/ppc/8260_io/fcc_enet.c	Wed Apr 30 22:28:09 2003
+++ b/arch/ppc/8260_io/fcc_enet.c	Wed Apr 30 22:28:09 2003
@@ -126,7 +126,7 @@
 static int fcc_enet_open(struct net_device *dev);
 static int fcc_enet_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static int fcc_enet_rx(struct net_device *dev);
-static	void fcc_enet_interrupt(int irq, void * dev_id, struct pt_regs * regs);
+static irqreturn_t fcc_enet_interrupt(int irq, void *dev_id, struct pt_regs *);
 static int fcc_enet_close(struct net_device *dev);
 static struct net_device_stats *fcc_enet_get_stats(struct net_device *dev);
 static void set_multicast_list(struct net_device *dev);
@@ -452,7 +452,7 @@
 }
 
 /* The interrupt handler. */
-static void
+static irqreturn_t
 fcc_enet_interrupt(int irq, void * dev_id, struct pt_regs * regs)
 {
 	struct	net_device *dev = dev_id;
@@ -583,7 +583,7 @@
 	if (int_events & FCC_ENET_BSY) {
 		cep->stats.rx_dropped++;
 	}
-	return;
+	return IRQ_HANDLED;
 }
 
 /* During a receive, the cur_rx points to the current incoming buffer.
@@ -1203,7 +1203,7 @@
 }
 
 /* This interrupt occurs when the PHY detects a link change. */
-static void
+static irqreturn_t
 mii_link_interrupt(int irq, void * dev_id, struct pt_regs * regs)
 {
 	struct	net_device *dev = dev_id;
@@ -1211,6 +1211,7 @@
 
 	mii_do_cmd(dev, fep->phy->ack_int);
 	mii_do_cmd(dev, phy_cmd_relink);  /* restart and display status */
+	return IRQ_HANDLED;
 }
 
 #endif	/* CONFIG_USE_MDIO */
diff -Nru a/arch/ppc/8260_io/uart.c b/arch/ppc/8260_io/uart.c
--- a/arch/ppc/8260_io/uart.c	Wed Apr 30 22:28:04 2003
+++ b/arch/ppc/8260_io/uart.c	Wed Apr 30 22:28:04 2003
@@ -219,7 +219,7 @@
 static void rs_8xx_wait_until_sent(struct tty_struct *tty, int timeout);
 
 static inline int serial_paranoia_check(ser_info_t *info,
-					kdev_t device, const char *routine)
+					char *name, const char *routine)
 {
 #ifdef SERIAL_PARANOIA_CHECK
 	static const char *badmagic =
@@ -228,11 +228,11 @@
 		"Warning: null async_struct for (%s) in %s\n";
 
 	if (!info) {
-		printk(badinfo, cdevname(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (info->magic != SERIAL_MAGIC) {
-		printk(badmagic, cdevname(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -265,7 +265,7 @@
 	volatile scc_t	*sccp;
 	volatile smc_t	*smcp;
 
-	if (serial_paranoia_check(info, tty->device, "rs_stop"))
+	if (serial_paranoia_check(info, tty->name, "rs_stop"))
 		return;
 	
 	save_flags(flags); cli();
@@ -288,7 +288,7 @@
 	volatile scc_t	*sccp;
 	volatile smc_t	*smcp;
 
-	if (serial_paranoia_check(info, tty->device, "rs_stop"))
+	if (serial_paranoia_check(info, tty->name, "rs_stop"))
 		return;
 	
 	save_flags(flags); cli();
@@ -570,7 +570,7 @@
 /*
  * This is the serial driver's interrupt routine for a single port
  */
-static void rs_8xx_interrupt(int irq, void * dev_id, struct pt_regs * regs)
+static irqreturn_t rs_8xx_interrupt(int irq, void * dev_id, struct pt_regs * regs)
 {
 	u_char	events;
 	int	idx;
@@ -610,6 +610,7 @@
 #ifdef SERIAL_DEBUG_INTR
 	printk("end.\n");
 #endif
+	return IRQ_HANDLED;
 }
 
 
@@ -964,7 +965,7 @@
 	ser_info_t *info = (ser_info_t *)tty->driver_data;
 	volatile cbd_t	*bdp;
 
-	if (serial_paranoia_check(info, tty->device, "rs_put_char"))
+	if (serial_paranoia_check(info, tty->name, "rs_put_char"))
 		return;
 
 	if (!tty)
@@ -995,7 +996,7 @@
 	ser_info_t *info = (ser_info_t *)tty->driver_data;
 	volatile cbd_t *bdp;
 
-	if (serial_paranoia_check(info, tty->device, "rs_write"))
+	if (serial_paranoia_check(info, tty->name, "rs_write"))
 		return 0;
 
 	if (!tty) 
@@ -1047,7 +1048,7 @@
 	ser_info_t *info = (ser_info_t *)tty->driver_data;
 	int	ret;
 
-	if (serial_paranoia_check(info, tty->device, "rs_write_room"))
+	if (serial_paranoia_check(info, tty->name, "rs_write_room"))
 		return 0;
 
 	if ((info->tx_cur->cbd_sc & BD_SC_READY) == 0) {
@@ -1067,7 +1068,7 @@
 {
 	ser_info_t *info = (ser_info_t *)tty->driver_data;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_chars_in_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
 		return 0;
 	return 0;
 }
@@ -1076,7 +1077,7 @@
 {
 	ser_info_t *info = (ser_info_t *)tty->driver_data;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_flush_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
 		return;
 
 	/* There is nothing to "flush", whatever we gave the CPM
@@ -1099,7 +1100,7 @@
 
 	ser_info_t *info = (ser_info_t *)tty->driver_data;
 
-	if (serial_paranoia_check(info, tty->device, "rs_send_char"))
+	if (serial_paranoia_check(info, tty->name, "rs_send_char"))
 		return;
 
 	bdp = info->tx_cur;
@@ -1137,7 +1138,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_throttle"))
+	if (serial_paranoia_check(info, tty->name, "rs_throttle"))
 		return;
 	
 	if (I_IXOFF(tty))
@@ -1163,7 +1164,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_unthrottle"))
+	if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
 		return;
 	
 	if (I_IXOFF(tty)) {
@@ -1414,7 +1415,7 @@
 	struct async_icount cnow;	/* kernel counter temps */
 	struct serial_icounter_struct *p_cuser;	/* user space */
 
-	if (serial_paranoia_check(info, tty->device, "rs_ioctl"))
+	if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
 		return -ENODEV;
 
 	if ((cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) {
@@ -1619,7 +1620,7 @@
 	volatile smc_t	*smcp;
 	volatile scc_t	*sccp;
 
-	if (!info || serial_paranoia_check(info, tty->device, "rs_close"))
+	if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
 		return;
 
 	state = info->state;
@@ -1701,8 +1702,8 @@
 		rs_8xx_wait_until_sent(tty, info->timeout);
 	}
 	shutdown(info);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -1732,7 +1733,7 @@
 	/*int lsr;*/
 	volatile cbd_t *bdp;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_wait_until_sent"))
+	if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
 		return;
 
 #ifdef maybe
@@ -1789,7 +1790,7 @@
 	ser_info_t *info = (ser_info_t *)tty->driver_data;
 	struct serial_state *state = info->state;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_hangup"))
+	if (serial_paranoia_check(info, tty->name, "rs_hangup"))
 		return;
 
 	state = info->state;
@@ -1840,7 +1841,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		if (info->flags & ASYNC_NORMAL_ACTIVE)
 			return -EBUSY;
 		if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
@@ -1975,18 +1976,17 @@
 	ser_info_t	*info;
 	int 		retval, line;
 
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if ((line < 0) || (line >= NR_PORTS))
 		return -ENODEV;
 	retval = get_async_struct(line, &info);
 	if (retval)
 		return retval;
-	if (serial_paranoia_check(info, tty->device, "rs_open"))
+	if (serial_paranoia_check(info, tty->name, "rs_open"))
 		return -ENODEV;
 
 #ifdef SERIAL_DEBUG_OPEN
-	printk("rs_open %s%d, count = %d\n", tty->driver.name, info->line,
-	       info->state->count);
+	printk("rs_open %s, count = %d\n", tty->name, info->state->count);
 #endif
 	tty->driver_data = info;
 	info->tty = tty;
@@ -2010,7 +2010,7 @@
 
 	if ((info->state->count == 1) &&
 	    (info->flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->state->normal_termios;
 		else 
 			*tty->termios = info->state->callout_termios;
@@ -2021,7 +2021,7 @@
 	info->pgrp = current->pgrp;
 
 #ifdef SERIAL_DEBUG_OPEN
-	printk("rs_open ttys%d successful...", info->line);
+	printk("rs_open %s successful...", line);
 #endif
 	return 0;
 }
@@ -2450,7 +2450,8 @@
 
 static kdev_t serial_console_device(struct console *c)
 {
-	return mk_kdev(TTY_MAJOR, 64 + c->index);
+	*index = c->index;
+	return &serial_driver;
 }
 
 
@@ -2507,7 +2508,7 @@
 	serial_driver.magic = TTY_DRIVER_MAGIC;
 	serial_driver.driver_name = "serial";
 #ifdef CONFIG_DEVFS_FS
-	serial_driver.name = "tts/%d";
+	serial_driver.name = "tts/";
 #else
 	serial_driver.name = "ttyS";
 #endif
@@ -2549,7 +2550,7 @@
 	 */
 	callout_driver = serial_driver;
 #ifdef CONFIG_DEVFS_FS
-	callout_driver.name = "cua/%d";
+	callout_driver.name = "cua/";
 #else
 	callout_driver.name = "cua";
 #endif
diff -Nru a/arch/ppc/8xx_io/uart.c b/arch/ppc/8xx_io/uart.c
--- a/arch/ppc/8xx_io/uart.c	Wed Apr 30 22:28:13 2003
+++ b/arch/ppc/8xx_io/uart.c	Wed Apr 30 22:28:13 2003
@@ -91,7 +91,7 @@
 
 static void serial_console_write(struct console *c, const char *s,
 				unsigned count);
-static kdev_t serial_console_device(struct console *c);
+static struct tty_driver *serial_console_device(struct console *c, int *index)
 
 #if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
 static unsigned long break_pressed; /* break, really ... */
@@ -233,7 +233,7 @@
 static void rs_8xx_wait_until_sent(struct tty_struct *tty, int timeout);
 
 static inline int serial_paranoia_check(ser_info_t *info,
-					kdev_t device, const char *routine)
+					char *name, const char *routine)
 {
 #ifdef SERIAL_PARANOIA_CHECK
 	static const char *badmagic =
@@ -242,11 +242,11 @@
 		"Warning: null async_struct for (%s) in %s\n";
 
 	if (!info) {
-		printk(badinfo, cdevname(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (info->magic != SERIAL_MAGIC) {
-		printk(badmagic, cdevname(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -279,7 +279,7 @@
 	volatile scc_t	*sccp;
 	volatile smc_t	*smcp;
 
-	if (serial_paranoia_check(info, tty->device, "rs_stop"))
+	if (serial_paranoia_check(info, tty->name, "rs_stop"))
 		return;
 	
 	save_flags(flags); cli();
@@ -303,7 +303,7 @@
 	volatile scc_t	*sccp;
 	volatile smc_t	*smcp;
 
-	if (serial_paranoia_check(info, tty->device, "rs_stop"))
+	if (serial_paranoia_check(info, tty->name, "rs_stop"))
 		return;
 	
 	idx = PORT_NUM(info->state->smc_scc_num);
@@ -1043,7 +1043,7 @@
 	volatile cbd_t	*bdp;
 	unsigned char *cp;
 
-	if (serial_paranoia_check(info, tty->device, "rs_put_char"))
+	if (serial_paranoia_check(info, tty->name, "rs_put_char"))
 		return;
 
 	if (!tty)
@@ -1082,7 +1082,7 @@
             return ret;
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_write"))
+	if (serial_paranoia_check(info, tty->name, "rs_write"))
 		return 0;
 
 	if (!tty) 
@@ -1135,7 +1135,7 @@
 	ser_info_t *info = (ser_info_t *)tty->driver_data;
 	int	ret;
 
-	if (serial_paranoia_check(info, tty->device, "rs_write_room"))
+	if (serial_paranoia_check(info, tty->name, "rs_write_room"))
 		return 0;
 
 	if ((info->tx_cur->cbd_sc & BD_SC_READY) == 0) {
@@ -1155,7 +1155,7 @@
 {
 	ser_info_t *info = (ser_info_t *)tty->driver_data;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_chars_in_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
 		return 0;
 	return 0;
 }
@@ -1164,7 +1164,7 @@
 {
 	ser_info_t *info = (ser_info_t *)tty->driver_data;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_flush_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
 		return;
 
 	/* There is nothing to "flush", whatever we gave the CPM
@@ -1188,7 +1188,7 @@
 
 	ser_info_t *info = (ser_info_t *)tty->driver_data;
 
-	if (serial_paranoia_check(info, tty->device, "rs_send_char"))
+	if (serial_paranoia_check(info, tty->name, "rs_send_char"))
 		return;
 
 	bdp = info->tx_cur;
@@ -1227,7 +1227,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_throttle"))
+	if (serial_paranoia_check(info, tty->name, "rs_throttle"))
 		return;
 	
 	if (I_IXOFF(tty))
@@ -1253,7 +1253,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_unthrottle"))
+	if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
 		return;
 	
 	if (I_IXOFF(tty)) {
@@ -1462,7 +1462,7 @@
 	struct async_icount cnow;	/* kernel counter temps */
 	struct serial_icounter_struct *p_cuser;	/* user space */
 
-	if (serial_paranoia_check(info, tty->device, "rs_ioctl"))
+	if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
 		return -ENODEV;
 
 	if ((cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) {
@@ -1667,7 +1667,7 @@
 	volatile smc_t	*smcp;
 	volatile scc_t	*sccp;
 
-	if (!info || serial_paranoia_check(info, tty->device, "rs_close"))
+	if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
 		return;
 
 	state = info->state;
@@ -1750,8 +1750,8 @@
 		rs_8xx_wait_until_sent(tty, info->timeout);
 	}
 	shutdown(info);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -1781,7 +1781,7 @@
 	/*int lsr;*/
 	volatile cbd_t *bdp;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_wait_until_sent"))
+	if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
 		return;
 
 #ifdef maybe
@@ -1849,7 +1849,7 @@
 	ser_info_t *info = (ser_info_t *)tty->driver_data;
 	struct serial_state *state = info->state;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_hangup"))
+	if (serial_paranoia_check(info, tty->name, "rs_hangup"))
 		return;
 
 	state = info->state;
@@ -1900,7 +1900,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		if (info->flags & ASYNC_NORMAL_ACTIVE)
 			return -EBUSY;
 		if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
@@ -2035,18 +2035,17 @@
 	ser_info_t	*info;
 	int 		retval, line;
 
-	line = MINOR(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if ((line < 0) || (line >= NR_PORTS))
 		return -ENODEV;
 	retval = get_async_struct(line, &info);
 	if (retval)
 		return retval;
-	if (serial_paranoia_check(info, tty->device, "rs_open"))
+	if (serial_paranoia_check(info, tty->name, "rs_open"))
 		return -ENODEV;
 
 #ifdef SERIAL_DEBUG_OPEN
-	printk("rs_open %s%d, count = %d\n", tty->driver.name, info->line,
-	       info->state->count);
+	printk("rs_open %s, count = %d\n", tty->name, info->state->count);
 #endif
 	tty->driver_data = info;
 	info->tty = tty;
@@ -2071,7 +2070,7 @@
 
 	if ((info->state->count == 1) &&
 	    (info->flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->state->normal_termios;
 		else 
 			*tty->termios = info->state->callout_termios;
@@ -2082,7 +2081,7 @@
 	info->pgrp = current->pgrp;
 
 #ifdef SERIAL_DEBUG_OPEN
-	printk("rs_open ttys%d successful...", info->line);
+	printk("rs_open %s successful...", tty->name);
 #endif
 	return 0;
 }
@@ -2514,9 +2513,10 @@
 }
 #endif
 
-static kdev_t serial_console_device(struct console *c)
+static struct tty_driver *serial_console_device(struct console *c, int *index)
 {
-	return MKDEV(TTY_MAJOR, 64 + c->index);
+	*index = c->index;
+	return &serial_driver;
 }
 
 /*
@@ -2561,7 +2561,7 @@
 	serial_driver.magic = TTY_DRIVER_MAGIC;
 	serial_driver.driver_name = "serial";
 #ifdef CONFIG_DEVFS_FS
-	serial_driver.name = "tts/%d";
+	serial_driver.name = "tts/";
 #else
 	serial_driver.name = "ttyS";
 #endif
@@ -2603,7 +2603,7 @@
 	 */
 	callout_driver = serial_driver;
 #ifdef CONFIG_DEVFS_FS
-	callout_driver.name = "cua/%d";
+	callout_driver.name = "cua/";
 #else
 	callout_driver.name = "cua";
 #endif
diff -Nru a/arch/ppc/Kconfig b/arch/ppc/Kconfig
--- a/arch/ppc/Kconfig	Wed Apr 30 22:28:19 2003
+++ b/arch/ppc/Kconfig	Wed Apr 30 22:28:19 2003
@@ -808,7 +808,7 @@
 	  programs that need an interpreter to run like Java, Python or
 	  Emacs-Lisp.  It's also useful if you often run DOS executables under
 	  the Linux DOS emulator DOSEMU (read the DOSEMU-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>).  Once you have
+	  <http://www.tldp.org/docs.html#howto>).  Once you have
 	  registered such a binary class with the kernel, you can start one of
 	  those programs simply by typing in its name at a shell prompt; Linux
 	  will automatically feed it to the correct interpreter.
@@ -1444,7 +1444,7 @@
 	  interrupt and DMA channel), because you will be asked for it.
 
 	  You want to read the Sound-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. General information about
+	  <http://www.tldp.org/docs.html#howto>. General information about
 	  the modular sound system is contained in the files
 	  <file:Documentation/sound/Introduction>.  The file
 	  <file:Documentation/sound/README.OSS> contains some slightly
diff -Nru a/arch/ppc/amiga/amiints.c b/arch/ppc/amiga/amiints.c
--- a/arch/ppc/amiga/amiints.c	Wed Apr 30 22:28:04 2003
+++ b/arch/ppc/amiga/amiints.c	Wed Apr 30 22:28:04 2003
@@ -55,10 +55,6 @@
 #include <asm/amigappc.h>
 #endif
 
-extern int cia_request_irq(int irq,
-                           void (*handler)(int, void *, struct pt_regs *),
-                           unsigned long flags, const char *devname, void *dev_id);
-extern void cia_free_irq(unsigned int irq, void *dev_id);
 extern void cia_init_IRQ(struct ciabase *base);
 
 unsigned short ami_intena_vals[AMI_STD_IRQS] = {
diff -Nru a/arch/ppc/amiga/config.c b/arch/ppc/amiga/config.c
--- a/arch/ppc/amiga/config.c	Wed Apr 30 22:28:15 2003
+++ b/arch/ppc/amiga/config.c	Wed Apr 30 22:28:15 2003
@@ -71,7 +71,7 @@
 
 extern char m68k_debug_device[];
 
-static void amiga_sched_init(void (*handler)(int, void *, struct pt_regs *));
+static void amiga_sched_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
 /* amiga specific irq functions */
 extern void amiga_init_IRQ (void);
 extern void (*amiga_default_handler[]) (int, void *, struct pt_regs *);
@@ -478,8 +478,8 @@
 
 static unsigned short jiffy_ticks;
 
-static void __init amiga_sched_init(void (*timer_routine)(int, void *,
-							  struct pt_regs *))
+static void __init amiga_sched_init(irqreturn_t (*timer_routine)(int, void *,
+						struct pt_regs *))
 {
 	static struct resource sched_res = {
 	    "timer", 0x00bfd400, 0x00bfd5ff,
diff -Nru a/arch/ppc/kernel/cpu_setup_6xx.S b/arch/ppc/kernel/cpu_setup_6xx.S
--- a/arch/ppc/kernel/cpu_setup_6xx.S	Wed Apr 30 22:28:05 2003
+++ b/arch/ppc/kernel/cpu_setup_6xx.S	Wed Apr 30 22:28:05 2003
@@ -16,6 +16,7 @@
 #include <asm/cputable.h>
 #include <asm/ppc_asm.h>
 #include <asm/offsets.h>
+#include <asm/cache.h>
 
 _GLOBAL(__setup_cpu_601)
 	blr
@@ -63,13 +64,7 @@
 	mtspr	SPRN_L2CR2,r3
 	mtlr	r4
 	blr
-_GLOBAL(__setup_cpu_7450)
-	mflr	r4
-	bl	setup_common_caches
-	bl	setup_745x_specifics
-	mtlr	r4
-	blr
-_GLOBAL(__setup_cpu_7455)
+_GLOBAL(__setup_cpu_745x)
 	mflr	r4
 	bl	setup_common_caches
 	bl	setup_745x_specifics
@@ -265,9 +260,10 @@
 #define CS_SIZE		28
 
 	.data
-	.balign	4
+	.balign	L1_CACHE_LINE_SIZE
 cpu_state_storage:	
 	.space	CS_SIZE
+	.balign	L1_CACHE_LINE_SIZE,0
 	.text
 	
 /* Called in normal context to backup CPU 0 state. This
@@ -277,6 +273,9 @@
  * like HID0, HID1, MSSCR0, etc...
  */
 _GLOBAL(__save_cpu_setup)
+	/* Some CR fields are volatile, we back it up all */
+	mfcr	r7
+
 	/* Get storage ptr */
 	lis	r5,cpu_state_storage@h
 	ori	r5,r5,cpu_state_storage@l
@@ -322,6 +321,7 @@
 	mfspr	r4,SPRN_HID1
 	stw	r4,CS_HID1(r5)
 1:
+	mtcr	r7
 	blr
 
 /* Called with no MMU context (typically MSR:IR/DR off) to
@@ -329,6 +329,9 @@
  * function. This does not include cache setting
  */
 _GLOBAL(__restore_cpu_setup)
+	/* Some CR fields are volatile, we back it up all */
+	mfcr	r7
+
 	/* Get storage ptr */
 	lis	r5,(cpu_state_storage-KERNELBASE)@h
 	ori	r5,r5,cpu_state_storage@l
@@ -411,5 +414,6 @@
 	/* Setup final PLL */
 	mtspr	SPRN_HID1,r4
 1:
+	mtcr	r7
 	blr
 
diff -Nru a/arch/ppc/kernel/cputable.c b/arch/ppc/kernel/cputable.c
--- a/arch/ppc/kernel/cputable.c	Wed Apr 30 22:28:10 2003
+++ b/arch/ppc/kernel/cputable.c	Wed Apr 30 22:28:10 2003
@@ -26,8 +26,7 @@
 extern void __setup_cpu_750fx(unsigned long offset, int cpu_nr, struct cpu_spec* spec);
 extern void __setup_cpu_7400(unsigned long offset, int cpu_nr, struct cpu_spec* spec);
 extern void __setup_cpu_7410(unsigned long offset, int cpu_nr, struct cpu_spec* spec);
-extern void __setup_cpu_7450(unsigned long offset, int cpu_nr, struct cpu_spec* spec);
-extern void __setup_cpu_7455(unsigned long offset, int cpu_nr, struct cpu_spec* spec);
+extern void __setup_cpu_745x(unsigned long offset, int cpu_nr, struct cpu_spec* spec);
 extern void __setup_cpu_power3(unsigned long offset, int cpu_nr, struct cpu_spec* spec);
 extern void __setup_cpu_8xx(unsigned long offset, int cpu_nr, struct cpu_spec* spec);
 extern void __setup_cpu_generic(unsigned long offset, int cpu_nr, struct cpu_spec* spec);
@@ -168,7 +167,7 @@
     	0xffff0000, 0x70000000, "750FX",
     	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB |
 	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_CAN_NAP |
-	CPU_FTR_DUAL_PLL_750FX,
+	CPU_FTR_DUAL_PLL_750FX | CPU_FTR_HAS_HIGH_BATS,
 	COMMON_PPC,
 	32, 32,
 	__setup_cpu_750fx
@@ -216,7 +215,7 @@
 	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450,
 	COMMON_PPC | PPC_FEATURE_HAS_ALTIVEC,
 	32, 32,
-	__setup_cpu_7450
+	__setup_cpu_745x
     },
     {	/* 7450 2.1 */
     	0xffffffff, 0x80000201, "7450",
@@ -226,7 +225,7 @@
 	CPU_FTR_L3_DISABLE_NAP,
 	COMMON_PPC | PPC_FEATURE_HAS_ALTIVEC,
 	32, 32,
-	__setup_cpu_7450
+	__setup_cpu_745x
     },
     {	/* 7450 2.3 and newer */
     	0xffff0000, 0x80000000, "7450",
@@ -235,35 +234,46 @@
 	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_NAP_DISABLE_L2_PR,
 	COMMON_PPC | PPC_FEATURE_HAS_ALTIVEC,
 	32, 32,
-	__setup_cpu_7450
+	__setup_cpu_745x
     },
     {	/* 7455 rev 1.x */
     	0xffffff00, 0x80010100, "7455",
     	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
 	CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
-	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450,
+	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_HAS_HIGH_BATS,
 	COMMON_PPC | PPC_FEATURE_HAS_ALTIVEC,
 	32, 32,
-	__setup_cpu_7455
+	__setup_cpu_745x
     },
     {	/* 7455 rev 2.0 */
     	0xffffffff, 0x80010200, "7455",
     	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_CAN_NAP |
 	CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
 	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_NAP_DISABLE_L2_PR |
-	CPU_FTR_L3_DISABLE_NAP,
+	CPU_FTR_L3_DISABLE_NAP | CPU_FTR_HAS_HIGH_BATS,
 	COMMON_PPC | PPC_FEATURE_HAS_ALTIVEC,
 	32, 32,
-	__setup_cpu_7455
+	__setup_cpu_745x
     },
     {	/* 7455 others */
     	0xffff0000, 0x80010000, "7455",
     	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_CAN_NAP |
 	CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
-	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_NAP_DISABLE_L2_PR,
+	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_NAP_DISABLE_L2_PR |
+	CPU_FTR_HAS_HIGH_BATS,
+	COMMON_PPC | PPC_FEATURE_HAS_ALTIVEC,
+	32, 32,
+	__setup_cpu_745x
+    },
+    {	/* 7457 */
+    	0xffff0000, 0x80020000, "7457",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_CAN_NAP |
+	CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
+	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_NAP_DISABLE_L2_PR |
+	CPU_FTR_HAS_HIGH_BATS,
 	COMMON_PPC | PPC_FEATURE_HAS_ALTIVEC,
 	32, 32,
-	__setup_cpu_7455
+	__setup_cpu_745x
     },
     {	/* 82xx (8240, 8245, 8260 are all 603e cores) */
 	0x7fff0000, 0x00810000, "82xx",
diff -Nru a/arch/ppc/kernel/head.S b/arch/ppc/kernel/head.S
--- a/arch/ppc/kernel/head.S	Wed Apr 30 22:28:10 2003
+++ b/arch/ppc/kernel/head.S	Wed Apr 30 22:28:10 2003
@@ -1451,6 +1451,30 @@
 	mtspr	IBAT2L,r10
 	mtspr	IBAT3U,r10
 	mtspr	IBAT3L,r10
+BEGIN_FTR_SECTION
+	/* Here's a tweak: at this point, CPU setup have
+	 * not been called yet, so HIGH_BAT_EN may not be
+	 * set in HID0 for the 745x processors. However, it
+	 * seems that doesn't affect our ability to actually
+	 * write to these SPRs.
+	 */
+	mtspr	SPRN_DBAT4U,r20
+	mtspr	SPRN_DBAT4L,r20
+	mtspr	SPRN_DBAT5U,r20
+	mtspr	SPRN_DBAT5L,r20
+	mtspr	SPRN_DBAT6U,r20
+	mtspr	SPRN_DBAT6L,r20
+	mtspr	SPRN_DBAT7U,r20
+	mtspr	SPRN_DBAT7L,r20
+	mtspr	SPRN_IBAT4U,r20
+	mtspr	SPRN_IBAT4L,r20
+	mtspr	SPRN_IBAT5U,r20
+	mtspr	SPRN_IBAT5L,r20
+	mtspr	SPRN_IBAT6U,r20
+	mtspr	SPRN_IBAT6L,r20
+	mtspr	SPRN_IBAT7U,r20
+	mtspr	SPRN_IBAT7L,r20
+END_FTR_SECTION_IFSET(CPU_FTR_HAS_HIGH_BATS)
 	blr
 
 flush_tlbs:
diff -Nru a/arch/ppc/kernel/irq.c b/arch/ppc/kernel/irq.c
--- a/arch/ppc/kernel/irq.c	Wed Apr 30 22:28:15 2003
+++ b/arch/ppc/kernel/irq.c	Wed Apr 30 22:28:15 2003
@@ -210,7 +210,8 @@
 	return;
 }
 
-int request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
+int request_irq(unsigned int irq,
+	irqreturn_t (*handler)(int, void *, struct pt_regs *),
 	unsigned long irqflags, const char * devname, void *dev_id)
 {
 	struct irqaction *action;
@@ -218,16 +219,9 @@
 
 	if (irq >= NR_IRQS)
 		return -EINVAL;
-	if (!handler)
-	{
-		/*
-		 * free_irq() used to be implemented as a call to
-		 * request_irq() with handler being NULL.  Now we have
-		 * a real free_irq() but need to allow the old behavior
-		 * for old code that hasn't caught up yet.
-		 *  -- Cort <cort@fsmlabs.com>
-		 */
-		free_irq(irq, dev_id);
+	if (!handler) {
+		printk(KERN_ERR "request_irq called with NULL handler!\n");
+		dump_stack();
 		return 0;
 	}
 	
@@ -246,8 +240,7 @@
 	action->next = NULL;
 	
 	retval = setup_irq(irq, action);
-	if (retval)
-	{
+	if (retval) {
 		kfree(action);
 		return retval;
 	}
@@ -732,6 +725,7 @@
 	}
 }
 
-void no_action(int irq, void *dev, struct pt_regs *regs)
+irqreturn_t no_action(int irq, void *dev, struct pt_regs *regs)
 {
+	return IRQ_NONE;
 }
diff -Nru a/arch/ppc/kernel/l2cr.S b/arch/ppc/kernel/l2cr.S
--- a/arch/ppc/kernel/l2cr.S	Wed Apr 30 22:28:10 2003
+++ b/arch/ppc/kernel/l2cr.S	Wed Apr 30 22:28:10 2003
@@ -40,9 +40,11 @@
 	Author:	Terry Greeniaus (tgree@phys.ualberta.ca)
 	Please e-mail updates to this file to me, thanks!
 */
+#include <linux/config.h>
 #include <asm/processor.h>
 #include <asm/cputable.h>
 #include <asm/ppc_asm.h>
+#include <asm/cache.h>
 
 /* Usage:
 	
@@ -101,6 +103,8 @@
 	blr
 END_FTR_SECTION_IFCLR(CPU_FTR_L2CR)
 
+	mflr	r9
+	
 	/* Stop DST streams */
 BEGIN_FTR_SECTION
 	DSSALL
@@ -115,6 +119,22 @@
 	mtmsr	r4
 	isync
 
+	/* Before we perform the global invalidation, we must disable dynamic
+	 * power management via HID0[DPM] to work around a processor bug where
+	 * DPM can possibly interfere with the state machine in the processor
+	 * that invalidates the L2 cache tags.
+	 */
+	mfspr	r8,HID0			/* Save HID0 in r8 */
+	rlwinm	r4,r8,0,12,10		/* Turn off HID0[DPM] */
+	sync
+	mtspr	HID0,r4			/* Disable DPM */
+	sync
+
+	/* Flush & disable L1 */
+	mr	r5,r3
+	bl	__flush_disable_L1
+	mr	r3,r5
+	
 	/* Get the current enable bit of the L2CR into r4 */
 	mfspr	r4,L2CR
 	
@@ -136,27 +156,28 @@
 	 /**** Might be a good idea to set L2DO here - to prevent instructions
 	       from getting into the cache.  But since we invalidate
 	       the next time we enable the cache it doesn't really matter.
-	       Don't do this unless you accommodate all processor variations.
+	       Don't do this unless you accomodate all processor variations.
 	       The bit moved on the 7450.....
 	  ****/
 
 	/* TODO: use HW flush assist when available */
 
-	lis	r4,0x0004
+	lis	r4,0x0002
 	mtctr	r4
 	li	r4,0
 1:
 	lwzx	r0,r0,r4
 	addi	r4,r4,32		/* Go to start of next cache line */
 	bdnz	1b
+	isync
 	
 	/* Now, flush the first 4MB of memory */
-	lis	r4,0x0004
+	lis	r4,0x0002
 	mtctr	r4
 	li	r4,0
 	sync
 1:
-	dcbf	r0,r4
+	dcbf	0,r4
 	addi	r4,r4,32		/* Go to start of next cache line */
 	bdnz	1b
 
@@ -166,25 +187,19 @@
 	 * L1 icache
 	 */
 	b	20f
-21:
+	.balign	L1_CACHE_LINE_SIZE
+22:
 	sync
 	mtspr	L2CR,r3
 	sync
-	b	22f
+	b	23f
 20:
-	b	21b
-22:
-	/* Before we perform the global invalidation, we must disable dynamic
-	 * power management via HID0[DPM] to work around a processor bug where
-	 * DPM can possibly interfere with the state machine in the processor
-	 * that invalidates the L2 cache tags.
-	 */
-	mfspr	r8,HID0			/* Save HID0 in r8 */
-	rlwinm	r4,r8,0,12,10		/* Turn off HID0[DPM] */
-	sync
-	mtspr	HID0,r4			/* Disable DPM */
-	sync
-
+	b	21f
+21:	sync
+	isync
+	b	22b
+		
+23:
 	/* Perform a global invalidation */
 	oris	r3,r3,0x0020
 	sync
@@ -211,11 +226,6 @@
 	mtspr	L2CR,r3
 	sync
 	
-	/* Restore HID0[DPM] to whatever it was before */
-	sync
-	mtspr	1008,r8
-	sync
-
 	/* See if we need to enable the cache */
 	cmplwi	r5,0
 	beq	4f
@@ -225,10 +235,20 @@
 	mtspr	L2CR,r3
 	sync
 
+4:
+	bl	__inval_enable_L1
+
+	/* Restore HID0[DPM] to whatever it was before */
+	sync
+	mtspr	1008,r8
+	sync
+
 	/* Restore MSR (restores EE and DR bits to original state) */
-4:	SYNC
+	SYNC
 	mtmsr	r7
 	isync
+
+	mtlr	r9
 	blr
 
 _GLOBAL(_get_L2CR)
@@ -286,7 +306,7 @@
 	li	r4,0
 1:
 	lwzx	r0,r0,r4
-	dcbf	r0,r4
+	dcbf	0,r4
 	addi	r4,r4,32		/* Go to start of next cache line */
 	bdnz	1b
 	
@@ -360,3 +380,73 @@
 
 /* --- End of PowerLogix code ---
  */
+
+
+/* flush_disable_L1()	- Flush and disable L1 cache
+ *
+ * clobbers r0, r3, ctr, cr0
+ *
+ */
+ 	.globl	__flush_disable_L1
+ __flush_disable_L1:
+ 
+	/* Stop pending alitvec streams and memory accesses */
+BEGIN_FTR_SECTION
+	DSSALL
+END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
+ 	sync
+ 	
+	/* Load counter to 0x1000 cache lines (128k) and
+	 * load cache with datas
+	 */
+	lis	r3,0x0002
+//	li	r3,0x1000	/* 128kB / 32B */
+	mtctr	r3
+	li	r3, 0
+1:
+	lwz	r0,0(r3)
+	addi	r3,r3,0x0020	/* Go to start of next cache line */
+	bdnz	1b
+	isync
+	sync
+
+	/* Now flush those cache lines */
+	lis	r3,0x0002
+//	li	r3,0x1000	/* 128kB / 32B */
+	mtctr	r3
+	li	r3, 0
+1:
+	dcbf	0,r3
+	addi	r3,r3,0x0020	/* Go to start of next cache line */
+	bdnz	1b
+	sync
+
+	/* We can now disable the L1 cache (HID0:DCE, HID0:ICE) */
+	mfspr	r3,SPRN_HID0
+	rlwinm	r3,r3,0,18,15
+	mtspr	SPRN_HID0,r3
+	sync
+	isync	
+ 	blr
+
+/* inval_enable_L1	- Invalidate and enable L1 cache
+ *
+ * Assumes L1 is already disabled and MSR:EE is off
+ *
+ * clobbers r3
+ */
+ 	.globl	__inval_enable_L1
+ __inval_enable_L1:
+	/* Enable and then Flash inval the instruction & data cache */
+	mfspr	r3,SPRN_HID0
+	ori	r3,r3, HID0_ICE|HID0_ICFI|HID0_DCE|HID0_DCI
+	sync
+	isync
+	mtspr	SPRN_HID0,r3
+	xori	r3,r3, HID0_ICFI|HID0_DCI
+	mtspr	SPRN_HID0,r3
+	sync
+
+ 	blr
+
+ 
diff -Nru a/arch/ppc/kernel/ppc_ksyms.c b/arch/ppc/kernel/ppc_ksyms.c
--- a/arch/ppc/kernel/ppc_ksyms.c	Wed Apr 30 22:28:17 2003
+++ b/arch/ppc/kernel/ppc_ksyms.c	Wed Apr 30 22:28:17 2003
@@ -46,6 +46,7 @@
 #include <asm/cputable.h>
 #include <asm/btext.h>
 #include <asm/div64.h>
+#include <asm/xmon.h>
 
 #ifdef  CONFIG_8xx
 #include <asm/commproc.h>
@@ -306,7 +307,6 @@
 EXPORT_SYMBOL(get_wchan);
 EXPORT_SYMBOL(console_drivers);
 #ifdef CONFIG_XMON
-extern void xmon_printf(char *fmt, ...);
 EXPORT_SYMBOL(xmon);
 EXPORT_SYMBOL(xmon_printf);
 #endif
diff -Nru a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c
--- a/arch/ppc/kernel/setup.c	Wed Apr 30 22:28:17 2003
+++ b/arch/ppc/kernel/setup.c	Wed Apr 30 22:28:17 2003
@@ -9,7 +9,7 @@
 #include <linux/init.h>
 #include <linux/reboot.h>
 #include <linux/delay.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/ide.h>
 #include <linux/tty.h>
 #include <linux/bootmem.h>
@@ -34,6 +34,7 @@
 #include <asm/system.h>
 #include <asm/pmac_feature.h>
 #include <asm/sections.h>
+#include <asm/xmon.h>
 
 #if defined CONFIG_KGDB
 #include <asm/kgdb.h>
@@ -46,9 +47,6 @@
 extern void do_cpu_ftr_fixups(unsigned long offset);
 extern void reloc_got2(unsigned long offset);
 
-#ifdef CONFIG_XMON
-extern void xmon_map_scc(void);
-#endif
 
 #ifdef CONFIG_KGDB
 extern void kgdb_map_scc(void);
diff -Nru a/arch/ppc/kernel/smp.c b/arch/ppc/kernel/smp.c
--- a/arch/ppc/kernel/smp.c	Wed Apr 30 22:28:17 2003
+++ b/arch/ppc/kernel/smp.c	Wed Apr 30 22:28:17 2003
@@ -35,6 +35,7 @@
 #include <asm/time.h>
 #include <asm/thread_info.h>
 #include <asm/tlbflush.h>
+#include <asm/xmon.h>
 
 int smp_threads_ready;
 volatile int smp_commenced;
diff -Nru a/arch/ppc/kernel/traps.c b/arch/ppc/kernel/traps.c
--- a/arch/ppc/kernel/traps.c	Wed Apr 30 22:28:05 2003
+++ b/arch/ppc/kernel/traps.c	Wed Apr 30 22:28:05 2003
@@ -36,21 +36,13 @@
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/processor.h>
+#include <asm/xmon.h>
 #ifdef CONFIG_PMAC_BACKLIGHT
 #include <asm/backlight.h>
 #endif
 
 extern int fix_alignment(struct pt_regs *);
 extern void bad_page_fault(struct pt_regs *, unsigned long, int sig);
-
-#ifdef CONFIG_XMON
-extern void xmon(struct pt_regs *regs);
-extern int xmon_bpt(struct pt_regs *regs);
-extern int xmon_sstep(struct pt_regs *regs);
-extern int xmon_iabr_match(struct pt_regs *regs);
-extern int xmon_dabr_match(struct pt_regs *regs);
-extern void (*xmon_fault_handler)(struct pt_regs *regs);
-#endif
 
 #ifdef CONFIG_XMON
 void (*debugger)(struct pt_regs *regs) = xmon;
diff -Nru a/arch/ppc/mm/init.c b/arch/ppc/mm/init.c
--- a/arch/ppc/mm/init.c	Wed Apr 30 22:28:05 2003
+++ b/arch/ppc/mm/init.c	Wed Apr 30 22:28:05 2003
@@ -28,9 +28,7 @@
 #include <linux/init.h>
 #include <linux/bootmem.h>
 #include <linux/highmem.h>
-#ifdef CONFIG_BLK_DEV_INITRD
-#include <linux/blk.h>		/* for initrd_* */
-#endif
+#include <linux/initrd.h>
 
 #include <asm/pgalloc.h>
 #include <asm/prom.h>
diff -Nru a/arch/ppc/mm/pgtable.c b/arch/ppc/mm/pgtable.c
--- a/arch/ppc/mm/pgtable.c	Wed Apr 30 22:28:05 2003
+++ b/arch/ppc/mm/pgtable.c	Wed Apr 30 22:28:05 2003
@@ -76,15 +76,11 @@
 	extern void *early_get_page(void);
 	int timeout = 0;
 
-	if (mem_init_done) {
-		while ((pte = (pte_t *) __get_free_page(GFP_KERNEL)) == NULL
-		       && ++timeout < 10) {
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(HZ);
-		}
-	} else
-		pte = (pte_t *) early_get_page();
-	if (pte != NULL)
+	if (mem_init_done)
+		pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
+	else
+		pte = (pte_t *)early_get_page();
+	if (pte)
 		clear_page(pte);
 	return pte;
 }
@@ -92,20 +88,16 @@
 struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
 {
 	struct page *pte;
-	int timeout = 0;
+
 #ifdef CONFIG_HIGHPTE
-	int flags = GFP_KERNEL | __GFP_HIGHMEM;
+	int flags = GFP_KERNEL | __GFP_HIGHMEM | __GFP_REPEAT;
 #else
-	int flags = GFP_KERNEL;
+	int flags = GFP_KERNEL | __GFP_REPEAT;
 #endif
 
-	while ((pte = alloc_pages(flags, 0)) == NULL) {
-		if (++timeout >= 10)
-			return NULL;
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ);
-	}
-	clear_highpage(pte);
+	pte = alloc_pages(flags, 0);
+	if (pte)
+		clear_highpage(pte);
 	return pte;
 }
 
diff -Nru a/arch/ppc/platforms/4xx/oak_setup.c b/arch/ppc/platforms/4xx/oak_setup.c
--- a/arch/ppc/platforms/4xx/oak_setup.c	Wed Apr 30 22:28:15 2003
+++ b/arch/ppc/platforms/4xx/oak_setup.c	Wed Apr 30 22:28:15 2003
@@ -18,7 +18,7 @@
 #include <linux/threads.h>
 #include <linux/param.h>
 #include <linux/string.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/irq.h>
 #include <linux/seq_file.h>
 
@@ -101,7 +101,7 @@
 
 	ppc_md.setup_arch	 	= oak_setup_arch;
 	ppc_md.show_percpuinfo	 	= oak_show_percpuinfo;
-	ppc_md.irq_cannonicalize 	= NULL;
+	ppc_md.irq_canonicalize 	= NULL;
 	ppc_md.init_IRQ		 	= oak_init_IRQ;
 	ppc_md.get_irq		 	= oak_get_irq;
 	ppc_md.init		 	= NULL;
diff -Nru a/arch/ppc/platforms/4xx/redwood.h b/arch/ppc/platforms/4xx/redwood.h
--- a/arch/ppc/platforms/4xx/redwood.h	Wed Apr 30 22:28:20 2003
+++ b/arch/ppc/platforms/4xx/redwood.h	Wed Apr 30 22:28:20 2003
@@ -49,7 +49,7 @@
 #define _ISA_MEM_BASE	0
 #define PCI_DRAM_OFFSET	0
 
-#define BASE_BAUD		1312500
+#define BASE_BAUD		(378000000 / 18 / 16)
 
 #define PPC4xx_MACHINE_NAME	"IBM Redwood"
 
diff -Nru a/arch/ppc/platforms/4xx/redwood5.h b/arch/ppc/platforms/4xx/redwood5.h
--- a/arch/ppc/platforms/4xx/redwood5.h	Wed Apr 30 22:28:04 2003
+++ b/arch/ppc/platforms/4xx/redwood5.h	Wed Apr 30 22:28:04 2003
@@ -45,9 +45,7 @@
 #define _ISA_MEM_BASE	0
 #define PCI_DRAM_OFFSET	0
 
-/* serail defines moved from ppc4xx_serial.h *
- */
-#define BASE_BAUD		1267200
+#define BASE_BAUD		(378000000 / 18 / 16)
 
 #define PPC4xx_MACHINE_NAME	"IBM Redwood5"
 
diff -Nru a/arch/ppc/platforms/4xx/redwood6.h b/arch/ppc/platforms/4xx/redwood6.h
--- a/arch/ppc/platforms/4xx/redwood6.h	Wed Apr 30 22:28:05 2003
+++ b/arch/ppc/platforms/4xx/redwood6.h	Wed Apr 30 22:28:05 2003
@@ -46,7 +46,7 @@
 #define _ISA_MEM_BASE	0
 #define PCI_DRAM_OFFSET	0
 
-#define BASE_BAUD		1267200
+#define BASE_BAUD		(378000000 / 18 / 16)
 
 #define PPC4xx_MACHINE_NAME	"IBM Redwood6"
 
diff -Nru a/arch/ppc/platforms/adir_setup.c b/arch/ppc/platforms/adir_setup.c
--- a/arch/ppc/platforms/adir_setup.c	Wed Apr 30 22:28:07 2003
+++ b/arch/ppc/platforms/adir_setup.c	Wed Apr 30 22:28:07 2003
@@ -17,7 +17,7 @@
 #include <linux/kdev_t.h>
 #include <linux/types.h>
 #include <linux/major.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/ide.h>
@@ -189,7 +189,7 @@
 
 	ppc_md.setup_arch = adir_setup_arch;
 	ppc_md.show_cpuinfo = adir_show_cpuinfo;
-	ppc_md.irq_cannonicalize = NULL;
+	ppc_md.irq_canonicalize = NULL;
 	ppc_md.init_IRQ = adir_init_IRQ;
 	ppc_md.get_irq = adir_get_irq;
 	ppc_md.init = NULL;
diff -Nru a/arch/ppc/platforms/apus_setup.c b/arch/ppc/platforms/apus_setup.c
--- a/arch/ppc/platforms/apus_setup.c	Wed Apr 30 22:28:10 2003
+++ b/arch/ppc/platforms/apus_setup.c	Wed Apr 30 22:28:10 2003
@@ -17,7 +17,7 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/init.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/seq_file.h>
 
 /* Needs INITSERIAL call in head.S! */
diff -Nru a/arch/ppc/platforms/chrp_setup.c b/arch/ppc/platforms/chrp_setup.c
--- a/arch/ppc/platforms/chrp_setup.c	Wed Apr 30 22:28:15 2003
+++ b/arch/ppc/platforms/chrp_setup.c	Wed Apr 30 22:28:15 2003
@@ -36,6 +36,7 @@
 #include <linux/console.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
+#include <linux/initrd.h>
 
 #include <asm/processor.h>
 #include <asm/io.h>
@@ -52,6 +53,7 @@
 #include <asm/btext.h>
 #include <asm/i8259.h>
 #include <asm/open_pic.h>
+#include <asm/xmon.h>
 
 unsigned long chrp_get_rtc_time(void);
 int chrp_set_rtc_time(unsigned long nowtime);
@@ -67,7 +69,14 @@
 extern unsigned long pmac_find_end_of_memory(void);
 extern int of_show_percpuinfo(struct seq_file *, int);
 
-extern kdev_t boot_dev;
+/*
+ * XXX this should be in xmon.h, but putting it there means xmon.h
+ * has to include <linux/interrupt.h> (to get irqreturn_t), which
+ * causes all sorts of problems.  -- paulus
+ */ 
+extern irqreturn_t xmon_irq(int, void *, struct pt_regs *);
+
+extern dev_t boot_dev;
 
 extern PTE *Hash, *Hash_end;
 extern unsigned long Hash_size, Hash_mask;
@@ -306,7 +315,7 @@
 }
 
 u_int __chrp
-chrp_irq_cannonicalize(u_int irq)
+chrp_irq_canonicalize(u_int irq)
 {
 	if (irq == 2)
 		return 9;
@@ -456,7 +465,7 @@
 	ppc_md.setup_arch     = chrp_setup_arch;
 	ppc_md.show_percpuinfo = of_show_percpuinfo;
 	ppc_md.show_cpuinfo   = chrp_show_cpuinfo;
-	ppc_md.irq_cannonicalize = chrp_irq_cannonicalize;
+	ppc_md.irq_canonicalize = chrp_irq_canonicalize;
 	ppc_md.init_IRQ       = chrp_init_IRQ;
 	ppc_md.get_irq        = openpic_get_irq;
 
diff -Nru a/arch/ppc/platforms/ev64260_setup.c b/arch/ppc/platforms/ev64260_setup.c
--- a/arch/ppc/platforms/ev64260_setup.c	Wed Apr 30 22:28:06 2003
+++ b/arch/ppc/platforms/ev64260_setup.c	Wed Apr 30 22:28:06 2003
@@ -25,7 +25,7 @@
 #include <linux/pci.h>
 #include <linux/kdev_t.h>
 #include <linux/major.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/irq.h>
@@ -437,7 +437,7 @@
 
 	ppc_md.setup_arch = ev64260_setup_arch;
 	ppc_md.show_cpuinfo = ev64260_show_cpuinfo;
-	ppc_md.irq_cannonicalize = NULL;
+	ppc_md.irq_canonicalize = NULL;
 	ppc_md.init_IRQ = ev64260_init_irq;
 	ppc_md.get_irq = gt64260_get_irq;
 	ppc_md.init = NULL;
diff -Nru a/arch/ppc/platforms/gemini_setup.c b/arch/ppc/platforms/gemini_setup.c
--- a/arch/ppc/platforms/gemini_setup.c	Wed Apr 30 22:28:09 2003
+++ b/arch/ppc/platforms/gemini_setup.c	Wed Apr 30 22:28:09 2003
@@ -19,7 +19,7 @@
 #include <linux/kdev_t.h>
 #include <linux/types.h>
 #include <linux/major.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/irq.h>
 #include <linux/seq_file.h>
@@ -559,7 +559,7 @@
 
 	ppc_md.setup_arch = gemini_setup_arch;
 	ppc_md.show_cpuinfo = gemini_show_cpuinfo;
-	ppc_md.irq_cannonicalize = NULL;
+	ppc_md.irq_canonicalize = NULL;
 	ppc_md.init_IRQ = gemini_init_IRQ;
 	ppc_md.get_irq = openpic_get_irq;
 	ppc_md.init = NULL;
diff -Nru a/arch/ppc/platforms/k2_setup.c b/arch/ppc/platforms/k2_setup.c
--- a/arch/ppc/platforms/k2_setup.c	Wed Apr 30 22:28:11 2003
+++ b/arch/ppc/platforms/k2_setup.c	Wed Apr 30 22:28:11 2003
@@ -21,7 +21,7 @@
 #include <linux/kdev_t.h>
 #include <linux/types.h>
 #include <linux/major.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/ide.h>
diff -Nru a/arch/ppc/platforms/lopec_setup.c b/arch/ppc/platforms/lopec_setup.c
--- a/arch/ppc/platforms/lopec_setup.c	Wed Apr 30 22:28:10 2003
+++ b/arch/ppc/platforms/lopec_setup.c	Wed Apr 30 22:28:10 2003
@@ -20,7 +20,7 @@
 #include <linux/init.h>
 #include <linux/ide.h>
 #include <linux/seq_file.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/root_dev.h>
 
@@ -67,7 +67,7 @@
 }
 
 static u32
-lopec_irq_cannonicalize(u32 irq)
+lopec_irq_canonicalize(u32 irq)
 {
 	if (irq == 2)
 		return 9;
@@ -360,7 +360,7 @@
 
 	ppc_md.setup_arch = lopec_setup_arch;
 	ppc_md.show_cpuinfo = lopec_show_cpuinfo;
-	ppc_md.irq_cannonicalize = lopec_irq_cannonicalize;
+	ppc_md.irq_canonicalize = lopec_irq_canonicalize;
 	ppc_md.init_IRQ = lopec_init_IRQ;
 	ppc_md.get_irq = openpic_get_irq;
 
diff -Nru a/arch/ppc/platforms/mcpn765_setup.c b/arch/ppc/platforms/mcpn765_setup.c
--- a/arch/ppc/platforms/mcpn765_setup.c	Wed Apr 30 22:28:12 2003
+++ b/arch/ppc/platforms/mcpn765_setup.c	Wed Apr 30 22:28:12 2003
@@ -24,7 +24,7 @@
 #include <linux/pci.h>
 #include <linux/kdev_t.h>
 #include <linux/major.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/irq.h>
@@ -201,7 +201,7 @@
 }
 
 static u32
-mcpn765_irq_cannonicalize(u32 irq)
+mcpn765_irq_canonicalize(u32 irq)
 {
 	if (irq == 2)
 		return 9;
@@ -434,7 +434,7 @@
 
 	ppc_md.setup_arch = mcpn765_setup_arch;
 	ppc_md.show_cpuinfo = mcpn765_show_cpuinfo;
-	ppc_md.irq_cannonicalize = mcpn765_irq_cannonicalize;
+	ppc_md.irq_canonicalize = mcpn765_irq_canonicalize;
 	ppc_md.init_IRQ = mcpn765_init_IRQ;
 	ppc_md.get_irq = openpic_get_irq;
 	ppc_md.init = mcpn765_init2;
diff -Nru a/arch/ppc/platforms/menf1_setup.c b/arch/ppc/platforms/menf1_setup.c
--- a/arch/ppc/platforms/menf1_setup.c	Wed Apr 30 22:28:16 2003
+++ b/arch/ppc/platforms/menf1_setup.c	Wed Apr 30 22:28:16 2003
@@ -21,7 +21,7 @@
 #include <linux/kdev_t.h>
 #include <linux/types.h>
 #include <linux/major.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/ide.h>
diff -Nru a/arch/ppc/platforms/mvme5100_setup.c b/arch/ppc/platforms/mvme5100_setup.c
--- a/arch/ppc/platforms/mvme5100_setup.c	Wed Apr 30 22:28:07 2003
+++ b/arch/ppc/platforms/mvme5100_setup.c	Wed Apr 30 22:28:07 2003
@@ -20,7 +20,7 @@
 #include <linux/pci.h>
 #include <linux/kdev_t.h>
 #include <linux/major.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/irq.h>
diff -Nru a/arch/ppc/platforms/pal4_setup.c b/arch/ppc/platforms/pal4_setup.c
--- a/arch/ppc/platforms/pal4_setup.c	Wed Apr 30 22:28:17 2003
+++ b/arch/ppc/platforms/pal4_setup.c	Wed Apr 30 22:28:17 2003
@@ -20,7 +20,7 @@
 #include <linux/time.h>
 #include <linux/irq.h>
 #include <linux/kdev_t.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
diff -Nru a/arch/ppc/platforms/pcore_setup.c b/arch/ppc/platforms/pcore_setup.c
--- a/arch/ppc/platforms/pcore_setup.c	Wed Apr 30 22:28:03 2003
+++ b/arch/ppc/platforms/pcore_setup.c	Wed Apr 30 22:28:03 2003
@@ -21,7 +21,7 @@
 #include <linux/kdev_t.h>
 #include <linux/types.h>
 #include <linux/major.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/irq.h>
diff -Nru a/arch/ppc/platforms/pmac_cpufreq.c b/arch/ppc/platforms/pmac_cpufreq.c
--- a/arch/ppc/platforms/pmac_cpufreq.c	Wed Apr 30 22:28:10 2003
+++ b/arch/ppc/platforms/pmac_cpufreq.c	Wed Apr 30 22:28:10 2003
@@ -262,13 +262,19 @@
 		goto out;
 	cur_freq = (*value) / 1000;
 
-	/* Check for tibook 800Mhz or 1Ghz */
-	if (machine_is_compatible("PowerBook3,4") || machine_is_compatible("PowerBook3,5")) {
+	/* Check for newer machines */
+	if (machine_is_compatible("PowerBook3,4") ||
+	    machine_is_compatible("PowerBook3,5") ||
+	    machine_is_compatible("MacRISC3")) {
 		value = (u32 *)get_property(cpunode, "min-clock-frequency", NULL);
 		if (!value)
 			goto out;
 		low_freq = (*value) / 1000;
-
+		/* The PowerBook G4 12" (PowerBook6,1) has an error in the device-tree
+		 * here */
+		if (low_freq < 100000)
+			low_freq *= 10;
+		
 		value = (u32 *)get_property(cpunode, "max-clock-frequency", NULL);
 		if (!value)
 			goto out;
diff -Nru a/arch/ppc/platforms/pmac_feature.c b/arch/ppc/platforms/pmac_feature.c
--- a/arch/ppc/platforms/pmac_feature.c	Wed Apr 30 22:28:17 2003
+++ b/arch/ppc/platforms/pmac_feature.c	Wed Apr 30 22:28:17 2003
@@ -52,8 +52,8 @@
 #endif
 
 /* Exported from arch/ppc/kernel/idle.c */
-extern int powersave_nap;
 extern int powersave_lowspeed;
+extern int powersave_nap;
 
 /*
  * We use a single global lock to protect accesses. Each driver has
@@ -1894,10 +1894,22 @@
 		PMAC_TYPE_RACKMAC,		rackmac_features,
 		0,
 	},
+	{	"RackMac1,2",			"XServe rev. 2",
+		PMAC_TYPE_RACKMAC,		rackmac_features,
+		0,
+	},
 	{	"PowerMac3,6",			"PowerMac G4 Windtunnel",
 		PMAC_TYPE_WINDTUNNEL,		rackmac_features,
 		0,
 	},
+	{	"PowerBook5,1",			"PowerBook G4 17\"",
+		PMAC_TYPE_UNKNOWN_INTREPID,	intrepid_features,
+		PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
+	},
+	{	"PowerBook6,1",			"PowerBook G4 12\"",
+		PMAC_TYPE_UNKNOWN_INTREPID,	intrepid_features,
+		PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
+	},
 };
 
 /*
@@ -1994,8 +2006,8 @@
 	    	pmac_mb.features = pangea_features;
 		break;
 	    case macio_intrepid:
-		pmac_mb.model_id = PMAC_TYPE_UNKNOWN_PANGEA;
-		pmac_mb.model_name = "Unknown Pangea-based";
+		pmac_mb.model_id = PMAC_TYPE_UNKNOWN_INTREPID;
+		pmac_mb.model_name = "Unknown Intrepid-based";
 	    	pmac_mb.features = intrepid_features;
 	    	break;
 	    default:
diff -Nru a/arch/ppc/platforms/pmac_pic.c b/arch/ppc/platforms/pmac_pic.c
--- a/arch/ppc/platforms/pmac_pic.c	Wed Apr 30 22:28:16 2003
+++ b/arch/ppc/platforms/pmac_pic.c	Wed Apr 30 22:28:16 2003
@@ -30,9 +30,17 @@
 #include <asm/pci-bridge.h>
 #include <asm/time.h>
 #include <asm/open_pic.h>
+#include <asm/xmon.h>
 
 #include "pmac_pic.h"
 
+/*
+ * XXX this should be in xmon.h, but putting it there means xmon.h
+ * has to include <linux/interrupt.h> (to get irqreturn_t), which
+ * causes all sorts of problems.  -- paulus
+ */ 
+extern irqreturn_t xmon_irq(int, void *, struct pt_regs *);
+
 struct pmac_irq_hw {
         unsigned int    event;
         unsigned int    enable;
@@ -177,7 +185,7 @@
 	NULL
 };
 
-static void gatwick_action(int cpl, void *dev_id, struct pt_regs *regs)
+static irqreturn_t gatwick_action(int cpl, void *dev_id, struct pt_regs *regs)
 {
 	int irq, bits;
 	
@@ -190,16 +198,11 @@
 		if (bits == 0)
 			continue;
 		irq += __ilog2(bits);
-		break;
+		ppc_irq_dispatch_handler(regs, irq);
+		return IRQ_HANDLED;
 	}
-	/* The previous version of this code allowed for this case, we
-	 * don't.  Put this here to check for it.
-	 * -- Cort
-	 */
-	if ( irq_desc[irq].handler != &gatwick_pic )
-		printk("gatwick irq not from gatwick pic\n");
-	else
-		ppc_irq_dispatch_handler( regs, irq );
+	printk("gatwick irq not from gatwick pic\n");
+	return IRQ_NONE;
 }
 
 int
@@ -393,7 +396,7 @@
 					nmi_irq = pswitch->intrs[0].line;
 					openpic_init_nmi_irq(nmi_irq);
 					request_irq(nmi_irq, xmon_irq, 0,
-							"NMI - XMON", 0);
+						    "NMI - XMON", 0);
 				}
 			}
 #endif	/* CONFIG_XMON */
diff -Nru a/arch/ppc/platforms/pmac_setup.c b/arch/ppc/platforms/pmac_setup.c
--- a/arch/ppc/platforms/pmac_setup.c	Wed Apr 30 22:28:11 2003
+++ b/arch/ppc/platforms/pmac_setup.c	Wed Apr 30 22:28:11 2003
@@ -40,7 +40,7 @@
 #include <linux/delay.h>
 #include <linux/ioport.h>
 #include <linux/major.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/vt_kern.h>
 #include <linux/console.h>
 #include <linux/ide.h>
@@ -364,7 +364,7 @@
 void *boot_host;
 int boot_target;
 int boot_part;
-extern kdev_t boot_dev;
+extern dev_t boot_dev;
 
 #ifdef CONFIG_SCSI
 void __init
@@ -398,18 +398,18 @@
 #endif
 
 #if defined(CONFIG_BLK_DEV_IDE) && defined(CONFIG_BLK_DEV_IDE_PMAC)
-kdev_t __init
+dev_t __init
 find_ide_boot(void)
 {
 	char *p;
 	int n;
-	kdev_t __init pmac_find_ide_boot(char *bootdevice, int n);
+	dev_t __init pmac_find_ide_boot(char *bootdevice, int n);
 
 	if (bootdevice == NULL)
-		return NODEV;
+		return 0;
 	p = strrchr(bootdevice, '/');
 	if (p == NULL)
-		return NODEV;
+		return 0;
 	n = p - bootdevice;
 
 	return pmac_find_ide_boot(bootdevice, n);
@@ -436,7 +436,7 @@
 
 /* can't be __init - can be called whenever a disk is first accessed */
 void __pmac
-note_bootable_part(kdev_t dev, int part, int goodness)
+note_bootable_part(dev_t dev, int part, int goodness)
 {
 	static int found_boot = 0;
 	char *p;
@@ -454,9 +454,9 @@
 		find_boot_device();
 		found_boot = 1;
 	}
-	if (kdev_same(boot_dev, NODEV) || kdev_same(dev, boot_dev)) {
-		ROOT_DEV = MKDEV(major(dev), minor(dev) + part);
-		boot_dev = NODEV;
+	if (!boot_dev || dev == boot_dev) {
+		ROOT_DEV = dev + part;
+		boot_dev = 0;
 		current_root_goodness = goodness;
 	}
 }
@@ -619,7 +619,7 @@
 	ppc_md.setup_arch     = pmac_setup_arch;
 	ppc_md.show_cpuinfo   = pmac_show_cpuinfo;
 	ppc_md.show_percpuinfo = pmac_show_percpuinfo;
-	ppc_md.irq_cannonicalize = NULL;
+	ppc_md.irq_canonicalize = NULL;
 	ppc_md.init_IRQ       = pmac_pic_init;
 	ppc_md.get_irq        = pmac_get_irq; /* Changed later on ... */
 	
diff -Nru a/arch/ppc/platforms/pmac_sleep.S b/arch/ppc/platforms/pmac_sleep.S
--- a/arch/ppc/platforms/pmac_sleep.S	Wed Apr 30 22:28:04 2003
+++ b/arch/ppc/platforms/pmac_sleep.S	Wed Apr 30 22:28:04 2003
@@ -15,6 +15,7 @@
 #include <asm/page.h>
 #include <asm/ppc_asm.h>
 #include <asm/cputable.h>
+#include <asm/cache.h>
 #include <asm/thread_info.h>
 #include <asm/offsets.h>
 
@@ -157,33 +158,22 @@
 	addi r3,r3,sleep_storage@l
 	stw r5,0(r3)
 
-BEGIN_FTR_SECTION
-	DSSALL
+	/* Disable DPM during cache flush */
+	mfspr	r3, SPRN_HID0
+	rlwinm	r3,r3,0,12,10
 	sync
-END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
-
-/*
- * Flush the L1 data cache by reading the first 128kB of RAM
- * and then flushing the same area with the dcbf instruction.
- * The L2 cache has already been disabled.
- */
-	li	r4,0x1000	/* 128kB / 32B */
-	mtctr	r4
-	lis	r4,KERNELBASE@h
-1:
-	lwz	r0,0(r4)
-	addi	r4,r4,0x0020	/* Go to start of next cache line */
-	bdnz	1b
+	mtspr	SPRN_HID0,r3
 	sync
 	
-	li	r4,0x1000	/* 128kB / 32B */
-	mtctr	r4
-	lis	r4,KERNELBASE@h
-1:
-	dcbf	r0,r4
-	addi	r4,r4,0x0020	/* Go to start of next cache line */
-	bdnz	1b
+	/* Turn off data relocation. */
+	mfmsr	r3		/* Save MSR in r7 */
+	rlwinm	r3,r3,0,28,26	/* Turn off DR bit */
 	sync
+	mtmsr	r3
+	isync
+
+	/* Flush & disable L1 cache */
+	bl	__flush_disable_L1
 
 /*
  * Set the HID0 and MSR for sleep.
@@ -192,6 +182,7 @@
 	rlwinm	r2,r2,0,10,7	/* clear doze, nap */
 	oris	r2,r2,HID0_SLEEP@h
 	sync
+	isync
 	mtspr	HID0,r2
 	sync
 
@@ -252,16 +243,11 @@
  */
 	
 grackle_wake_up:
-	/* Enable and then Flash inval the instruction & data cache */
-	mfspr	r3,HID0
-	ori	r3,r3, HID0_ICE|HID0_ICFI|HID0_DCE|HID0_DCI
-	sync
-	isync
-	mtspr	HID0,r3
-	xori	r3,r3, HID0_ICFI|HID0_DCI
-	mtspr	HID0,r3
-	sync
-	
+	/* Invalidate & enable L1 cache, we don't care about
+	 * whatever the ROM may have tried to write to memory
+	 */
+	bl	__inval_enable_L1
+
 	/* Restore the kernel's segment registers before
 	 * we do any r1 memory access as we are not sure they
 	 * are in a sane state above the first 256Mb region
@@ -274,6 +260,8 @@
 	addi	r3,r3,0x111	/* increment VSID */
 	addis	r4,r4,0x1000	/* address of next segment */
 	bdnz	3b
+	sync
+	isync
 	
 	subi	r1,r1,SL_PC
 
@@ -325,6 +313,26 @@
 	lwz	r4,SL_IBAT3+4(r1)
 	mtibatl	3,r4
 
+BEGIN_FTR_SECTION
+	li	r4,0
+	mtspr	SPRN_DBAT4U,r4
+	mtspr	SPRN_DBAT4L,r4
+	mtspr	SPRN_DBAT5U,r4
+	mtspr	SPRN_DBAT5L,r4
+	mtspr	SPRN_DBAT6U,r4
+	mtspr	SPRN_DBAT6L,r4
+	mtspr	SPRN_DBAT7U,r4
+	mtspr	SPRN_DBAT7L,r4
+	mtspr	SPRN_IBAT4U,r4
+	mtspr	SPRN_IBAT4L,r4
+	mtspr	SPRN_IBAT5U,r4
+	mtspr	SPRN_IBAT5L,r4
+	mtspr	SPRN_IBAT6U,r4
+	mtspr	SPRN_IBAT6L,r4
+	mtspr	SPRN_IBAT7U,r4
+	mtspr	SPRN_IBAT7L,r4
+END_FTR_SECTION_IFSET(CPU_FTR_HAS_HIGH_BATS)
+
 	/* Flush all TLBs */
 	lis	r4,0x1000
 1:	addic.	r4,r4,-0x1000
@@ -368,8 +376,9 @@
 
 #endif /* defined(CONFIG_PMAC_PBOOK) || defined(CONFIG_CPU_FREQ) */
 
-
-	.data
-	.globl sleep_storage
+	.section .data
+	.balign	L1_CACHE_LINE_SIZE
 sleep_storage:
 	.long 0
+	.balign	L1_CACHE_LINE_SIZE, 0
+	.section .text
diff -Nru a/arch/ppc/platforms/pmac_smp.c b/arch/ppc/platforms/pmac_smp.c
--- a/arch/ppc/platforms/pmac_smp.c	Wed Apr 30 22:28:09 2003
+++ b/arch/ppc/platforms/pmac_smp.c	Wed Apr 30 22:28:09 2003
@@ -3,6 +3,12 @@
  *
  * We support both the old "powersurge" SMP architecture
  * and the current Core99 (G4 PowerMac) machines.
+ * 
+ * Note that we don't support the very first rev. of
+ * Apple/DayStar 2 CPUs board, the one with the funky
+ * watchdog. Hopefully, none of these should be there except
+ * maybe internally to Apple. I should probably still add some
+ * code to detect this card though and disable SMP. --BenH.
  *
  * Support Macintosh G4 SMP by Troy Benjegerdes (hozer@drgw.net)
  * and Ben Herrenschmidt <benh@kernel.crashing.org>.
@@ -92,25 +98,22 @@
 static volatile u8 *psurge_sec_intr;
 static volatile u32 *psurge_start;
 
-/* what sort of powersurge board we have */
-static int psurge_type;
-
 /* values for psurge_type */
+#define PSURGE_NONE		-1
 #define PSURGE_DUAL		0
 #define PSURGE_QUAD_OKEE	1
 #define PSURGE_QUAD_COTTON	2
 #define PSURGE_QUAD_ICEGRASS	3
 
+/* what sort of powersurge board we have */
+static int psurge_type = PSURGE_NONE;
+
 volatile static long int core99_l2_cache;
 volatile static long int core99_l3_cache;
 
 static void __init
 core99_init_caches(int cpu)
 {
-	/* Check cache presence on cpu 0, we assume all CPUs have
-	 * same features here. We also assume that if we don't have
-	 * L2CR, we don't have L3CR neither
-	 */
 	if (!(cur_cpu_spec[0]->cpu_features & CPU_FTR_L2CR))
 		return;
 
@@ -143,6 +146,8 @@
  */
 static inline void psurge_set_ipi(int cpu)
 {
+	if (psurge_type == PSURGE_NONE)
+		return;
 	if (cpu == 0)
 		in_be32(psurge_pri_intr);
 	else if (psurge_type == PSURGE_DUAL)
@@ -154,10 +159,14 @@
 static inline void psurge_clr_ipi(int cpu)
 {
 	if (cpu > 0) {
-		if (psurge_type == PSURGE_DUAL)
+		switch(psurge_type) {
+		case PSURGE_DUAL:
 			out_8(psurge_sec_intr, ~0);
-		else
+		case PSURGE_NONE:
+			break;
+		default:
 			PSURGE_QUAD_OUT(PSURGE_QUAD_IRQ_CLR, 1 << cpu);
+		}
 	}
 }
 
@@ -189,10 +198,11 @@
 			smp_message_recv(msg, regs);
 }
 
-void __pmac
+irqreturn_t __pmac
 psurge_primary_intr(int irq, void *d, struct pt_regs *regs)
 {
 	psurge_smp_message_recv(regs);
+	return IRQ_HANDLED;
 }
 
 static void __pmac
@@ -311,6 +321,7 @@
 		if ((in_8(hhead_base + HHEAD_CONFIG) & 0x02) == 0) {
 			/* not a dual-cpu card */
 			iounmap((void *) hhead_base);
+			psurge_type = PSURGE_NONE;
 			return 1;
 		}
 		ncpus = 2;
diff -Nru a/arch/ppc/platforms/powerpmc250.c b/arch/ppc/platforms/powerpmc250.c
--- a/arch/ppc/platforms/powerpmc250.c	Wed Apr 30 22:28:05 2003
+++ b/arch/ppc/platforms/powerpmc250.c	Wed Apr 30 22:28:05 2003
@@ -23,7 +23,7 @@
 #include <linux/kdev_t.h>
 #include <linux/types.h>
 #include <linux/major.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/irq.h>
diff -Nru a/arch/ppc/platforms/pplus_setup.c b/arch/ppc/platforms/pplus_setup.c
--- a/arch/ppc/platforms/pplus_setup.c	Wed Apr 30 22:28:18 2003
+++ b/arch/ppc/platforms/pplus_setup.c	Wed Apr 30 22:28:18 2003
@@ -33,7 +33,7 @@
 #include <linux/interrupt.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/ioport.h>
 #include <linux/console.h>
 #include <linux/timex.h>
@@ -206,7 +206,7 @@
 }
 
 static unsigned int
-pplus_irq_cannonicalize(u_int irq)
+pplus_irq_canonicalize(u_int irq)
 {
 	if (irq == 2)
 	{
@@ -469,7 +469,7 @@
 	ppc_md.setup_arch     = pplus_setup_arch;
 	ppc_md.show_percpuinfo = NULL;
 	ppc_md.show_cpuinfo    = pplus_show_cpuinfo;
-	ppc_md.irq_cannonicalize = pplus_irq_cannonicalize;
+	ppc_md.irq_canonicalize = pplus_irq_canonicalize;
 	ppc_md.init_IRQ       = pplus_init_IRQ;
 	/* this gets changed later on if we have an OpenPIC -- Cort */
 	ppc_md.get_irq        = i8259_irq;
diff -Nru a/arch/ppc/platforms/prep_setup.c b/arch/ppc/platforms/prep_setup.c
--- a/arch/ppc/platforms/prep_setup.c	Wed Apr 30 22:28:16 2003
+++ b/arch/ppc/platforms/prep_setup.c	Wed Apr 30 22:28:16 2003
@@ -31,7 +31,7 @@
 #include <linux/interrupt.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/ioport.h>
 #include <linux/console.h>
 #include <linux/timex.h>
@@ -91,7 +91,7 @@
 #define cached_A1	(((char *)(ppc_cached_irq_mask))[2])
 
 /* for the mac fs */
-kdev_t boot_dev;
+dev_t boot_dev;
 
 #ifdef CONFIG_SOUND_CS4232 
 long ppc_cs4232_dma, ppc_cs4232_dma2;
@@ -850,7 +850,7 @@
 static volatile int calibrate_steps __initdata = 3;
 static unsigned tbstamp __initdata = 0;
 
-static void __init
+static irqreturn_t __init
 prep_calibrate_decr_handler(int irq, void *dev, struct pt_regs *regs)
 {
 	unsigned long t, freq;
@@ -866,6 +866,7 @@
 		tb_ticks_per_jiffy = freq / HZ;
 		tb_to_us = mulhwu_scale_factor(freq, 1000000);
 	}
+	return IRQ_HANDLED;
 }
 
 static void __init
@@ -976,7 +977,7 @@
 }
 
 static unsigned int __prep
-prep_irq_cannonicalize(u_int irq)
+prep_irq_canonicalize(u_int irq)
 {
 	if (irq == 2)
 	{
@@ -1150,7 +1151,7 @@
 	ppc_md.setup_arch     = prep_setup_arch;
 	ppc_md.show_percpuinfo = prep_show_percpuinfo;
 	ppc_md.show_cpuinfo   = NULL; /* set in prep_setup_arch() */
-	ppc_md.irq_cannonicalize = prep_irq_cannonicalize;
+	ppc_md.irq_canonicalize = prep_irq_canonicalize;
 	ppc_md.init_IRQ       = prep_init_IRQ;
 	/* this gets changed later on if we have an OpenPIC -- Cort */
 	ppc_md.get_irq        = i8259_irq;
diff -Nru a/arch/ppc/platforms/prpmc750_setup.c b/arch/ppc/platforms/prpmc750_setup.c
--- a/arch/ppc/platforms/prpmc750_setup.c	Wed Apr 30 22:28:07 2003
+++ b/arch/ppc/platforms/prpmc750_setup.c	Wed Apr 30 22:28:07 2003
@@ -21,7 +21,7 @@
 #include <linux/kdev_t.h>
 #include <linux/types.h>
 #include <linux/major.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/irq.h>
diff -Nru a/arch/ppc/platforms/prpmc800_setup.c b/arch/ppc/platforms/prpmc800_setup.c
--- a/arch/ppc/platforms/prpmc800_setup.c	Wed Apr 30 22:28:10 2003
+++ b/arch/ppc/platforms/prpmc800_setup.c	Wed Apr 30 22:28:10 2003
@@ -18,7 +18,7 @@
 #include <linux/kdev_t.h>
 #include <linux/types.h>
 #include <linux/major.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/irq.h>
diff -Nru a/arch/ppc/platforms/sandpoint_setup.c b/arch/ppc/platforms/sandpoint_setup.c
--- a/arch/ppc/platforms/sandpoint_setup.c	Wed Apr 30 22:28:19 2003
+++ b/arch/ppc/platforms/sandpoint_setup.c	Wed Apr 30 22:28:19 2003
@@ -64,7 +64,7 @@
 #include <linux/pci.h>
 #include <linux/kdev_t.h>
 #include <linux/major.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/irq.h>
@@ -349,7 +349,7 @@
 }
 
 static u32
-sandpoint_irq_cannonicalize(u32 irq)
+sandpoint_irq_canonicalize(u32 irq)
 {
 	if (irq == 2)
 	{
@@ -602,7 +602,7 @@
 
 	ppc_md.setup_arch = sandpoint_setup_arch;
 	ppc_md.show_cpuinfo = sandpoint_show_cpuinfo;
-	ppc_md.irq_cannonicalize = sandpoint_irq_cannonicalize;
+	ppc_md.irq_canonicalize = sandpoint_irq_canonicalize;
 	ppc_md.init_IRQ = sandpoint_init_IRQ;
 	ppc_md.get_irq = sandpoint_get_irq;
 	ppc_md.init = sandpoint_init2;
diff -Nru a/arch/ppc/platforms/spruce_setup.c b/arch/ppc/platforms/spruce_setup.c
--- a/arch/ppc/platforms/spruce_setup.c	Wed Apr 30 22:28:04 2003
+++ b/arch/ppc/platforms/spruce_setup.c	Wed Apr 30 22:28:04 2003
@@ -22,7 +22,7 @@
 #include <linux/kdev_t.h>
 #include <linux/types.h>
 #include <linux/major.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/seq_file.h>
diff -Nru a/arch/ppc/platforms/zx4500_setup.c b/arch/ppc/platforms/zx4500_setup.c
--- a/arch/ppc/platforms/zx4500_setup.c	Wed Apr 30 22:28:03 2003
+++ b/arch/ppc/platforms/zx4500_setup.c	Wed Apr 30 22:28:03 2003
@@ -35,7 +35,7 @@
 #include <linux/kdev_t.h>
 #include <linux/types.h>
 #include <linux/major.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/irq.h>
@@ -331,7 +331,7 @@
 
 	ppc_md.setup_arch = zx4500_setup_arch;
 	ppc_md.show_cpuinfo = zx4500_show_cpuinfo;
-	ppc_md.irq_cannonicalize = NULL;
+	ppc_md.irq_canonicalize = NULL;
 	ppc_md.init_IRQ = zx4500_init_IRQ;
 	ppc_md.get_irq = openpic_get_irq;
 	ppc_md.init = NULL;
diff -Nru a/arch/ppc/syslib/m8260_setup.c b/arch/ppc/syslib/m8260_setup.c
--- a/arch/ppc/syslib/m8260_setup.c	Wed Apr 30 22:28:09 2003
+++ b/arch/ppc/syslib/m8260_setup.c	Wed Apr 30 22:28:09 2003
@@ -28,7 +28,7 @@
 #include <linux/interrupt.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/ioport.h>
 #include <linux/ide.h>
 #include <linux/seq_file.h>
@@ -243,7 +243,7 @@
 
 	ppc_md.setup_arch		= m8260_setup_arch;
 	ppc_md.show_percpuinfo		= m8260_show_percpuinfo;
-	ppc_md.irq_cannonicalize	= NULL;
+	ppc_md.irq_canonicalize	= NULL;
 	ppc_md.init_IRQ			= m8260_init_IRQ;
 	ppc_md.get_irq			= m8260_get_irq;
 	ppc_md.init			= NULL;
diff -Nru a/arch/ppc/syslib/m8xx_setup.c b/arch/ppc/syslib/m8xx_setup.c
--- a/arch/ppc/syslib/m8xx_setup.c	Wed Apr 30 22:28:08 2003
+++ b/arch/ppc/syslib/m8xx_setup.c	Wed Apr 30 22:28:08 2003
@@ -28,7 +28,7 @@
 #include <linux/interrupt.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/ioport.h>
 #include <linux/bootmem.h>
 #include <linux/seq_file.h>
@@ -44,6 +44,7 @@
 #include <asm/machdep.h>
 #include <asm/bootinfo.h>
 #include <asm/time.h>
+#include <asm/xmon.h>
 
 #include "ppc8xx_pic.h"
 
@@ -377,7 +378,7 @@
 
 	ppc_md.setup_arch		= m8xx_setup_arch;
 	ppc_md.show_percpuinfo		= m8xx_show_percpuinfo;
-	ppc_md.irq_cannonicalize	= NULL;
+	ppc_md.irq_canonicalize	= NULL;
 	ppc_md.init_IRQ			= m8xx_init_IRQ;
 	ppc_md.get_irq			= m8xx_get_irq;
 	ppc_md.init			= NULL;
diff -Nru a/arch/ppc/syslib/open_pic.c b/arch/ppc/syslib/open_pic.c
--- a/arch/ppc/syslib/open_pic.c	Wed Apr 30 22:28:10 2003
+++ b/arch/ppc/syslib/open_pic.c	Wed Apr 30 22:28:10 2003
@@ -821,9 +821,10 @@
 {
 }
 
-static void openpic_ipi_action(int cpl, void *dev_id, struct pt_regs *regs)
+static irqreturn_t openpic_ipi_action(int cpl, void *dev_id, struct pt_regs *regs)
 {
 	smp_message_recv(cpl-OPENPIC_VEC_IPI-open_pic_irq_offset, regs);
+	return IRQ_HANDLED;
 }
 
 #endif /* CONFIG_SMP */
diff -Nru a/arch/ppc/syslib/ppc4xx_setup.c b/arch/ppc/syslib/ppc4xx_setup.c
--- a/arch/ppc/syslib/ppc4xx_setup.c	Wed Apr 30 22:28:03 2003
+++ b/arch/ppc/syslib/ppc4xx_setup.c	Wed Apr 30 22:28:03 2003
@@ -22,7 +22,7 @@
 #include <linux/reboot.h>
 #include <linux/param.h>
 #include <linux/string.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/pci.h>
 #include <linux/rtc.h>
 #include <linux/console.h>
diff -Nru a/arch/ppc/syslib/ppc8xx_pic.c b/arch/ppc/syslib/ppc8xx_pic.c
--- a/arch/ppc/syslib/ppc8xx_pic.c	Wed Apr 30 22:28:07 2003
+++ b/arch/ppc/syslib/ppc8xx_pic.c	Wed Apr 30 22:28:07 2003
@@ -168,7 +168,8 @@
  * drivers that may mess up the internal interrupt controllers, and also
  * allow them to run without modification on the MBX.
  */
-int request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
+int request_irq(unsigned int irq,
+	irqreturn_t (*handler)(int, void *, struct pt_regs *),
 	unsigned long irqflags, const char * devname, void *dev_id)
 {
 
diff -Nru a/arch/ppc/xmon/nonstdio.h b/arch/ppc/xmon/nonstdio.h
--- a/arch/ppc/xmon/nonstdio.h	Wed Apr 30 22:28:10 2003
+++ b/arch/ppc/xmon/nonstdio.h	Wed Apr 30 22:28:10 2003
@@ -15,7 +15,6 @@
 #define fflush(f)	do {} while (0)
 #define fclose(f)	do {} while (0)
 extern char *fgets(char *, int, void *);
-extern void xmon_printf(const char *, ...);
 extern void xmon_fprintf(void *, const char *, ...);
 extern void xmon_sprintf(char *, const char *, ...);
 extern void xmon_puts(char*);
diff -Nru a/arch/ppc/xmon/start.c b/arch/ppc/xmon/start.c
--- a/arch/ppc/xmon/start.c	Wed Apr 30 22:28:03 2003
+++ b/arch/ppc/xmon/start.c	Wed Apr 30 22:28:03 2003
@@ -26,7 +26,6 @@
 
 static volatile unsigned char *sccc, *sccd;
 unsigned int TXRDY, RXRDY, DLAB;
-extern void xmon_printf(const char *fmt, ...);
 static int xmon_expect(const char *str, unsigned int timeout);
 
 static int use_serial;
diff -Nru a/arch/ppc/xmon/xmon.c b/arch/ppc/xmon/xmon.c
--- a/arch/ppc/xmon/xmon.c	Wed Apr 30 22:28:03 2003
+++ b/arch/ppc/xmon/xmon.c	Wed Apr 30 22:28:03 2003
@@ -7,12 +7,14 @@
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <linux/smp.h>
+#include <linux/interrupt.h>
 #include <asm/ptrace.h>
 #include <asm/string.h>
 #include <asm/prom.h>
 #include <asm/bitops.h>
 #include <asm/bootx.h>
 #include <asm/machdep.h>
+#include <asm/xmon.h>
 #ifdef CONFIG_PMAC_BACKLIGHT
 #include <asm/backlight.h>
 #endif
@@ -103,7 +105,12 @@
 #endif /* CONFIG_SMP */
 static int pretty_print_addr(unsigned long addr);
 static void csum(void);
+#ifdef CONFIG_BOOTX_TEXT
+static void vidcmds(void);
+#endif
 static void bootcmds(void);
+static void proccall(void);
+static void printtime(void);
 
 extern int print_insn_big_powerpc(FILE *, unsigned long, unsigned);
 extern void printf(const char *fmt, ...);
@@ -116,6 +123,9 @@
 extern char* xmon_find_symbol(unsigned long addr, unsigned long* saddr);
 extern unsigned long xmon_symbol_to_addr(char* symbol);
 
+static unsigned start_tb[NR_CPUS][2];
+static unsigned stop_tb[NR_CPUS][2];
+
 #define GETWORD(v)	(((v)[0] << 24) + ((v)[1] << 16) + ((v)[2] << 8) + (v)[3])
 
 #define isxdigit(c)	(('0' <= (c) && (c) <= '9') \
@@ -165,6 +175,20 @@
 				     "r" (loops) : "ctr");
 }
 
+static void get_tb(unsigned *p)
+{
+	unsigned hi, lo, hiagain;
+
+	if ((get_pvr() >> 16) == 1)
+		return;
+
+	do {
+		asm volatile("mftbu %0; mftb %1; mftbu %2"
+			     : "=r" (hi), "=r" (lo), "=r" (hiagain));
+	} while (hi != hiagain);
+	p[0] = hi;
+	p[1] = lo;
+}
 
 void
 xmon(struct pt_regs *excp)
@@ -172,6 +196,7 @@
 	struct pt_regs regs;
 	int msr, cmd;
 
+	get_tb(stop_tb[smp_processor_id()]);
 	if (excp == NULL) {
 		asm volatile ("stw	0,0(%0)\n\
 			lwz	0,0(1)\n\
@@ -234,17 +259,18 @@
 	clear_bit(smp_processor_id(), &cpus_in_xmon);
 #endif /* CONFIG_SMP */
 	set_msr(msr);		/* restore interrupt enable */
+	get_tb(start_tb[smp_processor_id()]);
 }
 
-void
+irqreturn_t
 xmon_irq(int irq, void *d, struct pt_regs *regs)
 {
 	unsigned long flags;
-	local_save_flags(flags);
-	local_irq_disable();
+	local_irq_save(flags);
 	printf("Keyboard interrupt\n");
 	xmon(regs);
 	local_irq_restore(flags);
+	return IRQ_HANDLED;
 }
 
 int
@@ -481,13 +507,39 @@
 			cpu_cmd();
 			break;
 #endif /* CONFIG_SMP */
+#ifdef CONFIG_BOOTX_TEXT
+		case 'v':
+			vidcmds();
+			break;
+#endif
 		case 'z':
 			bootcmds();
 			break;
+		case 'p':
+			proccall();
+			break;
+		case 'T':
+			printtime();
+			break;
 		}
 	}
 }
 
+extern unsigned tb_to_us;
+
+#define mulhwu(x,y) \
+({unsigned z; asm ("mulhwu %0,%1,%2" : "=r" (z) : "r" (x), "r" (y)); z;})
+
+static void printtime(void)
+{
+	unsigned int delta;
+
+	delta = stop_tb[smp_processor_id()][1]
+		- start_tb[smp_processor_id()][1];
+	delta = mulhwu(tb_to_us, delta);
+	printf("%u.%06u seconds\n", delta / 1000000, delta % 1000000);
+}
+
 static void bootcmds(void)
 {
 	int cmd;
@@ -551,6 +603,44 @@
 }
 #endif /* CONFIG_SMP */
 
+#ifdef CONFIG_BOOTX_TEXT
+extern boot_infos_t disp_bi;
+
+static void vidcmds(void)
+{
+	int c = inchar();
+	unsigned int val, w;
+	extern int boot_text_mapped;
+
+	if (!boot_text_mapped)
+		return;
+	if (c != '\n' && scanhex(&val)) {
+		switch (c) {
+		case 'd':
+			w = disp_bi.dispDeviceRowBytes
+				/ (disp_bi.dispDeviceDepth >> 3);
+			disp_bi.dispDeviceDepth = val;
+			disp_bi.dispDeviceRowBytes = w * (val >> 3);
+			return;
+		case 'p':
+			disp_bi.dispDeviceRowBytes = val;
+			return;
+		case 'w':
+			disp_bi.dispDeviceRect[2] = val;
+			return;
+		case 'h':
+			disp_bi.dispDeviceRect[3] = val;
+			return;
+		}
+	}
+	printf("W = %d (0x%x) H = %d (0x%x) D = %d (0x%x) P = %d (0x%x)\n",
+	       disp_bi.dispDeviceRect[2], disp_bi.dispDeviceRect[2],
+	       disp_bi.dispDeviceRect[3], disp_bi.dispDeviceRect[3],
+	       disp_bi.dispDeviceDepth, disp_bi.dispDeviceDepth,
+	       disp_bi.dispDeviceRowBytes, disp_bi.dispDeviceRowBytes);
+}
+#endif /* CONFIG_BOOTX_TEXT */
+
 static unsigned short fcstab[256] = {
 	0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
 	0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
@@ -927,34 +1017,6 @@
 	scannl();
 }
 
-#if 0
-static void
-openforth()
-{
-    int c;
-    char *p;
-    char cmd[1024];
-    int args[5];
-    extern int (*prom_entry)(int *);
-
-    p = cmd;
-    c = skipbl();
-    while (c != '\n') {
-	*p++ = c;
-	c = inchar();
-    }
-    *p = 0;
-    args[0] = (int) "interpret";
-    args[1] = 1;
-    args[2] = 1;
-    args[3] = (int) cmd;
-    (*prom_entry)(args);
-    printf("\n");
-    if (args[4] != 0)
-	printf("error %x\n", args[4]);
-}
-#endif
-
 #ifndef CONFIG_PPC_STD_MMU
 static void
 dump_hash_table()
@@ -1176,11 +1238,13 @@
 }
 
 static int fault_type;
+static int fault_except;
 static char *fault_chars[] = { "--", "**", "##" };
 
 static void
 handle_fault(struct pt_regs *regs)
 {
+	fault_except = TRAP(regs);
 	fault_type = TRAP(regs) == 0x200? 0: TRAP(regs) == 0x300? 1: 2;
 	longjmp(bus_error_jmp, 1);
 }
@@ -1576,6 +1640,41 @@
 	}
 	if (ook)
 		printf("%.8x\n", a - mskip);
+}
+
+void proccall(void)
+{
+	unsigned int args[8];
+	unsigned int ret;
+	int i;
+	typedef unsigned int (*callfunc_t)(unsigned int, unsigned int,
+			unsigned int, unsigned int, unsigned int,
+			unsigned int, unsigned int, unsigned int);
+	callfunc_t func;
+
+	scanhex(&adrs);
+	if (termch != '\n')
+		termch = 0;
+	for (i = 0; i < 8; ++i)
+		args[i] = 0;
+	for (i = 0; i < 8; ++i) {
+		if (!scanhex(&args[i]) || termch == '\n')
+			break;
+		termch = 0;
+	}
+	func = (callfunc_t) adrs;
+	ret = 0;
+	if (setjmp(bus_error_jmp) == 0) {
+		debugger_fault_handler = handle_fault;
+		sync();
+		ret = func(args[0], args[1], args[2], args[3],
+			   args[4], args[5], args[6], args[7]);
+		sync();
+		printf("return value is %x\n", ret);
+	} else {
+		printf("*** %x exception occurred\n", fault_except);
+	}
+	debugger_fault_handler = 0;
 }
 
 /* Input scanning routines */
diff -Nru a/arch/ppc64/Kconfig b/arch/ppc64/Kconfig
--- a/arch/ppc64/Kconfig	Wed Apr 30 22:28:10 2003
+++ b/arch/ppc64/Kconfig	Wed Apr 30 22:28:10 2003
@@ -195,7 +195,7 @@
 	  programs that need an interpreter to run like Java, Python or
 	  Emacs-Lisp.  It's also useful if you often run DOS executables under
 	  the Linux DOS emulator DOSEMU (read the DOSEMU-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>).  Once you have
+	  <http://www.tldp.org/docs.html#howto>).  Once you have
 	  registered such a binary class with the kernel, you can start one of
 	  those programs simply by typing in its name at a shell prompt; Linux
 	  will automatically feed it to the correct interpreter.
@@ -387,7 +387,7 @@
 	  interrupt and DMA channel), because you will be asked for it.
 
 	  You want to read the Sound-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. General information about
+	  <http://www.tldp.org/docs.html#howto>. General information about
 	  the modular sound system is contained in the files
 	  <file:Documentation/sound/Introduction>.  The file
 	  <file:Documentation/sound/README.OSS> contains some slightly
diff -Nru a/arch/ppc64/kernel/chrp_setup.c b/arch/ppc64/kernel/chrp_setup.c
--- a/arch/ppc64/kernel/chrp_setup.c	Wed Apr 30 22:28:04 2003
+++ b/arch/ppc64/kernel/chrp_setup.c	Wed Apr 30 22:28:04 2003
@@ -31,7 +31,7 @@
 #include <linux/interrupt.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/ioport.h>
 #include <linux/console.h>
 #include <linux/pci.h>
@@ -79,7 +79,7 @@
 extern void SystemReset_FWNMI(void), MachineCheck_FWNMI(void);	/* from head.S */
 int fwnmi_active;  /* TRUE if an FWNMI handler is present */
 
-kdev_t boot_dev;
+dev_t boot_dev;
 unsigned long  virtPython0Facilities = 0;  // python0 facility area (memory mapped io) (64-bit format) VIRTUAL address.
 
 extern unsigned long loops_per_jiffy;
diff -Nru a/arch/ppc64/kernel/iSeries_setup.c b/arch/ppc64/kernel/iSeries_setup.c
--- a/arch/ppc64/kernel/iSeries_setup.c	Wed Apr 30 22:28:13 2003
+++ b/arch/ppc64/kernel/iSeries_setup.c	Wed Apr 30 22:28:13 2003
@@ -23,7 +23,7 @@
 #include <linux/param.h>
 #include <linux/string.h>
 #include <linux/bootmem.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
 
diff -Nru a/arch/ppc64/kernel/ioctl32.c b/arch/ppc64/kernel/ioctl32.c
--- a/arch/ppc64/kernel/ioctl32.c	Wed Apr 30 22:28:20 2003
+++ b/arch/ppc64/kernel/ioctl32.c	Wed Apr 30 22:28:20 2003
@@ -1799,7 +1799,7 @@
 	if (tty_paranoia_check(tty, inode->i_rdev, "tty_ioctl"))
 		return -EINVAL;
 	                                                
-	if (tty->driver.ioctl != vt_ioctl)
+	if (tty->driver->ioctl != vt_ioctl)
 		return -EINVAL;
 	
 	/*
@@ -3649,9 +3649,9 @@
 	unsigned long next;
 };
 
-#define COMPATIBLE_IOCTL(cmd) { cmd, (unsigned long)sys_ioctl, 0 }
+#define COMPATIBLE_IOCTL(cmd) { cmd, (unsigned long)sys_ioctl, 0 },
 
-#define HANDLE_IOCTL(cmd,handler) { cmd, (unsigned long)handler, 0 }
+#define HANDLE_IOCTL(cmd,handler) { cmd, (unsigned long)handler, 0 },
 
 #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
 #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
@@ -3661,942 +3661,816 @@
      * all others default to calling sys_ioctl().
      */
 /* Big T */
-COMPATIBLE_IOCTL(TCGETA),
-COMPATIBLE_IOCTL(TCSETA),
-COMPATIBLE_IOCTL(TCSETAW),
-COMPATIBLE_IOCTL(TCSETAF),
-COMPATIBLE_IOCTL(TCSBRK),
-COMPATIBLE_IOCTL(TCSBRKP),
-COMPATIBLE_IOCTL(TCXONC),
-COMPATIBLE_IOCTL(TCFLSH),
-COMPATIBLE_IOCTL(TCGETS),
-COMPATIBLE_IOCTL(TCSETS),
-COMPATIBLE_IOCTL(TCSETSW),
-COMPATIBLE_IOCTL(TCSETSF),
-COMPATIBLE_IOCTL(TIOCLINUX),
-COMPATIBLE_IOCTL(TIOCSTART),
-COMPATIBLE_IOCTL(TIOCSTOP),
+COMPATIBLE_IOCTL(TCGETA)
+COMPATIBLE_IOCTL(TCSETA)
+COMPATIBLE_IOCTL(TCSETAW)
+COMPATIBLE_IOCTL(TCSETAF)
+COMPATIBLE_IOCTL(TCSBRK)
+COMPATIBLE_IOCTL(TCSBRKP)
+COMPATIBLE_IOCTL(TCXONC)
+COMPATIBLE_IOCTL(TCFLSH)
+COMPATIBLE_IOCTL(TCGETS)
+COMPATIBLE_IOCTL(TCSETS)
+COMPATIBLE_IOCTL(TCSETSW)
+COMPATIBLE_IOCTL(TCSETSF)
+COMPATIBLE_IOCTL(TIOCLINUX)
+COMPATIBLE_IOCTL(TIOCSTART)
+COMPATIBLE_IOCTL(TIOCSTOP)
 /* Little t */
-COMPATIBLE_IOCTL(TIOCGETD),
-COMPATIBLE_IOCTL(TIOCSETD),
-COMPATIBLE_IOCTL(TIOCEXCL),
-COMPATIBLE_IOCTL(TIOCNXCL),
-COMPATIBLE_IOCTL(TIOCCONS),
-COMPATIBLE_IOCTL(TIOCGSOFTCAR),
-COMPATIBLE_IOCTL(TIOCSSOFTCAR),
-COMPATIBLE_IOCTL(TIOCSWINSZ),
-COMPATIBLE_IOCTL(TIOCGWINSZ),
-COMPATIBLE_IOCTL(TIOCMGET),
-COMPATIBLE_IOCTL(TIOCMBIC),
-COMPATIBLE_IOCTL(TIOCMBIS),
-COMPATIBLE_IOCTL(TIOCMSET),
-COMPATIBLE_IOCTL(TIOCPKT),
-COMPATIBLE_IOCTL(TIOCNOTTY),
-COMPATIBLE_IOCTL(TIOCSTI),
-COMPATIBLE_IOCTL(TIOCOUTQ),
-COMPATIBLE_IOCTL(TIOCSPGRP),
-COMPATIBLE_IOCTL(TIOCGPGRP),
-COMPATIBLE_IOCTL(TIOCSCTTY),
-COMPATIBLE_IOCTL(TIOCGPTN),
-COMPATIBLE_IOCTL(TIOCSPTLCK),
-COMPATIBLE_IOCTL(TIOCGSERIAL),
-COMPATIBLE_IOCTL(TIOCSSERIAL),
-COMPATIBLE_IOCTL(TIOCSERGETLSR),
-COMPATIBLE_IOCTL(TIOCSLTC),
+COMPATIBLE_IOCTL(TIOCGETD)
+COMPATIBLE_IOCTL(TIOCSETD)
+COMPATIBLE_IOCTL(TIOCEXCL)
+COMPATIBLE_IOCTL(TIOCNXCL)
+COMPATIBLE_IOCTL(TIOCCONS)
+COMPATIBLE_IOCTL(TIOCGSOFTCAR)
+COMPATIBLE_IOCTL(TIOCSSOFTCAR)
+COMPATIBLE_IOCTL(TIOCSWINSZ)
+COMPATIBLE_IOCTL(TIOCGWINSZ)
+COMPATIBLE_IOCTL(TIOCMGET)
+COMPATIBLE_IOCTL(TIOCMBIC)
+COMPATIBLE_IOCTL(TIOCMBIS)
+COMPATIBLE_IOCTL(TIOCMSET)
+COMPATIBLE_IOCTL(TIOCPKT)
+COMPATIBLE_IOCTL(TIOCNOTTY)
+COMPATIBLE_IOCTL(TIOCSTI)
+COMPATIBLE_IOCTL(TIOCOUTQ)
+COMPATIBLE_IOCTL(TIOCSPGRP)
+COMPATIBLE_IOCTL(TIOCGPGRP)
+COMPATIBLE_IOCTL(TIOCSCTTY)
+COMPATIBLE_IOCTL(TIOCGPTN)
+COMPATIBLE_IOCTL(TIOCSPTLCK)
+COMPATIBLE_IOCTL(TIOCGSERIAL)
+COMPATIBLE_IOCTL(TIOCSSERIAL)
+COMPATIBLE_IOCTL(TIOCSERGETLSR)
+COMPATIBLE_IOCTL(TIOCSLTC)
 /* Big F */
-COMPATIBLE_IOCTL(FBIOGET_VSCREENINFO),
-COMPATIBLE_IOCTL(FBIOPUT_VSCREENINFO),
-COMPATIBLE_IOCTL(FBIOPAN_DISPLAY),
-COMPATIBLE_IOCTL(FBIOGET_CON2FBMAP),
-COMPATIBLE_IOCTL(FBIOPUT_CON2FBMAP),
+COMPATIBLE_IOCTL(FBIOGET_VSCREENINFO)
+COMPATIBLE_IOCTL(FBIOPUT_VSCREENINFO)
+COMPATIBLE_IOCTL(FBIOPAN_DISPLAY)
+COMPATIBLE_IOCTL(FBIOGET_CON2FBMAP)
+COMPATIBLE_IOCTL(FBIOPUT_CON2FBMAP)
 #if 0
-COMPATIBLE_IOCTL(FBIOBLANK),
+COMPATIBLE_IOCTL(FBIOBLANK)
 #endif
 /* Little f */
-COMPATIBLE_IOCTL(FIOCLEX),
-COMPATIBLE_IOCTL(FIONCLEX),
-COMPATIBLE_IOCTL(FIOASYNC),
-COMPATIBLE_IOCTL(FIONBIO),
-COMPATIBLE_IOCTL(FIONREAD),  /* This is also TIOCINQ */
+COMPATIBLE_IOCTL(FIOCLEX)
+COMPATIBLE_IOCTL(FIONCLEX)
+COMPATIBLE_IOCTL(FIOASYNC)
+COMPATIBLE_IOCTL(FIONBIO)
+COMPATIBLE_IOCTL(FIONREAD)  /* This is also TIOCINQ */
 /* 0x00 */
-COMPATIBLE_IOCTL(FIBMAP),
-COMPATIBLE_IOCTL(FIGETBSZ),
+COMPATIBLE_IOCTL(FIBMAP)
+COMPATIBLE_IOCTL(FIGETBSZ)
 /* 0x03 -- HD/IDE ioctl's used by hdparm and friends.
  *         Some need translations, these do not.
  */
-COMPATIBLE_IOCTL(HDIO_GET_IDENTITY),
-COMPATIBLE_IOCTL(HDIO_SET_DMA),
-COMPATIBLE_IOCTL(HDIO_SET_UNMASKINTR),
-COMPATIBLE_IOCTL(HDIO_SET_NOWERR),
-COMPATIBLE_IOCTL(HDIO_SET_32BIT),
-COMPATIBLE_IOCTL(HDIO_SET_MULTCOUNT),
-COMPATIBLE_IOCTL(HDIO_DRIVE_CMD),
-COMPATIBLE_IOCTL(HDIO_SET_PIO_MODE),
-COMPATIBLE_IOCTL(HDIO_SET_NICE),
+COMPATIBLE_IOCTL(HDIO_GET_IDENTITY)
+COMPATIBLE_IOCTL(HDIO_SET_DMA)
+COMPATIBLE_IOCTL(HDIO_SET_UNMASKINTR)
+COMPATIBLE_IOCTL(HDIO_SET_NOWERR)
+COMPATIBLE_IOCTL(HDIO_SET_32BIT)
+COMPATIBLE_IOCTL(HDIO_SET_MULTCOUNT)
+COMPATIBLE_IOCTL(HDIO_DRIVE_CMD)
+COMPATIBLE_IOCTL(HDIO_SET_PIO_MODE)
+COMPATIBLE_IOCTL(HDIO_SET_NICE)
 /* 0x02 -- Floppy ioctls */
-COMPATIBLE_IOCTL(FDMSGON),
-COMPATIBLE_IOCTL(FDMSGOFF),
-COMPATIBLE_IOCTL(FDSETEMSGTRESH),
-COMPATIBLE_IOCTL(FDFLUSH),
-COMPATIBLE_IOCTL(FDWERRORCLR),
-COMPATIBLE_IOCTL(FDSETMAXERRS),
-COMPATIBLE_IOCTL(FDGETMAXERRS),
-COMPATIBLE_IOCTL(FDGETDRVTYP),
-COMPATIBLE_IOCTL(FDEJECT),
-COMPATIBLE_IOCTL(FDCLRPRM),
-COMPATIBLE_IOCTL(FDFMTBEG),
-COMPATIBLE_IOCTL(FDFMTEND),
-COMPATIBLE_IOCTL(FDRESET),
-COMPATIBLE_IOCTL(FDTWADDLE),
-COMPATIBLE_IOCTL(FDFMTTRK),
-COMPATIBLE_IOCTL(FDRAWCMD),
+COMPATIBLE_IOCTL(FDMSGON)
+COMPATIBLE_IOCTL(FDMSGOFF)
+COMPATIBLE_IOCTL(FDSETEMSGTRESH)
+COMPATIBLE_IOCTL(FDFLUSH)
+COMPATIBLE_IOCTL(FDWERRORCLR)
+COMPATIBLE_IOCTL(FDSETMAXERRS)
+COMPATIBLE_IOCTL(FDGETMAXERRS)
+COMPATIBLE_IOCTL(FDGETDRVTYP)
+COMPATIBLE_IOCTL(FDEJECT)
+COMPATIBLE_IOCTL(FDCLRPRM)
+COMPATIBLE_IOCTL(FDFMTBEG)
+COMPATIBLE_IOCTL(FDFMTEND)
+COMPATIBLE_IOCTL(FDRESET)
+COMPATIBLE_IOCTL(FDTWADDLE)
+COMPATIBLE_IOCTL(FDFMTTRK)
+COMPATIBLE_IOCTL(FDRAWCMD)
 /* 0x12 */
-COMPATIBLE_IOCTL(BLKROSET),
-COMPATIBLE_IOCTL(BLKROGET),
-COMPATIBLE_IOCTL(BLKRRPART),
-COMPATIBLE_IOCTL(BLKFLSBUF),
-COMPATIBLE_IOCTL(BLKSECTSET),
-COMPATIBLE_IOCTL(BLKSSZGET),
-COMPATIBLE_IOCTL(BLKRASET),
-COMPATIBLE_IOCTL(BLKFRASET),
+COMPATIBLE_IOCTL(BLKROSET)
+COMPATIBLE_IOCTL(BLKROGET)
+COMPATIBLE_IOCTL(BLKRRPART)
+COMPATIBLE_IOCTL(BLKFLSBUF)
+COMPATIBLE_IOCTL(BLKSECTSET)
+COMPATIBLE_IOCTL(BLKSSZGET)
+COMPATIBLE_IOCTL(BLKRASET)
+COMPATIBLE_IOCTL(BLKFRASET)
 /* RAID */
-COMPATIBLE_IOCTL(RAID_VERSION),
-COMPATIBLE_IOCTL(GET_ARRAY_INFO),
-COMPATIBLE_IOCTL(GET_DISK_INFO),
-COMPATIBLE_IOCTL(PRINT_RAID_DEBUG),
-COMPATIBLE_IOCTL(CLEAR_ARRAY),
-COMPATIBLE_IOCTL(ADD_NEW_DISK),
-COMPATIBLE_IOCTL(HOT_REMOVE_DISK),
-COMPATIBLE_IOCTL(SET_ARRAY_INFO),
-COMPATIBLE_IOCTL(SET_DISK_INFO),
-COMPATIBLE_IOCTL(WRITE_RAID_INFO),
-COMPATIBLE_IOCTL(UNPROTECT_ARRAY),
-COMPATIBLE_IOCTL(PROTECT_ARRAY),
-COMPATIBLE_IOCTL(HOT_ADD_DISK),
-COMPATIBLE_IOCTL(SET_DISK_FAULTY),
-COMPATIBLE_IOCTL(RUN_ARRAY),
-COMPATIBLE_IOCTL(START_ARRAY),
-COMPATIBLE_IOCTL(STOP_ARRAY),
-COMPATIBLE_IOCTL(STOP_ARRAY_RO),
-COMPATIBLE_IOCTL(RESTART_ARRAY_RW),
+COMPATIBLE_IOCTL(RAID_VERSION)
+COMPATIBLE_IOCTL(GET_ARRAY_INFO)
+COMPATIBLE_IOCTL(GET_DISK_INFO)
+COMPATIBLE_IOCTL(PRINT_RAID_DEBUG)
+COMPATIBLE_IOCTL(CLEAR_ARRAY)
+COMPATIBLE_IOCTL(ADD_NEW_DISK)
+COMPATIBLE_IOCTL(HOT_REMOVE_DISK)
+COMPATIBLE_IOCTL(SET_ARRAY_INFO)
+COMPATIBLE_IOCTL(SET_DISK_INFO)
+COMPATIBLE_IOCTL(WRITE_RAID_INFO)
+COMPATIBLE_IOCTL(UNPROTECT_ARRAY)
+COMPATIBLE_IOCTL(PROTECT_ARRAY)
+COMPATIBLE_IOCTL(HOT_ADD_DISK)
+COMPATIBLE_IOCTL(SET_DISK_FAULTY)
+COMPATIBLE_IOCTL(RUN_ARRAY)
+COMPATIBLE_IOCTL(START_ARRAY)
+COMPATIBLE_IOCTL(STOP_ARRAY)
+COMPATIBLE_IOCTL(STOP_ARRAY_RO)
+COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
 /* Big K */
-COMPATIBLE_IOCTL(PIO_FONT),
-COMPATIBLE_IOCTL(GIO_FONT),
-COMPATIBLE_IOCTL(KDSIGACCEPT),
-COMPATIBLE_IOCTL(KDGETKEYCODE),
-COMPATIBLE_IOCTL(KDSETKEYCODE),
-COMPATIBLE_IOCTL(KIOCSOUND),
-COMPATIBLE_IOCTL(KDMKTONE),
-COMPATIBLE_IOCTL(KDGKBTYPE),
-COMPATIBLE_IOCTL(KDSETMODE),
-COMPATIBLE_IOCTL(KDGETMODE),
-COMPATIBLE_IOCTL(KDSKBMODE),
-COMPATIBLE_IOCTL(KDGKBMODE),
-COMPATIBLE_IOCTL(KDSKBMETA),
-COMPATIBLE_IOCTL(KDGKBMETA),
-COMPATIBLE_IOCTL(KDGKBENT),
-COMPATIBLE_IOCTL(KDSKBENT),
-COMPATIBLE_IOCTL(KDGKBSENT),
-COMPATIBLE_IOCTL(KDSKBSENT),
-COMPATIBLE_IOCTL(KDGKBDIACR),
-COMPATIBLE_IOCTL(KDKBDREP),
-COMPATIBLE_IOCTL(KDSKBDIACR),
-COMPATIBLE_IOCTL(KDGKBLED),
-COMPATIBLE_IOCTL(KDSKBLED),
-COMPATIBLE_IOCTL(KDGETLED),
-COMPATIBLE_IOCTL(KDSETLED),
-COMPATIBLE_IOCTL(GIO_SCRNMAP),
-COMPATIBLE_IOCTL(PIO_SCRNMAP),
-COMPATIBLE_IOCTL(GIO_UNISCRNMAP),
-COMPATIBLE_IOCTL(PIO_UNISCRNMAP),
-COMPATIBLE_IOCTL(PIO_FONTRESET),
-COMPATIBLE_IOCTL(PIO_UNIMAPCLR),
+COMPATIBLE_IOCTL(PIO_FONT)
+COMPATIBLE_IOCTL(GIO_FONT)
+COMPATIBLE_IOCTL(KDSIGACCEPT)
+COMPATIBLE_IOCTL(KDGETKEYCODE)
+COMPATIBLE_IOCTL(KDSETKEYCODE)
+COMPATIBLE_IOCTL(KIOCSOUND)
+COMPATIBLE_IOCTL(KDMKTONE)
+COMPATIBLE_IOCTL(KDGKBTYPE)
+COMPATIBLE_IOCTL(KDSETMODE)
+COMPATIBLE_IOCTL(KDGETMODE)
+COMPATIBLE_IOCTL(KDSKBMODE)
+COMPATIBLE_IOCTL(KDGKBMODE)
+COMPATIBLE_IOCTL(KDSKBMETA)
+COMPATIBLE_IOCTL(KDGKBMETA)
+COMPATIBLE_IOCTL(KDGKBENT)
+COMPATIBLE_IOCTL(KDSKBENT)
+COMPATIBLE_IOCTL(KDGKBSENT)
+COMPATIBLE_IOCTL(KDSKBSENT)
+COMPATIBLE_IOCTL(KDGKBDIACR)
+COMPATIBLE_IOCTL(KDKBDREP)
+COMPATIBLE_IOCTL(KDSKBDIACR)
+COMPATIBLE_IOCTL(KDGKBLED)
+COMPATIBLE_IOCTL(KDSKBLED)
+COMPATIBLE_IOCTL(KDGETLED)
+COMPATIBLE_IOCTL(KDSETLED)
+COMPATIBLE_IOCTL(GIO_SCRNMAP)
+COMPATIBLE_IOCTL(PIO_SCRNMAP)
+COMPATIBLE_IOCTL(GIO_UNISCRNMAP)
+COMPATIBLE_IOCTL(PIO_UNISCRNMAP)
+COMPATIBLE_IOCTL(PIO_FONTRESET)
+COMPATIBLE_IOCTL(PIO_UNIMAPCLR)
 /* Big S */
-COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN),
-COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST),
-COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI),
-COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK),
-COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK),
-COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY),
-COMPATIBLE_IOCTL(SCSI_IOCTL_TAGGED_ENABLE),
-COMPATIBLE_IOCTL(SCSI_IOCTL_TAGGED_DISABLE),
-COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER),
-COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND),
+COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
+COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST)
+COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI)
+COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK)
+COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK)
+COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY)
+COMPATIBLE_IOCTL(SCSI_IOCTL_TAGGED_ENABLE)
+COMPATIBLE_IOCTL(SCSI_IOCTL_TAGGED_DISABLE)
+COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER)
+COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND)
 /* Big T */
-COMPATIBLE_IOCTL(TUNSETNOCSUM),
-COMPATIBLE_IOCTL(TUNSETDEBUG),
-COMPATIBLE_IOCTL(TUNSETIFF),
-COMPATIBLE_IOCTL(TUNSETPERSIST),
-COMPATIBLE_IOCTL(TUNSETOWNER),
+COMPATIBLE_IOCTL(TUNSETNOCSUM)
+COMPATIBLE_IOCTL(TUNSETDEBUG)
+COMPATIBLE_IOCTL(TUNSETIFF)
+COMPATIBLE_IOCTL(TUNSETPERSIST)
+COMPATIBLE_IOCTL(TUNSETOWNER)
 /* Big V */
-COMPATIBLE_IOCTL(VT_SETMODE),
-COMPATIBLE_IOCTL(VT_GETMODE),
-COMPATIBLE_IOCTL(VT_GETSTATE),
-COMPATIBLE_IOCTL(VT_OPENQRY),
-COMPATIBLE_IOCTL(VT_ACTIVATE),
-COMPATIBLE_IOCTL(VT_WAITACTIVE),
-COMPATIBLE_IOCTL(VT_RELDISP),
-COMPATIBLE_IOCTL(VT_DISALLOCATE),
-COMPATIBLE_IOCTL(VT_RESIZE),
-COMPATIBLE_IOCTL(VT_RESIZEX),
-COMPATIBLE_IOCTL(VT_LOCKSWITCH),
-COMPATIBLE_IOCTL(VT_UNLOCKSWITCH),
+COMPATIBLE_IOCTL(VT_SETMODE)
+COMPATIBLE_IOCTL(VT_GETMODE)
+COMPATIBLE_IOCTL(VT_GETSTATE)
+COMPATIBLE_IOCTL(VT_OPENQRY)
+COMPATIBLE_IOCTL(VT_ACTIVATE)
+COMPATIBLE_IOCTL(VT_WAITACTIVE)
+COMPATIBLE_IOCTL(VT_RELDISP)
+COMPATIBLE_IOCTL(VT_DISALLOCATE)
+COMPATIBLE_IOCTL(VT_RESIZE)
+COMPATIBLE_IOCTL(VT_RESIZEX)
+COMPATIBLE_IOCTL(VT_LOCKSWITCH)
+COMPATIBLE_IOCTL(VT_UNLOCKSWITCH)
 /* Little v, the video4linux ioctls */
-COMPATIBLE_IOCTL(VIDIOCGCAP),
-COMPATIBLE_IOCTL(VIDIOCGCHAN),
-COMPATIBLE_IOCTL(VIDIOCSCHAN),
-COMPATIBLE_IOCTL(VIDIOCGPICT),
-COMPATIBLE_IOCTL(VIDIOCSPICT),
-COMPATIBLE_IOCTL(VIDIOCCAPTURE),
-COMPATIBLE_IOCTL(VIDIOCKEY),
-COMPATIBLE_IOCTL(VIDIOCGAUDIO),
-COMPATIBLE_IOCTL(VIDIOCSAUDIO),
-COMPATIBLE_IOCTL(VIDIOCSYNC),
-COMPATIBLE_IOCTL(VIDIOCMCAPTURE),
-COMPATIBLE_IOCTL(VIDIOCGMBUF),
-COMPATIBLE_IOCTL(VIDIOCGUNIT),
-COMPATIBLE_IOCTL(VIDIOCGCAPTURE),
-COMPATIBLE_IOCTL(VIDIOCSCAPTURE),
+COMPATIBLE_IOCTL(VIDIOCGCAP)
+COMPATIBLE_IOCTL(VIDIOCGCHAN)
+COMPATIBLE_IOCTL(VIDIOCSCHAN)
+COMPATIBLE_IOCTL(VIDIOCGPICT)
+COMPATIBLE_IOCTL(VIDIOCSPICT)
+COMPATIBLE_IOCTL(VIDIOCCAPTURE)
+COMPATIBLE_IOCTL(VIDIOCKEY)
+COMPATIBLE_IOCTL(VIDIOCGAUDIO)
+COMPATIBLE_IOCTL(VIDIOCSAUDIO)
+COMPATIBLE_IOCTL(VIDIOCSYNC)
+COMPATIBLE_IOCTL(VIDIOCMCAPTURE)
+COMPATIBLE_IOCTL(VIDIOCGMBUF)
+COMPATIBLE_IOCTL(VIDIOCGUNIT)
+COMPATIBLE_IOCTL(VIDIOCGCAPTURE)
+COMPATIBLE_IOCTL(VIDIOCSCAPTURE)
 /* BTTV specific... */
-COMPATIBLE_IOCTL(_IOW('v',  BASE_VIDIOCPRIVATE+0, char [256])),
-COMPATIBLE_IOCTL(_IOR('v',  BASE_VIDIOCPRIVATE+1, char [256])),
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int)),
-COMPATIBLE_IOCTL(_IOW('v' , BASE_VIDIOCPRIVATE+3, char [16])), /* struct bttv_pll_info */
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+4, int)),
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+5, int)),
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+6, int)),
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+7, int)),
+COMPATIBLE_IOCTL(_IOW('v',  BASE_VIDIOCPRIVATE+0, char [256]))
+COMPATIBLE_IOCTL(_IOR('v',  BASE_VIDIOCPRIVATE+1, char [256]))
+COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int))
+COMPATIBLE_IOCTL(_IOW('v' , BASE_VIDIOCPRIVATE+3, char [16])) /* struct bttv_pll_info */
+COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+4, int))
+COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+5, int))
+COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+6, int))
+COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+7, int))
 /* Little p (/dev/rtc, /dev/envctrl, etc.) */
-COMPATIBLE_IOCTL(_IOR('p', 20, int[7])), /* RTCGET */
-COMPATIBLE_IOCTL(_IOW('p', 21, int[7])), /* RTCSET */
-COMPATIBLE_IOCTL(RTC_AIE_ON),
-COMPATIBLE_IOCTL(RTC_AIE_OFF),
-COMPATIBLE_IOCTL(RTC_UIE_ON),
-COMPATIBLE_IOCTL(RTC_UIE_OFF),
-COMPATIBLE_IOCTL(RTC_PIE_ON),
-COMPATIBLE_IOCTL(RTC_PIE_OFF),
-COMPATIBLE_IOCTL(RTC_WIE_ON),
-COMPATIBLE_IOCTL(RTC_WIE_OFF),
-COMPATIBLE_IOCTL(RTC_ALM_SET),
-COMPATIBLE_IOCTL(RTC_ALM_READ),
-COMPATIBLE_IOCTL(RTC_RD_TIME),
-COMPATIBLE_IOCTL(RTC_SET_TIME),
-COMPATIBLE_IOCTL(RTC_WKALM_SET),
-COMPATIBLE_IOCTL(RTC_WKALM_RD),
+COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */
+COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */
+COMPATIBLE_IOCTL(RTC_AIE_ON)
+COMPATIBLE_IOCTL(RTC_AIE_OFF)
+COMPATIBLE_IOCTL(RTC_UIE_ON)
+COMPATIBLE_IOCTL(RTC_UIE_OFF)
+COMPATIBLE_IOCTL(RTC_PIE_ON)
+COMPATIBLE_IOCTL(RTC_PIE_OFF)
+COMPATIBLE_IOCTL(RTC_WIE_ON)
+COMPATIBLE_IOCTL(RTC_WIE_OFF)
+COMPATIBLE_IOCTL(RTC_ALM_SET)
+COMPATIBLE_IOCTL(RTC_ALM_READ)
+COMPATIBLE_IOCTL(RTC_RD_TIME)
+COMPATIBLE_IOCTL(RTC_SET_TIME)
+COMPATIBLE_IOCTL(RTC_WKALM_SET)
+COMPATIBLE_IOCTL(RTC_WKALM_RD)
 /* Little m */
-COMPATIBLE_IOCTL(MTIOCTOP),
+COMPATIBLE_IOCTL(MTIOCTOP)
 /* Socket level stuff */
-COMPATIBLE_IOCTL(FIOSETOWN),
-COMPATIBLE_IOCTL(SIOCSPGRP),
-COMPATIBLE_IOCTL(FIOGETOWN),
-COMPATIBLE_IOCTL(SIOCGPGRP),
-COMPATIBLE_IOCTL(SIOCATMARK),
-COMPATIBLE_IOCTL(SIOCSIFLINK),
-COMPATIBLE_IOCTL(SIOCSIFENCAP),
-COMPATIBLE_IOCTL(SIOCGIFENCAP),
-COMPATIBLE_IOCTL(SIOCSIFBR),
-COMPATIBLE_IOCTL(SIOCGIFBR),
-COMPATIBLE_IOCTL(SIOCSARP),
-COMPATIBLE_IOCTL(SIOCGARP),
-COMPATIBLE_IOCTL(SIOCDARP),
-COMPATIBLE_IOCTL(SIOCSRARP),
-COMPATIBLE_IOCTL(SIOCGRARP),
-COMPATIBLE_IOCTL(SIOCDRARP),
-COMPATIBLE_IOCTL(SIOCADDDLCI),
-COMPATIBLE_IOCTL(SIOCDELDLCI),
-COMPATIBLE_IOCTL(SIOCGMIIPHY),
-COMPATIBLE_IOCTL(SIOCGMIIREG),
-COMPATIBLE_IOCTL(SIOCSMIIREG),
-COMPATIBLE_IOCTL(SIOCGIFVLAN),
-COMPATIBLE_IOCTL(SIOCSIFVLAN),
+COMPATIBLE_IOCTL(FIOSETOWN)
+COMPATIBLE_IOCTL(SIOCSPGRP)
+COMPATIBLE_IOCTL(FIOGETOWN)
+COMPATIBLE_IOCTL(SIOCGPGRP)
+COMPATIBLE_IOCTL(SIOCATMARK)
+COMPATIBLE_IOCTL(SIOCSIFLINK)
+COMPATIBLE_IOCTL(SIOCSIFENCAP)
+COMPATIBLE_IOCTL(SIOCGIFENCAP)
+COMPATIBLE_IOCTL(SIOCSIFBR)
+COMPATIBLE_IOCTL(SIOCGIFBR)
+COMPATIBLE_IOCTL(SIOCSARP)
+COMPATIBLE_IOCTL(SIOCGARP)
+COMPATIBLE_IOCTL(SIOCDARP)
+COMPATIBLE_IOCTL(SIOCSRARP)
+COMPATIBLE_IOCTL(SIOCGRARP)
+COMPATIBLE_IOCTL(SIOCDRARP)
+COMPATIBLE_IOCTL(SIOCADDDLCI)
+COMPATIBLE_IOCTL(SIOCDELDLCI)
+COMPATIBLE_IOCTL(SIOCGMIIPHY)
+COMPATIBLE_IOCTL(SIOCGMIIREG)
+COMPATIBLE_IOCTL(SIOCSMIIREG)
+COMPATIBLE_IOCTL(SIOCGIFVLAN)
+COMPATIBLE_IOCTL(SIOCSIFVLAN)
 /* SG stuff */
-COMPATIBLE_IOCTL(SG_SET_TIMEOUT),
-COMPATIBLE_IOCTL(SG_GET_TIMEOUT),
-COMPATIBLE_IOCTL(SG_EMULATED_HOST),
-COMPATIBLE_IOCTL(SG_SET_TRANSFORM),
-COMPATIBLE_IOCTL(SG_GET_TRANSFORM),
-COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE),
-COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE),
-COMPATIBLE_IOCTL(SG_GET_SCSI_ID),
-COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA),
-COMPATIBLE_IOCTL(SG_GET_LOW_DMA),
-COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID),
-COMPATIBLE_IOCTL(SG_GET_PACK_ID),
-COMPATIBLE_IOCTL(SG_GET_NUM_WAITING),
-COMPATIBLE_IOCTL(SG_SET_DEBUG),
-COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE),
-COMPATIBLE_IOCTL(SG_GET_COMMAND_Q),
-COMPATIBLE_IOCTL(SG_SET_COMMAND_Q),
-COMPATIBLE_IOCTL(SG_GET_VERSION_NUM),
-COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN),
-COMPATIBLE_IOCTL(SG_SCSI_RESET),
-COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE),
-COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN),
-COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN),
+COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
+COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
+COMPATIBLE_IOCTL(SG_EMULATED_HOST)
+COMPATIBLE_IOCTL(SG_SET_TRANSFORM)
+COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
+COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
+COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
+COMPATIBLE_IOCTL(SG_GET_SCSI_ID)
+COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA)
+COMPATIBLE_IOCTL(SG_GET_LOW_DMA)
+COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID)
+COMPATIBLE_IOCTL(SG_GET_PACK_ID)
+COMPATIBLE_IOCTL(SG_GET_NUM_WAITING)
+COMPATIBLE_IOCTL(SG_SET_DEBUG)
+COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE)
+COMPATIBLE_IOCTL(SG_GET_COMMAND_Q)
+COMPATIBLE_IOCTL(SG_SET_COMMAND_Q)
+COMPATIBLE_IOCTL(SG_GET_VERSION_NUM)
+COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN)
+COMPATIBLE_IOCTL(SG_SCSI_RESET)
+COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE)
+COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
+COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
 /* PPP stuff */
-COMPATIBLE_IOCTL(PPPIOCGFLAGS),
-COMPATIBLE_IOCTL(PPPIOCSFLAGS),
-COMPATIBLE_IOCTL(PPPIOCGASYNCMAP),
-COMPATIBLE_IOCTL(PPPIOCSASYNCMAP),
-COMPATIBLE_IOCTL(PPPIOCGUNIT),
-COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP),
-COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP),
-COMPATIBLE_IOCTL(PPPIOCGMRU),
-COMPATIBLE_IOCTL(PPPIOCSMRU),
-COMPATIBLE_IOCTL(PPPIOCSMAXCID),
-COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP),
-COMPATIBLE_IOCTL(LPGETSTATUS),
-COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP),
-COMPATIBLE_IOCTL(PPPIOCXFERUNIT),
-COMPATIBLE_IOCTL(PPPIOCGNPMODE),
-COMPATIBLE_IOCTL(PPPIOCSNPMODE),
-COMPATIBLE_IOCTL(PPPIOCGDEBUG),
-COMPATIBLE_IOCTL(PPPIOCSDEBUG),
-COMPATIBLE_IOCTL(PPPIOCNEWUNIT),
-COMPATIBLE_IOCTL(PPPIOCATTACH),
-COMPATIBLE_IOCTL(PPPIOCDETACH),
-COMPATIBLE_IOCTL(PPPIOCSMRRU),
-COMPATIBLE_IOCTL(PPPIOCCONNECT),
-COMPATIBLE_IOCTL(PPPIOCDISCONN),
-COMPATIBLE_IOCTL(PPPIOCATTCHAN),
-COMPATIBLE_IOCTL(PPPIOCGCHAN),
+COMPATIBLE_IOCTL(PPPIOCGFLAGS)
+COMPATIBLE_IOCTL(PPPIOCSFLAGS)
+COMPATIBLE_IOCTL(PPPIOCGASYNCMAP)
+COMPATIBLE_IOCTL(PPPIOCSASYNCMAP)
+COMPATIBLE_IOCTL(PPPIOCGUNIT)
+COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP)
+COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP)
+COMPATIBLE_IOCTL(PPPIOCGMRU)
+COMPATIBLE_IOCTL(PPPIOCSMRU)
+COMPATIBLE_IOCTL(PPPIOCSMAXCID)
+COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP)
+COMPATIBLE_IOCTL(LPGETSTATUS)
+COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP)
+COMPATIBLE_IOCTL(PPPIOCXFERUNIT)
+COMPATIBLE_IOCTL(PPPIOCGNPMODE)
+COMPATIBLE_IOCTL(PPPIOCSNPMODE)
+COMPATIBLE_IOCTL(PPPIOCGDEBUG)
+COMPATIBLE_IOCTL(PPPIOCSDEBUG)
+COMPATIBLE_IOCTL(PPPIOCNEWUNIT)
+COMPATIBLE_IOCTL(PPPIOCATTACH)
+COMPATIBLE_IOCTL(PPPIOCDETACH)
+COMPATIBLE_IOCTL(PPPIOCSMRRU)
+COMPATIBLE_IOCTL(PPPIOCCONNECT)
+COMPATIBLE_IOCTL(PPPIOCDISCONN)
+COMPATIBLE_IOCTL(PPPIOCATTCHAN)
+COMPATIBLE_IOCTL(PPPIOCGCHAN)
 /* PPPOX */
-COMPATIBLE_IOCTL(PPPOEIOCSFWD),
-COMPATIBLE_IOCTL(PPPOEIOCDFWD),
+COMPATIBLE_IOCTL(PPPOEIOCSFWD)
+COMPATIBLE_IOCTL(PPPOEIOCDFWD)
 /* CDROM stuff */
-COMPATIBLE_IOCTL(CDROMPAUSE),
-COMPATIBLE_IOCTL(CDROMRESUME),
-COMPATIBLE_IOCTL(CDROMPLAYMSF),
-COMPATIBLE_IOCTL(CDROMPLAYTRKIND),
-COMPATIBLE_IOCTL(CDROMREADTOCHDR),
-COMPATIBLE_IOCTL(CDROMREADTOCENTRY),
-COMPATIBLE_IOCTL(CDROMSTOP),
-COMPATIBLE_IOCTL(CDROMSTART),
-COMPATIBLE_IOCTL(CDROMEJECT),
-COMPATIBLE_IOCTL(CDROMVOLCTRL),
-COMPATIBLE_IOCTL(CDROMSUBCHNL),
-COMPATIBLE_IOCTL(CDROMEJECT_SW),
-COMPATIBLE_IOCTL(CDROMMULTISESSION),
-COMPATIBLE_IOCTL(CDROM_GET_MCN),
-COMPATIBLE_IOCTL(CDROMRESET),
-COMPATIBLE_IOCTL(CDROMVOLREAD),
-COMPATIBLE_IOCTL(CDROMSEEK),
-COMPATIBLE_IOCTL(CDROMPLAYBLK),
-COMPATIBLE_IOCTL(CDROMCLOSETRAY),
-COMPATIBLE_IOCTL(CDROM_SET_OPTIONS),
-COMPATIBLE_IOCTL(CDROM_CLEAR_OPTIONS),
-COMPATIBLE_IOCTL(CDROM_SELECT_SPEED),
-COMPATIBLE_IOCTL(CDROM_SELECT_DISC),
-COMPATIBLE_IOCTL(CDROM_MEDIA_CHANGED),
-COMPATIBLE_IOCTL(CDROM_DRIVE_STATUS),
-COMPATIBLE_IOCTL(CDROM_DISC_STATUS),
-COMPATIBLE_IOCTL(CDROM_CHANGER_NSLOTS),
-COMPATIBLE_IOCTL(CDROM_LOCKDOOR),
-COMPATIBLE_IOCTL(CDROM_DEBUG),
-COMPATIBLE_IOCTL(CDROM_GET_CAPABILITY),
+COMPATIBLE_IOCTL(CDROMPAUSE)
+COMPATIBLE_IOCTL(CDROMRESUME)
+COMPATIBLE_IOCTL(CDROMPLAYMSF)
+COMPATIBLE_IOCTL(CDROMPLAYTRKIND)
+COMPATIBLE_IOCTL(CDROMREADTOCHDR)
+COMPATIBLE_IOCTL(CDROMREADTOCENTRY)
+COMPATIBLE_IOCTL(CDROMSTOP)
+COMPATIBLE_IOCTL(CDROMSTART)
+COMPATIBLE_IOCTL(CDROMEJECT)
+COMPATIBLE_IOCTL(CDROMVOLCTRL)
+COMPATIBLE_IOCTL(CDROMSUBCHNL)
+COMPATIBLE_IOCTL(CDROMEJECT_SW)
+COMPATIBLE_IOCTL(CDROMMULTISESSION)
+COMPATIBLE_IOCTL(CDROM_GET_MCN)
+COMPATIBLE_IOCTL(CDROMRESET)
+COMPATIBLE_IOCTL(CDROMVOLREAD)
+COMPATIBLE_IOCTL(CDROMSEEK)
+COMPATIBLE_IOCTL(CDROMPLAYBLK)
+COMPATIBLE_IOCTL(CDROMCLOSETRAY)
+COMPATIBLE_IOCTL(CDROM_SET_OPTIONS)
+COMPATIBLE_IOCTL(CDROM_CLEAR_OPTIONS)
+COMPATIBLE_IOCTL(CDROM_SELECT_SPEED)
+COMPATIBLE_IOCTL(CDROM_SELECT_DISC)
+COMPATIBLE_IOCTL(CDROM_MEDIA_CHANGED)
+COMPATIBLE_IOCTL(CDROM_DRIVE_STATUS)
+COMPATIBLE_IOCTL(CDROM_DISC_STATUS)
+COMPATIBLE_IOCTL(CDROM_CHANGER_NSLOTS)
+COMPATIBLE_IOCTL(CDROM_LOCKDOOR)
+COMPATIBLE_IOCTL(CDROM_DEBUG)
+COMPATIBLE_IOCTL(CDROM_GET_CAPABILITY)
 /* DVD ioctls */
-COMPATIBLE_IOCTL(DVD_READ_STRUCT),
-COMPATIBLE_IOCTL(DVD_WRITE_STRUCT),
-COMPATIBLE_IOCTL(DVD_AUTH),
+COMPATIBLE_IOCTL(DVD_READ_STRUCT)
+COMPATIBLE_IOCTL(DVD_WRITE_STRUCT)
+COMPATIBLE_IOCTL(DVD_AUTH)
 /* Big L */
-COMPATIBLE_IOCTL(LOOP_SET_FD),
-COMPATIBLE_IOCTL(LOOP_CLR_FD),
+COMPATIBLE_IOCTL(LOOP_SET_FD)
+COMPATIBLE_IOCTL(LOOP_CLR_FD)
 /* Big Q for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET),
-COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC),
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_INFO),
-COMPATIBLE_IOCTL(SNDCTL_SEQ_CTRLRATE),
-COMPATIBLE_IOCTL(SNDCTL_SEQ_GETOUTCOUNT),
-COMPATIBLE_IOCTL(SNDCTL_SEQ_GETINCOUNT),
-COMPATIBLE_IOCTL(SNDCTL_SEQ_PERCMODE),
-COMPATIBLE_IOCTL(SNDCTL_FM_LOAD_INSTR),
-COMPATIBLE_IOCTL(SNDCTL_SEQ_TESTMIDI),
-COMPATIBLE_IOCTL(SNDCTL_SEQ_RESETSAMPLES),
-COMPATIBLE_IOCTL(SNDCTL_SEQ_NRSYNTHS),
-COMPATIBLE_IOCTL(SNDCTL_SEQ_NRMIDIS),
-COMPATIBLE_IOCTL(SNDCTL_MIDI_INFO),
-COMPATIBLE_IOCTL(SNDCTL_SEQ_THRESHOLD),
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_MEMAVL),
-COMPATIBLE_IOCTL(SNDCTL_FM_4OP_ENABLE),
-COMPATIBLE_IOCTL(SNDCTL_SEQ_PANIC),
-COMPATIBLE_IOCTL(SNDCTL_SEQ_OUTOFBAND),
-COMPATIBLE_IOCTL(SNDCTL_SEQ_GETTIME),
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_ID),
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_CONTROL),
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_REMOVESAMPLE),
+COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC)
+COMPATIBLE_IOCTL(SNDCTL_SYNTH_INFO)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_CTRLRATE)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_GETOUTCOUNT)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_GETINCOUNT)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_PERCMODE)
+COMPATIBLE_IOCTL(SNDCTL_FM_LOAD_INSTR)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_TESTMIDI)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_RESETSAMPLES)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_NRSYNTHS)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_NRMIDIS)
+COMPATIBLE_IOCTL(SNDCTL_MIDI_INFO)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_THRESHOLD)
+COMPATIBLE_IOCTL(SNDCTL_SYNTH_MEMAVL)
+COMPATIBLE_IOCTL(SNDCTL_FM_4OP_ENABLE)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_PANIC)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_OUTOFBAND)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_GETTIME)
+COMPATIBLE_IOCTL(SNDCTL_SYNTH_ID)
+COMPATIBLE_IOCTL(SNDCTL_SYNTH_CONTROL)
+COMPATIBLE_IOCTL(SNDCTL_SYNTH_REMOVESAMPLE)
 /* Big T for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_TMR_TIMEBASE),
-COMPATIBLE_IOCTL(SNDCTL_TMR_START),
-COMPATIBLE_IOCTL(SNDCTL_TMR_STOP),
-COMPATIBLE_IOCTL(SNDCTL_TMR_CONTINUE),
-COMPATIBLE_IOCTL(SNDCTL_TMR_TEMPO),
-COMPATIBLE_IOCTL(SNDCTL_TMR_SOURCE),
-COMPATIBLE_IOCTL(SNDCTL_TMR_METRONOME),
-COMPATIBLE_IOCTL(SNDCTL_TMR_SELECT),
+COMPATIBLE_IOCTL(SNDCTL_TMR_TIMEBASE)
+COMPATIBLE_IOCTL(SNDCTL_TMR_START)
+COMPATIBLE_IOCTL(SNDCTL_TMR_STOP)
+COMPATIBLE_IOCTL(SNDCTL_TMR_CONTINUE)
+COMPATIBLE_IOCTL(SNDCTL_TMR_TEMPO)
+COMPATIBLE_IOCTL(SNDCTL_TMR_SOURCE)
+COMPATIBLE_IOCTL(SNDCTL_TMR_METRONOME)
+COMPATIBLE_IOCTL(SNDCTL_TMR_SELECT)
 /* Little m for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_MIDI_PRETIME),
-COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUMODE),
-COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUCMD),
+COMPATIBLE_IOCTL(SNDCTL_MIDI_PRETIME)
+COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUMODE)
+COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUCMD)
 /* Big P for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_DSP_RESET),
-COMPATIBLE_IOCTL(SNDCTL_DSP_SYNC),
-COMPATIBLE_IOCTL(SNDCTL_DSP_SPEED),
-COMPATIBLE_IOCTL(SNDCTL_DSP_STEREO),
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETBLKSIZE),
-COMPATIBLE_IOCTL(SNDCTL_DSP_CHANNELS),
-COMPATIBLE_IOCTL(SOUND_PCM_WRITE_FILTER),
-COMPATIBLE_IOCTL(SNDCTL_DSP_POST),
-COMPATIBLE_IOCTL(SNDCTL_DSP_SUBDIVIDE),
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETFRAGMENT),
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETFMTS),
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETFMT),
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETOSPACE),
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETISPACE),
-COMPATIBLE_IOCTL(SNDCTL_DSP_NONBLOCK),
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETCAPS),
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETTRIGGER),
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETTRIGGER),
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETIPTR),
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETOPTR),
+COMPATIBLE_IOCTL(SNDCTL_DSP_RESET)
+COMPATIBLE_IOCTL(SNDCTL_DSP_SYNC)
+COMPATIBLE_IOCTL(SNDCTL_DSP_SPEED)
+COMPATIBLE_IOCTL(SNDCTL_DSP_STEREO)
+COMPATIBLE_IOCTL(SNDCTL_DSP_GETBLKSIZE)
+COMPATIBLE_IOCTL(SNDCTL_DSP_CHANNELS)
+COMPATIBLE_IOCTL(SOUND_PCM_WRITE_FILTER)
+COMPATIBLE_IOCTL(SNDCTL_DSP_POST)
+COMPATIBLE_IOCTL(SNDCTL_DSP_SUBDIVIDE)
+COMPATIBLE_IOCTL(SNDCTL_DSP_SETFRAGMENT)
+COMPATIBLE_IOCTL(SNDCTL_DSP_GETFMTS)
+COMPATIBLE_IOCTL(SNDCTL_DSP_SETFMT)
+COMPATIBLE_IOCTL(SNDCTL_DSP_GETOSPACE)
+COMPATIBLE_IOCTL(SNDCTL_DSP_GETISPACE)
+COMPATIBLE_IOCTL(SNDCTL_DSP_NONBLOCK)
+COMPATIBLE_IOCTL(SNDCTL_DSP_GETCAPS)
+COMPATIBLE_IOCTL(SNDCTL_DSP_GETTRIGGER)
+COMPATIBLE_IOCTL(SNDCTL_DSP_SETTRIGGER)
+COMPATIBLE_IOCTL(SNDCTL_DSP_GETIPTR)
+COMPATIBLE_IOCTL(SNDCTL_DSP_GETOPTR)
 /* SNDCTL_DSP_MAPINBUF,  XXX needs translation */
 /* SNDCTL_DSP_MAPOUTBUF,  XXX needs translation */
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETSYNCRO),
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETDUPLEX),
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETODELAY),
-COMPATIBLE_IOCTL(SNDCTL_DSP_PROFILE),
-COMPATIBLE_IOCTL(SOUND_PCM_READ_RATE),
-COMPATIBLE_IOCTL(SOUND_PCM_READ_CHANNELS),
-COMPATIBLE_IOCTL(SOUND_PCM_READ_BITS),
-COMPATIBLE_IOCTL(SOUND_PCM_READ_FILTER),
+COMPATIBLE_IOCTL(SNDCTL_DSP_SETSYNCRO)
+COMPATIBLE_IOCTL(SNDCTL_DSP_SETDUPLEX)
+COMPATIBLE_IOCTL(SNDCTL_DSP_GETODELAY)
+COMPATIBLE_IOCTL(SNDCTL_DSP_PROFILE)
+COMPATIBLE_IOCTL(SOUND_PCM_READ_RATE)
+COMPATIBLE_IOCTL(SOUND_PCM_READ_CHANNELS)
+COMPATIBLE_IOCTL(SOUND_PCM_READ_BITS)
+COMPATIBLE_IOCTL(SOUND_PCM_READ_FILTER)
 /* Big C for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_COPR_RESET),
-COMPATIBLE_IOCTL(SNDCTL_COPR_LOAD),
-COMPATIBLE_IOCTL(SNDCTL_COPR_RDATA),
-COMPATIBLE_IOCTL(SNDCTL_COPR_RCODE),
-COMPATIBLE_IOCTL(SNDCTL_COPR_WDATA),
-COMPATIBLE_IOCTL(SNDCTL_COPR_WCODE),
-COMPATIBLE_IOCTL(SNDCTL_COPR_RUN),
-COMPATIBLE_IOCTL(SNDCTL_COPR_HALT),
-COMPATIBLE_IOCTL(SNDCTL_COPR_SENDMSG),
-COMPATIBLE_IOCTL(SNDCTL_COPR_RCVMSG),
+COMPATIBLE_IOCTL(SNDCTL_COPR_RESET)
+COMPATIBLE_IOCTL(SNDCTL_COPR_LOAD)
+COMPATIBLE_IOCTL(SNDCTL_COPR_RDATA)
+COMPATIBLE_IOCTL(SNDCTL_COPR_RCODE)
+COMPATIBLE_IOCTL(SNDCTL_COPR_WDATA)
+COMPATIBLE_IOCTL(SNDCTL_COPR_WCODE)
+COMPATIBLE_IOCTL(SNDCTL_COPR_RUN)
+COMPATIBLE_IOCTL(SNDCTL_COPR_HALT)
+COMPATIBLE_IOCTL(SNDCTL_COPR_SENDMSG)
+COMPATIBLE_IOCTL(SNDCTL_COPR_RCVMSG)
 /* Big M for sound/OSS */
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_VOLUME),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_BASS),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_TREBLE),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_SYNTH),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_PCM),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_SPEAKER),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_MIC),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_CD),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_IMIX),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_ALTPCM),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECLEV),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_IGAIN),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_OGAIN),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE1),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE2),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE3),
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL1)),
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL2)),
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL3)),
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEIN)),
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEOUT)),
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_VIDEO)),
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_RADIO)),
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_MONITOR)),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_MUTE),
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_VOLUME)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_BASS)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_TREBLE)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_SYNTH)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_PCM)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_SPEAKER)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_MIC)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_CD)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_IMIX)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_ALTPCM)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECLEV)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_IGAIN)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_OGAIN)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE1)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE2)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE3)
+COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL1))
+COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL2))
+COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL3))
+COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEIN))
+COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEOUT))
+COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_VIDEO))
+COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_RADIO))
+COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_MONITOR))
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_MUTE)
 /* SOUND_MIXER_READ_ENHANCE,  same value as READ_MUTE */
 /* SOUND_MIXER_READ_LOUD,  same value as READ_MUTE */
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECSRC),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_DEVMASK),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECMASK),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_STEREODEVS),
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_CAPS),
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_VOLUME),
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_BASS),
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_TREBLE),
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SYNTH),
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_PCM),
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SPEAKER),
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE),
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MIC),
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_CD),
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IMIX),
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_ALTPCM),
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECLEV),
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IGAIN),
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_OGAIN),
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE1),
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE2),
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE3),
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL1)),
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL2)),
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL3)),
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEIN)),
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEOUT)),
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_VIDEO)),
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_RADIO)),
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_MONITOR)),
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MUTE),
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECSRC)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_DEVMASK)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECMASK)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_STEREODEVS)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_CAPS)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_VOLUME)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_BASS)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_TREBLE)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SYNTH)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_PCM)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SPEAKER)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MIC)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_CD)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IMIX)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_ALTPCM)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECLEV)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IGAIN)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_OGAIN)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE1)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE2)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE3)
+COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL1))
+COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL2))
+COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL3))
+COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEIN))
+COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEOUT))
+COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_VIDEO))
+COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_RADIO))
+COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_MONITOR))
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MUTE)
 /* SOUND_MIXER_WRITE_ENHANCE,  same value as WRITE_MUTE */
 /* SOUND_MIXER_WRITE_LOUD,  same value as WRITE_MUTE */
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECSRC),
-COMPATIBLE_IOCTL(SOUND_MIXER_INFO),
-COMPATIBLE_IOCTL(SOUND_OLD_MIXER_INFO),
-COMPATIBLE_IOCTL(SOUND_MIXER_ACCESS),
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE1),
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE2),
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE3),
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE4),
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5),
-COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS),
-COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS),
-COMPATIBLE_IOCTL(OSS_GETVERSION),
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECSRC)
+COMPATIBLE_IOCTL(SOUND_MIXER_INFO)
+COMPATIBLE_IOCTL(SOUND_OLD_MIXER_INFO)
+COMPATIBLE_IOCTL(SOUND_MIXER_ACCESS)
+COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE1)
+COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE2)
+COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE3)
+COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE4)
+COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
+COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
+COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
+COMPATIBLE_IOCTL(OSS_GETVERSION)
 /* AUTOFS */
-COMPATIBLE_IOCTL(AUTOFS_IOC_READY),
-COMPATIBLE_IOCTL(AUTOFS_IOC_FAIL),
-COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC),
-COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER),
-COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE),
+COMPATIBLE_IOCTL(AUTOFS_IOC_READY)
+COMPATIBLE_IOCTL(AUTOFS_IOC_FAIL)
+COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC)
+COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER)
+COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE)
 /* DEVFS */
-COMPATIBLE_IOCTL(DEVFSDIOC_GET_PROTO_REV),
-COMPATIBLE_IOCTL(DEVFSDIOC_SET_EVENT_MASK),
-COMPATIBLE_IOCTL(DEVFSDIOC_RELEASE_EVENT_QUEUE),
-COMPATIBLE_IOCTL(DEVFSDIOC_SET_DEBUG_MASK),
+COMPATIBLE_IOCTL(DEVFSDIOC_GET_PROTO_REV)
+COMPATIBLE_IOCTL(DEVFSDIOC_SET_EVENT_MASK)
+COMPATIBLE_IOCTL(DEVFSDIOC_RELEASE_EVENT_QUEUE)
+COMPATIBLE_IOCTL(DEVFSDIOC_SET_DEBUG_MASK)
 /* Raw devices */
-COMPATIBLE_IOCTL(RAW_SETBIND),
-COMPATIBLE_IOCTL(RAW_GETBIND),
+COMPATIBLE_IOCTL(RAW_SETBIND)
+COMPATIBLE_IOCTL(RAW_GETBIND)
 /* SMB ioctls which do not need any translations */
-COMPATIBLE_IOCTL(SMB_IOC_NEWCONN),
+COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
 /* NCP ioctls which do not need any translations */
-COMPATIBLE_IOCTL(NCP_IOC_CONN_LOGGED_IN),
-COMPATIBLE_IOCTL(NCP_IOC_SIGN_INIT),
-COMPATIBLE_IOCTL(NCP_IOC_SIGN_WANTED),
-COMPATIBLE_IOCTL(NCP_IOC_SET_SIGN_WANTED),
-COMPATIBLE_IOCTL(NCP_IOC_LOCKUNLOCK),
-COMPATIBLE_IOCTL(NCP_IOC_GETROOT),
-COMPATIBLE_IOCTL(NCP_IOC_SETROOT),
-COMPATIBLE_IOCTL(NCP_IOC_GETCHARSETS),
-COMPATIBLE_IOCTL(NCP_IOC_SETCHARSETS),
-COMPATIBLE_IOCTL(NCP_IOC_GETDENTRYTTL),
-COMPATIBLE_IOCTL(NCP_IOC_SETDENTRYTTL),
+COMPATIBLE_IOCTL(NCP_IOC_CONN_LOGGED_IN)
+COMPATIBLE_IOCTL(NCP_IOC_SIGN_INIT)
+COMPATIBLE_IOCTL(NCP_IOC_SIGN_WANTED)
+COMPATIBLE_IOCTL(NCP_IOC_SET_SIGN_WANTED)
+COMPATIBLE_IOCTL(NCP_IOC_LOCKUNLOCK)
+COMPATIBLE_IOCTL(NCP_IOC_GETROOT)
+COMPATIBLE_IOCTL(NCP_IOC_SETROOT)
+COMPATIBLE_IOCTL(NCP_IOC_GETCHARSETS)
+COMPATIBLE_IOCTL(NCP_IOC_SETCHARSETS)
+COMPATIBLE_IOCTL(NCP_IOC_GETDENTRYTTL)
+COMPATIBLE_IOCTL(NCP_IOC_SETDENTRYTTL)
 /* Little a */
-COMPATIBLE_IOCTL(ATMSIGD_CTRL),
-COMPATIBLE_IOCTL(ATMARPD_CTRL),
-COMPATIBLE_IOCTL(ATMLEC_CTRL),
-COMPATIBLE_IOCTL(ATMLEC_MCAST),
-COMPATIBLE_IOCTL(ATMLEC_DATA),
-COMPATIBLE_IOCTL(ATM_SETSC),
-COMPATIBLE_IOCTL(SIOCSIFATMTCP),
-COMPATIBLE_IOCTL(SIOCMKCLIP),
-COMPATIBLE_IOCTL(ATMARP_MKIP),
-COMPATIBLE_IOCTL(ATMARP_SETENTRY),
-COMPATIBLE_IOCTL(ATMARP_ENCAP),
-COMPATIBLE_IOCTL(ATMTCP_CREATE),
-COMPATIBLE_IOCTL(ATMTCP_REMOVE),
-COMPATIBLE_IOCTL(ATMMPC_CTRL),
-COMPATIBLE_IOCTL(ATMMPC_DATA),
+COMPATIBLE_IOCTL(ATMSIGD_CTRL)
+COMPATIBLE_IOCTL(ATMARPD_CTRL)
+COMPATIBLE_IOCTL(ATMLEC_CTRL)
+COMPATIBLE_IOCTL(ATMLEC_MCAST)
+COMPATIBLE_IOCTL(ATMLEC_DATA)
+COMPATIBLE_IOCTL(ATM_SETSC)
+COMPATIBLE_IOCTL(SIOCSIFATMTCP)
+COMPATIBLE_IOCTL(SIOCMKCLIP)
+COMPATIBLE_IOCTL(ATMARP_MKIP)
+COMPATIBLE_IOCTL(ATMARP_SETENTRY)
+COMPATIBLE_IOCTL(ATMARP_ENCAP)
+COMPATIBLE_IOCTL(ATMTCP_CREATE)
+COMPATIBLE_IOCTL(ATMTCP_REMOVE)
+COMPATIBLE_IOCTL(ATMMPC_CTRL)
+COMPATIBLE_IOCTL(ATMMPC_DATA)
 #if defined(CONFIG_DRM) || defined(CONFIG_DRM_MODULE)
-COMPATIBLE_IOCTL(DRM_IOCTL_GET_MAGIC),
-COMPATIBLE_IOCTL(DRM_IOCTL_IRQ_BUSID),
-COMPATIBLE_IOCTL(DRM_IOCTL_AUTH_MAGIC),
-COMPATIBLE_IOCTL(DRM_IOCTL_BLOCK),
-COMPATIBLE_IOCTL(DRM_IOCTL_UNBLOCK),
-COMPATIBLE_IOCTL(DRM_IOCTL_CONTROL),
-COMPATIBLE_IOCTL(DRM_IOCTL_ADD_BUFS),
-COMPATIBLE_IOCTL(DRM_IOCTL_MARK_BUFS),
-COMPATIBLE_IOCTL(DRM_IOCTL_ADD_CTX),
-COMPATIBLE_IOCTL(DRM_IOCTL_RM_CTX),
-COMPATIBLE_IOCTL(DRM_IOCTL_MOD_CTX),
-COMPATIBLE_IOCTL(DRM_IOCTL_GET_CTX),
-COMPATIBLE_IOCTL(DRM_IOCTL_SWITCH_CTX),
-COMPATIBLE_IOCTL(DRM_IOCTL_NEW_CTX),
-COMPATIBLE_IOCTL(DRM_IOCTL_ADD_DRAW),
-COMPATIBLE_IOCTL(DRM_IOCTL_RM_DRAW),
-COMPATIBLE_IOCTL(DRM_IOCTL_LOCK),
-COMPATIBLE_IOCTL(DRM_IOCTL_UNLOCK),
-COMPATIBLE_IOCTL(DRM_IOCTL_FINISH),
+COMPATIBLE_IOCTL(DRM_IOCTL_GET_MAGIC)
+COMPATIBLE_IOCTL(DRM_IOCTL_IRQ_BUSID)
+COMPATIBLE_IOCTL(DRM_IOCTL_AUTH_MAGIC)
+COMPATIBLE_IOCTL(DRM_IOCTL_BLOCK)
+COMPATIBLE_IOCTL(DRM_IOCTL_UNBLOCK)
+COMPATIBLE_IOCTL(DRM_IOCTL_CONTROL)
+COMPATIBLE_IOCTL(DRM_IOCTL_ADD_BUFS)
+COMPATIBLE_IOCTL(DRM_IOCTL_MARK_BUFS)
+COMPATIBLE_IOCTL(DRM_IOCTL_ADD_CTX)
+COMPATIBLE_IOCTL(DRM_IOCTL_RM_CTX)
+COMPATIBLE_IOCTL(DRM_IOCTL_MOD_CTX)
+COMPATIBLE_IOCTL(DRM_IOCTL_GET_CTX)
+COMPATIBLE_IOCTL(DRM_IOCTL_SWITCH_CTX)
+COMPATIBLE_IOCTL(DRM_IOCTL_NEW_CTX)
+COMPATIBLE_IOCTL(DRM_IOCTL_ADD_DRAW)
+COMPATIBLE_IOCTL(DRM_IOCTL_RM_DRAW)
+COMPATIBLE_IOCTL(DRM_IOCTL_LOCK)
+COMPATIBLE_IOCTL(DRM_IOCTL_UNLOCK)
+COMPATIBLE_IOCTL(DRM_IOCTL_FINISH)
 #endif /* DRM */
 /* Big W */
 /* WIOC_GETSUPPORT not yet implemented -E */
-COMPATIBLE_IOCTL(WDIOC_GETSTATUS),
-COMPATIBLE_IOCTL(WDIOC_GETBOOTSTATUS),
-COMPATIBLE_IOCTL(WDIOC_GETTEMP),
-COMPATIBLE_IOCTL(WDIOC_SETOPTIONS),
-COMPATIBLE_IOCTL(WDIOC_KEEPALIVE),
+COMPATIBLE_IOCTL(WDIOC_GETSTATUS)
+COMPATIBLE_IOCTL(WDIOC_GETBOOTSTATUS)
+COMPATIBLE_IOCTL(WDIOC_GETTEMP)
+COMPATIBLE_IOCTL(WDIOC_SETOPTIONS)
+COMPATIBLE_IOCTL(WDIOC_KEEPALIVE)
 /* Big R */
-COMPATIBLE_IOCTL(RNDGETENTCNT),
-COMPATIBLE_IOCTL(RNDADDTOENTCNT),
-COMPATIBLE_IOCTL(RNDGETPOOL),
-COMPATIBLE_IOCTL(RNDADDENTROPY),
-COMPATIBLE_IOCTL(RNDZAPENTCNT),
-COMPATIBLE_IOCTL(RNDCLEARPOOL),
+COMPATIBLE_IOCTL(RNDGETENTCNT)
+COMPATIBLE_IOCTL(RNDADDTOENTCNT)
+COMPATIBLE_IOCTL(RNDGETPOOL)
+COMPATIBLE_IOCTL(RNDADDENTROPY)
+COMPATIBLE_IOCTL(RNDZAPENTCNT)
+COMPATIBLE_IOCTL(RNDCLEARPOOL)
 /* Bluetooth ioctls */
-COMPATIBLE_IOCTL(HCIDEVUP),
-COMPATIBLE_IOCTL(HCIDEVDOWN),
-COMPATIBLE_IOCTL(HCIDEVRESET),
-COMPATIBLE_IOCTL(HCIDEVRESTAT),
-COMPATIBLE_IOCTL(HCIGETDEVLIST),
-COMPATIBLE_IOCTL(HCIGETDEVINFO),
-COMPATIBLE_IOCTL(HCIGETCONNLIST),
-COMPATIBLE_IOCTL(HCIGETCONNINFO),
-COMPATIBLE_IOCTL(HCISETRAW),
-COMPATIBLE_IOCTL(HCISETSCAN),
-COMPATIBLE_IOCTL(HCISETAUTH),
-COMPATIBLE_IOCTL(HCISETENCRYPT),
-COMPATIBLE_IOCTL(HCISETPTYPE),
-COMPATIBLE_IOCTL(HCISETLINKPOL),
-COMPATIBLE_IOCTL(HCISETLINKMODE),
-COMPATIBLE_IOCTL(HCISETACLMTU),
-COMPATIBLE_IOCTL(HCISETSCOMTU),
-COMPATIBLE_IOCTL(HCIINQUIRY),
-COMPATIBLE_IOCTL(HCIUARTSETPROTO),
-COMPATIBLE_IOCTL(HCIUARTGETPROTO),
-COMPATIBLE_IOCTL(RFCOMMCREATEDEV),
-COMPATIBLE_IOCTL(RFCOMMRELEASEDEV),
-COMPATIBLE_IOCTL(RFCOMMGETDEVLIST),
-COMPATIBLE_IOCTL(RFCOMMGETDEVINFO),
-COMPATIBLE_IOCTL(RFCOMMSTEALDLC),
-COMPATIBLE_IOCTL(BNEPCONNADD),
-COMPATIBLE_IOCTL(BNEPCONNDEL),
-COMPATIBLE_IOCTL(BNEPGETCONNLIST),
-COMPATIBLE_IOCTL(BNEPGETCONNINFO),
-COMPATIBLE_IOCTL(PCIIOC_CONTROLLER),
-COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO),
-COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM),
-COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE),
+COMPATIBLE_IOCTL(HCIDEVUP)
+COMPATIBLE_IOCTL(HCIDEVDOWN)
+COMPATIBLE_IOCTL(HCIDEVRESET)
+COMPATIBLE_IOCTL(HCIDEVRESTAT)
+COMPATIBLE_IOCTL(HCIGETDEVLIST)
+COMPATIBLE_IOCTL(HCIGETDEVINFO)
+COMPATIBLE_IOCTL(HCIGETCONNLIST)
+COMPATIBLE_IOCTL(HCIGETCONNINFO)
+COMPATIBLE_IOCTL(HCISETRAW)
+COMPATIBLE_IOCTL(HCISETSCAN)
+COMPATIBLE_IOCTL(HCISETAUTH)
+COMPATIBLE_IOCTL(HCISETENCRYPT)
+COMPATIBLE_IOCTL(HCISETPTYPE)
+COMPATIBLE_IOCTL(HCISETLINKPOL)
+COMPATIBLE_IOCTL(HCISETLINKMODE)
+COMPATIBLE_IOCTL(HCISETACLMTU)
+COMPATIBLE_IOCTL(HCISETSCOMTU)
+COMPATIBLE_IOCTL(HCIINQUIRY)
+COMPATIBLE_IOCTL(HCIUARTSETPROTO)
+COMPATIBLE_IOCTL(HCIUARTGETPROTO)
+COMPATIBLE_IOCTL(RFCOMMCREATEDEV)
+COMPATIBLE_IOCTL(RFCOMMRELEASEDEV)
+COMPATIBLE_IOCTL(RFCOMMGETDEVLIST)
+COMPATIBLE_IOCTL(RFCOMMGETDEVINFO)
+COMPATIBLE_IOCTL(RFCOMMSTEALDLC)
+COMPATIBLE_IOCTL(BNEPCONNADD)
+COMPATIBLE_IOCTL(BNEPCONNDEL)
+COMPATIBLE_IOCTL(BNEPGETCONNLIST)
+COMPATIBLE_IOCTL(BNEPGETCONNINFO)
+COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
+COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
+COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM)
+COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE)
 /* USB */
-COMPATIBLE_IOCTL(USBDEVFS_RESETEP),
-COMPATIBLE_IOCTL(USBDEVFS_SETINTERFACE),
-COMPATIBLE_IOCTL(USBDEVFS_SETCONFIGURATION),
-COMPATIBLE_IOCTL(USBDEVFS_GETDRIVER),
-COMPATIBLE_IOCTL(USBDEVFS_DISCARDURB),
-COMPATIBLE_IOCTL(USBDEVFS_CLAIMINTERFACE),
-COMPATIBLE_IOCTL(USBDEVFS_RELEASEINTERFACE),
-COMPATIBLE_IOCTL(USBDEVFS_CONNECTINFO),
-COMPATIBLE_IOCTL(USBDEVFS_HUB_PORTINFO),
-COMPATIBLE_IOCTL(USBDEVFS_RESET),
-COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT),
+COMPATIBLE_IOCTL(USBDEVFS_RESETEP)
+COMPATIBLE_IOCTL(USBDEVFS_SETINTERFACE)
+COMPATIBLE_IOCTL(USBDEVFS_SETCONFIGURATION)
+COMPATIBLE_IOCTL(USBDEVFS_GETDRIVER)
+COMPATIBLE_IOCTL(USBDEVFS_DISCARDURB)
+COMPATIBLE_IOCTL(USBDEVFS_CLAIMINTERFACE)
+COMPATIBLE_IOCTL(USBDEVFS_RELEASEINTERFACE)
+COMPATIBLE_IOCTL(USBDEVFS_CONNECTINFO)
+COMPATIBLE_IOCTL(USBDEVFS_HUB_PORTINFO)
+COMPATIBLE_IOCTL(USBDEVFS_RESET)
+COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
 /* MTD */
-COMPATIBLE_IOCTL(MEMGETINFO),
-COMPATIBLE_IOCTL(MEMERASE),
-COMPATIBLE_IOCTL(MEMLOCK),
-COMPATIBLE_IOCTL(MEMUNLOCK),
-COMPATIBLE_IOCTL(MEMGETREGIONCOUNT),
-COMPATIBLE_IOCTL(MEMGETREGIONINFO),
+COMPATIBLE_IOCTL(MEMGETINFO)
+COMPATIBLE_IOCTL(MEMERASE)
+COMPATIBLE_IOCTL(MEMLOCK)
+COMPATIBLE_IOCTL(MEMUNLOCK)
+COMPATIBLE_IOCTL(MEMGETREGIONCOUNT)
+COMPATIBLE_IOCTL(MEMGETREGIONINFO)
 /* NBD */
-COMPATIBLE_IOCTL(NBD_SET_SOCK),
-COMPATIBLE_IOCTL(NBD_SET_BLKSIZE),
-COMPATIBLE_IOCTL(NBD_SET_SIZE),
-COMPATIBLE_IOCTL(NBD_DO_IT),
-COMPATIBLE_IOCTL(NBD_CLEAR_SOCK),
-COMPATIBLE_IOCTL(NBD_CLEAR_QUE),
-COMPATIBLE_IOCTL(NBD_PRINT_DEBUG),
-COMPATIBLE_IOCTL(NBD_SET_SIZE_BLOCKS),
-COMPATIBLE_IOCTL(NBD_DISCONNECT),
+COMPATIBLE_IOCTL(NBD_SET_SOCK)
+COMPATIBLE_IOCTL(NBD_SET_BLKSIZE)
+COMPATIBLE_IOCTL(NBD_SET_SIZE)
+COMPATIBLE_IOCTL(NBD_DO_IT)
+COMPATIBLE_IOCTL(NBD_CLEAR_SOCK)
+COMPATIBLE_IOCTL(NBD_CLEAR_QUE)
+COMPATIBLE_IOCTL(NBD_PRINT_DEBUG)
+COMPATIBLE_IOCTL(NBD_SET_SIZE_BLOCKS)
+COMPATIBLE_IOCTL(NBD_DISCONNECT)
 /* device-mapper */
-COMPATIBLE_IOCTL(DM_VERSION),
-COMPATIBLE_IOCTL(DM_REMOVE_ALL),
-COMPATIBLE_IOCTL(DM_DEV_CREATE),
-COMPATIBLE_IOCTL(DM_DEV_REMOVE),
-COMPATIBLE_IOCTL(DM_DEV_RELOAD),
-COMPATIBLE_IOCTL(DM_DEV_SUSPEND),
-COMPATIBLE_IOCTL(DM_DEV_RENAME),
-COMPATIBLE_IOCTL(DM_DEV_DEPS),
-COMPATIBLE_IOCTL(DM_DEV_STATUS),
-COMPATIBLE_IOCTL(DM_TARGET_STATUS),
-COMPATIBLE_IOCTL(DM_TARGET_WAIT),
+COMPATIBLE_IOCTL(DM_VERSION)
+COMPATIBLE_IOCTL(DM_REMOVE_ALL)
+COMPATIBLE_IOCTL(DM_DEV_CREATE)
+COMPATIBLE_IOCTL(DM_DEV_REMOVE)
+COMPATIBLE_IOCTL(DM_DEV_RELOAD)
+COMPATIBLE_IOCTL(DM_DEV_SUSPEND)
+COMPATIBLE_IOCTL(DM_DEV_RENAME)
+COMPATIBLE_IOCTL(DM_DEV_DEPS)
+COMPATIBLE_IOCTL(DM_DEV_STATUS)
+COMPATIBLE_IOCTL(DM_TARGET_STATUS)
+COMPATIBLE_IOCTL(DM_TARGET_WAIT)
 /* And these ioctls need translation */
-HANDLE_IOCTL(MEMREADOOB32, mtd_rw_oob),
-HANDLE_IOCTL(MEMWRITEOOB32, mtd_rw_oob),
+HANDLE_IOCTL(MEMREADOOB32, mtd_rw_oob)
+HANDLE_IOCTL(MEMWRITEOOB32, mtd_rw_oob)
 #ifdef CONFIG_NET
-HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32),
+HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32)
 #endif
-HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf),
-HANDLE_IOCTL(SIOCGIFFLAGS, dev_ifsioc),
-HANDLE_IOCTL(SIOCSIFFLAGS, dev_ifsioc),
-HANDLE_IOCTL(SIOCGIFMETRIC, dev_ifsioc),
-HANDLE_IOCTL(SIOCSIFMETRIC, dev_ifsioc),
-HANDLE_IOCTL(SIOCGIFMTU, dev_ifsioc),
-HANDLE_IOCTL(SIOCSIFMTU, dev_ifsioc),
-HANDLE_IOCTL(SIOCGIFMEM, dev_ifsioc),
-HANDLE_IOCTL(SIOCSIFMEM, dev_ifsioc),
-HANDLE_IOCTL(SIOCGIFHWADDR, dev_ifsioc),
-HANDLE_IOCTL(SIOCSIFHWADDR, dev_ifsioc),
-HANDLE_IOCTL(SIOCADDMULTI, dev_ifsioc),
-HANDLE_IOCTL(SIOCDELMULTI, dev_ifsioc),
-HANDLE_IOCTL(SIOCGIFINDEX, dev_ifsioc),
-HANDLE_IOCTL(SIOCGIFMAP, dev_ifsioc),
-HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc),
-HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc),
-HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc),
-HANDLE_IOCTL(SIOCGIFBRDADDR, dev_ifsioc),
-HANDLE_IOCTL(SIOCSIFBRDADDR, dev_ifsioc),
-HANDLE_IOCTL(SIOCGIFDSTADDR, dev_ifsioc),
-HANDLE_IOCTL(SIOCSIFDSTADDR, dev_ifsioc),
-HANDLE_IOCTL(SIOCGIFNETMASK, dev_ifsioc),
-HANDLE_IOCTL(SIOCSIFNETMASK, dev_ifsioc),
-HANDLE_IOCTL(SIOCSIFPFLAGS, dev_ifsioc),
-HANDLE_IOCTL(SIOCGIFPFLAGS, dev_ifsioc),
-HANDLE_IOCTL(SIOCGIFTXQLEN, dev_ifsioc),
-HANDLE_IOCTL(SIOCSIFTXQLEN, dev_ifsioc),
-HANDLE_IOCTL(SIOCETHTOOL, ethtool_ioctl),
-HANDLE_IOCTL(SIOCBONDENSLAVE, bond_ioctl),
-HANDLE_IOCTL(SIOCBONDRELEASE, bond_ioctl),
-HANDLE_IOCTL(SIOCBONDSETHWADDR, bond_ioctl),
-HANDLE_IOCTL(SIOCBONDSLAVEINFOQUERY, bond_ioctl),
-HANDLE_IOCTL(SIOCBONDINFOQUERY, bond_ioctl),
-HANDLE_IOCTL(SIOCBONDCHANGEACTIVE, bond_ioctl),
-HANDLE_IOCTL(SIOCADDRT, routing_ioctl),
-HANDLE_IOCTL(SIOCDELRT, routing_ioctl),
+HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf)
+HANDLE_IOCTL(SIOCGIFFLAGS, dev_ifsioc)
+HANDLE_IOCTL(SIOCSIFFLAGS, dev_ifsioc)
+HANDLE_IOCTL(SIOCGIFMETRIC, dev_ifsioc)
+HANDLE_IOCTL(SIOCSIFMETRIC, dev_ifsioc)
+HANDLE_IOCTL(SIOCGIFMTU, dev_ifsioc)
+HANDLE_IOCTL(SIOCSIFMTU, dev_ifsioc)
+HANDLE_IOCTL(SIOCGIFMEM, dev_ifsioc)
+HANDLE_IOCTL(SIOCSIFMEM, dev_ifsioc)
+HANDLE_IOCTL(SIOCGIFHWADDR, dev_ifsioc)
+HANDLE_IOCTL(SIOCSIFHWADDR, dev_ifsioc)
+HANDLE_IOCTL(SIOCADDMULTI, dev_ifsioc)
+HANDLE_IOCTL(SIOCDELMULTI, dev_ifsioc)
+HANDLE_IOCTL(SIOCGIFINDEX, dev_ifsioc)
+HANDLE_IOCTL(SIOCGIFMAP, dev_ifsioc)
+HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc)
+HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc)
+HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc)
+HANDLE_IOCTL(SIOCGIFBRDADDR, dev_ifsioc)
+HANDLE_IOCTL(SIOCSIFBRDADDR, dev_ifsioc)
+HANDLE_IOCTL(SIOCGIFDSTADDR, dev_ifsioc)
+HANDLE_IOCTL(SIOCSIFDSTADDR, dev_ifsioc)
+HANDLE_IOCTL(SIOCGIFNETMASK, dev_ifsioc)
+HANDLE_IOCTL(SIOCSIFNETMASK, dev_ifsioc)
+HANDLE_IOCTL(SIOCSIFPFLAGS, dev_ifsioc)
+HANDLE_IOCTL(SIOCGIFPFLAGS, dev_ifsioc)
+HANDLE_IOCTL(SIOCGIFTXQLEN, dev_ifsioc)
+HANDLE_IOCTL(SIOCSIFTXQLEN, dev_ifsioc)
+HANDLE_IOCTL(SIOCETHTOOL, ethtool_ioctl)
+HANDLE_IOCTL(SIOCBONDENSLAVE, bond_ioctl)
+HANDLE_IOCTL(SIOCBONDRELEASE, bond_ioctl)
+HANDLE_IOCTL(SIOCBONDSETHWADDR, bond_ioctl)
+HANDLE_IOCTL(SIOCBONDSLAVEINFOQUERY, bond_ioctl)
+HANDLE_IOCTL(SIOCBONDINFOQUERY, bond_ioctl)
+HANDLE_IOCTL(SIOCBONDCHANGEACTIVE, bond_ioctl)
+HANDLE_IOCTL(SIOCADDRT, routing_ioctl)
+HANDLE_IOCTL(SIOCDELRT, routing_ioctl)
 /* Note SIOCRTMSG is no longer, so this is safe and
  * the user would have seen just an -EINVAL anyways. */
-HANDLE_IOCTL(SIOCRTMSG, ret_einval),
-HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp),
-HANDLE_IOCTL(HDIO_GETGEO, hdio_getgeo),
-HANDLE_IOCTL(HDIO_GETGEO_BIG_RAW, hdio_getgeo_big),
-HANDLE_IOCTL(BLKGETSIZE, w_long),
-HANDLE_IOCTL(BLKRAGET, w_long),
-HANDLE_IOCTL(BLKFRAGET, w_long),
-HANDLE_IOCTL(0x1260, broken_blkgetsize),
-HANDLE_IOCTL(BLKSECTGET, w_long),
-HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans),
-HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans),
-HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans),
-HANDLE_IOCTL(HDIO_GET_32BIT, hdio_ioctl_trans),
-HANDLE_IOCTL(HDIO_GET_MULTCOUNT, hdio_ioctl_trans),
-HANDLE_IOCTL(HDIO_GET_NOWERR, hdio_ioctl_trans),
-HANDLE_IOCTL(HDIO_GET_NICE, hdio_ioctl_trans),
-HANDLE_IOCTL(FDSETPRM32, fd_ioctl_trans),
-HANDLE_IOCTL(FDDEFPRM32, fd_ioctl_trans),
-HANDLE_IOCTL(FDGETPRM32, fd_ioctl_trans),
-HANDLE_IOCTL(FDSETDRVPRM32, fd_ioctl_trans),
-HANDLE_IOCTL(FDGETDRVPRM32, fd_ioctl_trans),
-HANDLE_IOCTL(FDGETDRVSTAT32, fd_ioctl_trans),
-HANDLE_IOCTL(FDPOLLDRVSTAT32, fd_ioctl_trans),
-HANDLE_IOCTL(FDGETFDCSTAT32, fd_ioctl_trans),
-HANDLE_IOCTL(FDWERRORGET32, fd_ioctl_trans),
-HANDLE_IOCTL(SG_IO,sg_ioctl_trans),
-HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans),
-HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans),
-HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans),
-HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans),
-HANDLE_IOCTL(MTIOCGETCONFIG32, mt_ioctl_trans),
-HANDLE_IOCTL(MTIOCSETCONFIG32, mt_ioctl_trans),
-HANDLE_IOCTL(CDROMREADMODE2, cdrom_ioctl_trans),
-HANDLE_IOCTL(CDROMREADMODE1, cdrom_ioctl_trans),
-HANDLE_IOCTL(CDROMREADRAW, cdrom_ioctl_trans),
-HANDLE_IOCTL(CDROMREADCOOKED, cdrom_ioctl_trans),
-HANDLE_IOCTL(CDROMREADAUDIO, cdrom_ioctl_trans),
-HANDLE_IOCTL(CDROMREADALL, cdrom_ioctl_trans),
-HANDLE_IOCTL(CDROM_SEND_PACKET, cdrom_ioctl_trans),
-HANDLE_IOCTL(LOOP_SET_STATUS, loop_status),
-HANDLE_IOCTL(LOOP_GET_STATUS, loop_status),
-HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout),
+HANDLE_IOCTL(SIOCRTMSG, ret_einval)
+HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp)
+HANDLE_IOCTL(HDIO_GETGEO, hdio_getgeo)
+HANDLE_IOCTL(HDIO_GETGEO_BIG_RAW, hdio_getgeo_big)
+HANDLE_IOCTL(BLKGETSIZE, w_long)
+HANDLE_IOCTL(BLKRAGET, w_long)
+HANDLE_IOCTL(BLKFRAGET, w_long)
+HANDLE_IOCTL(0x1260, broken_blkgetsize)
+HANDLE_IOCTL(BLKSECTGET, w_long)
+HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans)
+HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans)
+HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans)
+HANDLE_IOCTL(HDIO_GET_32BIT, hdio_ioctl_trans)
+HANDLE_IOCTL(HDIO_GET_MULTCOUNT, hdio_ioctl_trans)
+HANDLE_IOCTL(HDIO_GET_NOWERR, hdio_ioctl_trans)
+HANDLE_IOCTL(HDIO_GET_NICE, hdio_ioctl_trans)
+HANDLE_IOCTL(FDSETPRM32, fd_ioctl_trans)
+HANDLE_IOCTL(FDDEFPRM32, fd_ioctl_trans)
+HANDLE_IOCTL(FDGETPRM32, fd_ioctl_trans)
+HANDLE_IOCTL(FDSETDRVPRM32, fd_ioctl_trans)
+HANDLE_IOCTL(FDGETDRVPRM32, fd_ioctl_trans)
+HANDLE_IOCTL(FDGETDRVSTAT32, fd_ioctl_trans)
+HANDLE_IOCTL(FDPOLLDRVSTAT32, fd_ioctl_trans)
+HANDLE_IOCTL(FDGETFDCSTAT32, fd_ioctl_trans)
+HANDLE_IOCTL(FDWERRORGET32, fd_ioctl_trans)
+HANDLE_IOCTL(SG_IO,sg_ioctl_trans)
+HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans)
+HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans)
+HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans)
+HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans)
+HANDLE_IOCTL(MTIOCGETCONFIG32, mt_ioctl_trans)
+HANDLE_IOCTL(MTIOCSETCONFIG32, mt_ioctl_trans)
+HANDLE_IOCTL(CDROMREADMODE2, cdrom_ioctl_trans)
+HANDLE_IOCTL(CDROMREADMODE1, cdrom_ioctl_trans)
+HANDLE_IOCTL(CDROMREADRAW, cdrom_ioctl_trans)
+HANDLE_IOCTL(CDROMREADCOOKED, cdrom_ioctl_trans)
+HANDLE_IOCTL(CDROMREADAUDIO, cdrom_ioctl_trans)
+HANDLE_IOCTL(CDROMREADALL, cdrom_ioctl_trans)
+HANDLE_IOCTL(CDROM_SEND_PACKET, cdrom_ioctl_trans)
+HANDLE_IOCTL(LOOP_SET_STATUS, loop_status)
+HANDLE_IOCTL(LOOP_GET_STATUS, loop_status)
+HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout)
 #ifdef CONFIG_VT
-HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl),
-HANDLE_IOCTL(GIO_FONTX, do_fontx_ioctl),
-HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl),
-HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl),
-HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl),
-HANDLE_IOCTL(FBIOGET_FSCREENINFO, do_fbioget_fscreeninfo_ioctl),
-HANDLE_IOCTL(FBIOGETCMAP, do_fbiogetcmap_ioctl),
-HANDLE_IOCTL(FBIOPUTCMAP, do_fbioputcmap_ioctl),
+HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl)
+HANDLE_IOCTL(GIO_FONTX, do_fontx_ioctl)
+HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl)
+HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl)
+HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl)
+HANDLE_IOCTL(FBIOGET_FSCREENINFO, do_fbioget_fscreeninfo_ioctl)
+HANDLE_IOCTL(FBIOGETCMAP, do_fbiogetcmap_ioctl)
+HANDLE_IOCTL(FBIOPUTCMAP, do_fbioputcmap_ioctl)
 #endif
-HANDLE_IOCTL(EXT2_IOC32_GETFLAGS, do_ext2_ioctl),
-HANDLE_IOCTL(EXT2_IOC32_SETFLAGS, do_ext2_ioctl),
-HANDLE_IOCTL(EXT2_IOC32_GETVERSION, do_ext2_ioctl),
-HANDLE_IOCTL(EXT2_IOC32_SETVERSION, do_ext2_ioctl),
-HANDLE_IOCTL(VIDIOCGTUNER32, do_video_ioctl),
-HANDLE_IOCTL(VIDIOCSTUNER32, do_video_ioctl),
-HANDLE_IOCTL(VIDIOCGWIN32, do_video_ioctl),
-HANDLE_IOCTL(VIDIOCSWIN32, do_video_ioctl),
-HANDLE_IOCTL(VIDIOCGFBUF32, do_video_ioctl),
-HANDLE_IOCTL(VIDIOCSFBUF32, do_video_ioctl),
-HANDLE_IOCTL(VIDIOCGFREQ32, do_video_ioctl),
-HANDLE_IOCTL(VIDIOCSFREQ32, do_video_ioctl),
+HANDLE_IOCTL(EXT2_IOC32_GETFLAGS, do_ext2_ioctl)
+HANDLE_IOCTL(EXT2_IOC32_SETFLAGS, do_ext2_ioctl)
+HANDLE_IOCTL(EXT2_IOC32_GETVERSION, do_ext2_ioctl)
+HANDLE_IOCTL(EXT2_IOC32_SETVERSION, do_ext2_ioctl)
+HANDLE_IOCTL(VIDIOCGTUNER32, do_video_ioctl)
+HANDLE_IOCTL(VIDIOCSTUNER32, do_video_ioctl)
+HANDLE_IOCTL(VIDIOCGWIN32, do_video_ioctl)
+HANDLE_IOCTL(VIDIOCSWIN32, do_video_ioctl)
+HANDLE_IOCTL(VIDIOCGFBUF32, do_video_ioctl)
+HANDLE_IOCTL(VIDIOCSFBUF32, do_video_ioctl)
+HANDLE_IOCTL(VIDIOCGFREQ32, do_video_ioctl)
+HANDLE_IOCTL(VIDIOCSFREQ32, do_video_ioctl)
 /* One SMB ioctl needs translations. */
-HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid),
+HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid)
 /* NCPFS */
-HANDLE_IOCTL(NCP_IOC_NCPREQUEST_32, do_ncp_ncprequest),
-HANDLE_IOCTL(NCP_IOC_GETMOUNTUID2_32, do_ncp_getmountuid2),
-HANDLE_IOCTL(NCP_IOC_GET_FS_INFO_V2_32, do_ncp_getfsinfo2),
-HANDLE_IOCTL(NCP_IOC_GETOBJECTNAME_32, do_ncp_getobjectname),
-HANDLE_IOCTL(NCP_IOC_SETOBJECTNAME_32, do_ncp_setobjectname),
-HANDLE_IOCTL(NCP_IOC_GETPRIVATEDATA_32, do_ncp_getprivatedata),
-HANDLE_IOCTL(NCP_IOC_SETPRIVATEDATA_32, do_ncp_setprivatedata),
-HANDLE_IOCTL(ATM_GETLINKRATE32, do_atm_ioctl),
-HANDLE_IOCTL(ATM_GETNAMES32, do_atm_ioctl),
-HANDLE_IOCTL(ATM_GETTYPE32, do_atm_ioctl),
-HANDLE_IOCTL(ATM_GETESI32, do_atm_ioctl),
-HANDLE_IOCTL(ATM_GETADDR32, do_atm_ioctl),
-HANDLE_IOCTL(ATM_RSTADDR32, do_atm_ioctl),
-HANDLE_IOCTL(ATM_ADDADDR32, do_atm_ioctl),
-HANDLE_IOCTL(ATM_DELADDR32, do_atm_ioctl),
-HANDLE_IOCTL(ATM_GETCIRANGE32, do_atm_ioctl),
-HANDLE_IOCTL(ATM_SETCIRANGE32, do_atm_ioctl),
-HANDLE_IOCTL(ATM_SETESI32, do_atm_ioctl),
-HANDLE_IOCTL(ATM_SETESIF32, do_atm_ioctl),
-HANDLE_IOCTL(ATM_GETSTAT32, do_atm_ioctl),
-HANDLE_IOCTL(ATM_GETSTATZ32, do_atm_ioctl),
-HANDLE_IOCTL(ATM_GETLOOP32, do_atm_ioctl),
-HANDLE_IOCTL(ATM_SETLOOP32, do_atm_ioctl),
-HANDLE_IOCTL(ATM_QUERYLOOP32, do_atm_ioctl),
-HANDLE_IOCTL(SONET_GETSTAT, do_atm_ioctl),
-HANDLE_IOCTL(SONET_GETSTATZ, do_atm_ioctl),
-HANDLE_IOCTL(SONET_GETDIAG, do_atm_ioctl),
-HANDLE_IOCTL(SONET_SETDIAG, do_atm_ioctl),
-HANDLE_IOCTL(SONET_CLRDIAG, do_atm_ioctl),
-HANDLE_IOCTL(SONET_SETFRAMING, do_atm_ioctl),
-HANDLE_IOCTL(SONET_GETFRAMING, do_atm_ioctl),
-HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl),
+HANDLE_IOCTL(NCP_IOC_NCPREQUEST_32, do_ncp_ncprequest)
+HANDLE_IOCTL(NCP_IOC_GETMOUNTUID2_32, do_ncp_getmountuid2)
+HANDLE_IOCTL(NCP_IOC_GET_FS_INFO_V2_32, do_ncp_getfsinfo2)
+HANDLE_IOCTL(NCP_IOC_GETOBJECTNAME_32, do_ncp_getobjectname)
+HANDLE_IOCTL(NCP_IOC_SETOBJECTNAME_32, do_ncp_setobjectname)
+HANDLE_IOCTL(NCP_IOC_GETPRIVATEDATA_32, do_ncp_getprivatedata)
+HANDLE_IOCTL(NCP_IOC_SETPRIVATEDATA_32, do_ncp_setprivatedata)
+HANDLE_IOCTL(ATM_GETLINKRATE32, do_atm_ioctl)
+HANDLE_IOCTL(ATM_GETNAMES32, do_atm_ioctl)
+HANDLE_IOCTL(ATM_GETTYPE32, do_atm_ioctl)
+HANDLE_IOCTL(ATM_GETESI32, do_atm_ioctl)
+HANDLE_IOCTL(ATM_GETADDR32, do_atm_ioctl)
+HANDLE_IOCTL(ATM_RSTADDR32, do_atm_ioctl)
+HANDLE_IOCTL(ATM_ADDADDR32, do_atm_ioctl)
+HANDLE_IOCTL(ATM_DELADDR32, do_atm_ioctl)
+HANDLE_IOCTL(ATM_GETCIRANGE32, do_atm_ioctl)
+HANDLE_IOCTL(ATM_SETCIRANGE32, do_atm_ioctl)
+HANDLE_IOCTL(ATM_SETESI32, do_atm_ioctl)
+HANDLE_IOCTL(ATM_SETESIF32, do_atm_ioctl)
+HANDLE_IOCTL(ATM_GETSTAT32, do_atm_ioctl)
+HANDLE_IOCTL(ATM_GETSTATZ32, do_atm_ioctl)
+HANDLE_IOCTL(ATM_GETLOOP32, do_atm_ioctl)
+HANDLE_IOCTL(ATM_SETLOOP32, do_atm_ioctl)
+HANDLE_IOCTL(ATM_QUERYLOOP32, do_atm_ioctl)
+HANDLE_IOCTL(SONET_GETSTAT, do_atm_ioctl)
+HANDLE_IOCTL(SONET_GETSTATZ, do_atm_ioctl)
+HANDLE_IOCTL(SONET_GETDIAG, do_atm_ioctl)
+HANDLE_IOCTL(SONET_SETDIAG, do_atm_ioctl)
+HANDLE_IOCTL(SONET_CLRDIAG, do_atm_ioctl)
+HANDLE_IOCTL(SONET_SETFRAMING, do_atm_ioctl)
+HANDLE_IOCTL(SONET_GETFRAMING, do_atm_ioctl)
+HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl)
 #if defined(CONFIG_DRM) || defined(CONFIG_DRM_MODULE)
-HANDLE_IOCTL(DRM32_IOCTL_VERSION, drm32_version),
-HANDLE_IOCTL(DRM32_IOCTL_GET_UNIQUE, drm32_getsetunique),
-HANDLE_IOCTL(DRM32_IOCTL_SET_UNIQUE, drm32_getsetunique),
-HANDLE_IOCTL(DRM32_IOCTL_ADD_MAP, drm32_addmap),
-HANDLE_IOCTL(DRM32_IOCTL_INFO_BUFS, drm32_info_bufs),
-HANDLE_IOCTL(DRM32_IOCTL_FREE_BUFS, drm32_free_bufs),
-HANDLE_IOCTL(DRM32_IOCTL_MAP_BUFS, drm32_map_bufs),
-HANDLE_IOCTL(DRM32_IOCTL_DMA, drm32_dma),
-HANDLE_IOCTL(DRM32_IOCTL_RES_CTX, drm32_res_ctx),
+HANDLE_IOCTL(DRM32_IOCTL_VERSION, drm32_version)
+HANDLE_IOCTL(DRM32_IOCTL_GET_UNIQUE, drm32_getsetunique)
+HANDLE_IOCTL(DRM32_IOCTL_SET_UNIQUE, drm32_getsetunique)
+HANDLE_IOCTL(DRM32_IOCTL_ADD_MAP, drm32_addmap)
+HANDLE_IOCTL(DRM32_IOCTL_INFO_BUFS, drm32_info_bufs)
+HANDLE_IOCTL(DRM32_IOCTL_FREE_BUFS, drm32_free_bufs)
+HANDLE_IOCTL(DRM32_IOCTL_MAP_BUFS, drm32_map_bufs)
+HANDLE_IOCTL(DRM32_IOCTL_DMA, drm32_dma)
+HANDLE_IOCTL(DRM32_IOCTL_RES_CTX, drm32_res_ctx)
 #endif /* DRM */
-HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control),
-HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk),
+HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control)
+HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk)
 /*HANDLE_IOCTL(USBDEVFS_SUBMITURB32, do_usbdevfs_urb)*/
-HANDLE_IOCTL(USBDEVFS_REAPURB32, do_usbdevfs_reapurb),
-HANDLE_IOCTL(USBDEVFS_REAPURBNDELAY32, do_usbdevfs_reapurb),
-HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal),
+HANDLE_IOCTL(USBDEVFS_REAPURB32, do_usbdevfs_reapurb)
+HANDLE_IOCTL(USBDEVFS_REAPURBNDELAY32, do_usbdevfs_reapurb)
+HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
 /* take care of sizeof(sizeof()) breakage */
 /* block stuff */
-HANDLE_IOCTL(BLKBSZGET_32, do_blkbszget),
-HANDLE_IOCTL(BLKBSZSET_32, do_blkbszset),
-HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64),
+HANDLE_IOCTL(BLKBSZGET_32, do_blkbszget)
+HANDLE_IOCTL(BLKBSZSET_32, do_blkbszset)
+HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64)
 };
-
-unsigned long ioctl32_hash_table[1024];
-
-static inline unsigned long ioctl32_hash(unsigned long cmd)
-{
-	return ((cmd >> 6) ^ (cmd >> 4) ^ cmd) & 0x3ff;
-}
-
-static void ioctl32_insert_translation(struct ioctl_trans *trans)
-{
-	unsigned long hash;
-	struct ioctl_trans *t;
-
-	hash = ioctl32_hash (trans->cmd);
-	if (!ioctl32_hash_table[hash])
-		ioctl32_hash_table[hash] = (long)trans;
-	else {
-		t = (struct ioctl_trans *)ioctl32_hash_table[hash];
-		while (t->next)
-			t = (struct ioctl_trans *)(long)t->next;
-		trans->next = 0;
-		t->next = (long)trans;
-	}
-}
-
-static int __init init_sys32_ioctl(void)
-{
-        int i, size = sizeof(ioctl_translations) / sizeof(struct ioctl_trans);
-        for (i=0; i < size ;i++)
-                ioctl32_insert_translation(&ioctl_translations[i]);
-	return 0;
-}
-
-__initcall(init_sys32_ioctl);
-
-static struct ioctl_trans *additional_ioctls;
-
-/* Always call these with kernel lock held! */
-
-int register_ioctl32_conversion(unsigned int cmd, int (*handler)(unsigned int, unsigned int, unsigned long, struct file *))
-{
-	int i;
-	if (!additional_ioctls) {
-		additional_ioctls = (struct ioctl_trans *)get_zeroed_page(GFP_KERNEL);
-		if (!additional_ioctls)
-			return -ENOMEM;
-	}
-	for (i = 0; i < PAGE_SIZE/sizeof(struct ioctl_trans); i++) {
-		if (!additional_ioctls[i].cmd)
-			break;
-		if (additional_ioctls[i].cmd == cmd)
-			printk("duplicate ioctl found: %x\n", cmd);
-	}
-	if (i == PAGE_SIZE/sizeof(struct ioctl_trans))
-		return -ENOMEM;
-	additional_ioctls[i].cmd = cmd;
-	if (!handler)
-		additional_ioctls[i].handler = (long)sys_ioctl;
-	else
-		additional_ioctls[i].handler = (long)handler;
-	ioctl32_insert_translation(&additional_ioctls[i]);
-	return 0;
-}
-
-int unregister_ioctl32_conversion(unsigned int cmd)
-{
-	unsigned long hash = ioctl32_hash(cmd);
-	struct ioctl_trans *t, *t1;
-
-	t = (struct ioctl_trans *)ioctl32_hash_table[hash];
-	if (!t) return -EINVAL;
-	if (t->cmd == cmd && t >= additional_ioctls &&
-	    (unsigned long)t < ((unsigned long)additional_ioctls) + PAGE_SIZE) {
-		ioctl32_hash_table[hash] = t->next;
-		t->cmd = 0;
-		return 0;
-	} else while (t->next) {
-		t1 = (struct ioctl_trans *)t->next;
-		if (t1->cmd == cmd && t1 >= additional_ioctls &&
-		    (unsigned long)t1 < ((unsigned long)additional_ioctls) + PAGE_SIZE) {
-			t1->cmd = 0;
-			t->next = t1->next;
-			return 0;
-		}
-		t = t1;
-	}
-	return -EINVAL;
-}
-
-asmlinkage int sys32_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
-	struct file * filp;
-	int error = -EBADF;
-	int (*handler)(unsigned int, unsigned int, unsigned long, struct file * filp);
-	struct ioctl_trans *t;
-
-	filp = fget(fd);
-	if (!filp)
-		goto out2;
-
-	if (!filp->f_op || !filp->f_op->ioctl) {
-		error = sys_ioctl (fd, cmd, arg);
-		goto out;
-	}
-
-	t = (struct ioctl_trans *)ioctl32_hash_table [ioctl32_hash (cmd)];
-
-	while (t && t->cmd != cmd)
-		t = (struct ioctl_trans *)t->next;
-	if (t) {
-		handler = (void *)t->handler;
-		error = handler(fd, cmd, arg, filp);
-	} else {
-		static int count = 0;
-		if (++count <= 20)
-			printk("sys32_ioctl(%s:%d): Unknown cmd fd(%d) "
-			       "cmd(%08x) arg(%08x)\n",
-			       current->comm, current->pid,
-			       (int)fd, (unsigned int)cmd, (unsigned int)arg);
-		error = -EINVAL;
-	}
-out:
-	fput(filp);
-out2:
-	return error;
-}
diff -Nru a/arch/ppc64/kernel/misc.S b/arch/ppc64/kernel/misc.S
--- a/arch/ppc64/kernel/misc.S	Wed Apr 30 22:28:16 2003
+++ b/arch/ppc64/kernel/misc.S	Wed Apr 30 22:28:16 2003
@@ -556,8 +556,8 @@
 	.llong .sys_acct
 	.llong .sys32_umount
 	.llong .sys_ni_syscall		/* old lock syscall */
-	.llong .sys32_ioctl
-	.llong .compat_sys_fcntl	/* 55 */
+	.llong .compat_sys_ioctl
+	.llong .compat_sys_fcntl		/* 55 */
 	.llong .sys_ni_syscall		/* old mpx syscall */
 	.llong .sys32_setpgid
 	.llong .sys_ni_syscall		/* old ulimit syscall */
diff -Nru a/arch/ppc64/kernel/setup.c b/arch/ppc64/kernel/setup.c
--- a/arch/ppc64/kernel/setup.c	Wed Apr 30 22:28:09 2003
+++ b/arch/ppc64/kernel/setup.c	Wed Apr 30 22:28:09 2003
@@ -17,7 +17,7 @@
 #include <linux/init.h>
 #include <linux/reboot.h>
 #include <linux/delay.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/ide.h>
 #include <linux/seq_file.h>
 #include <linux/ioport.h>
diff -Nru a/arch/ppc64/kernel/sys_ppc32.c b/arch/ppc64/kernel/sys_ppc32.c
--- a/arch/ppc64/kernel/sys_ppc32.c	Wed Apr 30 22:28:12 2003
+++ b/arch/ppc64/kernel/sys_ppc32.c	Wed Apr 30 22:28:12 2003
@@ -910,7 +910,6 @@
 #define ca32_export	u.u32_export
 #define ca32_getfd	u.u32_getfd
 #define ca32_getfs	u.u32_getfs
-#define ca32_authd	u.u32_authd
 };
 
 union nfsctl_res32 {
diff -Nru a/arch/s390/Kconfig b/arch/s390/Kconfig
--- a/arch/s390/Kconfig	Wed Apr 30 22:28:08 2003
+++ b/arch/s390/Kconfig	Wed Apr 30 22:28:08 2003
@@ -60,7 +60,7 @@
 
 	  See also the <file:Documentation/smp.tex>,
 	  <file:Documentation/smp.txt> and the SMP-HOWTO available at
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  Even if you don't know what to do here, say Y.
 
@@ -226,7 +226,7 @@
 	  want to say Y here.
 
 	  Information about ELF is contained in the ELF HOWTO available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you find that after upgrading from Linux kernel 1.2 and saying Y
 	  here, you still can't run any ELF binaries (they just crash), then
@@ -248,7 +248,7 @@
 	  programs that need an interpreter to run like Java, Python or
 	  Emacs-Lisp. It's also useful if you often run DOS executables under
 	  the Linux DOS emulator DOSEMU (read the DOSEMU-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>). Once you have
+	  <http://www.tldp.org/docs.html#howto>). Once you have
 	  registered such a binary class with the kernel, you can start one of
 	  those programs simply by typing in its name at a shell prompt; Linux
 	  will automatically feed it to the correct interpreter.
diff -Nru a/arch/s390/kernel/compat_ioctl.c b/arch/s390/kernel/compat_ioctl.c
--- a/arch/s390/kernel/compat_ioctl.c	Wed Apr 30 22:28:11 2003
+++ b/arch/s390/kernel/compat_ioctl.c	Wed Apr 30 22:28:11 2003
@@ -972,113 +972,3 @@
 
 #define NR_IOCTL32_HANDLERS	(sizeof(ioctl32_handler_table) /	\
 				 sizeof(ioctl32_handler_table[0]))
-
-static struct ioctl32_list *ioctl32_hash_table[1024];
-
-static inline int ioctl32_hash(unsigned int cmd)
-{
-	return ((cmd >> 6) ^ (cmd >> 4) ^ cmd) & 0x3ff;
-}
-
-int sys32_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
-	int (*handler)(unsigned int, unsigned int, unsigned long, struct file * filp);
-	struct file *filp;
-	struct ioctl32_list *l;
-	int error;
-
-	l = ioctl32_hash_table[ioctl32_hash(cmd)];
-
-	error = -EBADF;
-
-	filp = fget(fd);
-	if (!filp)
-		return error;
-
-	if (!filp->f_op || !filp->f_op->ioctl) {
-		error = sys_ioctl (fd, cmd, arg);
-		goto out;
-	}
-
-	while (l && l->handler.cmd != cmd)
-		l = l->next;
-
-	if (l) {
-		handler = (void *)l->handler.function;
-		error = handler(fd, cmd, arg, filp);
-	} else {
-		error = -EINVAL;
-		printk("unknown ioctl: %08x\n", cmd);
-	}
-out:
-	fput(filp);
-	return error;
-}
-
-static void ioctl32_insert(struct ioctl32_list *entry)
-{
-	int hash = ioctl32_hash(entry->handler.cmd);
-
-	entry->next = 0;
-	if (!ioctl32_hash_table[hash])
-		ioctl32_hash_table[hash] = entry;
-	else {
-		struct ioctl32_list *l;
-		l = ioctl32_hash_table[hash];
-		while (l->next)
-			l = l->next;
-		l->next = entry;
-	}
-}
-
-int register_ioctl32_conversion(unsigned int cmd,
-				int (*handler)(unsigned int, unsigned int,
-					       unsigned long, struct file *))
-{
-	struct ioctl32_list *l, *new;
-	int hash;
-
-	hash = ioctl32_hash(cmd);
-	for (l = ioctl32_hash_table[hash]; l != NULL; l = l->next)
-		if (l->handler.cmd == cmd)
-			return -EBUSY;
-	new = kmalloc(sizeof(struct ioctl32_list), GFP_KERNEL);
-	if (new == NULL)
-		return -ENOMEM;
-	new->handler.cmd = cmd;
-	new->handler.function = (void *) handler;
-	ioctl32_insert(new);
-	return 0;
-}
-
-int unregister_ioctl32_conversion(unsigned int cmd)
-{
-	struct ioctl32_list *p, *l;
-	int hash;
-
-	hash = ioctl32_hash(cmd);
-	p = NULL;
-	for (l = ioctl32_hash_table[hash]; l != NULL; l = l->next) {
-		if (l->handler.cmd == cmd)
-			break;
-		p = l;
-	}
-	if (l == NULL)
-		return -ENOENT;
-	if (p == NULL)
-		ioctl32_hash_table[hash] = l->next;
-	else
-		p->next = l->next;
-	kfree(l);
-	return 0;
-}
-
-static int __init init_ioctl32(void)
-{
-	int i;
-	for (i = 0; i < NR_IOCTL32_HANDLERS; i++)
-		ioctl32_insert(&ioctl32_handler_table[i]);
-	return 0;
-}
-
-__initcall(init_ioctl32);
diff -Nru a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
--- a/arch/s390/kernel/setup.c	Wed Apr 30 22:28:04 2003
+++ b/arch/s390/kernel/setup.c	Wed Apr 30 22:28:04 2003
@@ -29,9 +29,7 @@
 #include <linux/delay.h>
 #include <linux/config.h>
 #include <linux/init.h>
-#ifdef CONFIG_BLK_DEV_RAM
-#include <linux/blk.h>
-#endif
+#include <linux/initrd.h>
 #include <linux/bootmem.h>
 #include <linux/root_dev.h>
 #include <linux/console.h>
diff -Nru a/arch/sh/Kconfig b/arch/sh/Kconfig
--- a/arch/sh/Kconfig	Wed Apr 30 22:28:19 2003
+++ b/arch/sh/Kconfig	Wed Apr 30 22:28:19 2003
@@ -483,7 +483,7 @@
 	  VESA. If you have PCI, say Y, otherwise N.
 
 	  The PCI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, contains valuable
+	  <http://www.tldp.org/docs.html#howto>, contains valuable
 	  information about which PCI hardware does work under Linux and which
 	  doesn't.
 
@@ -608,7 +608,7 @@
 	  want to say Y here.
 
 	  Information about ELF is contained in the ELF HOWTO available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you find that after upgrading from Linux kernel 1.2 and saying Y
 	  here, you still can't run any ELF binaries (they just crash), then
@@ -630,7 +630,7 @@
 	  programs that need an interpreter to run like Java, Python or
 	  Emacs-Lisp. It's also useful if you often run DOS executables under
 	  the Linux DOS emulator DOSEMU (read the DOSEMU-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>). Once you have
+	  <http://www.tldp.org/docs.html#howto>). Once you have
 	  registered such a binary class with the kernel, you can start one of
 	  those programs simply by typing in its name at a shell prompt; Linux
 	  will automatically feed it to the correct interpreter.
@@ -748,7 +748,7 @@
 	---help---
 	  If you have a CD-ROM drive that is neither SCSI nor IDE/ATAPI, say Y
 	  here, otherwise N. Read the CD-ROM-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  Note that the answer to this question doesn't directly affect the
 	  kernel: saying N will just cause the configurator to skip all
@@ -980,7 +980,7 @@
 	  box (as opposed to using a serial printer; if the connector at the
 	  printer has 9 or 25 holes ["female"], then it's serial), say Y.
 	  Also read the Printing-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  It is possible to share one parallel port among several devices
 	  (e.g. printer and ZIP drive) and it is safe to compile the
@@ -1049,7 +1049,7 @@
 
 	  Although PS/2 mice are not technically bus mice, they are explained
 	  in detail in the Busmouse-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  When using a PS/2 mouse, you can get problems if you want to use the
 	  mouse both on the Linux console and under X. Using the "-R" option
@@ -1157,7 +1157,7 @@
 	  interrupt and DMA channel), because you will be asked for it.
 
 	  You want to read the Sound-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. General information about
+	  <http://www.tldp.org/docs.html#howto>. General information about
 	  the modular sound system is contained in the files
 	  <file:Documentation/sound/Introduction>.  The file
 	  <file:Documentation/sound/README.OSS> contains some slightly
diff -Nru a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
--- a/arch/sh/kernel/setup.c	Wed Apr 30 22:28:11 2003
+++ b/arch/sh/kernel/setup.c	Wed Apr 30 22:28:11 2003
@@ -25,9 +25,7 @@
 #include <linux/delay.h>
 #include <linux/config.h>
 #include <linux/init.h>
-#ifdef CONFIG_BLK_DEV_RAM
-#include <linux/blk.h>
-#endif
+#include <linux/initrd.h>
 #include <linux/bootmem.h>
 #include <linux/console.h>
 #include <linux/ctype.h>
@@ -141,12 +139,6 @@
     	sh_bios_console_write(s, count);
 }
 
-static kdev_t sh_console_device(struct console *c)
-{
-	/* /dev/null */
-	return mk_kdev(MEM_MAJOR, 3);
-}
-
 /*
  *	Setup initial baud/bits/parity. We do two things here:
  *	- construct a cflag setting for the first rs_open()
@@ -173,7 +165,6 @@
 static struct console sh_console = {
 	.name		= "bios",
 	.write		= sh_console_write,
-	.device		= sh_console_device,
 	.setup		= sh_console_setup,
 	.flags		= CON_PRINTBUFFER,
 	.index		= -1,
diff -Nru a/arch/sparc/Kconfig b/arch/sparc/Kconfig
--- a/arch/sparc/Kconfig	Wed Apr 30 22:28:02 2003
+++ b/arch/sparc/Kconfig	Wed Apr 30 22:28:02 2003
@@ -106,7 +106,7 @@
 	  See also the <file:Documentation/smp.tex>,
 	  <file:Documentation/smp.txt>, <file:Documentation/i386/IO-APIC.txt>,
 	  <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you don't know what to do here, say N.
 
@@ -160,7 +160,7 @@
 	  To use your PC-cards, you will need supporting software from David
 	  Hinds' pcmcia-cs package (see the file <file:Documentation/Changes>
 	  for location).  Please also read the PCMCIA-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -314,7 +314,7 @@
 	  want to say Y here.
 
 	  Information about ELF is contained in the ELF HOWTO available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you find that after upgrading from Linux kernel 1.2 and saying Y
 	  here, you still can't run any ELF binaries (they just crash), then
@@ -336,7 +336,7 @@
 	  programs that need an interpreter to run like Java, Python or
 	  Emacs-Lisp. It's also useful if you often run DOS executables under
 	  the Linux DOS emulator DOSEMU (read the DOSEMU-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>). Once you have
+	  <http://www.tldp.org/docs.html#howto>). Once you have
 	  registered such a binary class with the kernel, you can start one of
 	  those programs simply by typing in its name at a shell prompt; Linux
 	  will automatically feed it to the correct interpreter.
@@ -372,7 +372,7 @@
 	  box (as opposed to using a serial printer; if the connector at the
 	  printer has 9 or 25 holes ["female"], then it's serial), say Y.
 	  Also read the Printing-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  It is possible to share one parallel port among several devices
 	  (e.g. printer and ZIP drive) and it is safe to compile the
@@ -636,7 +636,7 @@
 	  If you want to use a SCSI hard disk or the SCSI or parallel port
 	  version of the IOMEGA ZIP drive under Linux, say Y and read the
 	  SCSI-HOWTO, the Disk-HOWTO and the Multi-Disk-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. This is NOT for SCSI
+	  <http://www.tldp.org/docs.html#howto>. This is NOT for SCSI
 	  CD-ROMs.
 
 	  This driver is also available as a module ( = code which can be
@@ -671,7 +671,7 @@
 	---help---
 	  If you want to use a SCSI tape drive under Linux, say Y and read the
 	  SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, and
+	  <http://www.tldp.org/docs.html#howto>, and
 	  <file:Documentation/scsi/st.txt> in the kernel source.  This is NOT
 	  for SCSI CD-ROMs.
 
@@ -693,7 +693,7 @@
 	  tape drives (ADR-x0) that supports the standard SCSI-2 commands for
 	  tapes (QIC-157) and can be driven by the standard driver st.
 	  For more information, you may have a look at the SCSI-HOWTO
-	  <http://www.linuxdoc.org/docs.html#howto>  and
+	  <http://www.tldp.org/docs.html#howto>  and
 	  <file:Documentation/scsi/osst.txt>  in the kernel source.
 	  More info on the OnStream driver may be found on
 	  <http://linux1.onstream.nl/test/>
@@ -712,7 +712,7 @@
 	---help---
 	  If you want to use a SCSI CD-ROM under Linux, say Y and read the
 	  SCSI-HOWTO and the CD-ROM-HOWTO at
-	  <http://www.linuxdoc.org/docs.html#howto>. Also make sure to say Y
+	  <http://www.tldp.org/docs.html#howto>. Also make sure to say Y
 	  or M to "ISO 9660 CD-ROM file system support" later.
 
 	  This driver is also available as a module ( = code which can be
@@ -925,7 +925,7 @@
 	  interrupt and DMA channel), because you will be asked for it.
 
 	  You want to read the Sound-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. General information about
+	  <http://www.tldp.org/docs.html#howto>. General information about
 	  the modular sound system is contained in the files
 	  <file:Documentation/sound/Introduction>.  The file
 	  <file:Documentation/sound/README.OSS> contains some slightly
diff -Nru a/arch/sparc/kernel/auxio.c b/arch/sparc/kernel/auxio.c
--- a/arch/sparc/kernel/auxio.c	Wed Apr 30 22:28:12 2003
+++ b/arch/sparc/kernel/auxio.c	Wed Apr 30 22:28:12 2003
@@ -6,13 +6,19 @@
 #include <linux/stddef.h>
 #include <linux/init.h>
 #include <linux/config.h>
+#include <linux/spinlock.h>
 #include <asm/oplib.h>
 #include <asm/io.h>
 #include <asm/auxio.h>
 #include <asm/string.h>		/* memset(), Linux has no bzero() */
 
 /* Probe and map in the Auxiliary I/O register */
-unsigned char *auxio_register;
+
+/* auxio_register is not static because it is referenced 
+ * in entry.S::floppy_tdone
+ */
+unsigned long auxio_register = 0UL;
+static spinlock_t auxio_lock = SPIN_LOCK_UNLOCKED;
 
 void __init auxio_probe(void)
 {
@@ -23,7 +29,6 @@
 	switch (sparc_cpu_model) {
 	case sun4d:
 	case sun4:
-		auxio_register = 0;
 		return;
 	default:
 		break;
@@ -37,12 +42,10 @@
 		if(!auxio_nd) {
 #ifdef CONFIG_PCI
 			/* There may be auxio on Ebus */
-			auxio_register = 0;
 			return;
 #else
 			if(prom_searchsiblings(node, "leds")) {
 				/* VME chassis sun4m machine, no auxio exists. */
-				auxio_register = 0;
 				return;
 			}
 			prom_printf("Cannot find auxio node, cannot continue...\n");
@@ -56,14 +59,46 @@
 	r.flags = auxregs[0].which_io & 0xF;
 	r.start = auxregs[0].phys_addr;
 	r.end = auxregs[0].phys_addr + auxregs[0].reg_size - 1;
-	auxio_register = (unsigned char *) sbus_ioremap(&r, 0,
-	    auxregs[0].reg_size, "auxio");
+	auxio_register = sbus_ioremap(&r, 0, auxregs[0].reg_size, "auxio");
 	/* Fix the address on sun4m and sun4c. */
 	if((((unsigned long) auxregs[0].phys_addr) & 3) == 3 ||
 	   sparc_cpu_model == sun4c)
-		auxio_register = (unsigned char *) ((int)auxio_register | 3);
+		auxio_register |= 3;
+
+	set_auxio(AUXIO_LED, 0);
+}
 
-	TURN_ON_LED;
+unsigned char get_auxio(void)
+{
+	if(auxio_register) 
+		return sbus_readb(auxio_register);
+	return 0;
+}
+
+void set_auxio(unsigned char bits_on, unsigned char bits_off)
+{
+	unsigned char regval;
+	unsigned long flags;
+	spin_lock_irqsave(&auxio_lock, flags);
+	switch(sparc_cpu_model) {
+	case sun4c:
+		regval = sbus_readb(auxio_register);
+		sbus_writeb(((regval | bits_on) & ~bits_off) | AUXIO_ORMEIN,
+			auxio_register);
+		break;
+	case sun4m:
+		if(!auxio_register)
+			break;     /* VME chassic sun4m, no auxio. */
+		regval = sbus_readb(auxio_register);
+		sbus_writeb(((regval | bits_on) & ~bits_off) | AUXIO_ORMEIN4M,
+			auxio_register);
+		break;
+	case sun4d:
+		break;
+	default:
+		panic("Can't set AUXIO register on this machine.");
+	};
+	spin_unlock_irqrestore(&auxio_lock, flags);
 }
 
 
diff -Nru a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
--- a/arch/sparc/kernel/entry.S	Wed Apr 30 22:28:09 2003
+++ b/arch/sparc/kernel/entry.S	Wed Apr 30 22:28:09 2003
@@ -40,6 +40,14 @@
 
 #define NR_SYSCALLS 256      /* Each OS is different... */
 
+/* These are just handy. */
+#define _SV	save	%sp, -STACKFRAME_SZ, %sp
+#define _RS     restore 
+
+#define FLUSH_ALL_KERNEL_WINDOWS \
+	_SV; _SV; _SV; _SV; _SV; _SV; _SV; \
+	_RS; _RS; _RS; _RS; _RS; _RS; _RS;
+
 /* First, KGDB low level things.  This is a rewrite
  * of the routines found in the sparc-stub.c asm() statement
  * from the gdb distribution.  This is also dual-purpose
@@ -73,11 +81,11 @@
 	/* Make sure kgdb sees the same state we just saved. */
 	LOAD_PT_GLOBALS(sp)
 	LOAD_PT_INS(sp)
-	ld	[%sp + REGWIN_SZ + PT_Y], %l4
-	ld	[%sp + REGWIN_SZ + PT_WIM], %l3
-	ld	[%sp + REGWIN_SZ + PT_PSR], %l0
-	ld	[%sp + REGWIN_SZ + PT_PC], %l1
-	ld	[%sp + REGWIN_SZ + PT_NPC], %l2
+	ld	[%sp + STACKFRAME_SZ + PT_Y], %l4
+	ld	[%sp + STACKFRAME_SZ + PT_WIM], %l3
+	ld	[%sp + STACKFRAME_SZ + PT_PSR], %l0
+	ld	[%sp + STACKFRAME_SZ + PT_PC], %l1
+	ld	[%sp + STACKFRAME_SZ + PT_NPC], %l2
 	rd	%tbr, %l5	/* Never changes... */
 
 	/* Make kgdb exception frame. */	
@@ -97,7 +105,7 @@
 	WRITE_PAUSE
 
 	call	C_LABEL(handle_exception)
-	 add	%sp, REGWIN_SZ, %o0	! Pass address of registers
+	 add	%sp, STACKFRAME_SZ, %o0	! Pass address of registers
 
 	/* Load new kgdb register set. */
 	LOAD_KGDB_GLOBALS(sp)
@@ -266,7 +274,7 @@
 	mov	11, %o0			! floppy irq level (unused anyway)
 	mov	%g0, %o1		! devid is not used in fast interrupts
 	call	C_LABEL(sparc_floppy_irq)
-	 add	%sp, REGWIN_SZ, %o2	! struct pt_regs *regs
+	 add	%sp, STACKFRAME_SZ, %o2	! struct pt_regs *regs
 
 	RESTORE_ALL
 	
@@ -315,7 +323,7 @@
 	mov	%l7, %o0		! irq level
 patch_handler_irq:
 	call	C_LABEL(handler_irq)
-	 add	%sp, REGWIN_SZ, %o1	! pt_regs ptr
+	 add	%sp, STACKFRAME_SZ, %o1	! pt_regs ptr
 	or	%l0, PSR_PIL, %g2	! restore PIL after handler_irq
 	wr	%g2, PSR_ET, %psr	! keep ET up
 	WRITE_PAUSE
@@ -332,7 +340,7 @@
 	wr	%g2, PSR_ET, %psr
 	WRITE_PAUSE
 	call	C_LABEL(smp4m_percpu_timer_interrupt)
-	 add	%sp, REGWIN_SZ, %o0
+	 add	%sp, STACKFRAME_SZ, %o0
 	wr	%l0, PSR_ET, %psr
 	WRITE_PAUSE
 	RESTORE_ALL
@@ -439,7 +447,7 @@
 	wr	%g2, PSR_ET, %psr
 	WRITE_PAUSE
 	call	C_LABEL(smp4d_percpu_timer_interrupt)
-	 add	%sp, REGWIN_SZ, %o0
+	 add	%sp, STACKFRAME_SZ, %o0
 	wr	%l0, PSR_ET, %psr
 	WRITE_PAUSE
 	RESTORE_ALL
@@ -501,7 +509,7 @@
 	wr	%l0, PSR_ET, %psr		! re-enable traps
 	WRITE_PAUSE
 
-	add	%sp, REGWIN_SZ, %o0
+	add	%sp, STACKFRAME_SZ, %o0
 	mov	%l1, %o1
 	mov	%l2, %o2
 	call	C_LABEL(do_illegal_instruction)
@@ -521,7 +529,7 @@
 	wr	%l0, PSR_ET, %psr
 	WRITE_PAUSE
 
-	add	%sp, REGWIN_SZ, %o0
+	add	%sp, STACKFRAME_SZ, %o0
 	mov	%l1, %o1
 	mov	%l2, %o2
 	call	C_LABEL(do_priv_instruction)
@@ -544,7 +552,7 @@
 
 	ld	[%l1], %o1
 	call	C_LABEL(kernel_unaligned_trap)
-	 add	%sp, REGWIN_SZ, %o0
+	 add	%sp, STACKFRAME_SZ, %o0
 
 	RESTORE_ALL
 
@@ -556,7 +564,7 @@
 
 	ld	[%l1], %o1
 	call	C_LABEL(user_unaligned_trap)
-	 add	%sp, REGWIN_SZ, %o0
+	 add	%sp, STACKFRAME_SZ, %o0
 
 	RESTORE_ALL
 
@@ -569,7 +577,7 @@
 	wr	%l0, PSR_ET, %psr		! re-enable traps
 	WRITE_PAUSE
 
-	add	%sp, REGWIN_SZ, %o0
+	add	%sp, STACKFRAME_SZ, %o0
 	mov	%l1, %o1
 	mov	%l2, %o2
 	call	C_LABEL(do_fpd_trap)
@@ -608,7 +616,7 @@
 	wr	%l0, PSR_ET, %psr		! re-enable traps
 	WRITE_PAUSE
 
-	add	%sp, REGWIN_SZ, %o0
+	add	%sp, STACKFRAME_SZ, %o0
 	mov	%l1, %o1
 	mov	%l2, %o2
 	call	C_LABEL(do_fpe_trap)
@@ -625,7 +633,7 @@
 	wr	%l0, PSR_ET, %psr		! re-enable traps
 	WRITE_PAUSE
 
-	add	%sp, REGWIN_SZ, %o0
+	add	%sp, STACKFRAME_SZ, %o0
 	mov	%l1, %o1
 	mov	%l2, %o2
 	call	C_LABEL(handle_tag_overflow)
@@ -642,7 +650,7 @@
 	wr	%l0, PSR_ET, %psr		! re-enable traps
 	WRITE_PAUSE
 
-	add	%sp, REGWIN_SZ, %o0
+	add	%sp, STACKFRAME_SZ, %o0
 	mov	%l1, %o1
 	mov	%l2, %o2
 	call	C_LABEL(handle_watchpoint)
@@ -659,7 +667,7 @@
 	wr	%l0, PSR_ET, %psr		! re-enable traps
 	WRITE_PAUSE
 
-	add	%sp, REGWIN_SZ, %o0
+	add	%sp, STACKFRAME_SZ, %o0
 	mov	%l1, %o1
 	mov	%l2, %o2
 	call	C_LABEL(handle_reg_access)
@@ -676,7 +684,7 @@
 	wr	%l0, PSR_ET, %psr		! re-enable traps
 	WRITE_PAUSE
 
-	add	%sp, REGWIN_SZ, %o0
+	add	%sp, STACKFRAME_SZ, %o0
 	mov	%l1, %o1
 	mov	%l2, %o2
 	call	C_LABEL(handle_cp_disabled)
@@ -693,7 +701,7 @@
 	wr	%l0, PSR_ET, %psr		! re-enable traps
 	WRITE_PAUSE
 
-	add	%sp, REGWIN_SZ, %o0
+	add	%sp, STACKFRAME_SZ, %o0
 	mov	%l1, %o1
 	mov	%l2, %o2
 	call	C_LABEL(handle_cp_exception)
@@ -710,7 +718,7 @@
 	wr	%l0, PSR_ET, %psr		! re-enable traps
 	WRITE_PAUSE
 
-	add	%sp, REGWIN_SZ, %o0
+	add	%sp, STACKFRAME_SZ, %o0
 	mov	%l1, %o1
 	mov	%l2, %o2
 	call	C_LABEL(handle_hw_divzero)
@@ -734,10 +742,10 @@
 	 nop
 
 	/* Advance over the trap instruction. */
-	ld	[%sp + REGWIN_SZ + PT_NPC], %l1
+	ld	[%sp + STACKFRAME_SZ + PT_NPC], %l1
 	add	%l1, 0x4, %l2
-	st	%l1, [%sp + REGWIN_SZ + PT_PC]
-	st	%l2, [%sp + REGWIN_SZ + PT_NPC]
+	st	%l1, [%sp + STACKFRAME_SZ + PT_PC]
+	st	%l2, [%sp + STACKFRAME_SZ + PT_NPC]
 
 	RESTORE_ALL
 
@@ -749,10 +757,10 @@
 	FLUSH_ALL_KERNEL_WINDOWS
 
 	/* Advance over the trap instruction. */
-	ld	[%sp + REGWIN_SZ + PT_NPC], %l1
+	ld	[%sp + STACKFRAME_SZ + PT_NPC], %l1
 	add	%l1, 0x4, %l2
-	st	%l1, [%sp + REGWIN_SZ + PT_PC]
-	st	%l2, [%sp + REGWIN_SZ + PT_NPC]
+	st	%l1, [%sp + STACKFRAME_SZ + PT_PC]
+	st	%l2, [%sp + STACKFRAME_SZ + PT_NPC]
 
 	RESTORE_ALL
 
@@ -821,7 +829,7 @@
 	sub	%o0, 0x4, %o0
 	lda	[%o0] ASI_CONTROL, %o3	! async error
 	call	C_LABEL(sparc_lvl15_nmi)
-	 add	%sp, REGWIN_SZ, %o0
+	 add	%sp, STACKFRAME_SZ, %o0
 
 	RESTORE_ALL
 
@@ -1155,7 +1163,7 @@
 	WRITE_PAUSE
 
 	call	C_LABEL(do_sun4c_fault)
-	 add	%sp, REGWIN_SZ, %o0	! arg1 = pt_regs ptr
+	 add	%sp, STACKFRAME_SZ, %o0	! arg1 = pt_regs ptr
 
 	RESTORE_ALL
 
@@ -1189,7 +1197,7 @@
 	WRITE_PAUSE
 
 	call	C_LABEL(do_sparc_fault)
-	 add	%sp, REGWIN_SZ, %o0	! arg1 = pt_regs ptr
+	 add	%sp, STACKFRAME_SZ, %o0	! arg1 = pt_regs ptr
 
 	RESTORE_ALL
 
@@ -1227,7 +1235,7 @@
 	.globl	C_LABEL(sys_nis_syscall)
 C_LABEL(sys_nis_syscall):
 	mov	%o7, %l5
-	add	%sp, REGWIN_SZ, %o0		! pt_regs *regs arg
+	add	%sp, STACKFRAME_SZ, %o0		! pt_regs *regs arg
 	call	C_LABEL(c_sys_nis_syscall)
 	 mov	%l5, %o7
 
@@ -1235,7 +1243,7 @@
 	.globl	C_LABEL(sys_ptrace)
 C_LABEL(sys_ptrace):
 	call	C_LABEL(do_ptrace)
-	 add	%sp, REGWIN_SZ, %o0
+	 add	%sp, STACKFRAME_SZ, %o0
 
 	ld	[%curptr + TI_TASK], %l5
 	ld	[%l5 + AOFF_task_ptrace], %l5
@@ -1253,7 +1261,7 @@
 	.globl	C_LABEL(sys_execve)
 C_LABEL(sys_execve):
 	mov	%o7, %l5
-	add	%sp, REGWIN_SZ, %o0		! pt_regs *regs arg
+	add	%sp, STACKFRAME_SZ, %o0		! pt_regs *regs arg
 	call	C_LABEL(sparc_execve)
 	 mov	%l5, %o7
 
@@ -1261,7 +1269,7 @@
 	.globl	C_LABEL(sys_pipe)
 C_LABEL(sys_pipe):
 	mov	%o7, %l5
-	add	%sp, REGWIN_SZ, %o0		! pt_regs *regs arg
+	add	%sp, STACKFRAME_SZ, %o0		! pt_regs *regs arg
 	call	C_LABEL(sparc_pipe)
 	 mov	%l5, %o7
 
@@ -1286,7 +1294,7 @@
 C_LABEL(sys_sigpause):
 	/* Note: %o0 already has correct value... */
 	call	C_LABEL(do_sigpause)
-	 add	%sp, REGWIN_SZ, %o1
+	 add	%sp, STACKFRAME_SZ, %o1
 
 	ld	[%curptr + TI_TASK], %l5
 	ld	[%l5 + AOFF_task_ptrace], %l5
@@ -1305,7 +1313,7 @@
 	.globl	C_LABEL(sys_sigsuspend)
 C_LABEL(sys_sigsuspend):
 	call	C_LABEL(do_sigsuspend)
-	 add	%sp, REGWIN_SZ, %o0
+	 add	%sp, STACKFRAME_SZ, %o0
 
 	ld	[%curptr + TI_TASK], %l5
 	ld	[%l5 + AOFF_task_ptrace], %l5
@@ -1325,7 +1333,7 @@
 C_LABEL(sys_rt_sigsuspend):
 	/* Note: %o0, %o1 already have correct value... */
 	call	C_LABEL(do_rt_sigsuspend)
-	 add	%sp, REGWIN_SZ, %o2
+	 add	%sp, STACKFRAME_SZ, %o2
 
 	ld	[%curptr + TI_TASK], %l5
 	ld	[%l5 + AOFF_task_ptrace], %l5
@@ -1344,7 +1352,7 @@
 	.globl	C_LABEL(sys_sigreturn)
 C_LABEL(sys_sigreturn):
 	call	C_LABEL(do_sigreturn)
-	 add	%sp, REGWIN_SZ, %o0
+	 add	%sp, STACKFRAME_SZ, %o0
 
 	ld	[%curptr + TI_TASK], %l5
 	ld	[%l5 + AOFF_task_ptrace], %l5
@@ -1365,7 +1373,7 @@
 	.globl	C_LABEL(sys_rt_sigreturn)
 C_LABEL(sys_rt_sigreturn):
 	call	C_LABEL(do_rt_sigreturn)
-	 add	%sp, REGWIN_SZ, %o0
+	 add	%sp, STACKFRAME_SZ, %o0
 
 	ld	[%curptr + TI_TASK], %l5
 	ld	[%l5 + AOFF_task_ptrace], %l5
@@ -1401,7 +1409,7 @@
 	WRITE_PAUSE
 	mov	%fp, %o1			! arg1:	usp
 	std	%g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
-	add	%sp, REGWIN_SZ, %o2		! arg2:	pt_regs ptr
+	add	%sp, STACKFRAME_SZ, %o2		! arg2:	pt_regs ptr
 	mov	0, %o3
 	call	C_LABEL(sparc_do_fork)
 	 mov	%l5, %o7
@@ -1425,7 +1433,7 @@
 	andn	%o1, 7, %o1			! no, align to 8 bytes
 1:
 	std	%g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
-	add	%sp, REGWIN_SZ, %o2		! arg2:	pt_regs ptr
+	add	%sp, STACKFRAME_SZ, %o2		! arg2:	pt_regs ptr
 	mov	0, %o3
 	call	C_LABEL(sparc_do_fork)
 	 mov	%l5, %o7
@@ -1447,7 +1455,7 @@
 	sethi	%hi(C_LABEL(sparc_do_fork)), %l1
 	mov	0, %o3
 	jmpl	%l1 + %lo(C_LABEL(sparc_do_fork)), %g0
-	 add	%sp, REGWIN_SZ, %o2
+	 add	%sp, STACKFRAME_SZ, %o2
 
         .align  4
 linux_sparc_ni_syscall:
@@ -1478,7 +1486,7 @@
 	call	schedule_tail
 	 mov	%g3, %o0
 	b	C_LABEL(ret_sys_call)
-	 ld	[%sp + REGWIN_SZ + PT_I0], %o0
+	 ld	[%sp + STACKFRAME_SZ + PT_I0], %o0
 
 	/* Linux native and SunOS system calls enter here... */
 	.align	4
@@ -1514,14 +1522,14 @@
 	call	%l7
 	 mov	%i5, %o5
 
-	st	%o0, [%sp + REGWIN_SZ + PT_I0]
+	st	%o0, [%sp + STACKFRAME_SZ + PT_I0]
 
 	.globl	C_LABEL(ret_sys_call)
 C_LABEL(ret_sys_call):
 	ld	[%curptr + TI_TASK], %l6
 	ld	[%l6 + AOFF_task_ptrace], %l6
 	cmp	%o0, -ENOIOCTLCMD
-	ld	[%sp + REGWIN_SZ + PT_PSR], %g3
+	ld	[%sp + STACKFRAME_SZ + PT_PSR], %g3
 	set	PSR_C, %g2
 	bgeu	1f
 	 andcc	%l6, 0x02, %l6	
@@ -1529,35 +1537,35 @@
 	/* System call success, clear Carry condition code. */
 	andn	%g3, %g2, %g3
 	clr	%l6
-	st	%g3, [%sp + REGWIN_SZ + PT_PSR]	
+	st	%g3, [%sp + STACKFRAME_SZ + PT_PSR]	
 	bne	linux_syscall_trace2
-	 ld	[%sp + REGWIN_SZ + PT_NPC], %l1 /* pc = npc */
+	 ld	[%sp + STACKFRAME_SZ + PT_NPC], %l1 /* pc = npc */
 	add	%l1, 0x4, %l2			/* npc = npc+4 */
-	st	%l1, [%sp + REGWIN_SZ + PT_PC]
+	st	%l1, [%sp + STACKFRAME_SZ + PT_PC]
 	b	ret_trap_entry
-	 st	%l2, [%sp + REGWIN_SZ + PT_NPC]
+	 st	%l2, [%sp + STACKFRAME_SZ + PT_NPC]
 1:
 	/* System call failure, set Carry condition code.
 	 * Also, get abs(errno) to return to the process.
 	 */
 	sub	%g0, %o0, %o0
 	or	%g3, %g2, %g3
-	st	%o0, [%sp + REGWIN_SZ + PT_I0]
+	st	%o0, [%sp + STACKFRAME_SZ + PT_I0]
 	mov	1, %l6
-	st	%g3, [%sp + REGWIN_SZ + PT_PSR]
+	st	%g3, [%sp + STACKFRAME_SZ + PT_PSR]
 	bne	linux_syscall_trace2
-	 ld	[%sp + REGWIN_SZ + PT_NPC], %l1 /* pc = npc */
+	 ld	[%sp + STACKFRAME_SZ + PT_NPC], %l1 /* pc = npc */
 	add	%l1, 0x4, %l2			/* npc = npc+4 */
-	st	%l1, [%sp + REGWIN_SZ + PT_PC]
+	st	%l1, [%sp + STACKFRAME_SZ + PT_PC]
 	b	ret_trap_entry
-	 st	%l2, [%sp + REGWIN_SZ + PT_NPC]
+	 st	%l2, [%sp + STACKFRAME_SZ + PT_NPC]
 
 linux_syscall_trace2:
 	call	C_LABEL(syscall_trace)
 	 add	%l1, 0x4, %l2			/* npc = npc+4 */
-	st	%l1, [%sp + REGWIN_SZ + PT_PC]
+	st	%l1, [%sp + STACKFRAME_SZ + PT_PC]
 	b	ret_trap_entry
-	 st	%l2, [%sp + REGWIN_SZ + PT_NPC]
+	 st	%l2, [%sp + STACKFRAME_SZ + PT_NPC]
 
 
 	/*
@@ -1595,19 +1603,19 @@
 	mov	%i0, %l5
 
 	call	C_LABEL(do_solaris_syscall)
-	 add	%sp, REGWIN_SZ, %o0
+	 add	%sp, STACKFRAME_SZ, %o0
 
-	st	%o0, [%sp + REGWIN_SZ + PT_I0]
+	st	%o0, [%sp + STACKFRAME_SZ + PT_I0]
 	set	PSR_C, %g2
 	cmp	%o0, -ENOIOCTLCMD
 	bgeu	1f
-	 ld	[%sp + REGWIN_SZ + PT_PSR], %g3
+	 ld	[%sp + STACKFRAME_SZ + PT_PSR], %g3
 
 	/* System call success, clear Carry condition code. */		
 	andn	%g3, %g2, %g3
 	clr	%l6
 	b	2f
-	 st	%g3, [%sp + REGWIN_SZ + PT_PSR]	
+	 st	%g3, [%sp + STACKFRAME_SZ + PT_PSR]	
 
 1:
 	/* System call failure, set Carry condition code.
@@ -1615,9 +1623,9 @@
 	 */
 	sub	%g0, %o0, %o0
 	mov	1, %l6
-	st	%o0, [%sp + REGWIN_SZ + PT_I0]
+	st	%o0, [%sp + STACKFRAME_SZ + PT_I0]
 	or	%g3, %g2, %g3
-	st	%g3, [%sp + REGWIN_SZ + PT_PSR]
+	st	%g3, [%sp + STACKFRAME_SZ + PT_PSR]
 
 	/* Advance the pc and npc over the trap instruction.
 	 * If the npc is unaligned (has a 1 in the lower byte), it means
@@ -1626,19 +1634,19 @@
 	 * nPC (setcontext).
 	 */
 2:
-	ld	[%sp + REGWIN_SZ + PT_NPC], %l1	/* pc  = npc   */
+	ld	[%sp + STACKFRAME_SZ + PT_NPC], %l1	/* pc  = npc   */
 	andcc	%l1, 1, %g0
 	bne	1f
 	 add	%l1, 0x4, %l2			/* npc = npc+4 */
-	st	%l1, [%sp + REGWIN_SZ + PT_PC]
+	st	%l1, [%sp + STACKFRAME_SZ + PT_PC]
 	b	ret_trap_entry
-	 st	%l2, [%sp + REGWIN_SZ + PT_NPC]
+	 st	%l2, [%sp + STACKFRAME_SZ + PT_NPC]
 
 	/* kernel knows what it is doing, fixup npc and continue */
 1:
 	sub	%l1, 1, %l1
  	b	ret_trap_entry	
-	 st	%l1, [%sp + REGWIN_SZ + PT_NPC]
+	 st	%l1, [%sp + STACKFRAME_SZ + PT_NPC]
 
 #ifndef CONFIG_SUNOS_EMUL
 	.align	4
@@ -1651,7 +1659,7 @@
 	nop
 	mov	%i0, %l5
 	call	C_LABEL(do_sunos_syscall)
-	 add	%sp, REGWIN_SZ, %o0
+	 add	%sp, STACKFRAME_SZ, %o0
 #endif
 
 	/* {net, open}bsd system calls enter here... */
@@ -1688,17 +1696,17 @@
 	call	%l7
 	 mov	%i5, %o5
 
-	st	%o0, [%sp + REGWIN_SZ + PT_I0]
+	st	%o0, [%sp + STACKFRAME_SZ + PT_I0]
 	set	PSR_C, %g2
 	cmp	%o0, -ENOIOCTLCMD
 	bgeu	1f
-	 ld	[%sp + REGWIN_SZ + PT_PSR], %g3
+	 ld	[%sp + STACKFRAME_SZ + PT_PSR], %g3
 
 	/* System call success, clear Carry condition code. */		
 	andn	%g3, %g2, %g3
 	clr	%l6
 	b	2f
-	 st	%g3, [%sp + REGWIN_SZ + PT_PSR]	
+	 st	%g3, [%sp + STACKFRAME_SZ + PT_PSR]	
 
 1:
 	/* System call failure, set Carry condition code.
@@ -1712,17 +1720,17 @@
 	ld	[%o3 + %o0], %o0
 #endif
 	mov	1, %l6
-	st	%o0, [%sp + REGWIN_SZ + PT_I0]
+	st	%o0, [%sp + STACKFRAME_SZ + PT_I0]
 	or	%g3, %g2, %g3
-	st	%g3, [%sp + REGWIN_SZ + PT_PSR]
+	st	%g3, [%sp + STACKFRAME_SZ + PT_PSR]
 
 	/* Advance the pc and npc over the trap instruction. */
 2:
-	ld	[%sp + REGWIN_SZ + PT_NPC], %l1	/* pc  = npc   */
+	ld	[%sp + STACKFRAME_SZ + PT_NPC], %l1	/* pc  = npc   */
 	add	%l1, 0x4, %l2			/* npc = npc+4 */
-	st	%l1, [%sp + REGWIN_SZ + PT_PC]
+	st	%l1, [%sp + STACKFRAME_SZ + PT_PC]
 	b	ret_trap_entry
-	 st	%l2, [%sp + REGWIN_SZ + PT_NPC]
+	 st	%l2, [%sp + STACKFRAME_SZ + PT_NPC]
 
 /* Saving and restoring the FPU state is best done from lowlevel code.
  *
@@ -1810,7 +1818,7 @@
 
 	.globl	C_LABEL(ndelay)
 C_LABEL(ndelay):
-	save	%sp, -REGWIN_SZ, %sp
+	save	%sp, -STACKFRAME_SZ, %sp
 	mov	%i0, %o0
 	call	.umul
 	 mov	5, %o1
@@ -1819,7 +1827,7 @@
 
 	.globl	C_LABEL(udelay)
 C_LABEL(udelay):
-	save	%sp, -REGWIN_SZ, %sp
+	save	%sp, -STACKFRAME_SZ, %sp
 	mov	%i0, %o0
 	sethi	%hi(0x10c6), %o1
 	call	.umul
@@ -1856,9 +1864,9 @@
 	wr 	%l0, PSR_ET, %psr
 	WRITE_PAUSE
 
-	st	%i0, [%sp + REGWIN_SZ + PT_G0] ! for restarting syscalls
+	st	%i0, [%sp + STACKFRAME_SZ + PT_G0] ! for restarting syscalls
 	call	C_LABEL(sparc_breakpoint)
-	 add	%sp, REGWIN_SZ, %o0
+	 add	%sp, STACKFRAME_SZ, %o0
 
 	RESTORE_ALL
 
@@ -1953,7 +1961,7 @@
 	WRITE_PAUSE
 
 	call	C_LABEL(pcic_nmi)
-	 add	%sp, REGWIN_SZ, %o1	! struct pt_regs *regs
+	 add	%sp, STACKFRAME_SZ, %o1	! struct pt_regs *regs
 	RESTORE_ALL
 
 	.globl	C_LABEL(pcic_nmi_trap_patch)
diff -Nru a/arch/sparc/kernel/etrap.S b/arch/sparc/kernel/etrap.S
--- a/arch/sparc/kernel/etrap.S	Wed Apr 30 22:28:20 2003
+++ b/arch/sparc/kernel/etrap.S	Wed Apr 30 22:28:20 2003
@@ -88,7 +88,7 @@
 	/* From kernel, allocate more kernel stack and
 	 * build a pt_regs trap frame.
 	 */
-	sub	%fp, (REGWIN_SZ + TRACEREG_SZ), %t_kstack
+	sub	%fp, (STACKFRAME_SZ + TRACEREG_SZ), %t_kstack
 	STORE_PT_ALL(t_kstack, t_psr, t_pc, t_npc, g2)
 
 	/* See if we are in the trap window. */
@@ -129,7 +129,7 @@
 	jmpl	%t_retpc + 0x8, %g0	! return to caller
 	 mov	%t_kstack, %sp		! and onto new kernel stack
 
-#define STACK_OFFSET (THREAD_SIZE - (TRACEREG_SZ + REGWIN_SZ))
+#define STACK_OFFSET (THREAD_SIZE - TRACEREG_SZ - STACKFRAME_SZ)
 
 trap_setup_from_user:
 	/* We can't use %curptr yet. */
diff -Nru a/arch/sparc/kernel/head.S b/arch/sparc/kernel/head.S
--- a/arch/sparc/kernel/head.S	Wed Apr 30 22:28:06 2003
+++ b/arch/sparc/kernel/head.S	Wed Apr 30 22:28:06 2003
@@ -1012,7 +1012,7 @@
 
 		/* I want a kernel stack NOW! */
 		set	C_LABEL(init_thread_union), %g1
-		set	(THREAD_SIZE - REGWIN_SZ), %g2
+		set	(THREAD_SIZE - STACKFRAME_SZ), %g2
 		add	%g1, %g2, %sp
 		mov	0, %fp			/* And for good luck */
 
diff -Nru a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
--- a/arch/sparc/kernel/ioport.c	Wed Apr 30 22:28:19 2003
+++ b/arch/sparc/kernel/ioport.c	Wed Apr 30 22:28:19 2003
@@ -62,13 +62,6 @@
 };
 
 /*
- * BTFIXUP would do as well but it seems overkill for the case.
- */
-static void (*_sparc_mapioaddr)(unsigned long pa, unsigned long va,
-    int bus, int ro);
-static void (*_sparc_unmapioaddr)(unsigned long va);
-
-/*
  * Our mini-allocator...
  * Boy this is gross! We need it because we must map I/O for
  * timers and interrupt controller before the kmalloc is available.
@@ -201,8 +194,6 @@
 _sparc_ioremap(struct resource *res, u32 bus, u32 pa, int sz)
 {
 	unsigned long offset = ((unsigned long) pa) & (~PAGE_MASK);
-	unsigned long va;
-	unsigned int psz;
 
 	if (allocate_resource(&sparc_iomap, res,
 	    (offset + sz + PAGE_SIZE-1) & PAGE_MASK,
@@ -213,27 +204,10 @@
 		prom_halt();
 	}
 
-	va = res->start;
 	pa &= PAGE_MASK;
-	for (psz = res->end - res->start + 1; psz != 0; psz -= PAGE_SIZE) {
-		(*_sparc_mapioaddr)(pa, va, bus, 0);
-		va += PAGE_SIZE;
-		pa += PAGE_SIZE;
-	}
+	sparc_mapiorange(bus, pa, res->start, res->end - res->start + 1);
 
-	/*
-	 * XXX Playing with implementation details here.
-	 * On sparc64 Ebus has resources with precise boundaries.
-	 * We share drivers with sparc64. Too clever drivers use
-	 * start of a resource instead of a base address.
-	 *
-	 * XXX-2 This may be not valid anymore, clean when
-	 * interface to sbus_ioremap() is resolved.
-	 */
-	res->start += offset;
-	res->end = res->start + sz - 1;		/* not strictly necessary.. */
-
-	return (void *) res->start;
+	return (void *) (res->start + offset);
 }
 
 /*
@@ -244,12 +218,8 @@
 	unsigned long plen;
 
 	plen = res->end - res->start + 1;
-	plen = (plen + PAGE_SIZE-1) & PAGE_MASK;
-	while (plen != 0) {
-		plen -= PAGE_SIZE;
-		(*_sparc_unmapioaddr)(res->start + plen);
-	}
-
+	if ((plen & (PAGE_SIZE-1)) != 0) BUG();
+	sparc_unmapiorange(res->start, plen);
 	release_resource(res);
 }
 
@@ -283,40 +253,44 @@
 	}
 
 	order = get_order(len_total);
-	va = __get_free_pages(GFP_KERNEL, order);
-	if (va == 0) {
-		/*
-		 * printk here may be flooding... Consider removal XXX.
-		 */
-		printk("sbus_alloc_consistent: no %ld pages\n", len_total>>PAGE_SHIFT);
-		return NULL;
-	}
+	if ((va = __get_free_pages(GFP_KERNEL, order)) == 0)
+		goto err_nopages;
 
-	if ((res = kmalloc(sizeof(struct resource), GFP_KERNEL)) == NULL) {
-		free_pages(va, order);
-		printk("sbus_alloc_consistent: no core\n");
-		return NULL;
-	}
+	if ((res = kmalloc(sizeof(struct resource), GFP_KERNEL)) == NULL)
+		goto err_nomem;
 	memset((char*)res, 0, sizeof(struct resource));
 
 	if (allocate_resource(&_sparc_dvma, res, len_total,
 	    _sparc_dvma.start, _sparc_dvma.end, PAGE_SIZE, NULL, NULL) != 0) {
 		printk("sbus_alloc_consistent: cannot occupy 0x%lx", len_total);
-		free_pages(va, order);
-		kfree(res);
-		return NULL;
+		goto err_nova;
 	}
+	mmu_inval_dma_area(va, len_total);
+	// XXX The mmu_map_dma_area does this for us below, see comments.
+	// sparc_mapiorange(0, virt_to_phys(va), res->start, len_total);
+	/*
+	 * XXX That's where sdev would be used. Currently we load
+	 * all iommu tables with the same translations.
+	 */
+	if (mmu_map_dma_area(dma_addrp, va, res->start, len_total) != 0)
+		goto err_noiommu;
 
-	mmu_map_dma_area(va, res->start, len_total);
-
-	*dma_addrp = res->start;
 	return (void *)res->start;
+
+err_noiommu:
+	release_resource(res);
+err_nova:
+	free_pages(va, order);
+err_nomem:
+	kfree(res);
+err_nopages:
+	return NULL;
 }
 
 void sbus_free_consistent(struct sbus_dev *sdev, long n, void *p, u32 ba)
 {
 	struct resource *res;
-	unsigned long pgp;
+	struct page *pgv;
 
 	if ((res = _sparc_find_resource(&_sparc_dvma,
 	    (unsigned long)p)) == NULL) {
@@ -340,10 +314,10 @@
 	kfree(res);
 
 	/* mmu_inval_dma_area(va, n); */ /* it's consistent, isn't it */
-	pgp = (unsigned long) phys_to_virt(mmu_translate_dvma(ba));
+	pgv = mmu_translate_dvma(ba);
 	mmu_unmap_dma_area(ba, n);
 
-	free_pages(pgp, get_order(n));
+	__free_pages(pgv, get_order(n));
 }
 
 /*
@@ -353,39 +327,6 @@
  */
 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;
-	struct resource *res;
-
-	/* XXX why are some lenghts signed, others unsigned? */
-	if (len <= 0) {
-		return 0;
-	}
-	/* XXX So what is maxphys for us and how do drivers know it? */
-	if (len > 256*1024) {			/* __get_free_pages() limit */
-		return 0;
-	}
-
-	if ((res = kmalloc(sizeof(struct resource), GFP_KERNEL)) == NULL) {
-		printk("sbus_map_single: no core\n");
-		return 0;
-	}
-	memset((char*)res, 0, sizeof(struct resource));
-	res->name = va; /* XXX */
-
-	if (allocate_resource(&_sparc_dvma, res, len_total,
-	    _sparc_dvma.start, _sparc_dvma.end, PAGE_SIZE) != 0) {
-		printk("sbus_map_single: cannot occupy 0x%lx", len);
-		kfree(res);
-		return 0;
-	}
-
-	mmu_map_dma_area(va, res->start, len_total);
-	mmu_flush_dma_area((unsigned long)va, len_total); /* in all contexts? */
-
-	return res->start;
-#endif
-#if 1 /* "trampoline" version */
 	/* XXX why are some lenghts signed, others unsigned? */
 	if (len <= 0) {
 		return 0;
@@ -395,36 +336,11 @@
 		return 0;
 	}
 	return mmu_get_scsi_one(va, len, sdev->bus);
-#endif
 }
 
 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;
-	unsigned long va;
-
-	if ((res = _sparc_find_resource(&_sparc_dvma, ba)) == NULL) {
-		printk("sbus_unmap_single: cannot find %08x\n", (unsigned)ba);
-		return;
-	}
-
-	n = (n + PAGE_SIZE-1) & PAGE_MASK;
-	if ((res->end-res->start)+1 != n) {
-		printk("sbus_unmap_single: region 0x%lx asked 0x%lx\n",
-		    (long)((res->end-res->start)+1), n);
-		return;
-	}
-
-	va = (unsigned long) res->name;	/* XXX Ouch */
-	mmu_inval_dma_area(va, n);	/* in all contexts, mm's?... */
-	mmu_unmap_dma_area(ba, n);	/* iounit cache flush is here */
-	release_resource(res);
-	kfree(res);
-#endif
-#if 1 /* "trampoline" version */
 	mmu_release_scsi_one(ba, n, sdev->bus);
-#endif
 }
 
 int sbus_map_sg(struct sbus_dev *sdev, struct scatterlist *sg, int n, int direction)
@@ -456,7 +372,7 @@
 	if (res == NULL)
 		panic("sbus_dma_sync_single: 0x%x\n", ba);
 
-	va = (unsigned long) phys_to_virt(mmu_translate_dvma(ba));
+	va = page_address(mmu_translate_dvma(ba)); /* XXX higmem */
 	/*
 	 * XXX This bogosity will be fixed with the iommu rewrite coming soon
 	 * to a kernel near you. - Anton
@@ -511,24 +427,12 @@
 		kfree(res);
 		return NULL;
 	}
-
 	mmu_inval_dma_area(va, len_total);
-
 #if 0
-/* P3 */ printk("pci_alloc_consistent: kva %lx uncva %lx phys %lx size %x\n",
+/* P3 */ printk("pci_alloc_consistent: kva %lx uncva %lx phys %lx size %lx\n",
   (long)va, (long)res->start, (long)virt_to_phys(va), len_total);
 #endif
-	{
-		unsigned long xva, xpa;
-		xva = res->start;
-		xpa = virt_to_phys(va);
-		while (len_total != 0) {
-			len_total -= PAGE_SIZE;
-			(*_sparc_mapioaddr)(xpa, xva, 0, 0);
-			xva += PAGE_SIZE;
-			xpa += PAGE_SIZE;
-		}
-	}
+	sparc_mapiorange(0, virt_to_phys(va), res->start, len_total);
 
 	*pba = virt_to_phys(va); /* equals virt_to_bus (R.I.P.) for us. */
 	return (void *) res->start;
@@ -567,12 +471,7 @@
 
 	pgp = (unsigned long) phys_to_virt(ba);	/* bus_to_virt actually */
 	mmu_inval_dma_area(pgp, n);
-	{
-		int x;
-		for (x = 0; x < n; x += PAGE_SIZE) {
-			(*_sparc_unmapioaddr)((unsigned long)p + n);
-		}
-	}
+	sparc_unmapiorange((unsigned long)p, n);
 
 	release_resource(res);
 	kfree(res);
@@ -749,37 +648,6 @@
 			return tmp;
 	}
 	return NULL;
-}
-
-/*
- * Necessary boot time initializations.
- */
-
-void ioport_init(void)
-{
-	extern void sun4c_mapioaddr(unsigned long, unsigned long, int, int);
-	extern void srmmu_mapioaddr(unsigned long, unsigned long, int, int);
-	extern void sun4c_unmapioaddr(unsigned long);
-	extern void srmmu_unmapioaddr(unsigned long);
-
-	switch(sparc_cpu_model) {
-	case sun4c:
-	case sun4:
-	case sun4e:
-		_sparc_mapioaddr = sun4c_mapioaddr;
-		_sparc_unmapioaddr = sun4c_unmapioaddr;
-		break;
-	case sun4m:
-	case sun4d:
-		_sparc_mapioaddr = srmmu_mapioaddr;
-		_sparc_unmapioaddr = srmmu_unmapioaddr;
-		break;
-	default:
-		printk("ioport_init: cpu type %d is unknown.\n",
-		    sparc_cpu_model);
-		prom_halt();
-	};
-
 }
 
 void register_proc_sparc_ioport(void)
diff -Nru a/arch/sparc/kernel/irq.c b/arch/sparc/kernel/irq.c
--- a/arch/sparc/kernel/irq.c	Wed Apr 30 22:28:04 2003
+++ b/arch/sparc/kernel/irq.c	Wed Apr 30 22:28:04 2003
@@ -74,8 +74,8 @@
     prom_halt();
 }
 
-void (*sparc_init_timers)(void (*)(int, void *,struct pt_regs *)) =
-    (void (*)(void (*)(int, void *,struct pt_regs *))) irq_panic;
+void (*sparc_init_timers)(irqreturn_t (*)(int, void *,struct pt_regs *)) =
+    (void (*)(irqreturn_t (*)(int, void *,struct pt_regs *))) irq_panic;
 
 /*
  * Dave Redman (djhr@tadpole.co.uk)
@@ -461,7 +461,7 @@
  * thus no sharing possible.
  */
 int request_fast_irq(unsigned int irq,
-		     void (*handler)(int, void *, struct pt_regs *),
+		     irqreturn_t (*handler)(int, void *, struct pt_regs *),
 		     unsigned long irqflags, const char *devname)
 {
 	struct irqaction *action;
@@ -549,7 +549,7 @@
 }
 
 int request_irq(unsigned int irq,
-		void (*handler)(int, void *, struct pt_regs *),
+		irqreturn_t (*handler)(int, void *, struct pt_regs *),
 		unsigned long irqflags, const char * devname, void *dev_id)
 {
 	struct irqaction * action, *tmp = NULL;
@@ -558,7 +558,7 @@
 	
 	if (sparc_cpu_model == sun4d) {
 		extern int sun4d_request_irq(unsigned int, 
-					     void (*)(int, void *, struct pt_regs *),
+					     irqreturn_t (*)(int, void *, struct pt_regs *),
 					     unsigned long, const char *, void *);
 		return sun4d_request_irq(irq, handler, irqflags, devname, dev_id);
 	}
diff -Nru a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
--- a/arch/sparc/kernel/pcic.c	Wed Apr 30 22:28:10 2003
+++ b/arch/sparc/kernel/pcic.c	Wed Apr 30 22:28:10 2003
@@ -736,12 +736,13 @@
 	pcic_timer_dummy = readl(pcic0.pcic_regs+PCI_SYS_LIMIT);
 }
 
-static void pcic_timer_handler (int irq, void *h, struct pt_regs *regs)
+static irqreturn_t pcic_timer_handler (int irq, void *h, struct pt_regs *regs)
 {
 	write_seqlock(&xtime_lock);	/* Dummy, to show that we remember */
 	pcic_clear_clock_irq();
 	do_timer(regs);
 	write_sequnlock(&xtime_lock);
+	return IRQ_HANDLED;
 }
 
 #define USECS_PER_JIFFY  10000  /* We have 100HZ "standard" timer for sparc */
@@ -827,13 +828,27 @@
 	 * made, and then undo it!
 	 */
 	tv->tv_usec -= do_gettimeoffset();
-	tv->tv_usec -= (jiffies - wall_jiffies) * (1000000 / HZ);
+	tv->tv_usec -= (jiffies - wall_jiffies) * (USEC_PER_SEC / HZ);
 	while (tv->tv_usec < 0) {
-		tv->tv_usec += 1000000;
+		tv->tv_usec += USEC_PER_SEC;
 		tv->tv_sec--;
 	}
+	tv->tv_usec *= NSEC_PER_USEC;
+
+	wall_to_monotonic.tv_sec += xtime.tv_sec - tv->tv_sec;
+	wall_to_monotonic.tv_nsec += xtime.tv_nsec - tv->tv_usec;
+
+	if (wall_to_monotonic.tv_nsec > NSEC_PER_SEC) {
+		wall_to_monotonic.tv_nsec -= NSEC_PER_SEC;
+		wall_to_monotonic.tv_sec++;
+	}
+	if (wall_to_monotonic.tv_nsec < 0) {
+		wall_to_monotonic.tv_nsec += NSEC_PER_SEC;
+		wall_to_monotonic.tv_sec--;
+	}
+
 	xtime.tv_sec = tv->tv_sec;
-	xtime.tv_nsec = (tv->tv_usec * 1000);
+	xtime.tv_nsec = tv->tv_usec;
 	time_adjust = 0;		/* stop active adjtime() */
 	time_status |= STA_UNSYNC;
 	time_maxerror = NTP_PHASE_LIMIT;
diff -Nru a/arch/sparc/kernel/process.c b/arch/sparc/kernel/process.c
--- a/arch/sparc/kernel/process.c	Wed Apr 30 22:28:05 2003
+++ b/arch/sparc/kernel/process.c	Wed Apr 30 22:28:05 2003
@@ -377,60 +377,12 @@
 		current->thread.flags &= ~SPARC_FLAG_KTHREAD;
 
 		/* We must fixup kregs as well. */
+		/* XXX This was not fixed for ti for a while, worked. Unused? */
 		current->thread.kregs = (struct pt_regs *)
-			(((unsigned long)current) +
-			 (THREAD_SIZE - TRACEREG_SZ));
+		    ((char *)current->thread_info + (THREAD_SIZE - TRACEREG_SZ));
 	}
 }
 
-static __inline__ void copy_regs(struct pt_regs *dst, struct pt_regs *src)
-{
-	__asm__ __volatile__("ldd\t[%1 + 0x00], %%g2\n\t"
-			     "ldd\t[%1 + 0x08], %%g4\n\t"
-			     "ldd\t[%1 + 0x10], %%o4\n\t"
-			     "std\t%%g2, [%0 + 0x00]\n\t"
-			     "std\t%%g4, [%0 + 0x08]\n\t"
-			     "std\t%%o4, [%0 + 0x10]\n\t"
-			     "ldd\t[%1 + 0x18], %%g2\n\t"
-			     "ldd\t[%1 + 0x20], %%g4\n\t"
-			     "ldd\t[%1 + 0x28], %%o4\n\t"
-			     "std\t%%g2, [%0 + 0x18]\n\t"
-			     "std\t%%g4, [%0 + 0x20]\n\t"
-			     "std\t%%o4, [%0 + 0x28]\n\t"
-			     "ldd\t[%1 + 0x30], %%g2\n\t"
-			     "ldd\t[%1 + 0x38], %%g4\n\t"
-			     "ldd\t[%1 + 0x40], %%o4\n\t"
-			     "std\t%%g2, [%0 + 0x30]\n\t"
-			     "std\t%%g4, [%0 + 0x38]\n\t"
-			     "ldd\t[%1 + 0x48], %%g2\n\t"
-			     "std\t%%o4, [%0 + 0x40]\n\t"
-			     "std\t%%g2, [%0 + 0x48]\n\t" : :
-			     "r" (dst), "r" (src) :
-			     "g2", "g3", "g4", "g5", "o4", "o5");
-}
-
-static __inline__ void copy_regwin(struct reg_window *dst, struct reg_window *src)
-{
-	__asm__ __volatile__("ldd\t[%1 + 0x00], %%g2\n\t"
-			     "ldd\t[%1 + 0x08], %%g4\n\t"
-			     "ldd\t[%1 + 0x10], %%o4\n\t"
-			     "std\t%%g2, [%0 + 0x00]\n\t"
-			     "std\t%%g4, [%0 + 0x08]\n\t"
-			     "std\t%%o4, [%0 + 0x10]\n\t"
-			     "ldd\t[%1 + 0x18], %%g2\n\t"
-			     "ldd\t[%1 + 0x20], %%g4\n\t"
-			     "ldd\t[%1 + 0x28], %%o4\n\t"
-			     "std\t%%g2, [%0 + 0x18]\n\t"
-			     "std\t%%g4, [%0 + 0x20]\n\t"
-			     "std\t%%o4, [%0 + 0x28]\n\t"
-			     "ldd\t[%1 + 0x30], %%g2\n\t"
-			     "ldd\t[%1 + 0x38], %%g4\n\t"
-			     "std\t%%g2, [%0 + 0x30]\n\t"
-			     "std\t%%g4, [%0 + 0x38]\n\t" : :
-			     "r" (dst), "r" (src) :
-			     "g2", "g3", "g4", "g5", "o4", "o5");
-}
-
 static __inline__ struct sparc_stackf *
 clone_stackframe(struct sparc_stackf *dst, struct sparc_stackf *src)
 {
@@ -495,8 +447,7 @@
 {
 	struct thread_info *ti = p->thread_info;
 	struct pt_regs *childregs;
-	struct reg_window *new_stack;
-	unsigned long stack_offset;
+	char *new_stack;
 
 #ifndef CONFIG_SMP
 	if(last_task_used_math == current) {
@@ -513,15 +464,18 @@
 
 	p->set_child_tid = p->clear_child_tid = NULL;
 
-	/* Calculate offset to stack_frame & pt_regs */
-	stack_offset = THREAD_SIZE - TRACEREG_SZ;
-
-	if(regs->psr & PSR_PS)
-		stack_offset -= REGWIN_SZ;
-	childregs = ((struct pt_regs *) (((unsigned long)ti) + stack_offset));
-	copy_regs(childregs, regs);
-	new_stack = (((struct reg_window *) childregs) - 1);
-	copy_regwin(new_stack, (((struct reg_window *) regs) - 1));
+	/*
+	 *  p->thread_info         new_stack   childregs
+	 *  !                      !           !             {if(PSR_PS) }
+	 *  V                      V (stk.fr.) V  (pt_regs)  { (stk.fr.) }
+	 *  +----- - - - - - ------+===========+============={+==========}+
+	 */
+	new_stack = (char*)ti + THREAD_SIZE;
+	if (regs->psr & PSR_PS)
+		new_stack -= STACKFRAME_SZ;
+	new_stack -= STACKFRAME_SZ + TRACEREG_SZ;
+	memcpy(new_stack, (char *)regs - STACKFRAME_SZ, STACKFRAME_SZ + TRACEREG_SZ);
+	childregs = (struct pt_regs *) (new_stack + STACKFRAME_SZ);
 
 	/*
 	 * A new process must start with interrupts closed in 2.5,
@@ -542,14 +496,11 @@
 		extern struct pt_regs fake_swapper_regs;
 
 		p->thread.kregs = &fake_swapper_regs;
-		new_stack = (struct reg_window *)
-			((((unsigned long)ti) + (THREAD_SIZE)) - REGWIN_SZ);
+		new_stack += STACKFRAME_SZ + TRACEREG_SZ;
 		childregs->u_regs[UREG_FP] = (unsigned long) new_stack;
 		p->thread.flags |= SPARC_FLAG_KTHREAD;
 		p->thread.current_ds = KERNEL_DS;
-		memcpy((void *)new_stack,
-		       (void *)regs->u_regs[UREG_FP],
-		       sizeof(struct reg_window));
+		memcpy(new_stack, (void *)regs->u_regs[UREG_FP], STACKFRAME_SZ);
 		childregs->u_regs[UREG_G6] = (unsigned long) ti;
 	} else {
 		p->thread.kregs = childregs;
diff -Nru a/arch/sparc/kernel/rtrap.S b/arch/sparc/kernel/rtrap.S
--- a/arch/sparc/kernel/rtrap.S	Wed Apr 30 22:28:16 2003
+++ b/arch/sparc/kernel/rtrap.S	Wed Apr 30 22:28:16 2003
@@ -72,16 +72,16 @@
 signal_p:
 	andcc	%g2, (_TIF_NOTIFY_RESUME|_TIF_SIGPENDING), %g0
 	bz,a	ret_trap_continue
-	 ld	[%sp + REGWIN_SZ + PT_PSR], %t_psr
+	 ld	[%sp + STACKFRAME_SZ + PT_PSR], %t_psr
 
 	clr	%o0
 	mov	%l5, %o2
 	mov	%l6, %o3
 	call	C_LABEL(do_signal)
-	 add	%sp, REGWIN_SZ, %o1	! pt_regs ptr
+	 add	%sp, STACKFRAME_SZ, %o1	! pt_regs ptr
 
 	/* Fall through. */
-	ld	[%sp + REGWIN_SZ + PT_PSR], %t_psr
+	ld	[%sp + STACKFRAME_SZ + PT_PSR], %t_psr
 	clr	%l6
 ret_trap_continue:
 	wr	%t_psr, 0x0, %psr
@@ -98,7 +98,7 @@
 
 	mov	1, %o1
 	call	C_LABEL(try_to_clear_window_buffer)
-	 add	%sp, REGWIN_SZ, %o0
+	 add	%sp, STACKFRAME_SZ, %o0
 
 	b	signal_p
 	 ld	[%curptr + TI_FLAGS], %g2
@@ -145,7 +145,7 @@
 	 nop
 
 	b	ret_trap_unaligned_pc
-	 add	%sp, REGWIN_SZ, %o0
+	 add	%sp, STACKFRAME_SZ, %o0
 
 1:
 	LOAD_PT_YREG(sp, g1)
@@ -158,9 +158,9 @@
 	rett	%t_npc
 	
 ret_trap_unaligned_pc:
-	ld	[%sp + REGWIN_SZ + PT_PC], %o1
-	ld	[%sp + REGWIN_SZ + PT_NPC], %o2
-	ld	[%sp + REGWIN_SZ + PT_PSR], %o3
+	ld	[%sp + STACKFRAME_SZ + PT_PC], %o1
+	ld	[%sp + STACKFRAME_SZ + PT_NPC], %o2
+	ld	[%sp + STACKFRAME_SZ + PT_PSR], %o3
 
 	wr	%t_wim, 0x0, %wim		! or else...
 
@@ -218,7 +218,7 @@
 	WRITE_PAUSE
 
 	call	C_LABEL(window_ret_fault)
-	 add	%sp, REGWIN_SZ, %o0
+	 add	%sp, STACKFRAME_SZ, %o0
 
 	b	signal_p
 	 ld	[%curptr + TI_FLAGS], %g2
diff -Nru a/arch/sparc/kernel/setup.c b/arch/sparc/kernel/setup.c
--- a/arch/sparc/kernel/setup.c	Wed Apr 30 22:28:03 2003
+++ b/arch/sparc/kernel/setup.c	Wed Apr 30 22:28:03 2003
@@ -13,6 +13,7 @@
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
 #include <linux/slab.h>
+#include <linux/initrd.h>
 #include <asm/smp.h>
 #include <linux/user.h>
 #include <linux/a.out.h>
diff -Nru a/arch/sparc/kernel/signal.c b/arch/sparc/kernel/signal.c
--- a/arch/sparc/kernel/signal.c	Wed Apr 30 22:28:12 2003
+++ b/arch/sparc/kernel/signal.c	Wed Apr 30 22:28:12 2003
@@ -753,7 +753,7 @@
 
 	synchronize_user_stack();
 	sfp = (svr4_signal_frame_t __user *)
-		get_sigframe(sa, regs, SVR4_SF_ALIGNED + REGWIN_SZ);
+		get_sigframe(sa, regs, SVR4_SF_ALIGNED + sizeof(struct reg_window));
 
 	if (invalid_frame_pointer(sfp, sizeof(*sfp)))
 		goto sigill_and_return;
diff -Nru a/arch/sparc/kernel/smp.c b/arch/sparc/kernel/smp.c
--- a/arch/sparc/kernel/smp.c	Wed Apr 30 22:28:06 2003
+++ b/arch/sparc/kernel/smp.c	Wed Apr 30 22:28:06 2003
@@ -100,13 +100,6 @@
 	local_flush_tlb_all();
 }
 
-/* Only broken Intel needs this, thus it should not even be referenced
- * globally...
- */
-void __init initialize_secondary(void)
-{
-}
-
 extern int cpu_idle(void);
 
 /* Activate a secondary processor. */
diff -Nru a/arch/sparc/kernel/sparc_ksyms.c b/arch/sparc/kernel/sparc_ksyms.c
--- a/arch/sparc/kernel/sparc_ksyms.c	Wed Apr 30 22:28:04 2003
+++ b/arch/sparc/kernel/sparc_ksyms.c	Wed Apr 30 22:28:04 2003
@@ -158,7 +158,8 @@
 EXPORT_SYMBOL(mostek_lock);
 EXPORT_SYMBOL(mstk48t02_regs);
 #if CONFIG_SUN_AUXIO
-EXPORT_SYMBOL(auxio_register);
+EXPORT_SYMBOL(set_auxio);
+EXPORT_SYMBOL(get_auxio);
 #endif
 EXPORT_SYMBOL(request_fast_irq);
 EXPORT_SYMBOL(io_remap_page_range);
diff -Nru a/arch/sparc/kernel/sun4c_irq.c b/arch/sparc/kernel/sun4c_irq.c
--- a/arch/sparc/kernel/sun4c_irq.c	Wed Apr 30 22:28:04 2003
+++ b/arch/sparc/kernel/sun4c_irq.c	Wed Apr 30 22:28:04 2003
@@ -155,7 +155,7 @@
 	/* Errm.. not sure how to do this.. */
 }
 
-static void __init sun4c_init_timers(void (*counter_fn)(int, void *, struct pt_regs *))
+static void __init sun4c_init_timers(irqreturn_t (*counter_fn)(int, void *, struct pt_regs *))
 {
 	int irq;
 
diff -Nru a/arch/sparc/kernel/sun4d_irq.c b/arch/sparc/kernel/sun4d_irq.c
--- a/arch/sparc/kernel/sun4d_irq.c	Wed Apr 30 22:28:03 2003
+++ b/arch/sparc/kernel/sun4d_irq.c	Wed Apr 30 22:28:03 2003
@@ -262,7 +262,7 @@
 }
 
 int sun4d_request_irq(unsigned int irq,
-		void (*handler)(int, void *, struct pt_regs *),
+		irqreturn_t (*handler)(int, void *, struct pt_regs *),
 		unsigned long irqflags, const char * devname, void *dev_id)
 {
 	struct irqaction *action, *tmp = NULL, **actionp;
@@ -445,7 +445,7 @@
 	bw_set_prof_limit(cpu, limit);
 }
 
-static void __init sun4d_init_timers(void (*counter_fn)(int, void *, struct pt_regs *))
+static void __init sun4d_init_timers(irqreturn_t (*counter_fn)(int, void *, struct pt_regs *))
 {
 	int irq;
 	extern struct prom_cpuinfo linux_cpus[NR_CPUS];
diff -Nru a/arch/sparc/kernel/sun4m_irq.c b/arch/sparc/kernel/sun4m_irq.c
--- a/arch/sparc/kernel/sun4m_irq.c	Wed Apr 30 22:28:09 2003
+++ b/arch/sparc/kernel/sun4m_irq.c	Wed Apr 30 22:28:09 2003
@@ -235,7 +235,7 @@
 	return buff;
 }
 
-static void __init sun4m_init_timers(void (*counter_fn)(int, void *, struct pt_regs *))
+static void __init sun4m_init_timers(irqreturn_t (*counter_fn)(int, void *, struct pt_regs *))
 {
 	int reg_count, irq, cpu;
 	struct linux_prom_registers cnt_regs[PROMREG_MAX];
diff -Nru a/arch/sparc/kernel/sunos_asm.S b/arch/sparc/kernel/sunos_asm.S
--- a/arch/sparc/kernel/sunos_asm.S	Wed Apr 30 22:28:05 2003
+++ b/arch/sparc/kernel/sunos_asm.S	Wed Apr 30 22:28:05 2003
@@ -16,7 +16,7 @@
 	.align 4
 
 	/* When calling ret_sys_call, %o0 should contain the same
-	 * value as in [%sp + REGWIN_SZ + PT_I0] */
+	 * value as in [%sp + STACKFRAME_SZ + PT_I0] */
 
 	/* SunOS getpid() returns pid in %o0 and ppid in %o1 */
 	.globl	C_LABEL(sunos_getpid)
@@ -25,10 +25,10 @@
 	 nop
 
 	call	C_LABEL(sys_getpid)
-	 st	%o0, [%sp + REGWIN_SZ + PT_I1]
+	 st	%o0, [%sp + STACKFRAME_SZ + PT_I1]
 
 	b	C_LABEL(ret_sys_call)
-	 st	%o0, [%sp + REGWIN_SZ + PT_I0]
+	 st	%o0, [%sp + STACKFRAME_SZ + PT_I0]
 
 	/* SunOS getuid() returns uid in %o0 and euid in %o1 */
 	.globl	C_LABEL(sunos_getuid)
@@ -37,10 +37,10 @@
 	 nop
 
 	call	C_LABEL(sys_getuid16)
-	 st	%o0, [%sp + REGWIN_SZ + PT_I1]
+	 st	%o0, [%sp + STACKFRAME_SZ + PT_I1]
 
 	b	C_LABEL(ret_sys_call)
-	 st	%o0, [%sp + REGWIN_SZ + PT_I0]
+	 st	%o0, [%sp + STACKFRAME_SZ + PT_I0]
 
 	/* SunOS getgid() returns gid in %o0 and egid in %o1 */
 	.globl	C_LABEL(sunos_getgid)
@@ -49,20 +49,20 @@
 	 nop
 
 	call	C_LABEL(sys_getgid16)
-	 st	%o0, [%sp + REGWIN_SZ + PT_I1]
+	 st	%o0, [%sp + STACKFRAME_SZ + PT_I1]
 
 	b	C_LABEL(ret_sys_call)
-	 st	%o0, [%sp + REGWIN_SZ + PT_I0]
+	 st	%o0, [%sp + STACKFRAME_SZ + PT_I0]
 
 	/* SunOS's execv() call only specifies the argv argument, the
 	 * environment settings are the same as the calling processes.
 	 */
 	.globl	C_LABEL(sunos_execv)
 C_LABEL(sunos_execv):
-	st	%g0, [%sp + REGWIN_SZ + PT_I2]
+	st	%g0, [%sp + STACKFRAME_SZ + PT_I2]
 
 	call	C_LABEL(sparc_execve)
-	 add	%sp, REGWIN_SZ, %o0
+	 add	%sp, STACKFRAME_SZ, %o0
 
 	b	C_LABEL(ret_sys_call)
-	 ld	[%sp + REGWIN_SZ + PT_I0], %o0
+	 ld	[%sp + STACKFRAME_SZ + PT_I0], %o0
diff -Nru a/arch/sparc/kernel/tick14.c b/arch/sparc/kernel/tick14.c
--- a/arch/sparc/kernel/tick14.c	Wed Apr 30 22:28:18 2003
+++ b/arch/sparc/kernel/tick14.c	Wed Apr 30 22:28:18 2003
@@ -56,7 +56,7 @@
 	linux_lvl14[3] =  obp_lvl14[3]; 
 }
 
-void claim_ticker14(void (*handler)(int, void *, struct pt_regs *),
+void claim_ticker14(irqreturn_t (*handler)(int, void *, struct pt_regs *),
 		    int irq_nr, unsigned int timeout )
 {
 	int cpu = smp_processor_id();
diff -Nru a/arch/sparc/kernel/time.c b/arch/sparc/kernel/time.c
--- a/arch/sparc/kernel/time.c	Wed Apr 30 22:28:10 2003
+++ b/arch/sparc/kernel/time.c	Wed Apr 30 22:28:10 2003
@@ -120,7 +120,7 @@
 
 #define TICK_SIZE (tick_nsec / 1000)
 
-void timer_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
 	/* last time the cmos clock got updated */
 	static long last_rtc_update;
@@ -156,6 +156,8 @@
 	    last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */
 	}
 	write_sequnlock(&xtime_lock);
+
+	return IRQ_HANDLED;
 }
 
 /* Kick start a stopped clock (procedure from the Sun NVRAM/hostid FAQ). */
@@ -406,7 +408,9 @@
 	mon = MSTK_REG_MONTH(mregs);
 	year = MSTK_CVT_YEAR( MSTK_REG_YEAR(mregs) );
 	xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
-	xtime.tv_nsec = 0;
+	wall_to_monotonic.tv_sec = -xtime.tv_sec + INITIAL_JIFFIES / HZ;
+	xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
+	wall_to_monotonic.tv_nsec = 0;
 	mregs->creg &= ~MSTK_CREG_READ;
 	spin_unlock_irq(&mostek_lock);
 #ifdef CONFIG_SUN4
@@ -437,7 +441,9 @@
 		intersil_start(iregs);
 
 		xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
-		xtime.tv_nsec = 0;
+		wall_to_monotonic.tv_sec = -xtime.tv_sec + INITIAL_JIFFIES / HZ;
+		xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
+		wall_to_monotonic.tv_nsec = 0;
 		printk("%u/%u/%u %u:%u:%u\n",day,mon,year,hour,min,sec);
 	}
 #endif
@@ -510,13 +516,28 @@
 	 * made, and then undo it!
 	 */
 	tv->tv_usec -= do_gettimeoffset();
-	tv->tv_usec -= (jiffies - wall_jiffies) * (1000000 / HZ);
+	tv->tv_usec -= (jiffies - wall_jiffies) * (USEC_PER_SEC / HZ);
+
 	while (tv->tv_usec < 0) {
-		tv->tv_usec += 1000000;
+		tv->tv_usec += USEC_PER_SEC;
 		tv->tv_sec--;
 	}
+	tv->tv_usec *= NSEC_PER_USEC;
+
+	wall_to_monotonic.tv_sec += xtime.tv_sec - tv->tv_sec;
+	wall_to_monotonic.tv_nsec += xtime.tv_nsec - tv->tv_usec;
+
+	if (wall_to_monotonic.tv_nsec > NSEC_PER_SEC) {
+		wall_to_monotonic.tv_nsec -= NSEC_PER_SEC;
+		wall_to_monotonic.tv_sec++;
+	}
+	if (wall_to_monotonic.tv_nsec < 0) {
+		wall_to_monotonic.tv_nsec += NSEC_PER_SEC;
+		wall_to_monotonic.tv_sec--;
+	}
+
 	xtime.tv_sec = tv->tv_sec;
-	xtime.tv_nsec = (tv->tv_usec * 1000);
+	xtime.tv_nsec = tv->tv_usec;
 	time_adjust = 0;		/* stop active adjtime() */
 	time_status |= STA_UNSYNC;
 	time_maxerror = NTP_PHASE_LIMIT;
diff -Nru a/arch/sparc/kernel/trampoline.S b/arch/sparc/kernel/trampoline.S
--- a/arch/sparc/kernel/trampoline.S	Wed Apr 30 22:28:17 2003
+++ b/arch/sparc/kernel/trampoline.S	Wed Apr 30 22:28:17 2003
@@ -63,8 +63,8 @@
 	and	%g4, 0xc, %g4
 	ld	[%g5 + %g4], %g6
 
-	sethi	%hi(THREAD_SIZE - REGWIN_SZ), %sp
-	or	%sp, %lo(THREAD_SIZE - REGWIN_SZ), %sp
+	sethi	%hi(THREAD_SIZE - STACKFRAME_SZ), %sp
+	or	%sp, %lo(THREAD_SIZE - STACKFRAME_SZ), %sp
 	add	%g6, %sp, %sp
 
 	/* Turn on traps (PSR_ET). */
@@ -142,8 +142,8 @@
 	srl	%g3, 1, %g4
 	ld	[%g5 + %g4], %g6
 
-	sethi	%hi(THREAD_SIZE - REGWIN_SZ), %sp
-	or	%sp, %lo(THREAD_SIZE - REGWIN_SZ), %sp
+	sethi	%hi(THREAD_SIZE - STACKFRAME_SZ), %sp
+	or	%sp, %lo(THREAD_SIZE - STACKFRAME_SZ), %sp
 	add	%g6, %sp, %sp
 
 	/* Turn on traps (PSR_ET). */
diff -Nru a/arch/sparc/kernel/windows.c b/arch/sparc/kernel/windows.c
--- a/arch/sparc/kernel/windows.c	Wed Apr 30 22:28:10 2003
+++ b/arch/sparc/kernel/windows.c	Wed Apr 30 22:28:10 2003
@@ -120,7 +120,7 @@
 		unsigned long sp = tp->rwbuf_stkptrs[window];
 
 		if((sp & 7) ||
-		   copy_to_user((char *) sp, &tp->reg_window[window], REGWIN_SZ))
+		   copy_to_user((char *) sp, &tp->reg_window[window], sizeof(struct reg_window)))
 			do_exit(SIGILL);
 	}
 	tp->w_saved = 0;
diff -Nru a/arch/sparc/kernel/wof.S b/arch/sparc/kernel/wof.S
--- a/arch/sparc/kernel/wof.S	Wed Apr 30 22:28:13 2003
+++ b/arch/sparc/kernel/wof.S	Wed Apr 30 22:28:13 2003
@@ -238,7 +238,7 @@
 spnwin_patch3:	and	%twin_tmp, 0xff, %twin_tmp	! patched on 7win Sparcs
 		st	%twin_tmp, [%curptr + TI_UWINMASK]
 
-#define STACK_OFFSET	(THREAD_SIZE - TRACEREG_SZ - REGWIN_SZ)
+#define STACK_OFFSET (THREAD_SIZE - TRACEREG_SZ - STACKFRAME_SZ)
 
 	sethi	%hi(STACK_OFFSET), %sp
 	or	%sp, %lo(STACK_OFFSET), %sp
diff -Nru a/arch/sparc/kernel/wuf.S b/arch/sparc/kernel/wuf.S
--- a/arch/sparc/kernel/wuf.S	Wed Apr 30 22:28:03 2003
+++ b/arch/sparc/kernel/wuf.S	Wed Apr 30 22:28:03 2003
@@ -140,7 +140,7 @@
 C_LABEL(fwin_mmu_patchme):	b	C_LABEL(sun4c_fwin_stackchk)
 				 andcc	%sp, 0x7, %g0
 
-#define STACK_OFFSET (THREAD_SIZE - TRACEREG_SZ - REGWIN_SZ)
+#define STACK_OFFSET (THREAD_SIZE - TRACEREG_SZ - STACKFRAME_SZ)
 
 fwin_user_stack_is_bolixed:
 	/* LOCATION: Window 'W' */
diff -Nru a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
--- a/arch/sparc/lib/Makefile	Wed Apr 30 22:28:18 2003
+++ b/arch/sparc/lib/Makefile	Wed Apr 30 22:28:18 2003
@@ -10,4 +10,4 @@
          strlen.o checksum.o blockops.o memscan.o memcmp.o strncmp.o \
 	 strncpy_from_user.o divdi3.o udivdi3.o strlen_user.o \
 	 copy_user.o locks.o atomic.o bitops.o debuglocks.o lshrdi3.o \
-	 ashldi3.o rwsem.o muldi3.o
+	 ashldi3.o rwsem.o muldi3.o bitext.o
diff -Nru a/arch/sparc/lib/bitext.c b/arch/sparc/lib/bitext.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/arch/sparc/lib/bitext.c	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,114 @@
+/*
+ * bitext.c: kernel little helper (of bit shuffling variety).
+ *
+ * Copyright (C) 2002 Pete Zaitcev <zaitcev@yahoo.com>
+ *
+ * The algorithm to search a zero bit string is geared towards its application.
+ * We expect a couple of fixed sizes of requests, so a rotating counter, reset
+ * by align size, should provide fast enough search while maintaining low
+ * fragmentation.
+ */
+
+#include <linux/smp_lock.h>
+
+#include <asm/bitext.h>
+#include <asm/bitops.h>
+
+/**
+ * bit_map_string_get - find and set a bit string in bit map.
+ * @t: the bit map.
+ * @len: requested string length
+ * @align: requested alignment
+ *
+ * Returns offset in the map or -1 if out of space.
+ *
+ * Not safe to call from an interrupt (uses spin_lock).
+ */
+int bit_map_string_get(struct bit_map *t, int len, int align)
+{
+	int offset, count;	/* siamese twins */
+	int off_new;
+	int align1;
+	int i;
+
+	if (align == 0)
+		align = 1;
+	align1 = align - 1;
+	if ((align & align1) != 0)
+		BUG();
+	if (align < 0 || align >= t->size)
+		BUG();
+	if (len <= 0 || len > t->size)
+		BUG();
+
+	spin_lock(&t->lock);
+	offset = t->last_off & ~align1;
+	count = 0;
+	for (;;) {
+		off_new = find_next_zero_bit(t->map, t->size, offset);
+		off_new = (off_new + align1) & ~align1;
+		count += off_new - offset;
+		offset = off_new;
+		if (offset >= t->size)
+			offset = 0;
+		if (count + len > t->size) {
+			spin_unlock(&t->lock);
+/* P3 */ printk(KERN_ERR
+  "bitmap out: size %d used %d off %d len %d align %d count %d\n",
+  t->size, t->used, offset, len, align, count);
+			return -1;
+		}
+
+		if (offset + len > t->size) {
+			offset = 0;
+			count += t->size - offset;
+			continue;
+		}
+
+		i = 0;
+		while (test_bit(offset + i, t->map) == 0) {
+			i++;
+			if (i == len) {
+				for (i = 0; i < len; i++)
+					__set_bit(offset + i, t->map);
+				if ((t->last_off = offset + len) >= t->size)
+					t->last_off = 0;
+				t->used += len;
+				spin_unlock(&t->lock);
+				return offset;
+			}
+		}
+		count += i + 1;
+		if ((offset += i + 1) >= t->size)
+			offset = 0;
+	}
+}
+
+void bit_map_clear(struct bit_map *t, int offset, int len)
+{
+	int i;
+
+	if (t->used < len)
+		BUG();		/* Much too late to do any good, but alas... */
+	spin_lock(&t->lock);
+	for (i = 0; i < len; i++) {
+		if (test_bit(offset + i, t->map) == 0)
+			BUG();
+		__clear_bit(offset + i, t->map);
+	}
+	t->used -= len;
+	spin_unlock(&t->lock);
+}
+
+void bit_map_init(struct bit_map *t, unsigned long *map, int size)
+{
+
+	if ((size & 07) != 0)
+		BUG();
+	memset(map, 0, size>>3);
+
+	memset(t, 0, sizeof *t);
+	spin_lock_init(&t->lock);
+	t->map = map;
+	t->size = size;
+}
diff -Nru a/arch/sparc/mm/init.c b/arch/sparc/mm/init.c
--- a/arch/sparc/mm/init.c	Wed Apr 30 22:28:08 2003
+++ b/arch/sparc/mm/init.c	Wed Apr 30 22:28:08 2003
@@ -18,9 +18,7 @@
 #include <linux/mman.h>
 #include <linux/mm.h>
 #include <linux/swap.h>
-#ifdef CONFIG_BLK_DEV_INITRD
-#include <linux/blk.h>
-#endif
+#include <linux/initrd.h>
 #include <linux/init.h>
 #include <linux/highmem.h>
 #include <linux/bootmem.h>
@@ -89,8 +87,6 @@
 #endif	
 #endif
 }
-
-extern pgprot_t protection_map[16];
 
 void __init sparc_context_init(int numctx)
 {
diff -Nru a/arch/sparc/mm/io-unit.c b/arch/sparc/mm/io-unit.c
--- a/arch/sparc/mm/io-unit.c	Wed Apr 30 22:28:08 2003
+++ b/arch/sparc/mm/io-unit.c	Wed Apr 30 22:28:08 2003
@@ -176,13 +176,15 @@
 }
 
 #ifdef CONFIG_SBUS
-static void iounit_map_dma_area(unsigned long va, __u32 addr, int len)
+static int iounit_map_dma_area(dma_addr_t *pba, unsigned long va, __u32 addr, int len)
 {
 	unsigned long page, end;
 	pgprot_t dvma_prot;
 	iopte_t *iopte;
 	struct sbus_bus *sbus;
 
+	*pba = addr;
+
 	dvma_prot = __pgprot(SRMMU_CACHE | SRMMU_ET_PTE | SRMMU_PRIV);
 	end = PAGE_ALIGN((addr + len));
 	while(addr < end) {
@@ -213,6 +215,8 @@
 	}
 	flush_cache_all();
 	flush_tlb_all();
+
+	return 0;
 }
 
 static void iounit_unmap_dma_area(unsigned long addr, int len)
@@ -221,7 +225,7 @@
 }
 
 /* XXX We do not pass sbus device here, bad. */
-static unsigned long iounit_translate_dvma(unsigned long addr)
+static struct page *iounit_translate_dvma(unsigned long addr)
 {
 	struct sbus_bus *sbus = sbus_root;	/* They are all the same */
 	struct iounit_struct *iounit = (struct iounit_struct *)sbus->iommu;
@@ -230,7 +234,7 @@
 
 	i = ((addr - IOUNIT_DMA_BASE) >> PAGE_SHIFT);
 	iopte = (iopte_t *)(iounit->page_table + i);
-	return (iopte_val(*iopte) & 0xFFFFFFF0) << 4; /* XXX sun4d guru, help */
+	return pfn_to_page(iopte_val(*iopte) >> (PAGE_SHIFT-4)); /* XXX sun4d guru, help */
 }
 #endif
 
diff -Nru a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c
--- a/arch/sparc/mm/iommu.c	Wed Apr 30 22:28:18 2003
+++ b/arch/sparc/mm/iommu.c	Wed Apr 30 22:28:18 2003
@@ -23,6 +23,18 @@
 #include <asm/mbus.h>
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
+#include <asm/bitext.h>
+#include <asm/iommu.h>
+
+/*
+ * This can be sized dynamically, but we will do this
+ * only when we have a guidance about actual I/O pressures.
+ */
+#define IOMMU_RNGE	IOMMU_RNGE_256MB
+#define IOMMU_START	0xF0000000
+#define IOMMU_WINSIZE	(256*1024*1024U)
+#define IOMMU_NPTES	(IOMMU_WINSIZE/PAGE_SIZE)	/* 64K PTEs, 265KB */
+#define IOMMU_ORDER	6				/* 4096 * (1<<6) */
 
 /* srmmu.c */
 extern int viking_mxcc_present;
@@ -34,34 +46,30 @@
 extern void viking_flush_page(unsigned long page);
 extern void viking_mxcc_flush_page(unsigned long page);
 
-#define IOPERM        (IOPTE_CACHE | IOPTE_WRITE | IOPTE_VALID)
-#define MKIOPTE(phys) (((((phys)>>4) & IOPTE_PAGE) | IOPERM) & ~IOPTE_WAZ)
-
-static inline void iommu_map_dvma_pages_for_iommu(struct iommu_struct *iommu)
-{
-	unsigned long kern_end = (unsigned long) high_memory;
-	unsigned long first = PAGE_OFFSET;
-	unsigned long last = kern_end;
-	iopte_t *iopte = iommu->page_table;
+/*
+ * Values precomputed according to CPU type.
+ */
+static unsigned int ioperm_noc;		/* Consistent mapping iopte flags */
+static pgprot_t dvma_prot;		/* Consistent mapping pte flags */
 
-	iopte += ((first - iommu->start) >> PAGE_SHIFT);
-	while(first <= last) {
-		*iopte++ = __iopte(MKIOPTE(__pa(first)));
-		first += PAGE_SIZE;
-	}
-}
+#define IOPERM        (IOPTE_CACHE | IOPTE_WRITE | IOPTE_VALID)
+#define MKIOPTE(pfn, perm) (((((pfn)<<8) & IOPTE_PAGE) | (perm)) & ~IOPTE_WAZ)
 
 void __init
 iommu_init(int iommund, struct sbus_bus *sbus)
 {
-	unsigned int impl, vers, ptsize;
+	unsigned int impl, vers;
 	unsigned long tmp;
 	struct iommu_struct *iommu;
 	struct linux_prom_registers iommu_promregs[PROMREG_MAX];
 	struct resource r;
-	int i;
+	unsigned long *bitmap;
 
 	iommu = kmalloc(sizeof(struct iommu_struct), GFP_ATOMIC);
+	if (!iommu) {
+		prom_printf("Unable to allocate iommu structure\n");
+		prom_halt();
+	}
 	prom_getproperty(iommund, "reg", (void *) iommu_promregs,
 			 sizeof(iommu_promregs));
 	memset(&r, 0, sizeof(r));
@@ -69,93 +77,129 @@
 	r.start = iommu_promregs[0].phys_addr;
 	iommu->regs = (struct iommu_regs *)
 		sbus_ioremap(&r, 0, PAGE_SIZE * 3, "iommu_regs");
-	if(!iommu->regs)
-		panic("Cannot map IOMMU registers.");
+	if(!iommu->regs) {
+		prom_printf("Cannot map IOMMU registers\n");
+		prom_halt();
+	}
 	impl = (iommu->regs->control & IOMMU_CTRL_IMPL) >> 28;
 	vers = (iommu->regs->control & IOMMU_CTRL_VERS) >> 24;
 	tmp = iommu->regs->control;
 	tmp &= ~(IOMMU_CTRL_RNGE);
-	switch(PAGE_OFFSET & 0xf0000000) {
-	case 0xf0000000:
-		tmp |= (IOMMU_RNGE_256MB | IOMMU_CTRL_ENAB);
-		iommu->plow = iommu->start = 0xf0000000;
-		break;
-	case 0xe0000000:
-		tmp |= (IOMMU_RNGE_512MB | IOMMU_CTRL_ENAB);
-		iommu->plow = iommu->start = 0xe0000000;
-		break;
-	case 0xd0000000:
-	case 0xc0000000:
-		tmp |= (IOMMU_RNGE_1GB | IOMMU_CTRL_ENAB);
-		iommu->plow = iommu->start = 0xc0000000;
-		break;
-	case 0xb0000000:
-	case 0xa0000000:
-	case 0x90000000:
-	case 0x80000000:
-		tmp |= (IOMMU_RNGE_2GB | IOMMU_CTRL_ENAB);
-		iommu->plow = iommu->start = 0x80000000;
-		break;
-	}
+	tmp |= (IOMMU_RNGE_256MB | IOMMU_CTRL_ENAB);
 	iommu->regs->control = tmp;
 	iommu_invalidate(iommu->regs);
+	iommu->start = IOMMU_START;
 	iommu->end = 0xffffffff;
 
 	/* Allocate IOMMU page table */
-	ptsize = iommu->end - iommu->start + 1;
-	ptsize = (ptsize >> PAGE_SHIFT) * sizeof(iopte_t);
-
 	/* Stupid alignment constraints give me a headache. 
 	   We need 256K or 512K or 1M or 2M area aligned to
            its size and current gfp will fortunately give
            it to us. */
-	for (i = 6; i < 9; i++)
-		if ((1 << (i + PAGE_SHIFT)) == ptsize)
-			break;
-        tmp = __get_free_pages(GFP_KERNEL, i);
+        tmp = __get_free_pages(GFP_KERNEL, IOMMU_ORDER);
 	if (!tmp) {
-		prom_printf("Could not allocate iopte of size 0x%08x\n", ptsize);
+		prom_printf("Unable to allocate iommu table [0x%08x]\n",
+			    IOMMU_NPTES*sizeof(iopte_t));
 		prom_halt();
 	}
-	iommu->lowest = iommu->page_table = (iopte_t *)tmp;
+	iommu->page_table = (iopte_t *)tmp;
 
 	/* Initialize new table. */
+	memset(iommu->page_table, 0, IOMMU_NPTES*sizeof(iopte_t));
 	flush_cache_all();
-	memset(iommu->page_table, 0, ptsize);
-	iommu_map_dvma_pages_for_iommu(iommu);
-	if(viking_mxcc_present) {
-		unsigned long start = (unsigned long) iommu->page_table;
-		unsigned long end = (start + ptsize);
+	flush_tlb_all();
+	iommu->regs->base = __pa((unsigned long) iommu->page_table) >> 4;
+	iommu_invalidate(iommu->regs);
+
+	bitmap = kmalloc(IOMMU_NPTES>>3, GFP_KERNEL);
+	if (!bitmap) {
+		prom_printf("Unable to allocate iommu bitmap [%d]\n",
+			    (int)(IOMMU_NPTES>>3));
+		prom_halt();
+	}
+	bit_map_init(&iommu->usemap, bitmap, IOMMU_NPTES);
+
+	printk("IOMMU: impl %d vers %d table 0x%p[%d B] map [%d b]\n",
+	    impl, vers, iommu->page_table,
+	    (int)(IOMMU_NPTES*sizeof(iopte_t)), (int)IOMMU_NPTES);
+
+	sbus->iommu = iommu;
+}
+
+/* This begs to be btfixup-ed by srmmu. */
+static void iommu_viking_flush_iotlb(iopte_t *iopte, unsigned int niopte)
+{
+	unsigned long start;
+	unsigned long end;
+
+	start = (unsigned long)iopte & PAGE_MASK;
+	end = PAGE_ALIGN(start + niopte*sizeof(iopte_t));
+	if (viking_mxcc_present) {
 		while(start < end) {
 			viking_mxcc_flush_page(start);
 			start += PAGE_SIZE;
 		}
 	} else if (viking_flush) {
-		unsigned long start = (unsigned long) iommu->page_table;
-		unsigned long end = (start + ptsize);
 		while(start < end) {
 			viking_flush_page(start);
 			start += PAGE_SIZE;
 		}
 	}
-	flush_tlb_all();
-	iommu->regs->base = __pa((unsigned long) iommu->page_table) >> 4;
-	iommu_invalidate(iommu->regs);
+}
 
-	sbus->iommu = iommu;
-	printk("IOMMU: impl %d vers %d page table at %p of size %d bytes\n",
-	       impl, vers, iommu->page_table, ptsize);
+static u32 iommu_get_one(struct page *page, int npages, struct sbus_bus *sbus)
+{
+	struct iommu_struct *iommu = sbus->iommu;
+	int ioptex;
+	iopte_t *iopte, *iopte0;
+	unsigned int busa, busa0;
+	int i;
+
+	ioptex = bit_map_string_get(&iommu->usemap, npages, 1);
+	if (ioptex < 0)
+		panic("iommu out");
+	busa0 = iommu->start + (ioptex << PAGE_SHIFT);
+	iopte0 = &iommu->page_table[ioptex];
+
+	busa = busa0;
+	iopte = iopte0;
+	for (i = 0; i < npages; i++) {
+		iopte_val(*iopte) = MKIOPTE(page_to_pfn(page), IOPERM);
+		iommu_invalidate_page(iommu->regs, busa);
+		busa += PAGE_SIZE;
+		iopte++;
+		page++;
+	}
+
+	iommu_viking_flush_iotlb(iopte0, npages);
+
+	return busa0;
+}
+
+static u32 iommu_get_scsi_one(char *vaddr, unsigned int len,
+    struct sbus_bus *sbus)
+{
+	unsigned long off;
+	int npages;
+	struct page *page;
+	u32 busa;
+
+	off = (unsigned long)vaddr & ~PAGE_MASK;
+	npages = (off + len + PAGE_SIZE-1) >> PAGE_SHIFT;
+	page = virt_to_page((unsigned long)vaddr & PAGE_MASK);
+	busa = iommu_get_one(page, npages, sbus);
+	return busa + off;
 }
 
 static __u32 iommu_get_scsi_one_noflush(char *vaddr, unsigned long len, struct sbus_bus *sbus)
 {
-	return (__u32)vaddr;
+	return iommu_get_scsi_one(vaddr, len, sbus);
 }
 
 static __u32 iommu_get_scsi_one_gflush(char *vaddr, unsigned long len, struct sbus_bus *sbus)
 {
 	flush_page_for_dma(0);
-	return (__u32)vaddr;
+	return iommu_get_scsi_one(vaddr, len, sbus);
 }
 
 static __u32 iommu_get_scsi_one_pflush(char *vaddr, unsigned long len, struct sbus_bus *sbus)
@@ -166,75 +210,129 @@
 		flush_page_for_dma(page);
 		page += PAGE_SIZE;
 	}
-	return (__u32)vaddr;
+	return iommu_get_scsi_one(vaddr, len, sbus);
 }
 
 static void iommu_get_scsi_sgl_noflush(struct scatterlist *sg, int sz, struct sbus_bus *sbus)
 {
+	int n;
+
 	while (sz != 0) {
 		--sz;
-		sg[sz].dvma_address = (__u32) (page_address(sg[sz].page) + sg[sz].offset);
-		sg[sz].dvma_length = (__u32) (sg[sz].length);
+		n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT;
+		sg->dvma_address = iommu_get_one(sg->page, n, sbus) + sg->offset;
+		sg->dvma_length = (__u32) sg->length;
+		sg++;
 	}
 }
 
 static void iommu_get_scsi_sgl_gflush(struct scatterlist *sg, int sz, struct sbus_bus *sbus)
 {
+	int n;
+
 	flush_page_for_dma(0);
 	while (sz != 0) {
 		--sz;
-		sg[sz].dvma_address = (__u32) (page_address(sg[sz].page) + sg[sz].offset);
-		sg[sz].dvma_length = (__u32) (sg[sz].length);
+		n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT;
+		sg->dvma_address = iommu_get_one(sg->page, n, sbus) + sg->offset;
+		sg->dvma_length = (__u32) sg->length;
+		sg++;
 	}
 }
 
 static void iommu_get_scsi_sgl_pflush(struct scatterlist *sg, int sz, struct sbus_bus *sbus)
 {
 	unsigned long page, oldpage = 0;
+	int n, i;
 
 	while(sz != 0) {
 		--sz;
-		page = (unsigned long) page_address(sg[sz].page);
-		if (oldpage == page)
-			page += PAGE_SIZE; /* We flushed that page already */
-		while(page < (unsigned long)(page_address(sg[sz].page) + sg[sz].offset + sg[sz].length)) {
-			flush_page_for_dma(page);
-			page += PAGE_SIZE;
+
+		n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT;
+
+		/*
+		 * We expect unmapped highmem pages to be not in the cache.
+		 * XXX Is this a good assumption?
+		 * XXX What if someone else unmaps it here and races us?
+		 */
+		if ((page = (unsigned long) page_address(sg->page)) != 0) {
+			for (i = 0; i < n; i++) {
+				if (page != oldpage) {	/* Already flushed? */
+					flush_page_for_dma(page);
+					oldpage = page;
+				}
+				page += PAGE_SIZE;
+			}
 		}
-		sg[sz].dvma_address = (__u32) (page_address(sg[sz].page) + sg[sz].offset);
-		sg[sz].dvma_length = (__u32) (sg[sz].length);
-		oldpage = page - PAGE_SIZE;
+
+		sg->dvma_address = iommu_get_one(sg->page, n, sbus) + sg->offset;
+		sg->dvma_length = (__u32) sg->length;
+		sg++;
+	}
+}
+
+static void iommu_release_one(u32 busa, int npages, struct sbus_bus *sbus)
+{
+	struct iommu_struct *iommu = sbus->iommu;
+	int ioptex;
+	int i;
+
+	if (busa < iommu->start)
+		BUG();
+	ioptex = (busa - iommu->start) >> PAGE_SHIFT;
+	for (i = 0; i < npages; i++) {
+		iopte_val(iommu->page_table[ioptex + i]) = 0;
+		iommu_invalidate_page(iommu->regs, busa);
+		busa += PAGE_SIZE;
 	}
+	bit_map_clear(&iommu->usemap, ioptex, npages);
 }
 
 static void iommu_release_scsi_one(__u32 vaddr, unsigned long len, struct sbus_bus *sbus)
 {
+	unsigned long off;
+	int npages;
+
+	off = vaddr & ~PAGE_MASK;
+	npages = (off + len + PAGE_SIZE-1) >> PAGE_SHIFT;
+	iommu_release_one(vaddr & PAGE_MASK, npages, sbus);
 }
 
 static void iommu_release_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus *sbus)
 {
+	int n;
+
+	while(sz != 0) {
+		--sz;
+
+		n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT;
+		iommu_release_one(sg->dvma_address & PAGE_MASK, n, sbus);
+		sg->dvma_address = 0x21212121;
+		sg++;
+	}
 }
 
 #ifdef CONFIG_SBUS
-static void iommu_map_dma_area(unsigned long va, __u32 addr, int len)
+static int iommu_map_dma_area(dma_addr_t *pba, unsigned long va,
+    unsigned long addr, int len)
 {
-	unsigned long page, end, ipte_cache;
-	pgprot_t dvma_prot;
+	unsigned long page, end;
 	struct iommu_struct *iommu = sbus_root->iommu;
 	iopte_t *iopte = iommu->page_table;
 	iopte_t *first;
+	int ioptex;
 
-	if(viking_mxcc_present || srmmu_modtype == HyperSparc) {
-		dvma_prot = __pgprot(SRMMU_CACHE | SRMMU_ET_PTE | SRMMU_PRIV);
-		ipte_cache = 1;
-	} else {
-		dvma_prot = __pgprot(SRMMU_ET_PTE | SRMMU_PRIV);
-		ipte_cache = 0;
-	}
+	if ((va & ~PAGE_MASK) != 0) BUG();
+	if ((addr & ~PAGE_MASK) != 0) BUG();
+	if ((len & ~PAGE_MASK) != 0) BUG();
+
+	ioptex = bit_map_string_get(&iommu->usemap, len >> PAGE_SHIFT, 1);
+	if (ioptex < 0)
+		panic("iommu out");
 
-	iopte += ((addr - iommu->start) >> PAGE_SHIFT);
+	iopte += ioptex;
 	first = iopte;
-	end = PAGE_ALIGN((addr + len));
+	end = addr + len;
 	while(addr < end) {
 		page = va;
 		{
@@ -252,16 +350,11 @@
 			pgdp = pgd_offset(&init_mm, addr);
 			pmdp = pmd_offset(pgdp, addr);
 			ptep = pte_offset_map(pmdp, addr);
-			/* XXX What if we run out of atomic maps above */
 
 			set_pte(ptep, mk_pte(virt_to_page(page), dvma_prot));
-			if (ipte_cache != 0) {
-				iopte_val(*iopte++) = MKIOPTE(__pa(page));
-			} else {
-				iopte_val(*iopte++) =
-					MKIOPTE(__pa(page)) & ~IOPTE_CACHE;
-			}
 		}
+		iopte_val(*iopte++) =
+		    MKIOPTE(page_to_pfn(virt_to_page(page)), ioperm_noc);
 		addr += PAGE_SIZE;
 		va += PAGE_SIZE;
 	}
@@ -277,23 +370,12 @@
 	 *        to handle the latter case as well.
 	 */
 	flush_cache_all();
-	if(viking_mxcc_present) {
-		unsigned long start = ((unsigned long) first) & PAGE_MASK;
-		unsigned long end = PAGE_ALIGN(((unsigned long) iopte));
-		while(start < end) {
-			viking_mxcc_flush_page(start);
-			start += PAGE_SIZE;
-		}
-	} else if(viking_flush) {
-		unsigned long start = ((unsigned long) first) & PAGE_MASK;
-		unsigned long end = PAGE_ALIGN(((unsigned long) iopte));
-		while(start < end) {
-			viking_flush_page(start);
-			start += PAGE_SIZE;
-		}
-	}
+	iommu_viking_flush_iotlb(first, len >> PAGE_SHIFT);
 	flush_tlb_all();
 	iommu_invalidate(iommu->regs);
+
+	*pba = iommu->start + (ioptex << PAGE_SHIFT);
+	return 0;
 }
 
 static void iommu_unmap_dma_area(unsigned long busa, int len)
@@ -301,27 +383,29 @@
 	struct iommu_struct *iommu = sbus_root->iommu;
 	iopte_t *iopte = iommu->page_table;
 	unsigned long end;
+	int ioptex = (busa - iommu->start) >> PAGE_SHIFT;
 
-	iopte += ((busa - iommu->start) >> PAGE_SHIFT);
-	end = PAGE_ALIGN((busa + len));
+	if ((busa & ~PAGE_MASK) != 0) BUG();
+	if ((len & ~PAGE_MASK) != 0) BUG();
+
+	iopte += ioptex;
+	end = busa + len;
 	while (busa < end) {
 		iopte_val(*iopte++) = 0;
 		busa += PAGE_SIZE;
 	}
-	flush_tlb_all();	/* P3: Hmm... it would not hurt. */
+	flush_tlb_all();
 	iommu_invalidate(iommu->regs);
+	bit_map_clear(&iommu->usemap, ioptex, len >> PAGE_SHIFT);
 }
 
-static unsigned long iommu_translate_dvma(unsigned long busa)
+static struct page *iommu_translate_dvma(unsigned long busa)
 {
 	struct iommu_struct *iommu = sbus_root->iommu;
 	iopte_t *iopte = iommu->page_table;
-	unsigned long pa;
 
 	iopte += ((busa - iommu->start) >> PAGE_SHIFT);
-	pa = pte_val(*iopte);
-	pa = (pa & 0xFFFFFFF0) << 4;		/* Loose higher bits of 36 */
-	return pa + PAGE_OFFSET;
+	return pfn_to_page((pte_val(*iopte) & IOPTE_PAGE) >> (PAGE_SHIFT-4));
 }
 #endif
 
@@ -352,12 +436,20 @@
 		BTFIXUPSET_CALL(mmu_get_scsi_one, iommu_get_scsi_one_pflush, BTFIXUPCALL_NORM);
 		BTFIXUPSET_CALL(mmu_get_scsi_sgl, iommu_get_scsi_sgl_pflush, BTFIXUPCALL_NORM);
 	}
-	BTFIXUPSET_CALL(mmu_release_scsi_one, iommu_release_scsi_one, BTFIXUPCALL_NOP);
-	BTFIXUPSET_CALL(mmu_release_scsi_sgl, iommu_release_scsi_sgl, BTFIXUPCALL_NOP);
+	BTFIXUPSET_CALL(mmu_release_scsi_one, iommu_release_scsi_one, BTFIXUPCALL_NORM);
+	BTFIXUPSET_CALL(mmu_release_scsi_sgl, iommu_release_scsi_sgl, BTFIXUPCALL_NORM);
 
 #ifdef CONFIG_SBUS
 	BTFIXUPSET_CALL(mmu_map_dma_area, iommu_map_dma_area, BTFIXUPCALL_NORM);
 	BTFIXUPSET_CALL(mmu_unmap_dma_area, iommu_unmap_dma_area, BTFIXUPCALL_NORM);
 	BTFIXUPSET_CALL(mmu_translate_dvma, iommu_translate_dvma, BTFIXUPCALL_NORM);
 #endif
+
+	if (viking_mxcc_present || srmmu_modtype == HyperSparc) {
+		dvma_prot = __pgprot(SRMMU_CACHE | SRMMU_ET_PTE | SRMMU_PRIV);
+		ioperm_noc = IOPTE_CACHE | IOPTE_WRITE | IOPTE_VALID;
+	} else {
+		dvma_prot = __pgprot(SRMMU_ET_PTE | SRMMU_PRIV);
+		ioperm_noc = IOPTE_WRITE | IOPTE_VALID;
+	}
 }
diff -Nru a/arch/sparc/mm/loadmmu.c b/arch/sparc/mm/loadmmu.c
--- a/arch/sparc/mm/loadmmu.c	Wed Apr 30 22:28:11 2003
+++ b/arch/sparc/mm/loadmmu.c	Wed Apr 30 22:28:11 2003
@@ -26,7 +26,6 @@
 
 extern void ld_mmu_sun4c(void);
 extern void ld_mmu_srmmu(void);
-extern void ioport_init(void);
 
 void __init load_mmu(void)
 {
@@ -44,5 +43,4 @@
 		prom_halt();
 	}
 	btfixup();
-	ioport_init();
 }
diff -Nru a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
--- a/arch/sparc/mm/srmmu.c	Wed Apr 30 22:28:10 2003
+++ b/arch/sparc/mm/srmmu.c	Wed Apr 30 22:28:10 2003
@@ -21,6 +21,7 @@
 #include <linux/fs.h>
 #include <linux/seq_file.h>
 
+#include <asm/bitext.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
 #include <asm/pgtable.h>
@@ -137,29 +138,26 @@
 int srmmu_cache_pagetables;
 
 /* these will be initialized in srmmu_nocache_calcsize() */
-int srmmu_nocache_npages;
 unsigned long srmmu_nocache_size;
 unsigned long srmmu_nocache_end;
 unsigned long pkmap_base;
 unsigned long pkmap_base_end;
-unsigned long srmmu_nocache_bitmap_size;
 extern unsigned long fix_kmap_begin;
 extern unsigned long fix_kmap_end;
 
+/* 1 bit <=> 256 bytes of nocache <=> 64 PTEs */
 #define SRMMU_NOCACHE_BITMAP_SHIFT (PAGE_SHIFT - 4)
 
 void *srmmu_nocache_pool;
 void *srmmu_nocache_bitmap;
-int srmmu_nocache_low;
-int srmmu_nocache_used;
-static spinlock_t srmmu_nocache_spinlock = SPIN_LOCK_UNLOCKED;
+static struct bit_map srmmu_nocache_map;
 
 /* This makes sense. Honest it does - Anton */
 #define __nocache_pa(VADDR) (((unsigned long)VADDR) - SRMMU_NOCACHE_VADDR + __pa((unsigned long)srmmu_nocache_pool))
 #define __nocache_va(PADDR) (__va((unsigned long)PADDR) - (unsigned long)srmmu_nocache_pool + SRMMU_NOCACHE_VADDR)
 #define __nocache_fix(VADDR) __va(__nocache_pa(VADDR))
 
-static inline unsigned long srmmu_pte_pfn(pte_t pte)
+static unsigned long srmmu_pte_pfn(pte_t pte)
 {
 	if (srmmu_device_memory(pte_val(pte))) {
 		/* XXX Anton obviously had something in mind when he did this.
@@ -219,15 +217,6 @@
 static inline void srmmu_pgd_clear(pgd_t * pgdp)
 { srmmu_set_pte((pte_t *)pgdp, __pte(0)); }
 
-static inline int srmmu_pte_write(pte_t pte)
-{ return pte_val(pte) & SRMMU_WRITE; }
-
-static inline int srmmu_pte_dirty(pte_t pte)
-{ return pte_val(pte) & SRMMU_DIRTY; }
-
-static inline int srmmu_pte_young(pte_t pte)
-{ return pte_val(pte) & SRMMU_REF; }
-
 static inline pte_t srmmu_pte_wrprotect(pte_t pte)
 { return __pte(pte_val(pte) & ~SRMMU_WRITE);}
 
@@ -321,10 +310,7 @@
  */
 static unsigned long __srmmu_get_nocache(int size, int align)
 {
-	int offset = srmmu_nocache_low;
-	int i;
-	unsigned long va_tmp, phys_tmp;
-	int lowest_failed = 0;
+	int offset;
 
 	if (size < SRMMU_NOCACHE_BITMAP_SHIFT) {
 		printk("Size 0x%x too small for nocache request\n", size);
@@ -334,49 +320,20 @@
 		printk("Size 0x%x unaligned int nocache request\n", size);
 		size += SRMMU_NOCACHE_BITMAP_SHIFT-1;
 	}
-	size = size >> SRMMU_NOCACHE_BITMAP_SHIFT;
-
-	spin_lock(&srmmu_nocache_spinlock);
 
-repeat:
-	offset = find_next_zero_bit(srmmu_nocache_bitmap, srmmu_nocache_bitmap_size, offset);
-
-	/* we align on physical address */
-	if (align) {
-		va_tmp = (SRMMU_NOCACHE_VADDR + (offset << SRMMU_NOCACHE_BITMAP_SHIFT));
-		phys_tmp = (__nocache_pa(va_tmp) + align - 1) & ~(align - 1);
-		va_tmp = (unsigned long)__nocache_va(phys_tmp);
-		offset = (va_tmp - SRMMU_NOCACHE_VADDR) >> SRMMU_NOCACHE_BITMAP_SHIFT;
-	}
-
-	if ((srmmu_nocache_bitmap_size - offset) < size) {
-		printk("Run out of nocached RAM!\n");
-		spin_unlock(&srmmu_nocache_spinlock);
+	offset = bit_map_string_get(&srmmu_nocache_map,
+		       			size >> SRMMU_NOCACHE_BITMAP_SHIFT,
+					align >> SRMMU_NOCACHE_BITMAP_SHIFT);
+/* P3 */ /* printk("srmmu: get size %d align %d, got %d (0x%x)\n",
+   size >> SRMMU_NOCACHE_BITMAP_SHIFT, align >> SRMMU_NOCACHE_BITMAP_SHIFT,
+   offset, offset); */
+	if (offset == -1) {
+		printk("srmmu: out of nocache %d: %d/%d\n",
+		    size, (int) srmmu_nocache_size,
+		    srmmu_nocache_map.used << SRMMU_NOCACHE_BITMAP_SHIFT);
 		return 0;
 	}
 
-	i = 0;
-	while(i < size) {
-		if (test_bit(offset + i, srmmu_nocache_bitmap)) {
-			lowest_failed = 1;
-			offset = offset + i + 1;
-			goto repeat;
-		}
-		i++;
-	}
-
-	i = 0;
-	while(i < size) {
-		set_bit(offset + i, srmmu_nocache_bitmap);
-		i++;
-		srmmu_nocache_used++;
-	}
-
-	if (!lowest_failed && ((align >> SRMMU_NOCACHE_BITMAP_SHIFT) <= 1) && (offset > srmmu_nocache_low))
-		srmmu_nocache_low = offset;
-
-	spin_unlock(&srmmu_nocache_spinlock);
-
 	return (SRMMU_NOCACHE_VADDR + (offset << SRMMU_NOCACHE_BITMAP_SHIFT));
 }
 
@@ -422,63 +379,57 @@
 	offset = (vaddr - SRMMU_NOCACHE_VADDR) >> SRMMU_NOCACHE_BITMAP_SHIFT;
 	size = size >> SRMMU_NOCACHE_BITMAP_SHIFT;
 
-	spin_lock(&srmmu_nocache_spinlock);
-
-	while(size--) {
-		clear_bit(offset + size, srmmu_nocache_bitmap);
-		srmmu_nocache_used--;
-	}
-
-	if (offset < srmmu_nocache_low)
-		srmmu_nocache_low = offset;
-
-	spin_unlock(&srmmu_nocache_spinlock);
+/* P3 */ /* printk("srmmu: free off %d (0x%x) size %d\n", offset, offset, size); */
+	bit_map_clear(&srmmu_nocache_map, offset, size);
 }
 
 void srmmu_early_allocate_ptable_skeleton(unsigned long start, unsigned long end);
 
 extern unsigned long probe_memory(void);	/* in fault.c */
 
-/* Reserve nocache dynamically proportionally to the amount of
+/*
+ * Reserve nocache dynamically proportionally to the amount of
  * system RAM. -- Tomas Szepe <szepe@pinerecords.com>, June 2002
  */
 void srmmu_nocache_calcsize(void)
 {
 	unsigned long sysmemavail = probe_memory() / 1024;
+	int srmmu_nocache_npages;
 
 	srmmu_nocache_npages =
 		sysmemavail / SRMMU_NOCACHE_ALCRATIO / 1024 * 256;
-	if (sysmemavail % (SRMMU_NOCACHE_ALCRATIO * 1024))
-		srmmu_nocache_npages += 256;
+
+ /* P3 XXX The 4x overuse: corroborated by /proc/meminfo. */
+	// if (srmmu_nocache_npages < 256) srmmu_nocache_npages = 256;
+	if (srmmu_nocache_npages < 550) srmmu_nocache_npages = 550;
 
 	/* anything above 1280 blows up */
 	if (srmmu_nocache_npages > 1280) srmmu_nocache_npages = 1280;
 
 	srmmu_nocache_size = srmmu_nocache_npages * PAGE_SIZE;
-	srmmu_nocache_bitmap_size = srmmu_nocache_npages * 16;
 	srmmu_nocache_end = SRMMU_NOCACHE_VADDR + srmmu_nocache_size;
 	fix_kmap_begin = srmmu_nocache_end;
 	fix_kmap_end = fix_kmap_begin + (KM_TYPE_NR * NR_CPUS - 1) * PAGE_SIZE;
 	pkmap_base = SRMMU_NOCACHE_VADDR + srmmu_nocache_size + 0x40000;
 	pkmap_base_end = pkmap_base + LAST_PKMAP * PAGE_SIZE;
-
-	/* printk("system memory available = %luk\nnocache ram size = %luk\n",
-		sysmemavail, srmmu_nocache_size / 1024); */
 }
 
 void srmmu_nocache_init(void)
 {
+	unsigned int bitmap_bits;
 	pgd_t *pgd;
 	pmd_t *pmd;
 	pte_t *pte;
 	unsigned long paddr, vaddr;
 	unsigned long pteval;
 
+	bitmap_bits = srmmu_nocache_size >> SRMMU_NOCACHE_BITMAP_SHIFT;
+
 	srmmu_nocache_pool = __alloc_bootmem(srmmu_nocache_size, PAGE_SIZE, 0UL);
 	memset(srmmu_nocache_pool, 0, srmmu_nocache_size);
 
-	srmmu_nocache_bitmap = __alloc_bootmem(srmmu_nocache_bitmap_size, SMP_CACHE_BYTES, 0UL);
-	memset(srmmu_nocache_bitmap, 0, srmmu_nocache_bitmap_size);
+	srmmu_nocache_bitmap = __alloc_bootmem(bitmap_bits >> 3, SMP_CACHE_BYTES, 0UL);
+	bit_map_init(&srmmu_nocache_map, srmmu_nocache_bitmap, bitmap_bits);
 
 	srmmu_swapper_pg_dir = (pgd_t *)__srmmu_get_nocache(SRMMU_PGD_TABLE_SIZE, SRMMU_PGD_TABLE_SIZE);
 	memset(__nocache_fix(srmmu_swapper_pg_dir), 0, SRMMU_PGD_TABLE_SIZE);
@@ -486,11 +437,12 @@
 
 	srmmu_early_allocate_ptable_skeleton(SRMMU_NOCACHE_VADDR, srmmu_nocache_end);
 
-	spin_lock_init(&srmmu_nocache_spinlock);
-
 	paddr = __pa((unsigned long)srmmu_nocache_pool);
 	vaddr = SRMMU_NOCACHE_VADDR;
 
+/* P3 */ printk("srmmu: pool 0x%x vaddr 0x%x bitmap 0x%x bits %d (0x%x)\n",
+  (int)srmmu_nocache_pool, vaddr, srmmu_nocache_bitmap, bitmap_bits, bitmap_bits);
+
 	while (vaddr < srmmu_nocache_end) {
 		pgd = pgd_offset_k(vaddr);
 		pmd = srmmu_pmd_offset(__nocache_fix(pgd), vaddr);
@@ -637,7 +589,8 @@
 }
 
 /* Low level IO area allocation on the SRMMU. */
-void srmmu_mapioaddr(unsigned long physaddr, unsigned long virt_addr, int bus_type, int rdonly)
+static inline void srmmu_mapioaddr(unsigned long physaddr,
+    unsigned long virt_addr, int bus_type)
 {
 	pgd_t *pgdp;
 	pmd_t *pmdp;
@@ -656,16 +609,24 @@
 	 * 36-bit physical address on the I/O space lines...
 	 */
 	tmp |= (bus_type << 28);
-	if(rdonly)
-		tmp |= SRMMU_PRIV_RDONLY;
-	else
-		tmp |= SRMMU_PRIV;
+	tmp |= SRMMU_PRIV;
 	__flush_page_to_ram(virt_addr);
 	srmmu_set_pte(ptep, __pte(tmp));
+}
+
+static void srmmu_mapiorange(unsigned int bus, unsigned long xpa,
+    unsigned long xva, unsigned int len)
+{
+	while (len != 0) {
+		len -= PAGE_SIZE;
+		srmmu_mapioaddr(xpa, xva, bus);
+		xva += PAGE_SIZE;
+		xpa += PAGE_SIZE;
+	}
 	flush_tlb_all();
 }
 
-void srmmu_unmapioaddr(unsigned long virt_addr)
+static inline void srmmu_unmapioaddr(unsigned long virt_addr)
 {
 	pgd_t *pgdp;
 	pmd_t *pmdp;
@@ -677,6 +638,15 @@
 
 	/* No need to flush uncacheable page. */
 	srmmu_pte_clear(ptep);
+}
+
+static void srmmu_unmapiorange(unsigned long virt_addr, unsigned int len)
+{
+	while (len != 0) {
+		len -= PAGE_SIZE;
+		srmmu_unmapioaddr(virt_addr);
+		virt_addr += PAGE_SIZE;
+	}
 	flush_tlb_all();
 }
 
@@ -1398,7 +1368,7 @@
 		   srmmu_name,
 		   num_contexts,
 		   srmmu_nocache_size,
-		   (srmmu_nocache_used << SRMMU_NOCACHE_BITMAP_SHIFT));
+		   srmmu_nocache_map.used << SRMMU_NOCACHE_BITMAP_SHIFT);
 }
 
 static void srmmu_update_mmu_cache(struct vm_area_struct * vma, unsigned long address, pte_t pte)
@@ -2258,7 +2228,10 @@
 	BTFIXUPSET_CALL(pte_mkyoung, srmmu_pte_mkyoung, BTFIXUPCALL_ORINT(SRMMU_REF));
 	BTFIXUPSET_CALL(update_mmu_cache, srmmu_update_mmu_cache, BTFIXUPCALL_NOP);
 	BTFIXUPSET_CALL(destroy_context, srmmu_destroy_context, BTFIXUPCALL_NORM);
-	
+
+	BTFIXUPSET_CALL(sparc_mapiorange, srmmu_mapiorange, BTFIXUPCALL_NORM);
+	BTFIXUPSET_CALL(sparc_unmapiorange, srmmu_unmapiorange, BTFIXUPCALL_NORM);
+
 	BTFIXUPSET_CALL(mmu_info, srmmu_mmu_info, BTFIXUPCALL_NORM);
 
 	BTFIXUPSET_CALL(alloc_thread_info, srmmu_alloc_thread_info, BTFIXUPCALL_NORM);
diff -Nru a/arch/sparc/mm/sun4c.c b/arch/sparc/mm/sun4c.c
--- a/arch/sparc/mm/sun4c.c	Wed Apr 30 22:28:14 2003
+++ b/arch/sparc/mm/sun4c.c	Wed Apr 30 22:28:14 2003
@@ -248,7 +248,7 @@
 	_unused = sun4c_get_context();
 	sun4c_set_context(_unused);
 #ifdef CONFIG_SUN_AUXIO
-	_unused = *AUXREG;
+	_unused = get_auxio();
 #endif
 }
 
@@ -534,10 +534,13 @@
 }
 
 /* Addr is always aligned on a page boundary for us already. */
-static void sun4c_map_dma_area(unsigned long va, u32 addr, int len)
+static int sun4c_map_dma_area(dma_addr_t *pba, unsigned long va,
+    unsigned long addr, int len)
 {
 	unsigned long page, end;
 
+	*pba = addr;
+
 	end = PAGE_ALIGN((addr + len));
 	while (addr < end) {
 		page = va;
@@ -550,13 +553,15 @@
 		addr += PAGE_SIZE;
 		va += PAGE_SIZE;
 	}
+
+	return 0;
 }
 
-static unsigned long sun4c_translate_dvma(unsigned long busa)
+static struct page *sun4c_translate_dvma(unsigned long busa)
 {
 	/* Fortunately for us, bus_addr == uncached_virt in sun4c. */
 	unsigned long pte = sun4c_get_pte(busa);
-	return (pte << PAGE_SHIFT) + PAGE_OFFSET;
+	return pfn_to_page(pte & SUN4C_PFN_MASK);
 }
 
 static void sun4c_unmap_dma_area(unsigned long busa, int len)
@@ -1578,21 +1583,33 @@
 	}
 }
 
-void sun4c_mapioaddr(unsigned long physaddr, unsigned long virt_addr,
-		     int bus_type, int rdonly)
+static inline void sun4c_mapioaddr(unsigned long physaddr, unsigned long virt_addr)
 {
 	unsigned long page_entry;
 
 	page_entry = ((physaddr >> PAGE_SHIFT) & SUN4C_PFN_MASK);
 	page_entry |= ((pg_iobits | _SUN4C_PAGE_PRIV) & ~(_SUN4C_PAGE_PRESENT));
-	if (rdonly)
-		page_entry &= ~_SUN4C_WRITEABLE;
 	sun4c_put_pte(virt_addr, page_entry);
 }
 
-void sun4c_unmapioaddr(unsigned long virt_addr)
+static void sun4c_mapiorange(unsigned int bus, unsigned long xpa,
+    unsigned long xva, unsigned int len)
 {
-	sun4c_put_pte(virt_addr, 0);
+	while (len != 0) {
+		len -= PAGE_SIZE;
+		sun4c_mapioaddr(xpa, xva);
+		xva += PAGE_SIZE;
+		xpa += PAGE_SIZE;
+	}
+}
+
+static void sun4c_unmapiorange(unsigned long virt_addr, unsigned int len)
+{
+	while (len != 0) {
+		len -= PAGE_SIZE;
+		sun4c_put_pte(virt_addr, 0);
+		virt_addr += PAGE_SIZE;
+	}
 }
 
 static void sun4c_alloc_context(struct mm_struct *old_mm, struct mm_struct *mm)
@@ -1783,7 +1800,7 @@
  */
 static pte_t sun4c_mk_pte(struct page *page, pgprot_t pgprot)
 {
-	return __pte((page - mem_map) | pgprot_val(pgprot));
+	return __pte(page_to_pfn(page) | pgprot_val(pgprot));
 }
 
 static pte_t sun4c_mk_pte_phys(unsigned long phys_page, pgprot_t pgprot)
@@ -1901,7 +1918,7 @@
 	if ((pte = sun4c_pte_alloc_one_fast(mm, address)) != NULL)
 		return pte;
 
-	pte = (pte_t *)__get_free_page(GFP_KERNEL);
+	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (pte)
 		memset(pte, 0, PAGE_SIZE);
 	return pte;
@@ -2224,6 +2241,9 @@
 	BTFIXUPSET_CALL(mmu_map_dma_area, sun4c_map_dma_area, BTFIXUPCALL_NORM);
 	BTFIXUPSET_CALL(mmu_unmap_dma_area, sun4c_unmap_dma_area, BTFIXUPCALL_NORM);
 	BTFIXUPSET_CALL(mmu_translate_dvma, sun4c_translate_dvma, BTFIXUPCALL_NORM);
+
+	BTFIXUPSET_CALL(sparc_mapiorange, sun4c_mapiorange, BTFIXUPCALL_NORM);
+	BTFIXUPSET_CALL(sparc_unmapiorange, sun4c_unmapiorange, BTFIXUPCALL_NORM);
 
 	BTFIXUPSET_CALL(alloc_thread_info, sun4c_alloc_thread_info, BTFIXUPCALL_NORM);
 	BTFIXUPSET_CALL(free_thread_info, sun4c_free_thread_info, BTFIXUPCALL_NORM);
diff -Nru a/arch/sparc/prom/misc.c b/arch/sparc/prom/misc.c
--- a/arch/sparc/prom/misc.c	Wed Apr 30 22:28:14 2003
+++ b/arch/sparc/prom/misc.c	Wed Apr 30 22:28:14 2003
@@ -68,7 +68,7 @@
 	install_linux_ticker();
 	spin_unlock_irqrestore(&prom_lock, flags);
 #ifdef CONFIG_SUN_AUXIO
-	TURN_ON_LED;
+	set_auxio(AUXIO_LED, 0);
 #endif
 	if(!serial_console && prom_palette)
 		prom_palette (0);
diff -Nru a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
--- a/arch/sparc64/Kconfig	Wed Apr 30 22:28:16 2003
+++ b/arch/sparc64/Kconfig	Wed Apr 30 22:28:16 2003
@@ -114,7 +114,7 @@
 	  See also the <file:Documentation/smp.tex>,
 	  <file:Documentation/smp.txt>, <file:Documentation/i386/IO-APIC.txt>,
 	  <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you don't know what to do here, say N.
 
@@ -281,7 +281,7 @@
 	  To use your PC-cards, you will need supporting software from David
 	  Hinds' pcmcia-cs package (see the file <file:Documentation/Changes>
 	  for location).  Please also read the PCMCIA-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -314,7 +314,7 @@
 	  VESA. If you have PCI, say Y, otherwise N.
 
 	  The PCI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, contains valuable
+	  <http://www.tldp.org/docs.html#howto>, contains valuable
 	  information about which PCI hardware does work under Linux and which
 	  doesn't.
 
@@ -426,7 +426,7 @@
 	  want to say Y here.
 
 	  Information about ELF is contained in the ELF HOWTO available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you find that after upgrading from Linux kernel 1.2 and saying Y
 	  here, you still can't run any ELF binaries (they just crash), then
@@ -448,7 +448,7 @@
 	  programs that need an interpreter to run like Java, Python or
 	  Emacs-Lisp. It's also useful if you often run DOS executables under
 	  the Linux DOS emulator DOSEMU (read the DOSEMU-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>). Once you have
+	  <http://www.tldp.org/docs.html#howto>). Once you have
 	  registered such a binary class with the kernel, you can start one of
 	  those programs simply by typing in its name at a shell prompt; Linux
 	  will automatically feed it to the correct interpreter.
@@ -496,7 +496,7 @@
 	  box (as opposed to using a serial printer; if the connector at the
 	  printer has 9 or 25 holes ["female"], then it's serial), say Y.
 	  Also read the Printing-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  It is possible to share one parallel port among several devices
 	  (e.g. printer and ZIP drive) and it is safe to compile the
@@ -804,7 +804,7 @@
 	  If you want to use a SCSI hard disk or the SCSI or parallel port
 	  version of the IOMEGA ZIP drive under Linux, say Y and read the
 	  SCSI-HOWTO, the Disk-HOWTO and the Multi-Disk-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. This is NOT for SCSI
+	  <http://www.tldp.org/docs.html#howto>. This is NOT for SCSI
 	  CD-ROMs.
 
 	  This driver is also available as a module ( = code which can be
@@ -839,7 +839,7 @@
 	---help---
 	  If you want to use a SCSI tape drive under Linux, say Y and read the
 	  SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, and
+	  <http://www.tldp.org/docs.html#howto>, and
 	  <file:Documentation/scsi/st.txt> in the kernel source.  This is NOT
 	  for SCSI CD-ROMs.
 
@@ -861,7 +861,7 @@
 	  tape drives (ADR-x0) that supports the standard SCSI-2 commands for
 	  tapes (QIC-157) and can be driven by the standard driver st.
 	  For more information, you may have a look at the SCSI-HOWTO
-	  <http://www.linuxdoc.org/docs.html#howto>  and
+	  <http://www.tldp.org/docs.html#howto>  and
 	  <file:Documentation/scsi/osst.txt>  in the kernel source.
 	  More info on the OnStream driver may be found on
 	  <http://linux1.onstream.nl/test/>
@@ -880,7 +880,7 @@
 	---help---
 	  If you want to use a SCSI CD-ROM under Linux, say Y and read the
 	  SCSI-HOWTO and the CD-ROM-HOWTO at
-	  <http://www.linuxdoc.org/docs.html#howto>. Also make sure to say Y
+	  <http://www.tldp.org/docs.html#howto>. Also make sure to say Y
 	  or M to "ISO 9660 CD-ROM file system support" later.
 
 	  This driver is also available as a module ( = code which can be
@@ -1060,7 +1060,7 @@
 	  configuration options. You should read
 	  <file:Documentation/scsi/aic7xxx_old.txt> at a minimum before
 	  contacting the maintainer with any questions.  The SCSI-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>, can also
+	  available from <http://www.tldp.org/docs.html#howto>, can also
 	  be of great help.
 
 	  If you want to compile this driver as a module ( = code which can be
@@ -1406,7 +1406,7 @@
 
 	  Please read the file <file:Documentation/scsi/qlogicisp.txt>.  You
 	  should also read the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -1586,7 +1586,7 @@
 	  interrupt and DMA channel), because you will be asked for it.
 
 	  You want to read the Sound-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. General information about
+	  <http://www.tldp.org/docs.html#howto>. General information about
 	  the modular sound system is contained in the files
 	  <file:Documentation/sound/Introduction>.  The file
 	  <file:Documentation/sound/README.OSS> contains some slightly
diff -Nru a/arch/sparc64/defconfig b/arch/sparc64/defconfig
--- a/arch/sparc64/defconfig	Wed Apr 30 22:28:07 2003
+++ b/arch/sparc64/defconfig	Wed Apr 30 22:28:07 2003
@@ -334,7 +334,30 @@
 #
 # IEEE 1394 (FireWire) support (EXPERIMENTAL)
 #
-# CONFIG_IEEE1394 is not set
+CONFIG_IEEE1394=m
+
+#
+# Subsystem Options
+#
+# CONFIG_IEEE1394_VERBOSEDEBUG is not set
+CONFIG_IEEE1394_OUI_DB=y
+
+#
+# Device Drivers
+#
+CONFIG_IEEE1394_OHCI1394=m
+
+#
+# Protocol Drivers
+#
+CONFIG_IEEE1394_VIDEO1394=m
+CONFIG_IEEE1394_SBP2=m
+# CONFIG_IEEE1394_SBP2_PHYS_DMA is not set
+CONFIG_IEEE1394_ETH1394=m
+CONFIG_IEEE1394_DV1394=m
+CONFIG_IEEE1394_RAWIO=m
+CONFIG_IEEE1394_CMP=m
+CONFIG_IEEE1394_AMDTP=m
 
 #
 # Networking support
@@ -347,25 +370,103 @@
 CONFIG_PACKET=y
 CONFIG_PACKET_MMAP=y
 CONFIG_NETLINK_DEV=y
-# CONFIG_NETFILTER is not set
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
 CONFIG_UNIX=y
 CONFIG_NET_KEY=m
 CONFIG_INET=y
 # CONFIG_IP_MULTICAST is not set
 # CONFIG_IP_ADVANCED_ROUTER is not set
 # CONFIG_IP_PNP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
 CONFIG_ARPD=y
 CONFIG_INET_ECN=y
 # CONFIG_SYN_COOKIES is not set
 CONFIG_INET_AH=y
 CONFIG_INET_ESP=y
 CONFIG_INET_IPCOMP=y
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_LIMIT=m
+CONFIG_IP_NF_MATCH_MAC=m
+CONFIG_IP_NF_MATCH_PKTTYPE=m
+CONFIG_IP_NF_MATCH_MARK=m
+CONFIG_IP_NF_MATCH_MULTIPORT=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH_ESP=m
+CONFIG_IP_NF_MATCH_LENGTH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_TCPMSS=m
+CONFIG_IP_NF_MATCH_HELPER=m
+CONFIG_IP_NF_MATCH_STATE=m
+CONFIG_IP_NF_MATCH_CONNTRACK=m
+CONFIG_IP_NF_MATCH_UNCLEAN=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_PHYSDEV=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_MIRROR=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_NAT_LOCAL=y
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_MARK=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_COMPAT_IPCHAINS=m
+CONFIG_IP_NF_COMPAT_IPFWADM=m
 CONFIG_IPV6=m
 CONFIG_IPV6_PRIVACY=y
 CONFIG_INET6_AH=m
 CONFIG_INET6_ESP=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_LIMIT=m
+CONFIG_IP6_NF_MATCH_MAC=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_MULTIPORT=m
+CONFIG_IP6_NF_MATCH_OWNER=m
+CONFIG_IP6_NF_MATCH_MARK=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AHESP=m
+CONFIG_IP6_NF_MATCH_LENGTH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_MARK=m
 CONFIG_XFRM_USER=m
 
 #
@@ -387,7 +488,20 @@
 CONFIG_DECNET=m
 CONFIG_DECNET_SIOCGIFCONF=y
 # CONFIG_DECNET_ROUTER is not set
-# CONFIG_BRIDGE is not set
+CONFIG_BRIDGE=m
+CONFIG_BRIDGE_NF_EBTABLES=m
+CONFIG_BRIDGE_EBT_T_FILTER=m
+CONFIG_BRIDGE_EBT_T_NAT=m
+CONFIG_BRIDGE_EBT_BROUTE=m
+CONFIG_BRIDGE_EBT_LOG=m
+CONFIG_BRIDGE_EBT_IPF=m
+CONFIG_BRIDGE_EBT_ARPF=m
+CONFIG_BRIDGE_EBT_VLANF=m
+CONFIG_BRIDGE_EBT_MARKF=m
+CONFIG_BRIDGE_EBT_SNAT=m
+CONFIG_BRIDGE_EBT_DNAT=m
+CONFIG_BRIDGE_EBT_REDIRECT=m
+CONFIG_BRIDGE_EBT_MARK_T=m
 # CONFIG_X25 is not set
 # CONFIG_LAPB is not set
 # CONFIG_NET_DIVERT is not set
@@ -410,6 +524,7 @@
 CONFIG_NET_SCH_TBF=m
 CONFIG_NET_SCH_GRED=m
 CONFIG_NET_SCH_DSMARK=m
+CONFIG_NET_SCH_INGRESS=m
 CONFIG_NET_QOS=y
 CONFIG_NET_ESTIMATOR=y
 CONFIG_NET_CLS=y
diff -Nru a/arch/sparc64/kernel/auxio.c b/arch/sparc64/kernel/auxio.c
--- a/arch/sparc64/kernel/auxio.c	Wed Apr 30 22:28:11 2003
+++ b/arch/sparc64/kernel/auxio.c	Wed Apr 30 22:28:11 2003
@@ -1,28 +1,114 @@
 /* auxio.c: Probing for the Sparc AUXIO register at boot time.
  *
  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
+ *
+ * Refactoring for unified NCR/PCIO support 2002 Eric Brower (ebrower@usa.net)
  */
 
 #include <linux/config.h>
-#include <linux/stddef.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/smp.h>
 #include <linux/init.h>
-#include <linux/delay.h>
 #include <linux/ioport.h>
 
 #include <asm/oplib.h>
 #include <asm/io.h>
-#include <asm/auxio.h>
 #include <asm/sbus.h>
 #include <asm/ebus.h>
-#include <asm/fhc.h>
-#include <asm/spitfire.h>
-#include <asm/starfire.h>
+#include <asm/auxio.h>
+
+/* This cannot be static, as it is referenced in entry.S */
+unsigned long auxio_register = 0UL;
+
+enum auxio_type {
+	AUXIO_TYPE_NODEV,
+	AUXIO_TYPE_SBUS,
+	AUXIO_TYPE_EBUS
+};
+
+static enum auxio_type auxio_devtype = AUXIO_TYPE_NODEV;
+static spinlock_t auxio_lock = SPIN_LOCK_UNLOCKED;
+
+static void __auxio_sbus_set(u8 bits_on, u8 bits_off)
+{
+	if(auxio_register) {
+		unsigned char regval;
+		unsigned long flags;
+		unsigned char newval;
+
+		spin_lock_irqsave(&auxio_lock, flags);
+
+		regval =  sbus_readb(auxio_register);
+		newval =  regval | bits_on;
+		newval &= ~bits_off;
+		newval &= ~AUXIO_AUX1_MASK;
+		sbus_writeb(newval, auxio_register);
+		
+		spin_unlock_irqrestore(&auxio_lock, flags);
+	}
+}
+
+static void __auxio_ebus_set(u8 bits_on, u8 bits_off)
+{
+	if(auxio_register) {
+		unsigned char regval;
+		unsigned long flags;
+		unsigned char newval;
+
+		spin_lock_irqsave(&auxio_lock, flags);
+
+		regval =  (u8)readl(auxio_register);
+		newval =  regval | bits_on;
+		newval &= ~bits_off;
+		writel((u32)newval, auxio_register);
+
+		spin_unlock_irqrestore(&auxio_lock, flags);
+	}
+}
+
+static inline void __auxio_ebus_set_led(int on)
+{
+	(on) ? __auxio_ebus_set(AUXIO_PCIO_LED, 0) :
+		__auxio_ebus_set(0, AUXIO_PCIO_LED) ;
+}
 
-/* Probe and map in the Auxiliary I/O register */
-unsigned long auxio_register = 0;
+static inline void __auxio_sbus_set_led(int on)
+{
+	(on) ? __auxio_sbus_set(AUXIO_AUX1_LED, 0) :
+		__auxio_sbus_set(0, AUXIO_AUX1_LED) ;
+}
+
+void auxio_set_led(int on)
+{
+	switch(auxio_devtype) {
+	case AUXIO_TYPE_SBUS:
+		__auxio_sbus_set_led(on);
+		break;
+	case AUXIO_TYPE_EBUS:
+		__auxio_ebus_set_led(on);
+		break;
+	default:
+		break;
+	}
+}
+
+static inline void __auxio_sbus_set_lte(int on)
+{
+	(on) ? __auxio_sbus_set(AUXIO_AUX1_LTE, 0) : 
+		__auxio_sbus_set(0, AUXIO_AUX1_LTE) ;
+}
+
+void auxio_set_lte(int on)
+{
+	switch(auxio_devtype) {
+	case AUXIO_TYPE_SBUS:
+		__auxio_sbus_set_lte(on);
+		break;
+	case AUXIO_TYPE_EBUS:
+		/* FALL-THROUGH */
+	default:
+		break;
+	}
+}
 
 void __init auxio_probe(void)
 {
@@ -37,11 +123,15 @@
         }
 
 found_sdev:
-	if (!sdev) {
+	if (sdev) {
+		auxio_devtype  = AUXIO_TYPE_SBUS;
+		auxio_register = sbus_ioremap(&sdev->resource[0], 0,
+		  		sdev->reg_addrs[0].reg_size, "auxiliaryIO");
+	}
 #ifdef CONFIG_PCI
+	else {
 		struct linux_ebus *ebus;
 		struct linux_ebus_device *edev = 0;
-		unsigned long led_auxio;
 
 		for_each_ebus(ebus) {
 			for_each_ebusdev(edev, ebus) {
@@ -50,19 +140,12 @@
 			}
 		}
 	ebus_done:
-
 		if (edev) {
-			led_auxio = edev->resource[0].start;
-			outl(0x01, led_auxio);
-			return;
+			auxio_devtype  = AUXIO_TYPE_EBUS;
+			auxio_register = (unsigned long)
+				ioremap(edev->resource[0].start, sizeof(u32));
 		}
-#endif
-		auxio_register = 0UL;
-		return;
 	}
-
-	/* Map the register both read and write */
-	auxio_register = sbus_ioremap(&sdev->resource[0], 0,
-				      sdev->reg_addrs[0].reg_size, "auxiliaryIO");
-	TURN_ON_LED;
+	auxio_set_led(AUXIO_LED_ON);
+#endif
 }
diff -Nru a/arch/sparc64/kernel/chmc.c b/arch/sparc64/kernel/chmc.c
--- a/arch/sparc64/kernel/chmc.c	Wed Apr 30 22:28:06 2003
+++ b/arch/sparc64/kernel/chmc.c	Wed Apr 30 22:28:06 2003
@@ -224,7 +224,7 @@
 		int dimm;
 
 		/* Multi-bit error, we just dump out all the
-		 * dimm labels assosciated with this bank.
+		 * dimm labels associated with this bank.
 		 */
 		for (dimm = 0; dimm < CHMCTRL_NDIMMS; dimm++) {
 			sprintf(buf, "%s ",
diff -Nru a/arch/sparc64/kernel/devices.c b/arch/sparc64/kernel/devices.c
--- a/arch/sparc64/kernel/devices.c	Wed Apr 30 22:28:06 2003
+++ b/arch/sparc64/kernel/devices.c	Wed Apr 30 22:28:06 2003
@@ -40,7 +40,6 @@
 
 	/* FIX ME FAST... -DaveM */
 	ioport_resource.end = 0xffffffffffffffffUL;
-	iomem_resource.end = 0xffffffffffffffffUL;
 
 	prom_getstring(prom_root_node, "device_type", node_str, sizeof(node_str));
 
diff -Nru a/arch/sparc64/kernel/ebus.c b/arch/sparc64/kernel/ebus.c
--- a/arch/sparc64/kernel/ebus.c	Wed Apr 30 22:28:07 2003
+++ b/arch/sparc64/kernel/ebus.c	Wed Apr 30 22:28:07 2003
@@ -73,7 +73,7 @@
 	}
 }
 
-static void ebus_dma_irq(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t ebus_dma_irq(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct ebus_dma_info *p = dev_id;
 	unsigned long flags;
@@ -87,12 +87,16 @@
 	if (csr & EBDMA_CSR_ERR_PEND) {
 		printk(KERN_CRIT "ebus_dma(%s): DMA error!\n", p->name);
 		p->callback(p, EBUS_DMA_EVENT_ERROR, p->client_cookie);
+		return IRQ_HANDLED;
 	} else if (csr & EBDMA_CSR_INT_PEND) {
 		p->callback(p,
 			    (csr & EBDMA_CSR_TC) ?
 			    EBUS_DMA_EVENT_DMA : EBUS_DMA_EVENT_DEVICE,
 			    p->client_cookie);
+		return IRQ_HANDLED;
 	}
+
+	return IRQ_NONE;
 }
 
 int ebus_dma_register(struct ebus_dma_info *p)
diff -Nru a/arch/sparc64/kernel/entry.S b/arch/sparc64/kernel/entry.S
--- a/arch/sparc64/kernel/entry.S	Wed Apr 30 22:28:02 2003
+++ b/arch/sparc64/kernel/entry.S	Wed Apr 30 22:28:02 2003
@@ -20,6 +20,7 @@
 #include <asm/processor.h>
 #include <asm/visasm.h>
 #include <asm/estate.h>
+#include <asm/auxio.h>
 
 /* #define SYSCALL_TRACING	1 */
 
@@ -662,9 +663,11 @@
 	sethi		%hi(auxio_register), %g1
 	ldx		[%g1 + %lo(auxio_register)], %g7
 	lduba		[%g7] ASI_PHYS_BYPASS_EC_E, %g5
-	or		%g5, 0xc2, %g5
+	or		%g5, AUXIO_AUX1_FTCNT, %g5
+/*	andn		%g5, AUXIO_AUX1_MASK, %g5 */
 	stba		%g5, [%g7] ASI_PHYS_BYPASS_EC_E
-	andn		%g5, 0x02, %g5
+	andn		%g5, AUXIO_AUX1_FTCNT, %g5
+/*	andn		%g5, AUXIO_AUX1_MASK, %g5 */
 
 	nop; nop;  nop; nop;  nop; nop;
 	nop; nop;  nop; nop;  nop; nop;
@@ -1264,7 +1267,7 @@
 	 * because corrupt data may have been placed there and we don't
 	 * want to reference it.
 	 *
-	 * %g1 is one if this trap occured at %tl >= 1.
+	 * %g1 is one if this trap occurred at %tl >= 1.
 	 *
 	 * Next, we turn off error reporting so that we don't recurse.
 	 */
diff -Nru a/arch/sparc64/kernel/head.S b/arch/sparc64/kernel/head.S
--- a/arch/sparc64/kernel/head.S	Wed Apr 30 22:28:08 2003
+++ b/arch/sparc64/kernel/head.S	Wed Apr 30 22:28:08 2003
@@ -84,7 +84,7 @@
 	 nop
 
 cheetah_plus_boot:
-	/* Preserve OBP choosen DCU and DCR register settings.  */
+	/* Preserve OBP chosen DCU and DCR register settings.  */
 	ba,pt	%xcc, cheetah_generic_boot
 	 nop
 
diff -Nru a/arch/sparc64/kernel/ioctl32.c b/arch/sparc64/kernel/ioctl32.c
--- a/arch/sparc64/kernel/ioctl32.c	Wed Apr 30 22:28:16 2003
+++ b/arch/sparc64/kernel/ioctl32.c	Wed Apr 30 22:28:16 2003
@@ -11,6 +11,7 @@
 #include <linux/config.h>
 #include <linux/types.h>
 #include <linux/compat.h>
+#include <linux/ioctl32.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/smp.h>
@@ -670,7 +671,7 @@
 	return (void *) (usp - len);
 }
 
-static int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
+int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
 	struct ifreq *u_ifreq64;
 	struct ifreq32 *u_ifreq32 = (struct ifreq32 *) arg;
@@ -2109,7 +2110,7 @@
 	if (tty_paranoia_check(tty, inode->i_rdev, "tty_ioctl"))
 		return -EINVAL;
 	                                                
-	if (tty->driver.ioctl != vt_ioctl)
+	if (tty->driver->ioctl != vt_ioctl)
 		return -EINVAL;
 	
 	/*
@@ -3137,7 +3138,7 @@
 #define DRM32_IOCTL_DMA	     DRM_IOWR(0x29, drm32_dma_t)
 
 /* RED PEN	The DRM layer blindly dereferences the send/request
- * 		indice/size arrays even though they are userland
+ * 		index/size arrays even though they are userland
  * 		pointers.  -DaveM
  */
 static int drm32_dma(unsigned int fd, unsigned int cmd, unsigned long arg)
@@ -3832,65 +3833,23 @@
 #define BNEPGETCONNLIST	_IOR('B', 210, int)
 #define BNEPGETCONNINFO	_IOR('B', 211, int)
 
-struct ioctl_trans {
-	unsigned int cmd;
-	unsigned int handler;
-	unsigned int next;
-};
+typedef int (* ioctl32_handler_t)(unsigned int, unsigned int, unsigned long, struct file *);
 
-#define COMPATIBLE_IOCTL(cmd) asm volatile(".word %0, sys_ioctl, 0" : : "i" (cmd));
-#define HANDLE_IOCTL(cmd,handler) asm volatile(".word %0, %1, 0" : : "i" (cmd), "i" (handler));
-#define IOCTL_TABLE_START void ioctl32_foo(void) { asm volatile(".data\nioctl_translations:");
-#define IOCTL_TABLE_END asm volatile("\nioctl_translations_end:\n\t.previous"); }
+#define COMPATIBLE_IOCTL(cmd)		HANDLE_IOCTL((cmd),sys_ioctl)
+#define HANDLE_IOCTL(cmd,handler)	{ (cmd), (ioctl32_handler_t)(handler), NULL },
+#define IOCTL_TABLE_START \
+	struct ioctl_trans ioctl_start[] = {
+#define IOCTL_TABLE_END \
+	}; struct ioctl_trans ioctl_end[0];
 
 IOCTL_TABLE_START
-/* List here exlicitly which ioctl's are known to have
- * compatible types passed or none at all...
- */
-/* Big T */
-COMPATIBLE_IOCTL(TCGETA)
-COMPATIBLE_IOCTL(TCSETA)
-COMPATIBLE_IOCTL(TCSETAW)
-COMPATIBLE_IOCTL(TCSETAF)
-COMPATIBLE_IOCTL(TCSBRK)
+#include <linux/compat_ioctl.h>
 COMPATIBLE_IOCTL(TCSBRKP)
-COMPATIBLE_IOCTL(TCXONC)
-COMPATIBLE_IOCTL(TCFLSH)
-COMPATIBLE_IOCTL(TCGETS)
-COMPATIBLE_IOCTL(TCSETS)
-COMPATIBLE_IOCTL(TCSETSW)
-COMPATIBLE_IOCTL(TCSETSF)
-COMPATIBLE_IOCTL(TIOCLINUX)
 COMPATIBLE_IOCTL(TIOCSTART)
 COMPATIBLE_IOCTL(TIOCSTOP)
-/* Little t */
-COMPATIBLE_IOCTL(TIOCGETD)
-COMPATIBLE_IOCTL(TIOCSETD)
-COMPATIBLE_IOCTL(TIOCEXCL)
-COMPATIBLE_IOCTL(TIOCNXCL)
-COMPATIBLE_IOCTL(TIOCCONS)
-COMPATIBLE_IOCTL(TIOCGSOFTCAR)
-COMPATIBLE_IOCTL(TIOCSSOFTCAR)
-COMPATIBLE_IOCTL(TIOCSWINSZ)
-COMPATIBLE_IOCTL(TIOCGWINSZ)
-COMPATIBLE_IOCTL(TIOCMGET)
-COMPATIBLE_IOCTL(TIOCMBIC)
-COMPATIBLE_IOCTL(TIOCMBIS)
-COMPATIBLE_IOCTL(TIOCMSET)
-COMPATIBLE_IOCTL(TIOCPKT)
-COMPATIBLE_IOCTL(TIOCNOTTY)
-COMPATIBLE_IOCTL(TIOCSTI)
-COMPATIBLE_IOCTL(TIOCOUTQ)
-COMPATIBLE_IOCTL(TIOCSPGRP)
-COMPATIBLE_IOCTL(TIOCGPGRP)
-COMPATIBLE_IOCTL(TIOCSCTTY)
-COMPATIBLE_IOCTL(TIOCGPTN)
-COMPATIBLE_IOCTL(TIOCSPTLCK)
 COMPATIBLE_IOCTL(TIOCGSERIAL)
 COMPATIBLE_IOCTL(TIOCSSERIAL)
-COMPATIBLE_IOCTL(TIOCSERGETLSR)
 COMPATIBLE_IOCTL(TIOCSLTC)
-/* Big F */
 COMPATIBLE_IOCTL(FBIOGTYPE)
 COMPATIBLE_IOCTL(FBIOSATTR)
 COMPATIBLE_IOCTL(FBIOGATTR)
@@ -3900,109 +3859,6 @@
 COMPATIBLE_IOCTL(FBIOSCURPOS)
 COMPATIBLE_IOCTL(FBIOGCURPOS)
 COMPATIBLE_IOCTL(FBIOGCURMAX)
-COMPATIBLE_IOCTL(FBIOGET_VSCREENINFO)
-COMPATIBLE_IOCTL(FBIOPUT_VSCREENINFO)
-COMPATIBLE_IOCTL(FBIOPAN_DISPLAY)
-COMPATIBLE_IOCTL(FBIOGET_CON2FBMAP)
-COMPATIBLE_IOCTL(FBIOPUT_CON2FBMAP)
-/* Little f */
-COMPATIBLE_IOCTL(FIOCLEX)
-COMPATIBLE_IOCTL(FIONCLEX)
-COMPATIBLE_IOCTL(FIOASYNC)
-COMPATIBLE_IOCTL(FIONBIO)
-COMPATIBLE_IOCTL(FIONREAD)  /* This is also TIOCINQ */
-/* 0x00 */
-COMPATIBLE_IOCTL(FIBMAP)
-COMPATIBLE_IOCTL(FIGETBSZ)
-/* 0x03 -- HD/IDE ioctl's used by hdparm and friends.
- *         Some need translations, these do not.
- */
-COMPATIBLE_IOCTL(HDIO_GET_IDENTITY)
-COMPATIBLE_IOCTL(HDIO_SET_DMA)
-COMPATIBLE_IOCTL(HDIO_SET_UNMASKINTR)
-COMPATIBLE_IOCTL(HDIO_SET_NOWERR)
-COMPATIBLE_IOCTL(HDIO_SET_32BIT)
-COMPATIBLE_IOCTL(HDIO_SET_MULTCOUNT)
-COMPATIBLE_IOCTL(HDIO_DRIVE_CMD)
-COMPATIBLE_IOCTL(HDIO_SET_PIO_MODE)
-COMPATIBLE_IOCTL(HDIO_SET_NICE)
-/* 0x02 -- Floppy ioctls */
-COMPATIBLE_IOCTL(FDMSGON)
-COMPATIBLE_IOCTL(FDMSGOFF)
-COMPATIBLE_IOCTL(FDSETEMSGTRESH)
-COMPATIBLE_IOCTL(FDFLUSH)
-COMPATIBLE_IOCTL(FDWERRORCLR)
-COMPATIBLE_IOCTL(FDSETMAXERRS)
-COMPATIBLE_IOCTL(FDGETMAXERRS)
-COMPATIBLE_IOCTL(FDGETDRVTYP)
-COMPATIBLE_IOCTL(FDEJECT)
-COMPATIBLE_IOCTL(FDCLRPRM)
-COMPATIBLE_IOCTL(FDFMTBEG)
-COMPATIBLE_IOCTL(FDFMTEND)
-COMPATIBLE_IOCTL(FDRESET)
-COMPATIBLE_IOCTL(FDTWADDLE)
-COMPATIBLE_IOCTL(FDFMTTRK)
-COMPATIBLE_IOCTL(FDRAWCMD)
-/* 0x12 */
-COMPATIBLE_IOCTL(BLKROSET)
-COMPATIBLE_IOCTL(BLKROGET)
-COMPATIBLE_IOCTL(BLKRRPART)
-COMPATIBLE_IOCTL(BLKFLSBUF)
-COMPATIBLE_IOCTL(BLKSECTSET)
-COMPATIBLE_IOCTL(BLKSSZGET)
-/* RAID */
-COMPATIBLE_IOCTL(RAID_VERSION)
-COMPATIBLE_IOCTL(GET_ARRAY_INFO)
-COMPATIBLE_IOCTL(GET_DISK_INFO)
-COMPATIBLE_IOCTL(PRINT_RAID_DEBUG)
-COMPATIBLE_IOCTL(CLEAR_ARRAY)
-COMPATIBLE_IOCTL(ADD_NEW_DISK)
-COMPATIBLE_IOCTL(HOT_REMOVE_DISK)
-COMPATIBLE_IOCTL(SET_ARRAY_INFO)
-COMPATIBLE_IOCTL(SET_DISK_INFO)
-COMPATIBLE_IOCTL(WRITE_RAID_INFO)
-COMPATIBLE_IOCTL(UNPROTECT_ARRAY)
-COMPATIBLE_IOCTL(PROTECT_ARRAY)
-COMPATIBLE_IOCTL(HOT_ADD_DISK)
-COMPATIBLE_IOCTL(SET_DISK_FAULTY)
-COMPATIBLE_IOCTL(RUN_ARRAY)
-COMPATIBLE_IOCTL(START_ARRAY)
-COMPATIBLE_IOCTL(STOP_ARRAY)
-COMPATIBLE_IOCTL(STOP_ARRAY_RO)
-COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
-
-/* Big K */
-COMPATIBLE_IOCTL(PIO_FONT)
-COMPATIBLE_IOCTL(GIO_FONT)
-COMPATIBLE_IOCTL(KDSIGACCEPT)
-COMPATIBLE_IOCTL(KDGETKEYCODE)
-COMPATIBLE_IOCTL(KDSETKEYCODE)
-COMPATIBLE_IOCTL(KIOCSOUND)
-COMPATIBLE_IOCTL(KDMKTONE)
-COMPATIBLE_IOCTL(KDGKBTYPE)
-COMPATIBLE_IOCTL(KDSETMODE)
-COMPATIBLE_IOCTL(KDGETMODE)
-COMPATIBLE_IOCTL(KDSKBMODE)
-COMPATIBLE_IOCTL(KDGKBMODE)
-COMPATIBLE_IOCTL(KDSKBMETA)
-COMPATIBLE_IOCTL(KDGKBMETA)
-COMPATIBLE_IOCTL(KDGKBENT)
-COMPATIBLE_IOCTL(KDSKBENT)
-COMPATIBLE_IOCTL(KDGKBSENT)
-COMPATIBLE_IOCTL(KDSKBSENT)
-COMPATIBLE_IOCTL(KDGKBDIACR)
-COMPATIBLE_IOCTL(KDKBDREP)
-COMPATIBLE_IOCTL(KDSKBDIACR)
-COMPATIBLE_IOCTL(KDGKBLED)
-COMPATIBLE_IOCTL(KDSKBLED)
-COMPATIBLE_IOCTL(KDGETLED)
-COMPATIBLE_IOCTL(KDSETLED)
-COMPATIBLE_IOCTL(GIO_SCRNMAP)
-COMPATIBLE_IOCTL(PIO_SCRNMAP)
-COMPATIBLE_IOCTL(GIO_UNISCRNMAP)
-COMPATIBLE_IOCTL(PIO_UNISCRNMAP)
-COMPATIBLE_IOCTL(PIO_FONTRESET)
-COMPATIBLE_IOCTL(PIO_UNIMAPCLR)
 /* Little k */
 COMPATIBLE_IOCTL(KIOCTYPE)
 COMPATIBLE_IOCTL(KIOCLAYOUT)
@@ -4014,81 +3870,11 @@
 COMPATIBLE_IOCTL(KIOCGLED)
 COMPATIBLE_IOCTL(KIOCSRATE)
 COMPATIBLE_IOCTL(KIOCGRATE)
-/* Big S */
-COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
-COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST)
-COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI)
-COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK)
-COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK)
-COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY)
-COMPATIBLE_IOCTL(SCSI_IOCTL_TAGGED_ENABLE)
-COMPATIBLE_IOCTL(SCSI_IOCTL_TAGGED_DISABLE)
-COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER)
-COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND)
-/* Big T */
-COMPATIBLE_IOCTL(TUNSETNOCSUM)
-COMPATIBLE_IOCTL(TUNSETDEBUG)
-COMPATIBLE_IOCTL(TUNSETIFF)
-COMPATIBLE_IOCTL(TUNSETPERSIST)
-COMPATIBLE_IOCTL(TUNSETOWNER)
-/* Big V */
-COMPATIBLE_IOCTL(VT_SETMODE)
-COMPATIBLE_IOCTL(VT_GETMODE)
-COMPATIBLE_IOCTL(VT_GETSTATE)
-COMPATIBLE_IOCTL(VT_OPENQRY)
-COMPATIBLE_IOCTL(VT_ACTIVATE)
-COMPATIBLE_IOCTL(VT_WAITACTIVE)
-COMPATIBLE_IOCTL(VT_RELDISP)
-COMPATIBLE_IOCTL(VT_DISALLOCATE)
-COMPATIBLE_IOCTL(VT_RESIZE)
-COMPATIBLE_IOCTL(VT_RESIZEX)
-COMPATIBLE_IOCTL(VT_LOCKSWITCH)
-COMPATIBLE_IOCTL(VT_UNLOCKSWITCH)
-/* Little v */
 COMPATIBLE_IOCTL(VUIDSFORMAT)
 COMPATIBLE_IOCTL(VUIDGFORMAT)
 /* Little v, the video4linux ioctls */
-COMPATIBLE_IOCTL(VIDIOCGCAP)
-COMPATIBLE_IOCTL(VIDIOCGCHAN)
-COMPATIBLE_IOCTL(VIDIOCSCHAN)
-COMPATIBLE_IOCTL(VIDIOCGPICT)
-COMPATIBLE_IOCTL(VIDIOCSPICT)
-COMPATIBLE_IOCTL(VIDIOCCAPTURE)
-COMPATIBLE_IOCTL(VIDIOCKEY)
-COMPATIBLE_IOCTL(VIDIOCGAUDIO)
-COMPATIBLE_IOCTL(VIDIOCSAUDIO)
-COMPATIBLE_IOCTL(VIDIOCSYNC)
-COMPATIBLE_IOCTL(VIDIOCMCAPTURE)
-COMPATIBLE_IOCTL(VIDIOCGMBUF)
-COMPATIBLE_IOCTL(VIDIOCGUNIT)
-COMPATIBLE_IOCTL(VIDIOCGCAPTURE)
-COMPATIBLE_IOCTL(VIDIOCSCAPTURE)
-/* BTTV specific... */
-COMPATIBLE_IOCTL(_IOW('v',  BASE_VIDIOCPRIVATE+0, char [256]))
-COMPATIBLE_IOCTL(_IOR('v',  BASE_VIDIOCPRIVATE+1, char [256]))
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int))
-COMPATIBLE_IOCTL(_IOW('v' , BASE_VIDIOCPRIVATE+3, char [16])) /* struct bttv_pll_info */
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+4, int))
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+5, int))
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+6, int))
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+7, int))
-/* Little p (/dev/rtc, /dev/envctrl, etc.) */
 COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */
 COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */
-COMPATIBLE_IOCTL(RTC_AIE_ON)
-COMPATIBLE_IOCTL(RTC_AIE_OFF)
-COMPATIBLE_IOCTL(RTC_UIE_ON)
-COMPATIBLE_IOCTL(RTC_UIE_OFF)
-COMPATIBLE_IOCTL(RTC_PIE_ON)
-COMPATIBLE_IOCTL(RTC_PIE_OFF)
-COMPATIBLE_IOCTL(RTC_WIE_ON)
-COMPATIBLE_IOCTL(RTC_WIE_OFF)
-COMPATIBLE_IOCTL(RTC_ALM_SET)
-COMPATIBLE_IOCTL(RTC_ALM_READ)
-COMPATIBLE_IOCTL(RTC_RD_TIME)
-COMPATIBLE_IOCTL(RTC_SET_TIME)
-COMPATIBLE_IOCTL(RTC_WKALM_SET)
-COMPATIBLE_IOCTL(RTC_WKALM_RD)
 COMPATIBLE_IOCTL(ENVCTRL_RD_WARNING_TEMPERATURE)
 COMPATIBLE_IOCTL(ENVCTRL_RD_SHUTDOWN_TEMPERATURE)
 COMPATIBLE_IOCTL(ENVCTRL_RD_CPU_TEMPERATURE)
@@ -4102,8 +3888,6 @@
 /* COMPATIBLE_IOCTL(D7SIOCRD) same value as ENVCTRL_RD_VOLTAGE_STATUS */
 COMPATIBLE_IOCTL(D7SIOCWR)
 COMPATIBLE_IOCTL(D7SIOCTM)
-/* Little m */
-COMPATIBLE_IOCTL(MTIOCTOP)
 /* OPENPROMIO, SunOS/Solaris only, the NetBSD one's have
  * embedded pointers in the arg which we'd need to clean up...
  */
@@ -4122,127 +3906,9 @@
 COMPATIBLE_IOCTL(OPROMSETCUR)
 COMPATIBLE_IOCTL(OPROMPCI2NODE)
 COMPATIBLE_IOCTL(OPROMPATH2NODE)
-/* Socket level stuff */
-COMPATIBLE_IOCTL(FIOSETOWN)
-COMPATIBLE_IOCTL(SIOCSPGRP)
-COMPATIBLE_IOCTL(FIOGETOWN)
-COMPATIBLE_IOCTL(SIOCGPGRP)
-COMPATIBLE_IOCTL(SIOCATMARK)
-COMPATIBLE_IOCTL(SIOCSIFLINK)
-COMPATIBLE_IOCTL(SIOCSIFENCAP)
-COMPATIBLE_IOCTL(SIOCGIFENCAP)
-COMPATIBLE_IOCTL(SIOCSIFBR)
-COMPATIBLE_IOCTL(SIOCGIFBR)
-COMPATIBLE_IOCTL(SIOCSARP)
-COMPATIBLE_IOCTL(SIOCGARP)
-COMPATIBLE_IOCTL(SIOCDARP)
-COMPATIBLE_IOCTL(SIOCSRARP)
-COMPATIBLE_IOCTL(SIOCGRARP)
-COMPATIBLE_IOCTL(SIOCDRARP)
-COMPATIBLE_IOCTL(SIOCADDDLCI)
-COMPATIBLE_IOCTL(SIOCDELDLCI)
-COMPATIBLE_IOCTL(SIOCGMIIPHY)
-COMPATIBLE_IOCTL(SIOCGMIIREG)
-COMPATIBLE_IOCTL(SIOCSMIIREG)
-COMPATIBLE_IOCTL(SIOCGIFVLAN)
-COMPATIBLE_IOCTL(SIOCSIFVLAN)
-/* SG stuff */
-COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
-COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
-COMPATIBLE_IOCTL(SG_EMULATED_HOST)
-COMPATIBLE_IOCTL(SG_SET_TRANSFORM)
-COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
-COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
-COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
-COMPATIBLE_IOCTL(SG_GET_SCSI_ID)
-COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA)
-COMPATIBLE_IOCTL(SG_GET_LOW_DMA)
-COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID)
-COMPATIBLE_IOCTL(SG_GET_PACK_ID)
-COMPATIBLE_IOCTL(SG_GET_NUM_WAITING)
-COMPATIBLE_IOCTL(SG_SET_DEBUG)
-COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE)
-COMPATIBLE_IOCTL(SG_GET_COMMAND_Q)
-COMPATIBLE_IOCTL(SG_SET_COMMAND_Q)
-COMPATIBLE_IOCTL(SG_GET_VERSION_NUM)
-COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN)
-COMPATIBLE_IOCTL(SG_SCSI_RESET)
-COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE)
-COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
-COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
-/* PPP stuff */
-COMPATIBLE_IOCTL(PPPIOCGFLAGS)
-COMPATIBLE_IOCTL(PPPIOCSFLAGS)
-COMPATIBLE_IOCTL(PPPIOCGASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCSASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCGUNIT)
-COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCGMRU)
-COMPATIBLE_IOCTL(PPPIOCSMRU)
-COMPATIBLE_IOCTL(PPPIOCSMAXCID)
-COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCXFERUNIT)
-/* PPPIOCSCOMPRESS is translated */
-COMPATIBLE_IOCTL(PPPIOCGNPMODE)
-COMPATIBLE_IOCTL(PPPIOCSNPMODE)
-/* PPPIOCSPASS is translated */
-/* PPPIOCSACTIVE is translated */
-COMPATIBLE_IOCTL(PPPIOCGDEBUG)
-COMPATIBLE_IOCTL(PPPIOCSDEBUG)
-/* PPPIOCGIDLE is translated */
-COMPATIBLE_IOCTL(PPPIOCNEWUNIT)
-COMPATIBLE_IOCTL(PPPIOCATTACH)
-COMPATIBLE_IOCTL(PPPIOCDETACH)
-COMPATIBLE_IOCTL(PPPIOCSMRRU)
-COMPATIBLE_IOCTL(PPPIOCCONNECT)
-COMPATIBLE_IOCTL(PPPIOCDISCONN)
-COMPATIBLE_IOCTL(PPPIOCATTCHAN)
-COMPATIBLE_IOCTL(PPPIOCGCHAN)
-/* LP */
-COMPATIBLE_IOCTL(LPGETSTATUS)
-/* PPPOX */
-COMPATIBLE_IOCTL(PPPOEIOCSFWD)
-COMPATIBLE_IOCTL(PPPOEIOCDFWD)
-/* CDROM stuff */
-COMPATIBLE_IOCTL(CDROMPAUSE)
-COMPATIBLE_IOCTL(CDROMRESUME)
-COMPATIBLE_IOCTL(CDROMPLAYMSF)
-COMPATIBLE_IOCTL(CDROMPLAYTRKIND)
-COMPATIBLE_IOCTL(CDROMREADTOCHDR)
-COMPATIBLE_IOCTL(CDROMREADTOCENTRY)
-COMPATIBLE_IOCTL(CDROMSTOP)
-COMPATIBLE_IOCTL(CDROMSTART)
-COMPATIBLE_IOCTL(CDROMEJECT)
-COMPATIBLE_IOCTL(CDROMVOLCTRL)
-COMPATIBLE_IOCTL(CDROMSUBCHNL)
-COMPATIBLE_IOCTL(CDROMEJECT_SW)
-COMPATIBLE_IOCTL(CDROMMULTISESSION)
-COMPATIBLE_IOCTL(CDROM_GET_MCN)
-COMPATIBLE_IOCTL(CDROMRESET)
-COMPATIBLE_IOCTL(CDROMVOLREAD)
-COMPATIBLE_IOCTL(CDROMSEEK)
-COMPATIBLE_IOCTL(CDROMPLAYBLK)
-COMPATIBLE_IOCTL(CDROMCLOSETRAY)
-COMPATIBLE_IOCTL(CDROM_SET_OPTIONS)
-COMPATIBLE_IOCTL(CDROM_CLEAR_OPTIONS)
-COMPATIBLE_IOCTL(CDROM_SELECT_SPEED)
-COMPATIBLE_IOCTL(CDROM_SELECT_DISC)
-COMPATIBLE_IOCTL(CDROM_MEDIA_CHANGED)
-COMPATIBLE_IOCTL(CDROM_DRIVE_STATUS)
-COMPATIBLE_IOCTL(CDROM_DISC_STATUS)
-COMPATIBLE_IOCTL(CDROM_CHANGER_NSLOTS)
-COMPATIBLE_IOCTL(CDROM_LOCKDOOR)
-COMPATIBLE_IOCTL(CDROM_DEBUG)
-COMPATIBLE_IOCTL(CDROM_GET_CAPABILITY)
-/* DVD ioctls */
-COMPATIBLE_IOCTL(DVD_READ_STRUCT)
-COMPATIBLE_IOCTL(DVD_WRITE_STRUCT)
-COMPATIBLE_IOCTL(DVD_AUTH)
 /* Big L */
-COMPATIBLE_IOCTL(LOOP_SET_FD)
-COMPATIBLE_IOCTL(LOOP_CLR_FD)
+COMPATIBLE_IOCTL(LOOP_SET_STATUS64)
+COMPATIBLE_IOCTL(LOOP_GET_STATUS64)
 /* Big A */
 COMPATIBLE_IOCTL(AUDIO_GETINFO)
 COMPATIBLE_IOCTL(AUDIO_SETINFO)
@@ -4250,175 +3916,10 @@
 COMPATIBLE_IOCTL(AUDIO_GETDEV)
 COMPATIBLE_IOCTL(AUDIO_GETDEV_SUNOS)
 COMPATIBLE_IOCTL(AUDIO_FLUSH)
-/* Big Q for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC)
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_INFO)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_CTRLRATE)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_GETOUTCOUNT)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_GETINCOUNT)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_PERCMODE)
-COMPATIBLE_IOCTL(SNDCTL_FM_LOAD_INSTR)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_TESTMIDI)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_RESETSAMPLES)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_NRSYNTHS)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_NRMIDIS)
-COMPATIBLE_IOCTL(SNDCTL_MIDI_INFO)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_THRESHOLD)
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_MEMAVL)
-COMPATIBLE_IOCTL(SNDCTL_FM_4OP_ENABLE)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_PANIC)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_OUTOFBAND)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_GETTIME)
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_ID)
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_CONTROL)
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_REMOVESAMPLE)
-/* Big T for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_TMR_TIMEBASE)
-COMPATIBLE_IOCTL(SNDCTL_TMR_START)
-COMPATIBLE_IOCTL(SNDCTL_TMR_STOP)
-COMPATIBLE_IOCTL(SNDCTL_TMR_CONTINUE)
-COMPATIBLE_IOCTL(SNDCTL_TMR_TEMPO)
-COMPATIBLE_IOCTL(SNDCTL_TMR_SOURCE)
-COMPATIBLE_IOCTL(SNDCTL_TMR_METRONOME)
-COMPATIBLE_IOCTL(SNDCTL_TMR_SELECT)
-/* Little m for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_MIDI_PRETIME)
-COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUMODE)
-COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUCMD)
-/* Big P for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_DSP_RESET)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SYNC)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SPEED)
-COMPATIBLE_IOCTL(SNDCTL_DSP_STEREO)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETBLKSIZE)
-COMPATIBLE_IOCTL(SNDCTL_DSP_CHANNELS)
-COMPATIBLE_IOCTL(SOUND_PCM_WRITE_FILTER)
-COMPATIBLE_IOCTL(SNDCTL_DSP_POST)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SUBDIVIDE)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETFRAGMENT)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETFMTS)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETFMT)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETOSPACE)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETISPACE)
-COMPATIBLE_IOCTL(SNDCTL_DSP_NONBLOCK)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETCAPS)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETTRIGGER)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETTRIGGER)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETIPTR)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETOPTR)
-/* SNDCTL_DSP_MAPINBUF,  XXX needs translation */
-/* SNDCTL_DSP_MAPOUTBUF,  XXX needs translation */
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETSYNCRO)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETDUPLEX)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETODELAY)
-COMPATIBLE_IOCTL(SNDCTL_DSP_PROFILE)
-COMPATIBLE_IOCTL(SOUND_PCM_READ_RATE)
-COMPATIBLE_IOCTL(SOUND_PCM_READ_CHANNELS)
-COMPATIBLE_IOCTL(SOUND_PCM_READ_BITS)
-COMPATIBLE_IOCTL(SOUND_PCM_READ_FILTER)
-/* Big C for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_COPR_RESET)
-COMPATIBLE_IOCTL(SNDCTL_COPR_LOAD)
-COMPATIBLE_IOCTL(SNDCTL_COPR_RDATA)
-COMPATIBLE_IOCTL(SNDCTL_COPR_RCODE)
-COMPATIBLE_IOCTL(SNDCTL_COPR_WDATA)
-COMPATIBLE_IOCTL(SNDCTL_COPR_WCODE)
-COMPATIBLE_IOCTL(SNDCTL_COPR_RUN)
-COMPATIBLE_IOCTL(SNDCTL_COPR_HALT)
-COMPATIBLE_IOCTL(SNDCTL_COPR_SENDMSG)
-COMPATIBLE_IOCTL(SNDCTL_COPR_RCVMSG)
-/* Big M for sound/OSS */
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_VOLUME)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_BASS)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_TREBLE)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_SYNTH)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_PCM)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_SPEAKER)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_MIC)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_CD)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_IMIX)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_ALTPCM)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECLEV)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_IGAIN)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_OGAIN)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE1)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE2)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE3)
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL1))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL2))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL3))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEIN))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEOUT))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_VIDEO))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_RADIO))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_MONITOR))
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_MUTE)
-/* SOUND_MIXER_READ_ENHANCE,  same value as READ_MUTE */
-/* SOUND_MIXER_READ_LOUD,  same value as READ_MUTE */
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECSRC)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_DEVMASK)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECMASK)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_STEREODEVS)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_CAPS)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_VOLUME)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_BASS)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_TREBLE)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SYNTH)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_PCM)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SPEAKER)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MIC)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_CD)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IMIX)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_ALTPCM)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECLEV)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IGAIN)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_OGAIN)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE1)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE2)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE3)
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL1))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL2))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL3))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEIN))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEOUT))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_VIDEO))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_RADIO))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_MONITOR))
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MUTE)
-/* SOUND_MIXER_WRITE_ENHANCE,  same value as WRITE_MUTE */
-/* SOUND_MIXER_WRITE_LOUD,  same value as WRITE_MUTE */
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECSRC)
-COMPATIBLE_IOCTL(SOUND_MIXER_INFO)
-COMPATIBLE_IOCTL(SOUND_OLD_MIXER_INFO)
-COMPATIBLE_IOCTL(SOUND_MIXER_ACCESS)
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE1)
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE2)
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE3)
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE4)
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
-COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
-COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
-COMPATIBLE_IOCTL(OSS_GETVERSION)
-/* AUTOFS */
-COMPATIBLE_IOCTL(AUTOFS_IOC_READY)
-COMPATIBLE_IOCTL(AUTOFS_IOC_FAIL)
-COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC)
-COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER)
-COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE)
 COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE_MULTI)
-/* DEVFS */
-COMPATIBLE_IOCTL(DEVFSDIOC_GET_PROTO_REV)
-COMPATIBLE_IOCTL(DEVFSDIOC_SET_EVENT_MASK)
-COMPATIBLE_IOCTL(DEVFSDIOC_RELEASE_EVENT_QUEUE)
-COMPATIBLE_IOCTL(DEVFSDIOC_SET_DEBUG_MASK)
 /* Raw devices */
 COMPATIBLE_IOCTL(RAW_SETBIND)
 COMPATIBLE_IOCTL(RAW_GETBIND)
-/* SMB ioctls which do not need any translations */
-COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
 /* NCP ioctls which do not need any translations */
 COMPATIBLE_IOCTL(NCP_IOC_CONN_LOGGED_IN)
 COMPATIBLE_IOCTL(NCP_IOC_SIGN_INIT)
@@ -4431,22 +3932,6 @@
 COMPATIBLE_IOCTL(NCP_IOC_SETCHARSETS)
 COMPATIBLE_IOCTL(NCP_IOC_GETDENTRYTTL)
 COMPATIBLE_IOCTL(NCP_IOC_SETDENTRYTTL)
-/* Little a */
-COMPATIBLE_IOCTL(ATMSIGD_CTRL)
-COMPATIBLE_IOCTL(ATMARPD_CTRL)
-COMPATIBLE_IOCTL(ATMLEC_CTRL)
-COMPATIBLE_IOCTL(ATMLEC_MCAST)
-COMPATIBLE_IOCTL(ATMLEC_DATA)
-COMPATIBLE_IOCTL(ATM_SETSC)
-COMPATIBLE_IOCTL(SIOCSIFATMTCP)
-COMPATIBLE_IOCTL(SIOCMKCLIP)
-COMPATIBLE_IOCTL(ATMARP_MKIP)
-COMPATIBLE_IOCTL(ATMARP_SETENTRY)
-COMPATIBLE_IOCTL(ATMARP_ENCAP)
-COMPATIBLE_IOCTL(ATMTCP_CREATE)
-COMPATIBLE_IOCTL(ATMTCP_REMOVE)
-COMPATIBLE_IOCTL(ATMMPC_CTRL)
-COMPATIBLE_IOCTL(ATMMPC_DATA)
 #if defined(CONFIG_DRM) || defined(CONFIG_DRM_MODULE)
 COMPATIBLE_IOCTL(DRM_IOCTL_GET_MAGIC)
 COMPATIBLE_IOCTL(DRM_IOCTL_IRQ_BUSID)
@@ -4468,42 +3953,9 @@
 COMPATIBLE_IOCTL(DRM_IOCTL_UNLOCK)
 COMPATIBLE_IOCTL(DRM_IOCTL_FINISH)
 #endif /* DRM */
-/* Big W */
-/* WIOC_GETSUPPORT not yet implemented -E */
-COMPATIBLE_IOCTL(WDIOC_GETSTATUS)
-COMPATIBLE_IOCTL(WDIOC_GETBOOTSTATUS)
-COMPATIBLE_IOCTL(WDIOC_GETTEMP)
-COMPATIBLE_IOCTL(WDIOC_SETOPTIONS)
-COMPATIBLE_IOCTL(WDIOC_KEEPALIVE)
 COMPATIBLE_IOCTL(WIOCSTART)
 COMPATIBLE_IOCTL(WIOCSTOP)
 COMPATIBLE_IOCTL(WIOCGSTAT)
-/* Big R */
-COMPATIBLE_IOCTL(RNDGETENTCNT)
-COMPATIBLE_IOCTL(RNDADDTOENTCNT)
-COMPATIBLE_IOCTL(RNDGETPOOL)
-COMPATIBLE_IOCTL(RNDADDENTROPY)
-COMPATIBLE_IOCTL(RNDZAPENTCNT)
-COMPATIBLE_IOCTL(RNDCLEARPOOL)
-/* Bluetooth ioctls */
-COMPATIBLE_IOCTL(HCIDEVUP)
-COMPATIBLE_IOCTL(HCIDEVDOWN)
-COMPATIBLE_IOCTL(HCIDEVRESET)
-COMPATIBLE_IOCTL(HCIDEVRESTAT)
-COMPATIBLE_IOCTL(HCIGETDEVLIST)
-COMPATIBLE_IOCTL(HCIGETDEVINFO)
-COMPATIBLE_IOCTL(HCIGETCONNLIST)
-COMPATIBLE_IOCTL(HCIGETCONNINFO)
-COMPATIBLE_IOCTL(HCISETRAW)
-COMPATIBLE_IOCTL(HCISETSCAN)
-COMPATIBLE_IOCTL(HCISETAUTH)
-COMPATIBLE_IOCTL(HCISETENCRYPT)
-COMPATIBLE_IOCTL(HCISETPTYPE)
-COMPATIBLE_IOCTL(HCISETLINKPOL)
-COMPATIBLE_IOCTL(HCISETLINKMODE)
-COMPATIBLE_IOCTL(HCISETACLMTU)
-COMPATIBLE_IOCTL(HCISETSCOMTU)
-COMPATIBLE_IOCTL(HCIINQUIRY)
 COMPATIBLE_IOCTL(HCIUARTSETPROTO)
 COMPATIBLE_IOCTL(HCIUARTGETPROTO)
 COMPATIBLE_IOCTL(RFCOMMCREATEDEV)
@@ -4515,42 +3967,6 @@
 COMPATIBLE_IOCTL(BNEPCONNDEL)
 COMPATIBLE_IOCTL(BNEPGETCONNLIST)
 COMPATIBLE_IOCTL(BNEPGETCONNINFO)
-/* Misc. */
-COMPATIBLE_IOCTL(0x41545900)		/* ATYIO_CLKR */
-COMPATIBLE_IOCTL(0x41545901)		/* ATYIO_CLKW */
-COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
-COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
-COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM)
-COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE)
-/* USB */
-COMPATIBLE_IOCTL(USBDEVFS_RESETEP)
-COMPATIBLE_IOCTL(USBDEVFS_SETINTERFACE)
-COMPATIBLE_IOCTL(USBDEVFS_SETCONFIGURATION)
-COMPATIBLE_IOCTL(USBDEVFS_GETDRIVER)
-COMPATIBLE_IOCTL(USBDEVFS_DISCARDURB)
-COMPATIBLE_IOCTL(USBDEVFS_CLAIMINTERFACE)
-COMPATIBLE_IOCTL(USBDEVFS_RELEASEINTERFACE)
-COMPATIBLE_IOCTL(USBDEVFS_CONNECTINFO)
-COMPATIBLE_IOCTL(USBDEVFS_HUB_PORTINFO)
-COMPATIBLE_IOCTL(USBDEVFS_RESET)
-COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
-/* MTD */
-COMPATIBLE_IOCTL(MEMGETINFO)
-COMPATIBLE_IOCTL(MEMERASE)
-COMPATIBLE_IOCTL(MEMLOCK)
-COMPATIBLE_IOCTL(MEMUNLOCK)
-COMPATIBLE_IOCTL(MEMGETREGIONCOUNT)
-COMPATIBLE_IOCTL(MEMGETREGIONINFO)
-/* NBD */
-COMPATIBLE_IOCTL(NBD_SET_SOCK)
-COMPATIBLE_IOCTL(NBD_SET_BLKSIZE)
-COMPATIBLE_IOCTL(NBD_SET_SIZE)
-COMPATIBLE_IOCTL(NBD_DO_IT)
-COMPATIBLE_IOCTL(NBD_CLEAR_SOCK)
-COMPATIBLE_IOCTL(NBD_CLEAR_QUE)
-COMPATIBLE_IOCTL(NBD_PRINT_DEBUG)
-COMPATIBLE_IOCTL(NBD_SET_SIZE_BLOCKS)
-COMPATIBLE_IOCTL(NBD_DISCONNECT)
 /* device-mapper */
 COMPATIBLE_IOCTL(DM_VERSION)
 COMPATIBLE_IOCTL(DM_REMOVE_ALL)
@@ -4739,134 +4155,3 @@
 HANDLE_IOCTL(BLKBSZSET_32, do_blkbszset)
 HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64)
 IOCTL_TABLE_END
-
-unsigned int ioctl32_hash_table[1024];
-
-static inline unsigned long ioctl32_hash(unsigned long cmd)
-{
-	return ((cmd >> 6) ^ (cmd >> 4) ^ cmd) & 0x3ff;
-}
-
-static void ioctl32_insert_translation(struct ioctl_trans *trans)
-{
-	unsigned long hash;
-	struct ioctl_trans *t;
-
-	hash = ioctl32_hash (trans->cmd);
-	if (!ioctl32_hash_table[hash])
-		ioctl32_hash_table[hash] = (u32)(long)trans;
-	else {
-		t = (struct ioctl_trans *)(long)ioctl32_hash_table[hash];
-		while (t->next)
-			t = (struct ioctl_trans *)(long)t->next;
-		trans->next = 0;
-		t->next = (u32)(long)trans;
-	}
-}
-
-static int __init init_sys32_ioctl(void)
-{
-	int i;
-	extern struct ioctl_trans ioctl_translations[], ioctl_translations_end[];
-
-	for (i = 0; &ioctl_translations[i] < &ioctl_translations_end[0]; i++)
-		ioctl32_insert_translation(&ioctl_translations[i]);
-	return 0;
-}
-
-__initcall(init_sys32_ioctl);
-
-static struct ioctl_trans *additional_ioctls;
-
-/* Always call these with kernel lock held! */
-
-int register_ioctl32_conversion(unsigned int cmd, int (*handler)(unsigned int, unsigned int, unsigned long, struct file *))
-{
-	int i;
-	if (!additional_ioctls) {
-		additional_ioctls = vmalloc(PAGE_SIZE);
-		if (!additional_ioctls)
-			return -ENOMEM;
-		memset(additional_ioctls, 0, PAGE_SIZE);
-	}
-	for (i = 0; i < PAGE_SIZE/sizeof(struct ioctl_trans); i++)
-		if (!additional_ioctls[i].cmd)
-			break;
-	if (i == PAGE_SIZE/sizeof(struct ioctl_trans))
-		return -ENOMEM;
-	additional_ioctls[i].cmd = cmd;
-	if (!handler)
-		additional_ioctls[i].handler = (u32)(long)sys_ioctl;
-	else
-		additional_ioctls[i].handler = (u32)(long)handler;
-	ioctl32_insert_translation(&additional_ioctls[i]);
-	return 0;
-}
-
-int unregister_ioctl32_conversion(unsigned int cmd)
-{
-	unsigned long hash = ioctl32_hash(cmd);
-	struct ioctl_trans *t, *t1;
-
-	t = (struct ioctl_trans *)(long)ioctl32_hash_table[hash];
-	if (!t) return -EINVAL;
-	if (t->cmd == cmd && t >= additional_ioctls &&
-	    (unsigned long)t < ((unsigned long)additional_ioctls) + PAGE_SIZE) {
-		ioctl32_hash_table[hash] = t->next;
-		t->cmd = 0;
-		t->next = 0;
-		return 0;
-	} else while (t->next) {
-		t1 = (struct ioctl_trans *)(long)t->next;
-		if (t1->cmd == cmd && t1 >= additional_ioctls &&
-		    (unsigned long)t1 < ((unsigned long)additional_ioctls) + PAGE_SIZE) {
-			t->next = t1->next;
-			t1->cmd = 0;
-			t1->next = 0;
-			return 0;
-		}
-		t = t1;
-	}
-	return -EINVAL;
-}
-
-asmlinkage int sys32_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
-	struct file * filp;
-	int error = -EBADF;
-	int (*handler)(unsigned int, unsigned int, unsigned long, struct file * filp);
-	struct ioctl_trans *t;
-
-	filp = fget(fd);
-	if(!filp)
-		goto out2;
-
-	if (!filp->f_op || !filp->f_op->ioctl) {
-		error = sys_ioctl (fd, cmd, arg);
-		goto out;
-	}
-
-	t = (struct ioctl_trans *)(long)ioctl32_hash_table [ioctl32_hash (cmd)];
-
-	while (t && t->cmd != cmd)
-		t = (struct ioctl_trans *)(long)t->next;
-	if (t) {
-		handler = (void *)(long)t->handler;
-		error = handler(fd, cmd, arg, filp);
-	} else if (cmd >= SIOCDEVPRIVATE &&
-		   cmd <= (SIOCDEVPRIVATE + 15)) {
-		error = siocdevprivate_ioctl(fd, cmd, arg);
-	} else {
-		static int count;
-		if (++count <= 20)
-			printk("sys32_ioctl(%s:%d): Unknown cmd fd(%d) "
-			       "cmd(%08x) arg(%08x)\n",
-			       current->comm, current->pid,
-			       (int)fd, (unsigned int)cmd, (unsigned int)arg);
-		error = -EINVAL;
-	}
-out:
-	fput(filp);
-out2:
-	return error;
-}
diff -Nru a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c
--- a/arch/sparc64/kernel/irq.c	Wed Apr 30 22:28:17 2003
+++ b/arch/sparc64/kernel/irq.c	Wed Apr 30 22:28:17 2003
@@ -294,7 +294,7 @@
 	__asm__ __volatile__("wrpr %0, 0x0, %%pstate" : : "r" (pstate));
 }
 
-int request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
+int request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_regs *),
 		unsigned long irqflags, const char *name, void *dev_id)
 {
 	struct irqaction *action, *tmp = NULL;
@@ -831,7 +831,7 @@
 #define SPARC_NOP (0x01000000)
 
 static void install_fast_irq(unsigned int cpu_irq,
-			     void (*handler)(int, void *, struct pt_regs *))
+			     irqreturn_t (*handler)(int, void *, struct pt_regs *))
 {
 	extern unsigned long sparc64_ttable_tl0;
 	unsigned long ttent = (unsigned long) &sparc64_ttable_tl0;
@@ -847,7 +847,7 @@
 }
 
 int request_fast_irq(unsigned int irq,
-		     void (*handler)(int, void *, struct pt_regs *),
+		     irqreturn_t (*handler)(int, void *, struct pt_regs *),
 		     unsigned long irqflags, const char *name, void *dev_id)
 {
 	struct irqaction *action;
diff -Nru a/arch/sparc64/kernel/pci_common.c b/arch/sparc64/kernel/pci_common.c
--- a/arch/sparc64/kernel/pci_common.c	Wed Apr 30 22:28:06 2003
+++ b/arch/sparc64/kernel/pci_common.c	Wed Apr 30 22:28:06 2003
@@ -145,7 +145,7 @@
 		 * there must be a damn good reason for it.
 		 *
 		 * So what we do is delete the device from the
-		 * PCI device tree completely.  This scenerio
+		 * PCI device tree completely.  This scenario
 		 * is seen, for example, on CP1500 for the
 		 * second EBUS/HappyMeal pair if the external
 		 * connector for it is not present.
diff -Nru a/arch/sparc64/kernel/pci_psycho.c b/arch/sparc64/kernel/pci_psycho.c
--- a/arch/sparc64/kernel/pci_psycho.c	Wed Apr 30 22:28:10 2003
+++ b/arch/sparc64/kernel/pci_psycho.c	Wed Apr 30 22:28:10 2003
@@ -713,7 +713,7 @@
 #define  PSYCHO_UEAFSR_RESV2	0x00000000007fffff /* Reserved                     */
 #define PSYCHO_UE_AFAR	0x0038UL
 
-static void psycho_ue_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t psycho_ue_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct pci_controller_info *p = dev_id;
 	unsigned long afsr_reg = p->controller_regs + PSYCHO_UE_AFSR;
@@ -730,7 +730,7 @@
 		(PSYCHO_UEAFSR_PPIO | PSYCHO_UEAFSR_PDRD | PSYCHO_UEAFSR_PDWR |
 		 PSYCHO_UEAFSR_SPIO | PSYCHO_UEAFSR_SDRD | PSYCHO_UEAFSR_SDWR);
 	if (!error_bits)
-		return;
+		return IRQ_NONE;
 	psycho_write(afsr_reg, error_bits);
 
 	/* Log the error. */
@@ -769,6 +769,8 @@
 
 	/* Interrogate IOMMU for error status. */
 	psycho_check_iommu_error(p, afsr, afar, UE_ERR);
+
+	return IRQ_HANDLED;
 }
 
 /* Correctable Errors. */
@@ -788,7 +790,7 @@
 #define  PSYCHO_CEAFSR_RESV2	0x00000000007fffff /* Reserved                     */
 #define PSYCHO_CE_AFAR	0x0040UL
 
-static void psycho_ce_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t psycho_ce_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct pci_controller_info *p = dev_id;
 	unsigned long afsr_reg = p->controller_regs + PSYCHO_CE_AFSR;
@@ -805,7 +807,7 @@
 		(PSYCHO_CEAFSR_PPIO | PSYCHO_CEAFSR_PDRD | PSYCHO_CEAFSR_PDWR |
 		 PSYCHO_CEAFSR_SPIO | PSYCHO_CEAFSR_SDRD | PSYCHO_CEAFSR_SDWR);
 	if (!error_bits)
-		return;
+		return IRQ_NONE;
 	psycho_write(afsr_reg, error_bits);
 
 	/* Log the error. */
@@ -847,10 +849,12 @@
 	if (!reported)
 		printk("(none)");
 	printk("]\n");
+
+	return IRQ_HANDLED;
 }
 
 /* PCI Errors.  They are signalled by the PCI bus module since they
- * are assosciated with a specific bus segment.
+ * are associated with a specific bus segment.
  */
 #define PSYCHO_PCI_AFSR_A	0x2010UL
 #define PSYCHO_PCI_AFSR_B	0x4010UL
@@ -871,7 +875,7 @@
 #define PSYCHO_PCI_AFAR_A	0x2018UL
 #define PSYCHO_PCI_AFAR_B	0x4018UL
 
-static void psycho_pcierr_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t psycho_pcierr_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct pci_pbm_info *pbm = dev_id;
 	struct pci_controller_info *p = pbm->parent;
@@ -899,7 +903,7 @@
 		 PSYCHO_PCIAFSR_SMA | PSYCHO_PCIAFSR_STA |
 		 PSYCHO_PCIAFSR_SRTRY | PSYCHO_PCIAFSR_SPERR);
 	if (!error_bits)
-		return;
+		return IRQ_NONE;
 	psycho_write(afsr_reg, error_bits);
 
 	/* Log the error. */
@@ -968,6 +972,8 @@
 
 	if (error_bits & (PSYCHO_PCIAFSR_PPERR | PSYCHO_PCIAFSR_SPERR))
 		pci_scan_for_parity_error(p, pbm, pbm->pci_bus);
+
+	return IRQ_HANDLED;
 }
 
 /* XXX What about PowerFail/PowerManagement??? -DaveM */
diff -Nru a/arch/sparc64/kernel/pci_sabre.c b/arch/sparc64/kernel/pci_sabre.c
--- a/arch/sparc64/kernel/pci_sabre.c	Wed Apr 30 22:28:18 2003
+++ b/arch/sparc64/kernel/pci_sabre.c	Wed Apr 30 22:28:18 2003
@@ -744,7 +744,7 @@
 	spin_unlock_irqrestore(&iommu->lock, flags);
 }
 
-static void sabre_ue_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sabre_ue_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct pci_controller_info *p = dev_id;
 	unsigned long afsr_reg = p->controller_regs + SABRE_UE_AFSR;
@@ -762,7 +762,7 @@
 		 SABRE_UEAFSR_SDRD | SABRE_UEAFSR_SDWR |
 		 SABRE_UEAFSR_SDTE | SABRE_UEAFSR_PDTE);
 	if (!error_bits)
-		return;
+		return IRQ_NONE;
 	sabre_write(afsr_reg, error_bits);
 
 	/* Log the error. */
@@ -800,9 +800,11 @@
 
 	/* Interrogate IOMMU for error status. */
 	sabre_check_iommu_error(p, afsr, afar);
+
+	return IRQ_HANDLED;
 }
 
-static void sabre_ce_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sabre_ce_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct pci_controller_info *p = dev_id;
 	unsigned long afsr_reg = p->controller_regs + SABRE_CE_AFSR;
@@ -819,7 +821,7 @@
 		(SABRE_CEAFSR_PDRD | SABRE_CEAFSR_PDWR |
 		 SABRE_CEAFSR_SDRD | SABRE_CEAFSR_SDWR);
 	if (!error_bits)
-		return;
+		return IRQ_NONE;
 	sabre_write(afsr_reg, error_bits);
 
 	/* Log the error. */
@@ -854,9 +856,11 @@
 	if (!reported)
 		printk("(none)");
 	printk("]\n");
+
+	return IRQ_HANDLED;
 }
 
-static void sabre_pcierr_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sabre_pcierr_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct pci_controller_info *p = dev_id;
 	unsigned long afsr_reg, afar_reg;
@@ -877,7 +881,7 @@
 		 SABRE_PIOAFSR_SMA | SABRE_PIOAFSR_STA |
 		 SABRE_PIOAFSR_SRTRY | SABRE_PIOAFSR_SPERR);
 	if (!error_bits)
-		return;
+		return IRQ_NONE;
 	sabre_write(afsr_reg, error_bits);
 
 	/* Log the error. */
@@ -947,6 +951,8 @@
 		pci_scan_for_parity_error(p, &p->pbm_A, p->pbm_A.pci_bus);
 		pci_scan_for_parity_error(p, &p->pbm_B, p->pbm_B.pci_bus);
 	}
+
+	return IRQ_HANDLED;
 }
 
 /* XXX What about PowerFail/PowerManagement??? -DaveM */
diff -Nru a/arch/sparc64/kernel/pci_schizo.c b/arch/sparc64/kernel/pci_schizo.c
--- a/arch/sparc64/kernel/pci_schizo.c	Wed Apr 30 22:28:12 2003
+++ b/arch/sparc64/kernel/pci_schizo.c	Wed Apr 30 22:28:12 2003
@@ -672,7 +672,7 @@
 #define SCHIZO_UEAFSR_MTAG	0x000000000000e000UL
 #define SCHIZO_UEAFSR_ECCSYND	0x00000000000001ffUL
 
-static void schizo_ue_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t schizo_ue_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct pci_controller_info *p = dev_id;
 	unsigned long afsr_reg = p->controller_regs + SCHIZO_UE_AFSR;
@@ -697,7 +697,7 @@
 		(SCHIZO_UEAFSR_PPIO | SCHIZO_UEAFSR_PDRD | SCHIZO_UEAFSR_PDWR |
 		 SCHIZO_UEAFSR_SPIO | SCHIZO_UEAFSR_SDMA);
 	if (!error_bits)
-		return;
+		return IRQ_NONE;
 	schizo_write(afsr_reg, error_bits);
 
 	/* Log the error. */
@@ -740,6 +740,8 @@
 	schizo_check_iommu_error(p, UE_ERR);
 
 	schizo_clear_other_err_intr(irq);
+
+	return IRQ_HANDLED;
 }
 
 #define SCHIZO_CE_AFSR	0x10040UL
@@ -760,7 +762,7 @@
 #define SCHIZO_CEAFSR_MTAG	0x000000000000e000UL
 #define SCHIZO_CEAFSR_ECCSYND	0x00000000000001ffUL
 
-static void schizo_ce_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t schizo_ce_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct pci_controller_info *p = dev_id;
 	unsigned long afsr_reg = p->controller_regs + SCHIZO_CE_AFSR;
@@ -785,7 +787,7 @@
 		(SCHIZO_CEAFSR_PPIO | SCHIZO_CEAFSR_PDRD | SCHIZO_CEAFSR_PDWR |
 		 SCHIZO_CEAFSR_SPIO | SCHIZO_CEAFSR_SDMA);
 	if (!error_bits)
-		return;
+		return IRQ_NONE;
 	schizo_write(afsr_reg, error_bits);
 
 	/* Log the error. */
@@ -829,6 +831,8 @@
 	printk("]\n");
 
 	schizo_clear_other_err_intr(irq);
+
+	return IRQ_HANDLED;
 }
 
 #define SCHIZO_PCI_AFSR	0x2010UL
@@ -852,7 +856,7 @@
 #define SCHIZO_PCIAFSR_MEM	0x0000000020000000UL
 #define SCHIZO_PCIAFSR_IO	0x0000000010000000UL
 
-static void schizo_pcierr_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t schizo_pcierr_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct pci_pbm_info *pbm = dev_id;
 	struct pci_controller_info *p = pbm->parent;
@@ -886,7 +890,7 @@
 		 SCHIZO_PCIAFSR_SRTRY | SCHIZO_PCIAFSR_SPERR |
 		 SCHIZO_PCIAFSR_STTO | SCHIZO_PCIAFSR_SUNUS);
 	if (!error_bits)
-		return;
+		return IRQ_NONE;
 	schizo_write(afsr_reg, error_bits);
 
 	/* Log the error. */
@@ -974,6 +978,8 @@
 		pci_scan_for_parity_error(p, pbm, pbm->pci_bus);
 
 	schizo_clear_other_err_intr(irq);
+
+	return IRQ_HANDLED;
 }
 
 #define SCHIZO_SAFARI_ERRLOG	0x10018UL
@@ -1002,7 +1008,7 @@
 /* We only expect UNMAP errors here.  The rest of the Safari errors
  * are marked fatal and thus cause a system reset.
  */
-static void schizo_safarierr_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t schizo_safarierr_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct pci_controller_info *p = dev_id;
 	u64 errlog;
@@ -1016,7 +1022,7 @@
 		       p->index, errlog);
 
 		schizo_clear_other_err_intr(irq);
-		return;
+		return IRQ_HANDLED;
 	}
 
 	printk("SCHIZO%d: Safari interrupt, UNMAPPED error, interrogating IOMMUs.\n",
@@ -1024,6 +1030,7 @@
 	schizo_check_iommu_error(p, SAFARI_ERR);
 
 	schizo_clear_other_err_intr(irq);
+	return IRQ_HANDLED;
 }
 
 /* Nearly identical to PSYCHO equivalents... */
diff -Nru a/arch/sparc64/kernel/power.c b/arch/sparc64/kernel/power.c
--- a/arch/sparc64/kernel/power.c	Wed Apr 30 22:28:16 2003
+++ b/arch/sparc64/kernel/power.c	Wed Apr 30 22:28:16 2003
@@ -14,24 +14,26 @@
 
 #include <asm/system.h>
 #include <asm/ebus.h>
+#include <asm/auxio.h>
 
 #define __KERNEL_SYSCALLS__
 #include <linux/unistd.h>
 
 #ifdef CONFIG_PCI
 static unsigned long power_reg = 0UL;
-#define POWER_SYSTEM_OFF (1 << 0)
-#define POWER_COURTESY_OFF (1 << 1)
 
 static DECLARE_WAIT_QUEUE_HEAD(powerd_wait);
 static int button_pressed;
 
-static void power_handler(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t power_handler(int irq, void *dev_id, struct pt_regs *regs)
 {
 	if (button_pressed == 0) {
 		wake_up(&powerd_wait);
 		button_pressed = 1;
 	}
+
+	/* FIXME: Check registers for status... */
+	return IRQ_HANDLED;
 }
 #endif /* CONFIG_PCI */
 
@@ -48,7 +50,7 @@
 			 * same effect, so until I figure out
 			 * what the difference is...
 			 */
-			writel(POWER_COURTESY_OFF | POWER_SYSTEM_OFF, power_reg);
+			writel(AUXIO_PCIO_CPWR_OFF | AUXIO_PCIO_SPWR_OFF, power_reg);
 		} else
 #endif /* CONFIG_PCI */
 			if (poweroff_method != NULL) {
diff -Nru a/arch/sparc64/kernel/ptrace.c b/arch/sparc64/kernel/ptrace.c
--- a/arch/sparc64/kernel/ptrace.c	Wed Apr 30 22:28:18 2003
+++ b/arch/sparc64/kernel/ptrace.c	Wed Apr 30 22:28:18 2003
@@ -6,7 +6,7 @@
  * Based upon code written by Ross Biro, Linus Torvalds, Bob Manson,
  * and David Mosberger.
  *
- * Added Linux support -miguel (weird, eh?, the orignal code was meant
+ * Added Linux support -miguel (weird, eh?, the original code was meant
  * to emulate SunOS).
  */
 
diff -Nru a/arch/sparc64/kernel/rtrap.S b/arch/sparc64/kernel/rtrap.S
--- a/arch/sparc64/kernel/rtrap.S	Wed Apr 30 22:28:09 2003
+++ b/arch/sparc64/kernel/rtrap.S	Wed Apr 30 22:28:09 2003
@@ -210,7 +210,7 @@
 __handle_perfctrs_continue:
 		 andcc			%l1, %o0, %g0
 
-		/* This fpdepth clear is neccessary for non-syscall rtraps only */
+		/* This fpdepth clear is necessary for non-syscall rtraps only */
 user_nowork:
 		bne,pn			%xcc, __handle_userfpu
 		 stb			%g0, [%g6 + TI_FPDEPTH]
diff -Nru a/arch/sparc64/kernel/sbus.c b/arch/sparc64/kernel/sbus.c
--- a/arch/sparc64/kernel/sbus.c	Wed Apr 30 22:28:20 2003
+++ b/arch/sparc64/kernel/sbus.c	Wed Apr 30 22:28:20 2003
@@ -728,7 +728,7 @@
 
 #define NUM_SYSIO_OFFSETS (sizeof(sysio_irq_offsets) / sizeof(sysio_irq_offsets[0]))
 
-/* Convert Interrupt Mapping register pointer to assosciated
+/* Convert Interrupt Mapping register pointer to associated
  * Interrupt Clear register pointer, SYSIO specific version.
  */
 #define SYSIO_ICLR_UNUSED0	0x3400UL
@@ -813,7 +813,7 @@
 #define  SYSIO_UEAFSR_SIZE	0x00001c0000000000 /* Bad transfer size is 2**SIZE */
 #define  SYSIO_UEAFSR_MID	0x000003e000000000 /* UPA MID causing the fault    */
 #define  SYSIO_UEAFSR_RESV2	0x0000001fffffffff /* Reserved                     */
-static void sysio_ue_handler(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sysio_ue_handler(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct sbus_bus *sbus = dev_id;
 	struct sbus_iommu *iommu = sbus->iommu;
@@ -867,6 +867,8 @@
 	if (!reported)
 		printk("(none)");
 	printk("]\n");
+
+	return IRQ_HANDLED;
 }
 
 #define SYSIO_CE_AFSR	0x0040UL
@@ -883,7 +885,7 @@
 #define  SYSIO_CEAFSR_SIZE	0x00001c0000000000 /* Bad transfer size is 2**SIZE */
 #define  SYSIO_CEAFSR_MID	0x000003e000000000 /* UPA MID causing the fault    */
 #define  SYSIO_CEAFSR_RESV2	0x0000001fffffffff /* Reserved                     */
-static void sysio_ce_handler(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sysio_ce_handler(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct sbus_bus *sbus = dev_id;
 	struct sbus_iommu *iommu = sbus->iommu;
@@ -942,6 +944,8 @@
 	if (!reported)
 		printk("(none)");
 	printk("]\n");
+
+	return IRQ_HANDLED;
 }
 
 #define SYSIO_SBUS_AFSR		0x2010UL
@@ -958,7 +962,7 @@
 #define  SYSIO_SBAFSR_SIZE	0x00001c0000000000 /* Size of transfer             */
 #define  SYSIO_SBAFSR_MID	0x000003e000000000 /* MID causing the error        */
 #define  SYSIO_SBAFSR_RESV3	0x0000001fffffffff /* Reserved                     */
-static void sysio_sbus_error_handler(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sysio_sbus_error_handler(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct sbus_bus *sbus = dev_id;
 	struct sbus_iommu *iommu = sbus->iommu;
@@ -1013,6 +1017,8 @@
 	printk("]\n");
 
 	/* XXX check iommu/strbuf for further error status XXX */
+
+	return IRQ_HANDLED;
 }
 
 #define ECC_CONTROL	0x0020UL
@@ -1092,7 +1098,7 @@
 		prom_halt();
 	}
 
-	/* Align on E$ line boundry. */
+	/* Align on E$ line boundary. */
 	iommu = (struct sbus_iommu *)
 		(((unsigned long)iommu + (SMP_CACHE_BYTES - 1UL)) &
 		 ~(SMP_CACHE_BYTES - 1UL));
diff -Nru a/arch/sparc64/kernel/setup.c b/arch/sparc64/kernel/setup.c
--- a/arch/sparc64/kernel/setup.c	Wed Apr 30 22:28:07 2003
+++ b/arch/sparc64/kernel/setup.c	Wed Apr 30 22:28:07 2003
@@ -31,6 +31,7 @@
 #include <linux/root_dev.h>
 #include <linux/interrupt.h>
 #include <linux/cpu.h>
+#include <linux/initrd.h>
 
 #include <asm/segment.h>
 #include <asm/system.h>
diff -Nru a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
--- a/arch/sparc64/kernel/smp.c	Wed Apr 30 22:28:03 2003
+++ b/arch/sparc64/kernel/smp.c	Wed Apr 30 22:28:03 2003
@@ -1071,7 +1071,7 @@
 			prof_counter(cpu) = prof_multiplier(cpu);
 		}
 
-		/* Guarentee that the following sequences execute
+		/* Guarantee that the following sequences execute
 		 * uninterrupted.
 		 */
 		__asm__ __volatile__("rdpr	%%pstate, %0\n\t"
@@ -1096,7 +1096,7 @@
 
 	prof_counter(cpu) = prof_multiplier(cpu) = 1;
 
-	/* Guarentee that the following sequences execute
+	/* Guarantee that the following sequences execute
 	 * uninterrupted.
 	 */
 	__asm__ __volatile__("rdpr	%%pstate, %0\n\t"
diff -Nru a/arch/sparc64/kernel/sparc64_ksyms.c b/arch/sparc64/kernel/sparc64_ksyms.c
--- a/arch/sparc64/kernel/sparc64_ksyms.c	Wed Apr 30 22:28:15 2003
+++ b/arch/sparc64/kernel/sparc64_ksyms.c	Wed Apr 30 22:28:15 2003
@@ -91,7 +91,7 @@
 extern int svr4_getcontext(svr4_ucontext_t *uc, struct pt_regs *regs);
 extern int svr4_setcontext(svr4_ucontext_t *uc, struct pt_regs *regs);
 extern int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
-extern int sys32_ioctl(unsigned int fd, unsigned int cmd, u32 arg);
+extern int compat_sys_ioctl(unsigned int fd, unsigned int cmd, u32 arg);
 extern int (*handle_mathemu)(struct pt_regs *, struct fpustate *);
 extern long sparc32_open(const char * filename, int flags, int mode);
 extern int register_ioctl32_conversion(unsigned int cmd, int (*handler)(unsigned int, unsigned int, unsigned long, struct file *));
@@ -197,7 +197,8 @@
 EXPORT_SYMBOL(mstk48t02_regs);
 EXPORT_SYMBOL(request_fast_irq);
 #if CONFIG_SUN_AUXIO
-EXPORT_SYMBOL(auxio_register);
+EXPORT_SYMBOL(auxio_set_led);
+EXPORT_SYMBOL(auxio_set_lte);
 #endif
 #if CONFIG_SBUS
 EXPORT_SYMBOL(sbus_root);
@@ -318,7 +319,7 @@
 EXPORT_SYMBOL(svr4_setcontext);
 EXPORT_SYMBOL(prom_cpu_nodes);
 EXPORT_SYMBOL(sys_ioctl);
-EXPORT_SYMBOL(sys32_ioctl);
+EXPORT_SYMBOL(compat_sys_ioctl);
 EXPORT_SYMBOL(sparc32_open);
 #endif
 
diff -Nru a/arch/sparc64/kernel/sunos_ioctl32.c b/arch/sparc64/kernel/sunos_ioctl32.c
--- a/arch/sparc64/kernel/sunos_ioctl32.c	Wed Apr 30 22:28:17 2003
+++ b/arch/sparc64/kernel/sunos_ioctl32.c	Wed Apr 30 22:28:17 2003
@@ -92,7 +92,7 @@
 
 extern asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
 
-extern asmlinkage int sys32_ioctl(unsigned int, unsigned int, u32);
+extern asmlinkage int compat_sys_ioctl(unsigned int, unsigned int, u32);
 extern asmlinkage int sys_setsid(void);
 
 asmlinkage int sunos_ioctl (int fd, u32 cmd, u32 arg)
@@ -127,39 +127,39 @@
 	}
 	switch(cmd) {
 	case _IOW('r', 10, struct rtentry32):
-		ret = sys32_ioctl(fd, SIOCADDRT, arg);
+		ret = compat_sys_ioctl(fd, SIOCADDRT, arg);
 		goto out;
 	case _IOW('r', 11, struct rtentry32):
-		ret = sys32_ioctl(fd, SIOCDELRT, arg);
+		ret = compat_sys_ioctl(fd, SIOCDELRT, arg);
 		goto out;
 
 	case _IOW('i', 12, struct ifreq32):
-		ret = sys32_ioctl(fd, SIOCSIFADDR, arg);
+		ret = compat_sys_ioctl(fd, SIOCSIFADDR, arg);
 		goto out;
 	case _IOWR('i', 13, struct ifreq32):
-		ret = sys32_ioctl(fd, SIOCGIFADDR, arg);
+		ret = compat_sys_ioctl(fd, SIOCGIFADDR, arg);
 		goto out;
 	case _IOW('i', 14, struct ifreq32):
-		ret = sys32_ioctl(fd, SIOCSIFDSTADDR, arg);
+		ret = compat_sys_ioctl(fd, SIOCSIFDSTADDR, arg);
 		goto out;
 	case _IOWR('i', 15, struct ifreq32):
-		ret = sys32_ioctl(fd, SIOCGIFDSTADDR, arg);
+		ret = compat_sys_ioctl(fd, SIOCGIFDSTADDR, arg);
 		goto out;
 	case _IOW('i', 16, struct ifreq32):
-		ret = sys32_ioctl(fd, SIOCSIFFLAGS, arg);
+		ret = compat_sys_ioctl(fd, SIOCSIFFLAGS, arg);
 		goto out;
 	case _IOWR('i', 17, struct ifreq32):
-		ret = sys32_ioctl(fd, SIOCGIFFLAGS, arg);
+		ret = compat_sys_ioctl(fd, SIOCGIFFLAGS, arg);
 		goto out;
 	case _IOW('i', 18, struct ifreq32):
-		ret = sys32_ioctl(fd, SIOCSIFMEM, arg);
+		ret = compat_sys_ioctl(fd, SIOCSIFMEM, arg);
 		goto out;
 	case _IOWR('i', 19, struct ifreq32):
-		ret = sys32_ioctl(fd, SIOCGIFMEM, arg);
+		ret = compat_sys_ioctl(fd, SIOCGIFMEM, arg);
 		goto out;
 
 	case _IOWR('i', 20, struct ifconf32):
-		ret = sys32_ioctl(fd, SIOCGIFCONF, arg);
+		ret = compat_sys_ioctl(fd, SIOCGIFCONF, arg);
 		goto out;
 
 	case _IOW('i', 21, struct ifreq): /* SIOCSIFMTU */
@@ -170,32 +170,32 @@
 		goto out;
 
 	case _IOWR('i', 23, struct ifreq32):
-		ret = sys32_ioctl(fd, SIOCGIFBRDADDR, arg);
+		ret = compat_sys_ioctl(fd, SIOCGIFBRDADDR, arg);
 		goto out;
 	case _IOW('i', 24, struct ifreq32):
-		ret = sys32_ioctl(fd, SIOCSIFBRDADDR, arg);
+		ret = compat_sys_ioctl(fd, SIOCSIFBRDADDR, arg);
 		goto out;
 	case _IOWR('i', 25, struct ifreq32):
-		ret = sys32_ioctl(fd, SIOCGIFNETMASK, arg);
+		ret = compat_sys_ioctl(fd, SIOCGIFNETMASK, arg);
 		goto out;
 	case _IOW('i', 26, struct ifreq32):
-		ret = sys32_ioctl(fd, SIOCSIFNETMASK, arg);
+		ret = compat_sys_ioctl(fd, SIOCSIFNETMASK, arg);
 		goto out;
 	case _IOWR('i', 27, struct ifreq32):
-		ret = sys32_ioctl(fd, SIOCGIFMETRIC, arg);
+		ret = compat_sys_ioctl(fd, SIOCGIFMETRIC, arg);
 		goto out;
 	case _IOW('i', 28, struct ifreq32):
-		ret = sys32_ioctl(fd, SIOCSIFMETRIC, arg);
+		ret = compat_sys_ioctl(fd, SIOCSIFMETRIC, arg);
 		goto out;
 
 	case _IOW('i', 30, struct arpreq):
-		ret = sys32_ioctl(fd, SIOCSARP, arg);
+		ret = compat_sys_ioctl(fd, SIOCSARP, arg);
 		goto out;
 	case _IOWR('i', 31, struct arpreq):
-		ret = sys32_ioctl(fd, SIOCGARP, arg);
+		ret = compat_sys_ioctl(fd, SIOCGARP, arg);
 		goto out;
 	case _IOW('i', 32, struct arpreq):
-		ret = sys32_ioctl(fd, SIOCDARP, arg);
+		ret = compat_sys_ioctl(fd, SIOCDARP, arg);
 		goto out;
 
 	case _IOW('i', 40, struct ifreq32): /* SIOCUPPER */
@@ -209,10 +209,10 @@
 		goto out;
 
 	case _IOW('i', 49, struct ifreq32):
-		ret = sys32_ioctl(fd, SIOCADDMULTI, arg);
+		ret = compat_sys_ioctl(fd, SIOCADDMULTI, arg);
 		goto out;
 	case _IOW('i', 50, struct ifreq32):
-		ret = sys32_ioctl(fd, SIOCDELMULTI, arg);
+		ret = compat_sys_ioctl(fd, SIOCDELMULTI, arg);
 		goto out;
 
 	/* FDDI interface ioctls, unsupported. */
@@ -246,7 +246,7 @@
 		ret = -EFAULT;
 		if(get_user(oldval, ptr))
 			goto out;
-		ret = sys32_ioctl(fd, cmd, arg);
+		ret = compat_sys_ioctl(fd, cmd, arg);
 		__get_user(newval, ptr);
 		if(newval == -1) {
 			__put_user(oldval, ptr);
@@ -265,7 +265,7 @@
 		ret = -EFAULT;
 		if(get_user(oldval, ptr))
 			goto out;
-		ret = sys32_ioctl(fd, cmd, arg);
+		ret = compat_sys_ioctl(fd, cmd, arg);
 		__get_user(newval, ptr);
 		if(newval == -1) {
 			__put_user(oldval, ptr);
@@ -277,7 +277,7 @@
 	}
 	};
 
-	ret = sys32_ioctl(fd, cmd, arg);
+	ret = compat_sys_ioctl(fd, cmd, arg);
 	/* so stupid... */
 	ret = (ret == -EINVAL ? -EOPNOTSUPP : ret);
 out:
diff -Nru a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c
--- a/arch/sparc64/kernel/sys_sparc32.c	Wed Apr 30 22:28:11 2003
+++ b/arch/sparc64/kernel/sys_sparc32.c	Wed Apr 30 22:28:11 2003
@@ -2133,7 +2133,6 @@
 #define ca32_export	u.u32_export
 #define ca32_getfd	u.u32_getfd
 #define ca32_getfs	u.u32_getfs
-#define ca32_authd	u.u32_authd
 };
 
 union nfsctl_res32 {
diff -Nru a/arch/sparc64/kernel/systbls.S b/arch/sparc64/kernel/systbls.S
--- a/arch/sparc64/kernel/systbls.S	Wed Apr 30 22:28:08 2003
+++ b/arch/sparc64/kernel/systbls.S	Wed Apr 30 22:28:08 2003
@@ -29,7 +29,7 @@
 	.word sys_chown, sys_sync, sys_kill, compat_sys_newstat, sys32_sendfile
 /*40*/	.word compat_sys_newlstat, sys_dup, sys_pipe, compat_sys_times, sys_getuid
 	.word sys_umount, sys32_setgid16, sys32_getgid16, sys_signal, sys32_geteuid16
-/*50*/	.word sys32_getegid16, sys_acct, sys_nis_syscall, sys_getgid, sys32_ioctl
+/*50*/	.word sys32_getegid16, sys_acct, sys_nis_syscall, sys_getgid, compat_sys_ioctl
 	.word sys_reboot, sys32_mmap2, sys_symlink, sys_readlink, sys32_execve
 /*60*/	.word sys_umask, sys_chroot, compat_sys_newfstat, sys_fstat64, sys_getpagesize
 	.word sys_msync, sys_vfork, sys32_pread64, sys32_pwrite64, sys_geteuid
diff -Nru a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c
--- a/arch/sparc64/kernel/time.c	Wed Apr 30 22:28:09 2003
+++ b/arch/sparc64/kernel/time.c	Wed Apr 30 22:28:09 2003
@@ -477,7 +477,7 @@
 	}
 }
 
-static void timer_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
 	unsigned long ticks, pstate;
 
@@ -489,7 +489,7 @@
 #endif
 		do_timer(regs);
 
-		/* Guarentee that the following sequences execute
+		/* Guarantee that the following sequences execute
 		 * uninterrupted.
 		 */
 		__asm__ __volatile__("rdpr	%%pstate, %0\n\t"
@@ -509,6 +509,8 @@
 	timer_check_rtc();
 
 	write_sequnlock(&xtime_lock);
+
+	return IRQ_HANDLED;
 }
 
 #ifdef CONFIG_SMP
@@ -701,7 +703,9 @@
 	}
 
 	xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
-	xtime.tv_nsec = 0;
+	wall_to_monotonic.tv_sec = -xtime.tv_sec + INITIAL_JIFFIES / HZ;
+	xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
+	wall_to_monotonic.tv_nsec = 0;
 
 	if (mregs) {
 		tmp = mostek_read(mregs + MOSTEK_CREG);
@@ -739,7 +743,9 @@
 			(unsigned int) (long) &unix_tod);
 		prom_feval(obp_gettod);
 		xtime.tv_sec = unix_tod;
-		xtime.tv_nsec = 0;
+		wall_to_monotonic.tv_sec = -xtime.tv_sec + INITIAL_JIFFIES / HZ;
+		xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
+		wall_to_monotonic.tv_nsec = 0;
 		return;
 	}
 
@@ -925,7 +931,7 @@
 }
 
 /* This is gets the master TICK_INT timer going. */
-static unsigned long sparc64_init_timers(void (*cfunc)(int, void *, struct pt_regs *))
+static unsigned long sparc64_init_timers(irqreturn_t (*cfunc)(int, void *, struct pt_regs *))
 {
 	unsigned long pstate, clock;
 	int node, err;
@@ -970,7 +976,7 @@
 		prom_halt();
 	}
 
-	/* Guarentee that the following sequences execute
+	/* Guarantee that the following sequences execute
 	 * uninterrupted.
 	 */
 	__asm__ __volatile__("rdpr	%%pstate, %0\n\t"
@@ -1095,15 +1101,28 @@
 	 * made, and then undo it!
 	 */
 	tv->tv_usec -= do_gettimeoffset();
-	tv->tv_usec -= (jiffies - wall_jiffies) * (1000000 / HZ);
+	tv->tv_usec -= (jiffies - wall_jiffies) * (USEC_PER_SEC / HZ);
 
 	while (tv->tv_usec < 0) {
-		tv->tv_usec += 1000000;
+		tv->tv_usec += USEC_PER_SEC;
 		tv->tv_sec--;
 	}
+	tv->tv_usec *= NSEC_PER_USEC;
+
+	wall_to_monotonic.tv_sec += xtime.tv_sec - tv->tv_sec;
+	wall_to_monotonic.tv_nsec += xtime.tv_nsec - tv->tv_usec;
+
+	if (wall_to_monotonic.tv_nsec > NSEC_PER_SEC) {
+		wall_to_monotonic.tv_nsec -= NSEC_PER_SEC;
+		wall_to_monotonic.tv_sec++;
+	}
+	if (wall_to_monotonic.tv_nsec < 0) {
+		wall_to_monotonic.tv_nsec += NSEC_PER_SEC;
+		wall_to_monotonic.tv_sec--;
+	}
 
 	xtime.tv_sec = tv->tv_sec;
-	xtime.tv_nsec = (tv->tv_usec * 1000);
+	xtime.tv_nsec = tv->tv_usec;
 	time_adjust = 0;		/* stop active adjtime() */
 	time_status |= STA_UNSYNC;
 	time_maxerror = NTP_PHASE_LIMIT;
diff -Nru a/arch/sparc64/kernel/trampoline.S b/arch/sparc64/kernel/trampoline.S
--- a/arch/sparc64/kernel/trampoline.S	Wed Apr 30 22:28:08 2003
+++ b/arch/sparc64/kernel/trampoline.S	Wed Apr 30 22:28:08 2003
@@ -40,7 +40,7 @@
 	 nop
 
 cheetah_plus_startup:
-	/* Preserve OBP choosen DCU and DCR register settings.  */
+	/* Preserve OBP chosen DCU and DCR register settings.  */
 	ba,pt	%xcc, cheetah_generic_startup
 	 nop
 
diff -Nru a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
--- a/arch/sparc64/mm/init.c	Wed Apr 30 22:28:07 2003
+++ b/arch/sparc64/mm/init.c	Wed Apr 30 22:28:08 2003
@@ -14,7 +14,7 @@
 #include <linux/mm.h>
 #include <linux/hugetlb.h>
 #include <linux/slab.h>
-#include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/swap.h>
 #include <linux/pagemap.h>
 #include <linux/fs.h>
@@ -1173,7 +1173,7 @@
 	}
 
 	color = VPTE_COLOR(address);
-	page = alloc_pages(GFP_KERNEL, DC_ALIAS_SHIFT);
+	page = alloc_pages(GFP_KERNEL|__GFP_REPEAT, DC_ALIAS_SHIFT);
 	if (page) {
 		unsigned long *to_free;
 		unsigned long paddr;
diff -Nru a/arch/sparc64/prom/printf.c b/arch/sparc64/prom/printf.c
--- a/arch/sparc64/prom/printf.c	Wed Apr 30 22:28:10 2003
+++ b/arch/sparc64/prom/printf.c	Wed Apr 30 22:28:10 2003
@@ -6,7 +6,7 @@
  * Copyright (c) 2002 Pete Zaitcev (zaitcev@yahoo.com)
  *
  * We used to warn all over the code: DO NOT USE prom_printf(),
- * and yet people do. Anton's banking code was outputing banks
+ * and yet people do. Anton's banking code was outputting banks
  * with prom_printf for most of the 2.4 lifetime. Since an effective
  * stick is not available, we deployed a carrot: an early printk
  * through PROM by means of -p boot option. This ought to fix it.
diff -Nru a/arch/sparc64/solaris/ioctl.c b/arch/sparc64/solaris/ioctl.c
--- a/arch/sparc64/solaris/ioctl.c	Wed Apr 30 22:28:10 2003
+++ b/arch/sparc64/solaris/ioctl.c	Wed Apr 30 22:28:10 2003
@@ -23,6 +23,7 @@
 #include <linux/netdevice.h>
 #include <linux/mtio.h>
 #include <linux/time.h>
+#include <linux/compat.h>
 
 #include <net/sock.h>
 
@@ -35,7 +36,7 @@
 
 extern asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, 
 	unsigned long arg);
-extern asmlinkage int sys32_ioctl(unsigned int fd, unsigned int cmd,
+extern asmlinkage int compat_sys_ioctl(unsigned int fd, unsigned int cmd,
 	u32 arg);
 asmlinkage int solaris_ioctl(unsigned int fd, unsigned int cmd, u32 arg);
 
@@ -597,9 +598,9 @@
 {
 	switch (cmd & 0xff) {
 	case 10: /* SIOCADDRT */
-		return sys32_ioctl(fd, SIOCADDRT, arg);
+		return compat_sys_ioctl(fd, SIOCADDRT, arg);
 	case 11: /* SIOCDELRT */
-		return sys32_ioctl(fd, SIOCDELRT, arg);
+		return compat_sys_ioctl(fd, SIOCDELRT, arg);
 	}
 	return -ENOSYS;
 }
@@ -608,45 +609,45 @@
 {
 	switch (cmd & 0xff) {
 	case 12: /* SIOCSIFADDR */
-		return sys32_ioctl(fd, SIOCSIFADDR, arg);
+		return compat_sys_ioctl(fd, SIOCSIFADDR, arg);
 	case 13: /* SIOCGIFADDR */
-		return sys32_ioctl(fd, SIOCGIFADDR, arg);
+		return compat_sys_ioctl(fd, SIOCGIFADDR, arg);
 	case 14: /* SIOCSIFDSTADDR */
-		return sys32_ioctl(fd, SIOCSIFDSTADDR, arg);
+		return compat_sys_ioctl(fd, SIOCSIFDSTADDR, arg);
 	case 15: /* SIOCGIFDSTADDR */
-		return sys32_ioctl(fd, SIOCGIFDSTADDR, arg);
+		return compat_sys_ioctl(fd, SIOCGIFDSTADDR, arg);
 	case 16: /* SIOCSIFFLAGS */
-		return sys32_ioctl(fd, SIOCSIFFLAGS, arg);
+		return compat_sys_ioctl(fd, SIOCSIFFLAGS, arg);
 	case 17: /* SIOCGIFFLAGS */
-		return sys32_ioctl(fd, SIOCGIFFLAGS, arg);
+		return compat_sys_ioctl(fd, SIOCGIFFLAGS, arg);
 	case 18: /* SIOCSIFMEM */
-		return sys32_ioctl(fd, SIOCSIFMEM, arg);
+		return compat_sys_ioctl(fd, SIOCSIFMEM, arg);
 	case 19: /* SIOCGIFMEM */
-		return sys32_ioctl(fd, SIOCGIFMEM, arg);
+		return compat_sys_ioctl(fd, SIOCGIFMEM, arg);
 	case 20: /* SIOCGIFCONF */
-		return sys32_ioctl(fd, SIOCGIFCONF, arg);
+		return compat_sys_ioctl(fd, SIOCGIFCONF, arg);
 	case 21: /* SIOCSIFMTU */
-		return sys32_ioctl(fd, SIOCSIFMTU, arg);
+		return compat_sys_ioctl(fd, SIOCSIFMTU, arg);
 	case 22: /* SIOCGIFMTU */
-		return sys32_ioctl(fd, SIOCGIFMTU, arg);
+		return compat_sys_ioctl(fd, SIOCGIFMTU, arg);
 	case 23: /* SIOCGIFBRDADDR */
-		return sys32_ioctl(fd, SIOCGIFBRDADDR, arg);
+		return compat_sys_ioctl(fd, SIOCGIFBRDADDR, arg);
 	case 24: /* SIOCSIFBRDADDR */
-		return sys32_ioctl(fd, SIOCSIFBRDADDR, arg);
+		return compat_sys_ioctl(fd, SIOCSIFBRDADDR, arg);
 	case 25: /* SIOCGIFNETMASK */
-		return sys32_ioctl(fd, SIOCGIFNETMASK, arg);
+		return compat_sys_ioctl(fd, SIOCGIFNETMASK, arg);
 	case 26: /* SIOCSIFNETMASK */
-		return sys32_ioctl(fd, SIOCSIFNETMASK, arg);
+		return compat_sys_ioctl(fd, SIOCSIFNETMASK, arg);
 	case 27: /* SIOCGIFMETRIC */
-		return sys32_ioctl(fd, SIOCGIFMETRIC, arg);
+		return compat_sys_ioctl(fd, SIOCGIFMETRIC, arg);
 	case 28: /* SIOCSIFMETRIC */
-		return sys32_ioctl(fd, SIOCSIFMETRIC, arg);
+		return compat_sys_ioctl(fd, SIOCSIFMETRIC, arg);
 	case 30: /* SIOCSARP */
-		return sys32_ioctl(fd, SIOCSARP, arg);
+		return compat_sys_ioctl(fd, SIOCSARP, arg);
 	case 31: /* SIOCGARP */
-		return sys32_ioctl(fd, SIOCGARP, arg);
+		return compat_sys_ioctl(fd, SIOCGARP, arg);
 	case 32: /* SIOCDARP */
-		return sys32_ioctl(fd, SIOCDARP, arg);
+		return compat_sys_ioctl(fd, SIOCDARP, arg);
 	case 52: /* SIOCGETNAME */
 	case 53: /* SIOCGETPEER */
 		{
diff -Nru a/arch/sparc64/solaris/misc.c b/arch/sparc64/solaris/misc.c
--- a/arch/sparc64/solaris/misc.c	Wed Apr 30 22:28:17 2003
+++ b/arch/sparc64/solaris/misc.c	Wed Apr 30 22:28:17 2003
@@ -1,5 +1,5 @@
 /* $Id: misc.c,v 1.36 2002/02/09 19:49:31 davem Exp $
- * misc.c: Miscelaneous syscall emulation for Solaris
+ * misc.c: Miscellaneous syscall emulation for Solaris
  *
  * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  */
diff -Nru a/arch/sparc64/solaris/timod.c b/arch/sparc64/solaris/timod.c
--- a/arch/sparc64/solaris/timod.c	Wed Apr 30 22:28:08 2003
+++ b/arch/sparc64/solaris/timod.c	Wed Apr 30 22:28:08 2003
@@ -29,8 +29,6 @@
 
 extern asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, 
 	unsigned long arg);
-extern asmlinkage int sys32_ioctl(unsigned int fd, unsigned int cmd,
-	u32 arg);
 asmlinkage int solaris_ioctl(unsigned int fd, unsigned int cmd, u32 arg);
 
 static spinlock_t timod_pagelock = SPIN_LOCK_UNLOCKED;
diff -Nru a/arch/um/drivers/line.c b/arch/um/drivers/line.c
--- a/arch/um/drivers/line.c	Wed Apr 30 22:28:16 2003
+++ b/arch/um/drivers/line.c	Wed Apr 30 22:28:16 2003
@@ -109,7 +109,7 @@
 		buf = new;
 	}
 
-	i = minor(tty->device) - tty->driver.minor_start;
+	i = tty->index;
 	line = &lines[i];
 
 	down(&line->sem);
@@ -219,7 +219,7 @@
 	int n, err = 0;
 
 	if(tty == NULL) n = 0;
-	else n = minor(tty->device) - tty->driver.minor_start;
+	else n = tty->index;
 	line = &lines[n];
 
 	down(&line->sem);
@@ -267,7 +267,7 @@
 	int n;
 
 	if(tty == NULL) n = 0;
-	else n = minor(tty->device) - tty->driver.minor_start;
+	else n = tty->index;
 	line = &lines[n];
 
 	down(&line->sem);
@@ -444,7 +444,7 @@
 
 	for(i = 0; i < nlines; i++){
 		if(!lines[i].valid) 
-			tty_unregister_devfs(driver, driver->minor_start + i);
+			tty_unregister_devfs(driver, i);
 	}
 
 	mconsole_register_dev(&line_driver->mc);
diff -Nru a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c
--- a/arch/um/drivers/stdio_console.c	Wed Apr 30 22:28:06 2003
+++ b/arch/um/drivers/stdio_console.c	Wed Apr 30 22:28:06 2003
@@ -199,9 +199,10 @@
 	.set_termios 		= set_termios
 };
 
-static kdev_t console_device(struct console *c)
+static struct tty_driver *console_device(struct console *c, int *index)
 {
-	return mk_kdev(TTY_MAJOR, c->index);
+	*index = c->index;
+	return &console_driver;
 }
 
 static int console_setup(struct console *co, char *options)
diff -Nru a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
--- a/arch/um/drivers/ubd_kern.c	Wed Apr 30 22:28:09 2003
+++ b/arch/um/drivers/ubd_kern.c	Wed Apr 30 22:28:09 2003
@@ -106,8 +106,6 @@
 	__u64 size;
 	struct openflags boot_openflags;
 	struct openflags openflags;
-	devfs_handle_t real;
-	devfs_handle_t fake;
 	struct cow cow;
 };
 
@@ -127,8 +125,6 @@
 	.size =			-1, \
 	.boot_openflags =	OPEN_FLAGS, \
 	.openflags =		OPEN_FLAGS, \
-	.real =			NULL, \
-	.fake =			NULL, \
         .cow =			DEFAULT_COW, \
 }
 
@@ -484,41 +480,30 @@
 	return(err);
 }
 
-static int ubd_new_disk(int major, u64 size, char *name, int unit,
-			struct gendisk **disk_out, devfs_handle_t dir_handle,
-			devfs_handle_t *handle_out)
+static int ubd_new_disk(int major, u64 size, int unit,
+			struct gendisk **disk_out)
+			
 {
-	char devfs_name[sizeof("ubd/nnnnnn\0")];
 	struct gendisk *disk;
-	int minor = unit << UBD_SHIFT;
 
 	disk = alloc_disk(1 << UBD_SHIFT);
-	if(disk == NULL)
-		return(-ENOMEM);
+	if (!disk)
+		return -ENOMEM;
 
 	disk->major = major;
-	disk->first_minor = minor;
+	disk->first_minor = unit << UBD_SHIFT;
 	disk->fops = &ubd_blops;
 	set_capacity(disk, size / 512);
-	/* needs to be ubd -> /dev/ubd/discX/disc */
 	sprintf(disk->disk_name, "ubd");
-	*disk_out = disk;
+	sprintf(disk->devfs_name, "ubd/disc%d", unit);
 
-	/* /dev/ubd/N style names */
-	sprintf(devfs_name, "ubd/%d", unit);
-	*handle_out = devfs_register(NULL, devfs_name,
-				     0, major, minor,
-				     S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP |
-				     S_IWGRP, &ubd_blops, NULL);
 	disk->private_data = &ubd_dev[unit];
 	disk->queue = &ubd_queue;
 	add_disk(disk);
-	return(0);
-}
 
-/* Initialized in an initcall, and unchanged thereafter */
-devfs_handle_t ubd_dir_handle;
-devfs_handle_t ubd_fake_dir_handle;
+	*disk_out = disk;
+	return 0;
+}
 
 static int ubd_add(int n)
 {
@@ -538,15 +523,13 @@
 	if(err)
 		return(err);
 
-	err = ubd_new_disk(MAJOR_NR, dev->size, "ubd", n, &ubd_gendisk[n], 
-			   ubd_dir_handle, &dev->real);
+	err = ubd_new_disk(MAJOR_NR, dev->size, n, &ubd_gendisk[n]);
 	if(err) 
 		return(err);
  
 	if(fake_major)
-		ubd_new_disk(fake_major, dev->size, "ubd%d", n, 
-			     &fake_gendisk[n], ubd_fake_dir_handle, 
-			     &dev->fake);
+		ubd_new_disk(fake_major, dev->size, n, 
+			     &fake_gendisk[n]);
 
 	/* perhaps this should also be under the "if (fake_major)" above */
 	/* using the fake_disk->disk_name and also the fakehd_set name */
@@ -645,15 +628,11 @@
 	del_gendisk(ubd_gendisk[n]);
 	put_disk(ubd_gendisk[n]);
 	ubd_gendisk[n] = NULL;
-	if(dev->real != NULL) 
-		devfs_unregister(dev->real);
 
 	if(fake_gendisk[n] != NULL){
 		del_gendisk(fake_gendisk[n]);
 		put_disk(fake_gendisk[n]);
 		fake_gendisk[n] = NULL;
-		if(dev->fake != NULL) 
-			devfs_unregister(dev->fake);
 	}
 
 	*dev = ((struct ubd) DEFAULT_UBD);
@@ -682,7 +661,7 @@
 {
         int i;
 
-	ubd_dir_handle = devfs_mk_dir("ubd");
+	devfs_mk_dir("ubd");
 	if (register_blkdev(MAJOR_NR, "ubd"))
 		return -1;
 
@@ -693,7 +672,7 @@
 		char name[sizeof("ubd_nnn\0")];
 
 		snprintf(name, sizeof(name), "ubd_%d", fake_major);
-		ubd_fake_dir_handle = devfs_mk_dir(name);
+		devfs_mk_dir(name);
 		if (register_blkdev(fake_major, "ubd"))
 			return -1;
 	}
diff -Nru a/arch/um/kernel/initrd_kern.c b/arch/um/kernel/initrd_kern.c
--- a/arch/um/kernel/initrd_kern.c	Wed Apr 30 22:28:03 2003
+++ b/arch/um/kernel/initrd_kern.c	Wed Apr 30 22:28:03 2003
@@ -5,7 +5,7 @@
 
 #include "linux/init.h"
 #include "linux/bootmem.h"
-#include "linux/blk.h"
+#include "linux/initrd.h"
 #include "asm/types.h"
 #include "user_util.h"
 #include "kern_util.h"
diff -Nru a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
--- a/arch/um/kernel/mem.c	Wed Apr 30 22:28:08 2003
+++ b/arch/um/kernel/mem.c	Wed Apr 30 22:28:08 2003
@@ -810,35 +810,21 @@
 
 pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
 {
-	int count = 0;
 	pte_t *pte;
 
-   	do {
-		pte = (pte_t *) __get_free_page(GFP_KERNEL);
-		if (pte)
-			clear_page(pte);
-		else {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pte && (count++ < 10));
+	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
+	if (pte)
+		clear_page(pte);
 	return pte;
 }
 
 struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	int count = 0;
 	struct page *pte;
    
-   	do {
-		pte = alloc_pages(GFP_KERNEL, 0);
-		if (pte)
-			clear_highpage(pte);
-		else {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pte && (count++ < 10));
+	pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
+	if (pte)
+		clear_highpage(pte);
 	return pte;
 }
 
diff -Nru a/arch/v850/Kconfig b/arch/v850/Kconfig
--- a/arch/v850/Kconfig	Wed Apr 30 22:28:08 2003
+++ b/arch/v850/Kconfig	Wed Apr 30 22:28:08 2003
@@ -341,7 +341,7 @@
 	  interrupt and DMA channel), because you will be asked for it.
 
 	  You want to read the Sound-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. General information about
+	  <http://www.tldp.org/docs.html#howto>. General information about
 	  the modular sound system is contained in the files
 	  <file:Documentation/sound/Introduction>.  The file
 	  <file:Documentation/sound/README.OSS> contains some slightly
diff -Nru a/arch/v850/kernel/memcons.c b/arch/v850/kernel/memcons.c
--- a/arch/v850/kernel/memcons.c	Wed Apr 30 22:28:17 2003
+++ b/arch/v850/kernel/memcons.c	Wed Apr 30 22:28:17 2003
@@ -58,9 +58,11 @@
 		len -= write (buf, len);
 }
 
-static kdev_t memcons_device (struct console *co)
+extern struct tty_driver tty_driver;
+static struct tty_driver *memcons_device (struct console *co, int *index)
 {
-        return MKDEV (TTY_MAJOR, 64 + co->index);
+	*index = co->index;
+	return &tty_driver;
 }
 
 static struct console memcons =
diff -Nru a/arch/v850/kernel/simcons.c b/arch/v850/kernel/simcons.c
--- a/arch/v850/kernel/simcons.c	Wed Apr 30 22:28:15 2003
+++ b/arch/v850/kernel/simcons.c	Wed Apr 30 22:28:15 2003
@@ -35,9 +35,11 @@
 	return V850_SIM_SYSCALL (read, 0, buf, len);
 }
 
-static kdev_t simcons_device (struct console *c)
+extern struct tty_driver tty_driver;
+static struct tty_driver *simcons_device (struct console *c, int *index)
 {
-        return mk_kdev (TTY_MAJOR, 64 + c->index);
+	*index = c->index;
+	return &tty_driver;
 }
 
 static struct console simcons =
diff -Nru a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
--- a/arch/x86_64/Kconfig	Wed Apr 30 22:28:15 2003
+++ b/arch/x86_64/Kconfig	Wed Apr 30 22:28:15 2003
@@ -286,7 +286,7 @@
 
 config SOFTWARE_SUSPEND
 	bool "Software Suspend (EXPERIMENTAL)"
-	depends on EXPERIMENTAL && PM
+	depends on EXPERIMENTAL && PM && SWAP
 	---help---
 	  Enable the possibilty of suspending the machine. It doesn't need APM.
 	  You may suspend your machine by 'swsusp' or 'shutdown -z <time>' 
diff -Nru a/arch/x86_64/ia32/ia32_ioctl.c b/arch/x86_64/ia32/ia32_ioctl.c
--- a/arch/x86_64/ia32/ia32_ioctl.c	Wed Apr 30 22:28:09 2003
+++ b/arch/x86_64/ia32/ia32_ioctl.c	Wed Apr 30 22:28:09 2003
@@ -63,12 +63,6 @@
 #include <linux/ctype.h>
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/rfcomm.h>
-#if defined(CONFIG_BLK_DEV_LVM) || defined(CONFIG_BLK_DEV_LVM_MODULE)
-/* Ugh. This header really is not clean */
-#define min min
-#define max max
-#include <linux/lvm.h>
-#endif /* LVM */
 
 #include <scsi/scsi.h>
 /* Ugly hack. */
@@ -683,7 +677,7 @@
 	return (void *)regs->rsp - len; 
 }
 
-static int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
+int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
 	struct ifreq *u_ifreq64;
 	struct ifreq32 *u_ifreq32 = (struct ifreq32 *) arg;
@@ -1987,7 +1981,7 @@
 	if (tty_paranoia_check(tty, inode->i_rdev, "tty_ioctl"))
 		return -EINVAL;
 	                                                
-	if (tty->driver.ioctl != vt_ioctl)
+	if (tty->driver->ioctl != vt_ioctl)
 		return -EINVAL;
 	
 	/*
@@ -2340,445 +2334,6 @@
         return -EINVAL;
 }
 
-#if defined(CONFIG_BLK_DEV_LVM) || defined(CONFIG_BLK_DEV_LVM_MODULE)
-/* Ugh, LVM. Pitty it was not cleaned up before accepted :((. */
-/* AK: dev_t/kdev_t use here is somewhat dubious */
-typedef struct {
-	uint8_t vg_name[NAME_LEN];
-	uint32_t vg_number;
-	uint32_t vg_access;
-	uint32_t vg_status;
-	uint32_t lv_max;
-	uint32_t lv_cur;
-	uint32_t lv_open;
-	uint32_t pv_max;
-	uint32_t pv_cur;
-	uint32_t pv_act;
-	uint32_t dummy;
-	uint32_t vgda;
-	uint32_t pe_size;
-	uint32_t pe_total;
-	uint32_t pe_allocated;
-	uint32_t pvg_total;
-	u32 proc;
-	u32 pv[ABS_MAX_PV + 1];
-	u32 lv[ABS_MAX_LV + 1];
-    	uint8_t vg_uuid[UUID_LEN+1];	/* volume group UUID */
-	uint8_t dummy1[200];
-} vg32_t;
-
-typedef struct {
-	uint8_t id[2];
-	uint16_t version;
-	lvm_disk_data_t pv_on_disk;
-	lvm_disk_data_t vg_on_disk;
-	lvm_disk_data_t pv_namelist_on_disk;
-	lvm_disk_data_t lv_on_disk;
-	lvm_disk_data_t pe_on_disk;
-	uint8_t pv_name[NAME_LEN];
-	uint8_t vg_name[NAME_LEN];
-	uint8_t system_id[NAME_LEN];
-	__u32 pv_dev;
-	uint32_t pv_number;
-	uint32_t pv_status;
-	uint32_t pv_allocatable;
-	uint32_t pv_size;
-	uint32_t lv_cur;
-	uint32_t pe_size;
-	uint32_t pe_total;
-	uint32_t pe_allocated;
-	uint32_t pe_stale;
-	u32 pe;
-	u32 inode;
-	uint8_t pv_uuid[UUID_LEN+1];
-} pv32_t;
-
-typedef struct {
-	char lv_name[NAME_LEN];
-	u32 lv;
-} lv_req32_t;
-
-typedef struct {
-	u32 lv_index;
-	u32 lv;
-	/* Transfer size because user space and kernel space differ */
-	uint16_t size;
-} lv_status_byindex_req32_t;
-
-typedef struct {
-	dev_t dev;
-	u32   lv;
-} lv_status_bydev_req32_t;
-
-typedef struct {
-	uint8_t lv_name[NAME_LEN];
-	kdev_t old_dev;
-	kdev_t new_dev;
-	u32 old_pe;
-	u32 new_pe;
-} le_remap_req32_t;
-
-typedef struct {
-	char pv_name[NAME_LEN];
-	u32 pv;
-} pv_status_req32_t;
-
-typedef struct {
-	uint8_t lv_name[NAME_LEN];
-	uint8_t vg_name[NAME_LEN];
-	uint32_t lv_access;
-	uint32_t lv_status;
-	uint32_t lv_open;
-	kdev_t lv_dev;
-	uint32_t lv_number;
-	uint32_t lv_mirror_copies;
-	uint32_t lv_recovery;
-	uint32_t lv_schedule;
-	uint32_t lv_size;
-	u32 lv_current_pe;
-	uint32_t lv_current_le;
-	uint32_t lv_allocated_le;
-	uint32_t lv_stripes;
-	uint32_t lv_stripesize;
-	uint32_t lv_badblock;
-	uint32_t lv_allocation;
-	uint32_t lv_io_timeout;
-	uint32_t lv_read_ahead;
-	/* delta to version 1 starts here */
-	u32 lv_snapshot_org;
-	u32 lv_snapshot_prev;
-	u32 lv_snapshot_next;
-	u32 lv_block_exception;
-	uint32_t lv_remap_ptr;
-	uint32_t lv_remap_end;
-	uint32_t lv_chunk_size;
-	uint32_t lv_snapshot_minor;
-	char dummy[200];
-} lv32_t;
-
-typedef struct {
-	u32 hash[2];
-	u32 rsector_org;
-	kdev_t rdev_org;
-	u32 rsector_new;
-	kdev_t rdev_new;
-} lv_block_exception32_t;
-
-static void put_lv_t(lv_t *l)
-{
-	if (l->lv_current_pe) vfree(l->lv_current_pe);
-	if (l->lv_block_exception) vfree(l->lv_block_exception);
-	kfree(l);
-}
-
-static lv_t *get_lv_t(u32 p, int *errp)
-{
-	int err, i;
-	u32 ptr1, ptr2;
-	size_t size;
-	lv_block_exception32_t *lbe32;
-	lv_block_exception_t *lbe;
-	lv32_t *ul = (lv32_t *)A(p);
-	lv_t *l = (lv_t *) kmalloc(sizeof(lv_t), GFP_KERNEL);
-
-	if (!l) {
-		*errp = -ENOMEM;
-		return NULL;
-	}
-	memset(l, 0, sizeof(lv_t));
-	err = copy_from_user(l, ul, (long)&((lv32_t *)0)->lv_current_pe);
-	err |= __copy_from_user(&l->lv_current_le, &ul->lv_current_le,
-				((long)&ul->lv_snapshot_org) - ((long)&ul->lv_current_le));
-	err |= __copy_from_user(&l->lv_remap_ptr, &ul->lv_remap_ptr,
-				((long)&ul->dummy[0]) - ((long)&ul->lv_remap_ptr));
-	err |= __get_user(ptr1, &ul->lv_current_pe);
-	err |= __get_user(ptr2, &ul->lv_block_exception);
-	if (err) {
-		kfree(l);
-		*errp = -EFAULT;
-		return NULL;
-	}
-	if (ptr1) {
-		size = l->lv_allocated_le * sizeof(pe_t);
-		l->lv_current_pe = vmalloc(size);
-		if (l->lv_current_pe)
-			err = copy_from_user(l->lv_current_pe, (void *)A(ptr1), size);
-	}
-	if (!err && ptr2) {
-		size = l->lv_remap_end * sizeof(lv_block_exception_t);
-		l->lv_block_exception = lbe = vmalloc(size);
-		if (l->lv_block_exception) {
-			lbe32 = (lv_block_exception32_t *)A(ptr2);
-			memset(lbe, 0, size);
-                       for (i = 0; i < l->lv_remap_end; i++, lbe++, lbe32++) {
-                               err |= get_user(lbe->rsector_org, &lbe32->rsector_org);
-                               err |= __get_user(lbe->rdev_org, &lbe32->rdev_org);
-                               err |= __get_user(lbe->rsector_new, &lbe32->rsector_new);
-                               err |= __get_user(lbe->rdev_new, &lbe32->rdev_new);
-			}
-		}
-	}
-	if (err || (ptr1 && !l->lv_current_pe) || (ptr2 && !l->lv_block_exception)) {
-		if (!err)
-			*errp = -ENOMEM;
-		else
-			*errp = -EFAULT;
-		put_lv_t(l);
-		return NULL;
-	}
-	return l;
-}
-
-static int copy_lv_t(u32 ptr, lv_t *l)
-{
-	int err;
-	lv32_t *ul = (lv32_t *)A(ptr);
-	u32 ptr1;
-	size_t size;
-
-	err = get_user(ptr1, &ul->lv_current_pe);
-	if (err)
-		return -EFAULT;
-	err = copy_to_user(ul, l, (long)&((lv32_t *)0)->lv_current_pe);
-	err |= __copy_to_user(&ul->lv_current_le, &l->lv_current_le,
-				((long)&ul->lv_snapshot_org) - ((long)&ul->lv_current_le));
-	err |= __copy_to_user(&ul->lv_remap_ptr, &l->lv_remap_ptr,
-				((long)&ul->dummy[0]) - ((long)&ul->lv_remap_ptr));
-	size = l->lv_allocated_le * sizeof(pe_t);
-	if (ptr1)
-		err |= __copy_to_user((void *)A(ptr1), l->lv_current_pe, size);
-	return err ? -EFAULT : 0;
-}
-
-static int do_lvm_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
-	vg_t *v = NULL;
-	union {
-		lv_req_t lv_req;
-		le_remap_req_t le_remap;
-		lv_status_byindex_req_t lv_byindex;
-	        lv_status_bydev_req_t lv_bydev;
-		pv_status_req_t pv_status;
-	} u;
-	pv_t p;
-	int err;
-	u32 ptr = 0;
-	int i;
-	mm_segment_t old_fs;
-	void *karg = &u;
-
-	switch (cmd) {
-	case VG_STATUS:
-		v = kmalloc(sizeof(vg_t), GFP_KERNEL);
-		if (!v)
-			return -ENOMEM;
-		karg = v;
-		break;
-
-	case VG_CREATE_OLD:
-	case VG_CREATE:
-		v = kmalloc(sizeof(vg_t), GFP_KERNEL);
-		if (!v)
-			return -ENOMEM;
-		if (copy_from_user(v, (void *)arg, (long)&((vg32_t *)0)->proc)) {
-			kfree(v);
-			return -EFAULT;
-		}
-		/* 'proc' field is unused, just NULL it out. */
-		v->proc = NULL;
-		if (copy_from_user(v->vg_uuid, ((vg32_t *)arg)->vg_uuid, UUID_LEN+1)) {
-			kfree(v);
-			return -EFAULT;
-		}
-		    
-		karg = v;
-		memset(v->pv, 0, sizeof(v->pv) + sizeof(v->lv));
-		if (v->pv_max > ABS_MAX_PV || v->lv_max > ABS_MAX_LV)
-			return -EPERM;
-		for (i = 0; i < v->pv_max; i++) {
-			err = __get_user(ptr, &((vg32_t *)arg)->pv[i]);
-			if (err)
-				break;
-			if (ptr) {
-				v->pv[i] = kmalloc(sizeof(pv_t), GFP_KERNEL);
-				if (!v->pv[i]) {
-					err = -ENOMEM;
-					break;
-				}
-				err = copy_from_user(v->pv[i], (void *)A(ptr),
-						     sizeof(pv32_t) - 8 - UUID_LEN+1);
-				if (err) {
-					err = -EFAULT;
-					break;
-				}
-				err = copy_from_user(v->pv[i]->pv_uuid,
-						     ((pv32_t *)A(ptr))->pv_uuid,
-						     UUID_LEN+1);
-				if (err) {
-				        err = -EFAULT;
-					break;
-				}
-
-				v->pv[i]->pe = NULL;
-				v->pv[i]->bd = NULL;
-			}
-		}
-		if (!err) {
-			for (i = 0; i < v->lv_max; i++) {
-				err = __get_user(ptr, &((vg32_t *)arg)->lv[i]);
-				if (err)
-					break;
-				if (ptr) {
-					v->lv[i] = get_lv_t(ptr, &err);
-					if (err)
-						break;
-				}
-			}
-		}
-		break;
-
-	case LV_CREATE:
-	case LV_EXTEND:
-	case LV_REDUCE:
-	case LV_REMOVE:
-	case LV_RENAME:
-	case LV_STATUS_BYNAME:
-	        err = copy_from_user(&u.pv_status, (void*)arg, sizeof(u.pv_status.pv_name));
-		if (err)
-			return -EFAULT;
-		if (cmd != LV_REMOVE) {
-			err = __get_user(ptr, &((lv_req32_t *)arg)->lv);
-			if (err)
-				return err;
-			u.lv_req.lv = get_lv_t(ptr, &err);
-		} else
-			u.lv_req.lv = NULL;
-		break;
-
-	case LV_STATUS_BYINDEX:
-		err = get_user(u.lv_byindex.lv_index,
-			       &((lv_status_byindex_req32_t *)arg)->lv_index);
-		err |= __get_user(ptr, &((lv_status_byindex_req32_t *)arg)->lv);
-		if (err)
-			return err;
-		u.lv_byindex.lv = get_lv_t(ptr, &err);
-		break;
-
-	case LV_STATUS_BYDEV:
-	        err = get_user(u.lv_bydev.dev, &((lv_status_bydev_req32_t *)arg)->dev);
-		err |= __get_user(ptr, &((lv_status_bydev_req32_t *)arg)->lv);
-		if (err)
-			return err;
-		u.lv_bydev.lv = get_lv_t(ptr, &err);
-		break;		
-
-	case VG_EXTEND:
-		err = copy_from_user(&p, (void *)arg, sizeof(pv32_t) - 8 - UUID_LEN+1);
-		if (err)
-			return -EFAULT;
-		err = copy_from_user(p.pv_uuid, ((pv32_t *)arg)->pv_uuid, UUID_LEN+1);
-		if (err)
-			return -EFAULT;
-		p.pe = NULL;
-		p.bd = NULL;
-		karg = &p;
-		break;
-
-	case PV_CHANGE:
-	case PV_STATUS:
-		err = copy_from_user(&u.pv_status, (void*)arg, sizeof(u.lv_req.lv_name));
-		if (err)
-			return -EFAULT;
-		err = __get_user(ptr, &((pv_status_req32_t *)arg)->pv);
-		if (err)
-			return err;
-		u.pv_status.pv = &p;
-		if (cmd == PV_CHANGE) {
-			err = copy_from_user(&p, (void *)A(ptr),
-					     sizeof(pv32_t) - 8 - UUID_LEN+1);
-			if (err)
-				return -EFAULT;
-			p.pe = NULL;
-			p.bd = NULL;
-		}
-		break;
-	};
-
-        old_fs = get_fs(); set_fs (KERNEL_DS);
-        err = sys_ioctl (fd, cmd, (unsigned long)karg);
-        set_fs (old_fs);
-
-	switch (cmd) {
-	case VG_STATUS:
-		if (!err) {
-			if (copy_to_user((void *)arg, v, (long)&((vg32_t *)0)->proc) ||
-			    clear_user(&((vg32_t *)arg)->proc, sizeof(vg32_t) - (long)&((vg32_t *)0)->proc))
-				err = -EFAULT;
-		}
-		if (copy_to_user(((vg32_t *)arg)->vg_uuid, v->vg_uuid, UUID_LEN+1)) {
-		        err = -EFAULT;
-		}
-		kfree(v);
-		break;
-
-	case VG_CREATE_OLD:
-	case VG_CREATE:
-		for (i = 0; i < v->pv_max; i++) {
-			if (v->pv[i])
-				kfree(v->pv[i]);
-		}
-		for (i = 0; i < v->lv_max; i++) {
-			if (v->lv[i])
-				put_lv_t(v->lv[i]);
-		}
-		kfree(v);
-		break;
-
-	case LV_STATUS_BYNAME:
-		if (!err && u.lv_req.lv)
-			err = copy_lv_t(ptr, u.lv_req.lv);
-		/* Fall through */
-
-        case LV_CREATE:
-	case LV_EXTEND:
-	case LV_REDUCE:
-		if (u.lv_req.lv)
-			put_lv_t(u.lv_req.lv);
-		break;
-
-	case LV_STATUS_BYINDEX:
-		if (u.lv_byindex.lv) {
-			if (!err)
-				err = copy_lv_t(ptr, u.lv_byindex.lv);
-			put_lv_t(u.lv_byindex.lv);
-		}
-		break;
-
-	case LV_STATUS_BYDEV:
-	        if (u.lv_bydev.lv) {
-			if (!err)
-				err = copy_lv_t(ptr, u.lv_bydev.lv);
-			put_lv_t(u.lv_byindex.lv);
-	        }
-	        break;
-
-	case PV_STATUS:
-		if (!err) {
-			err = copy_to_user((void *)A(ptr), &p, sizeof(pv32_t) - 8 - UUID_LEN+1);
-			if (err)
-				return -EFAULT;
-			err = copy_to_user(((pv_t *)A(ptr))->pv_uuid, p.pv_uuid, UUID_LEN + 1);
-			if (err)
-				return -EFAULT;
-	}
-		break;
-	};
-
-	return err;
-}
-#endif
-
-
 static int ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
 	return -EINVAL;
@@ -2847,7 +2402,7 @@
 	real_tty = (struct tty_struct *)file->private_data;
 	if (!real_tty) 	
 		return -EINVAL; 
-	return put_user(kdev_t_to_nr(real_tty->device), ptr); 
+	return put_user(real_tty->device, ptr); 
 } 
 
 
@@ -3581,567 +3136,21 @@
 	return err;
 } 
 
-struct ioctl_trans {
-	unsigned long cmd;
-	int (*handler)(unsigned int, unsigned int, unsigned long, struct file * filp);
-	struct ioctl_trans *next;
-};
-
 #define REF_SYMBOL(handler) if (0) (void)handler;
 #define HANDLE_IOCTL2(cmd,handler) REF_SYMBOL(handler);  asm volatile(".quad %c0, " #handler ",0"::"i" (cmd)); 
 #define HANDLE_IOCTL(cmd,handler) HANDLE_IOCTL2(cmd,handler)
 #define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL(cmd,sys_ioctl)
-#define IOCTL_TABLE_START void ioctl_dummy(void) { asm volatile("\nioctl_start:\n\t" );
-#define IOCTL_TABLE_END  asm volatile("\nioctl_end:"); }
+#define IOCTL_TABLE_START void ioctl_dummy(void) { asm volatile("\n.global ioctl_start\nioctl_start:\n\t" );
+#define IOCTL_TABLE_END  asm volatile("\n.global ioctl_end;\nioctl_end:\n"); }
 
 IOCTL_TABLE_START
-/* List here explicitly which ioctl's are known to have
- * compatible types passed or none at all...
- */
-/* Big T */
-COMPATIBLE_IOCTL(TCGETA)
-COMPATIBLE_IOCTL(TCSETA)
-COMPATIBLE_IOCTL(TCSETAW)
-COMPATIBLE_IOCTL(TCSETAF)
-COMPATIBLE_IOCTL(TCSBRK)
-COMPATIBLE_IOCTL(TCXONC)
-COMPATIBLE_IOCTL(TCFLSH)
-COMPATIBLE_IOCTL(TCGETS)
-COMPATIBLE_IOCTL(TCSETS)
-COMPATIBLE_IOCTL(TCSETSW)
-COMPATIBLE_IOCTL(TCSETSF)
-COMPATIBLE_IOCTL(TIOCLINUX)
-/* Little t */
-COMPATIBLE_IOCTL(TIOCGETD)
-COMPATIBLE_IOCTL(TIOCSETD)
-COMPATIBLE_IOCTL(TIOCEXCL)
-COMPATIBLE_IOCTL(TIOCNXCL)
-COMPATIBLE_IOCTL(TIOCCONS)
-COMPATIBLE_IOCTL(TIOCGSOFTCAR)
-COMPATIBLE_IOCTL(TIOCSSOFTCAR)
-COMPATIBLE_IOCTL(TIOCSWINSZ)
-COMPATIBLE_IOCTL(TIOCGWINSZ)
-COMPATIBLE_IOCTL(TIOCMGET)
-COMPATIBLE_IOCTL(TIOCMBIC)
-COMPATIBLE_IOCTL(TIOCMBIS)
-COMPATIBLE_IOCTL(TIOCMSET)
-COMPATIBLE_IOCTL(TIOCPKT)
-COMPATIBLE_IOCTL(TIOCNOTTY)
-COMPATIBLE_IOCTL(TIOCSTI)
-COMPATIBLE_IOCTL(TIOCOUTQ)
-COMPATIBLE_IOCTL(TIOCSPGRP)
-COMPATIBLE_IOCTL(TIOCGPGRP)
-COMPATIBLE_IOCTL(TIOCSCTTY)
-COMPATIBLE_IOCTL(TIOCGPTN)
-COMPATIBLE_IOCTL(TIOCSPTLCK)
-COMPATIBLE_IOCTL(TIOCSERGETLSR)
-/* Big F */
-COMPATIBLE_IOCTL(FBIOGET_VSCREENINFO)
-COMPATIBLE_IOCTL(FBIOPUT_VSCREENINFO)
-COMPATIBLE_IOCTL(FBIOPAN_DISPLAY)
-COMPATIBLE_IOCTL(FBIOGET_CON2FBMAP)
-COMPATIBLE_IOCTL(FBIOPUT_CON2FBMAP)
-/* Little f */
-COMPATIBLE_IOCTL(FIOCLEX)
-COMPATIBLE_IOCTL(FIONCLEX)
-COMPATIBLE_IOCTL(FIOASYNC)
-COMPATIBLE_IOCTL(FIONBIO)
-COMPATIBLE_IOCTL(FIONREAD)  /* This is also TIOCINQ */
-/* 0x00 */
-COMPATIBLE_IOCTL(FIBMAP)
-COMPATIBLE_IOCTL(FIGETBSZ)
-/* 0x03 -- HD/IDE ioctl's used by hdparm and friends.
- *         Some need translations, these do not.
- */
-COMPATIBLE_IOCTL(HDIO_GET_IDENTITY)
-COMPATIBLE_IOCTL(HDIO_SET_DMA)
+#include <linux/compat_ioctl.h>
 COMPATIBLE_IOCTL(HDIO_SET_KEEPSETTINGS)
-COMPATIBLE_IOCTL(HDIO_SET_UNMASKINTR)
-COMPATIBLE_IOCTL(HDIO_SET_NOWERR)
-COMPATIBLE_IOCTL(HDIO_SET_32BIT)
-COMPATIBLE_IOCTL(HDIO_SET_MULTCOUNT)
-COMPATIBLE_IOCTL(HDIO_DRIVE_CMD)
-COMPATIBLE_IOCTL(HDIO_SET_PIO_MODE)
 COMPATIBLE_IOCTL(HDIO_SCAN_HWIF)
-COMPATIBLE_IOCTL(HDIO_SET_NICE)
-/* 0x02 -- Floppy ioctls */
-COMPATIBLE_IOCTL(FDMSGON)
-COMPATIBLE_IOCTL(FDMSGOFF)
-COMPATIBLE_IOCTL(FDSETEMSGTRESH)
-COMPATIBLE_IOCTL(FDFLUSH)
-COMPATIBLE_IOCTL(FDWERRORCLR)
-COMPATIBLE_IOCTL(FDSETMAXERRS)
-COMPATIBLE_IOCTL(FDGETMAXERRS)
-COMPATIBLE_IOCTL(FDGETDRVTYP)
-COMPATIBLE_IOCTL(FDEJECT)
-COMPATIBLE_IOCTL(FDCLRPRM)
-COMPATIBLE_IOCTL(FDFMTBEG)
-COMPATIBLE_IOCTL(FDFMTEND)
-COMPATIBLE_IOCTL(FDRESET)
-COMPATIBLE_IOCTL(FDTWADDLE)
-COMPATIBLE_IOCTL(FDFMTTRK)
-COMPATIBLE_IOCTL(FDRAWCMD)
-/* 0x12 */
-COMPATIBLE_IOCTL(BLKROSET)
-COMPATIBLE_IOCTL(BLKROGET)
-COMPATIBLE_IOCTL(BLKRRPART)
-COMPATIBLE_IOCTL(BLKFLSBUF)
 COMPATIBLE_IOCTL(BLKRASET)
 COMPATIBLE_IOCTL(BLKFRASET)
-COMPATIBLE_IOCTL(BLKSECTSET)
-COMPATIBLE_IOCTL(BLKSSZGET)
-/* RAID */
-COMPATIBLE_IOCTL(RAID_VERSION)
-COMPATIBLE_IOCTL(GET_ARRAY_INFO)
-COMPATIBLE_IOCTL(GET_DISK_INFO)
-COMPATIBLE_IOCTL(PRINT_RAID_DEBUG)
-COMPATIBLE_IOCTL(CLEAR_ARRAY)
-COMPATIBLE_IOCTL(ADD_NEW_DISK)
-COMPATIBLE_IOCTL(HOT_REMOVE_DISK)
-COMPATIBLE_IOCTL(SET_ARRAY_INFO)
-COMPATIBLE_IOCTL(SET_DISK_INFO)
-COMPATIBLE_IOCTL(WRITE_RAID_INFO)
-COMPATIBLE_IOCTL(UNPROTECT_ARRAY)
-COMPATIBLE_IOCTL(PROTECT_ARRAY)
-COMPATIBLE_IOCTL(HOT_ADD_DISK)
-COMPATIBLE_IOCTL(SET_DISK_FAULTY)
-COMPATIBLE_IOCTL(RUN_ARRAY)
-COMPATIBLE_IOCTL(START_ARRAY)
-COMPATIBLE_IOCTL(STOP_ARRAY)
-COMPATIBLE_IOCTL(STOP_ARRAY_RO)
-COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
-/* Big K */
-COMPATIBLE_IOCTL(PIO_FONT)
-COMPATIBLE_IOCTL(GIO_FONT)
-COMPATIBLE_IOCTL(KDSIGACCEPT)
-COMPATIBLE_IOCTL(KDGETKEYCODE)
-COMPATIBLE_IOCTL(KDSETKEYCODE)
-COMPATIBLE_IOCTL(KIOCSOUND)
-COMPATIBLE_IOCTL(KDMKTONE)
-COMPATIBLE_IOCTL(KDGKBTYPE)
-COMPATIBLE_IOCTL(KDSETMODE)
-COMPATIBLE_IOCTL(KDGETMODE)
-COMPATIBLE_IOCTL(KDSKBMODE)
-COMPATIBLE_IOCTL(KDGKBMODE)
-COMPATIBLE_IOCTL(KDSKBMETA)
-COMPATIBLE_IOCTL(KDGKBMETA)
-COMPATIBLE_IOCTL(KDGKBENT)
-COMPATIBLE_IOCTL(KDSKBENT)
-COMPATIBLE_IOCTL(KDGKBSENT)
-COMPATIBLE_IOCTL(KDSKBSENT)
-COMPATIBLE_IOCTL(KDGKBDIACR)
-COMPATIBLE_IOCTL(KDSKBDIACR)
-COMPATIBLE_IOCTL(KDKBDREP)
-COMPATIBLE_IOCTL(KDGKBLED)
-COMPATIBLE_IOCTL(KDSKBLED)
-COMPATIBLE_IOCTL(KDGETLED)
-COMPATIBLE_IOCTL(KDSETLED)
-COMPATIBLE_IOCTL(GIO_SCRNMAP)
-COMPATIBLE_IOCTL(PIO_SCRNMAP)
-COMPATIBLE_IOCTL(GIO_UNISCRNMAP)
-COMPATIBLE_IOCTL(PIO_UNISCRNMAP)
-COMPATIBLE_IOCTL(PIO_FONTRESET)
-COMPATIBLE_IOCTL(PIO_UNIMAPCLR)
-/* Big S */
-COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
-COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK)
-COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK)
-COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY)
-COMPATIBLE_IOCTL(SCSI_IOCTL_TAGGED_ENABLE)
-COMPATIBLE_IOCTL(SCSI_IOCTL_TAGGED_DISABLE)
-COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER)
-COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND)
-COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST)
-COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI)
-/* Big T */
-COMPATIBLE_IOCTL(TUNSETNOCSUM)
-COMPATIBLE_IOCTL(TUNSETDEBUG)
-COMPATIBLE_IOCTL(TUNSETIFF)
-COMPATIBLE_IOCTL(TUNSETPERSIST)
-COMPATIBLE_IOCTL(TUNSETOWNER)
-/* Big V */
-COMPATIBLE_IOCTL(VT_SETMODE)
-COMPATIBLE_IOCTL(VT_GETMODE)
-COMPATIBLE_IOCTL(VT_GETSTATE)
-COMPATIBLE_IOCTL(VT_OPENQRY)
-COMPATIBLE_IOCTL(VT_ACTIVATE)
-COMPATIBLE_IOCTL(VT_WAITACTIVE)
-COMPATIBLE_IOCTL(VT_RELDISP)
-COMPATIBLE_IOCTL(VT_DISALLOCATE)
-COMPATIBLE_IOCTL(VT_RESIZE)
-COMPATIBLE_IOCTL(VT_RESIZEX)
-COMPATIBLE_IOCTL(VT_LOCKSWITCH)
-COMPATIBLE_IOCTL(VT_UNLOCKSWITCH)
-/* Little v */
-/* Little v, the video4linux ioctls (conflict?) */
-COMPATIBLE_IOCTL(VIDIOCGCAP)
-COMPATIBLE_IOCTL(VIDIOCGCHAN)
-COMPATIBLE_IOCTL(VIDIOCSCHAN)
-COMPATIBLE_IOCTL(VIDIOCGPICT)
-COMPATIBLE_IOCTL(VIDIOCSPICT)
-COMPATIBLE_IOCTL(VIDIOCCAPTURE)
-COMPATIBLE_IOCTL(VIDIOCKEY)
-COMPATIBLE_IOCTL(VIDIOCGAUDIO)
-COMPATIBLE_IOCTL(VIDIOCSAUDIO)
-COMPATIBLE_IOCTL(VIDIOCSYNC)
-COMPATIBLE_IOCTL(VIDIOCMCAPTURE)
-COMPATIBLE_IOCTL(VIDIOCGMBUF)
-COMPATIBLE_IOCTL(VIDIOCGUNIT)
-COMPATIBLE_IOCTL(VIDIOCGCAPTURE)
-COMPATIBLE_IOCTL(VIDIOCSCAPTURE)
-/* BTTV specific... */
-COMPATIBLE_IOCTL(_IOW('v',  BASE_VIDIOCPRIVATE+0, char [256]))
-COMPATIBLE_IOCTL(_IOR('v',  BASE_VIDIOCPRIVATE+1, char [256]))
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int))
-COMPATIBLE_IOCTL(_IOW('v' , BASE_VIDIOCPRIVATE+3, char [16])) /* struct bttv_pll_info */
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+4, int))
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+5, int))
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+6, int))
-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+7, int))
-/* Little p (/dev/rtc, /dev/envctrl, etc.) */
-COMPATIBLE_IOCTL(RTC_AIE_ON)
-COMPATIBLE_IOCTL(RTC_AIE_OFF)
-COMPATIBLE_IOCTL(RTC_UIE_ON)
-COMPATIBLE_IOCTL(RTC_UIE_OFF)
-COMPATIBLE_IOCTL(RTC_PIE_ON)
-COMPATIBLE_IOCTL(RTC_PIE_OFF)
-COMPATIBLE_IOCTL(RTC_WIE_ON)
-COMPATIBLE_IOCTL(RTC_WIE_OFF)
-COMPATIBLE_IOCTL(RTC_ALM_SET)
-COMPATIBLE_IOCTL(RTC_ALM_READ)
-COMPATIBLE_IOCTL(RTC_RD_TIME)
-COMPATIBLE_IOCTL(RTC_SET_TIME)
-COMPATIBLE_IOCTL(RTC_WKALM_SET)
-COMPATIBLE_IOCTL(RTC_WKALM_RD)
-/* Little m */
-COMPATIBLE_IOCTL(MTIOCTOP)
-/* Socket level stuff */
-COMPATIBLE_IOCTL(FIOSETOWN)
-COMPATIBLE_IOCTL(SIOCSPGRP)
-COMPATIBLE_IOCTL(FIOGETOWN)
-COMPATIBLE_IOCTL(SIOCGPGRP)
-COMPATIBLE_IOCTL(SIOCATMARK)
-COMPATIBLE_IOCTL(SIOCSIFLINK)
-COMPATIBLE_IOCTL(SIOCSIFENCAP)
-COMPATIBLE_IOCTL(SIOCGIFENCAP)
-COMPATIBLE_IOCTL(SIOCSIFBR)
-COMPATIBLE_IOCTL(SIOCGIFBR)
-COMPATIBLE_IOCTL(SIOCSARP)
-COMPATIBLE_IOCTL(SIOCGARP)
-COMPATIBLE_IOCTL(SIOCDARP)
-COMPATIBLE_IOCTL(SIOCSRARP)
-COMPATIBLE_IOCTL(SIOCGRARP)
-COMPATIBLE_IOCTL(SIOCDRARP)
-COMPATIBLE_IOCTL(SIOCADDDLCI)
-COMPATIBLE_IOCTL(SIOCDELDLCI)
-COMPATIBLE_IOCTL(SIOCGMIIPHY)
-COMPATIBLE_IOCTL(SIOCGMIIREG)
-COMPATIBLE_IOCTL(SIOCSMIIREG)
-COMPATIBLE_IOCTL(SIOCGIFVLAN)
-COMPATIBLE_IOCTL(SIOCSIFVLAN)
-/* SG stuff */
-COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
-COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
-COMPATIBLE_IOCTL(SG_EMULATED_HOST)
-COMPATIBLE_IOCTL(SG_SET_TRANSFORM)
-COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
-COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
-COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
-COMPATIBLE_IOCTL(SG_GET_SCSI_ID)
-COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA)
-COMPATIBLE_IOCTL(SG_GET_LOW_DMA)
-COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID)
-COMPATIBLE_IOCTL(SG_GET_PACK_ID)
-COMPATIBLE_IOCTL(SG_GET_NUM_WAITING)
-COMPATIBLE_IOCTL(SG_SET_DEBUG)
-COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE)
-COMPATIBLE_IOCTL(SG_GET_COMMAND_Q)
-COMPATIBLE_IOCTL(SG_SET_COMMAND_Q)
-COMPATIBLE_IOCTL(SG_GET_VERSION_NUM)
-COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN)
-COMPATIBLE_IOCTL(SG_SCSI_RESET)
-COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE)
-COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
-COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
-/* PPP stuff */
-COMPATIBLE_IOCTL(PPPIOCGFLAGS)
-COMPATIBLE_IOCTL(PPPIOCSFLAGS)
-COMPATIBLE_IOCTL(PPPIOCGASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCSASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCGUNIT)
-COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCGMRU)
-COMPATIBLE_IOCTL(PPPIOCSMRU)
-COMPATIBLE_IOCTL(PPPIOCSMAXCID)
-COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCXFERUNIT)
-/* PPPIOCSCOMPRESS is translated */
-COMPATIBLE_IOCTL(PPPIOCGNPMODE)
-COMPATIBLE_IOCTL(PPPIOCSNPMODE)
-COMPATIBLE_IOCTL(PPPIOCGDEBUG)
-COMPATIBLE_IOCTL(PPPIOCSDEBUG)
-/* PPPIOCSPASS is translated */
-/* PPPIOCSACTIVE is translated */
-/* PPPIOCGIDLE is translated */
-COMPATIBLE_IOCTL(PPPIOCNEWUNIT)
-COMPATIBLE_IOCTL(PPPIOCATTACH)
-COMPATIBLE_IOCTL(PPPIOCDETACH)
-COMPATIBLE_IOCTL(PPPIOCSMRRU)
-COMPATIBLE_IOCTL(PPPIOCCONNECT)
-COMPATIBLE_IOCTL(PPPIOCDISCONN)
-COMPATIBLE_IOCTL(PPPIOCATTCHAN)
-COMPATIBLE_IOCTL(PPPIOCGCHAN)
-/* PPPOX */
-COMPATIBLE_IOCTL(PPPOEIOCSFWD)
-COMPATIBLE_IOCTL(PPPOEIOCDFWD)
-/* LP */
-COMPATIBLE_IOCTL(LPGETSTATUS)
-/* CDROM stuff */
-COMPATIBLE_IOCTL(CDROMPAUSE)
-COMPATIBLE_IOCTL(CDROMRESUME)
-COMPATIBLE_IOCTL(CDROMPLAYMSF)
-COMPATIBLE_IOCTL(CDROMPLAYTRKIND)
-COMPATIBLE_IOCTL(CDROMREADTOCHDR)
-COMPATIBLE_IOCTL(CDROMREADTOCENTRY)
-COMPATIBLE_IOCTL(CDROMSTOP)
-COMPATIBLE_IOCTL(CDROMSTART)
-COMPATIBLE_IOCTL(CDROMEJECT)
-COMPATIBLE_IOCTL(CDROMVOLCTRL)
-COMPATIBLE_IOCTL(CDROMSUBCHNL)
-COMPATIBLE_IOCTL(CDROMEJECT_SW)
-COMPATIBLE_IOCTL(CDROMMULTISESSION)
-COMPATIBLE_IOCTL(CDROM_GET_MCN)
-COMPATIBLE_IOCTL(CDROMRESET)
-COMPATIBLE_IOCTL(CDROMVOLREAD)
-COMPATIBLE_IOCTL(CDROMSEEK)
-COMPATIBLE_IOCTL(CDROMPLAYBLK)
-COMPATIBLE_IOCTL(CDROMCLOSETRAY)
-COMPATIBLE_IOCTL(CDROM_SET_OPTIONS)
-COMPATIBLE_IOCTL(CDROM_CLEAR_OPTIONS)
-COMPATIBLE_IOCTL(CDROM_SELECT_SPEED)
-COMPATIBLE_IOCTL(CDROM_SELECT_DISC)
-COMPATIBLE_IOCTL(CDROM_MEDIA_CHANGED)
-COMPATIBLE_IOCTL(CDROM_DRIVE_STATUS)
-COMPATIBLE_IOCTL(CDROM_DISC_STATUS)
-COMPATIBLE_IOCTL(CDROM_CHANGER_NSLOTS)
-COMPATIBLE_IOCTL(CDROM_LOCKDOOR)
-COMPATIBLE_IOCTL(CDROM_DEBUG)
-COMPATIBLE_IOCTL(CDROM_GET_CAPABILITY)
-/* DVD ioctls */
-COMPATIBLE_IOCTL(DVD_READ_STRUCT)
-COMPATIBLE_IOCTL(DVD_WRITE_STRUCT)
-COMPATIBLE_IOCTL(DVD_AUTH)
-/* Big L */
-COMPATIBLE_IOCTL(LOOP_SET_FD)
-COMPATIBLE_IOCTL(LOOP_CLR_FD)
-/* Big A */
-/* sparc only */
-/* Big Q for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC)
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_INFO)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_CTRLRATE)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_GETOUTCOUNT)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_GETINCOUNT)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_PERCMODE)
-COMPATIBLE_IOCTL(SNDCTL_FM_LOAD_INSTR)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_TESTMIDI)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_RESETSAMPLES)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_NRSYNTHS)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_NRMIDIS)
-COMPATIBLE_IOCTL(SNDCTL_MIDI_INFO)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_THRESHOLD)
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_MEMAVL)
-COMPATIBLE_IOCTL(SNDCTL_FM_4OP_ENABLE)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_PANIC)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_OUTOFBAND)
-COMPATIBLE_IOCTL(SNDCTL_SEQ_GETTIME)
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_ID)
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_CONTROL)
-COMPATIBLE_IOCTL(SNDCTL_SYNTH_REMOVESAMPLE)
-/* Big T for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_TMR_TIMEBASE)
-COMPATIBLE_IOCTL(SNDCTL_TMR_START)
-COMPATIBLE_IOCTL(SNDCTL_TMR_STOP)
-COMPATIBLE_IOCTL(SNDCTL_TMR_CONTINUE)
-COMPATIBLE_IOCTL(SNDCTL_TMR_TEMPO)
-COMPATIBLE_IOCTL(SNDCTL_TMR_SOURCE)
-COMPATIBLE_IOCTL(SNDCTL_TMR_METRONOME)
-COMPATIBLE_IOCTL(SNDCTL_TMR_SELECT)
-/* Little m for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_MIDI_PRETIME)
-COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUMODE)
-COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUCMD)
-/* Big P for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_DSP_RESET)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SYNC)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SPEED)
-COMPATIBLE_IOCTL(SNDCTL_DSP_STEREO)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETBLKSIZE)
-COMPATIBLE_IOCTL(SNDCTL_DSP_CHANNELS)
-COMPATIBLE_IOCTL(SOUND_PCM_WRITE_FILTER)
-COMPATIBLE_IOCTL(SNDCTL_DSP_POST)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SUBDIVIDE)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETFRAGMENT)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETFMTS)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETFMT)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETOSPACE)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETISPACE)
-COMPATIBLE_IOCTL(SNDCTL_DSP_NONBLOCK)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETCAPS)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETTRIGGER)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETTRIGGER)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETIPTR)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETOPTR)
-/* SNDCTL_DSP_MAPINBUF,  XXX needs translation */
-/* SNDCTL_DSP_MAPOUTBUF,  XXX needs translation */
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETSYNCRO)
-COMPATIBLE_IOCTL(SNDCTL_DSP_SETDUPLEX)
-COMPATIBLE_IOCTL(SNDCTL_DSP_GETODELAY)
-COMPATIBLE_IOCTL(SNDCTL_DSP_PROFILE)
-COMPATIBLE_IOCTL(SOUND_PCM_READ_RATE)
-COMPATIBLE_IOCTL(SOUND_PCM_READ_CHANNELS)
-COMPATIBLE_IOCTL(SOUND_PCM_READ_BITS)
-COMPATIBLE_IOCTL(SOUND_PCM_READ_FILTER)
-/* Big C for sound/OSS */
-COMPATIBLE_IOCTL(SNDCTL_COPR_RESET)
-COMPATIBLE_IOCTL(SNDCTL_COPR_LOAD)
-COMPATIBLE_IOCTL(SNDCTL_COPR_RDATA)
-COMPATIBLE_IOCTL(SNDCTL_COPR_RCODE)
-COMPATIBLE_IOCTL(SNDCTL_COPR_WDATA)
-COMPATIBLE_IOCTL(SNDCTL_COPR_WCODE)
-COMPATIBLE_IOCTL(SNDCTL_COPR_RUN)
-COMPATIBLE_IOCTL(SNDCTL_COPR_HALT)
-COMPATIBLE_IOCTL(SNDCTL_COPR_SENDMSG)
-COMPATIBLE_IOCTL(SNDCTL_COPR_RCVMSG)
-/* Big M for sound/OSS */
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_VOLUME)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_BASS)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_TREBLE)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_SYNTH)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_PCM)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_SPEAKER)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_MIC)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_CD)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_IMIX)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_ALTPCM)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECLEV)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_IGAIN)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_OGAIN)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE1)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE2)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE3)
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL1))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL2))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL3))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEIN))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEOUT))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_VIDEO))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_RADIO))
-COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_MONITOR))
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_MUTE)
-/* SOUND_MIXER_READ_ENHANCE,  same value as READ_MUTE */
-/* SOUND_MIXER_READ_LOUD,  same value as READ_MUTE */
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECSRC)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_DEVMASK)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECMASK)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_STEREODEVS)
-COMPATIBLE_IOCTL(SOUND_MIXER_READ_CAPS)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_VOLUME)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_BASS)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_TREBLE)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SYNTH)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_PCM)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SPEAKER)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MIC)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_CD)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IMIX)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_ALTPCM)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECLEV)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IGAIN)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_OGAIN)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE1)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE2)
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE3)
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL1))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL2))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL3))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEIN))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEOUT))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_VIDEO))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_RADIO))
-COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_MONITOR))
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MUTE)
-/* SOUND_MIXER_WRITE_ENHANCE,  same value as WRITE_MUTE */
-/* SOUND_MIXER_WRITE_LOUD,  same value as WRITE_MUTE */
-COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECSRC)
-COMPATIBLE_IOCTL(SOUND_MIXER_INFO)
-COMPATIBLE_IOCTL(SOUND_OLD_MIXER_INFO)
-COMPATIBLE_IOCTL(SOUND_MIXER_ACCESS)
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE1)
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE2)
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE3)
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE4)
-COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
-COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
-COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
-COMPATIBLE_IOCTL(OSS_GETVERSION)
-/* AUTOFS */
-COMPATIBLE_IOCTL(AUTOFS_IOC_READY)
-COMPATIBLE_IOCTL(AUTOFS_IOC_FAIL)
-COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC)
-COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER)
-COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE)
-COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE_MULTI)
-/* DEVFS */
-COMPATIBLE_IOCTL(DEVFSDIOC_GET_PROTO_REV)
-COMPATIBLE_IOCTL(DEVFSDIOC_SET_EVENT_MASK)
-COMPATIBLE_IOCTL(DEVFSDIOC_RELEASE_EVENT_QUEUE)
-COMPATIBLE_IOCTL(DEVFSDIOC_SET_DEBUG_MASK)
-/* SMB ioctls which do not need any translations */
-COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
-/* Little a */
-COMPATIBLE_IOCTL(ATMSIGD_CTRL)
-COMPATIBLE_IOCTL(ATMARPD_CTRL)
-COMPATIBLE_IOCTL(ATMLEC_CTRL)
-COMPATIBLE_IOCTL(ATMLEC_MCAST)
-COMPATIBLE_IOCTL(ATMLEC_DATA)
-COMPATIBLE_IOCTL(ATM_SETSC)
-COMPATIBLE_IOCTL(SIOCSIFATMTCP)
-COMPATIBLE_IOCTL(SIOCMKCLIP)
-COMPATIBLE_IOCTL(ATMARP_MKIP)
-COMPATIBLE_IOCTL(ATMARP_SETENTRY)
-COMPATIBLE_IOCTL(ATMARP_ENCAP)
-COMPATIBLE_IOCTL(ATMTCP_CREATE)
-COMPATIBLE_IOCTL(ATMTCP_REMOVE)
-COMPATIBLE_IOCTL(ATMMPC_CTRL)
-COMPATIBLE_IOCTL(ATMMPC_DATA)
-#if defined(CONFIG_BLK_DEV_LVM) || defined(CONFIG_BLK_DEV_LVM_MODULE)
-/* 0xfe - lvm */
-COMPATIBLE_IOCTL(VG_SET_EXTENDABLE)
-COMPATIBLE_IOCTL(VG_STATUS_GET_COUNT)
-COMPATIBLE_IOCTL(VG_STATUS_GET_NAMELIST)
-COMPATIBLE_IOCTL(VG_REMOVE)
-COMPATIBLE_IOCTL(VG_RENAME)
-COMPATIBLE_IOCTL(VG_REDUCE)
-COMPATIBLE_IOCTL(PE_LOCK_UNLOCK)
-COMPATIBLE_IOCTL(PV_FLUSH)
-COMPATIBLE_IOCTL(LVM_LOCK_LVM)
-COMPATIBLE_IOCTL(LVM_GET_IOP_VERSION)
-#ifdef LVM_TOTAL_RESET
-COMPATIBLE_IOCTL(LVM_RESET)
-#endif
-COMPATIBLE_IOCTL(LV_SET_ACCESS)
-COMPATIBLE_IOCTL(LV_SET_STATUS)
-COMPATIBLE_IOCTL(LV_SET_ALLOCATION)
-COMPATIBLE_IOCTL(LE_REMAP)
-COMPATIBLE_IOCTL(LV_BMAP)
-COMPATIBLE_IOCTL(LV_SNAPSHOT_USE_RATE)
-#endif /* LVM */
+COMPATIBLE_IOCTL(0x4B50)   /* KDGHWCLK - not in the kernel, but don't complain */
+COMPATIBLE_IOCTL(0x4B51)   /* KDSHWCLK - not in the kernel, but don't complain */
 #ifdef CONFIG_AUTOFS_FS
 COMPATIBLE_IOCTL(AUTOFS_IOC_READY)
 COMPATIBLE_IOCTL(AUTOFS_IOC_FAIL)
@@ -4149,6 +3158,7 @@
 COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER)
 COMPATIBLE_IOCTL(AUTOFS_IOC_SETTIMEOUT)
 COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE)
+COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE_MULTI)
 #endif
 #ifdef CONFIG_RTC
 COMPATIBLE_IOCTL(RTC_AIE_ON)
@@ -4166,44 +3176,6 @@
 COMPATIBLE_IOCTL(RTC_WKALM_SET)
 COMPATIBLE_IOCTL(RTC_WKALM_RD)
 #endif
-/* Big W */
-/* WIOC_GETSUPPORT not yet implemented -E */
-COMPATIBLE_IOCTL(WDIOC_GETSTATUS)
-COMPATIBLE_IOCTL(WDIOC_GETBOOTSTATUS)
-COMPATIBLE_IOCTL(WDIOC_GETTEMP)
-COMPATIBLE_IOCTL(WDIOC_SETOPTIONS)
-COMPATIBLE_IOCTL(WDIOC_KEEPALIVE)
-#if 0 /* sparc only ? */
-COMPATIBLE_IOCTL(WIOCSTART)
-COMPATIBLE_IOCTL(WIOCSTOP)
-COMPATIBLE_IOCTL(WIOCGSTAT)
-#endif
-/* Big R */
-COMPATIBLE_IOCTL(RNDGETENTCNT)
-COMPATIBLE_IOCTL(RNDADDTOENTCNT)
-COMPATIBLE_IOCTL(RNDGETPOOL)
-COMPATIBLE_IOCTL(RNDADDENTROPY)
-COMPATIBLE_IOCTL(RNDZAPENTCNT)
-COMPATIBLE_IOCTL(RNDCLEARPOOL)
-/* Bluetooth ioctls */
-COMPATIBLE_IOCTL(HCIDEVUP)
-COMPATIBLE_IOCTL(HCIDEVDOWN)
-COMPATIBLE_IOCTL(HCIDEVRESET)
-COMPATIBLE_IOCTL(HCIDEVRESTAT)
-COMPATIBLE_IOCTL(HCIGETDEVLIST)
-COMPATIBLE_IOCTL(HCIGETDEVINFO)
-COMPATIBLE_IOCTL(HCIGETCONNLIST)
-COMPATIBLE_IOCTL(HCIGETCONNINFO)
-COMPATIBLE_IOCTL(HCISETRAW)
-COMPATIBLE_IOCTL(HCISETSCAN)
-COMPATIBLE_IOCTL(HCISETAUTH)
-COMPATIBLE_IOCTL(HCISETENCRYPT)
-COMPATIBLE_IOCTL(HCISETPTYPE)
-COMPATIBLE_IOCTL(HCISETLINKPOL)
-COMPATIBLE_IOCTL(HCISETLINKMODE)
-COMPATIBLE_IOCTL(HCISETACLMTU)
-COMPATIBLE_IOCTL(HCISETSCOMTU)
-COMPATIBLE_IOCTL(HCIINQUIRY)
 COMPATIBLE_IOCTL(HCIUARTSETPROTO)
 COMPATIBLE_IOCTL(HCIUARTGETPROTO)
 COMPATIBLE_IOCTL(RFCOMMCREATEDEV)
@@ -4215,44 +3187,7 @@
 COMPATIBLE_IOCTL(BNEPCONNDEL)
 COMPATIBLE_IOCTL(BNEPGETCONNLIST)
 COMPATIBLE_IOCTL(BNEPGETCONNINFO)
-/* Misc. */
-COMPATIBLE_IOCTL(0x41545900)		/* ATYIO_CLKR */
-COMPATIBLE_IOCTL(0x41545901)		/* ATYIO_CLKW */
-COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
-COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
-COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM)
-COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE)
-COMPATIBLE_IOCTL(0x4B50);   /* KDGHWCLK - not in the kernel, but don't complain */
-COMPATIBLE_IOCTL(0x4B51);   /* KDSHWCLK - not in the kernel, but don't complain */
-/* USB */
-COMPATIBLE_IOCTL(USBDEVFS_RESETEP)
-COMPATIBLE_IOCTL(USBDEVFS_SETINTERFACE)
-COMPATIBLE_IOCTL(USBDEVFS_SETCONFIGURATION)
-COMPATIBLE_IOCTL(USBDEVFS_GETDRIVER)
-COMPATIBLE_IOCTL(USBDEVFS_DISCARDURB)
-COMPATIBLE_IOCTL(USBDEVFS_CLAIMINTERFACE)
-COMPATIBLE_IOCTL(USBDEVFS_RELEASEINTERFACE)
-COMPATIBLE_IOCTL(USBDEVFS_CONNECTINFO)
-COMPATIBLE_IOCTL(USBDEVFS_HUB_PORTINFO)
-COMPATIBLE_IOCTL(USBDEVFS_RESET)
-COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
-/* MTD */
-COMPATIBLE_IOCTL(MEMGETINFO)
-COMPATIBLE_IOCTL(MEMERASE)
-COMPATIBLE_IOCTL(MEMLOCK)
-COMPATIBLE_IOCTL(MEMUNLOCK)
-COMPATIBLE_IOCTL(MEMGETREGIONCOUNT)
-COMPATIBLE_IOCTL(MEMGETREGIONINFO)
-/* NBD */
-COMPATIBLE_IOCTL(NBD_SET_SOCK)
-COMPATIBLE_IOCTL(NBD_SET_BLKSIZE)
-COMPATIBLE_IOCTL(NBD_SET_SIZE)
-COMPATIBLE_IOCTL(NBD_DO_IT)
-COMPATIBLE_IOCTL(NBD_CLEAR_SOCK)
-COMPATIBLE_IOCTL(NBD_CLEAR_QUE)
-COMPATIBLE_IOCTL(NBD_PRINT_DEBUG)
-COMPATIBLE_IOCTL(NBD_SET_SIZE_BLOCKS)
-COMPATIBLE_IOCTL(NBD_DISCONNECT)
+
 /* And these ioctls need translation */
 HANDLE_IOCTL(TIOCGDEV, tiocgdev)
 HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl)
@@ -4446,218 +3381,4 @@
 HANDLE_IOCTL(MTRRIOC32_GET_PAGE_ENTRY, mtrr_ioctl32)
 HANDLE_IOCTL(MTRRIOC32_KILL_PAGE_ENTRY, mtrr_ioctl32)
 IOCTL_TABLE_END
-
-#define IOCTL_HASHSIZE 256
-struct ioctl_trans *ioctl32_hash_table[IOCTL_HASHSIZE];
-
-extern struct ioctl_trans ioctl_start[], ioctl_end[]; 
-
-extern struct ioctl_trans ioctl_start[], ioctl_end[]; 
-
-static inline unsigned long ioctl32_hash(unsigned long cmd)
-{
-	return (((cmd >> 6) ^ (cmd >> 4) ^ cmd)) % IOCTL_HASHSIZE;
-}
-
-static void ioctl32_insert_translation(struct ioctl_trans *trans)
-{
-	unsigned long hash;
-	struct ioctl_trans *t;
-
-	hash = ioctl32_hash (trans->cmd);
-	if (!ioctl32_hash_table[hash])
-		ioctl32_hash_table[hash] = trans;
-	else {
-		t = ioctl32_hash_table[hash];
-		while (t->next)
-			t = t->next;
-		trans->next = 0;
-		t->next = trans;
-	}
-}
-
-static int __init init_sys32_ioctl(void)
-{
-	int i;
-
-	for (i = 0; &ioctl_start[i] < &ioctl_end[0]; i++) {
-		if (ioctl_start[i].next != 0) { 
-			printk("ioctl translation %d bad\n",i); 
-			return -1;
-		}
-
-		ioctl32_insert_translation(&ioctl_start[i]);
-	}
-	return 0;
-}
-
-__initcall(init_sys32_ioctl);
-
-static struct ioctl_trans *ioctl_free_list;
-
-/* Never free them really. This avoids SMP races. With a Read-Copy-Update
-   enabled kernel we could just use the RCU infrastructure for this. */
-static void free_ioctl(struct ioctl_trans *t) 
-{ 
-	t->cmd = 0; 
-	mb();
-	t->next = ioctl_free_list;
-	ioctl_free_list = t;
-} 
-
-int register_ioctl32_conversion(unsigned int cmd, int (*handler)(unsigned int, unsigned int, unsigned long, struct file *))
-{
-	struct ioctl_trans *t;
-	unsigned long hash = ioctl32_hash(cmd);
-
-	lock_kernel(); 
-	for (t = (struct ioctl_trans *)ioctl32_hash_table[hash];
-	     t;
-	     t = t->next) { 
-		if (t->cmd == cmd) {
-			printk("Trying to register duplicated ioctl32 handler %x\n", cmd);
-			unlock_kernel();
-			return -EINVAL; 
-	}
-	} 
-
-	if (ioctl_free_list) { 
-		t = ioctl_free_list; 
-		ioctl_free_list = t->next; 
-	} else { 
-		t = kmalloc(sizeof(struct ioctl_trans), GFP_KERNEL); 
-		if (!t) { 
-			unlock_kernel();
-		return -ENOMEM;
-		}
-	}
-	
-	t->next = NULL;
-	t->cmd = cmd;
-	t->handler = handler; 
-	ioctl32_insert_translation(t);
-
-	unlock_kernel();
-	return 0;
-}
-
-static inline int builtin_ioctl(struct ioctl_trans *t)
-{ 
-	return t >= (struct ioctl_trans *)ioctl_start &&
-	       t < (struct ioctl_trans *)ioctl_end; 
-} 
-
-/* Problem: 
-   This function cannot unregister duplicate ioctls, because they are not
-   unique.
-   When they happen we need to extend the prototype to pass the handler too. */
-
-int unregister_ioctl32_conversion(unsigned int cmd)
-{
-	unsigned long hash = ioctl32_hash(cmd);
-	struct ioctl_trans *t, *t1;
-
-	lock_kernel(); 
-
-	t = (struct ioctl_trans *)ioctl32_hash_table[hash];
-	if (!t) { 
-		unlock_kernel();
-		return -EINVAL;
-	} 
-
-	if (t->cmd == cmd) { 
-		if (builtin_ioctl(t)) {
-			printk("%p tried to unregister builtin ioctl %x\n",
-			       __builtin_return_address(0), cmd);
-		} else { 
-		ioctl32_hash_table[hash] = t->next;
-			free_ioctl(t); 
-			unlock_kernel();
-		return 0;
-		}
-	} 
-	while (t->next) {
-		t1 = (struct ioctl_trans *)(long)t->next;
-		if (t1->cmd == cmd) { 
-			if (builtin_ioctl(t1)) {
-				printk("%p tried to unregister builtin ioctl %x\n",
-				       __builtin_return_address(0), cmd);
-				goto out;
-			} else { 
-			t->next = t1->next;
-				free_ioctl(t1); 
-				unlock_kernel();
-			return 0;
-		}
-		}
-		t = t1;
-	}
-	printk(KERN_ERR "Trying to free unknown 32bit ioctl handler %x\n", cmd);
- out:
-	unlock_kernel();
-	return -EINVAL;
-}
-
-EXPORT_SYMBOL(register_ioctl32_conversion); 
-EXPORT_SYMBOL(unregister_ioctl32_conversion); 
-
-asmlinkage long sys32_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
-	struct file * filp;
-	int error = -EBADF;
-	int (*handler)(unsigned int, unsigned int, unsigned long, struct file * filp);
-	struct ioctl_trans *t;
-
-	filp = fget(fd);
-	if(!filp)
-		goto out2;
-
-	if (!filp->f_op || !filp->f_op->ioctl) {
-		error = sys_ioctl (fd, cmd, arg);
-		goto out;
-	}
-
-	t = (struct ioctl_trans *)ioctl32_hash_table [ioctl32_hash (cmd)];
-
-	while (t && t->cmd != cmd)
-		t = (struct ioctl_trans *)t->next;
-	if (t) {
-		handler = t->handler;
-		error = handler(fd, cmd, arg, filp);
-	} else if (cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) {
-		error = siocdevprivate_ioctl(fd, cmd, arg);
-	} else {
-		static int count;
-		if (++count <= 50) { 
-			char buf[10];
-			char *path = (char *)__get_free_page(GFP_KERNEL), *fn = "?"; 
-
-			/* find the name of the device. */
-			if (path) {
-				struct file *f = fget(fd); 
-				if (f) {
-					fn = d_path(f->f_dentry, f->f_vfsmnt, 
-						    path, PAGE_SIZE);
-					fput(f);
-				}
-			}
-
-			sprintf(buf,"'%c'", (cmd>>24) & 0x3f); 
-			if (!isprint(buf[1]))
-			    sprintf(buf, "%02x", buf[1]);
-			printk("ioctl32(%s:%d): Unknown cmd fd(%d) "
-			       "cmd(%08x){%s} arg(%08x) on %s\n",
-			       current->comm, current->pid,
-			       (int)fd, (unsigned int)cmd, buf, (unsigned int)arg,
-			       fn);
-			if (path) 
-				free_page((unsigned long)path); 
-		}
-		error = -EINVAL;
-	}
-out:
-	fput(filp);
-out2:
-	return error;
-}
 
diff -Nru a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S
--- a/arch/x86_64/ia32/ia32entry.S	Wed Apr 30 22:28:08 2003
+++ b/arch/x86_64/ia32/ia32entry.S	Wed Apr 30 22:28:08 2003
@@ -258,7 +258,7 @@
 	.quad sys_acct
 	.quad sys_umount			/* new_umount */
 	.quad ni_syscall			/* old lock syscall holder */
-	.quad sys32_ioctl
+	.quad compat_sys_ioctl
 	.quad compat_sys_fcntl64		/* 55 */
 	.quad ni_syscall			/* old mpx syscall holder */
 	.quad sys_setpgid
diff -Nru a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c
--- a/arch/x86_64/ia32/sys_ia32.c	Wed Apr 30 22:28:08 2003
+++ b/arch/x86_64/ia32/sys_ia32.c	Wed Apr 30 22:28:08 2003
@@ -855,28 +855,14 @@
 	return i;
 }
 
-asmlinkage long
-sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr, int options)
-{
-	return compat_sys_wait4(pid, stat_addr, options, NULL);
-}
-
-
 extern asmlinkage long
-sys_getrusage(int who, struct rusage *ru);
+compat_sys_wait4(compat_pid_t pid, compat_uint_t * stat_addr, int options,
+		 struct compat_rusage *ru);
 
 asmlinkage long
-sys32_getrusage(int who, struct rusage32 *ru)
+sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr, int options)
 {
-	struct rusage r;
-	int ret;
-	mm_segment_t old_fs = get_fs();
-		
-	set_fs (KERNEL_DS);
-	ret = sys_getrusage(who, &r);
-	set_fs (old_fs);
-	if (put_rusage (ru, &r)) return -EFAULT;
-	return ret;
+	return compat_sys_wait4(pid, stat_addr, options, NULL);
 }
 
 int sys32_ni_syscall(int call)
@@ -1708,7 +1694,6 @@
 #define ca32_export	u.u32_export
 #define ca32_getfd	u.u32_getfd
 #define ca32_getfs	u.u32_getfs
-#define ca32_authd	u.u32_authd
 };
 
 union nfsctl_res32 {
diff -Nru a/arch/x86_64/kernel/irq.c b/arch/x86_64/kernel/irq.c
--- a/arch/x86_64/kernel/irq.c	Wed Apr 30 22:28:08 2003
+++ b/arch/x86_64/kernel/irq.c	Wed Apr 30 22:28:08 2003
@@ -74,7 +74,7 @@
  * Special irq handlers.
  */
 
-void no_action(int cpl, void *dev_id, struct pt_regs *regs) { }
+irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs) { return IRQ_NONE; }
 
 /*
  * Generic no controller code
@@ -433,7 +433,7 @@
  */
  
 int request_irq(unsigned int irq, 
-		void (*handler)(int, void *, struct pt_regs *),
+		irqreturn_t (*handler)(int, void *, struct pt_regs *),
 		unsigned long irqflags, 
 		const char * devname,
 		void *dev_id)
diff -Nru a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
--- a/arch/x86_64/kernel/setup.c	Wed Apr 30 22:28:04 2003
+++ b/arch/x86_64/kernel/setup.c	Wed Apr 30 22:28:04 2003
@@ -28,9 +28,7 @@
 #include <linux/delay.h>
 #include <linux/config.h>
 #include <linux/init.h>
-#ifdef CONFIG_BLK_DEV_RAM
-#include <linux/blk.h>
-#endif
+#include <linux/initrd.h>
 #include <linux/highmem.h>
 #include <linux/bootmem.h>
 #include <asm/processor.h>
diff -Nru a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
--- a/arch/x86_64/kernel/time.c	Wed Apr 30 22:28:12 2003
+++ b/arch/x86_64/kernel/time.c	Wed Apr 30 22:28:12 2003
@@ -195,7 +195,7 @@
 	spin_unlock(&rtc_lock);
 }
 
-static void timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	static unsigned long rtc_update = 0;
 
@@ -255,6 +255,8 @@
 	}
  
 	write_sequnlock(&xtime_lock);
+
+	return IRQ_HANDLED;
 }
 
 unsigned long get_cmos_time(void)
diff -Nru a/drivers/acorn/block/fd1772.c b/drivers/acorn/block/fd1772.c
--- a/drivers/acorn/block/fd1772.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/acorn/block/fd1772.c	Wed Apr 30 22:28:07 2003
@@ -1474,9 +1474,6 @@
 
 	fd_device[drive] = type;
 
-	if (old_dev && old_dev != type)
-		invalidate_buffers(mk_kdev(MAJOR_NR, drive + (old_dev<<2)));
-
 	if (filp->f_flags & O_NDELAY)
 		return 0;
 
diff -Nru a/drivers/acpi/dispatcher/dsfield.c b/drivers/acpi/dispatcher/dsfield.c
--- a/drivers/acpi/dispatcher/dsfield.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/acpi/dispatcher/dsfield.c	Wed Apr 30 22:28:11 2003
@@ -249,9 +249,9 @@
 			 * In field_flags, preserve the flag bits other than the ACCESS_TYPE bits
 			 */
 			info->field_flags = (u8) ((info->field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
-					  ((u8) (arg->common.value.integer32 >> 8)));
+					  ((u8) ((u32) arg->common.value.integer >> 8)));
 
-			info->attribute = (u8) (arg->common.value.integer32);
+			info->attribute = (u8) (arg->common.value.integer);
 			break;
 
 
@@ -356,7 +356,7 @@
 	/* Second arg is the field flags */
 
 	arg = arg->common.next;
-	info.field_flags = arg->common.value.integer8;
+	info.field_flags = (u8) arg->common.value.integer;
 	info.attribute = 0;
 
 	/* Each remaining arg is a Named Field */
@@ -509,12 +509,12 @@
 	/* Third arg is the bank_value */
 
 	arg = arg->common.next;
-	info.bank_value = arg->common.value.integer32;
+	info.bank_value = (u32) arg->common.value.integer;
 
 	/* Fourth arg is the field flags */
 
 	arg = arg->common.next;
-	info.field_flags = arg->common.value.integer8;
+	info.field_flags = (u8) arg->common.value.integer;
 
 	/* Each remaining arg is a Named Field */
 
@@ -580,7 +580,7 @@
 	/* Next arg is the field flags */
 
 	arg = arg->common.next;
-	info.field_flags = arg->common.value.integer8;
+	info.field_flags = (u8) arg->common.value.integer;
 
 	/* Each remaining arg is a Named Field */
 
diff -Nru a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c
--- a/drivers/acpi/dispatcher/dsmthdat.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/acpi/dispatcher/dsmthdat.c	Wed Apr 30 22:28:07 2003
@@ -87,8 +87,8 @@
 	/* Init the method arguments */
 
 	for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) {
-		ACPI_MOVE_UNALIGNED32_TO_32 (&walk_state->arguments[i].name,
-				 NAMEOF_ARG_NTE);
+		ACPI_MOVE_32_TO_32 (&walk_state->arguments[i].name,
+				   NAMEOF_ARG_NTE);
 		walk_state->arguments[i].name.integer |= (i << 24);
 		walk_state->arguments[i].descriptor   = ACPI_DESC_TYPE_NAMED;
 		walk_state->arguments[i].type         = ACPI_TYPE_ANY;
@@ -98,8 +98,8 @@
 	/* Init the method locals */
 
 	for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) {
-		ACPI_MOVE_UNALIGNED32_TO_32 (&walk_state->local_variables[i].name,
-				 NAMEOF_LOCAL_NTE);
+		ACPI_MOVE_32_TO_32 (&walk_state->local_variables[i].name,
+				   NAMEOF_LOCAL_NTE);
 
 		walk_state->local_variables[i].name.integer |= (i << 24);
 		walk_state->local_variables[i].descriptor  = ACPI_DESC_TYPE_NAMED;
diff -Nru a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/dispatcher/dsobject.c
--- a/drivers/acpi/dispatcher/dsobject.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/acpi/dispatcher/dsobject.c	Wed Apr 30 22:28:03 2003
@@ -187,7 +187,7 @@
 			return (AE_TYPE);
 		}
 
-		byte_list_length = byte_list->common.value.integer32;
+		byte_list_length = (u32) byte_list->common.value.integer;
 	}
 
 	/*
diff -Nru a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/dispatcher/dswexec.c
--- a/drivers/acpi/dispatcher/dswexec.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/acpi/dispatcher/dswexec.c	Wed Apr 30 22:28:18 2003
@@ -647,7 +647,7 @@
 		acpi_ds_delete_result_if_not_used (op, walk_state->result_obj, walk_state);
 	}
 
-#if _UNDER_DEVELOPMENT
+#ifdef _UNDER_DEVELOPMENT
 
 	if (walk_state->parser_state.aml == walk_state->parser_state.aml_end) {
 		acpi_db_method_end (walk_state);
diff -Nru a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c
--- a/drivers/acpi/events/evgpe.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/acpi/events/evgpe.c	Wed Apr 30 22:28:10 2003
@@ -76,7 +76,7 @@
 	acpi_native_uint                i;
 
 
-	ACPI_FUNCTION_NAME ("ev_get_gpe_event_info");
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/* A NULL gpe_block means use the FADT-defined GPE block(s) */
diff -Nru a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c
--- a/drivers/acpi/events/evgpeblk.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/acpi/events/evgpeblk.c	Wed Apr 30 22:28:10 2003
@@ -71,7 +71,7 @@
 	struct acpi_gpe_block_info      *gpe_block;
 
 
-	ACPI_FUNCTION_NAME ("ev_valid_gpe_event");
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/* No need for spin lock since we are not changing any list elements */
@@ -81,7 +81,7 @@
 		gpe_block = gpe_xrupt_block->gpe_block_list_head;
 		while (gpe_block) {
 			if ((&gpe_block->event_info[0] <= gpe_event_info) &&
-				(&gpe_block->event_info[gpe_block->register_count * 8] > gpe_event_info)) {
+				(&gpe_block->event_info[((acpi_size) gpe_block->register_count) * 8] > gpe_event_info)) {
 				return (TRUE);
 			}
 
@@ -186,13 +186,13 @@
 	acpi_status                     status;
 
 
-	ACPI_FUNCTION_NAME ("ev_save_method_info");
+	ACPI_FUNCTION_TRACE ("ev_save_method_info");
 
 
 	/* Extract the name from the object and convert to a string */
 
-	ACPI_MOVE_UNALIGNED32_TO_32 (name,
-			 &((struct acpi_namespace_node *) obj_handle)->name.integer);
+	ACPI_MOVE_32_TO_32 (name,
+			   &((struct acpi_namespace_node *) obj_handle)->name.integer);
 	name[ACPI_NAME_SIZE] = 0;
 
 	/*
@@ -213,7 +213,7 @@
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 			"Unknown GPE method type: %s (name not of form _Lnn or _Enn)\n",
 			name));
-		return (AE_OK);
+		return_ACPI_STATUS (AE_OK);
 	}
 
 	/* Convert the last two characters of the name to the GPE Number */
@@ -225,7 +225,7 @@
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 			"Could not extract GPE number from name: %s (name is not of form _Lnn or _Enn)\n",
 			name));
-		return (AE_OK);
+		return_ACPI_STATUS (AE_OK);
 	}
 
 	/* Ensure that we have a valid GPE number for this GPE block */
@@ -237,7 +237,7 @@
 		 * However, it may be valid for a different GPE block, since GPE0 and GPE1
 		 * methods both appear under \_GPE.
 		 */
-		return (AE_OK);
+		return_ACPI_STATUS (AE_OK);
 	}
 
 	/*
@@ -254,13 +254,13 @@
 	 */
 	status = acpi_hw_enable_gpe (gpe_event_info);
 	if (ACPI_FAILURE (status)) {
-		return (status);
+		return_ACPI_STATUS (status);
 	}
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 		"Registered GPE method %s as GPE number 0x%.2X\n",
 		name, gpe_number));
-	return (AE_OK);
+	return_ACPI_STATUS (AE_OK);
 }
 
 
@@ -279,7 +279,7 @@
  *
  ******************************************************************************/
 
-struct acpi_gpe_xrupt_info *
+static struct acpi_gpe_xrupt_info *
 acpi_ev_get_gpe_xrupt_block (
 	u32                             interrupt_level)
 {
@@ -288,12 +288,15 @@
 	acpi_status                     status;
 
 
+	ACPI_FUNCTION_TRACE ("ev_get_gpe_xrupt_block");
+
+
 	/* No need for spin lock since we are not changing any list elements here */
 
 	next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head;
 	while (next_gpe_xrupt) {
 		if (next_gpe_xrupt->interrupt_level == interrupt_level) {
-			return (next_gpe_xrupt);
+			return_PTR (next_gpe_xrupt);
 		}
 
 		next_gpe_xrupt = next_gpe_xrupt->next;
@@ -303,7 +306,7 @@
 
 	gpe_xrupt = ACPI_MEM_CALLOCATE (sizeof (struct acpi_gpe_xrupt_info));
 	if (!gpe_xrupt) {
-		return (NULL);
+		return_PTR (NULL);
 	}
 
 	gpe_xrupt->interrupt_level = interrupt_level;
@@ -330,9 +333,15 @@
 	if (interrupt_level != acpi_gbl_FADT->sci_int) {
 		status = acpi_os_install_interrupt_handler (interrupt_level,
 				 acpi_ev_gpe_xrupt_handler, gpe_xrupt);
+		if (ACPI_FAILURE (status)) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"Could not install GPE interrupt handler at level 0x%X\n",
+				interrupt_level));
+			return_PTR (NULL);
+		}
 	}
 
-	return (gpe_xrupt);
+	return_PTR (gpe_xrupt);
 }
 
 
@@ -349,7 +358,7 @@
  *
  ******************************************************************************/
 
-acpi_status
+static acpi_status
 acpi_ev_delete_gpe_xrupt (
 	struct acpi_gpe_xrupt_info      *gpe_xrupt)
 {
@@ -406,7 +415,7 @@
  *
  ******************************************************************************/
 
-acpi_status
+static acpi_status
 acpi_ev_install_gpe_block (
 	struct acpi_gpe_block_info      *gpe_block,
 	u32                             interrupt_level)
@@ -535,7 +544,7 @@
  *
  ******************************************************************************/
 
-acpi_status
+static acpi_status
 acpi_ev_create_gpe_info_blocks (
 	struct acpi_gpe_block_info      *gpe_block)
 {
diff -Nru a/drivers/acpi/events/evregion.c b/drivers/acpi/events/evregion.c
--- a/drivers/acpi/events/evregion.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/acpi/events/evregion.c	Wed Apr 30 22:28:11 2003
@@ -315,9 +315,10 @@
 	handler = handler_desc->addr_handler.handler;
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
-		"Addrhandler %p (%p), Address %8.8X%8.8X\n",
+		"Handler %p (@%p) Address %8.8X%8.8X [%s]\n",
 		&region_obj->region.addr_handler->addr_handler, handler,
-		ACPI_HIDWORD (address), ACPI_LODWORD (address)));
+		ACPI_HIDWORD (address), ACPI_LODWORD (address),
+		acpi_ut_get_region_name (region_obj->region.space_id)));
 
 	if (!(handler_desc->addr_handler.flags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
 		/*
diff -Nru a/drivers/acpi/events/evxfregn.c b/drivers/acpi/events/evxfregn.c
--- a/drivers/acpi/events/evxfregn.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/acpi/events/evxfregn.c	Wed Apr 30 22:28:05 2003
@@ -159,16 +159,14 @@
 		}
 	}
 
-	/*
-	 * If the caller hasn't specified a setup routine, use the default
-	 */
+	/* If the caller hasn't specified a setup routine, use the default */
+
 	if (!setup) {
 		setup = acpi_ev_default_region_setup;
 	}
 
-	/*
-	 * Check for an existing internal object
-	 */
+	/* Check for an existing internal object */
+
 	obj_desc = acpi_ns_get_attached_object (node);
 	if (obj_desc) {
 		/*
@@ -181,7 +179,7 @@
 		handler_obj = obj_desc->device.addr_handler;
 		while (handler_obj) {
 			/*
-			 * We have an Address handler, see if user requested this
+			 * Found an Address handler, see if user requested this
 			 * address space.
 			 */
 			if(handler_obj->addr_handler.space_id == space_id) {
@@ -189,9 +187,8 @@
 				goto unlock_and_exit;
 			}
 
-			/*
-			 * Move through the linked list of handlers
-			 */
+			/* Walk the linked list of handlers */
+
 			handler_obj = handler_obj->addr_handler.next;
 		}
 	}
@@ -232,10 +229,10 @@
 		acpi_ut_get_region_name (space_id), space_id, node->name.ascii, node, obj_desc));
 
 	/*
-	 * Now we can install the handler
+	 * Install the handler
 	 *
-	 * At this point we know that there is no existing handler.
-	 * So, we just allocate the object for the handler and link it
+	 * At this point there is no existing handler.
+	 * Just allocate the object for the handler and link it
 	 * into the list.
 	 */
 	handler_obj = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_ADDRESS_HANDLER);
@@ -254,15 +251,15 @@
 	handler_obj->addr_handler.setup     = setup;
 
 	/*
-	 * Now walk the namespace finding all of the regions this
+	 * Walk the namespace finding all of the regions this
 	 * handler will manage.
 	 *
-	 * We start at the device and search the branch toward
+	 * Start at the device and search the branch toward
 	 * the leaf nodes until either the leaf is encountered or
 	 * a device is detected that has an address handler of the
 	 * same type.
 	 *
-	 * In either case we back up and search down the remainder
+	 * In either case, back up and search down the remainder
 	 * of the branch
 	 */
 	status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, device,
@@ -270,9 +267,8 @@
 			 acpi_ev_addr_handler_helper,
 			 handler_obj, NULL);
 
-	/*
-	 * Place this handler 1st on the list
-	 */
+	/* Place this handler 1st on the list */
+
 	handler_obj->common.reference_count =
 			 (u16) (handler_obj->common.reference_count +
 			 obj_desc->common.reference_count - 1);
@@ -289,12 +285,13 @@
  *
  * FUNCTION:    acpi_remove_address_space_handler
  *
- * PARAMETERS:  space_id        - The address space ID
+ * PARAMETERS:  Device          - Handle for the device
+ *              space_id        - The address space ID
  *              Handler         - Address of the handler
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Install a handler for accesses on an Operation Region
+ * DESCRIPTION: Remove a previously installed handler.
  *
  ******************************************************************************/
 
@@ -342,19 +339,16 @@
 		goto unlock_and_exit;
 	}
 
-	/*
-	 * find the address handler the user requested
-	 */
+	/* Find the address handler the user requested */
+
 	handler_obj = obj_desc->device.addr_handler;
 	last_obj_ptr = &obj_desc->device.addr_handler;
 	while (handler_obj) {
-		/*
-		 * We have a handler, see if user requested this one
-		 */
+		/* We have a handler, see if user requested this one */
+
 		if (handler_obj->addr_handler.space_id == space_id) {
-			/*
-			 * Got it, first dereference this in the Regions
-			 */
+			/* Matched space_id, first dereference this in the Regions */
+
 			ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
 				"Removing address handler %p(%p) for region %s on Device %p(%p)\n",
 				handler_obj, handler, acpi_ut_get_region_name (space_id),
@@ -375,45 +369,36 @@
 				acpi_ev_detach_region (region_obj, TRUE);
 
 				/*
-				 * Walk the list, since we took the first region and it
-				 * was removed from the list by the dissassociate call
-				 * we just get the first item on the list again
+				 * Walk the list: Just grab the head because the
+				 * detach_region removed the previous head.
 				 */
 				region_obj = handler_obj->addr_handler.region_list;
 
 			}
 
-			/*
-			 * Remove this Handler object from the list
-			 */
+			/* Remove this Handler object from the list */
+
 			*last_obj_ptr = handler_obj->addr_handler.next;
 
-			/*
-			 * Now we can delete the handler object
-			 */
-			acpi_ut_remove_reference (handler_obj);
-			acpi_ut_remove_reference (handler_obj);
+			/* Now we can delete the handler object */
 
+			acpi_ut_remove_reference (handler_obj);
 			goto unlock_and_exit;
 		}
 
-		/*
-		 * Move through the linked list of handlers
-		 */
+		/* Walk the linked list of handlers */
+
 		last_obj_ptr = &handler_obj->addr_handler.next;
 		handler_obj = handler_obj->addr_handler.next;
 	}
 
+	/* The handler does not exist */
 
-	/*
-	 * The handler does not exist
-	 */
 	ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
 		"Unable to remove address handler %p for %s(%X), dev_node %p, obj %p\n",
 		handler, acpi_ut_get_region_name (space_id), space_id, node, obj_desc));
 
 	status = AE_NOT_EXIST;
-
 
 unlock_and_exit:
 	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
diff -Nru a/drivers/acpi/executer/exfldio.c b/drivers/acpi/executer/exfldio.c
--- a/drivers/acpi/executer/exfldio.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/acpi/executer/exfldio.c	Wed Apr 30 22:28:07 2003
@@ -568,9 +568,10 @@
  *
  * PARAMETERS:  Datum               - Where the Datum is returned
  *              Buffer              - Raw field buffer
+ *              buffer_length       - Entire length (used for big-endian only)
  *              byte_granularity    - 1/2/4/8 Granularity of the field
  *                                    (aka Datum Size)
- *              Offset              - Datum offset into the buffer
+ *              buffer_offset       - Datum offset into the buffer
  *
  * RETURN:      none
  *
@@ -580,35 +581,44 @@
  ******************************************************************************/
 
 void
-acpi_ex_get_buffer_datum(
+acpi_ex_get_buffer_datum (
 	acpi_integer                    *datum,
 	void                            *buffer,
+	u32                             buffer_length,
 	u32                             byte_granularity,
-	u32                             offset)
+	u32                             buffer_offset)
 {
+	u32                             index;
+
 
 	ACPI_FUNCTION_ENTRY ();
 
 
+	/* Get proper index into buffer (handles big/little endian) */
+
+	index = ACPI_BUFFER_INDEX (buffer_length, buffer_offset, byte_granularity);
+
+	/* Move the requested number of bytes */
+
 	switch (byte_granularity) {
 	case ACPI_FIELD_BYTE_GRANULARITY:
 
-		*datum = ((u8 *) buffer) [offset];
+		*datum = ((u8 *) buffer) [index];
 		break;
 
 	case ACPI_FIELD_WORD_GRANULARITY:
 
-		ACPI_MOVE_UNALIGNED16_TO_32 (datum, &(((u16 *) buffer) [offset]));
+		ACPI_MOVE_16_TO_64 (datum, &(((u16 *) buffer) [index]));
 		break;
 
 	case ACPI_FIELD_DWORD_GRANULARITY:
 
-		ACPI_MOVE_UNALIGNED32_TO_32 (datum, &(((u32 *) buffer) [offset]));
+		ACPI_MOVE_32_TO_64 (datum, &(((u32 *) buffer) [index]));
 		break;
 
 	case ACPI_FIELD_QWORD_GRANULARITY:
 
-		ACPI_MOVE_UNALIGNED64_TO_64 (datum, &(((u64 *) buffer) [offset]));
+		ACPI_MOVE_64_TO_64 (datum, &(((u64 *) buffer) [index]));
 		break;
 
 	default:
@@ -624,9 +634,10 @@
  *
  * PARAMETERS:  merged_datum        - Value to store
  *              Buffer              - Receiving buffer
+ *              buffer_length       - Entire length (used for big-endian only)
  *              byte_granularity    - 1/2/4/8 Granularity of the field
  *                                    (aka Datum Size)
- *              Offset              - Datum offset into the buffer
+ *              buffer_offset       - Datum offset into the buffer
  *
  * RETURN:      none
  *
@@ -639,32 +650,40 @@
 acpi_ex_set_buffer_datum (
 	acpi_integer                    merged_datum,
 	void                            *buffer,
+	u32                             buffer_length,
 	u32                             byte_granularity,
-	u32                             offset)
+	u32                             buffer_offset)
 {
+	u32                             index;
 
 	ACPI_FUNCTION_ENTRY ();
 
 
+	/* Get proper index into buffer (handles big/little endian) */
+
+	index = ACPI_BUFFER_INDEX (buffer_length, buffer_offset, byte_granularity);
+
+	/* Move the requested number of bytes */
+
 	switch (byte_granularity) {
 	case ACPI_FIELD_BYTE_GRANULARITY:
 
-		((u8 *) buffer) [offset] = (u8) merged_datum;
+		((u8 *) buffer) [index] = (u8) merged_datum;
 		break;
 
 	case ACPI_FIELD_WORD_GRANULARITY:
 
-		ACPI_MOVE_UNALIGNED16_TO_16 (&(((u16 *) buffer)[offset]), &merged_datum);
+		ACPI_MOVE_64_TO_16 (&(((u16 *) buffer)[index]), &merged_datum);
 		break;
 
 	case ACPI_FIELD_DWORD_GRANULARITY:
 
-		ACPI_MOVE_UNALIGNED32_TO_32 (&(((u32 *) buffer)[offset]), &merged_datum);
+		ACPI_MOVE_64_TO_32 (&(((u32 *) buffer)[index]), &merged_datum);
 		break;
 
 	case ACPI_FIELD_QWORD_GRANULARITY:
 
-		ACPI_MOVE_UNALIGNED64_TO_64 (&(((u64 *) buffer)[offset]), &merged_datum);
+		ACPI_MOVE_64_TO_64 (&(((u64 *) buffer)[index]), &merged_datum);
 		break;
 
 	default:
@@ -762,8 +781,8 @@
 
 		/* Store the datum to the caller buffer */
 
-		acpi_ex_set_buffer_datum (merged_datum, buffer, obj_desc->common_field.access_byte_width,
-				datum_offset);
+		acpi_ex_set_buffer_datum (merged_datum, buffer, buffer_length,
+				obj_desc->common_field.access_byte_width, datum_offset);
 
 		return_ACPI_STATUS (AE_OK);
 	}
@@ -835,7 +854,7 @@
 		 * Store the merged field datum in the caller's buffer, according to
 		 * the granularity of the field (size of each datum).
 		 */
-		acpi_ex_set_buffer_datum (merged_datum, buffer,
+		acpi_ex_set_buffer_datum (merged_datum, buffer, buffer_length,
 				obj_desc->common_field.access_byte_width, datum_offset);
 
 		/*
@@ -916,7 +935,7 @@
 
 	/* Get a single datum from the caller's buffer */
 
-	acpi_ex_get_buffer_datum (&previous_raw_datum, buffer,
+	acpi_ex_get_buffer_datum (&previous_raw_datum, buffer, buffer_length,
 			obj_desc->common_field.access_byte_width, datum_offset);
 
 	/*
@@ -979,7 +998,7 @@
 		 * Get the next raw buffer datum.  It may contain bits of the previous
 		 * field datum
 		 */
-		acpi_ex_get_buffer_datum (&this_raw_datum, buffer,
+		acpi_ex_get_buffer_datum (&this_raw_datum, buffer, buffer_length,
 				obj_desc->common_field.access_byte_width, datum_offset);
 
 		/* Create the field datum based on the field alignment */
diff -Nru a/drivers/acpi/executer/exregion.c b/drivers/acpi/executer/exregion.c
--- a/drivers/acpi/executer/exregion.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/acpi/executer/exregion.c	Wed Apr 30 22:28:05 2003
@@ -83,7 +83,7 @@
 	struct acpi_mem_space_context   *mem_info = region_context;
 	u32                             length;
 	acpi_size                       window_size;
-#ifndef _HW_ALIGNMENT_SUPPORT
+#ifndef ACPI_MISALIGNED_TRANSFERS
 	u32                             remainder;
 #endif
 
@@ -116,7 +116,7 @@
 	}
 
 
-#ifndef _HW_ALIGNMENT_SUPPORT
+#ifndef ACPI_MISALIGNED_TRANSFERS
 	/*
 	 * Hardware does not support non-aligned data transfers, we must verify
 	 * the request.
@@ -283,6 +283,7 @@
 	void                            *region_context)
 {
 	acpi_status                     status = AE_OK;
+	u32                             value32;
 
 
 	ACPI_FUNCTION_TRACE ("ex_system_io_space_handler");
@@ -297,13 +298,13 @@
 	switch (function) {
 	case ACPI_READ:
 
-		*value = 0;
-		status = acpi_os_read_port ((acpi_io_address) address, value, bit_width);
+		status = acpi_os_read_port ((acpi_io_address) address, &value32, bit_width);
+		*value = value32;
 		break;
 
 	case ACPI_WRITE:
 
-		status = acpi_os_write_port ((acpi_io_address) address, *value, bit_width);
+		status = acpi_os_write_port ((acpi_io_address) address, (u32) *value, bit_width);
 		break;
 
 	default:
diff -Nru a/drivers/acpi/hardware/hwacpi.c b/drivers/acpi/hardware/hwacpi.c
--- a/drivers/acpi/hardware/hwacpi.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/acpi/hardware/hwacpi.c	Wed Apr 30 22:28:03 2003
@@ -141,7 +141,7 @@
 		/* BIOS should have disabled ALL fixed and GP events */
 
 		status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd,
-				  (acpi_integer) acpi_gbl_FADT->acpi_enable, 8);
+				  (u32) acpi_gbl_FADT->acpi_enable, 8);
 		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n"));
 		break;
 
@@ -152,7 +152,7 @@
 		 * enable bits to default
 		 */
 		status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd,
-				 (acpi_integer) acpi_gbl_FADT->acpi_disable, 8);
+				 (u32) acpi_gbl_FADT->acpi_disable, 8);
 		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
 				 "Attempting to enable Legacy (non-ACPI) mode\n"));
 		break;
diff -Nru a/drivers/acpi/hardware/hwgpe.c b/drivers/acpi/hardware/hwgpe.c
--- a/drivers/acpi/hardware/hwgpe.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/acpi/hardware/hwgpe.c	Wed Apr 30 22:28:03 2003
@@ -424,7 +424,7 @@
  *
  ******************************************************************************/
 
-acpi_status
+static acpi_status
 acpi_hw_disable_non_wakeup_gpe_block (
 	struct acpi_gpe_xrupt_info      *gpe_xrupt_info,
 	struct acpi_gpe_block_info      *gpe_block)
@@ -515,7 +515,7 @@
  *
  ******************************************************************************/
 
-acpi_status
+static acpi_status
 acpi_hw_enable_non_wakeup_gpe_block (
 	struct acpi_gpe_xrupt_info      *gpe_xrupt_info,
 	struct acpi_gpe_block_info      *gpe_block)
diff -Nru a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c
--- a/drivers/acpi/hardware/hwregs.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/acpi/hardware/hwregs.c	Wed Apr 30 22:28:15 2003
@@ -654,7 +654,7 @@
 
 		/* SMI_CMD is currently always in IO space */
 
-		status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, (acpi_integer) value, 8);
+		status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, value, 8);
 		break;
 
 
@@ -812,7 +812,7 @@
 		mem_address = (reg->address
 				  + (acpi_physical_address) offset);
 
-		status = acpi_os_write_memory (mem_address, (acpi_integer) value, width);
+		status = acpi_os_write_memory (mem_address, value, width);
 		break;
 
 
@@ -821,7 +821,7 @@
 		io_address = (acpi_io_address) (reg->address
 				   + (acpi_physical_address) offset);
 
-		status = acpi_os_write_port (io_address, (acpi_integer) value, width);
+		status = acpi_os_write_port (io_address, value, width);
 		break;
 
 
diff -Nru a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c
--- a/drivers/acpi/hardware/hwsleep.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/acpi/hardware/hwsleep.c	Wed Apr 30 22:28:04 2003
@@ -226,7 +226,7 @@
 
 	/* Clear wake status */
 
-	status = acpi_set_register (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_LOCK);
+	status = acpi_set_register (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK);
 	if (ACPI_FAILURE (status)) {
 		return_ACPI_STATUS (status);
 	}
@@ -238,7 +238,7 @@
 
 	/* Disable BM arbitration */
 
-	status = acpi_set_register (ACPI_BITREG_ARB_DISABLE, 1, ACPI_MTX_LOCK);
+	status = acpi_set_register (ACPI_BITREG_ARB_DISABLE, 1, ACPI_MTX_DO_NOT_LOCK);
 	if (ACPI_FAILURE (status)) {
 		return_ACPI_STATUS (status);
 	}
@@ -327,11 +327,6 @@
 
 	} while (!in_value);
 
-	status = acpi_set_register (ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_DO_NOT_LOCK);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
-
 	return_ACPI_STATUS (AE_OK);
 }
 
@@ -366,7 +361,7 @@
 
 	ACPI_FLUSH_CPU_CACHE();
 
-	status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, (acpi_integer) acpi_gbl_FADT->S4bios_req, 8);
+	status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, (u32) acpi_gbl_FADT->S4bios_req, 8);
 
 	do {
 		acpi_os_stall(1000);
diff -Nru a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c
--- a/drivers/acpi/namespace/nsaccess.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/acpi/namespace/nsaccess.c	Wed Apr 30 22:28:18 2003
@@ -527,7 +527,7 @@
 
 		/* Extract one ACPI name from the front of the pathname */
 
-		ACPI_MOVE_UNALIGNED32_TO_32 (&simple_name, path);
+		ACPI_MOVE_32_TO_32 (&simple_name, path);
 
 		/* Try to find the single (4 character) ACPI name */
 
diff -Nru a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c
--- a/drivers/acpi/namespace/nsnames.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/acpi/namespace/nsnames.c	Wed Apr 30 22:28:20 2003
@@ -98,7 +98,7 @@
 
 		/* Put the name into the buffer */
 
-		ACPI_MOVE_UNALIGNED32_TO_32 ((name_buffer + index), &parent_node->name);
+		ACPI_MOVE_32_TO_32 ((name_buffer + index), &parent_node->name);
 		parent_node = acpi_ns_get_parent_node (parent_node);
 
 		/* Prefix name with the path separator */
diff -Nru a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/namespace/nsutils.c
--- a/drivers/acpi/namespace/nsutils.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/acpi/namespace/nsutils.c	Wed Apr 30 22:28:09 2003
@@ -76,31 +76,38 @@
 	acpi_status                     lookup_status)
 {
 	acpi_status                     status;
-	char                            *name;
+	char                            *name = NULL;
 
 
-	/* Convert path to external format */
-
-	status = acpi_ns_externalize_name (ACPI_UINT32_MAX, internal_name, NULL, &name);
-
 	acpi_os_printf ("%8s-%04d: *** Error: Looking up ",
 		module_name, line_number);
 
-	/* Print target name */
+	if (lookup_status == AE_BAD_CHARACTER) {
+		/* There is a non-ascii character in the name */
 
-	if (ACPI_SUCCESS (status)) {
-		acpi_os_printf ("[%s]", name);
+		acpi_os_printf ("[0x%4.4X] (NON-ASCII)\n", *(ACPI_CAST_PTR (u32, internal_name)));
 	}
 	else {
-		acpi_os_printf ("[COULD NOT EXTERNALIZE NAME]");
+		/* Convert path to external format */
+
+		status = acpi_ns_externalize_name (ACPI_UINT32_MAX, internal_name, NULL, &name);
+
+		/* Print target name */
+
+		if (ACPI_SUCCESS (status)) {
+			acpi_os_printf ("[%s]", name);
+		}
+		else {
+			acpi_os_printf ("[COULD NOT EXTERNALIZE NAME]");
+		}
+
+		if (name) {
+			ACPI_MEM_FREE (name);
+		}
 	}
 
 	acpi_os_printf (" in namespace, %s\n",
 		acpi_format_exception (lookup_status));
-
-	if (name) {
-		ACPI_MEM_FREE (name);
-	}
 }
 
 
@@ -609,7 +616,7 @@
 			/* <count> 4-byte names */
 
 			names_index = prefix_length + 2;
-			num_segments = (u32) (u8) internal_name[(acpi_native_uint) (prefix_length + 1)];
+			num_segments = (acpi_native_uint) (u8) internal_name[(acpi_native_uint) (prefix_length + 1)];
 			break;
 
 		case AML_DUAL_NAME_PREFIX:
diff -Nru a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c
--- a/drivers/acpi/namespace/nsxfeval.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/acpi/namespace/nsxfeval.c	Wed Apr 30 22:28:19 2003
@@ -524,8 +524,8 @@
  *
  * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
  *              starting (and ending) at the object specified by start_handle.
- *              The user_function is called whenever an object that matches
- *              the type parameter is found.  If the user function returns
+ *              The user_function is called whenever an object of type
+ *              Device is found.  If the user function returns
  *              a non-zero value, the search is terminated immediately and this
  *              value is returned to the caller.
  *
diff -Nru a/drivers/acpi/osl.c b/drivers/acpi/osl.c
--- a/drivers/acpi/osl.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/acpi/osl.c	Wed Apr 30 22:28:15 2003
@@ -234,10 +234,10 @@
 	return AE_OK;
 }
 
-static void
+static irqreturn_t
 acpi_irq(int irq, void *dev_id, struct pt_regs *regs)
 {
-	(*acpi_irq_handler)(acpi_irq_context);
+	return (*acpi_irq_handler)(acpi_irq_context);
 }
 
 acpi_status
@@ -303,7 +303,7 @@
 acpi_status
 acpi_os_read_port(
 	acpi_io_address	port,
-	void		*value,
+	u32		*value,
 	u32		width)
 {
 	u32 dummy;
@@ -332,7 +332,7 @@
 acpi_status
 acpi_os_write_port(
 	acpi_io_address	port,
-	acpi_integer	value,
+	u32		value,
 	u32		width)
 {
 	switch (width)
@@ -356,7 +356,7 @@
 acpi_status
 acpi_os_read_memory(
 	acpi_physical_address	phys_addr,
-	void			*value,
+	u32			*value,
 	u32			width)
 {
 	u32			dummy;
@@ -402,7 +402,7 @@
 acpi_status
 acpi_os_write_memory(
 	acpi_physical_address	phys_addr,
-	acpi_integer		value,
+	u32			value,
 	u32			width)
 {
 	void			*virt_addr;
diff -Nru a/drivers/acpi/parser/psargs.c b/drivers/acpi/parser/psargs.c
--- a/drivers/acpi/parser/psargs.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/acpi/parser/psargs.c	Wed Apr 30 22:28:07 2003
@@ -412,7 +412,7 @@
 
 		/* Get 2 bytes from the AML stream */
 
-		ACPI_MOVE_UNALIGNED16_TO_32 (&arg->common.value.integer, parser_state->aml);
+		ACPI_MOVE_16_TO_32 (&arg->common.value.integer, parser_state->aml);
 		parser_state->aml += 2;
 		break;
 
@@ -423,7 +423,7 @@
 
 		/* Get 4 bytes from the AML stream */
 
-		ACPI_MOVE_UNALIGNED32_TO_32 (&arg->common.value.integer, parser_state->aml);
+		ACPI_MOVE_32_TO_32 (&arg->common.value.integer, parser_state->aml);
 		parser_state->aml += 4;
 		break;
 
@@ -434,7 +434,7 @@
 
 		/* Get 8 bytes from the AML stream */
 
-		ACPI_MOVE_UNALIGNED64_TO_64 (&arg->common.value.integer, parser_state->aml);
+		ACPI_MOVE_64_TO_64 (&arg->common.value.integer, parser_state->aml);
 		parser_state->aml += 8;
 		break;
 
@@ -533,7 +533,7 @@
 
 		/* Get the 4-character name */
 
-		ACPI_MOVE_UNALIGNED32_TO_32 (&name, parser_state->aml);
+		ACPI_MOVE_32_TO_32 (&name, parser_state->aml);
 		acpi_ps_set_name (field, name);
 		parser_state->aml += ACPI_NAME_SIZE;
 
@@ -557,9 +557,9 @@
 		 * Get access_type and access_attrib and merge into the field Op
 		 * access_type is first operand, access_attribute is second
 		 */
-		field->common.value.integer32 = (ACPI_GET8 (parser_state->aml) << 8);
+		field->common.value.integer = (ACPI_GET8 (parser_state->aml) << 8);
 		parser_state->aml++;
-		field->common.value.integer32 |= ACPI_GET8 (parser_state->aml);
+		field->common.value.integer |= ACPI_GET8 (parser_state->aml);
 		parser_state->aml++;
 		break;
 
diff -Nru a/drivers/acpi/resources/rsaddr.c b/drivers/acpi/resources/rsaddr.c
--- a/drivers/acpi/resources/rsaddr.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/acpi/resources/rsaddr.c	Wed Apr 30 22:28:10 2003
@@ -92,7 +92,7 @@
 	 * Point past the Descriptor to get the number of bytes consumed
 	 */
 	buffer += 1;
-	ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 	*bytes_consumed = temp16 + 3;
 	output_struct->id = ACPI_RSTYPE_ADDRESS16;
@@ -162,36 +162,31 @@
 	 * Get Granularity (Bytes 6-7)
 	 */
 	buffer += 1;
-	ACPI_MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.granularity,
-			 buffer);
+	ACPI_MOVE_16_TO_32 (&output_struct->data.address16.granularity, buffer);
 
 	/*
 	 * Get min_address_range (Bytes 8-9)
 	 */
 	buffer += 2;
-	ACPI_MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.min_address_range,
-			 buffer);
+	ACPI_MOVE_16_TO_32 (&output_struct->data.address16.min_address_range, buffer);
 
 	/*
 	 * Get max_address_range (Bytes 10-11)
 	 */
 	buffer += 2;
-	ACPI_MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.max_address_range,
-			 buffer);
+	ACPI_MOVE_16_TO_32 (&output_struct->data.address16.max_address_range, buffer);
 
 	/*
 	 * Get address_translation_offset (Bytes 12-13)
 	 */
 	buffer += 2;
-	ACPI_MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.address_translation_offset,
-			 buffer);
+	ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_translation_offset, buffer);
 
 	/*
 	 * Get address_length (Bytes 14-15)
 	 */
 	buffer += 2;
-	ACPI_MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.address_length,
-			 buffer);
+	ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_length, buffer);
 
 	/*
 	 * Resource Source Index (if present)
@@ -360,36 +355,31 @@
 	/*
 	 * Set the address space granularity
 	 */
-	ACPI_MOVE_UNALIGNED16_TO_16 (buffer,
-			   &linked_list->data.address16.granularity);
+	ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.granularity);
 	buffer += 2;
 
 	/*
 	 * Set the address range minimum
 	 */
-	ACPI_MOVE_UNALIGNED16_TO_16 (buffer,
-			   &linked_list->data.address16.min_address_range);
+	ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.min_address_range);
 	buffer += 2;
 
 	/*
 	 * Set the address range maximum
 	 */
-	ACPI_MOVE_UNALIGNED16_TO_16 (buffer,
-			   &linked_list->data.address16.max_address_range);
+	ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.max_address_range);
 	buffer += 2;
 
 	/*
 	 * Set the address translation offset
 	 */
-	ACPI_MOVE_UNALIGNED16_TO_16 (buffer,
-			   &linked_list->data.address16.address_translation_offset);
+	ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.address_translation_offset);
 	buffer += 2;
 
 	/*
 	 * Set the address length
 	 */
-	ACPI_MOVE_UNALIGNED16_TO_16 (buffer,
-			   &linked_list->data.address16.address_length);
+	ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.address_length);
 	buffer += 2;
 
 	/*
@@ -413,7 +403,7 @@
 		 * Buffer needs to be set to the length of the sting + one for the
 		 *  terminating null
 		 */
-		buffer += (ACPI_STRLEN (linked_list->data.address16.resource_source.string_ptr) + 1);
+		buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.address16.resource_source.string_ptr) + 1);
 	}
 
 	/*
@@ -427,7 +417,7 @@
 	 * minus the header size (3 bytes)
 	 */
 	actual_bytes -= 3;
-	ACPI_MOVE_UNALIGNED16_TO_16 (length_field, &actual_bytes);
+	ACPI_MOVE_SIZE_TO_16 (length_field, &actual_bytes);
 	return_ACPI_STATUS (AE_OK);
 }
 
@@ -479,7 +469,7 @@
 	 * Point past the Descriptor to get the number of bytes consumed
 	 */
 	buffer += 1;
-	ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 	*bytes_consumed = temp16 + 3;
 
 	output_struct->id = ACPI_RSTYPE_ADDRESS32;
@@ -553,36 +543,31 @@
 	 * Get Granularity (Bytes 6-9)
 	 */
 	buffer += 1;
-	ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.granularity,
-			 buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.address32.granularity, buffer);
 
 	/*
 	 * Get min_address_range (Bytes 10-13)
 	 */
 	buffer += 4;
-	ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.min_address_range,
-			 buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.address32.min_address_range, buffer);
 
 	/*
 	 * Get max_address_range (Bytes 14-17)
 	 */
 	buffer += 4;
-	ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.max_address_range,
-			 buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.address32.max_address_range, buffer);
 
 	/*
 	 * Get address_translation_offset (Bytes 18-21)
 	 */
 	buffer += 4;
-	ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.address_translation_offset,
-			 buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_translation_offset, buffer);
 
 	/*
 	 * Get address_length (Bytes 22-25)
 	 */
 	buffer += 4;
-	ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.address_length,
-			 buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_length, buffer);
 
 	/*
 	 * Resource Source Index (if present)
@@ -749,36 +734,31 @@
 	/*
 	 * Set the address space granularity
 	 */
-	ACPI_MOVE_UNALIGNED32_TO_32 (buffer,
-			  &linked_list->data.address32.granularity);
+	ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.granularity);
 	buffer += 4;
 
 	/*
 	 * Set the address range minimum
 	 */
-	ACPI_MOVE_UNALIGNED32_TO_32 (buffer,
-			  &linked_list->data.address32.min_address_range);
+	ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.min_address_range);
 	buffer += 4;
 
 	/*
 	 * Set the address range maximum
 	 */
-	ACPI_MOVE_UNALIGNED32_TO_32 (buffer,
-			  &linked_list->data.address32.max_address_range);
+	ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.max_address_range);
 	buffer += 4;
 
 	/*
 	 * Set the address translation offset
 	 */
-	ACPI_MOVE_UNALIGNED32_TO_32 (buffer,
-			  &linked_list->data.address32.address_translation_offset);
+	ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.address_translation_offset);
 	buffer += 4;
 
 	/*
 	 * Set the address length
 	 */
-	ACPI_MOVE_UNALIGNED32_TO_32 (buffer,
-			  &linked_list->data.address32.address_length);
+	ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.address_length);
 	buffer += 4;
 
 	/*
@@ -802,7 +782,7 @@
 		 * Buffer needs to be set to the length of the sting + one for the
 		 *  terminating null
 		 */
-		buffer += (ACPI_STRLEN (linked_list->data.address32.resource_source.string_ptr) + 1);
+		buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.address32.resource_source.string_ptr) + 1);
 	}
 
 	/*
@@ -866,7 +846,7 @@
 	 * Point past the Descriptor to get the number of bytes consumed
 	 */
 	buffer += 1;
-	ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 	*bytes_consumed = temp16 + 3;
 	output_struct->id = ACPI_RSTYPE_ADDRESS64;
@@ -941,36 +921,31 @@
 	 * Get Granularity (Bytes 6-13)
 	 */
 	buffer += 1;
-	ACPI_MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.granularity,
-			 buffer);
+	ACPI_MOVE_64_TO_64 (&output_struct->data.address64.granularity, buffer);
 
 	/*
 	 * Get min_address_range (Bytes 14-21)
 	 */
 	buffer += 8;
-	ACPI_MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.min_address_range,
-			 buffer);
+	ACPI_MOVE_64_TO_64 (&output_struct->data.address64.min_address_range, buffer);
 
 	/*
 	 * Get max_address_range (Bytes 22-29)
 	 */
 	buffer += 8;
-	ACPI_MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.max_address_range,
-			 buffer);
+	ACPI_MOVE_64_TO_64 (&output_struct->data.address64.max_address_range, buffer);
 
 	/*
 	 * Get address_translation_offset (Bytes 30-37)
 	 */
 	buffer += 8;
-	ACPI_MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.address_translation_offset,
-			 buffer);
+	ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_translation_offset, buffer);
 
 	/*
 	 * Get address_length (Bytes 38-45)
 	 */
 	buffer += 8;
-	ACPI_MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.address_length,
-			 buffer);
+	ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_length, buffer);
 
 	/*
 	 * Resource Source Index (if present)
@@ -1141,36 +1116,31 @@
 	/*
 	 * Set the address space granularity
 	 */
-	ACPI_MOVE_UNALIGNED64_TO_64 (buffer,
-			   &linked_list->data.address64.granularity);
+	ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.granularity);
 	buffer += 8;
 
 	/*
 	 * Set the address range minimum
 	 */
-	ACPI_MOVE_UNALIGNED64_TO_64 (buffer,
-			   &linked_list->data.address64.min_address_range);
+	ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.min_address_range);
 	buffer += 8;
 
 	/*
 	 * Set the address range maximum
 	 */
-	ACPI_MOVE_UNALIGNED64_TO_64 (buffer,
-			   &linked_list->data.address64.max_address_range);
+	ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.max_address_range);
 	buffer += 8;
 
 	/*
 	 * Set the address translation offset
 	 */
-	ACPI_MOVE_UNALIGNED64_TO_64 (buffer,
-			   &linked_list->data.address64.address_translation_offset);
+	ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.address_translation_offset);
 	buffer += 8;
 
 	/*
 	 * Set the address length
 	 */
-	ACPI_MOVE_UNALIGNED64_TO_64 (buffer,
-			   &linked_list->data.address64.address_length);
+	ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.address_length);
 	buffer += 8;
 
 	/*
@@ -1193,7 +1163,7 @@
 		 * Buffer needs to be set to the length of the sting + one for the
 		 *  terminating null
 		 */
-		buffer += (ACPI_STRLEN (linked_list->data.address64.resource_source.string_ptr) + 1);
+		buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.address64.resource_source.string_ptr) + 1);
 	}
 
 	/*
diff -Nru a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c
--- a/drivers/acpi/resources/rscalc.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/acpi/resources/rscalc.c	Wed Apr 30 22:28:10 2003
@@ -349,7 +349,7 @@
 			buffer = byte_stream_buffer;
 			++buffer;
 
-			ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+			ACPI_MOVE_16_TO_16 (&temp16, buffer);
 			bytes_consumed = temp16 + 3;
 
 			/*
@@ -390,7 +390,7 @@
 			buffer = byte_stream_buffer;
 
 			++buffer;
-			ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+			ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 			bytes_consumed = temp16 + 3;
 
@@ -428,7 +428,7 @@
 			buffer = byte_stream_buffer;
 
 			++buffer;
-			ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+			ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 			bytes_consumed = temp16 + 3;
 
@@ -466,7 +466,7 @@
 			buffer = byte_stream_buffer;
 
 			++buffer;
-			ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+			ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 			bytes_consumed = temp16 + 3;
 
@@ -504,7 +504,7 @@
 			buffer = byte_stream_buffer;
 
 			++buffer;
-			ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+			ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 			bytes_consumed = temp16 + 3;
 
@@ -573,7 +573,7 @@
 			/*
 			 * Look at the number of bits set
 			 */
-			ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+			ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 			for (index = 0; index < 16; index++) {
 				if (temp16 & 0x1) {
diff -Nru a/drivers/acpi/resources/rsio.c b/drivers/acpi/resources/rsio.c
--- a/drivers/acpi/resources/rsio.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/acpi/resources/rsio.c	Wed Apr 30 22:28:03 2003
@@ -106,7 +106,7 @@
 	 * Check min_base Address
 	 */
 	buffer += 1;
-	ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 	output_struct->data.io.min_base_address = temp16;
 
@@ -114,7 +114,7 @@
 	 * Check max_base Address
 	 */
 	buffer += 2;
-	ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 	output_struct->data.io.max_base_address = temp16;
 
@@ -196,7 +196,7 @@
 	 * Check Range Base Address
 	 */
 	buffer += 1;
-	ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 	output_struct->data.fixed_io.base_address = temp16;
 
@@ -270,7 +270,7 @@
 	 */
 	temp16 = (u16) linked_list->data.io.min_base_address;
 
-	ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+	ACPI_MOVE_16_TO_16 (buffer, &temp16);
 	buffer += 2;
 
 	/*
@@ -278,7 +278,7 @@
 	 */
 	temp16 = (u16) linked_list->data.io.max_base_address;
 
-	ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+	ACPI_MOVE_16_TO_16 (buffer, &temp16);
 	buffer += 2;
 
 	/*
@@ -347,7 +347,7 @@
 	 */
 	temp16 = (u16) linked_list->data.fixed_io.base_address;
 
-	ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+	ACPI_MOVE_16_TO_16 (buffer, &temp16);
 	buffer += 2;
 
 	/*
diff -Nru a/drivers/acpi/resources/rsirq.c b/drivers/acpi/resources/rsirq.c
--- a/drivers/acpi/resources/rsirq.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/acpi/resources/rsirq.c	Wed Apr 30 22:28:19 2003
@@ -101,7 +101,7 @@
 	 * Point to the 16-bits of Bytes 1 and 2
 	 */
 	buffer += 1;
-	ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 	output_struct->data.irq.number_of_interrupts = 0;
 
@@ -242,7 +242,7 @@
 		temp16 |= 0x1 << temp8;
 	}
 
-	ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+	ACPI_MOVE_16_TO_16 (buffer, &temp16);
 	buffer += 2;
 
 	/*
@@ -317,7 +317,7 @@
 	 * Point past the Descriptor to get the number of bytes consumed
 	 */
 	buffer += 1;
-	ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 	*bytes_consumed = temp16 + 3;
 	output_struct->id = ACPI_RSTYPE_EXT_IRQ;
@@ -374,7 +374,7 @@
 	 * Cycle through every IRQ in the table
 	 */
 	for (index = 0; index < temp8; index++) {
-		ACPI_MOVE_UNALIGNED32_TO_32 (
+		ACPI_MOVE_32_TO_32 (
 			&output_struct->data.extended_irq.interrupts[index], buffer);
 
 		/* Point to the next IRQ */
@@ -533,7 +533,7 @@
 
 	for (index = 0; index < linked_list->data.extended_irq.number_of_interrupts;
 		 index++) {
-		ACPI_MOVE_UNALIGNED32_TO_32 (buffer,
+		ACPI_MOVE_32_TO_32 (buffer,
 				  &linked_list->data.extended_irq.interrupts[index]);
 		buffer += 4;
 	}
@@ -557,7 +557,7 @@
 		 * Buffer needs to be set to the length of the sting + one for the
 		 * terminating null
 		 */
-		buffer += (ACPI_STRLEN (linked_list->data.extended_irq.resource_source.string_ptr) + 1);
+		buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.extended_irq.resource_source.string_ptr) + 1);
 	}
 
 	/*
diff -Nru a/drivers/acpi/resources/rsmemory.c b/drivers/acpi/resources/rsmemory.c
--- a/drivers/acpi/resources/rsmemory.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/acpi/resources/rsmemory.c	Wed Apr 30 22:28:15 2003
@@ -92,7 +92,7 @@
 	 */
 	buffer += 1;
 
-	ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 	buffer += 2;
 	*bytes_consumed = (acpi_size) temp16 + 3;
 	output_struct->id = ACPI_RSTYPE_MEM24;
@@ -107,28 +107,28 @@
 	/*
 	 * Get min_base_address (Bytes 4-5)
 	 */
-	ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 	buffer += 2;
 	output_struct->data.memory24.min_base_address = temp16;
 
 	/*
 	 * Get max_base_address (Bytes 6-7)
 	 */
-	ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 	buffer += 2;
 	output_struct->data.memory24.max_base_address = temp16;
 
 	/*
 	 * Get Alignment (Bytes 8-9)
 	 */
-	ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 	buffer += 2;
 	output_struct->data.memory24.alignment = temp16;
 
 	/*
 	 * Get range_length (Bytes 10-11)
 	 */
-	ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 	output_struct->data.memory24.range_length = temp16;
 
 	/*
@@ -184,7 +184,7 @@
 	 * The length field is static
 	 */
 	temp16 = 0x09;
-	ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+	ACPI_MOVE_16_TO_16 (buffer, &temp16);
 	buffer += 2;
 
 	/*
@@ -197,25 +197,25 @@
 	/*
 	 * Set the Range minimum base address
 	 */
-	ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.min_base_address);
+	ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.min_base_address);
 	buffer += 2;
 
 	/*
 	 * Set the Range maximum base address
 	 */
-	ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.max_base_address);
+	ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.max_base_address);
 	buffer += 2;
 
 	/*
 	 * Set the base alignment
 	 */
-	ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.alignment);
+	ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.alignment);
 	buffer += 2;
 
 	/*
 	 * Set the range length
 	 */
-	ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.range_length);
+	ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.range_length);
 	buffer += 2;
 
 	/*
@@ -269,7 +269,7 @@
 	 */
 	buffer += 1;
 
-	ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 	buffer += 2;
 	*bytes_consumed = (acpi_size) temp16 + 3;
 
@@ -296,27 +296,25 @@
 	/*
 	 * Get min_base_address (Bytes 4-7)
 	 */
-	ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.min_base_address,
-			 buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.min_base_address, buffer);
 	buffer += 4;
 
 	/*
 	 * Get max_base_address (Bytes 8-11)
 	 */
-	ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.max_base_address,
-			 buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.max_base_address, buffer);
 	buffer += 4;
 
 	/*
 	 * Get Alignment (Bytes 12-15)
 	 */
-	ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.alignment, buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.alignment, buffer);
 	buffer += 4;
 
 	/*
 	 * Get range_length (Bytes 16-19)
 	 */
-	ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.range_length, buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.range_length, buffer);
 
 	/*
 	 * Set the Length parameter
@@ -373,7 +371,7 @@
 	 * Point past the Descriptor to get the number of bytes consumed
 	 */
 	buffer += 1;
-	ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 	buffer += 2;
 	*bytes_consumed = (acpi_size) temp16 + 3;
@@ -390,15 +388,13 @@
 	/*
 	 * Get range_base_address (Bytes 4-7)
 	 */
-	ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.fixed_memory32.range_base_address,
-			 buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_base_address, buffer);
 	buffer += 4;
 
 	/*
 	 * Get range_length (Bytes 8-11)
 	 */
-	ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.fixed_memory32.range_length,
-			 buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_length, buffer);
 
 	/*
 	 * Set the Length parameter
@@ -454,7 +450,7 @@
 	 */
 	temp16 = 0x11;
 
-	ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+	ACPI_MOVE_16_TO_16 (buffer, &temp16);
 	buffer += 2;
 
 	/*
@@ -467,25 +463,25 @@
 	/*
 	 * Set the Range minimum base address
 	 */
-	ACPI_MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.min_base_address);
+	ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.min_base_address);
 	buffer += 4;
 
 	/*
 	 * Set the Range maximum base address
 	 */
-	ACPI_MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.max_base_address);
+	ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.max_base_address);
 	buffer += 4;
 
 	/*
 	 * Set the base alignment
 	 */
-	ACPI_MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.alignment);
+	ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.alignment);
 	buffer += 4;
 
 	/*
 	 * Set the range length
 	 */
-	ACPI_MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.range_length);
+	ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.range_length);
 	buffer += 4;
 
 	/*
@@ -537,7 +533,7 @@
 	 */
 	temp16 = 0x09;
 
-	ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+	ACPI_MOVE_16_TO_16 (buffer, &temp16);
 	buffer += 2;
 
 	/*
@@ -550,14 +546,14 @@
 	/*
 	 * Set the Range base address
 	 */
-	ACPI_MOVE_UNALIGNED32_TO_32 (buffer,
+	ACPI_MOVE_32_TO_32 (buffer,
 			 &linked_list->data.fixed_memory32.range_base_address);
 	buffer += 4;
 
 	/*
 	 * Set the range length
 	 */
-	ACPI_MOVE_UNALIGNED32_TO_32 (buffer,
+	ACPI_MOVE_32_TO_32 (buffer,
 			 &linked_list->data.fixed_memory32.range_length);
 	buffer += 4;
 
diff -Nru a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c
--- a/drivers/acpi/resources/rsmisc.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/acpi/resources/rsmisc.c	Wed Apr 30 22:28:06 2003
@@ -211,7 +211,7 @@
 
 		/* Dereference */
 
-		ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+		ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 		/* Calculate bytes consumed */
 
@@ -307,7 +307,7 @@
 
 		temp16 = (u16) linked_list->data.vendor_specific.length;
 
-		ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+		ACPI_MOVE_16_TO_16 (buffer, &temp16);
 		buffer += 2;
 	}
 	else {
diff -Nru a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c
--- a/drivers/acpi/resources/rsxface.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/acpi/resources/rsxface.c	Wed Apr 30 22:28:12 2003
@@ -339,20 +339,20 @@
 }
 
 
-#define COPY_FIELD(out, in, field)  out->field = in->field
-#define COPY_ADDRESS(out, in)                      \
-	COPY_FIELD(out, in, resource_type);             \
-	COPY_FIELD(out, in, producer_consumer);         \
-	COPY_FIELD(out, in, decode);                    \
-	COPY_FIELD(out, in, min_address_fixed);         \
-	COPY_FIELD(out, in, max_address_fixed);         \
-	COPY_FIELD(out, in, attribute);                 \
-	COPY_FIELD(out, in, granularity);               \
-	COPY_FIELD(out, in, min_address_range);         \
-	COPY_FIELD(out, in, max_address_range);         \
-	COPY_FIELD(out, in, address_translation_offset); \
-	COPY_FIELD(out, in, address_length);            \
-	COPY_FIELD(out, in, resource_source);
+#define ACPI_COPY_FIELD(out, in, field)  ((out)->field = (in)->field)
+#define ACPI_COPY_ADDRESS(out, in)                      \
+	ACPI_COPY_FIELD(out, in, resource_type);             \
+	ACPI_COPY_FIELD(out, in, producer_consumer);         \
+	ACPI_COPY_FIELD(out, in, decode);                    \
+	ACPI_COPY_FIELD(out, in, min_address_fixed);         \
+	ACPI_COPY_FIELD(out, in, max_address_fixed);         \
+	ACPI_COPY_FIELD(out, in, attribute);                 \
+	ACPI_COPY_FIELD(out, in, granularity);               \
+	ACPI_COPY_FIELD(out, in, min_address_range);         \
+	ACPI_COPY_FIELD(out, in, max_address_range);         \
+	ACPI_COPY_FIELD(out, in, address_translation_offset); \
+	ACPI_COPY_FIELD(out, in, address_length);            \
+	ACPI_COPY_FIELD(out, in, resource_source);
 
 /******************************************************************************
  *
@@ -385,17 +385,17 @@
 	switch (resource->id) {
 	case ACPI_RSTYPE_ADDRESS16:
 		address16 = (struct acpi_resource_address16 *) &resource->data;
-		COPY_ADDRESS(out, address16);
+		ACPI_COPY_ADDRESS(out, address16);
 		break;
 
 	case ACPI_RSTYPE_ADDRESS32:
 		address32 = (struct acpi_resource_address32 *) &resource->data;
-		COPY_ADDRESS(out, address32);
+		ACPI_COPY_ADDRESS(out, address32);
 		break;
 
 	case ACPI_RSTYPE_ADDRESS64:
 		address64 = (struct acpi_resource_address64 *) &resource->data;
-		COPY_ADDRESS(out, address64);
+		ACPI_COPY_ADDRESS(out, address64);
 		break;
 
 	default:
diff -Nru a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c
--- a/drivers/acpi/tables/tbutils.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/acpi/tables/tbutils.c	Wed Apr 30 22:28:15 2003
@@ -133,7 +133,7 @@
 
 	/* Ensure that the signature is 4 ASCII characters */
 
-	ACPI_MOVE_UNALIGNED32_TO_32 (&signature, table_header->signature);
+	ACPI_MOVE_32_TO_32 (&signature, table_header->signature);
 	if (!acpi_ut_valid_acpi_name (signature)) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 			"Table signature at %p [%p] has invalid characters\n",
diff -Nru a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c
--- a/drivers/acpi/utilities/utdebug.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/acpi/utilities/utdebug.c	Wed Apr 30 22:28:11 2003
@@ -559,8 +559,7 @@
 
 			case DB_WORD_DISPLAY:
 
-				ACPI_MOVE_UNALIGNED16_TO_32 (&temp32,
-						   &buffer[i + j]);
+				ACPI_MOVE_16_TO_32 (&temp32, &buffer[i + j]);
 				acpi_os_printf ("%04X ", temp32);
 				j += 2;
 				break;
@@ -568,8 +567,7 @@
 
 			case DB_DWORD_DISPLAY:
 
-				ACPI_MOVE_UNALIGNED32_TO_32 (&temp32,
-						   &buffer[i + j]);
+				ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]);
 				acpi_os_printf ("%08X ", temp32);
 				j += 4;
 				break;
@@ -577,12 +575,10 @@
 
 			case DB_QWORD_DISPLAY:
 
-				ACPI_MOVE_UNALIGNED32_TO_32 (&temp32,
-						   &buffer[i + j]);
+				ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]);
 				acpi_os_printf ("%08X", temp32);
 
-				ACPI_MOVE_UNALIGNED32_TO_32 (&temp32,
-						   &buffer[i + j + 4]);
+				ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j + 4]);
 				acpi_os_printf ("%08X ", temp32);
 				j += 8;
 				break;
diff -Nru a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
--- a/drivers/acpi/utilities/utmisc.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/acpi/utilities/utmisc.c	Wed Apr 30 22:28:04 2003
@@ -592,7 +592,7 @@
 		(void) acpi_ut_delete_mutex (i);
 	}
 
-	(void) acpi_os_delete_lock (acpi_gbl_gpe_lock);
+	acpi_os_delete_lock (acpi_gbl_gpe_lock);
 	return_VOID;
 }
 
diff -Nru a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
--- a/drivers/atm/ambassador.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/atm/ambassador.c	Wed Apr 30 22:28:04 2003
@@ -868,7 +868,8 @@
 
 /********** interrupt handling **********/
 
-static void interrupt_handler (int irq, void * dev_id, struct pt_regs * pt_regs) {
+static irqreturn_t interrupt_handler(int irq, void *dev_id,
+					struct pt_regs *pt_regs) {
   amb_dev * dev = amb_devs;
   (void) pt_regs;
   
@@ -876,7 +877,7 @@
   
   if (!dev_id) {
     PRINTD (DBG_IRQ|DBG_ERR, "irq with NULL dev_id: %d", irq);
-    return;
+    return IRQ_NONE;
   }
   // Did one of our cards generate the interrupt?
   while (dev) {
@@ -889,12 +890,12 @@
   // the card generates an IRQ at startup - should not happen again
   if (!dev) {
     PRINTD (DBG_IRQ, "irq for unknown device: %d", irq);
-    return;
+    return IRQ_NONE;
   }
   // impossible - unless we have memory corruption of dev or kernel
   if (irq != dev->irq) {
     PRINTD (DBG_IRQ|DBG_ERR, "irq mismatch: %d", irq);
-    return;
+    return IRQ_NONE;
   }
   
   {
@@ -903,7 +904,7 @@
     // for us or someone else sharing the same interrupt
     if (!interrupt) {
       PRINTD (DBG_IRQ, "irq not for me: %d", irq);
-      return;
+      return IRQ_NONE;
     }
     
     // definitely for us
@@ -934,7 +935,7 @@
   }
   
   PRINTD (DBG_IRQ|DBG_FLOW, "interrupt_handler done: %p", dev_id);
-  return;
+  return IRQ_HANDLED;
 }
 
 /********** don't panic... yeah, right **********/
diff -Nru a/drivers/atm/eni.c b/drivers/atm/eni.c
--- a/drivers/atm/eni.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/atm/eni.c	Wed Apr 30 22:28:05 2003
@@ -1483,7 +1483,7 @@
 }
 
 
-static void eni_int(int irq,void *dev_id,struct pt_regs *regs)
+static irqreturn_t eni_int(int irq,void *dev_id,struct pt_regs *regs)
 {
 	struct atm_dev *dev;
 	struct eni_dev *eni_dev;
@@ -1515,6 +1515,7 @@
 	eni_dev->events |= reason;
 	spin_unlock(&eni_dev->lock);
 	tasklet_schedule(&eni_dev->task);
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/atm/firestream.c b/drivers/atm/firestream.c
--- a/drivers/atm/firestream.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/atm/firestream.c	Wed Apr 30 22:28:05 2003
@@ -1562,14 +1562,15 @@
 
 
 
-static void fs_irq (int irq, void *dev_id,  struct pt_regs * pt_regs) 
+static irqreturn_t fs_irq (int irq, void *dev_id,  struct pt_regs * pt_regs) 
 {
 	int i;
 	u32 status;
 	struct fs_dev *dev = dev_id;
 
 	status = read_fs (dev, ISR);
-	if (!status) return;
+	if (!status)
+		return IRQ_NONE;
 
 	func_enter ();
 
@@ -1649,6 +1650,7 @@
 	}
 
 	func_exit ();
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
--- a/drivers/atm/fore200e.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/atm/fore200e.c	Wed Apr 30 22:28:19 2003
@@ -1227,7 +1227,7 @@
 }
 
 
-static void
+static irqreturn_t
 fore200e_interrupt(int irq, void* dev, struct pt_regs* regs)
 {
     struct fore200e* fore200e = FORE200E_DEV((struct atm_dev*)dev);
@@ -1235,13 +1235,14 @@
     if (fore200e->bus->irq_check(fore200e) == 0) {
 	
 	DPRINTK(3, "unexpected interrupt on device %c\n", fore200e->name[9]);
-	return;
+	return IRQ_NONE;
     }
     DPRINTK(3, "valid interrupt on device %c\n", fore200e->name[9]);
 
     tasklet_schedule(&fore200e->tasklet);
     
     fore200e->bus->irq_ack(fore200e);
+    return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/atm/horizon.c b/drivers/atm/horizon.c
--- a/drivers/atm/horizon.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/atm/horizon.c	Wed Apr 30 22:28:03 2003
@@ -1398,7 +1398,8 @@
 
 /********** interrupt handler **********/
 
-static void interrupt_handler (int irq, void * dev_id, struct pt_regs * pt_regs) {
+static irqreturn_t interrupt_handler(int irq, void *dev_id,
+					struct pt_regs *pt_regs) {
   hrz_dev * dev = hrz_devs;
   u32 int_source;
   unsigned int irq_ok;
@@ -1408,7 +1409,7 @@
   
   if (!dev_id) {
     PRINTD (DBG_IRQ|DBG_ERR, "irq with NULL dev_id: %d", irq);
-    return;
+    return IRQ_NONE;
   }
   // Did one of our cards generate the interrupt?
   while (dev) {
@@ -1418,11 +1419,11 @@
   }
   if (!dev) {
     PRINTD (DBG_IRQ, "irq not for me: %d", irq);
-    return;
+    return IRQ_NONE;
   }
   if (irq != dev->irq) {
     PRINTD (DBG_IRQ|DBG_ERR, "irq mismatch: %d", irq);
-    return;
+    return IRQ_NONE;
   }
   
   // definitely for us
@@ -1468,6 +1469,9 @@
   }
   
   PRINTD (DBG_IRQ|DBG_FLOW, "interrupt_handler done: %p", dev_id);
+  if (irq_ok)
+	return IRQ_HANDLED;
+  return IRQ_NONE;
 }
 
 /********** housekeeping **********/
diff -Nru a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
--- a/drivers/atm/idt77252.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/atm/idt77252.c	Wed Apr 30 22:28:09 2003
@@ -134,8 +134,6 @@
 			       int flags);
 static int idt77252_proc_read(struct atm_dev *dev, loff_t * pos,
 			      char *page);
-static void idt77252_interrupt(int irq, void *dev_id,
-			       struct pt_regs *regs);
 static void idt77252_softint(void *dev_id);
 
 
@@ -2812,7 +2810,7 @@
 #endif
 }
 
-static void
+static irqreturn_t
 idt77252_interrupt(int irq, void *dev_id, struct pt_regs *ptregs)
 {
 	struct idt77252_dev *card = dev_id;
@@ -2820,7 +2818,7 @@
 
 	stat = readl(SAR_REG_STAT) & 0xffff;
 	if (!stat)	/* no interrupt for us */
-		return;
+		return IRQ_NONE;
 
 	if (test_and_set_bit(IDT77252_BIT_INTERRUPT, &card->flags)) {
 		printk("%s: Re-entering irq_handler()\n", card->name);
@@ -2901,6 +2899,7 @@
 
 out:
 	clear_bit(IDT77252_BIT_INTERRUPT, &card->flags);
+	return IRQ_HANDLED;
 }
 
 static void
diff -Nru a/drivers/atm/iphase.c b/drivers/atm/iphase.c
--- a/drivers/atm/iphase.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/atm/iphase.c	Wed Apr 30 22:28:18 2003
@@ -2197,16 +2197,18 @@
 	return -ENOMEM;
 }   
    
-static void ia_int(int irq, void *dev_id, struct pt_regs *regs)  
+static irqreturn_t ia_int(int irq, void *dev_id, struct pt_regs *regs)  
 {  
    struct atm_dev *dev;  
    IADEV *iadev;  
    unsigned int status;  
+   int handled = 0;
 
    dev = dev_id;  
    iadev = INPH_IA_DEV(dev);  
    while( (status = readl(iadev->reg+IPHASE5575_BUS_STATUS_REG) & 0x7f))  
    { 
+	handled = 1;
         IF_EVENT(printk("ia_int: status = 0x%x\n", status);) 
 	if (status & STAT_REASSINT)  
 	{  
@@ -2236,7 +2238,8 @@
            if (status & STAT_FEINT) 
                IaFrontEndIntr(iadev);
 	}  
-   }  
+   }
+   return IRQ_RETVAL(handled);
 }  
 	  
 	  
diff -Nru a/drivers/atm/lanai.c b/drivers/atm/lanai.c
--- a/drivers/atm/lanai.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/atm/lanai.c	Wed Apr 30 22:28:06 2003
@@ -2047,10 +2047,12 @@
 		reg_write(lanai, ack, IntAck_Reg);
 }
 
-static void lanai_int(int irq, void *devid, struct pt_regs *regs)
+static irqreturn_t lanai_int(int irq, void *devid, struct pt_regs *regs)
 {
 	struct lanai_dev *lanai = (struct lanai_dev *) devid;
 	u32 reason;
+	int handled = 0;
+
 	(void) irq; (void) regs;	/* unused variables */
 #ifdef USE_POWERDOWN
 	if (lanai->conf1 & CONFIG1_POWERDOWN) {
@@ -2062,8 +2064,11 @@
 		conf2_write(lanai);
 	}
 #endif
-	while ((reason = intr_pending(lanai)) != 0)
+	while ((reason = intr_pending(lanai)) != 0) {
+		handled = 1;
 		lanai_int_1(lanai, reason);
+	}
+	return IRQ_RETVAL(handled);
 }
 
 /* TODO - it would be nice if we could use the "delayed interrupt" system
diff -Nru a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
--- a/drivers/atm/nicstar.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/atm/nicstar.c	Wed Apr 30 22:28:05 2003
@@ -220,7 +220,7 @@
 static void free_scq(scq_info *scq, struct atm_vcc *vcc);
 static void push_rxbufs(ns_dev *card, u32 type, u32 handle1, u32 addr1,
                        u32 handle2, u32 addr2);
-static void ns_irq_handler(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t ns_irq_handler(int irq, void *dev_id, struct pt_regs *regs);
 static int ns_open(struct atm_vcc *vcc, short vpi, int vci);
 static void ns_close(struct atm_vcc *vcc);
 static void fill_tst(ns_dev *card, int n, vc_map *vc);
@@ -1186,7 +1186,7 @@
 
 
 
-static void ns_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t ns_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
 {
    u32 stat_r;
    ns_dev *card;
@@ -1366,6 +1366,7 @@
    
    spin_unlock_irqrestore(&card->int_lock, flags);
    PRINTK("nicstar%d: end of interrupt service\n", card->index);
+   return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/atm/zatm.c b/drivers/atm/zatm.c
--- a/drivers/atm/zatm.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/atm/zatm.c	Wed Apr 30 22:28:06 2003
@@ -1214,15 +1214,17 @@
 /*------------------------------- interrupts --------------------------------*/
 
 
-static void zatm_int(int irq,void *dev_id,struct pt_regs *regs)
+static irqreturn_t zatm_int(int irq,void *dev_id,struct pt_regs *regs)
 {
 	struct atm_dev *dev;
 	struct zatm_dev *zatm_dev;
 	u32 reason;
+	int handled = 0;
 
 	dev = dev_id;
 	zatm_dev = ZATM_DEV(dev);
 	while ((reason = zin(GSR))) {
+		handled = 1;
 		EVENT("reason 0x%x\n",reason,0);
 		if (reason & uPD98401_INT_PI) {
 			EVENT("PHY int\n",0,0);
@@ -1285,6 +1287,7 @@
 		}
 		/* @@@ handle RCRn */
 	}
+	return IRQ_RETVAL(handled);
 }
 
 
diff -Nru a/drivers/base/Makefile b/drivers/base/Makefile
--- a/drivers/base/Makefile	Wed Apr 30 22:28:15 2003
+++ b/drivers/base/Makefile	Wed Apr 30 22:28:15 2003
@@ -1,8 +1,6 @@
 # Makefile for the Linux device tree
 
 obj-y			:= core.o sys.o interface.o power.o bus.o \
-			   driver.o class.o intf.o platform.o \
+			   driver.o class.o platform.o \
 			   cpu.o firmware.o init.o
 obj-$(CONFIG_NUMA)	+= node.o  memblk.o
-obj-y			+= fs/
-obj-$(CONFIG_HOTPLUG)	+= hotplug.o
diff -Nru a/drivers/base/base.h b/drivers/base/base.h
--- a/drivers/base/base.h	Wed Apr 30 22:28:08 2003
+++ b/drivers/base/base.h	Wed Apr 30 22:28:08 2003
@@ -1,28 +1,8 @@
 extern struct semaphore device_sem;
-extern struct semaphore devclass_sem;
 
 extern int bus_add_device(struct device * dev);
 extern void bus_remove_device(struct device * dev);
 
 extern int bus_add_driver(struct device_driver *);
 extern void bus_remove_driver(struct device_driver *);
-
-extern int devclass_add_device(struct device *);
-extern void devclass_remove_device(struct device *);
-
-extern int devclass_add_driver(struct device_driver *);
-extern void devclass_remove_driver(struct device_driver *);
-
-extern int interface_add_dev(struct device *);
-extern void interface_remove_dev(struct device *);
-
-
-#ifdef CONFIG_HOTPLUG
-extern int class_hotplug(struct device *dev, const char *action);
-#else
-static inline int class_hotplug(struct device *dev, const char *action)
-{
-	return 0;
-}
-#endif
 
diff -Nru a/drivers/base/bus.c b/drivers/base/bus.c
--- a/drivers/base/bus.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/base/bus.c	Wed Apr 30 22:28:06 2003
@@ -311,8 +311,7 @@
  *	Walk the list of devices that the bus has on it and try to match
  *	the driver with each one.
  *	If bus_match() returns 0 and the @dev->driver is set, we've found
- *	a compatible pair, so we call devclass_add_device() to add the 
- *	device to the class. 
+ *	a compatible pair.
  *
  *	Note that we ignore the error from bus_match(), since it's perfectly
  *	valid for a driver not to bind to any devices.
@@ -328,8 +327,7 @@
 	list_for_each(entry,&bus->devices.list) {
 		struct device * dev = container_of(entry,struct device,bus_list);
 		if (!dev->driver) {
-			if (!bus_match(dev,drv))
-				devclass_add_device(dev);
+			bus_match(dev,drv);
 		}
 	}
 }
@@ -351,7 +349,6 @@
 	if (drv) {
 		sysfs_remove_link(&drv->kobj,dev->kobj.name);
 		list_del_init(&dev->driver_list);
-		devclass_remove_device(dev);
 		if (drv->remove)
 			drv->remove(dev);
 		dev->driver = NULL;
@@ -443,8 +440,7 @@
 		}
 
 		down_write(&bus->subsys.rwsem);
-		if (!(error = devclass_add_driver(drv)))
-			driver_attach(drv);
+		driver_attach(drv);
 		up_write(&bus->subsys.rwsem);
 
 		if (error) {
@@ -471,7 +467,6 @@
 		down_write(&drv->bus->subsys.rwsem);
 		pr_debug("bus %s: remove driver %s\n",drv->bus->name,drv->name);
 		driver_detach(drv);
-		devclass_remove_driver(drv);
 		up_write(&drv->bus->subsys.rwsem);
 		kobject_unregister(&drv->kobj);
 		put_bus(drv->bus);
diff -Nru a/drivers/base/class.c b/drivers/base/class.c
--- a/drivers/base/class.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/base/class.c	Wed Apr 30 22:28:19 2003
@@ -1,5 +1,7 @@
 /*
  * class.c - basic device class management
+ * 
+ * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org>
  */
 
 #undef DEBUG
@@ -10,16 +12,14 @@
 #include <linux/string.h>
 #include "base.h"
 
-#define to_class_attr(_attr) container_of(_attr,struct devclass_attribute,attr)
-#define to_class(obj) container_of(obj,struct device_class,subsys.kset.kobj)
-
-DECLARE_MUTEX(devclass_sem);
+#define to_class_attr(_attr) container_of(_attr,struct class_attribute,attr)
+#define to_class(obj) container_of(obj,struct class,subsys.kset.kobj)
 
 static ssize_t
-devclass_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
+class_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
 {
-	struct devclass_attribute * class_attr = to_class_attr(attr);
-	struct device_class * dc = to_class(kobj);
+	struct class_attribute * class_attr = to_class_attr(attr);
+	struct class * dc = to_class(kobj);
 	ssize_t ret = 0;
 
 	if (class_attr->show)
@@ -28,11 +28,11 @@
 }
 
 static ssize_t
-devclass_attr_store(struct kobject * kobj, struct attribute * attr, 
-		    const char * buf, size_t count)
+class_attr_store(struct kobject * kobj, struct attribute * attr, 
+		 const char * buf, size_t count)
 {
-	struct devclass_attribute * class_attr = to_class_attr(attr);
-	struct device_class * dc = to_class(kobj);
+	struct class_attribute * class_attr = to_class_attr(attr);
+	struct class * dc = to_class(kobj);
 	ssize_t ret = 0;
 
 	if (class_attr->store)
@@ -41,242 +41,376 @@
 }
 
 static struct sysfs_ops class_sysfs_ops = {
-	.show	= devclass_attr_show,
-	.store	= devclass_attr_store,
+	.show	= class_attr_show,
+	.store	= class_attr_store,
 };
 
-static struct kobj_type ktype_devclass = {
+static struct kobj_type ktype_class = {
 	.sysfs_ops	= &class_sysfs_ops,
 };
 
-/* Classes can't use the kobject hotplug logic, as
- * they do not add new kobjects to the system */
-static decl_subsys(class,&ktype_devclass,NULL);
+/* Hotplug events for classes go to the class_obj subsys */
+static decl_subsys(class,&ktype_class,NULL);
 
 
-static int devclass_dev_link(struct device_class * cls, struct device * dev)
+int class_create_file(struct class * cls, struct class_attribute * attr)
 {
-	char	linkname[16];
-	snprintf(linkname,16,"%u",dev->class_num);
-	return sysfs_create_link(&cls->devices.kobj,&dev->kobj,linkname);
+	int error;
+	if (cls) {
+		error = sysfs_create_file(&cls->subsys.kset.kobj,&attr->attr);
+	} else
+		error = -EINVAL;
+	return error;
 }
 
-static void devclass_dev_unlink(struct device_class * cls, struct device * dev)
+void class_remove_file(struct class * cls, struct class_attribute * attr)
 {
-	char	linkname[16];
-	snprintf(linkname,16,"%u",dev->class_num);
-	sysfs_remove_link(&cls->devices.kobj,linkname);
+	if (cls)
+		sysfs_remove_file(&cls->subsys.kset.kobj,&attr->attr);
 }
 
-static int devclass_drv_link(struct device_driver * drv)
+struct class * class_get(struct class * cls)
 {
-	char	name[KOBJ_NAME_LEN * 3];
-	snprintf(name,KOBJ_NAME_LEN * 3,"%s:%s",drv->bus->name,drv->name);
-	return sysfs_create_link(&drv->devclass->drivers.kobj,&drv->kobj,name);
+	if (cls)
+		return container_of(subsys_get(&cls->subsys),struct class,subsys);
+	return NULL;
 }
 
-static void devclass_drv_unlink(struct device_driver * drv)
+void class_put(struct class * cls)
 {
-	char	name[KOBJ_NAME_LEN * 3];
-	snprintf(name,KOBJ_NAME_LEN * 3,"%s:%s",drv->bus->name,drv->name);
-	return sysfs_remove_link(&drv->devclass->drivers.kobj,name);
+	subsys_put(&cls->subsys);
 }
 
+int class_register(struct class * cls)
+{
+	pr_debug("device class '%s': registering\n",cls->name);
+
+	INIT_LIST_HEAD(&cls->children);
+	INIT_LIST_HEAD(&cls->interfaces);
+	
+	strncpy(cls->subsys.kset.kobj.name,cls->name,KOBJ_NAME_LEN);
+	subsys_set_kset(cls,class_subsys);
+	subsystem_register(&cls->subsys);
 
-int devclass_create_file(struct device_class * cls, struct devclass_attribute * attr)
+	return 0;
+}
+
+void class_unregister(struct class * cls)
 {
-	int error;
-	if (cls) {
-		error = sysfs_create_file(&cls->subsys.kset.kobj,&attr->attr);
-	} else
-		error = -EINVAL;
+	pr_debug("device class '%s': unregistering\n",cls->name);
+	subsystem_unregister(&cls->subsys);
+}
+
+/* Class Device Stuff */
+
+int class_device_create_file(struct class_device * class_dev,
+			     struct class_device_attribute * attr)
+{
+	int error = -EINVAL;
+	if (class_dev)
+		error = sysfs_create_file(&class_dev->kobj, &attr->attr);
 	return error;
 }
 
-void devclass_remove_file(struct device_class * cls, struct devclass_attribute * attr)
+void class_device_remove_file(struct class_device * class_dev,
+			      struct class_device_attribute * attr)
 {
-	if (cls)
-		sysfs_remove_file(&cls->subsys.kset.kobj,&attr->attr);
+	if (class_dev)
+		sysfs_remove_file(&class_dev->kobj, &attr->attr);
 }
 
+static int class_device_dev_link(struct class_device * class_dev)
+{
+	if (class_dev->dev)
+		return sysfs_create_link(&class_dev->kobj,
+					 &class_dev->dev->kobj, "device");
+	return 0;
+}
 
-int devclass_add_driver(struct device_driver * drv)
+static void class_device_dev_unlink(struct class_device * class_dev)
 {
-	struct device_class * cls = get_devclass(drv->devclass);
-	int error = 0;
+	if (class_dev->dev)
+		sysfs_remove_link(&class_dev->kobj, "device");
+}
 
-	if (cls) {
-		down_write(&cls->subsys.rwsem);
-		pr_debug("device class %s: adding driver %s:%s\n",
-			 cls->name,drv->bus->name,drv->name);
-		error = devclass_drv_link(drv);
-		
-		if (!error)
-			list_add_tail(&drv->class_list,&cls->drivers.list);
-		up_write(&cls->subsys.rwsem);
-	}
-	return error;
+#define to_class_dev(obj) container_of(obj,struct class_device,kobj)
+#define to_class_dev_attr(_attr) container_of(_attr,struct class_device_attribute,attr)
+
+static ssize_t
+class_device_attr_show(struct kobject * kobj, struct attribute * attr,
+		       char * buf)
+{
+	struct class_device_attribute * class_dev_attr = to_class_dev_attr(attr);
+	struct class_device * cd = to_class_dev(kobj);
+	ssize_t ret = 0;
+
+	if (class_dev_attr->show)
+		ret = class_dev_attr->show(cd,buf);
+	return ret;
 }
 
-void devclass_remove_driver(struct device_driver * drv)
+static ssize_t
+class_device_attr_store(struct kobject * kobj, struct attribute * attr, 
+			const char * buf, size_t count)
 {
-	struct device_class * cls = drv->devclass;
-	if (cls) {
-		down_write(&cls->subsys.rwsem);
-		pr_debug("device class %s: removing driver %s:%s\n",
-			 cls->name,drv->bus->name,drv->name);
-		list_del_init(&drv->class_list);
-		devclass_drv_unlink(drv);
-		up_write(&cls->subsys.rwsem);
-		put_devclass(cls);
-	}
+	struct class_device_attribute * class_dev_attr = to_class_dev_attr(attr);
+	struct class_device * cd = to_class_dev(kobj);
+	ssize_t ret = 0;
+
+	if (class_dev_attr->store)
+		ret = class_dev_attr->store(cd,buf,count);
+	return ret;
 }
 
+static struct sysfs_ops class_dev_sysfs_ops = {
+	.show	= class_device_attr_show,
+	.store	= class_device_attr_store,
+};
 
-static void enum_device(struct device_class * cls, struct device * dev)
-{
-	u32 val;
-	val = cls->devnum++;
-	dev->class_num = val;
-	devclass_dev_link(cls,dev);
-}
-
-static void unenum_device(struct device_class * cls, struct device * dev)
-{
-	devclass_dev_unlink(cls,dev);
-	dev->class_num = 0;
-}
-
-/**
- *	devclass_add_device - register device with device class
- *	@dev:   device to be registered 
- *
- *	This is called when a device is either registered with the 
- *	core, or after the a driver module is loaded and bound to
- *	the device. 
- *	The class is determined by looking at @dev's driver, so one
- *	way or another, it must be bound to something. Once the 
- *	class is determined, it's set to prevent against concurrent
- *	calls for the same device stomping on each other. 
- *
- *	/sbin/hotplug should be called once the device is added to 
- *	class and all the interfaces. 
- */
-int devclass_add_device(struct device * dev)
+static struct kobj_type ktype_class_device = {
+	.sysfs_ops	= &class_dev_sysfs_ops,
+};
+
+static int class_hotplug_filter(struct kset *kset, struct kobject *kobj)
 {
-	struct device_class * cls;
-	int error = 0;
+	struct kobj_type *ktype = get_ktype(kobj);
 
-	down(&devclass_sem);
-	if (dev->driver) {
-		cls = get_devclass(dev->driver->devclass);
-
-		if (!cls)
-			goto Done;
-
-		pr_debug("device class %s: adding device %s\n",
-			 cls->name,dev->name);
-		if (cls->add_device) 
-			error = cls->add_device(dev);
-		if (error) {
-			put_devclass(cls);
-			goto Done;
-		}
+	if (ktype == &ktype_class_device) {
+		struct class_device *class_dev = to_class_dev(kobj);
+		if (class_dev->class)
+			return 1;
+	}
+	return 0;
+}
+
+static char *class_hotplug_name(struct kset *kset, struct kobject *kobj)
+{
+	struct class_device *class_dev = to_class_dev(kobj);
 
-		down_write(&cls->subsys.rwsem);
-		enum_device(cls,dev);
-		list_add_tail(&dev->class_list,&cls->devices.list);
-		/* notify userspace (call /sbin/hotplug) */
-		class_hotplug (dev, "add");
+	return class_dev->class->name;
+}
 
-		up_write(&cls->subsys.rwsem);
+static int class_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
+			 int num_envp, char *buffer, int buffer_size)
+{
+	struct class_device *class_dev = to_class_dev(kobj);
+	int retval = 0;
 
-		interface_add_dev(dev);
+	pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id);
+	if (class_dev->class->hotplug) {
+		/* have the bus specific function add its stuff */
+		retval = class_dev->class->hotplug (class_dev, envp, num_envp,
+						    buffer, buffer_size);
+			if (retval) {
+			pr_debug ("%s - hotplug() returned %d\n",
+				  __FUNCTION__, retval);
+		}
 	}
- Done:
-	up(&devclass_sem);
-	return error;
+
+	return retval;
 }
 
-void devclass_remove_device(struct device * dev)
+static struct kset_hotplug_ops class_hotplug_ops = {
+	.filter =	class_hotplug_filter,
+	.name =		class_hotplug_name,
+	.hotplug =	class_hotplug,
+};
+
+static decl_subsys(class_obj, &ktype_class_device, &class_hotplug_ops);
+
+void class_device_initialize(struct class_device *class_dev)
 {
-	struct device_class * cls;
+	kobject_init(&class_dev->kobj);
+	INIT_LIST_HEAD(&class_dev->node);
+}
 
-	down(&devclass_sem);
-	if (dev->driver) {
-		cls = dev->driver->devclass;
-		if (!cls) 
-			goto Done;
+int class_device_add(struct class_device *class_dev)
+{
+	struct class * parent;
+	struct class_interface * class_intf;
+	struct list_head * entry;
+	int error;
 
-		interface_remove_dev(dev);
+	class_dev = class_device_get(class_dev);
+	if (!class_dev || !strlen(class_dev->class_id))
+		return -EINVAL;
+
+	parent = class_get(class_dev->class);
+	if (class_dev->dev)
+		get_device(class_dev->dev);
+
+	pr_debug("CLASS: registering class device: ID = '%s'\n",
+		 class_dev->class_id);
+
+	/* first, register with generic layer. */
+	strncpy(class_dev->kobj.name, class_dev->class_id, KOBJ_NAME_LEN);
+	kobj_set_kset_s(class_dev, class_subsys);
+	kobj_set_kset_s(class_dev, class_obj_subsys);
+	if (parent)
+		class_dev->kobj.parent = &parent->subsys.kset.kobj;
+
+	if ((error = kobject_add(&class_dev->kobj)))
+		goto register_done;
+
+	/* now take care of our own registration */
+	if (parent) {
+		down_write(&parent->subsys.rwsem);
+		list_add_tail(&class_dev->node, &parent->children);
+		list_for_each(entry, &parent->interfaces) {
+			class_intf = container_of(entry, struct class_interface, node);
+			if (class_intf->add)
+				class_intf->add(class_dev);
+		}
+		up_write(&parent->subsys.rwsem);
+	}
 
-		down_write(&cls->subsys.rwsem);
-		pr_debug("device class %s: removing device %s\n",
-			 cls->name,dev->name);
+	class_device_dev_link(class_dev);
 
-		unenum_device(cls,dev);
+ register_done:
+	if (error && parent)
+		class_put(parent);
+	class_device_put(class_dev);
+	return error;
+}
 
-		list_del(&dev->class_list);
+int class_device_register(struct class_device *class_dev)
+{
+	class_device_initialize(class_dev);
+	return class_device_add(class_dev);
+}
 
-		/* notify userspace (call /sbin/hotplug) */
-		class_hotplug (dev, "remove");
+void class_device_del(struct class_device *class_dev)
+{
+	struct class * parent = class_dev->class;
+	struct class_interface * class_intf;
+	struct list_head * entry;
 
-		up_write(&cls->subsys.rwsem);
+	if (parent) {
+		down_write(&parent->subsys.rwsem);
+		list_del_init(&class_dev->node);
+		list_for_each(entry, &parent->interfaces) {
+			class_intf = container_of(entry, struct class_interface, node);
+			if (class_intf->remove)
+				class_intf->remove(class_dev);
+		}
+		up_write(&parent->subsys.rwsem);
+	}
 
-		if (cls->remove_device)
-			cls->remove_device(dev);
-		put_devclass(cls);
+	if (class_dev->dev) {
+		class_device_dev_unlink(class_dev);
+		put_device(class_dev->dev);
 	}
- Done:
-	up(&devclass_sem);
+	
+	kobject_del(&class_dev->kobj);
+
+	if (parent)
+		class_put(parent);
 }
 
-struct device_class * get_devclass(struct device_class * cls)
+void class_device_unregister(struct class_device *class_dev)
 {
-	return cls ? container_of(subsys_get(&cls->subsys),struct device_class,subsys) : NULL;
+	pr_debug("CLASS: Unregistering class device. ID = '%s'\n",
+		 class_dev->class_id);
+	class_device_del(class_dev);
+	class_device_put(class_dev);
 }
 
-void put_devclass(struct device_class * cls)
+struct class_device * class_device_get(struct class_device *class_dev)
 {
-	subsys_put(&cls->subsys);
+	if (class_dev)
+		return to_class_dev(kobject_get(&class_dev->kobj));
+	return NULL;
+}
+
+void class_device_put(struct class_device *class_dev)
+{
+	kobject_put(&class_dev->kobj);
 }
 
 
-int devclass_register(struct device_class * cls)
+int class_interface_register(struct class_interface *class_intf)
 {
-	pr_debug("device class '%s': registering\n",cls->name);
-	strncpy(cls->subsys.kset.kobj.name,cls->name,KOBJ_NAME_LEN);
-	subsys_set_kset(cls,class_subsys);
-	subsystem_register(&cls->subsys);
+	struct class * parent;
+	struct class_device * class_dev;
+	struct list_head * entry;
+
+	if (!class_intf || !class_intf->class)
+		return -ENODEV;
 
-	snprintf(cls->devices.kobj.name,KOBJ_NAME_LEN,"devices");
-	cls->devices.subsys = &cls->subsys;
-	kset_register(&cls->devices);
-
-	snprintf(cls->drivers.kobj.name,KOBJ_NAME_LEN,"drivers");
-	cls->drivers.subsys = &cls->subsys;
-	kset_register(&cls->drivers);
+	parent = class_get(class_intf->class);
+	if (!parent)
+		return -EINVAL;
+
+	down_write(&parent->subsys.rwsem);
+	list_add_tail(&class_intf->node, &parent->interfaces);
+
+	if (class_intf->add) {
+		list_for_each(entry, &parent->children) {
+			class_dev = container_of(entry, struct class_device, node);
+			class_intf->add(class_dev);
+		}
+	}
+	up_write(&parent->subsys.rwsem);
 
 	return 0;
 }
 
-void devclass_unregister(struct device_class * cls)
+void class_interface_unregister(struct class_interface *class_intf)
 {
-	pr_debug("device class '%s': unregistering\n",cls->name);
-	kset_unregister(&cls->drivers);
-	kset_unregister(&cls->devices);
-	subsystem_unregister(&cls->subsys);
+	struct class * parent = class_intf->class;
+	struct list_head * entry;
+
+	if (!parent)
+		return;
+
+	down_write(&parent->subsys.rwsem);
+	list_del_init(&class_intf->node);
+
+	if (class_intf->remove) {
+		list_for_each(entry, &parent->children) {
+			struct class_device *class_dev = container_of(entry, struct class_device, node);
+			class_intf->remove(class_dev);
+		}
+	}
+	up_write(&parent->subsys.rwsem);
+
+	class_put(parent);
 }
 
+
+
 int __init classes_init(void)
 {
-	return subsystem_register(&class_subsys);
+	int retval;
+
+	retval = subsystem_register(&class_subsys);
+	if (retval)
+		return retval;
+
+	/* ick, this is ugly, the things we go through to keep from showing up
+	 * in sysfs... */
+	subsystem_init(&class_obj_subsys);
+	if (!class_obj_subsys.kset.subsys)
+			class_obj_subsys.kset.subsys = &class_obj_subsys;
+	return 0;
 }
 
-EXPORT_SYMBOL(devclass_create_file);
-EXPORT_SYMBOL(devclass_remove_file);
-EXPORT_SYMBOL(devclass_register);
-EXPORT_SYMBOL(devclass_unregister);
-EXPORT_SYMBOL(get_devclass);
-EXPORT_SYMBOL(put_devclass);
+EXPORT_SYMBOL(class_create_file);
+EXPORT_SYMBOL(class_remove_file);
+EXPORT_SYMBOL(class_register);
+EXPORT_SYMBOL(class_unregister);
+EXPORT_SYMBOL(class_get);
+EXPORT_SYMBOL(class_put);
+
+EXPORT_SYMBOL(class_device_register);
+EXPORT_SYMBOL(class_device_unregister);
+EXPORT_SYMBOL(class_device_initialize);
+EXPORT_SYMBOL(class_device_add);
+EXPORT_SYMBOL(class_device_del);
+EXPORT_SYMBOL(class_device_get);
+EXPORT_SYMBOL(class_device_put);
+EXPORT_SYMBOL(class_device_create_file);
+EXPORT_SYMBOL(class_device_remove_file);
 
+EXPORT_SYMBOL(class_interface_register);
+EXPORT_SYMBOL(class_interface_unregister);
diff -Nru a/drivers/base/core.c b/drivers/base/core.c
--- a/drivers/base/core.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/base/core.c	Wed Apr 30 22:28:04 2003
@@ -185,7 +185,6 @@
 	INIT_LIST_HEAD(&dev->children);
 	INIT_LIST_HEAD(&dev->driver_list);
 	INIT_LIST_HEAD(&dev->bus_list);
-	INIT_LIST_HEAD(&dev->class_list);
 }
 
 /**
@@ -235,7 +234,6 @@
 	if (platform_notify)
 		platform_notify(dev);
 
-	devclass_add_device(dev);
  register_done:
 	if (error && parent)
 		put_device(parent);
diff -Nru a/drivers/base/cpu.c b/drivers/base/cpu.c
--- a/drivers/base/cpu.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/base/cpu.c	Wed Apr 30 22:28:07 2003
@@ -10,23 +10,16 @@
 #include <asm/topology.h>
 
 
-static int cpu_add_device(struct device * dev)
-{
-	return 0;
-}
-struct device_class cpu_devclass = {
+struct class cpu_class = {
 	.name		= "cpu",
-	.add_device	= cpu_add_device,
 };
 
 
 struct device_driver cpu_driver = {
 	.name		= "cpu",
 	.bus		= &system_bus_type,
-	.devclass	= &cpu_devclass,
 };
 
-
 /*
  * register_cpu - Setup a driverfs device for a CPU.
  * @num - CPU number to use when creating the device.
@@ -35,6 +28,8 @@
  */
 int __init register_cpu(struct cpu *cpu, int num, struct node *root)
 {
+	int retval;
+
 	cpu->node_id = cpu_to_node(num);
 	cpu->sysdev.name = "cpu";
 	cpu->sysdev.id = num;
@@ -42,7 +37,19 @@
 		cpu->sysdev.root = &root->sysroot;
 	snprintf(cpu->sysdev.dev.name, DEVICE_NAME_SIZE, "CPU %u", num);
 	cpu->sysdev.dev.driver = &cpu_driver;
-	return sys_device_register(&cpu->sysdev);
+	retval = sys_device_register(&cpu->sysdev);
+	if (retval)
+		return retval;
+	memset(&cpu->sysdev.class_dev, 0x00, sizeof(struct class_device));
+	cpu->sysdev.class_dev.dev = &cpu->sysdev.dev;
+	cpu->sysdev.class_dev.class = &cpu_class;
+	snprintf(cpu->sysdev.class_dev.class_id, BUS_ID_SIZE, "cpu%d", num);
+	retval = class_device_register(&cpu->sysdev.class_dev);
+	if (retval) {
+		// FIXME cleanup sys_device_register
+		return retval;
+	}
+	return 0;
 }
 
 
@@ -50,11 +57,11 @@
 {
 	int error;
 
-	error = devclass_register(&cpu_devclass);
+	error = class_register(&cpu_class);
 	if (!error) {
 		error = driver_register(&cpu_driver);
 		if (error)
-			devclass_unregister(&cpu_devclass);
+			class_unregister(&cpu_class);
 	}
 	return error;
 }
diff -Nru a/drivers/base/driver.c b/drivers/base/driver.c
--- a/drivers/base/driver.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/base/driver.c	Wed Apr 30 22:28:16 2003
@@ -82,7 +82,6 @@
 int driver_register(struct device_driver * drv)
 {
 	INIT_LIST_HEAD(&drv->devices);
-	INIT_LIST_HEAD(&drv->class_list);
 	init_MUTEX_LOCKED(&drv->unload_sem);
 	return bus_add_driver(drv);
 }
diff -Nru a/drivers/base/fs/Makefile b/drivers/base/fs/Makefile
--- a/drivers/base/fs/Makefile	Wed Apr 30 22:28:09 2003
+++ /dev/null	Wed Dec 31 16:00:00 1969
@@ -1,2 +0,0 @@
-obj-y		:= device.o
-
diff -Nru a/drivers/base/fs/device.c b/drivers/base/fs/device.c
--- a/drivers/base/fs/device.c	Wed Apr 30 22:28:09 2003
+++ /dev/null	Wed Dec 31 16:00:00 1969
@@ -1,49 +0,0 @@
-/*
- * drivers/base/fs.c - driver model interface to driverfs 
- *
- * Copyright (c) 2002 Patrick Mochel
- *		 2002 Open Source Development Lab
- */
-
-#undef DEBUG
-
-#include <linux/device.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/err.h>
-#include <linux/stat.h>
-#include <linux/limits.h>
-
-int get_devpath_length(struct device * dev)
-{
-	int length = 1;
-	struct device * parent = dev;
-
-	/* walk up the ancestors until we hit the root.
-	 * Add 1 to strlen for leading '/' of each level.
-	 */
-	do {
-		length += strlen(parent->bus_id) + 1;
-		parent = parent->parent;
-	} while (parent);
-	return length;
-}
-
-void fill_devpath(struct device * dev, char * path, int length)
-{
-	struct device * parent;
-	--length;
-	for (parent = dev; parent; parent = parent->parent) {
-		int cur = strlen(parent->bus_id);
-
-		/* back up enough to print this bus id with '/' */
-		length -= cur;
-		strncpy(path + length,parent->bus_id,cur);
-		*(path + --length) = '/';
-	}
-
-	pr_debug("%s: path = '%s'\n",__FUNCTION__,path);
-}
-
diff -Nru a/drivers/base/fs/fs.h b/drivers/base/fs/fs.h
--- a/drivers/base/fs/fs.h	Wed Apr 30 22:28:06 2003
+++ /dev/null	Wed Dec 31 16:00:00 1969
@@ -1,5 +0,0 @@
-
-int get_devpath_length(struct device * dev);
-
-void fill_devpath(struct device * dev, char * path, int length);
-
diff -Nru a/drivers/base/hotplug.c b/drivers/base/hotplug.c
--- a/drivers/base/hotplug.c	Wed Apr 30 22:28:03 2003
+++ /dev/null	Wed Dec 31 16:00:00 1969
@@ -1,145 +0,0 @@
-/*
- * drivers/base/hotplug.c - hotplug call code
- * 
- * Copyright (c) 2000-2001 David Brownell
- * Copyright (c) 2002-2003 Greg Kroah-Hartman
- * Copyright (c) 2002-2003 IBM Corp.
- *
- * Based off of drivers/usb/core/usb.c:call_agent(), which was 
- * written by David Brownell.
- *
- */
-
-#undef DEBUG
-
-#include <linux/device.h>
-#include <linux/slab.h>
-#include <linux/err.h>
-#include <linux/kmod.h>
-#include <linux/interrupt.h>
-#include <linux/sched.h>
-#include <linux/string.h>
-#include "base.h"
-#include "fs/fs.h"
-
-/*
- * hotplugging invokes what /proc/sys/kernel/hotplug says (normally
- * /sbin/hotplug) when devices or classes get added or removed.
- *
- * This invokes a user mode policy agent, typically helping to load driver
- * or other modules, configure the device, and more.  Drivers can provide
- * a MODULE_DEVICE_TABLE to help with module loading subtasks.
- *
- * See the documentation at http://linux-hotplug.sf.net for more info.
- * 
- */
-
-#define BUFFER_SIZE	1024	/* should be enough memory for the env */
-#define NUM_ENVP	32	/* number of env pointers */
-
-static char prefix [] = "devices";	/* /sys/devices/... */
-
-static int do_hotplug (struct device *dev, char *argv1, const char *action,
-			int (* hotplug) (struct device *, char **, int, char *, int))
-{
-	char *argv [3], **envp, *buffer, *scratch;
-	char *dev_path;
-	int retval;
-	int i = 0;
-	int dev_length;
-
-	pr_debug ("%s\n", __FUNCTION__);
-
-	if (!hotplug_path [0])
-		return -ENODEV;
-
-	envp = (char **) kmalloc (NUM_ENVP * sizeof (char *), GFP_KERNEL);
-	if (!envp)
-		return -ENOMEM;
-	memset (envp, 0x00, NUM_ENVP * sizeof (char *));
-
-	buffer = kmalloc (BUFFER_SIZE, GFP_KERNEL);
-	if (!buffer) {
-		kfree (envp);
-		return -ENOMEM;
-	}
-
-	dev_length = get_devpath_length (dev);
-	dev_length += strlen(prefix);
-	dev_path = kmalloc (dev_length, GFP_KERNEL);
-	if (!dev_path) {
-		kfree (buffer);
-		kfree (envp);
-		return -ENOMEM;
-	}
-	memset (dev_path, 0x00, dev_length);
-	strcpy (dev_path, prefix);
-	fill_devpath (dev, dev_path, dev_length);
-
-	argv [0] = hotplug_path;
-	argv [1] = argv1;
-	argv [2] = 0;
-
-	/* minimal command environment */
-	envp [i++] = "HOME=/";
-	envp [i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
-
-	scratch = buffer;
-
-	envp [i++] = scratch;
-	scratch += sprintf (scratch, "ACTION=%s", action) + 1;
-
-	envp [i++] = scratch;
-	scratch += sprintf (scratch, "DEVPATH=%s", dev_path) + 1;
-	
-	if (hotplug) {
-		/* have the bus specific function add its stuff */
-		retval = hotplug (dev, &envp[i], NUM_ENVP - i, scratch,
-				  BUFFER_SIZE - (scratch - buffer));
-		if (retval) {
-			pr_debug ("%s - hotplug() returned %d\n",
-				  __FUNCTION__, retval);
-			goto exit;
-		}
-	}
-
-	pr_debug ("%s: %s %s %s %s %s %s\n", __FUNCTION__, argv [0], argv[1],
-		  envp[0], envp[1], envp[2], envp[3]);
-	retval = call_usermodehelper (argv [0], argv, envp, 0);
-	if (retval)
-		pr_debug ("%s - call_usermodehelper returned %d\n",
-			  __FUNCTION__, retval);
-
-exit:
-	kfree (dev_path);
-	kfree (buffer);
-	kfree (envp);
-	return retval;
-}
-
-/*
- * class_hotplug - called when a class is added or removed from a device
- */
-int class_hotplug (struct device *dev, const char *action)
-{
-	struct device_class * cls;
-	int retval;
-
-	pr_debug ("%s\n", __FUNCTION__);
-
-	if (!dev)
-		return -ENODEV;
-
-	if (!dev->bus)
-		return -ENODEV;
-
-	cls = get_devclass(dev->driver->devclass);
-	if (!cls)
-		return -ENODEV;
-
-	retval = do_hotplug (dev, cls->name, action, cls->hotplug);
-
-	put_devclass(cls);
-
-	return retval;
-}
diff -Nru a/drivers/base/intf.c b/drivers/base/intf.c
--- a/drivers/base/intf.c	Wed Apr 30 22:28:15 2003
+++ /dev/null	Wed Dec 31 16:00:00 1969
@@ -1,225 +0,0 @@
-/*
- * intf.c - class-specific interface management
- */
-
-#undef DEBUG
-
-#include <linux/device.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include "base.h"
-
-
-#define to_intf(node) container_of(node,struct device_interface,kset.kobj.entry)
-
-#define to_dev(d) container_of(d,struct device,class_list)
-
-/**
- *	intf_dev_link - create sysfs symlink for interface.
- *	@intf:	interface.
- *	@dev:	device.
- *
- *	Create a symlink 'phys' in the interface's directory to 
- */
-
-static int intf_dev_link(struct device_interface * intf, struct device * dev)
-{
-	return sysfs_create_link(&intf->kset.kobj,&dev->kobj,dev->bus_id);
-}
-
-/**
- *	intf_dev_unlink - remove symlink for interface.
- *	@intf:	interface.
- *	@dev:	device.
- *
- */
-
-static void intf_dev_unlink(struct device_interface * intf, struct device * dev)
-{
-	sysfs_remove_link(&intf->kset.kobj,dev->bus_id);
-}
-
-
-/**
- *	add - attach device to interface
- *	@intf:	interface.
- *	@dev:	device.
- *
- *	This is just a simple helper. Check the interface's interface
- *	helper and call it. This is called when adding an interface
- *	the class's devices, or a device to the class's interfaces.
- */
-
-static int add(struct device_interface * intf, struct device * dev)
-{
-	int error = 0;
-
-	if (intf->add_device) {
-		if (!(error = intf->add_device(dev)))
-			intf_dev_link(intf,dev);
-	}
-	pr_debug(" -> %s (%d)\n",dev->bus_id,error);
-	return error;
-}
-
-/**
- *	del - detach device from interface.
- *	@intf:	interface.
- *	@dev:	device.
- */
-
-static void del(struct device_interface * intf, struct device * dev)
-{
-	pr_debug(" -> %s ",intf->name);
-	if (intf->remove_device)
-		intf->remove_device(dev);
-	intf_dev_unlink(intf,dev);
-}
-
-
-/**
- *	add_intf - add class's devices to interface.
- *	@intf:	interface.
- *
- *	Loop over the devices registered with the class, and call
- *	the interface's add_device() method for each.
- *
- *	On an error, we won't break, but we will print debugging info.
- */
-static void add_intf(struct device_interface * intf)
-{
-	struct device_class * cls = intf->devclass;
-	struct list_head * entry;
-
-	list_for_each(entry,&cls->devices.list)
-		add(intf,to_dev(entry));
-}
-
-/**
- *	interface_register - register an interface with a device class.
- *	@intf:	interface.
- *
- *	An interface may be loaded after drivers and devices have been
- *	added to the class. So, we must add each device already known to
- *	the class to the interface as its registered.
- */
-
-int interface_register(struct device_interface * intf)
-{
-	struct device_class * cls = get_devclass(intf->devclass);
-
-	down(&devclass_sem);
-	if (cls) {
-		pr_debug("register interface '%s' with class '%s'\n",
-			 intf->name,cls->name);
-
-		strncpy(intf->kset.kobj.name,intf->name,KOBJ_NAME_LEN);
-		kset_set_kset_s(intf,cls->subsys);
-		kset_register(&intf->kset);
-		add_intf(intf);
-	}
-	up(&devclass_sem);
-	return 0;
-}
-
-
-/**
- *	del_intf - remove devices from interface.
- *	@intf:	interface being unloaded.
- *
- *	This loops over the devices registered with a class and 
- *	calls the interface's remove_device() method for each.
- *	This is called when an interface is being unregistered.
- */
-
-static void del_intf(struct device_interface * intf)
-{
-	struct device_class * cls = intf->devclass;
-	struct list_head * entry;
-
-	list_for_each(entry,&cls->devices.list) {
-		struct device * dev = to_dev(entry);
-		del(intf,dev);
-	}
-}
-
-/**
- *	interface_unregister - remove interface from class.
- *	@intf:	interface.
- *
- *	This is called when an interface in unloaded, giving it a
- *	chance to remove itself from devicse that have been added to 
- *	it.
- */
-
-void interface_unregister(struct device_interface * intf)
-{
-	struct device_class * cls = intf->devclass;
-
-	down(&devclass_sem);
-	if (cls) {
-		pr_debug("unregistering interface '%s' from class '%s'\n",
-			 intf->name,cls->name);
-		del_intf(intf);
-		kset_unregister(&intf->kset);
-		put_devclass(cls);
-	}
-	up(&devclass_sem);
-}
-
-
-/**
- *	interface_add_dev - add device to interfaces.
- *	@dev:	device.
- *
- *	This is a helper for the class driver core. When a 
- *	device is being added to a class, this is called to add
- *	the device to all the interfaces in the class.
- *
- *	The operation is simple enough: loop over the interfaces
- *	and call add() [above] for each. The class rwsem is assumed
- *	to be held.
- */
-
-int interface_add_dev(struct device * dev)
-{
-	struct device_class * cls = dev->driver->devclass;
-	struct list_head * node;
-
-	pr_debug("interfaces: adding device %s\n",dev->name);
-
-	list_for_each(node,&cls->subsys.kset.list) {
-		struct device_interface * intf = to_intf(node);
-		add(intf,dev);
-	}
-	return 0;
-}
-
-
-/**
- *	interface_remove_dev - remove device from interfaces.
- *	@dev:	device.
- *
- *	This is another helper for the class driver core, and called
- *	when the device is being removed from the class. 
- *	
- *	We iterate over the list of the class's devices and call del() 
- *	[above] for each. Again, the class's rwsem is _not_ held, but
- *	the devclass_sem is (see class.c).
- */
-
-void interface_remove_dev(struct device * dev)
-{
-	struct list_head * entry, * next;
-	struct device_class * cls = dev->driver->devclass;
-
-	pr_debug("interfaces: removing device %s\n",dev->name);
-
-	list_for_each_safe(entry,next,&cls->subsys.kset.list) {
-		struct device_interface * intf = to_intf(entry);
-		del(intf,dev);
-	}
-}
-
-EXPORT_SYMBOL(interface_register);
-EXPORT_SYMBOL(interface_unregister);
diff -Nru a/drivers/base/memblk.c b/drivers/base/memblk.c
--- a/drivers/base/memblk.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/base/memblk.c	Wed Apr 30 22:28:19 2003
@@ -11,20 +11,14 @@
 #include <asm/topology.h>
 
 
-static int memblk_add_device(struct device * dev)
-{
-	return 0;
-}
-struct device_class memblk_devclass = {
+static struct class memblk_class = {
 	.name		= "memblk",
-	.add_device	= memblk_add_device,
 };
 
 
-struct device_driver memblk_driver = {
+static struct device_driver memblk_driver = {
 	.name		= "memblk",
 	.bus		= &system_bus_type,
-	.devclass	= &memblk_devclass,
 };
 
 
@@ -51,11 +45,11 @@
 {
 	int error;
 
-	error = devclass_register(&memblk_devclass);
+	error = class_register(&memblk_class);
 	if (!error) {
 		error = driver_register(&memblk_driver);
 		if (error)
-			devclass_unregister(&memblk_devclass);
+			class_unregister(&memblk_class);
 	}
 	return error;
 }
diff -Nru a/drivers/base/node.c b/drivers/base/node.c
--- a/drivers/base/node.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/base/node.c	Wed Apr 30 22:28:05 2003
@@ -11,20 +11,14 @@
 #include <asm/topology.h>
 
 
-static int node_add_device(struct device * dev)
-{
-	return 0;
-}
-struct device_class node_devclass = {
+static struct class node_class = {
 	.name		= "node",
-	.add_device	= node_add_device,
 };
 
 
-struct device_driver node_driver = {
+static struct device_driver node_driver = {
 	.name		= "node",
 	.bus		= &system_bus_type,
-	.devclass	= &node_devclass,
 };
 
 
@@ -93,11 +87,11 @@
 {
 	int error;
 	
-	error = devclass_register(&node_devclass);
+	error = class_register(&node_class);
 	if (!error) {
 		error = driver_register(&node_driver);
 		if (error)
-			devclass_unregister(&node_devclass);
+			class_unregister(&node_class);
 	}
 	return error;
 }
diff -Nru a/drivers/block/DAC960.c b/drivers/block/DAC960.c
--- a/drivers/block/DAC960.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/block/DAC960.c	Wed Apr 30 22:28:14 2003
@@ -46,43 +46,126 @@
 #include "DAC960.h"
 
 
-/*
-  DAC960_ControllerCount is the number of DAC960 Controllers detected.
-*/
+static DAC960_Controller_T *DAC960_Controllers[DAC960_MaxControllers];
+static int DAC960_ControllerCount;
+static PROC_DirectoryEntry_T *DAC960_ProcDirectoryEntry;
 
-static int
-  DAC960_ControllerCount =			0;
 
-/*
-  DAC960_Controllers is an array of pointers to the DAC960 Controller
-  structures.
-*/
+static long disk_size(DAC960_Controller_T *p, int drive_nr)
+{
+	if (p->FirmwareType == DAC960_V1_Controller) {
+		if (drive_nr >= p->LogicalDriveCount)
+			return 0;
+		return p->V1.LogicalDriveInformation[drive_nr].
+			LogicalDriveSize;
+	} else {
+		DAC960_V2_LogicalDeviceInfo_T *i =
+			p->V2.LogicalDeviceInformation[drive_nr];
+		if (i == NULL)
+			return 0;
+		return i->ConfigurableDeviceSize;
+	}
+}
 
-static DAC960_Controller_T
-  *DAC960_Controllers[DAC960_MaxControllers] =	{ NULL };
+static int DAC960_open(struct inode *inode, struct file *file)
+{
+	struct gendisk *disk = inode->i_bdev->bd_disk;
+	DAC960_Controller_T *p = disk->queue->queuedata;
+	int drive_nr = (int)disk->private_data;
 
+	/* bad hack for the "user" ioctls */
+	if (!p->ControllerNumber && !drive_nr && (file->f_flags & O_NONBLOCK))
+		return 0;
+
+	if (p->FirmwareType == DAC960_V1_Controller) {
+		if (p->V1.LogicalDriveInformation[drive_nr].
+		    LogicalDriveState == DAC960_V1_LogicalDrive_Offline)
+			return -ENXIO;
+	} else {
+		DAC960_V2_LogicalDeviceInfo_T *i =
+			p->V2.LogicalDeviceInformation[drive_nr];
+		if (i->LogicalDeviceState == DAC960_V2_LogicalDevice_Offline)
+			return -ENXIO;
+	}
 
-static int DAC960_revalidate(struct gendisk *);
-/*
-  DAC960_BlockDeviceOperations is the Block Device Operations structure for
-  DAC960 Logical Disk Devices.
-*/
+	check_disk_change(inode->i_bdev);
 
-static struct block_device_operations DAC960_BlockDeviceOperations = {
-	.owner		=THIS_MODULE,
-	.open		=DAC960_Open,
-	.release	=DAC960_Release,
-	.ioctl		=DAC960_IOCTL,
-	.revalidate_disk=DAC960_revalidate,
-};
+	if (!get_capacity(p->disks[drive_nr]))
+		return -ENXIO;
+	return 0;
+}
+
+static int DAC960_ioctl(struct inode *inode, struct file *file,
+			unsigned int cmd, unsigned long arg)
+{
+	struct gendisk *disk = inode->i_bdev->bd_disk;
+	DAC960_Controller_T *p = disk->queue->queuedata;
+	int drive_nr = (int)disk->private_data;
+	struct hd_geometry g, *loc = (struct hd_geometry *)arg;
 
+	if (file->f_flags & O_NONBLOCK)
+		return DAC960_UserIOCTL(inode, file, cmd, arg);
 
-/*
-  DAC960_ProcDirectoryEntry is the DAC960 /proc/rd directory entry.
-*/
+	if (cmd != HDIO_GETGEO || !loc)
+		return -EINVAL;
+
+	if (p->FirmwareType == DAC960_V1_Controller) {
+		g.heads = p->V1.GeometryTranslationHeads;
+		g.sectors = p->V1.GeometryTranslationSectors;
+		g.cylinders = p->V1.LogicalDriveInformation[drive_nr].
+			LogicalDriveSize / (g.heads * g.sectors);
+	} else {
+		DAC960_V2_LogicalDeviceInfo_T *i =
+			p->V2.LogicalDeviceInformation[drive_nr];
+		switch (i->DriveGeometry) {
+		case DAC960_V2_Geometry_128_32:
+			g.heads = 128;
+			g.sectors = 32;
+			break;
+		case DAC960_V2_Geometry_255_63:
+			g.heads = 255;
+			g.sectors = 63;
+			break;
+		default:
+			DAC960_Error("Illegal Logical Device Geometry %d\n",
+					p, i->DriveGeometry);
+			return -EINVAL;
+		}
+
+		g.cylinders = i->ConfigurableDeviceSize / (g.heads * g.sectors);
+	}
+	
+	g.start = get_start_sect(inode->i_bdev);
 
-static PROC_DirectoryEntry_T
-  *DAC960_ProcDirectoryEntry;
+	return copy_to_user(loc, &g, sizeof g) ? -EFAULT : 0; 
+}
+
+static int DAC960_media_changed(struct gendisk *disk)
+{
+	DAC960_Controller_T *p = disk->queue->queuedata;
+	int drive_nr = (int)disk->private_data;
+
+	if (!p->LogicalDriveInitiallyAccessible[drive_nr])
+		return 1;
+	return 0;
+}
+
+static int DAC960_revalidate_disk(struct gendisk *disk)
+{
+	DAC960_Controller_T *p = disk->queue->queuedata;
+	int unit = (int)disk->private_data;
+
+	set_capacity(disk, disk_size(p, unit));
+	return 0;
+}
+
+static struct block_device_operations DAC960_BlockDeviceOperations = {
+	.owner			= THIS_MODULE,
+	.open			= DAC960_open,
+	.ioctl			= DAC960_ioctl,
+	.media_changed		= DAC960_media_changed,
+	.revalidate_disk	= DAC960_revalidate_disk,
+};
 
 
 /*
@@ -1069,6 +1152,7 @@
   
   if (pci_set_dma_mask(Controller->PCIDevice, DAC690_V1_PciDmaMask))
 	return DAC960_Failure(Controller, "DMA mask out of range");
+  Controller->BounceBufferLimit = DAC690_V1_PciDmaMask;
 
   if ((hw_type == DAC960_PD_Controller) || (hw_type == DAC960_P_Controller)) {
     CommandMailboxesSize =  0;
@@ -1271,6 +1355,7 @@
 
   if (pci_set_dma_mask(Controller->PCIDevice, DAC690_V2_PciDmaMask))
 	return DAC960_Failure(Controller, "DMA mask out of range");
+  Controller->BounceBufferLimit = DAC690_V2_PciDmaMask;
 
   /* This is a temporary dma mapping, used only in the scope of this function */
   CommandMailbox =
@@ -2386,6 +2471,7 @@
   */
   RequestQueue = &Controller->RequestQueue;
   blk_init_queue(RequestQueue, DAC960_RequestFunction, &Controller->queue_lock);
+  blk_queue_bounce_limit(RequestQueue, Controller->BounceBufferLimit);
   RequestQueue->queuedata = Controller;
   blk_queue_max_hw_segments(RequestQueue,
 			    Controller->DriverScatterGatherLimit);
@@ -2430,21 +2516,6 @@
   blk_cleanup_queue(&Controller->RequestQueue);
 }
 
-static long disk_size(DAC960_Controller_T *Controller, int disk)
-{
-	if (Controller->FirmwareType == DAC960_V1_Controller) {
-		if (disk >= Controller->LogicalDriveCount)
-			return 0;
-		return Controller->V1.LogicalDriveInformation[disk].LogicalDriveSize;
-	} else {
-		DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo =
-			Controller->V2.LogicalDeviceInformation[disk];
-		if (LogicalDeviceInfo == NULL)
-			return 0;
-		return LogicalDeviceInfo->ConfigurableDeviceSize;
-	}
-}
-
 /*
   DAC960_ComputeGenericDiskInfo computes the values for the Generic Disk
   Information Partition Sector Counts and Block Sizes.
@@ -2457,14 +2528,6 @@
 		set_capacity(Controller->disks[disk], disk_size(Controller, disk));
 }
 
-static int DAC960_revalidate(struct gendisk *disk)
-{
-	DAC960_Controller_T *p = disk->queue->queuedata;
-	int unit = (int)disk->private_data;
-	set_capacity(disk, disk_size(p, unit));
-	return 0;
-}
-
 /*
   DAC960_ReportErrorStatus reports Controller BIOS Messages passed through
   the Error Status Register when the driver performs the BIOS handshaking.
@@ -2583,7 +2646,7 @@
 					const struct pci_device_id *entry)
 {
   struct DAC960_privdata *privdata = (struct DAC960_privdata *)entry->driver_data;
-  void (*InterruptHandler)(int, void *, Registers_T *) = privdata->InterruptHandler;
+  irqreturn_t (*InterruptHandler)(int, void *, Registers_T *) = privdata->InterruptHandler;
   unsigned int MemoryWindowSize = privdata->MemoryWindowSize;
   DAC960_Controller_T *Controller = NULL;
   unsigned char DeviceFunction = PCI_Device->devfn;
@@ -5109,7 +5172,7 @@
   Controllers.
 */
 
-static void DAC960_BA_InterruptHandler(int IRQ_Channel,
+static irqreturn_t DAC960_BA_InterruptHandler(int IRQ_Channel,
 				       void *DeviceIdentifier,
 				       Registers_T *InterruptRegisters)
 {
@@ -5117,6 +5180,7 @@
   void *ControllerBaseAddress = Controller->BaseAddress;
   DAC960_V2_StatusMailbox_T *NextStatusMailbox;
   ProcessorFlags_T ProcessorFlags;
+
   /*
     Acquire exclusive access to Controller.
   */
@@ -5151,6 +5215,7 @@
     Release exclusive access to Controller.
   */
   DAC960_ReleaseControllerLockIH(Controller, &ProcessorFlags);
+  return IRQ_HANDLED;
 }
 
 
@@ -5159,7 +5224,7 @@
   Controllers.
 */
 
-static void DAC960_LP_InterruptHandler(int IRQ_Channel,
+static irqreturn_t DAC960_LP_InterruptHandler(int IRQ_Channel,
 				       void *DeviceIdentifier,
 				       Registers_T *InterruptRegisters)
 {
@@ -5201,6 +5266,7 @@
     Release exclusive access to Controller.
   */
   DAC960_ReleaseControllerLockIH(Controller, &ProcessorFlags);
+  return IRQ_HANDLED;
 }
 
 
@@ -5209,7 +5275,7 @@
   Controllers.
 */
 
-static void DAC960_LA_InterruptHandler(int IRQ_Channel,
+static irqreturn_t DAC960_LA_InterruptHandler(int IRQ_Channel,
 				       void *DeviceIdentifier,
 				       Registers_T *InterruptRegisters)
 {
@@ -5247,6 +5313,7 @@
     Release exclusive access to Controller.
   */
   DAC960_ReleaseControllerLockIH(Controller, &ProcessorFlags);
+  return IRQ_HANDLED;
 }
 
 
@@ -5255,7 +5322,7 @@
   Controllers.
 */
 
-static void DAC960_PG_InterruptHandler(int IRQ_Channel,
+static irqreturn_t DAC960_PG_InterruptHandler(int IRQ_Channel,
 				       void *DeviceIdentifier,
 				       Registers_T *InterruptRegisters)
 {
@@ -5293,6 +5360,7 @@
     Release exclusive access to Controller.
   */
   DAC960_ReleaseControllerLockIH(Controller, &ProcessorFlags);
+  return IRQ_HANDLED;
 }
 
 
@@ -5301,7 +5369,7 @@
   Controllers.
 */
 
-static void DAC960_PD_InterruptHandler(int IRQ_Channel,
+static irqreturn_t DAC960_PD_InterruptHandler(int IRQ_Channel,
 				       void *DeviceIdentifier,
 				       Registers_T *InterruptRegisters)
 {
@@ -5335,6 +5403,7 @@
     Release exclusive access to Controller.
   */
   DAC960_ReleaseControllerLockIH(Controller, &ProcessorFlags);
+  return IRQ_HANDLED;
 }
 
 
@@ -5347,7 +5416,7 @@
   an arbitrary buffer.
 */
 
-static void DAC960_P_InterruptHandler(int IRQ_Channel,
+static irqreturn_t DAC960_P_InterruptHandler(int IRQ_Channel,
 				      void *DeviceIdentifier,
 				      Registers_T *InterruptRegisters)
 {
@@ -5416,6 +5485,7 @@
     Release exclusive access to Controller.
   */
   DAC960_ReleaseControllerLockIH(Controller, &ProcessorFlags);
+  return IRQ_HANDLED;
 }
 
 
@@ -5564,151 +5634,6 @@
       wake_up(&Controller->HealthStatusWaitQueue);
     }
 }
-
-
-/*
-  DAC960_Open is the Device Open Function for the DAC960 Driver.
-*/
-
-static int DAC960_Open(Inode_T *Inode, File_T *File)
-{
-  int ControllerNumber = DAC960_ControllerNumber(Inode->i_rdev);
-  int LogicalDriveNumber = DAC960_LogicalDriveNumber(Inode->i_rdev);
-  DAC960_Controller_T *Controller;
-  if (ControllerNumber == 0 && LogicalDriveNumber == 0 &&
-      (File->f_flags & O_NONBLOCK))
-    goto ModuleOnly;
-  if (ControllerNumber < 0 || ControllerNumber > DAC960_ControllerCount - 1)
-    return -ENXIO;
-  Controller = DAC960_Controllers[ControllerNumber];
-  if (Controller == NULL) return -ENXIO;
-  if (Controller->FirmwareType == DAC960_V1_Controller)
-    {
-      if (LogicalDriveNumber > Controller->LogicalDriveCount - 1)
-	return -ENXIO;
-      if (Controller->V1.LogicalDriveInformation
-			 [LogicalDriveNumber].LogicalDriveState
-	  == DAC960_V1_LogicalDrive_Offline)
-	return -ENXIO;
-    }
-  else
-    {
-      DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo =
-	Controller->V2.LogicalDeviceInformation[LogicalDriveNumber];
-      if (LogicalDeviceInfo == NULL ||
-	  LogicalDeviceInfo->LogicalDeviceState
-	  == DAC960_V2_LogicalDevice_Offline)
-	return -ENXIO;
-    }
-  if (!Controller->LogicalDriveInitiallyAccessible[LogicalDriveNumber])
-    {
-      long size;
-      Controller->LogicalDriveInitiallyAccessible[LogicalDriveNumber] = true;
-      size = disk_size(Controller, LogicalDriveNumber);
-      set_capacity(Controller->disks[LogicalDriveNumber], size);
-      Inode->i_bdev->bd_invalidated = 1;
-    }
-  if (!get_capacity(Controller->disks[LogicalDriveNumber]))
-    return -ENXIO;
-  /*
-    Increment Controller and Logical Drive Usage Counts.
-  */
-  Controller->ControllerUsageCount++;
-  Controller->LogicalDriveUsageCount[LogicalDriveNumber]++;
- ModuleOnly:
-  return 0;
-}
-
-
-/*
-  DAC960_Release is the Device Release Function for the DAC960 Driver.
-*/
-
-static int DAC960_Release(Inode_T *Inode, File_T *File)
-{
-  int ControllerNumber = DAC960_ControllerNumber(Inode->i_rdev);
-  int LogicalDriveNumber = DAC960_LogicalDriveNumber(Inode->i_rdev);
-  DAC960_Controller_T *Controller = DAC960_Controllers[ControllerNumber];
-  if (ControllerNumber == 0 && LogicalDriveNumber == 0 &&
-      File != NULL && (File->f_flags & O_NONBLOCK))
-    goto ModuleOnly;
-  /*
-    Decrement the Logical Drive and Controller Usage Counts.
-  */
-  Controller->LogicalDriveUsageCount[LogicalDriveNumber]--;
-  Controller->ControllerUsageCount--;
- ModuleOnly:
-  return 0;
-}
-
-
-/*
-  DAC960_IOCTL is the Device IOCTL Function for the DAC960 Driver.
-*/
-
-static int DAC960_IOCTL(Inode_T *Inode, File_T *File,
-			unsigned int Request, unsigned long Argument)
-{
-  int ControllerNumber = DAC960_ControllerNumber(Inode->i_rdev);
-  int LogicalDriveNumber = DAC960_LogicalDriveNumber(Inode->i_rdev);
-  DiskGeometry_T Geometry, *UserGeometry;
-  DAC960_Controller_T *Controller;
-
-  if (File != NULL && (File->f_flags & O_NONBLOCK))
-    return DAC960_UserIOCTL(Inode, File, Request, Argument);
-  if (ControllerNumber < 0 || ControllerNumber > DAC960_ControllerCount - 1)
-    return -ENXIO;
-  Controller = DAC960_Controllers[ControllerNumber];
-  if (Controller == NULL) return -ENXIO;
-  switch (Request)
-    {
-    case HDIO_GETGEO:
-      /* Get BIOS Disk Geometry. */
-      UserGeometry = (DiskGeometry_T *) Argument;
-      if (UserGeometry == NULL) return -EINVAL;
-      if (Controller->FirmwareType == DAC960_V1_Controller)
-	{
-	  if (LogicalDriveNumber > Controller->LogicalDriveCount - 1)
-	    return -ENXIO;
-	  Geometry.heads = Controller->V1.GeometryTranslationHeads;
-	  Geometry.sectors = Controller->V1.GeometryTranslationSectors;
-	  Geometry.cylinders =
-	    Controller->V1.LogicalDriveInformation[LogicalDriveNumber]
-						  .LogicalDriveSize
-	    / (Geometry.heads * Geometry.sectors);
-	}
-      else
-	{
-	  DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo =
-	    Controller->V2.LogicalDeviceInformation[LogicalDriveNumber];
-	  if (LogicalDeviceInfo == NULL)
-	    return -EINVAL;
-	  switch (LogicalDeviceInfo->DriveGeometry)
-	    {
-	    case DAC960_V2_Geometry_128_32:
-	      Geometry.heads = 128;
-	      Geometry.sectors = 32;
-	      break;
-	    case DAC960_V2_Geometry_255_63:
-	      Geometry.heads = 255;
-	      Geometry.sectors = 63;
-	      break;
-	    default:
-	      DAC960_Error("Illegal Logical Device Geometry %d\n",
-			   Controller, LogicalDeviceInfo->DriveGeometry);
-	      return -EINVAL;
-	    }
-	  Geometry.cylinders =
-	    LogicalDeviceInfo->ConfigurableDeviceSize
-	    / (Geometry.heads * Geometry.sectors);
-	}
-      Geometry.start = get_start_sect(Inode->i_bdev);
-      return (copy_to_user(UserGeometry, &Geometry,
-			   sizeof(DiskGeometry_T)) ? -EFAULT : 0);
-    }
-  return -EINVAL;
-}
-
 
 /*
   DAC960_UserIOCTL is the User IOCTL Function for the DAC960 Driver.
diff -Nru a/drivers/block/DAC960.h b/drivers/block/DAC960.h
--- a/drivers/block/DAC960.h	Wed Apr 30 22:28:14 2003
+++ b/drivers/block/DAC960.h	Wed Apr 30 22:28:14 2003
@@ -62,11 +62,6 @@
 
 /*
   Define the pci dma mask supported by DAC960 V1 and V2 Firmware Controlers
-
-  For now set the V2 mask to only 32 bits.  The controller IS capable
-  of doing 64 bit dma.  But I have yet to find out whether this needs to
-  be explicitely enabled in the controller, or of the controller adapts
-  automatically.
  */
 
 #define DAC690_V1_PciDmaMask	0xffffffff
@@ -2234,7 +2229,7 @@
 struct DAC960_privdata {
 	DAC960_HardwareType_T	HardwareType;
 	DAC960_FirmwareType_T	FirmwareType;
-	void (*InterruptHandler)(int, void *, Registers_T *);
+	irqreturn_t (*InterruptHandler)(int, void *, Registers_T *);
 	unsigned int		MemoryWindowSize;
 };
 
@@ -2369,7 +2364,7 @@
   unsigned short MaxBlocksPerCommand;
   unsigned short ControllerScatterGatherLimit;
   unsigned short DriverScatterGatherLimit;
-  unsigned int ControllerUsageCount;
+  u64		BounceBufferLimit;
   unsigned int CombinedStatusBufferLength;
   unsigned int InitialStatusLength;
   unsigned int CurrentStatusLength;
@@ -2401,7 +2396,6 @@
   DAC960_Command_T InitialCommand;
   DAC960_Command_T *Commands[DAC960_MaxDriverQueueDepth];
   PROC_DirectoryEntry_T *ControllerProcEntry;
-  unsigned int LogicalDriveUsageCount[DAC960_MaxLogicalDrives];
   boolean LogicalDriveInitiallyAccessible[DAC960_MaxLogicalDrives];
   void (*QueueCommand)(DAC960_Command_T *Command);
   boolean (*ReadControllerConfiguration)(struct DAC960_Controller *);
@@ -4237,18 +4231,15 @@
 static void DAC960_V1_QueueReadWriteCommand(DAC960_Command_T *);
 static void DAC960_V2_QueueReadWriteCommand(DAC960_Command_T *); 
 static void DAC960_RequestFunction(RequestQueue_T *);
-static void DAC960_BA_InterruptHandler(int, void *, Registers_T *);
-static void DAC960_LP_InterruptHandler(int, void *, Registers_T *);
-static void DAC960_LA_InterruptHandler(int, void *, Registers_T *);
-static void DAC960_PG_InterruptHandler(int, void *, Registers_T *);
-static void DAC960_PD_InterruptHandler(int, void *, Registers_T *);
-static void DAC960_P_InterruptHandler(int, void *, Registers_T *);
+static irqreturn_t DAC960_BA_InterruptHandler(int, void *, Registers_T *);
+static irqreturn_t DAC960_LP_InterruptHandler(int, void *, Registers_T *);
+static irqreturn_t DAC960_LA_InterruptHandler(int, void *, Registers_T *);
+static irqreturn_t DAC960_PG_InterruptHandler(int, void *, Registers_T *);
+static irqreturn_t DAC960_PD_InterruptHandler(int, void *, Registers_T *);
+static irqreturn_t DAC960_P_InterruptHandler(int, void *, Registers_T *);
 static void DAC960_V1_QueueMonitoringCommand(DAC960_Command_T *);
 static void DAC960_V2_QueueMonitoringCommand(DAC960_Command_T *);
 static void DAC960_MonitoringTimerFunction(unsigned long);
-static int DAC960_Open(Inode_T *, File_T *);
-static int DAC960_Release(Inode_T *, File_T *);
-static int DAC960_IOCTL(Inode_T *, File_T *, unsigned int, unsigned long);
 static int DAC960_UserIOCTL(Inode_T *, File_T *, unsigned int, unsigned long);
 static void DAC960_Message(DAC960_MessageLevel_T, unsigned char *,
 			   DAC960_Controller_T *, ...);
diff -Nru a/drivers/block/Kconfig b/drivers/block/Kconfig
--- a/drivers/block/Kconfig	Wed Apr 30 22:28:05 2003
+++ b/drivers/block/Kconfig	Wed Apr 30 22:28:05 2003
@@ -331,7 +331,6 @@
 
 config BLK_DEV_INITRD
 	bool "Initial RAM disk (initrd) support"
-	depends on BLK_DEV_RAM=y
 	help
 	  The initial RAM disk is a RAM disk that is loaded by the boot loader
 	  (loadlin or lilo) and that is mounted as root before the normal boot
diff -Nru a/drivers/block/Makefile b/drivers/block/Makefile
--- a/drivers/block/Makefile	Wed Apr 30 22:28:15 2003
+++ b/drivers/block/Makefile	Wed Apr 30 22:28:15 2003
@@ -20,6 +20,7 @@
 obj-$(CONFIG_ATARI_SLM)		+= acsi_slm.o
 obj-$(CONFIG_AMIGA_Z2RAM)	+= z2ram.o
 obj-$(CONFIG_BLK_DEV_RAM)	+= rd.o
+obj-$(CONFIG_BLK_DEV_INITRD)	+= initrd.o
 obj-$(CONFIG_BLK_DEV_LOOP)	+= loop.o
 obj-$(CONFIG_BLK_DEV_PS2)	+= ps2esdi.o
 obj-$(CONFIG_BLK_DEV_XD)	+= xd.o
diff -Nru a/drivers/block/amiflop.c b/drivers/block/amiflop.c
--- a/drivers/block/amiflop.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/block/amiflop.c	Wed Apr 30 22:28:09 2003
@@ -1496,7 +1496,7 @@
 		break;
 	case FDFMTEND:
 		floppy_off(drive);
-		invalidate_device(inode->i_rdev, 0);
+		invalidate_bdev(inode->i_bdev, 0);
 		break;
 	case FDGETPRM:
 		memset((void *)&getprm, 0, sizeof (getprm));
@@ -1603,9 +1603,6 @@
 		MOD_INC_USE_COUNT;
 #endif
 	local_irq_restore(flags);
-
-	if (old_dev != system)
-		invalidate_buffers(mk_kdev(FLOPPY_MAJOR, drive + (system << 2)));
 
 	unit[drive].dtype=&data_types[system];
 	unit[drive].blocks=unit[drive].type->heads*unit[drive].type->tracks*
diff -Nru a/drivers/block/ataflop.c b/drivers/block/ataflop.c
--- a/drivers/block/ataflop.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/block/ataflop.c	Wed Apr 30 22:28:05 2003
@@ -237,6 +237,8 @@
 				   disk change detection) */
 	int flags;		/* flags */
 	struct gendisk *disk;
+	int ref;
+	int type;
 } unit[FD_MAX_UNITS];
 
 #define	UD	unit[drive]
@@ -364,7 +366,7 @@
 static __inline__ int get_head_settle_flag( void );
 static void floppy_irq (int irq, void *dummy, struct pt_regs *fp);
 static void fd_error( void );
-static int do_format(kdev_t drive, struct atari_format_descr *desc);
+static int do_format(int drive, int type, struct atari_format_descr *desc);
 static void do_fd_action( int drive );
 static void fd_calibrate( void );
 static void fd_calibrate_done( int status );
@@ -656,12 +658,11 @@
 	p += n;			\
     } while(0)
 
-static int do_format(kdev_t device, struct atari_format_descr *desc)
+static int do_format(int drive, int type, struct atari_format_descr *desc)
 {
 	unsigned char	*p;
 	int sect, nsect;
 	unsigned long	flags;
-	int type, drive = minor(device) & 3;
 
 	DPRINT(("do_format( dr=%d tr=%d he=%d offs=%d )\n",
 		drive, desc->track, desc->head, desc->sect_offset ));
@@ -673,7 +674,6 @@
 	atari_turnon_irq( IRQ_MFP_FDC ); /* should be already, just to be sure */
 	local_irq_restore(flags);
 
-	type = minor(device) >> 2;
 	if (type) {
 		if (--type >= NUM_DISK_MINORS ||
 		    minor2disktype[type].drive_types > DriveType) {
@@ -1330,12 +1330,6 @@
 	DPRINT(("finish_fdc() finished\n"));
 }
 
-
-/* Prevent "aliased" accesses. */
-static int fd_ref[4] = { 0,0,0,0 };
-static int fd_device[4] = { 0,0,0,0 };
-
-
 /* The detection of disk changes is a dark chapter in Atari history :-(
  * Because the "Drive ready" signal isn't present in the Atari
  * hardware, one has to rely on the "Write Protect". This works fine,
@@ -1380,7 +1374,7 @@
 
 	if (test_bit(drive, &changed_floppies) ||
 	    test_bit(drive, &fake_change) ||
-	    unit[drive].disktype == 0) {
+	    p->disktype == 0) {
 		if (UD.flags & FTD_MSG)
 			printk(KERN_ERR "floppy: clear format %p!\n", UDT);
 		BufferDrive = -1;
@@ -1447,7 +1441,7 @@
 
 	floppy = CURRENT->rq_disk->private_data;
 	drive = floppy - unit;
-	type = fd_device[drive];
+	type = floppy->type;
 	
 	if (!UD.connected) {
 		/* drive not connected */
@@ -1460,7 +1454,7 @@
 		if (!UDT) {
 			Probing = 1;
 			UDT = disk_type + StartDiskType[DriveType];
-			set_capacity(unit[drive].disk, UDT->blocks);
+			set_capacity(floppy->disk, UDT->blocks);
 			UD.autoprobe = 1;
 		}
 	} 
@@ -1478,7 +1472,7 @@
 		}
 		type = minor2disktype[type].index;
 		UDT = &disk_type[type];
-		set_capacity(unit[drive].disk, UDT->blocks);
+		set_capacity(floppy->disk, UDT->blocks);
 		UD.autoprobe = 0;
 	}
 	
@@ -1524,19 +1518,16 @@
 static int fd_ioctl(struct inode *inode, struct file *filp,
 		    unsigned int cmd, unsigned long param)
 {
-	int drive, type;
-	kdev_t device;
 	struct gendisk *disk = inode->i_bdev->bd_disk;
+	struct atari_floppy_struct *floppy = disk->private_data;
+	int drive = floppy - unit;
+	int type = floppy->type;
 	struct atari_format_descr fmt_desc;
 	struct atari_disk_type *dtp;
 	struct floppy_struct getprm;
 	int settype;
 	struct floppy_struct setprm;
 
-	device = inode->i_rdev;
-	drive = minor (device);
-	type  = drive >> 2;
-	drive &= 3;
 	switch (cmd) {
 	case FDGETPRM:
 		if (type) {
@@ -1579,7 +1570,7 @@
 		 */
 
 		/* get the parameters from user space */
-		if (fd_ref[drive] != 1 && fd_ref[drive] != -1)
+		if (p->ref != 1 && p->ref != -1)
 			return -EBUSY;
 		if (copy_from_user(&setprm, (void *) param, sizeof(setprm)))
 			return -EFAULT;
@@ -1626,7 +1617,7 @@
 				    printk (KERN_INFO "floppy%d: setting %s %p!\n",
 				        drive, dtp->name, dtp);
 				UDT = dtp;
-				set_capacity(unit[drive].disk, UDT->blocks);
+				set_capacity(p->disk, UDT->blocks);
 
 				if (cmd == FDDEFPRM) {
 				  /* save settings as permanent default type */
@@ -1672,7 +1663,7 @@
 		}
 
 		UDT = dtp;
-		set_capacity(unit[drive].disk, UDT->blocks);
+		set_capacity(p->disk, UDT->blocks);
 
 		return 0;
 	case FDMSGON:
@@ -1686,16 +1677,16 @@
 	case FDFMTBEG:
 		return 0;
 	case FDFMTTRK:
-		if (fd_ref[drive] != 1 && fd_ref[drive] != -1)
+		if (p->ref != 1 && p->ref != -1)
 			return -EBUSY;
 		if (copy_from_user(&fmt_desc, (void *) param, sizeof(fmt_desc)))
 			return -EFAULT;
-		return do_format(device, &fmt_desc);
+		return do_format(drive, type, &fmt_desc);
 	case FDCLRPRM:
 		UDT = NULL;
 		/* MSch: invalidate default_params */
 		default_params[drive].blocks  = 0;
-		set_capacity(unit[drive].disk, MAX_DISK_SIZE * 2);
+		set_capacity(p->disk, MAX_DISK_SIZE * 2);
 	case FDFMTEND:
 	case FDFLUSH:
 		/* invalidate the buffer track to force a reread */
@@ -1846,26 +1837,22 @@
 
 static int floppy_open( struct inode *inode, struct file *filp )
 {
-	int drive = minor(inode->i_rdev) & 3;
+	struct atari_floppy_struct *p = inode->i_bdev->bd_disk->private_data;
 	int type  = minor(inode->i_rdev) >> 2;
-	int old_dev = fd_device[drive];
 
 	DPRINT(("fd_open: type=%d\n",type));
-	if (fd_ref[drive] && old_dev != type)
+	if (p->ref && p->type != type)
 		return -EBUSY;
 
-	if (fd_ref[drive] == -1 || (fd_ref[drive] && filp->f_flags & O_EXCL))
+	if (p->ref == -1 || (p->ref && filp->f_flags & O_EXCL))
 		return -EBUSY;
 
 	if (filp->f_flags & O_EXCL)
-		fd_ref[drive] = -1;
+		p->ref = -1;
 	else
-		fd_ref[drive]++;
-
-	fd_device[drive] = type;
+		p->ref++;
 
-	if (old_dev && old_dev != type)
-		invalidate_buffers(mk_kdev(FLOPPY_MAJOR, drive + (type<<2)));
+	p->type = type;
 
 	if (filp->f_flags & O_NDELAY)
 		return 0;
@@ -1873,28 +1860,29 @@
 	if (filp->f_mode & 3) {
 		check_disk_change(inode->i_bdev);
 		if (filp->f_mode & 2) {
-			if (UD.wpstat) {
+			if (p->wpstat) {
+				if (p->ref < 0)
+					p->ref = 0;
+				else
+					p->ref--;
 				floppy_release(inode, filp);
 				return -EROFS;
 			}
 		}
 	}
-
 	return 0;
 }
 
 
 static int floppy_release( struct inode * inode, struct file * filp )
 {
-	int drive = minor(inode->i_rdev) & 3;
-
-	if (fd_ref[drive] < 0)
-		fd_ref[drive] = 0;
-	else if (!fd_ref[drive]--) {
+	struct atari_floppy_struct *p = inode->i_bdev->bd_disk->private_data;
+	if (p->ref < 0)
+		p->ref = 0;
+	else if (!p->ref--) {
 		printk(KERN_ERR "floppy_release with fd_ref == 0");
-		fd_ref[drive] = 0;
+		p->ref = 0;
 	}
-
 	return 0;
 }
 
@@ -1917,7 +1905,7 @@
 	return get_disk(unit[drive].disk);
 }
 
-int __init atari_floppy_init (void)
+static int __init atari_floppy_init (void)
 {
 	int i;
 
@@ -2019,18 +2007,7 @@
 	}
 }
 
-#ifdef MODULE
-
-MODULE_LICENSE("GPL");
-
-int init_module (void)
-{
-	if (!MACH_IS_ATARI)
-		return -ENXIO;
-	return atari_floppy_init ();
-}
-
-void cleanup_module (void)
+static void atari_floppy_exit(void)
 {
 	int i;
 	blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
@@ -2044,5 +2021,8 @@
 	del_timer_sync(&fd_timer);
 	atari_stram_free( DMABuffer );
 }
-#endif
 
+module_init(atari_floppy_init)
+module_exit(atari_floppy_exit)
+
+MODULE_LICENSE("GPL");
diff -Nru a/drivers/block/cciss.c b/drivers/block/cciss.c
--- a/drivers/block/cciss.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/block/cciss.c	Wed Apr 30 22:28:18 2003
@@ -599,9 +599,12 @@
  		luninfo.num_opens = drv->usage_count;
  		luninfo.num_parts = 0;
  		/* count partitions 1 to 15 with sizes > 0 */
- 		for(i=1; i <MAX_PART; i++)
- 			if (disk->part[i].nr_sects != 0)
- 				luninfo.num_parts++;
+ 		for(i=1; i <MAX_PART; i++) {
+			if (!disk->part[i])
+				continue;
+			if (disk->part[i]->nr_sects != 0)
+				luninfo.num_parts++;
+		}
  		if (copy_to_user((void *) arg, &luninfo,
  				sizeof(LogvolInfo_struct)))
  			return -EFAULT;
@@ -1962,7 +1965,7 @@
 	start_io(h);
 }
 
-static void do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	ctlr_info_t *h = dev_id;
 	CommandList_struct *c;
@@ -1972,7 +1975,7 @@
 
 	/* Is this interrupt for us? */
 	if ( h->access.intr_pending(h) == 0)
-		return;
+		return IRQ_NONE;
 
 	/*
 	 * If there are completed commands in the completion queue,
@@ -2020,6 +2023,7 @@
 	 */
 	spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
 	blk_start_queue(&h->queue);
+	return IRQ_HANDLED;
 }
 /* 
  *  We cannot read the structure directly, for portablity we must use 
diff -Nru a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
--- a/drivers/block/cpqarray.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/block/cpqarray.c	Wed Apr 30 22:28:05 2003
@@ -144,7 +144,7 @@
 static inline void complete_buffers(struct bio *bio, int ok);
 static inline void complete_command(cmdlist_t *cmd, int timeout);
 
-static void do_ida_intr(int irq, void *dev_id, struct pt_regs * regs);
+static irqreturn_t do_ida_intr(int irq, void *dev_id, struct pt_regs * regs);
 static void ida_timer(unsigned long tdata);
 static int ida_revalidate(struct gendisk *disk);
 static int revalidate_allvol(kdev_t dev);
@@ -929,7 +929,7 @@
  *  Find the command on the completion queue, remove it, tell the OS and
  *  try to queue up more IO
  */
-static void do_ida_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t do_ida_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	ctlr_info_t *h = dev_id;
 	cmdlist_t *c;
@@ -940,7 +940,7 @@
 	istat = h->access.intr_pending(h);
 	/* Is this interrupt for us? */
 	if (istat == 0)
-		return;
+		return IRQ_NONE;
 
 	/*
 	 * If there are completed commands in the completion queue,
@@ -991,6 +991,7 @@
 	 */
 	do_ida_request(&h->queue);
 	spin_unlock_irqrestore(IDA_LOCK(h->ctlr), flags); 
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/block/floppy.c b/drivers/block/floppy.c
--- a/drivers/block/floppy.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/block/floppy.c	Wed Apr 30 22:28:05 2003
@@ -217,7 +217,7 @@
 static spinlock_t floppy_lock = SPIN_LOCK_UNLOCKED;
 
 static unsigned short virtual_dma_port=0x3f0;
-void floppy_interrupt(int irq, void *dev_id, struct pt_regs * regs);
+irqreturn_t floppy_interrupt(int irq, void *dev_id, struct pt_regs * regs);
 static int set_dor(int fdc, char mask, char data);
 static void register_devfs_entries (int drive) __init;
 
@@ -283,12 +283,6 @@
 static unsigned long fake_change;
 static int initialising=1;
 
-static inline int TYPE(kdev_t x) {
-	return  (minor(x)>>2) & 0x1f;
-}
-static inline int DRIVE(kdev_t x) {
-	return (minor(x)&0x03) | ((minor(x)&0x80) >> 5);
-}
 #define ITYPE(x) (((x)>>2) & 0x1f)
 #define TOMINOR(x) ((x & 3) | ((x & 4) << 5))
 #define UNIT(x) ((x) & 0x03)		/* drive on fdc */
@@ -415,6 +409,8 @@
 static struct floppy_write_errors write_errors[N_DRIVE];
 static struct timer_list motor_off_timer[N_DRIVE];
 static struct gendisk *disks[N_DRIVE];
+static struct block_device *opened_bdev[N_DRIVE];
+static DECLARE_MUTEX(open_lock);
 static struct floppy_raw_cmd *raw_cmd, default_raw_cmd;
 
 /*
@@ -1743,7 +1739,7 @@
 }
 
 /* interrupt handler. Note that this can be called externally on the Sparc */
-void floppy_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+irqreturn_t floppy_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
 	void (*handler)(void) = do_floppy;
 	int do_print;
@@ -1764,7 +1760,7 @@
 		printk("floppy interrupt on bizarre fdc %d\n",fdc);
 		printk("handler=%p\n", handler);
 		is_alive("bizarre fdc");
-		return;
+		return IRQ_NONE;
 	}
 
 	FDCS->reset = 0;
@@ -1797,6 +1793,9 @@
 	} else
 		FDCS->reset = 1;
 	is_alive("normal interrupt end");
+
+	/* FIXME! Was it really for us? */
+	return IRQ_HANDLED;
 }
 
 static void recalibrate_floppy(void)
@@ -2263,10 +2262,9 @@
 	bad_flp_intr,
 	generic_done };
 
-static int do_format(kdev_t device, struct format_descr *tmp_format_req)
+static int do_format(int drive, struct format_descr *tmp_format_req)
 {
 	int ret;
-	int drive=DRIVE(device);
 
 	LOCK_FDC(drive,1);
 	set_floppy(drive);
@@ -2293,7 +2291,7 @@
  * =============================
  */
 
-static inline void end_request(struct request *req, int uptodate)
+static void floppy_end_request(struct request *req, int uptodate)
 {
 	if (end_that_request_first(req, uptodate, current_count_sectors))
 		return;
@@ -2334,7 +2332,7 @@
 
 		/* unlock chained buffers */
 		spin_lock_irqsave(q->queue_lock, flags);
-		end_request(req, 1);
+		floppy_end_request(req, 1);
 		spin_unlock_irqrestore(q->queue_lock, flags);
 	} else {
 		if (rq_data_dir(req) == WRITE) {
@@ -2348,7 +2346,7 @@
 			DRWE->last_error_generation = DRS->generation;
 		}
 		spin_lock_irqsave(q->queue_lock, flags);
-		end_request(req, 0);
+		floppy_end_request(req, 0);
 		spin_unlock_irqrestore(q->queue_lock, flags);
 	}
 }
@@ -3330,25 +3328,21 @@
 	if (type){
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
+		down(&open_lock);
 		LOCK_FDC(drive,1);
-		for (cnt = 0; cnt < N_DRIVE; cnt++){
-			if (ITYPE(drive_state[cnt].fd_device) == type &&
-			    drive_state[cnt].fd_ref)
-				set_bit(drive, &fake_change);
-		}
 		floppy_type[type] = *g;
 		floppy_type[type].name="user format";
 		for (cnt = type << 2; cnt < (type << 2) + 4; cnt++)
 			floppy_sizes[cnt]= floppy_sizes[cnt+0x80]=
 				floppy_type[type].size+1;
 		process_fd_request();
-		for (cnt = 0; cnt < N_DRIVE; cnt++){
-			if (ITYPE(drive_state[cnt].fd_device) == type &&
-			    drive_state[cnt].fd_ref)
-				__check_disk_change(
-					MKDEV(FLOPPY_MAJOR,
-					      drive_state[cnt].fd_device));
+		for (cnt = 0; cnt < N_DRIVE; cnt++) {
+			struct block_device *bdev = opened_bdev[cnt];
+			if (!bdev || ITYPE(drive_state[cnt].fd_device) != type)
+				continue;
+			__invalidate_device(bdev, 0);
 		}
+		up(&open_lock);
 	} else {
 		LOCK_FDC(drive,1);
 		if (cmd != FDDEFPRM)
@@ -3446,8 +3440,8 @@
 #define OUT(c,x) case c: outparam = (const char *) (x); break
 #define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0
 
-	int i,drive,type;
-	kdev_t device;
+	int drive = (long)inode->i_bdev->bd_disk->private_data;
+	int i, type = ITYPE(UDRS->fd_device);
 	int ret;
 	int size;
 	union inparam {
@@ -3458,9 +3452,6 @@
 	} inparam; /* parameters coming from user space */
 	const char *outparam; /* parameters passed back to user space */
 
-	device = inode->i_rdev;
-	type = TYPE(device);
-	drive = DRIVE(device);
 
 	/* convert compatibility eject ioctls into floppy eject ioctl.
 	 * We do this in order to provide a means to eject floppy disks before
@@ -3556,7 +3547,7 @@
 		case FDFMTTRK:
 			if (UDRS->fd_ref != 1)
 				return -EBUSY;
-			return do_format(device, &inparam.f);
+			return do_format(drive, &inparam.f);
 		case FDFMTEND:
 		case FDFLUSH:
 			LOCK_FDC(drive,1);
@@ -3673,15 +3664,19 @@
 
 static int floppy_release(struct inode * inode, struct file * filp)
 {
-	int drive = DRIVE(inode->i_rdev);
+	int drive = (long)inode->i_bdev->bd_disk->private_data;
 
+	down(&open_lock);
 	if (UDRS->fd_ref < 0)
 		UDRS->fd_ref=0;
 	else if (!UDRS->fd_ref--) {
 		DPRINT("floppy_release with fd_ref == 0");
 		UDRS->fd_ref = 0;
 	}
+	if (!UDRS->fd_ref)
+		opened_bdev[drive] = NULL;
 	floppy_release_irq_and_dma();
+	up(&open_lock);
 	return 0;
 }
 
@@ -3690,28 +3685,19 @@
  * /dev/PS0 etc), and disallows simultaneous access to the same
  * drive with different device numbers.
  */
-#define RETERR(x) do{floppy_release(inode,filp); return -(x);}while(0)
-
 static int floppy_open(struct inode * inode, struct file * filp)
 {
-	int drive;
+	int drive = (long)inode->i_bdev->bd_disk->private_data;
 	int old_dev;
 	int try;
+	int res = -EBUSY;
 	char *tmp;
 
 	filp->private_data = (void*) 0;
-
-	drive = DRIVE(inode->i_rdev);
-	if (drive >= N_DRIVE ||
-	    !(allowed_drive_mask & (1 << drive)) ||
-	    fdc_state[FDC(drive)].version == FDC_NONE)
-		return -ENXIO;
-
-	if (TYPE(inode->i_rdev) >= NUMBER(floppy_type))
-		return -ENXIO;
+	down(&open_lock);
 	old_dev = UDRS->fd_device;
-	if (UDRS->fd_ref && old_dev != minor(inode->i_rdev))
-		return -EBUSY;
+	if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev)
+		goto out2;
 
 	if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)){
 		USETF(FD_DISK_CHANGED);
@@ -3720,16 +3706,20 @@
 
 	if (UDRS->fd_ref == -1 ||
 	   (UDRS->fd_ref && (filp->f_flags & O_EXCL)))
-		return -EBUSY;
+		goto out2;
 
 	if (floppy_grab_irq_and_dma())
-		return -EBUSY;
+		goto out2;
 
 	if (filp->f_flags & O_EXCL)
 		UDRS->fd_ref = -1;
 	else
 		UDRS->fd_ref++;
 
+	opened_bdev[drive] = inode->i_bdev;
+
+	res = -ENXIO;
+
 	if (!floppy_track_buffer){
 		/* if opening an ED drive, reserve a big buffer,
 		 * else reserve a small one */
@@ -3749,7 +3739,7 @@
 		}
 		if (!tmp && !floppy_track_buffer) {
 			DPRINT("Unable to allocate DMA memory\n");
-			RETERR(ENXIO);
+			goto out;
 		}
 		if (floppy_track_buffer) {
 			if (tmp)
@@ -3766,8 +3756,6 @@
 	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));
 	}
 
 	/* Allow ioctls if we have write-permissions even if read-only open.
@@ -3780,18 +3768,30 @@
 	if (UFDCS->rawcmd == 1)
 		UFDCS->rawcmd = 2;
 
-	if (filp->f_flags & O_NDELAY)
-		return 0;
-	if (filp->f_mode & 3) {
-		UDRS->last_checked = 0;
-		check_disk_change(inode->i_bdev);
-		if (UTESTF(FD_DISK_CHANGED))
-			RETERR(ENXIO);
+	if (!filp->f_flags & O_NDELAY) {
+		if (filp->f_mode & 3) {
+			UDRS->last_checked = 0;
+			check_disk_change(inode->i_bdev);
+			if (UTESTF(FD_DISK_CHANGED))
+				goto out;
+		}
+		res = -EROFS;
+		if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE)))
+			goto out;
 	}
-	if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE)))
-		RETERR(EROFS);
+	up(&open_lock);
 	return 0;
-#undef RETERR
+out:
+	if (UDRS->fd_ref < 0)
+		UDRS->fd_ref=0;
+	else
+		UDRS->fd_ref--;
+	if (!UDRS->fd_ref)
+		opened_bdev[drive] = NULL;
+	floppy_release_irq_and_dma();
+out2:
+	up(&open_lock);
+	return res;
 }
 
 /*
@@ -3885,7 +3885,7 @@
 	struct block_device *bdev;
 	int ret;
 
-	bdev = bdget(MKDEV(disk->major, disk->first_minor));
+	bdev = bdget_disk(disk, 0);
 	if (!bdev) {
 		printk("No block device for %s\n", disk->disk_name);
 		BUG();
@@ -3965,21 +3965,19 @@
 
 static void __init register_devfs_entries (int drive)
 {
-    int base_minor, i;
+	int base_minor = (drive < 4) ? drive : (124 + drive);
 
-    base_minor = (drive < 4) ? drive : (124 + drive);
-    if (UDP->cmos < NUMBER(default_drive_params)) {
-	i = 0;
-	do {
-	    char name[16];
-
-	    sprintf(name, "floppy/%d%s", drive, table[table_sup[UDP->cmos][i]]);
-	    devfs_register(NULL, name, DEVFS_FL_DEFAULT, FLOPPY_MAJOR,
-			    base_minor + (table_sup[UDP->cmos][i] << 2),
-			    S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP |S_IWGRP,
-			    &floppy_fops, NULL);
-	} while (table_sup[UDP->cmos][i++]);
-    }
+	if (UDP->cmos < NUMBER(default_drive_params)) {
+		int i = 0;
+		do {
+			int minor = base_minor + (table_sup[UDP->cmos][i] << 2);
+
+			devfs_mk_bdev(MKDEV(FLOPPY_MAJOR, minor), 
+					S_IFBLK|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP,
+					"floppy/%d%s",
+					drive, table[table_sup[UDP->cmos][i]]);
+		} while (table_sup[UDP->cmos][i++]);
+	}
 }
 
 /*
@@ -4215,6 +4213,8 @@
 	if (drive >= N_DRIVE ||
 	    !(allowed_drive_mask & (1 << drive)) ||
 	    fdc_state[FDC(drive)].version == FDC_NONE)
+		return NULL;
+	if (((*part >> 2) & 0x1f) >= NUMBER(floppy_type))
 		return NULL;
 	*part = 0;
 	return get_disk(disks[drive]);
diff -Nru a/drivers/block/floppy98.c b/drivers/block/floppy98.c
--- a/drivers/block/floppy98.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/block/floppy98.c	Wed Apr 30 22:28:07 2003
@@ -318,12 +318,6 @@
 static unsigned long fake_change;
 static int initialising=1;
 
-static inline int TYPE(kdev_t x) {
-	return  (minor(x)>>2) & 0x1f;
-}
-static inline int DRIVE(kdev_t x) {
-	return (minor(x)&0x03) | ((minor(x)&0x80) >> 5);
-}
 #define ITYPE(x) (((x)>>2) & 0x1f)
 #define TOMINOR(x) ((x & 3) | ((x & 4) << 5))
 #define UNIT(x) ((x) & 0x03)		/* drive on fdc */
@@ -450,6 +444,8 @@
 static struct floppy_write_errors write_errors[N_DRIVE];
 static struct timer_list motor_off_timer[N_DRIVE];
 static struct gendisk *disks[N_DRIVE];
+static struct block_device *opened_bdev[N_DRIVE];
+static DECLARE_MUTEX(open_lock);
 static struct floppy_raw_cmd *raw_cmd, default_raw_cmd;
 
 /*
@@ -2318,10 +2314,9 @@
 	bad_flp_intr,
 	generic_done };
 
-static int do_format(kdev_t device, struct format_descr *tmp_format_req)
+static int do_format(int drive, struct format_descr *tmp_format_req)
 {
 	int ret;
-	int drive=DRIVE(device);
 
 	LOCK_FDC(drive,1);
 	set_floppy(drive);
@@ -2348,7 +2343,7 @@
  * =============================
  */
 
-static inline void end_request(struct request *req, int uptodate)
+static void floppy_end_request(struct request *req, int uptodate)
 {
 	if (end_that_request_first(req, uptodate, current_count_sectors))
 		return;
@@ -2389,7 +2384,7 @@
 
 		/* unlock chained buffers */
 		spin_lock_irqsave(q->queue_lock, flags);
-		end_request(req, 1);
+		floppy_end_request(req, 1);
 		spin_unlock_irqrestore(q->queue_lock, flags);
 	} else {
 		if (rq_data_dir(req) == WRITE) {
@@ -2403,7 +2398,7 @@
 			DRWE->last_error_generation = DRS->generation;
 		}
 		spin_lock_irqsave(q->queue_lock, flags);
-		end_request(req, 0);
+		floppy_end_request(req, 0);
 		spin_unlock_irqrestore(q->queue_lock, flags);
 	}
 }
@@ -3385,25 +3380,21 @@
 	if (type){
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
+		down(&open_lock);
 		LOCK_FDC(drive,1);
-		for (cnt = 0; cnt < N_DRIVE; cnt++){
-			if (ITYPE(drive_state[cnt].fd_device) == type &&
-			    drive_state[cnt].fd_ref)
-				set_bit(drive, &fake_change);
-		}
 		floppy_type[type] = *g;
 		floppy_type[type].name="user format";
 		for (cnt = type << 2; cnt < (type << 2) + 4; cnt++)
 			floppy_sizes[cnt]= floppy_sizes[cnt+0x80]=
 				floppy_type[type].size+1;
 		process_fd_request();
-		for (cnt = 0; cnt < N_DRIVE; cnt++){
-			if (ITYPE(drive_state[cnt].fd_device) == type &&
-			    drive_state[cnt].fd_ref)
-				__check_disk_change(
-					MKDEV(FLOPPY_MAJOR,
-					      drive_state[cnt].fd_device));
+		for (cnt = 0; cnt < N_DRIVE; cnt++) {
+			struct block_device *bdev = opened_bdev[cnt];
+			if (!bdev || ITYPE(drive_state[cnt].fd_device) != type)
+				continue;
+			__invalidate_device(bdev, 0);
 		}
+		up(&open_lock);
 	} else {
 		LOCK_FDC(drive,1);
 		if (cmd != FDDEFPRM)
@@ -3501,8 +3492,8 @@
 #define OUT(c,x) case c: outparam = (const char *) (x); break
 #define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0
 
-	int i,drive,type;
-	kdev_t device;
+	int drive = (long)inode->i_bdev->bd_disk->private_data;
+	int i, type = ITYPE(UDRS->fd_device);
 	int ret;
 	int size;
 	union inparam {
@@ -3513,10 +3504,6 @@
 	} inparam; /* parameters coming from user space */
 	const char *outparam; /* parameters passed back to user space */
 
-	device = inode->i_rdev;
-	type = TYPE(device);
-	drive = DRIVE(device);
-
 	/* convert compatibility eject ioctls into floppy eject ioctl.
 	 * We do this in order to provide a means to eject floppy disks before
 	 * installing the new fdutils package */
@@ -3635,7 +3622,7 @@
 		case FDFMTTRK:
 			if (UDRS->fd_ref != 1)
 				return -EBUSY;
-			return do_format(device, &inparam.f);
+			return do_format(drive, &inparam.f);
 		case FDFMTEND:
 		case FDFLUSH:
 			LOCK_FDC(drive,1);
@@ -3751,15 +3738,19 @@
 
 static int floppy_release(struct inode * inode, struct file * filp)
 {
-	int drive = DRIVE(inode->i_rdev);
+	int drive = (long)inode->i_bdev->bd_disk->private_data;
 
+	down(&open_lock);
 	if (UDRS->fd_ref < 0)
 		UDRS->fd_ref=0;
 	else if (!UDRS->fd_ref--) {
 		DPRINT("floppy_release with fd_ref == 0");
 		UDRS->fd_ref = 0;
 	}
+	if (!UDRS->fd_ref)
+		opened_bdev[drive] = NULL;
 	floppy_release_irq_and_dma();
+	up(&open_lock);
 	return 0;
 }
 
@@ -3772,9 +3763,10 @@
 
 static int floppy_open(struct inode * inode, struct file * filp)
 {
-	int drive;
+	int drive = (long)inode->i_bdev->bd_disk->private_data;
 	int old_dev;
 	int try;
+	int res = -EBUSY;
 	char *tmp;
 
 #ifdef PC9800_DEBUG_FLOPPY
@@ -3782,7 +3774,6 @@
 #endif
 	filp->private_data = (void*) 0;
 
-	drive = DRIVE(inode->i_rdev);
 #ifdef PC9800_DEBUG_FLOPPY
 	printk("floppy open: drive=%d, current_drive=%d, UDP->cmos=%d\n"
 		   "floppy open: FDCS={spec1=%d, spec2=%d, dtr=%d, version=%d, dor=%d, address=%lu}\n",
@@ -3797,16 +3788,10 @@
 	}
 #endif /* PC9800_DEBUG_FLOPPY */
 
-	if (drive >= N_DRIVE ||
-	    !(allowed_drive_mask & (1 << drive)) ||
-	    fdc_state[FDC(drive)].version == FDC_NONE)
-		return -ENXIO;
-
-	if (TYPE(inode->i_rdev) >= NUMBER(floppy_type))
-		return -ENXIO;
+	down(&open_lock);
 	old_dev = UDRS->fd_device;
-	if (UDRS->fd_ref && old_dev != minor(inode->i_rdev))
-		return -EBUSY;
+	if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev)
+		goto out2;
 
 	if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)){
 		USETF(FD_DISK_CHANGED);
@@ -3815,16 +3800,20 @@
 
 	if (UDRS->fd_ref == -1 ||
 	   (UDRS->fd_ref && (filp->f_flags & O_EXCL)))
-		return -EBUSY;
+		goto out2;
 
 	if (floppy_grab_irq_and_dma())
-		return -EBUSY;
+		goto out2;
 
 	if (filp->f_flags & O_EXCL)
 		UDRS->fd_ref = -1;
 	else
 		UDRS->fd_ref++;
 
+	opened_bdev[drive] = inode->i_bdev;
+
+	res = -ENXIO;
+
 	if (!floppy_track_buffer){
 		/* if opening an ED drive, reserve a big buffer,
 		 * else reserve a small one */
@@ -3844,7 +3833,7 @@
 		}
 		if (!tmp && !floppy_track_buffer) {
 			DPRINT("Unable to allocate DMA memory\n");
-			RETERR(ENXIO);
+			goto out;
 		}
 		if (floppy_track_buffer) {
 			if (tmp)
@@ -3861,8 +3850,6 @@
 	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));
 	}
 
 #ifdef PC9800_DEBUG_FLOPPY
@@ -3884,22 +3871,33 @@
 	printk("floppy open: floppy.c:%d passed\n", __LINE__);
 #endif
 
-	if (filp->f_flags & O_NDELAY)
-		return 0;
-	if (filp->f_mode & 3) {
-		UDRS->last_checked = 0;
-		check_disk_change(inode->i_bdev);
-		if (UTESTF(FD_DISK_CHANGED))
-			RETERR(ENXIO);
-	}
-	if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE)))
-		RETERR(EROFS);
+	if (!(filp->f_flags & O_NDELAY)) {
+		if (filp->f_mode & 3) {
+			UDRS->last_checked = 0;
+			check_disk_change(inode->i_bdev);
+			if (UTESTF(FD_DISK_CHANGED))
+				goto out;
+		}
+		res = -EROFS;
+		if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE)))
+			goto out;
 #ifdef PC9800_DEBUG_FLOPPY
-	printk("floppy open: end normally\n");
+		printk("floppy open: end normally\n");
 #endif
-
+	}
+	up(&open_lock);
 	return 0;
-#undef RETERR
+out:
+	if (UDRS->fd_ref < 0)
+		UDRS->fd_ref=0;
+	else
+		UDRS->fd_ref--;
+	if (!UDRS->fd_ref)
+		opened_bdev[drive] = NULL;
+	floppy_release_irq_and_dma();
+out2:
+	up(&open_lock);
+	return res;
 }
 
 /*
@@ -3997,7 +3995,7 @@
 	struct block_device *bdev;
 	int ret;
 
-	bdev = bdget(MKDEV(disk->major, disk->first_minor));
+	bdev = bdget_disk(disk, 0);
 	if (!bdev) {
 		printk("No block device for %s\n", disk->disk_name);
 		BUG();
@@ -4084,21 +4082,19 @@
 
 static void __init register_devfs_entries (int drive)
 {
-    int base_minor, i;
+	int base_minor = (drive < 4) ? drive : (124 + drive);
 
-    base_minor = (drive < 4) ? drive : (124 + drive);
-    if (UDP->cmos < NUMBER(default_drive_params)) {
-	i = 0;
-	do {
-	    char name[16];
-
-	    sprintf(name, "floppy/%d%s", drive, table[table_sup[UDP->cmos][i]]);
-	    devfs_register(NULL, name, DEVFS_FL_DEFAULT, FLOPPY_MAJOR,
-			    base_minor + (table_sup[UDP->cmos][i] << 2),
-			    S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP |S_IWGRP,
-			    &floppy_fops, NULL);
-	} while (table_sup[UDP->cmos][i++]);
-    }
+	if (UDP->cmos < NUMBER(default_drive_params)) {
+		int i = 0;
+		do {
+			int minor = base_minor + (table_sup[UDP->cmos][i] << 2);
+
+			devfs_mk_bdev(MKDEV(FLOPPY_MAJOR, minor), 
+					S_IFBLK|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP,
+					"floppy/%d%s",
+					drive, table[table_sup[UDP->cmos][i]]);
+		} while (table_sup[UDP->cmos][i++]);
+	}
 }
 
 /*
@@ -4256,6 +4252,8 @@
 	if (drive >= N_DRIVE ||
 	    !(allowed_drive_mask & (1 << drive)) ||
 	    fdc_state[FDC(drive)].version == FDC_NONE)
+		return NULL;
+	if (((*part>>2) & 0x1f) >= NUMBER(floppy_type))
 		return NULL;
 	return get_disk(disks[drive]);
 }
diff -Nru a/drivers/block/genhd.c b/drivers/block/genhd.c
--- a/drivers/block/genhd.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/block/genhd.c	Wed Apr 30 22:28:09 2003
@@ -365,11 +365,13 @@
 		(unsigned long long)get_capacity(sgp) >> 1,
 		disk_name(sgp, 0, buf));
 	for (n = 0; n < sgp->minors - 1; n++) {
-		if (sgp->part[n].nr_sects == 0)
+		if (!sgp->part[n])
+			continue;
+		if (sgp->part[n]->nr_sects == 0)
 			continue;
 		seq_printf(part, "%4d  %4d %10llu %s\n",
 			sgp->major, n + 1 + sgp->first_minor,
-			(unsigned long long)sgp->part[n].nr_sects >> 1 ,
+			(unsigned long long)sgp->part[n]->nr_sects >> 1 ,
 			disk_name(sgp, n + 1, buf));
 	}
 
@@ -542,6 +544,92 @@
 static decl_subsys(block, &ktype_block, &block_hotplug_ops);
 
 
+/*
+ * aggregate disk stat collector.  Uses the same stats that the sysfs
+ * entries do, above, but makes them available through one seq_file.
+ * Watching a few disks may be efficient through sysfs, but watching
+ * all of them will be more efficient through this interface.
+ *
+ * The output looks suspiciously like /proc/partitions with a bunch of
+ * extra fields.
+ */
+
+/* iterator */
+static void *diskstats_start(struct seq_file *part, loff_t *pos)
+{
+	loff_t k = *pos;
+	struct list_head *p;
+
+	down_read(&block_subsys.rwsem);
+	list_for_each(p, &block_subsys.kset.list)
+		if (!k--)
+			return list_entry(p, struct gendisk, kobj.entry);
+	return NULL;
+}
+
+static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos)
+{
+	struct list_head *p = ((struct gendisk *)v)->kobj.entry.next;
+	++*pos;
+	return p==&block_subsys.kset.list ? NULL :
+		list_entry(p, struct gendisk, kobj.entry);
+}
+
+static void diskstats_stop(struct seq_file *part, void *v)
+{
+	up_read(&block_subsys.rwsem);
+}
+
+static int diskstats_show(struct seq_file *s, void *v)
+{
+	struct gendisk *gp = v;
+	char buf[64];
+	int n = 0;
+
+	/*
+	if (&sgp->kobj.entry == block_subsys.kset.list.next)
+		seq_puts(s,	"major minor name"
+				"     rio rmerge rsect ruse wio wmerge "
+				"wsect wuse running use aveq"
+				"\n\n");
+	*/
+ 
+	disk_round_stats(gp);
+	seq_printf(s, "%4d %4d %s %u %u %llu %u %u %u %llu %u %u %u %u\n",
+		gp->major, n + gp->first_minor, disk_name(gp, n, buf),
+		disk_stat_read(gp, reads), disk_stat_read(gp, read_merges),
+		(unsigned long long)disk_stat_read(gp, read_sectors),
+		jiffies_to_msec(disk_stat_read(gp, read_ticks)),
+		disk_stat_read(gp, writes), disk_stat_read(gp, write_merges),
+		(unsigned long long)disk_stat_read(gp, write_sectors),
+		jiffies_to_msec(disk_stat_read(gp, write_ticks)),
+		disk_stat_read(gp, in_flight),
+		jiffies_to_msec(disk_stat_read(gp, io_ticks)),
+		jiffies_to_msec(disk_stat_read(gp, time_in_queue)));
+
+	/* now show all non-0 size partitions of it */
+	for (n = 0; n < gp->minors - 1; n++) {
+		struct hd_struct *hd = gp->part[n];
+
+		if (hd && hd->nr_sects)
+			seq_printf(s, "%4d %4d %s %u %u %u %u\n",
+				gp->major, n + gp->first_minor + 1,
+				disk_name(gp, n + 1, buf),
+				hd->reads, hd->read_sectors,
+				hd->writes, hd->write_sectors);
+	}
+ 
+	return 0;
+}
+
+struct seq_operations diskstats_op = {
+	.start	= diskstats_start,
+	.next	= diskstats_next,
+	.stop	= diskstats_stop,
+	.show	= diskstats_show
+};
+
+
 struct gendisk *alloc_disk(int minors)
 {
 	struct gendisk *disk = kmalloc(sizeof(struct gendisk), GFP_KERNEL);
@@ -552,7 +640,7 @@
 			return NULL;
 		}
 		if (minors > 1) {
-			int size = (minors - 1) * sizeof(struct hd_struct);
+			int size = (minors - 1) * sizeof(struct hd_struct *);
 			disk->part = kmalloc(size, GFP_KERNEL);
 			if (!disk->part) {
 				kfree(disk);
@@ -604,8 +692,8 @@
 	struct gendisk *disk = bdev->bd_disk;
 	if (bdev->bd_contains != bdev) {
 		int part = bdev->bd_dev - MKDEV(disk->major, disk->first_minor);
-		struct hd_struct *p = &disk->part[part-1];
-		p->policy = flag;
+		struct hd_struct *p = disk->part[part-1];
+		if (p) p->policy = flag;
 	} else
 		disk->policy = flag;
 }
@@ -615,7 +703,7 @@
 	int i;
 	disk->policy = flag;
 	for (i = 0; i < disk->minors - 1; i++)
-		disk->part[i].policy = flag;
+		if (disk->part[i]) disk->part[i]->policy = flag;
 }
 
 int bdev_read_only(struct block_device *bdev)
@@ -626,12 +714,24 @@
 	disk = bdev->bd_disk;
 	if (bdev->bd_contains != bdev) {
 		int part = bdev->bd_dev - MKDEV(disk->major, disk->first_minor);
-		struct hd_struct *p = &disk->part[part-1];
-		return p->policy;
+		struct hd_struct *p = disk->part[part-1];
+		if (p) return p->policy;
+		return 0;
 	} else
 		return disk->policy;
 }
 
+int invalidate_partition(struct gendisk *disk, int index)
+{
+	int res = 0;
+	struct block_device *bdev = bdget_disk(disk, index);
+	if (bdev)
+		res = __invalidate_device(bdev, 1);
+	bdput(bdev);
+	return res;
+}
+
 EXPORT_SYMBOL(bdev_read_only);
 EXPORT_SYMBOL(set_device_ro);
 EXPORT_SYMBOL(set_disk_ro);
+EXPORT_SYMBOL(invalidate_partition);
diff -Nru a/drivers/block/initrd.c b/drivers/block/initrd.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/block/initrd.c	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,100 @@
+
+#include <linux/blkdev.h>
+#include <linux/genhd.h>
+#include <linux/initrd.h>
+#include <linux/init.h>
+#include <linux/major.h>
+#include <linux/module.h>
+#include <linux/spinlock.h>
+#include <asm/uaccess.h>
+
+
+unsigned long initrd_start, initrd_end;
+int initrd_below_start_ok;
+
+static int initrd_users;
+static spinlock_t initrd_users_lock = SPIN_LOCK_UNLOCKED;
+
+static struct gendisk *initrd_disk;
+
+static ssize_t initrd_read(struct file *file, char *buf,
+			   size_t count, loff_t *ppos)
+{
+	int left = initrd_end - initrd_start - *ppos;
+
+	if (count > left)
+		count = left;
+	if (count == 0)
+		return 0;
+	if (copy_to_user(buf, (char *)initrd_start + *ppos, count))
+		return -EFAULT;
+
+	*ppos += count;
+	return count;
+}
+
+static int initrd_release(struct inode *inode,struct file *file)
+{
+
+	blkdev_put(inode->i_bdev, BDEV_FILE);
+
+	spin_lock(&initrd_users_lock);
+	if (!--initrd_users) {
+		spin_unlock(&initrd_users_lock);
+		del_gendisk(initrd_disk);
+		free_initrd_mem(initrd_start, initrd_end);
+		initrd_start = 0;
+	} else
+		spin_unlock(&initrd_users_lock);
+
+	return 0;
+}
+
+static struct file_operations initrd_fops = {
+	.read =		initrd_read,
+	.release =	initrd_release,
+};
+
+static int initrd_open(struct inode *inode, struct file *filp)
+{
+	if (!initrd_start) 
+		return -ENODEV;
+
+	spin_lock(&initrd_users_lock);
+	initrd_users++;
+	spin_unlock(&initrd_users_lock);
+
+	filp->f_op = &initrd_fops;
+	return 0;
+}
+
+static struct block_device_operations initrd_bdops = {
+	.owner =	THIS_MODULE,
+	.open =		initrd_open,
+};
+
+static int __init initrd_init(void)
+{
+	initrd_disk = alloc_disk(1);
+	if (!initrd_disk)
+		return -ENOMEM;
+
+	initrd_disk->major = RAMDISK_MAJOR;
+	initrd_disk->first_minor = INITRD_MINOR;
+	initrd_disk->fops = &initrd_bdops;	
+
+	sprintf(initrd_disk->disk_name, "initrd");
+	sprintf(initrd_disk->devfs_name, "rd/initrd");
+
+	set_capacity(initrd_disk, (initrd_end-initrd_start+511) >> 9);
+	add_disk(initrd_disk);
+	return 0;
+}
+
+static void __exit initrd_exit(void)
+{
+	put_disk(initrd_disk);
+}
+
+module_init(initrd_init);
+module_exit(initrd_exit);
diff -Nru a/drivers/block/ioctl.c b/drivers/block/ioctl.c
--- a/drivers/block/ioctl.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/block/ioctl.c	Wed Apr 30 22:28:04 2003
@@ -41,11 +41,14 @@
 					return -EINVAL;
 			}
 			/* partition number in use? */
-			if (disk->part[part - 1].nr_sects != 0)
+			if (disk->part[part - 1])
 				return -EBUSY;
 			/* overlap? */
 			for (i = 0; i < disk->minors - 1; i++) {
-				struct hd_struct *s = &disk->part[i];
+				struct hd_struct *s = disk->part[i];
+
+				if (!s)
+					continue;
 				if (!(start+length <= s->start_sect ||
 				      start >= s->start_sect + s->nr_sects))
 					return -EBUSY;
@@ -54,10 +57,12 @@
 			add_partition(disk, part, start, length);
 			return 0;
 		case BLKPG_DEL_PARTITION:
-			if (disk->part[part - 1].nr_sects == 0)
+			if (!disk->part[part-1])
+				return -ENXIO;
+			if (disk->part[part - 1]->nr_sects == 0)
 				return -ENXIO;
 			/* partition in use? Incomplete check for now. */
-			bdevp = bdget(MKDEV(disk->major, disk->first_minor) + part);
+			bdevp = bdget_disk(disk, part);
 			if (!bdevp)
 				return -ENOMEM;
 			if (bd_claim(bdevp, &holder) < 0) {
diff -Nru a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c
--- a/drivers/block/ll_rw_blk.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/block/ll_rw_blk.c	Wed Apr 30 22:28:04 2003
@@ -1078,10 +1078,14 @@
  * blk_run_queue - run a single device queue
  * @q	The queue to run
  */
-void __blk_run_queue(request_queue_t *q)
+void blk_run_queue(struct request_queue *q)
 {
+	unsigned long flags;
+
+	spin_lock_irqsave(q->queue_lock, flags);
 	blk_remove_plug(q);
 	q->request_fn(q);
+	spin_unlock_irqrestore(q->queue_lock, flags);
 }
 
 /**
@@ -1841,7 +1845,7 @@
 	if (bdev == bdev->bd_contains)
 		return;
 
-	p = &disk->part[bdev->bd_dev-MKDEV(disk->major,disk->first_minor)-1];
+	p = disk->part[bdev->bd_dev-MKDEV(disk->major,disk->first_minor)-1];
 	switch (bio->bi_rw) {
 	case READ:
 		p->read_sectors += bio_sectors(bio);
@@ -2160,8 +2164,7 @@
 void end_that_request_last(struct request *req)
 {
 	struct gendisk *disk = req->rq_disk;
-	if (req->waiting)
-		complete(req->waiting);
+	struct completion *waiting = req->waiting;
 
 	if (disk) {
 		unsigned long duration = jiffies - req->start_time;
@@ -2179,6 +2182,33 @@
 		disk_stat_dec(disk, in_flight);
 	}
 	__blk_put_request(req->q, req);
+	/* Do this LAST! The structure may be freed immediately afterwards */
+	if (waiting)
+		complete(waiting);
+}
+
+void end_request(struct request *req, int uptodate)
+{
+	if (!end_that_request_first(req, uptodate, req->hard_cur_sectors)) {
+		add_disk_randomness(req->rq_disk);
+		blkdev_dequeue_request(req);
+		end_that_request_last(req);
+	}
+}
+
+void blk_rq_bio_prep(request_queue_t *q, struct request *rq, struct bio *bio)
+{
+	/* first three bits are identical in rq->flags and bio->bi_rw */
+	rq->flags |= (bio->bi_rw & 7);
+
+	rq->nr_phys_segments = bio_phys_segments(q, bio);
+	rq->nr_hw_segments = bio_hw_segments(q, bio);
+	rq->current_nr_sectors = bio_cur_sectors(bio);
+	rq->hard_cur_sectors = rq->current_nr_sectors;
+	rq->hard_nr_sectors = rq->nr_sectors = bio_sectors(bio);
+	rq->buffer = bio_data(bio);
+
+	rq->bio = rq->biotail = bio;
 }
 
 int __init blk_dev_init(void)
@@ -2223,6 +2253,7 @@
 EXPORT_SYMBOL(end_that_request_first);
 EXPORT_SYMBOL(end_that_request_chunk);
 EXPORT_SYMBOL(end_that_request_last);
+EXPORT_SYMBOL(end_request);
 EXPORT_SYMBOL(blk_init_queue);
 EXPORT_SYMBOL(blk_cleanup_queue);
 EXPORT_SYMBOL(blk_queue_make_request);
@@ -2267,5 +2298,7 @@
 EXPORT_SYMBOL(blk_start_queue);
 EXPORT_SYMBOL(blk_stop_queue);
 EXPORT_SYMBOL(__blk_stop_queue);
-EXPORT_SYMBOL(__blk_run_queue);
+EXPORT_SYMBOL(blk_run_queue);
 EXPORT_SYMBOL(blk_run_queues);
+
+EXPORT_SYMBOL(blk_rq_bio_prep);
diff -Nru a/drivers/block/loop.c b/drivers/block/loop.c
--- a/drivers/block/loop.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/block/loop.c	Wed Apr 30 22:28:10 2003
@@ -1143,7 +1143,6 @@
 	}
 
 	for (i = 0; i < max_loop; i++) {
-		char name[16];
 		struct loop_device *lo = &loop_dev[i];
 		struct gendisk *disk = disks[i];
 		memset(lo, 0, sizeof(*lo));
@@ -1156,14 +1155,10 @@
 		disk->first_minor = i;
 		disk->fops = &lo_fops;
 		sprintf(disk->disk_name, "loop%d", i);
+		sprintf(disk->devfs_name, "loop/%d", i);
 		disk->private_data = lo;
 		disk->queue = &lo->lo_queue;
 		add_disk(disk);
-		sprintf(name, "loop/%d", i);
-		devfs_register(NULL, name, DEVFS_FL_DEFAULT,
-			      disk->major, disk->first_minor,
-			      S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP,
-			      disk->fops, NULL);
 	}
 	printk(KERN_INFO "loop: loaded (max %d devices)\n", max_loop);
 	return 0;
@@ -1184,7 +1179,6 @@
 	for (i = 0; i < max_loop; i++) {
 		del_gendisk(disks[i]);
 		put_disk(disks[i]);
-		devfs_remove("loop/%d", i);
 	}
 	devfs_remove("loop");
 	if (unregister_blkdev(LOOP_MAJOR, "loop"))
diff -Nru a/drivers/block/nbd.c b/drivers/block/nbd.c
--- a/drivers/block/nbd.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/block/nbd.c	Wed Apr 30 22:28:06 2003
@@ -568,7 +568,6 @@
 	devfs_mk_dir("nbd");
 	for (i = 0; i < MAX_NBD; i++) {
 		struct gendisk *disk = nbd_dev[i].disk;
-		char name[16];
 		nbd_dev[i].refcnt = 0;
 		nbd_dev[i].file = NULL;
 		nbd_dev[i].magic = LO_MAGIC;
@@ -585,13 +584,9 @@
 		disk->private_data = &nbd_dev[i];
 		disk->queue = &nbd_queue;
 		sprintf(disk->disk_name, "nbd%d", i);
+		sprintf(disk->devfs_name, "nbd/%d", i);
 		set_capacity(disk, 0x3ffffe);
 		add_disk(disk);
-		sprintf(name, "nbd/%d", i);
-		devfs_register(NULL, name, DEVFS_FL_DEFAULT,
-			       disk->major, disk->first_minor,
-			       S_IFBLK | S_IRUSR | S_IWUSR,
-			       disk->fops, NULL);
 	}
 
 	return 0;
@@ -607,7 +602,6 @@
 	for (i = 0; i < MAX_NBD; i++) {
 		del_gendisk(nbd_dev[i].disk);
 		put_disk(nbd_dev[i].disk);
-		devfs_remove("nbd/%d", i);
 	}
 	devfs_remove("nbd");
 	blk_cleanup_queue(&nbd_queue);
diff -Nru a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
--- a/drivers/block/paride/pcd.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/block/paride/pcd.c	Wed Apr 30 22:28:18 2003
@@ -761,7 +761,7 @@
 
 static inline void next_request(int success)
 {
-	long saved_flags;
+	unsigned long saved_flags;
 
 	spin_lock_irqsave(&pcd_lock, saved_flags);
 	end_request(pcd_req, success);
diff -Nru a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
--- a/drivers/block/paride/pd.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/block/paride/pd.c	Wed Apr 30 22:28:15 2003
@@ -757,7 +757,7 @@
 
 static int pd_next_buf(void)
 {
-	long saved_flags;
+	unsigned long saved_flags;
 
 	pd_count--;
 	pd_run--;
@@ -777,7 +777,7 @@
 
 static inline void next_request(int success)
 {
-	long saved_flags;
+	unsigned long saved_flags;
 
 	spin_lock_irqsave(&pd_lock, saved_flags);
 	end_request(pd_req, success);
diff -Nru a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
--- a/drivers/block/paride/pf.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/block/paride/pf.c	Wed Apr 30 22:28:12 2003
@@ -812,7 +812,7 @@
 
 static int pf_next_buf(void)
 {
-	long saved_flags;
+	unsigned long saved_flags;
 
 	pf_count--;
 	pf_run--;
@@ -832,7 +832,8 @@
 
 static inline void next_request(int success)
 {
-	long saved_flags;
+	unsigned long saved_flags;
+
 	spin_lock_irqsave(&pf_spin_lock, saved_flags);
 	end_request(pf_req, success);
 	pf_busy = 0;
diff -Nru a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
--- a/drivers/block/paride/pt.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/block/paride/pt.c	Wed Apr 30 22:28:06 2003
@@ -661,8 +661,6 @@
 	int unit;
 	struct mtop mtop;
 
-        if (!inode || kdev_none(inode->i_rdev))
-		return -EINVAL;
         unit = DEVICE_NR(inode->i_rdev);
         if (unit >= PT_UNITS)
 		return -EINVAL;
diff -Nru a/drivers/block/ps2esdi.c b/drivers/block/ps2esdi.c
--- a/drivers/block/ps2esdi.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/block/ps2esdi.c	Wed Apr 30 22:28:03 2003
@@ -77,7 +77,7 @@
 
 static void ps2esdi_prep_dma(char *buffer, u_short length, u_char dma_xmode);
 
-static void ps2esdi_interrupt_handler(int irq, void *dev_id,
+static irqreturn_t ps2esdi_interrupt_handler(int irq, void *dev_id,
 				      struct pt_regs *regs);
 static void (*current_int_handler) (u_int) = NULL;
 static void ps2esdi_normal_interrupt_handler(u_int);
@@ -613,18 +613,21 @@
 static int ps2esdi_out_cmd_blk(u_short * cmd_blk)
 {
 
-	int i, j;
+	int i;
+	unsigned long jif;
 	u_char status;
 
 	/* enable interrupts */
 	outb(CTRL_ENABLE_INTR, ESDI_CONTROL);
 
 	/* do not write to the controller, if it is busy */
-	for (i = jiffies + ESDI_STAT_TIMEOUT; time_after(i, jiffies) && (inb(ESDI_STATUS) &
-							  STATUS_BUSY););
+	for (jif = jiffies + ESDI_STAT_TIMEOUT;
+		time_after(jif, jiffies) &&
+			(inb(ESDI_STATUS) & STATUS_BUSY); )
+		;
 
 #if 0
-	printk("%s: i(1)=%d\n", DEVICE_NAME, i);
+	printk("%s: i(1)=%ld\n", DEVICE_NAME, jif);
 #endif
 
 	/* if device is still busy - then just time out */
@@ -642,8 +645,8 @@
 	/* one by one send each word out */
 	for (i = (((*cmd_blk) >> 14) + 1) << 1; i; i--) {
 		status = inb(ESDI_STATUS);
-		for (j = jiffies + ESDI_STAT_TIMEOUT;
-		     time_after(j, jiffies) && (status & STATUS_BUSY) &&
+		for (jif = jiffies + ESDI_STAT_TIMEOUT;
+		     time_after(jif, jiffies) && (status & STATUS_BUSY) &&
 		   (status & STATUS_CMD_INF); status = inb(ESDI_STATUS));
 		if ((status & (STATUS_BUSY | STATUS_CMD_INF)) == STATUS_BUSY) {
 #if 0
@@ -681,7 +684,7 @@
 
 
 
-static void ps2esdi_interrupt_handler(int irq, void *dev_id,
+static irqreturn_t ps2esdi_interrupt_handler(int irq, void *dev_id,
 				      struct pt_regs *regs)
 {
 	u_int int_ret_code;
@@ -695,8 +698,9 @@
 		} else
 			printk("%s: help ! No interrupt handler.\n", DEVICE_NAME);
 	} else {
-		return;
+		return IRQ_NONE;
 	}
+	return IRQ_HANDLED;
 }
 
 static void ps2esdi_initial_reset_int_handler(u_int int_ret_code)
diff -Nru a/drivers/block/rd.c b/drivers/block/rd.c
--- a/drivers/block/rd.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/block/rd.c	Wed Apr 30 22:28:11 2003
@@ -50,22 +50,18 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/devfs_fs_kernel.h>
+#include <linux/pagemap.h>
+#include <linux/blkdev.h>
+#include <linux/genhd.h>
+#include <linux/bio.h>
 #include <linux/buffer_head.h>		/* for invalidate_bdev() */
 #include <linux/backing-dev.h>
-#include <linux/blk.h>
 #include <linux/blkpg.h>
 #include <asm/uaccess.h>
 
 /* The RAM disk size is now a parameter */
 #define NUM_RAMDISKS 16		/* This cannot be overridden (yet) */ 
 
-#ifdef CONFIG_BLK_DEV_INITRD
-static int initrd_users;
-static spinlock_t initrd_users_lock = SPIN_LOCK_UNLOCKED;
-unsigned long initrd_start, initrd_end;
-int initrd_below_start_ok;
-#endif
-
 /* Various static variables go here.  Most are used only in the RAM disk code.
  */
 
@@ -265,53 +261,6 @@
 	return error;
 }
 
-
-#ifdef CONFIG_BLK_DEV_INITRD
-
-static struct block_device_operations rd_bd_op;
-static struct gendisk *initrd_disk;
-
-static ssize_t initrd_read(struct file *file, char *buf,
-			   size_t count, loff_t *ppos)
-{
-	int left;
-
-	left = initrd_end - initrd_start - *ppos;
-	if (count > left) count = left;
-	if (count == 0) return 0;
-	if (copy_to_user(buf, (char *)initrd_start + *ppos, count))
-		return -EFAULT;
-	*ppos += count;
-	return count;
-}
-
-
-static int initrd_release(struct inode *inode,struct file *file)
-{
-	extern void free_initrd_mem(unsigned long, unsigned long);
-
-	blkdev_put(inode->i_bdev, BDEV_FILE);
-
-	spin_lock(&initrd_users_lock);
-	if (!--initrd_users) {
-		spin_unlock(&initrd_users_lock);
-		del_gendisk(initrd_disk);
-		free_initrd_mem(initrd_start, initrd_end);
-		initrd_start = 0;
-	} else {
-		spin_unlock(&initrd_users_lock);
-	}
-	return 0;
-}
-
-
-static struct file_operations initrd_fops = {
-	.read =		initrd_read,
-	.release =	initrd_release,
-};
-
-#endif
-
 static struct backing_dev_info rd_backing_dev_info = {
 	.ra_pages	= 0,	/* No readahead */
 	.memory_backed	= 1,	/* Does not contribute to dirty memory */
@@ -321,18 +270,6 @@
 {
 	int unit = minor(inode->i_rdev);
 
-#ifdef CONFIG_BLK_DEV_INITRD
-	if (unit == INITRD_MINOR) {
-		spin_lock(&initrd_users_lock);
-		initrd_users++;
-		spin_unlock(&initrd_users_lock);
-		if (!initrd_start) 
-			return -ENODEV;
-		filp->f_op = &initrd_fops;
-		return 0;
-	}
-#endif
-
 	/*
 	 * Immunize device against invalidate_buffers() and prune_icache().
 	 */
@@ -370,12 +307,8 @@
 		}
 		del_gendisk(rd_disks[i]);
 		put_disk(rd_disks[i]);
-		devfs_remove("rd/%d", i);
 	}
-#ifdef CONFIG_BLK_DEV_INITRD
-	put_disk(initrd_disk);
-	devfs_remove("rd/initrd");
-#endif
+
 	devfs_remove("rd");
 	unregister_blkdev(RAMDISK_MAJOR, "ramdisk" );
 }
@@ -394,15 +327,6 @@
 		rd_blocksize = BLOCK_SIZE;
 	}
 
-#ifdef CONFIG_BLK_DEV_INITRD
-	initrd_disk = alloc_disk(1);
-	if (!initrd_disk)
-		return -ENOMEM;
-	initrd_disk->major = RAMDISK_MAJOR;
-	initrd_disk->first_minor = INITRD_MINOR;
-	initrd_disk->fops = &rd_bd_op;	
-	sprintf(initrd_disk->disk_name, "initrd");
-#endif
 	for (i = 0; i < NUM_RAMDISKS; i++) {
 		rd_disks[i] = alloc_disk(1);
 		if (!rd_disks[i])
@@ -420,31 +344,17 @@
 
 	for (i = 0; i < NUM_RAMDISKS; i++) {
 		struct gendisk *disk = rd_disks[i];
-		char name[16];
+
 		/* rd_size is given in kB */
 		disk->major = RAMDISK_MAJOR;
 		disk->first_minor = i;
 		disk->fops = &rd_bd_op;
 		disk->queue = &rd_queue;
 		sprintf(disk->disk_name, "ram%d", i);
+		sprintf(disk->devfs_name, "rd/%d", i);
 		set_capacity(disk, rd_size * 2);
-		sprintf(name, "rd/%d", i);
-		devfs_register(NULL, name, DEVFS_FL_DEFAULT,
-			       disk->major, disk->first_minor,
-			       S_IFBLK | S_IRUSR | S_IWUSR,
-			       disk->fops, NULL);
-	}
-
-	for (i = 0; i < NUM_RAMDISKS; i++)
 		add_disk(rd_disks[i]);
-
-#ifdef CONFIG_BLK_DEV_INITRD
-	/* We ought to separate initrd operations here */
-	set_capacity(initrd_disk, (initrd_end-initrd_start+511)>>9);
-	add_disk(initrd_disk);
-	devfs_register(NULL, "rd/initrd", DEVFS_FL_DEFAULT, RAMDISK_MAJOR,
-			INITRD_MINOR, S_IFBLK | S_IRUSR, &rd_bd_op, NULL);
-#endif
+	}
 
 	/* rd_size is given in kB */
 	printk("RAMDISK driver initialized: "
@@ -455,9 +365,6 @@
 out:
 	while (i--)
 		put_disk(rd_disks[i]);
-#ifdef CONFIG_BLK_DEV_INITRD
-	put_disk(initrd_disk);
-#endif
 	return err;
 }
 
diff -Nru a/drivers/block/scsi_ioctl.c b/drivers/block/scsi_ioctl.c
--- a/drivers/block/scsi_ioctl.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/block/scsi_ioctl.c	Wed Apr 30 22:28:19 2003
@@ -183,9 +183,11 @@
 		}
 
 		uaddr = (unsigned long) hdr.dxferp;
-		if (writing && !access_ok(VERIFY_WRITE, uaddr, bytes))
+		/* writing to device -> reading from vm */
+		if (writing && !access_ok(VERIFY_READ, uaddr, bytes))
 			return -EFAULT;
-		else if (reading && !access_ok(VERIFY_READ, uaddr, bytes))
+		/* reading from device -> writing to vm */
+		else if (reading && !access_ok(VERIFY_WRITE, uaddr, bytes))
 			return -EFAULT;
 
 		/*
@@ -193,18 +195,6 @@
 		 * be a write to vm.
 		 */
 		bio = bio_map_user(bdev, uaddr, hdr.dxfer_len, reading);
-		if (bio) {
-			if (writing)
-				bio->bi_rw |= (1 << BIO_RW);
-
-			nr_sectors = (bio->bi_size + 511) >> 9;
-
-			if (bio->bi_size < hdr.dxfer_len) {
-				bio_endio(bio, bio->bi_size, 0);
-				bio_unmap_user(bio, 0);
-				bio = NULL;
-			}
-		}
 
 		/*
 		 * if bio setup failed, fall back to slow approach
@@ -243,21 +233,10 @@
 	rq->hard_nr_sectors = rq->nr_sectors = nr_sectors;
 	rq->hard_cur_sectors = rq->current_nr_sectors = nr_sectors;
 
-	if (bio) {
-		/*
-		 * subtle -- if bio_map_user() ended up bouncing a bio, it
-		 * would normally disappear when its bi_end_io is run.
-		 * however, we need it for the unmap, so grab an extra
-		 * reference to it
-		 */
-		bio_get(bio);
+	rq->bio = rq->biotail = bio;
 
-		rq->nr_phys_segments = bio_phys_segments(q, bio);
-		rq->nr_hw_segments = bio_hw_segments(q, bio);
-		rq->current_nr_sectors = bio_cur_sectors(bio);
-		rq->hard_cur_sectors = rq->current_nr_sectors;
-		rq->buffer = bio_data(bio);
-	}
+	if (bio)
+		blk_rq_bio_prep(q, rq, bio);
 
 	rq->data_len = hdr.dxfer_len;
 	rq->data = buffer;
@@ -268,8 +247,6 @@
 	if (!rq->timeout)
 		rq->timeout = BLK_DEFAULT_TIMEOUT;
 
-	rq->bio = rq->biotail = bio;
-
 	start_time = jiffies;
 
 	/* ignore return value. All information is passed back to caller
@@ -277,11 +254,9 @@
 	 * N.B. a non-zero SCSI status is _not_ necessarily an error.
 	 */
 	blk_do_rq(q, bdev, rq);
-	
-	if (bio) {
+
+	if (bio)
 		bio_unmap_user(bio, reading);
-		bio_put(bio);
-	}
 
 	/* write to all output members */
 	hdr.status = rq->errors;	
diff -Nru a/drivers/block/swim3.c b/drivers/block/swim3.c
--- a/drivers/block/swim3.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/block/swim3.c	Wed Apr 30 22:28:07 2003
@@ -971,15 +971,13 @@
 	.revalidate_disk= floppy_revalidate,
 };
 
-static devfs_handle_t floppy_devfs_handle;
-
 int swim3_init(void)
 {
 	struct device_node *swim;
 	int err = -ENOMEM;
 	int i;
 
-	floppy_devfs_handle = devfs_mk_dir("floppy");
+	devfs_mk_dir("floppy");
 
 	swim = find_devices("floppy");
 	while (swim && (floppy_count < MAX_FLOPPIES))
@@ -1017,6 +1015,7 @@
 		disk->private_data = &floppy_states[i];
 		disk->queue = &swim3_queue;
 		sprintf(disk->disk_name, "fd%d", i);
+		sprintf(disk->devfs_name, "floppy/%d", i);
 		set_capacity(disk, 2880);
 		add_disk(disk);
 	}
@@ -1033,8 +1032,6 @@
 {
 	struct device_node *mediabay;
 	struct floppy_state *fs = &floppy_states[floppy_count];
-	char floppy_name[16];
-	devfs_handle_t floppy_handle;
 
 	if (swim->n_addrs < 2)
 	{
@@ -1095,12 +1092,6 @@
 
 	printk(KERN_INFO "fd%d: SWIM3 floppy controller %s\n", floppy_count,
 		mediabay ? "in media bay" : "");
-
-	sprintf(floppy_name, "floppy/%d", floppy_count);
-	floppy_handle = devfs_register(NULL, floppy_name, 
-			DEVFS_FL_DEFAULT, FLOPPY_MAJOR, floppy_count, 
-			S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP |S_IWGRP, 
-			&floppy_fops, NULL);
 
 	floppy_count++;
 	
diff -Nru a/drivers/block/umem.c b/drivers/block/umem.c
--- a/drivers/block/umem.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/block/umem.c	Wed Apr 30 22:28:19 2003
@@ -52,6 +52,7 @@
 
 #include <linux/fcntl.h>        /* O_ACCMODE */
 #include <linux/hdreg.h>  /* HDIO_GETGEO */
+#include <linux/devfs_fs_kernel.h>
 
 #include <linux/umem.h>
 
@@ -149,6 +150,7 @@
 	spinlock_t 	lock;
 	int		check_batteries;
 
+	int		flags;
 };
 
 static struct cardinfo cards[MM_MAXCARDS];
@@ -573,7 +575,7 @@
 --                              mm_interrupt
 -----------------------------------------------------------------------------------
 */
-static void mm_interrupt(int irq, void *__card, struct pt_regs *regs)
+static irqreturn_t mm_interrupt(int irq, void *__card, struct pt_regs *regs)
 {
 	struct cardinfo *card = (struct cardinfo *) __card;
 	unsigned int dma_status;
@@ -585,13 +587,16 @@
 
 	if (!(dma_status & (DMASCR_ERROR_MASK | DMASCR_CHAIN_COMPLETE))) {
 		/* interrupt wasn't for me ... */
-		return;
+		return IRQ_NONE;
         }
 
 	/* clear COMPLETION interrupts */
-	writel(cpu_to_le32(DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE),
-	       card->csr_remap+ DMA_STATUS_CTRL);
-
+	if (card->flags & UM_FLAG_NO_BYTE_STATUS)
+		writel(cpu_to_le32(DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE),
+		       card->csr_remap+ DMA_STATUS_CTRL);
+	else
+		writeb((DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE) >> 16,
+		       card->csr_remap+ DMA_STATUS_CTRL + 2);
 	
 	/* log errors and clear interrupt status */
 	if (dma_status & DMASCR_ANY_ERR) {
@@ -663,6 +668,7 @@
 
 HW_TRACE(0x36);
 
+	return IRQ_HANDLED; 
 }
 /*
 -----------------------------------------------------------------------------------
@@ -755,15 +761,16 @@
 {
 	int i;
 
-	for (i = 0; i < num_cards; i++) {
-		struct cardinfo *card = &cards[i];
-		spin_lock_bh(&card->lock);
-		if (card->Active >= 0)
-			card->check_batteries = 1;
-		else
-			check_batteries(card);
-		spin_unlock_bh(&card->lock);
-	}
+	for (i = 0; i < num_cards; i++) 
+		if (!(cards[i].flags & UM_FLAG_NO_BATT)) {
+			struct cardinfo *card = &cards[i];
+			spin_lock_bh(&card->lock);
+			if (card->Active >= 0)
+				card->check_batteries = 1;
+			else
+				check_batteries(card);
+			spin_unlock_bh(&card->lock);
+		}
 
 	init_battery_timer();
 }
@@ -869,6 +876,7 @@
 	unsigned char	mem_present;
 	unsigned char	batt_status;
 	unsigned int	saved_bar, data;
+	int		magic_number;
 
 	if (pci_enable_device(dev) < 0)
 		return -ENODEV;
@@ -933,12 +941,33 @@
 	printk(KERN_INFO "MM%d: MEM area not remapped (CONFIG_MM_MAP_MEMORY not set)\n",
 	       card->card_number);
 #endif
-	if (readb(card->csr_remap + MEMCTRLSTATUS_MAGIC) != MM_MAGIC_VALUE) {
+	switch(card->dev->device) {
+	case 0x5415:
+		card->flags |= UM_FLAG_NO_BYTE_STATUS | UM_FLAG_NO_BATTREG;
+		magic_number = 0x59;
+		break;
+
+	case 0x5425:
+		card->flags |= UM_FLAG_NO_BYTE_STATUS;
+		magic_number = 0x5C;
+		break;
+
+	case 0x6155:
+		card->flags |= UM_FLAG_NO_BYTE_STATUS | UM_FLAG_NO_BATTREG | UM_FLAG_NO_BATT;
+		magic_number = 0x99;
+		break;
+
+	default:
+		magic_number = 0x100;
+		break;
+	}
+
+	if (readb(card->csr_remap + MEMCTRLSTATUS_MAGIC) != magic_number) {
 		printk(KERN_ERR "MM%d: Magic number invalid\n", card->card_number);
 		ret = -ENOMEM;
-
 		goto failed_magic;
 	}
+
 	card->mm_pages[0].desc = pci_alloc_consistent(card->dev,
 						      PAGE_SIZE*2,
 						      &card->mm_pages[0].page_dma);
@@ -997,14 +1026,19 @@
 	card->battery[1].good = !(batt_status & BATTERY_2_FAILURE);
 	card->battery[0].last_change = card->battery[1].last_change = jiffies;
 
-	printk(KERN_INFO "MM%d: Size %d KB, Battery 1 %s (%s), Battery 2 %s (%s)\n",
-	       card->card_number, card->mm_size,
-	       (batt_status & BATTERY_1_DISABLED ? "Disabled" : "Enabled"),
-	       card->battery[0].good ? "OK" : "FAILURE",
-	       (batt_status & BATTERY_2_DISABLED ? "Disabled" : "Enabled"),
-	       card->battery[1].good ? "OK" : "FAILURE");
+	if (card->flags & UM_FLAG_NO_BATT) 
+		printk(KERN_INFO "MM%d: Size %d KB\n",
+		       card->card_number, card->mm_size);
+	else {
+		printk(KERN_INFO "MM%d: Size %d KB, Battery 1 %s (%s), Battery 2 %s (%s)\n",
+		       card->card_number, card->mm_size,
+		       (batt_status & BATTERY_1_DISABLED ? "Disabled" : "Enabled"),
+		       card->battery[0].good ? "OK" : "FAILURE",
+		       (batt_status & BATTERY_2_DISABLED ? "Disabled" : "Enabled"),
+		       card->battery[1].good ? "OK" : "FAILURE");
 
-	set_fault_to_battery_status(card);
+		set_fault_to_battery_status(card);
+	}
 
 	pci_read_config_dword(dev, PCI_BASE_ADDRESS_1, &saved_bar);
 	data = 0xffffffff;
@@ -1117,6 +1151,16 @@
 	}, {
 	.vendor =	PCI_VENDOR_ID_MICRO_MEMORY,
 	.device =	PCI_DEVICE_ID_MICRO_MEMORY_5425CN,
+	}, {
+	.vendor =	PCI_VENDOR_ID_MICRO_MEMORY,
+	.device =	PCI_DEVICE_ID_MICRO_MEMORY_6155,
+	}, {
+	.vendor	=	0x8086,
+	.device	=	0xB555,
+	.subvendor=	0x1332,
+	.subdevice=	0x5460,
+	.class	=	0x050000,
+	.class_mask=	0,
 	}, { /* end: all zeroes */ }
 };
 
diff -Nru a/drivers/block/xd.c b/drivers/block/xd.c
--- a/drivers/block/xd.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/block/xd.c	Wed Apr 30 22:28:15 2003
@@ -57,7 +57,9 @@
 #include "xd.h"
 
 static void __init do_xd_setup (int *integers);
+#ifdef MODULE
 static int xd[5] = { -1,-1,-1,-1, };
+#endif
 
 #define XD_DONT_USE_DMA		0  /* Initial value. may be overriden using
 				      "nodma" module option */
@@ -148,16 +150,18 @@
 static int __init xd_init(void)
 {
 	u_char i,controller;
-	u_char count = 0;
 	unsigned int address;
 	int err;
 
 #ifdef MODULE
-	for (i = 4; i > 0; i--)
-		if (((xd[i] = xd[i-1]) >= 0) && !count)
-			count = i;
-	if ((xd[0] = count))
-		do_xd_setup(xd);
+	{
+		u_char count = 0;
+		for (i = 4; i > 0; i--)
+			if (((xd[i] = xd[i-1]) >= 0) && !count)
+				count = i;
+		if ((xd[0] = count))
+			do_xd_setup(xd);
+	}
 #endif
 
 	init_timer (&xd_watchdog_int); xd_watchdog_int.function = xd_watchdog;
@@ -446,17 +450,20 @@
 }
 
 /* xd_interrupt_handler: interrupt service routine */
-static void xd_interrupt_handler(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t xd_interrupt_handler(int irq, void *dev_id,
+					struct pt_regs *regs)
 {
 	if (inb(XD_STATUS) & STAT_INTERRUPT) {							/* check if it was our device */
 #ifdef DEBUG_OTHER
 		printk("xd_interrupt_handler: interrupt detected\n");
 #endif /* DEBUG_OTHER */
 		outb(0,XD_CONTROL);								/* acknowledge interrupt */
-		wake_up(&xd_wait_int);								/* and wake up sleeping processes */
+		wake_up(&xd_wait_int);	/* and wake up sleeping processes */
+		return IRQ_HANDLED;
 	}
 	else
 		printk("xd: unexpected interrupt\n");
+	return IRQ_NONE;
 }
 
 /* xd_setup_dma: set up the DMA controller for a data transfer */
diff -Nru a/drivers/block/xd.h b/drivers/block/xd.h
--- a/drivers/block/xd.h	Wed Apr 30 22:28:15 2003
+++ b/drivers/block/xd.h	Wed Apr 30 22:28:15 2003
@@ -13,6 +13,8 @@
  * Also thanks to: Salvador Abreu, Dave Thaler, Risto Kankkunen and Wim Van Dorst.
  */
 
+#include <linux/interrupt.h>
+
 /* XT hard disk controller registers */
 #define XD_DATA		(xd_iobase + 0x00)	/* data RW register */
 #define XD_RESET	(xd_iobase + 0x01)	/* reset WO register */
@@ -107,7 +109,8 @@
 static int xd_readwrite (u_char operation,XD_INFO *disk,char *buffer,u_int block,u_int count);
 static void xd_recalibrate (u_char drive);
 
-static void xd_interrupt_handler (int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t xd_interrupt_handler(int irq, void *dev_id,
+					struct pt_regs *regs);
 static u_char xd_setup_dma (u_char opcode,u_char *buffer,u_int count);
 static u_char *xd_build (u_char *cmdblk,u_char command,u_char drive,u_char head,u_short cylinder,u_char sector,u_char count,u_char control);
 static void xd_watchdog (unsigned long unused);
diff -Nru a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
--- a/drivers/bluetooth/Kconfig	Wed Apr 30 22:28:08 2003
+++ b/drivers/bluetooth/Kconfig	Wed Apr 30 22:28:08 2003
@@ -13,11 +13,18 @@
 	  Say Y here to compile support for Bluetooth USB devices into the
 	  kernel or say M to compile it as module (hci_usb).
 
+config BT_USB_SCO
+	bool "SCO over HCI USB support"
+	depends on BT_HCIUSB
+	help
+	  This option enables the SCO support in the HCI USB driver. You need this
+	  to transmit voice data with your Bluetooth USB device. 
+	  Say Y here to compile support for SCO over HCI USB.
+
 config BT_USB_ZERO_PACKET
 	bool "USB zero packet support"
 	depends on BT_HCIUSB
 	help
-	  Support for USB zero packets. 
 	  This option is provided only as a work around for buggy Bluetooth USB 
 	  devices. Do _not_ enable it unless you know for sure that your device 
 	  requires zero packets.
diff -Nru a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
--- a/drivers/bluetooth/bluecard_cs.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/bluetooth/bluecard_cs.c	Wed Apr 30 22:28:09 2003
@@ -822,19 +822,6 @@
 	return 0;
 }
 
-
-
-/* ======================== Card services ======================== */
-
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-	error_info_t err = { func, ret };
-
-	CardServices(ReportError, handle, &err);
-}
-
-
 dev_link_t *bluecard_attach(void)
 {
 	bluecard_info_t *info;
@@ -1075,36 +1062,29 @@
 	return 0;
 }
 
+static struct pcmcia_driver bluecard_driver = {
+	.owner		= THIS_MODULE,
+	.drv		= {
+		.name	= "bluecard_cs",
+	},
+	.attach		= bluecard_attach,
+	.detach		= bluecard_detach,
+};
 
-
-/* ======================== Module initialization ======================== */
-
-
-int __init init_bluecard_cs(void)
+static int __init init_bluecard_cs(void)
 {
-	servinfo_t serv;
-	int err;
-
-	CardServices(GetCardServicesInfo, &serv);
-	if (serv.Revision != CS_RELEASE_CODE) {
-		printk(KERN_NOTICE "bluecard_cs: Card Services release does not match!\n");
-		return -1;
-	}
-
-	err = register_pccard_driver(&dev_info, &bluecard_attach, &bluecard_detach);
-
-	return err;
+	return pcmcia_register_driver(&bluecard_driver);
 }
 
 
-void __exit exit_bluecard_cs(void)
+static void __exit exit_bluecard_cs(void)
 {
-	unregister_pccard_driver(&dev_info);
+	pcmcia_unregister_driver(&bluecard_driver);
 
+	/* XXX: this really needs to move into generic code.. */
 	while (dev_list != NULL)
 		bluecard_detach(dev_list);
 }
-
 
 module_init(init_bluecard_cs);
 module_exit(exit_bluecard_cs);
diff -Nru a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
--- a/drivers/bluetooth/bt3c_cs.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/bluetooth/bt3c_cs.c	Wed Apr 30 22:28:19 2003
@@ -569,19 +569,6 @@
 	return 0;
 }
 
-
-
-/* ======================== Card services ======================== */
-
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-	error_info_t err = { func, ret };
-
-	CardServices(ReportError, handle, &err);
-}
-
-
 dev_link_t *bt3c_attach(void)
 {
 	bt3c_info_t *info;
@@ -861,36 +848,29 @@
 	return 0;
 }
 
+static struct pcmcia_driver bt3c_driver = {
+	.owner		= THIS_MODULE,
+	.drv		= {
+		.name	= "bt3c_cs",
+	},
+	.attach		= bt3c_attach,
+	.detach		= bt3c_detach,
+};
 
-
-/* ======================== Module initialization ======================== */
-
-
-int __init init_bt3c_cs(void)
+static int __init init_bt3c_cs(void)
 {
-	servinfo_t serv;
-	int err;
-
-	CardServices(GetCardServicesInfo, &serv);
-	if (serv.Revision != CS_RELEASE_CODE) {
-		printk(KERN_NOTICE "bt3c_cs: Card Services release does not match!\n");
-		return -1;
-	}
-
-	err = register_pccard_driver(&dev_info, &bt3c_attach, &bt3c_detach);
-
-	return err;
+	return pcmcia_register_driver(&bt3c_driver);
 }
 
 
-void __exit exit_bt3c_cs(void)
+static void __exit exit_bt3c_cs(void)
 {
-	unregister_pccard_driver(&dev_info);
+	pcmcia_unregister_driver(&bt3c_driver);
 
+	/* XXX: this really needs to move into generic code.. */
 	while (dev_list != NULL)
 		bt3c_detach(dev_list);
 }
-
 
 module_init(init_bt3c_cs);
 module_exit(exit_bt3c_cs);
diff -Nru a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
--- a/drivers/bluetooth/btuart_cs.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/bluetooth/btuart_cs.c	Wed Apr 30 22:28:19 2003
@@ -576,19 +576,6 @@
 	return 0;
 }
 
-
-
-/* ======================== Card services ======================== */
-
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-	error_info_t err = { func, ret };
-
-	CardServices(ReportError, handle, &err);
-}
-
-
 dev_link_t *btuart_attach(void)
 {
 	btuart_info_t *info;
@@ -868,36 +855,29 @@
 	return 0;
 }
 
+static struct pcmcia_driver btuart_driver = {
+	.owner		= THIS_MODULE,
+	.drv		= {
+		.name	= "btuart_cs",
+	},
+	.attach		= btuart_attach,
+	.detach		= btuart_detach,
+};
 
-
-/* ======================== Module initialization ======================== */
-
-
-int __init init_btuart_cs(void)
+static int __init init_btuart_cs(void)
 {
-	servinfo_t serv;
-	int err;
-
-	CardServices(GetCardServicesInfo, &serv);
-	if (serv.Revision != CS_RELEASE_CODE) {
-		printk(KERN_NOTICE "btuart_cs: Card Services release does not match!\n");
-		return -1;
-	}
-
-	err = register_pccard_driver(&dev_info, &btuart_attach, &btuart_detach);
-
-	return err;
+	return pcmcia_register_driver(&btuart_driver);
 }
 
 
-void __exit exit_btuart_cs(void)
+static void __exit exit_btuart_cs(void)
 {
-	unregister_pccard_driver(&dev_info);
+	pcmcia_unregister_driver(&btuart_driver);
 
+	/* XXX: this really needs to move into generic code.. */
 	while (dev_list != NULL)
 		btuart_detach(dev_list);
 }
-
 
 module_init(init_btuart_cs);
 module_exit(exit_btuart_cs);
diff -Nru a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
--- a/drivers/bluetooth/dtl1_cs.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/bluetooth/dtl1_cs.c	Wed Apr 30 22:28:08 2003
@@ -555,19 +555,6 @@
 	return 0;
 }
 
-
-
-/* ======================== Card services ======================== */
-
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-	error_info_t err = { func, ret };
-
-	CardServices(ReportError, handle, &err);
-}
-
-
 dev_link_t *dtl1_attach(void)
 {
 	dtl1_info_t *info;
@@ -820,36 +807,29 @@
 	return 0;
 }
 
+static struct pcmcia_driver dtl1_driver = {
+	.owner		= THIS_MODULE,
+	.drv		= {
+		.name	= "dtl1_cs",
+	},
+	.attach		= dtl1_attach,
+	.detach		= dtl1_detach,
+};
 
-
-/* ======================== Module initialization ======================== */
-
-
-int __init init_dtl1_cs(void)
+static int __init init_dtl1_cs(void)
 {
-	servinfo_t serv;
-	int err;
-
-	CardServices(GetCardServicesInfo, &serv);
-	if (serv.Revision != CS_RELEASE_CODE) {
-		printk(KERN_NOTICE "dtl1_cs: Card Services release does not match!\n");
-		return -1;
-	}
-
-	err = register_pccard_driver(&dev_info, &dtl1_attach, &dtl1_detach);
-
-	return err;
+	return pcmcia_register_driver(&dtl1_driver);
 }
 
 
-void __exit exit_dtl1_cs(void)
+static void __exit exit_dtl1_cs(void)
 {
-	unregister_pccard_driver(&dev_info);
+	pcmcia_unregister_driver(&dtl1_driver);
 
+	/* XXX: this really needs to move into generic code.. */
 	while (dev_list != NULL)
 		dtl1_detach(dev_list);
 }
-
 
 module_init(init_dtl1_cs);
 module_exit(exit_dtl1_cs);
diff -Nru a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
--- a/drivers/bluetooth/hci_ldisc.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/bluetooth/hci_ldisc.c	Wed Apr 30 22:28:14 2003
@@ -145,7 +145,7 @@
 		int len;
 	
 		set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
-		len = tty->driver.write(tty, 0, skb->data, skb->len);
+		len = tty->driver->write(tty, 0, skb->data, skb->len);
 		hdev->stat.byte_tx += len;
 
 		skb_pull(skb, len);
@@ -193,8 +193,8 @@
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 
 	if (test_bit(HCI_UART_PROTO_SET, &hu->flags))
 		hu->proto->flush(hu);
@@ -286,8 +286,8 @@
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 
 	return 0;
 }
@@ -384,8 +384,8 @@
 	hu->hdev.stat.byte_rx += count;
 	spin_unlock(&hu->rx_lock);
 
-	if (test_and_clear_bit(TTY_THROTTLED,&tty->flags) && tty->driver.unthrottle)
-		tty->driver.unthrottle(tty);
+	if (test_and_clear_bit(TTY_THROTTLED,&tty->flags) && tty->driver->unthrottle)
+		tty->driver->unthrottle(tty);
 }
 
 static int hci_uart_register_dev(struct hci_uart *hu)
diff -Nru a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c
--- a/drivers/bluetooth/hci_usb.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/bluetooth/hci_usb.c	Wed Apr 30 22:28:17 2003
@@ -1,9 +1,10 @@
 /* 
-   BlueZ - Bluetooth protocol stack for Linux
+   HCI USB driver for Linux Bluetooth protocol stack (BlueZ)
    Copyright (C) 2000-2001 Qualcomm Incorporated
-
    Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
 
+   Copyright (C) 2003 Maxim Krasnyansky <maxk@qualcomm.com>
+
    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;
@@ -30,13 +31,11 @@
  *
  * $Id: hci_usb.c,v 1.8 2002/07/18 17:23:09 maxk Exp $    
  */
-#define VERSION "2.1"
+#define VERSION "2.4"
 
 #include <linux/config.h>
 #include <linux/module.h>
 
-#define __KERNEL_SYSCALLS__
-
 #include <linux/version.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -49,17 +48,15 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/skbuff.h>
-#include <linux/kmod.h>
 
 #include <linux/usb.h>
 
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
-#include "hci_usb.h"
 
-#define HCI_MAX_PENDING (HCI_MAX_BULK_RX + HCI_MAX_BULK_TX + 1)
+#include "hci_usb.h"
 
-#ifndef CONFIG_BT_HCIUSB_DEBUG
+#ifndef HCI_USB_DEBUG
 #undef  BT_DBG
 #define BT_DBG( A... )
 #undef  BT_DMP
@@ -67,8 +64,8 @@
 #endif
 
 #ifndef CONFIG_BT_USB_ZERO_PACKET
-#undef  URB_ZERO_PACKET
-#define URB_ZERO_PACKET 0
+#undef  USB_ZERO_PACKET
+#define USB_ZERO_PACKET 0
 #endif
 
 static struct usb_driver hci_usb_driver; 
@@ -80,6 +77,9 @@
 	/* Ericsson with non-standard id */
 	{ USB_DEVICE(0x0bdb, 0x1002) },
 
+	/* Bluetooth Ultraport Module from IBM */
+	{ USB_DEVICE(0x04bf, 0x030a) },
+
 	{ }	/* Terminating entry */
 };
 
@@ -92,108 +92,196 @@
 	{ }	/* Terminating entry */
 };
 
-static void hci_usb_interrupt(struct urb *urb, struct pt_regs *regs);
+struct _urb *_urb_alloc(int isoc, int gfp)
+{
+	struct _urb *_urb = kmalloc(sizeof(struct _urb) +
+				sizeof(struct usb_iso_packet_descriptor) * isoc, gfp);
+	if (_urb) {
+		memset(_urb, 0, sizeof(*_urb));
+		_urb->urb.count = (atomic_t)ATOMIC_INIT(1);
+		spin_lock_init(&_urb->urb.lock);
+	}
+	return _urb;
+}
+
+struct _urb *_urb_dequeue(struct _urb_queue *q)
+{
+	struct _urb *_urb = NULL;
+        unsigned long flags;
+        spin_lock_irqsave(&q->lock, flags);
+	{
+		struct list_head *head = &q->head;
+		struct list_head *next = head->next;
+		if (next != head) {
+			_urb = list_entry(next, struct _urb, list);
+			list_del(next); _urb->queue = NULL;
+		}
+	}
+	spin_unlock_irqrestore(&q->lock, flags);
+	return _urb;
+}
+
 static void hci_usb_rx_complete(struct urb *urb, struct pt_regs *regs);
 static void hci_usb_tx_complete(struct urb *urb, struct pt_regs *regs);
 
-static struct urb *hci_usb_get_completed(struct hci_usb *husb)
+#define __pending_tx(husb, type)  (&husb->pending_tx[type-1])
+#define __pending_q(husb, type)   (&husb->pending_q[type-1])
+#define __completed_q(husb, type) (&husb->completed_q[type-1])
+#define __transmit_q(husb, type)  (&husb->transmit_q[type-1])
+#define __reassembly(husb, type)  (husb->reassembly[type-1])
+
+static inline struct _urb *__get_completed(struct hci_usb *husb, int type)
 {
-	struct sk_buff *skb;
-	struct urb *urb = NULL;
+	return _urb_dequeue(__completed_q(husb, type)); 
+}
 
-	skb = skb_dequeue(&husb->completed_q);
-	if (skb) {
-		urb = ((struct hci_usb_scb *) skb->cb)->urb;
-		kfree_skb(skb);
-	}
+#ifdef CONFIG_BT_USB_SCO
+static void __fill_isoc_desc(struct urb *urb, int len, int mtu)
+{
+	int offset = 0, i;
 
-	BT_DBG("%s urb %p", husb->hdev.name, urb);
-	return urb;
+	BT_DBG("len %d mtu %d", len, mtu);
+
+	for (i=0; i < HCI_MAX_ISOC_FRAMES && len >= mtu; i++, offset += mtu, len -= mtu) {
+		urb->iso_frame_desc[i].offset = offset;
+		urb->iso_frame_desc[i].length = mtu;
+		BT_DBG("desc %d offset %d len %d", i, offset, mtu);
+	}
+	if (len && i < HCI_MAX_ISOC_FRAMES) {
+		urb->iso_frame_desc[i].offset = offset;
+		urb->iso_frame_desc[i].length = len;
+		BT_DBG("desc %d offset %d len %d", i, offset, len);
+		i++;
+	}
+	urb->number_of_packets = i;
 }
+#endif
 
-static int hci_usb_enable_intr(struct hci_usb *husb)
+static int hci_usb_intr_rx_submit(struct hci_usb *husb)
 {
+	struct _urb *_urb;
 	struct urb *urb;
-	int pipe, size;
+	int err, pipe, interval, size;
 	void *buf;
 
 	BT_DBG("%s", husb->hdev.name);
 
- 	if (!(urb = usb_alloc_urb(0, GFP_KERNEL)))
+        size = husb->intr_in_ep->desc.wMaxPacketSize;
+
+	buf = kmalloc(size, GFP_ATOMIC);
+	if (!buf)
 		return -ENOMEM;
 
-	if (!(buf = kmalloc(HCI_MAX_EVENT_SIZE, GFP_KERNEL))) {
-		usb_free_urb(urb);
+	_urb = _urb_alloc(0, GFP_ATOMIC);
+	if (!_urb) {
+		kfree(buf);
 		return -ENOMEM;
 	}
+	_urb->type = HCI_EVENT_PKT;
+	_urb_queue_tail(__pending_q(husb, _urb->type), _urb);
 
-	husb->intr_urb = urb;
-	
-        pipe = usb_rcvintpipe(husb->udev, husb->intr_ep);
-        size = usb_maxpacket(husb->udev, pipe, usb_pipeout(pipe));
-	usb_fill_int_urb(urb, husb->udev, pipe, buf, size, 
-			hci_usb_interrupt, husb, husb->intr_interval);
+	urb = &_urb->urb;
+	pipe     = usb_rcvintpipe(husb->udev, husb->intr_in_ep->desc.bEndpointAddress);
+	interval = husb->intr_in_ep->desc.bInterval;
+	usb_fill_int_urb(urb, husb->udev, pipe, buf, size, hci_usb_rx_complete, husb, interval);
 	
-	return usb_submit_urb(urb, GFP_KERNEL);
+	err = usb_submit_urb(urb, GFP_ATOMIC);
+	if (err) {
+		BT_ERR("%s intr rx submit failed urb %p err %d",
+				husb->hdev.name, urb, err);
+		_urb_unlink(_urb);
+		_urb_free(_urb);
+		kfree(buf);
+	}
+	return err;
 }
 
-static int hci_usb_disable_intr(struct hci_usb *husb)
+static int hci_usb_bulk_rx_submit(struct hci_usb *husb)
 {
-	struct urb *urb = husb->intr_urb;
-	struct sk_buff *skb;
-
-	BT_DBG("%s", husb->hdev.name);
+	struct _urb *_urb;
+	struct urb *urb;
+	int err, pipe, size = HCI_MAX_FRAME_SIZE;
+	void *buf;
 
-	usb_unlink_urb(urb); usb_free_urb(urb);
-	husb->intr_urb = NULL;
+	buf = kmalloc(size, GFP_ATOMIC);
+	if (!buf)
+		return -ENOMEM;
 
-	skb = husb->intr_skb;
-	if (skb) {
-		husb->intr_skb = NULL;
-		kfree_skb(skb);
+	_urb = _urb_alloc(0, GFP_ATOMIC);
+	if (!_urb) {
+		kfree(buf);
+		return -ENOMEM;
 	}
+	_urb->type = HCI_ACLDATA_PKT;
+	_urb_queue_tail(__pending_q(husb, _urb->type), _urb);
 
-	return 0;
+	urb  = &_urb->urb;
+	pipe = usb_rcvbulkpipe(husb->udev, husb->bulk_in_ep->desc.bEndpointAddress);
+        usb_fill_bulk_urb(urb, husb->udev, pipe, buf, size, hci_usb_rx_complete, husb);
+        urb->transfer_flags = 0;
+
+	BT_DBG("%s urb %p", husb->hdev.name, urb);
+
+	err = usb_submit_urb(urb, GFP_ATOMIC);
+	if (err) {
+		BT_ERR("%s bulk rx submit failed urb %p err %d",
+				husb->hdev.name, urb, err);
+		_urb_unlink(_urb);
+		_urb_free(_urb);
+		kfree(buf);
+	}
+	return err;
 }
 
-static int hci_usb_rx_submit(struct hci_usb *husb, struct urb *urb)
+#ifdef CONFIG_BT_USB_SCO
+static int hci_usb_isoc_rx_submit(struct hci_usb *husb)
 {
-	struct hci_usb_scb *scb;
-	struct sk_buff *skb;
-	int    pipe, size, err;
+	struct _urb *_urb;
+	struct urb *urb;
+	int err, mtu, size;
+	void *buf;
 
-	if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC)))
-		return -ENOMEM;
+	mtu  = husb->isoc_in_ep->desc.wMaxPacketSize;
+        size = mtu * HCI_MAX_ISOC_FRAMES;
 
-        size = HCI_MAX_FRAME_SIZE;
+	buf = kmalloc(size, GFP_ATOMIC);
+	if (!buf)
+		return -ENOMEM;
 
-	if (!(skb = bt_skb_alloc(size, GFP_ATOMIC))) {
-		usb_free_urb(urb);
+	_urb = _urb_alloc(HCI_MAX_ISOC_FRAMES, GFP_ATOMIC);
+	if (!_urb) {
+		kfree(buf);
 		return -ENOMEM;
 	}
-	
-	BT_DBG("%s urb %p", husb->hdev.name, urb);
+	_urb->type = HCI_SCODATA_PKT;
+	_urb_queue_tail(__pending_q(husb, _urb->type), _urb);
 
-	skb->dev = (void *) &husb->hdev;
-	skb->pkt_type = HCI_ACLDATA_PKT;
+	urb = &_urb->urb;
 
-	scb = (struct hci_usb_scb *) skb->cb;
-	scb->urb = urb;
+	urb->context  = husb;
+	urb->dev      = husb->udev;
+	urb->pipe     = usb_rcvisocpipe(husb->udev, husb->isoc_in_ep->desc.bEndpointAddress);
+	urb->complete = hci_usb_rx_complete;
 
-        pipe = usb_rcvbulkpipe(husb->udev, husb->bulk_in_ep);
+	urb->transfer_buffer_length = size;
+	urb->transfer_buffer = buf;
+	urb->transfer_flags  = URB_ISO_ASAP;
 
-        usb_fill_bulk_urb(urb, husb->udev, pipe, skb->data, size, hci_usb_rx_complete, skb);
+	__fill_isoc_desc(urb, size, mtu);
+
+	BT_DBG("%s urb %p", husb->hdev.name, urb);
 
-	skb_queue_tail(&husb->pending_q, skb);
 	err = usb_submit_urb(urb, GFP_ATOMIC);
 	if (err) {
-		BT_ERR("%s bulk rx submit failed urb %p err %d",
+		BT_ERR("%s isoc rx submit failed urb %p err %d",
 				husb->hdev.name, urb, err);
-		skb_unlink(skb);
-		usb_free_urb(urb);
+		_urb_unlink(_urb);
+		_urb_free(_urb);
+		kfree(buf);
 	}
 	return err;
 }
+#endif
 
 /* Initialize device */
 static int hci_usb_open(struct hci_dev *hdev)
@@ -209,13 +297,17 @@
 
 	write_lock_irqsave(&husb->completion_lock, flags);
 
-	err = hci_usb_enable_intr(husb);
+	err = hci_usb_intr_rx_submit(husb);
 	if (!err) {
 		for (i = 0; i < HCI_MAX_BULK_RX; i++)
-			hci_usb_rx_submit(husb, NULL);
-	} else
+			hci_usb_bulk_rx_submit(husb);
+
+#ifdef CONFIG_BT_USB_SCO
+		hci_usb_isoc_rx_submit(husb);
+#endif
+	} else {
 		clear_bit(HCI_RUNNING, &hdev->flags);
-	
+	}
 
 	write_unlock_irqrestore(&husb->completion_lock, flags);
 	return err;
@@ -225,29 +317,52 @@
 static int hci_usb_flush(struct hci_dev *hdev)
 {
 	struct hci_usb *husb = (struct hci_usb *) hdev->driver_data;
+	int i;
 
 	BT_DBG("%s", hdev->name);
 
-	skb_queue_purge(&husb->cmd_q);
-	skb_queue_purge(&husb->acl_q);
+	for (i=0; i < 4; i++)
+		skb_queue_purge(&husb->transmit_q[i]);
 	return 0;
 }
 
-static inline void hci_usb_unlink_urbs(struct hci_usb *husb)
+static void hci_usb_unlink_urbs(struct hci_usb *husb)
 {
-	struct sk_buff *skb;
-	struct urb *urb;
+	int i;
 
 	BT_DBG("%s", husb->hdev.name);
 
-	while ((skb = skb_dequeue(&husb->pending_q))) {
-		urb = ((struct hci_usb_scb *) skb->cb)->urb;
-		usb_unlink_urb(urb);
-		kfree_skb(skb);
-	}
+	for (i=0; i < 4; i++) {
+		struct _urb *_urb;
+		struct urb *urb;
+
+		/* Kill pending requests */
+		while ((_urb = _urb_dequeue(&husb->pending_q[i]))) {
+			urb = &_urb->urb;
+			BT_DBG("%s unlinking _urb %p type %d urb %p", 
+					husb->hdev.name, _urb, _urb->type, urb);
+			usb_unlink_urb(urb);
+			_urb_queue_tail(__completed_q(husb, _urb->type), _urb);
+		}
 
-	while ((urb = hci_usb_get_completed(husb)))
-		usb_free_urb(urb);
+		/* Release completed requests */
+		while ((_urb = _urb_dequeue(&husb->completed_q[i]))) {
+			urb = &_urb->urb;
+			BT_DBG("%s freeing _urb %p type %d urb %p",
+					husb->hdev.name, _urb, _urb->type, urb);
+			if (urb->setup_packet)
+				kfree(urb->setup_packet);
+			if (urb->transfer_buffer)
+				kfree(urb->transfer_buffer);
+			_urb_free(_urb);
+		}
+
+		/* Release reassembly buffers */
+		if (husb->reassembly[i]) {
+			kfree_skb(husb->reassembly[i]);
+			husb->reassembly[i] = NULL;
+		}
+	}
 }
 
 /* Close device */
@@ -261,114 +376,166 @@
 
 	BT_DBG("%s", hdev->name);
 
+	/* Synchronize with completion handlers */
 	write_lock_irqsave(&husb->completion_lock, flags);
+	write_unlock_irqrestore(&husb->completion_lock, flags);
 	
-	hci_usb_disable_intr(husb);
 	hci_usb_unlink_urbs(husb);
 	hci_usb_flush(hdev);
-
-	write_unlock_irqrestore(&husb->completion_lock, flags);
 	return 0;
 }
 
-static inline int hci_usb_send_ctrl(struct hci_usb *husb, struct sk_buff *skb)
+static int __tx_submit(struct hci_usb *husb, struct _urb *_urb)
 {
-	struct hci_usb_scb *scb = (void *) skb->cb;
-	struct urb *urb = hci_usb_get_completed(husb);
-	struct usb_ctrlrequest *cr;
-	int pipe, err;
-
-	if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC)))
-		return -ENOMEM;
+	struct urb *urb = &_urb->urb;
+	int err;
 
-	if (!(cr = kmalloc(sizeof(*cr), GFP_ATOMIC))) {
-		usb_free_urb(urb);
-		return -ENOMEM;
-	}
+	BT_DBG("%s urb %p type %d", husb->hdev.name, urb, _urb->type);
 	
-	pipe = usb_sndctrlpipe(husb->udev, 0);
+	_urb_queue_tail(__pending_q(husb, _urb->type), _urb);
+	err = usb_submit_urb(urb, GFP_ATOMIC);
+	if (err) {
+		BT_ERR("%s tx submit failed urb %p type %d err %d",
+				husb->hdev.name, urb, _urb->type, err);
+		_urb_unlink(_urb);
+		_urb_queue_tail(__completed_q(husb, _urb->type), _urb);
+	} else
+		atomic_inc(__pending_tx(husb, _urb->type));
 
-	cr->bRequestType = HCI_CTRL_REQ;
-	cr->bRequest = 0;
-	cr->wIndex   = 0;
-	cr->wValue   = 0;
-	cr->wLength  = __cpu_to_le16(skb->len);
+	return err;
+}
 
-	usb_fill_control_urb(urb, husb->udev, pipe, (void *) cr,
-			skb->data, skb->len, hci_usb_tx_complete, skb);
+static inline int hci_usb_send_ctrl(struct hci_usb *husb, struct sk_buff *skb)
+{
+	struct _urb *_urb = __get_completed(husb, skb->pkt_type);
+	struct usb_ctrlrequest *dr;
+	struct urb *urb;
 
-	BT_DBG("%s urb %p len %d", husb->hdev.name, urb, skb->len);
+	if (!_urb) {
+	       	_urb = _urb_alloc(0, GFP_ATOMIC);
+	       	if (!_urb)
+			return -ENOMEM;
+		_urb->type = skb->pkt_type;
+
+		dr = kmalloc(sizeof(*dr), GFP_ATOMIC);
+		if (!dr) {
+			_urb_free(_urb);
+			return -ENOMEM;
+		}
+	} else
+		dr = (void *) _urb->urb.setup_packet;
 
-	scb->urb = urb;
+	dr->bRequestType = HCI_CTRL_REQ;
+	dr->bRequest = 0;
+	dr->wIndex   = 0;
+	dr->wValue   = 0;
+	dr->wLength  = __cpu_to_le16(skb->len);
+
+	urb = &_urb->urb;
+	usb_fill_control_urb(urb, husb->udev, usb_sndctrlpipe(husb->udev, 0),
+		(void *) dr, skb->data, skb->len, hci_usb_tx_complete, husb);
 
-	skb_queue_tail(&husb->pending_q, skb);
-	err = usb_submit_urb(urb, GFP_ATOMIC);
-	if (err) {
-		BT_ERR("%s ctrl tx submit failed urb %p err %d", 
-				husb->hdev.name, urb, err);
-		skb_unlink(skb);
-		usb_free_urb(urb); kfree(cr);
-	}
-	return err;
+	BT_DBG("%s skb %p len %d", husb->hdev.name, skb, skb->len);
+	
+	_urb->priv = skb;
+	return __tx_submit(husb, _urb);
 }
 
 static inline int hci_usb_send_bulk(struct hci_usb *husb, struct sk_buff *skb)
 {
-	struct hci_usb_scb *scb = (void *) skb->cb;
-	struct urb *urb = hci_usb_get_completed(husb);
-	int pipe, err;
+	struct _urb *_urb = __get_completed(husb, skb->pkt_type);
+	struct urb *urb;
+	int pipe;
 
-	if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC)))
-		return -ENOMEM;
+	if (!_urb) {
+	       	_urb = _urb_alloc(0, GFP_ATOMIC);
+	       	if (!_urb)
+			return -ENOMEM;
+		_urb->type = skb->pkt_type;
+	}
 
-	pipe = usb_sndbulkpipe(husb->udev, husb->bulk_out_ep);
-        
-	usb_fill_bulk_urb(urb, husb->udev, pipe, skb->data, skb->len,
-	              hci_usb_tx_complete, skb);
-	urb->transfer_flags = URB_ZERO_PACKET;
+	urb  = &_urb->urb;
+	pipe = usb_sndbulkpipe(husb->udev, husb->bulk_out_ep->desc.bEndpointAddress);
+	usb_fill_bulk_urb(urb, husb->udev, pipe, skb->data, skb->len, 
+			hci_usb_tx_complete, husb);
+	urb->transfer_flags = USB_ZERO_PACKET;
 
-	BT_DBG("%s urb %p len %d", husb->hdev.name, urb, skb->len);
+	BT_DBG("%s skb %p len %d", husb->hdev.name, skb, skb->len);
 
-	scb->urb = urb;
+	_urb->priv = skb;
+	return __tx_submit(husb, _urb);
+}
 
-	skb_queue_tail(&husb->pending_q, skb);
-	err = usb_submit_urb(urb, GFP_ATOMIC);
-	if (err) {
-		BT_ERR("%s bulk tx submit failed urb %p err %d", 
-				husb->hdev.name, urb, err);
-		skb_unlink(skb);
-		usb_free_urb(urb);
+#ifdef CONFIG_BT_USB_SCO
+static inline int hci_usb_send_isoc(struct hci_usb *husb, struct sk_buff *skb)
+{
+	struct _urb *_urb = __get_completed(husb, skb->pkt_type);
+	struct urb *urb;
+	
+	if (!_urb) {
+	       	_urb = _urb_alloc(HCI_MAX_ISOC_FRAMES, GFP_ATOMIC);
+	       	if (!_urb)
+			return -ENOMEM;
+		_urb->type = skb->pkt_type;
 	}
-	return err;
+
+	BT_DBG("%s skb %p len %d", husb->hdev.name, skb, skb->len);
+
+	urb = &_urb->urb;
+	
+	urb->context  = husb;
+	urb->dev      = husb->udev;
+	urb->pipe     = usb_sndisocpipe(husb->udev, husb->isoc_out_ep->desc.bEndpointAddress);
+	urb->complete = hci_usb_tx_complete;
+	urb->transfer_flags = URB_ISO_ASAP;
+
+	urb->transfer_buffer = skb->data;
+	urb->transfer_buffer_length = skb->len;
+	
+	__fill_isoc_desc(urb, skb->len, husb->isoc_out_ep->desc.wMaxPacketSize);
+
+	_urb->priv = skb;
+	return __tx_submit(husb, _urb);
 }
+#endif
 
 static void hci_usb_tx_process(struct hci_usb *husb)
 {
+	struct sk_buff_head *q;
 	struct sk_buff *skb;
 
 	BT_DBG("%s", husb->hdev.name);
 
 	do {
 		clear_bit(HCI_USB_TX_WAKEUP, &husb->state);
+
+		/* Process command queue */
+		q = __transmit_q(husb, HCI_COMMAND_PKT);
+		if (!atomic_read(__pending_tx(husb, HCI_COMMAND_PKT)) &&
+				(skb = skb_dequeue(q))) {
+			if (hci_usb_send_ctrl(husb, skb) < 0)
+				skb_queue_head(q, skb);
+		}
+
+#ifdef CONFIG_BT_USB_SCO
+		/* Process SCO queue */
+		q = __transmit_q(husb, HCI_SCODATA_PKT);
+		if (!atomic_read(__pending_tx(husb, HCI_SCODATA_PKT)) &&
+				(skb = skb_dequeue(q))) {
+			if (hci_usb_send_isoc(husb, skb) < 0)
+				skb_queue_head(q, skb);
+		}
+#endif
 		
 		/* Process ACL queue */
-		while (skb_queue_len(&husb->pending_q) < HCI_MAX_PENDING &&
-				(skb = skb_dequeue(&husb->acl_q))) {
+		q = __transmit_q(husb, HCI_ACLDATA_PKT);
+		while (atomic_read(__pending_tx(husb, HCI_ACLDATA_PKT)) < HCI_MAX_BULK_TX &&
+				(skb = skb_dequeue(q))) {
 			if (hci_usb_send_bulk(husb, skb) < 0) {
-				skb_queue_head(&husb->acl_q, skb);
+				skb_queue_head(q, skb);
 				break;
 			}
 		}
-
-		/* Process command queue */
-		if (!test_bit(HCI_USB_CTRL_TX, &husb->state) &&
-			(skb = skb_dequeue(&husb->cmd_q)) != NULL) {
-			set_bit(HCI_USB_CTRL_TX, &husb->state);
-			if (hci_usb_send_ctrl(husb, skb) < 0) {
-				skb_queue_head(&husb->cmd_q, skb);
-				clear_bit(HCI_USB_CTRL_TX, &husb->state);
-			}
-		}
 	} while(test_bit(HCI_USB_TX_WAKEUP, &husb->state));
 }
 
@@ -383,7 +550,7 @@
 }
 
 /* Send frames from HCI layer */
-int hci_usb_send_frame(struct sk_buff *skb)
+static int hci_usb_send_frame(struct sk_buff *skb)
 {
 	struct hci_dev *hdev = (struct hci_dev *) skb->dev;
 	struct hci_usb *husb;
@@ -396,247 +563,227 @@
 	if (!test_bit(HCI_RUNNING, &hdev->flags))
 		return -EBUSY;
 
-	husb = (struct hci_usb *) hdev->driver_data;
-
 	BT_DBG("%s type %d len %d", hdev->name, skb->pkt_type, skb->len);
 
-	read_lock(&husb->completion_lock);
+	husb = (struct hci_usb *) hdev->driver_data;
 
 	switch (skb->pkt_type) {
 	case HCI_COMMAND_PKT:
-		skb_queue_tail(&husb->cmd_q, skb);
 		hdev->stat.cmd_tx++;
 		break;
 
 	case HCI_ACLDATA_PKT:
-		skb_queue_tail(&husb->acl_q, skb);
 		hdev->stat.acl_tx++;
 		break;
 
+#ifdef CONFIG_BT_USB_SCO
 	case HCI_SCODATA_PKT:
+		hdev->stat.sco_tx++;
+		break;
+#endif
+
 	default:
 		kfree_skb(skb);
-		break;
+		return 0;
 	}
+
+	read_lock(&husb->completion_lock);
+
+	skb_queue_tail(__transmit_q(husb, skb->pkt_type), skb);
 	hci_usb_tx_wakeup(husb);
 
 	read_unlock(&husb->completion_lock);
 	return 0;
 }
 
-static void hci_usb_interrupt(struct urb *urb, struct pt_regs *regs)
+static inline int __recv_frame(struct hci_usb *husb, int type, void *data, int count)
 {
-	struct hci_usb *husb = (void *) urb->context;
-	struct hci_usb_scb *scb;
-	struct sk_buff *skb;
-	struct hci_event_hdr *eh;
-	__u8 *data = urb->transfer_buffer;
-	int count = urb->actual_length;
-	int len = HCI_EVENT_HDR_SIZE;
-	int status;
-
-	BT_DBG("%s urb %p count %d", husb->hdev.name, urb, count);
+	BT_DBG("%s type %d data %p count %d", husb->hdev.name, type, data, count);
 
-	if (!test_bit(HCI_RUNNING, &husb->hdev.flags))
-		return;
-
-	switch (urb->status) {
-	case 0:
-		/* success */
-		break;
-	case -ECONNRESET:
-	case -ENOENT:
-	case -ESHUTDOWN:
-		/* this urb is terminated, clean up */
-		BT_DBG("%s urb shutting down with status: %d",
-				husb->hdev.name, urb->status);
-		return;
-	default:
-		BT_ERR("%s nonzero urb status received: %d",
-				husb->hdev.name, urb->status);
-		goto exit;
-	}
-
-	if (!count) {
-		BT_DBG("%s intr status %d, count %d", 
-				husb->hdev.name, urb->status, count);
-		goto exit;
-	}
-
-	read_lock(&husb->completion_lock);
-	
 	husb->hdev.stat.byte_rx += count;
 
-	if (!(skb = husb->intr_skb)) {
-		/* Start of the frame */
-		if (count < HCI_EVENT_HDR_SIZE)
-			goto bad_len;
+	while (count) {
+		struct sk_buff *skb = __reassembly(husb, type);
+		struct { int expect; } *scb;
+		int len = 0;
+	
+		if (!skb) {
+			/* Start of the frame */
 
-		eh  = (struct hci_event_hdr *) data;
-		len = eh->plen + HCI_EVENT_HDR_SIZE;
+			switch (type) {
+			case HCI_EVENT_PKT:
+				if (count >= HCI_EVENT_HDR_SIZE) {
+					struct hci_event_hdr *h = data;
+					len = HCI_EVENT_HDR_SIZE + h->plen;
+				} else
+					return -EILSEQ;
+				break;
 
-		if (count > len)
-			goto bad_len;
+			case HCI_ACLDATA_PKT:
+				if (count >= HCI_ACL_HDR_SIZE) {
+					struct hci_acl_hdr *h = data;
+					len = HCI_ACL_HDR_SIZE + __le16_to_cpu(h->dlen);
+				} else
+					return -EILSEQ;
+				break;
+#ifdef CONFIG_BT_USB_SCO
+			case HCI_SCODATA_PKT:
+				if (count >= HCI_SCO_HDR_SIZE) {
+					struct hci_sco_hdr *h = data;
+					len = HCI_SCO_HDR_SIZE + h->dlen;
+				} else 
+					return -EILSEQ;
+				break;
+#endif
+			}
+			BT_DBG("new packet len %d", len);
+				
+			skb = bt_skb_alloc(len, GFP_ATOMIC);
+			if (!skb) {
+				BT_ERR("%s no memory for the packet", husb->hdev.name);
+				return -ENOMEM;
+			}
+			skb->dev = (void *) &husb->hdev;
+			skb->pkt_type = type;
+	
+			__reassembly(husb, type) = skb;
 
-		skb = bt_skb_alloc(len, GFP_ATOMIC);
-		if (!skb) {
-			BT_ERR("%s no memory for event packet", husb->hdev.name);
-			goto done;
+			scb = (void *) skb->cb;
+			scb->expect = len;
+		} else {
+			/* Continuation */
+			scb = (void *) skb->cb;
+			len = scb->expect;
 		}
-		scb = (void *) skb->cb;
 
-		skb->dev = (void *) &husb->hdev;
-		skb->pkt_type = HCI_EVENT_PKT;
+		len = min(len, count);
+		
+		memcpy(skb_put(skb, len), data, len);
 
-		husb->intr_skb = skb;
-		scb->intr_len  = len;
-	} else {
-		/* Continuation */
-		scb = (void *) skb->cb;
-		len = scb->intr_len;
-		if (count > len) {
-			husb->intr_skb = NULL;
-			kfree_skb(skb);
-			goto bad_len;
+		scb->expect -= len;
+		if (!scb->expect) {
+			/* Complete frame */
+			__reassembly(husb, type) = NULL;
+			hci_recv_frame(skb);
 		}
-	}
 
-	memcpy(skb_put(skb, count), data, count);
-	scb->intr_len -= count;
-
-	if (!scb->intr_len) {
-		/* Complete frame */
-		husb->intr_skb = NULL;
-		hci_recv_frame(skb);
+		count -= len; data += len;
 	}
-
-done:
-	read_unlock(&husb->completion_lock);
-	goto exit;
-
-bad_len:
-	BT_ERR("%s bad frame len %d expected %d", husb->hdev.name, count, len);
-	husb->hdev.stat.err_rx++;
-	read_unlock(&husb->completion_lock);
-
-exit:
-	status = usb_submit_urb (urb, GFP_ATOMIC);
-	if (status)
-		BT_ERR ("%s usb_submit_urb failed with result %d",
-				husb->hdev.name, status);
+	return 0;
 }
 
-static void hci_usb_tx_complete(struct urb *urb, struct pt_regs *regs)
+static void hci_usb_rx_complete(struct urb *urb, struct pt_regs *regs)
 {
-	struct sk_buff *skb  = (struct sk_buff *) urb->context;
-	struct hci_dev *hdev = (struct hci_dev *) skb->dev;
-	struct hci_usb *husb = (struct hci_usb *) hdev->driver_data;
+	struct _urb *_urb = container_of(urb, struct _urb, urb);
+	struct hci_usb *husb = (void *) urb->context;
+	struct hci_dev *hdev = &husb->hdev;
+	int    err, count = urb->actual_length;
 
-	BT_DBG("%s urb %p status %d flags %x", husb->hdev.name, urb,
-			urb->status, urb->transfer_flags);
-
-	if (urb->pipe == usb_sndctrlpipe(husb->udev, 0)) {
-		kfree(urb->setup_packet);
-		clear_bit(HCI_USB_CTRL_TX, &husb->state);
-	}
+	BT_DBG("%s urb %p type %d status %d count %d flags %x", hdev->name, urb,
+			_urb->type, urb->status, count, urb->transfer_flags);
 
 	if (!test_bit(HCI_RUNNING, &hdev->flags))
 		return;
 
 	read_lock(&husb->completion_lock);
-	
-	if (!urb->status)
-		husb->hdev.stat.byte_tx += skb->len;
-	else
-		husb->hdev.stat.err_tx++;
 
-	skb_unlink(skb);
-	skb_queue_tail(&husb->completed_q, skb);
-	hci_usb_tx_wakeup(husb);
-	
+	if (urb->status || !count)
+		goto resubmit;
+
+	if (_urb->type == HCI_SCODATA_PKT) {
+#ifdef CONFIG_BT_USB_SCO
+		int i;
+		for (i=0; i < urb->number_of_packets; i++) {
+			BT_DBG("desc %d status %d offset %d len %d", i,
+					urb->iso_frame_desc[i].status,
+					urb->iso_frame_desc[i].offset,
+					urb->iso_frame_desc[i].actual_length);
+	
+			if (!urb->iso_frame_desc[i].status)
+				__recv_frame(husb, _urb->type, 
+					urb->transfer_buffer + urb->iso_frame_desc[i].offset,
+					urb->iso_frame_desc[i].actual_length);
+		}
+#else
+		;
+#endif
+	} else {
+		err = __recv_frame(husb, _urb->type, urb->transfer_buffer, count);
+		if (err < 0) { 
+			BT_ERR("%s corrupted packet: type %d count %d",
+					husb->hdev.name, _urb->type, count);
+			hdev->stat.err_rx++;
+		}
+	}
+
+resubmit:
+	urb->dev = husb->udev;
+	err      = usb_submit_urb(urb, GFP_ATOMIC);
+	BT_DBG("%s urb %p type %d resubmit status %d", hdev->name, urb,
+			_urb->type, err);
+
 	read_unlock(&husb->completion_lock);
-	return;
 }
 
-static void hci_usb_rx_complete(struct urb *urb, struct pt_regs *regs)
+static void hci_usb_tx_complete(struct urb *urb, struct pt_regs *regs)
 {
-	struct sk_buff *skb  = (struct sk_buff *) urb->context;
-	struct hci_dev *hdev = (struct hci_dev *) skb->dev;
-	struct hci_usb *husb = (struct hci_usb *) hdev->driver_data;
-	int status, count = urb->actual_length;
-	struct hci_acl_hdr *ah;
-	int dlen, size;
-
-	BT_DBG("%s urb %p status %d count %d flags %x", husb->hdev.name, urb,
-			urb->status, count, urb->transfer_flags);
+	struct _urb *_urb = container_of(urb, struct _urb, urb);
+	struct hci_usb *husb = (void *) urb->context;
+	struct hci_dev *hdev = &husb->hdev;
 
-	if (!test_bit(HCI_RUNNING, &hdev->flags))
-		return;
+	BT_DBG("%s urb %p status %d flags %x", hdev->name, urb,
+			urb->status, urb->transfer_flags);
 
-	read_lock(&husb->completion_lock);
+	atomic_dec(__pending_tx(husb, _urb->type));
 
-	if (urb->status || !count)
-		goto resubmit;
+	urb->transfer_buffer = NULL;
+	kfree_skb((struct sk_buff *) _urb->priv);
 
-	husb->hdev.stat.byte_rx += count;
+	if (!test_bit(HCI_RUNNING, &hdev->flags))
+		return;
 
-	ah   = (struct hci_acl_hdr *) skb->data;
-	dlen = __le16_to_cpu(ah->dlen);
-	size = HCI_ACL_HDR_SIZE + dlen;
-
-	/* Verify frame len and completeness */
-	if (count != size) {
-		BT_ERR("%s corrupted ACL packet: count %d, dlen %d",
-				husb->hdev.name, count, dlen);
-		bt_dump("hci_usb", skb->data, count);
-		husb->hdev.stat.err_rx++;
-		goto resubmit;
-	}
+	if (!urb->status)
+		hdev->stat.byte_tx += urb->transfer_buffer_length;
+	else
+		hdev->stat.err_tx++;
 
-	skb_unlink(skb);
-	skb_put(skb, count);
-	hci_recv_frame(skb);
+	read_lock(&husb->completion_lock);
 
-	hci_usb_rx_submit(husb, urb);
+	_urb_unlink(_urb);
+	_urb_queue_tail(__completed_q(husb, _urb->type), _urb);
 
-	read_unlock(&husb->completion_lock);
-	return;
-		
-resubmit:
-	urb->dev = husb->udev;
-	status   = usb_submit_urb(urb, GFP_ATOMIC);
-	BT_DBG("%s URB resubmit status %d", husb->hdev.name, status);
+	hci_usb_tx_wakeup(husb);
+	
 	read_unlock(&husb->completion_lock);
 }
 
 static void hci_usb_destruct(struct hci_dev *hdev)
 {
-	struct hci_usb *husb;
-
-	if (!hdev) return;
+	struct hci_usb *husb = (struct hci_usb *) hdev->driver_data;
 
 	BT_DBG("%s", hdev->name);
 
-	husb = (struct hci_usb *) hdev->driver_data;
 	kfree(husb);
 }
 
 int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
 {
-	struct usb_device *udev = interface_to_usbdev(intf);	
+	struct usb_device *udev = interface_to_usbdev(intf);
 	struct usb_host_endpoint *bulk_out_ep[HCI_MAX_IFACE_NUM];
 	struct usb_host_endpoint *isoc_out_ep[HCI_MAX_IFACE_NUM];
 	struct usb_host_endpoint *bulk_in_ep[HCI_MAX_IFACE_NUM];
 	struct usb_host_endpoint *isoc_in_ep[HCI_MAX_IFACE_NUM];
 	struct usb_host_endpoint *intr_in_ep[HCI_MAX_IFACE_NUM];
+	struct usb_host_endpoint  *ep;
 	struct usb_host_interface *uif;
-	struct usb_host_endpoint *ep;
 	struct usb_interface *iface, *isoc_iface;
 	struct hci_usb *husb;
 	struct hci_dev *hdev;
 	int i, a, e, size, ifn, isoc_ifnum, isoc_alts;
 
-	BT_DBG("intf %p", intf);
+	BT_DBG("udev %p ifnum %d", udev, ifnum);
+
+	iface = &udev->actconfig->interface[0];
 
 	/* Check our black list */
 	if (usb_match_id(intf, ignore_ids))
@@ -679,6 +826,7 @@
 						bulk_out_ep[i] = ep;
 					break;
 
+#ifdef CONFIG_BT_USB_SCO
 				case USB_ENDPOINT_XFER_ISOC:
 					if (ep->desc.wMaxPacketSize < size)
 						break;
@@ -693,6 +841,7 @@
 					else
 						isoc_out_ep[i] = ep;
 					break;
+#endif
 				}
 			}
 		}
@@ -703,10 +852,12 @@
 		goto done;
 	}
 
+#ifdef CONFIG_BT_USB_SCO
 	if (!isoc_in_ep[1] || !isoc_out_ep[1]) {
 		BT_DBG("Isoc endpoints not found");
 		isoc_iface = NULL;
 	}
+#endif
 
 	if (!(husb = kmalloc(sizeof(struct hci_usb), GFP_KERNEL))) {
 		BT_ERR("Can't allocate: control structure");
@@ -716,35 +867,36 @@
 	memset(husb, 0, sizeof(struct hci_usb));
 
 	husb->udev = udev;
-	husb->bulk_out_ep = bulk_out_ep[0]->desc.bEndpointAddress;
-	husb->bulk_in_ep  = bulk_in_ep[0]->desc.bEndpointAddress;
-
-	husb->intr_ep = intr_in_ep[0]->desc.bEndpointAddress;
-	husb->intr_interval = intr_in_ep[0]->desc.bInterval;
+	husb->bulk_out_ep = bulk_out_ep[0];
+	husb->bulk_in_ep  = bulk_in_ep[0];
+	husb->intr_in_ep  = intr_in_ep[0];
 
+#ifdef CONFIG_BT_USB_SCO
 	if (isoc_iface) {
+		BT_DBG("isoc ifnum %d alts %d", isoc_ifnum, isoc_alts);
 		if (usb_set_interface(udev, isoc_ifnum, isoc_alts)) {
 			BT_ERR("Can't set isoc interface settings");
 			isoc_iface = NULL;
 		}
 		usb_driver_claim_interface(&hci_usb_driver, isoc_iface, husb);
 		husb->isoc_iface  = isoc_iface;
-
-		husb->isoc_in_ep  = isoc_in_ep[1]->desc.bEndpointAddress;
-		husb->isoc_out_ep = isoc_in_ep[1]->desc.bEndpointAddress;
+		husb->isoc_in_ep  = isoc_in_ep[isoc_ifnum];
+		husb->isoc_out_ep = isoc_out_ep[isoc_ifnum];
 	}
-
-	husb->completion_lock = RW_LOCK_UNLOCKED;
+#endif
 	
-	skb_queue_head_init(&husb->acl_q);
-	skb_queue_head_init(&husb->cmd_q);
-	skb_queue_head_init(&husb->pending_q);
-	skb_queue_head_init(&husb->completed_q);
+	husb->completion_lock = RW_LOCK_UNLOCKED;
+
+	for (i = 0; i < 4; i++) {	
+		skb_queue_head_init(&husb->transmit_q[i]);
+		_urb_queue_init(&husb->pending_q[i]);
+		_urb_queue_init(&husb->completed_q[i]);
+	}
 
 	/* Initialize and register HCI device */
 	hdev = &husb->hdev;
 
-	hdev->type = HCI_USB;
+	hdev->type  = HCI_USB;
 	hdev->driver_data = husb;
 
 	hdev->open  = hci_usb_open;
@@ -754,7 +906,7 @@
 	hdev->destruct = hci_usb_destruct;
 
 	hdev->owner = THIS_MODULE;
-	
+
 	if (hci_register_dev(hdev) < 0) {
 		BT_ERR("Can't register HCI device");
 		goto probe_error;
@@ -773,13 +925,12 @@
 static void hci_usb_disconnect(struct usb_interface *intf)
 {
 	struct hci_usb *husb = usb_get_intfdata(intf);
-	struct hci_dev *hdev;
+	struct hci_dev *hdev = &husb->hdev;
 
 	if (!husb)
 		return;
 	usb_set_intfdata(intf, NULL);
 
-	hdev = &husb->hdev;
 	BT_DBG("%s", hdev->name);
 
 	hci_usb_close(hdev);
@@ -792,10 +943,10 @@
 }
 
 static struct usb_driver hci_usb_driver = {
-	.name       = "hci_usb",
-	.probe      = hci_usb_probe,
-	.disconnect = hci_usb_disconnect,
-	.id_table   = bluetooth_ids
+	.name       =  "hci_usb",
+	.probe      =  hci_usb_probe,
+	.disconnect =  hci_usb_disconnect,
+	.id_table   =  bluetooth_ids,
 };
 
 int hci_usb_init(void)
diff -Nru a/drivers/bluetooth/hci_usb.h b/drivers/bluetooth/hci_usb.h
--- a/drivers/bluetooth/hci_usb.h	Wed Apr 30 22:28:15 2003
+++ b/drivers/bluetooth/hci_usb.h	Wed Apr 30 22:28:15 2003
@@ -1,9 +1,10 @@
 /* 
-   BlueZ - Bluetooth protocol stack for Linux
+   HCI USB driver for Linux Bluetooth protocol stack (BlueZ)
    Copyright (C) 2000-2001 Qualcomm Incorporated
-
    Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
 
+   Copyright (C) 2003 Maxim Krasnyansky <maxk@qualcomm.com>
+
    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;
@@ -40,40 +41,96 @@
 #define HCI_MAX_BULK_TX     	4
 #define HCI_MAX_BULK_RX     	1
 
+#define HCI_MAX_ISOC_FRAMES     10
+
+struct _urb_queue {
+	struct list_head head;
+	spinlock_t       lock;
+};
+
+struct _urb {
+	struct list_head  list;
+	struct _urb_queue *queue;
+	int               type;
+	void              *priv;
+	struct urb        urb;
+};
+
+struct _urb *_urb_alloc(int isoc, int gfp);
+
+static inline void _urb_free(struct _urb *_urb)
+{
+	kfree(_urb);
+}
+
+static inline void _urb_queue_init(struct _urb_queue *q)
+{
+	INIT_LIST_HEAD(&q->head);
+	spin_lock_init(&q->lock);
+}
+
+static inline void _urb_queue_head(struct _urb_queue *q, struct _urb *_urb)
+{
+        unsigned long flags;
+        spin_lock_irqsave(&q->lock, flags);
+	list_add(&_urb->list, &q->head); _urb->queue = q;
+	spin_unlock_irqrestore(&q->lock, flags);
+}
+
+static inline void _urb_queue_tail(struct _urb_queue *q, struct _urb *_urb)
+{
+        unsigned long flags;
+        spin_lock_irqsave(&q->lock, flags);
+	list_add_tail(&_urb->list, &q->head); _urb->queue = q;
+	spin_unlock_irqrestore(&q->lock, flags);
+}
+
+static inline void _urb_unlink(struct _urb *_urb)
+{
+	struct _urb_queue *q = _urb->queue;
+        unsigned long flags;
+	if (q) {
+        	spin_lock_irqsave(&q->lock, flags);
+		list_del(&_urb->list); _urb->queue = NULL;
+		spin_unlock_irqrestore(&q->lock, flags);
+	}
+}
+
+struct _urb *_urb_dequeue(struct _urb_queue *q);
+
+#ifndef container_of
+#define container_of(ptr, type, member) ({                      \
+		        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
+			        (type *)( (char *)__mptr - offsetof(type,member) );})
+#endif
+
 struct hci_usb {
 	struct hci_dev		hdev;
 
 	unsigned long		state;
 	
 	struct usb_device 	*udev;
-	struct usb_interface    *isoc_iface;
 	
-	__u8			bulk_out_ep;
-	__u8			bulk_in_ep;
-	__u8			isoc_out_ep;
-	__u8			isoc_in_ep;
-
-	__u8			intr_ep;
-	__u8			intr_interval;
-	struct urb		*intr_urb;
-	struct sk_buff		*intr_skb;
+	struct usb_host_endpoint	*bulk_in_ep;
+	struct usb_host_endpoint	*bulk_out_ep;
+	struct usb_host_endpoint	*intr_in_ep;
+
+	struct usb_interface            *isoc_iface;
+	struct usb_host_endpoint	*isoc_out_ep;
+	struct usb_host_endpoint	*isoc_in_ep;
+
+	struct sk_buff_head	transmit_q[4];
+	struct sk_buff		*reassembly[4]; // Reassembly buffers
 
 	rwlock_t		completion_lock;
-	
-	struct sk_buff_head	cmd_q;	     // TX Commands
-	struct sk_buff_head	acl_q;	     // TX ACLs
-	struct sk_buff_head	pending_q;   // Pending requests
-	struct sk_buff_head	completed_q; // Completed requests
-};
 
-struct hci_usb_scb {
-	struct urb *urb;
-	int    intr_len;
+	atomic_t		pending_tx[4];  // Number of pending requests 
+	struct _urb_queue	pending_q[4];   // Pending requests
+	struct _urb_queue	completed_q[4]; // Completed requests
 };
 
 /* States  */
 #define HCI_USB_TX_PROCESS	1
 #define HCI_USB_TX_WAKEUP	2
-#define HCI_USB_CTRL_TX		3
 
 #endif /* __KERNEL__ */
diff -Nru a/drivers/cdrom/aztcd.c b/drivers/cdrom/aztcd.c
--- a/drivers/cdrom/aztcd.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/cdrom/aztcd.c	Wed Apr 30 22:28:17 2003
@@ -180,7 +180,6 @@
 #include <linux/ioport.h>
 #include <linux/string.h>
 #include <linux/major.h>
-#include <linux/devfs_fs_kernel.h>
 
 #include <linux/init.h>
 
@@ -1922,12 +1921,9 @@
 	azt_disk->first_minor = 0;
 	azt_disk->fops = &azt_fops;
 	sprintf(azt_disk->disk_name, "aztcd");
+	sprintf(azt_disk->devfs_name, "aztcd");
 	azt_disk->queue = &azt_queue;
 	add_disk(azt_disk);
-	devfs_register(NULL, "aztcd", DEVFS_FL_DEFAULT,
-		       azt_disk->major, azt_disk->first_minor,
-		       S_IFBLK | S_IRUGO | S_IWUGO, azt_disk->fops, NULL);
-
 	azt_invalidate_buffers();
 	aztPresent = 1;
 	aztCloseDoor();
@@ -1946,7 +1942,6 @@
 
 static void __exit aztcd_exit(void)
 {
-	devfs_remove("aztcd");
 	del_gendisk(azt_disk);
 	put_disk(azt_disk);
 	if ((unregister_blkdev(MAJOR_NR, "aztcd") == -EINVAL)) {
diff -Nru a/drivers/cdrom/cdu31a.c b/drivers/cdrom/cdu31a.c
--- a/drivers/cdrom/cdu31a.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/cdrom/cdu31a.c	Wed Apr 30 22:28:12 2003
@@ -451,7 +451,7 @@
  */
 static int scd_reset(struct cdrom_device_info *cdi)
 {
-	int retry_count;
+	unsigned long retry_count;
 
 	reset_drive();
 
@@ -511,7 +511,7 @@
 	outb(cmd, sony_cd_cmd_reg);
 }
 
-static void cdu31a_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t cdu31a_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	unsigned char val;
 
@@ -545,6 +545,7 @@
 		printk
 		    ("CDU31A: Got an interrupt but nothing was waiting\n");
 	}
+	return IRQ_HANDLED;
 }
 
 /*
@@ -712,7 +713,7 @@
 {
 	unsigned char res_reg[12];
 	unsigned int res_size;
-	unsigned int retry_count;
+	unsigned long retry_count;
 
 
 	printk("cdu31a: Resetting drive on error\n");
@@ -772,7 +773,7 @@
 {
 	unsigned char a, b;
 	int i;
-	unsigned int retry_count;
+	unsigned long retry_count;
 
 
 	while (handle_sony_cd_attention());
@@ -900,7 +901,7 @@
 	       unsigned int num_params,
 	       unsigned char *result_buffer, unsigned int *result_size)
 {
-	unsigned int retry_count;
+	unsigned long retry_count;
 	int num_retries;
 	int recursive_call;
 	unsigned long flags;
@@ -1148,7 +1149,7 @@
 {
 	unsigned char params[6];
 	unsigned int read_size;
-	unsigned int retry_count;
+	unsigned long retry_count;
 
 
 #if DEBUG
@@ -1339,7 +1340,7 @@
 		unsigned int nblocks,
 		unsigned char res_reg[], int *res_size)
 {
-	unsigned int retry_count;
+	unsigned long retry_count;
 	unsigned int bytesleft;
 	unsigned int offset;
 	unsigned int skip;
@@ -2372,7 +2373,7 @@
 static void
 read_audio_data(char *buffer, unsigned char res_reg[], int *res_size)
 {
-	unsigned int retry_count;
+	unsigned long retry_count;
 	int result_read;
 
 
@@ -3206,7 +3207,7 @@
 get_drive_configuration(unsigned short base_io,
 			unsigned char res_reg[], unsigned int *res_size)
 {
-	int retry_count;
+	unsigned long retry_count;
 
 
 	/* Set the base address */
diff -Nru a/drivers/cdrom/cm206.c b/drivers/cdrom/cm206.c
--- a/drivers/cdrom/cm206.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/cdrom/cm206.c	Wed Apr 30 22:28:16 2003
@@ -360,8 +360,7 @@
    as there seems so reason for this to happen.
 */
 
-static void cm206_interrupt(int sig, void *dev_id, struct pt_regs *regs)
-/* you rang? */
+static irqreturn_t cm206_interrupt(int sig, void *dev_id, struct pt_regs *regs)
 {
 	volatile ush fool;
 	cd->intr_ds = inw(r_data_status);	/* resets data_ready, data_error,
@@ -436,6 +435,7 @@
 		|| cd->fifo_overflowed))
 		tasklet_schedule(&cm206_tasklet);	/* issue a stop read command */
 	stats(interrupt);
+	return IRQ_HANDLED;
 }
 
 /* we have put the address of the wait queue in who */
diff -Nru a/drivers/cdrom/gscd.c b/drivers/cdrom/gscd.c
--- a/drivers/cdrom/gscd.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/cdrom/gscd.c	Wed Apr 30 22:28:03 2003
@@ -63,7 +63,6 @@
 #include <linux/major.h>
 #include <linux/string.h>
 #include <linux/init.h>
-#include <linux/devfs_fs_kernel.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
@@ -883,7 +882,6 @@
 {
 	CLEAR_TIMER;
 
-	devfs_remove("gscd");
 	del_gendisk(gscd_disk);
 	put_disk(gscd_disk);
 	if ((unregister_blkdev(MAJOR_NR, "gscd") == -EINVAL)) {
@@ -958,14 +956,12 @@
 	gscd_disk->first_minor = 0;
 	gscd_disk->fops = &gscd_fops;
 	sprintf(gscd_disk->disk_name, "gscd");
+	sprintf(gscd_disk->devfs_name, "gscd");
 
 	if (register_blkdev(MAJOR_NR, "gscd")) {
 		ret = -EIO;
 		goto err_out2;
 	}
-
-	devfs_register(NULL, "gscd", DEVFS_FL_DEFAULT, MAJOR_NR, 0,
-		       S_IFBLK | S_IRUGO | S_IWUGO, &gscd_fops, NULL);
 
 	blk_init_queue(&gscd_queue, do_gscd_request, &gscd_lock);
 
diff -Nru a/drivers/cdrom/mcd.c b/drivers/cdrom/mcd.c
--- a/drivers/cdrom/mcd.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/cdrom/mcd.c	Wed Apr 30 22:28:11 2003
@@ -623,7 +623,7 @@
  * Just take the interrupt and clear out the status reg.
  */
 
-static void mcd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t mcd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	int st;
 
@@ -635,6 +635,7 @@
 		if ((st & 0xFF) != 0xFF)
 			mcd_error = st ? st & 0xFF : -1;
 	}
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/cdrom/mcdx.c b/drivers/cdrom/mcdx.c
--- a/drivers/cdrom/mcdx.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/cdrom/mcdx.c	Wed Apr 30 22:28:09 2003
@@ -260,9 +260,6 @@
 	addresses, such as mcdx_open and mcdx_close in the
 	structure mcdx_dops. */
 
-/* ???  exported by the mcdx_sigaction struct */
-static void mcdx_intr(int, void *, struct pt_regs *);
-
 /* exported by file_ops */
 static int mcdx_open(struct cdrom_device_info *cdi, int purpose);
 static void mcdx_close(struct cdrom_device_info *cdi);
@@ -854,7 +851,7 @@
 	}
 }
 
-static void mcdx_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t mcdx_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct s_drive_stuff *stuffp;
 	unsigned char b;
@@ -863,7 +860,7 @@
 
 	if (stuffp == NULL) {
 		xwarn("mcdx: no device for intr %d\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 #ifdef AK2
 	if (!stuffp->busy && stuffp->pending)
@@ -895,6 +892,7 @@
 
 	stuffp->busy = 0;
 	wake_up_interruptible(&stuffp->busyq);
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/cdrom/optcd.c b/drivers/cdrom/optcd.c
--- a/drivers/cdrom/optcd.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/cdrom/optcd.c	Wed Apr 30 22:28:06 2003
@@ -71,7 +71,6 @@
 #include <linux/mm.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
-#include <linux/devfs_fs_kernel.h>
 
 #include <asm/io.h>
 #include <linux/blk.h>
@@ -2033,6 +2032,8 @@
 	optcd_disk->first_minor = 0;
 	optcd_disk->fops = &opt_fops;
 	sprintf(optcd_disk->disk_name, "optcd");
+	sprintf(optcd_disk->devfs_name, "optcd");
+
 	if (!request_region(optcd_port, 4, "optcd")) {
 		printk(KERN_ERR "optcd: conflict, I/O port 0x%x already used\n",
 			optcd_port);
@@ -2065,8 +2066,8 @@
 		put_disk(optcd_disk);
 		return -EIO;
 	}
-	devfs_register (NULL, "optcd", DEVFS_FL_DEFAULT, MAJOR_NR, 0,
-			S_IFBLK | S_IRUGO | S_IWUGO, &opt_fops, NULL);
+
+
 	blk_init_queue(&opt_queue, do_optcd_request, &optcd_lock);
 	blk_queue_hardsect_size(&opt_queue, 2048);
 	optcd_disk->queue = &opt_queue;
@@ -2079,7 +2080,6 @@
 
 static void __exit optcd_exit(void)
 {
-	devfs_remove("optcd");
 	del_gendisk(optcd_disk);
 	put_disk(optcd_disk);
 	if (unregister_blkdev(MAJOR_NR, "optcd") == -EINVAL) {
diff -Nru a/drivers/cdrom/sjcd.c b/drivers/cdrom/sjcd.c
--- a/drivers/cdrom/sjcd.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/cdrom/sjcd.c	Wed Apr 30 22:28:11 2003
@@ -70,7 +70,6 @@
 #include <linux/string.h>
 #include <linux/major.h>
 #include <linux/init.h>
-#include <linux/devfs_fs_kernel.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
@@ -1692,6 +1691,7 @@
 	sjcd_disk->first_minor = 0,
 	sjcd_disk->fops = &sjcd_fops,
 	sprintf(sjcd_disk->disk_name, "sjcd");
+	sprintf(sjcd_disk->devfs_name, "sjcd");
 
 	if (check_region(sjcd_base, 4)) {
 		printk
@@ -1778,8 +1778,6 @@
 	}
 
 	printk(KERN_INFO "SJCD: Status: port=0x%x.\n", sjcd_base);
-	devfs_register(NULL, "sjcd", DEVFS_FL_DEFAULT, MAJOR_NR, 0,
-		       S_IFBLK | S_IRUGO | S_IWUGO, &sjcd_fops, NULL);
 	sjcd_disk->queue = &sjcd_queue;
 	add_disk(sjcd_disk);
 
@@ -1798,7 +1796,6 @@
 
 static void __exit sjcd_exit(void)
 {
-	devfs_remove("sjcd");
 	del_gendisk(sjcd_disk);
 	put_disk(sjcd_disk);
 	release_region(sjcd_base, 4);
diff -Nru a/drivers/cdrom/sonycd535.c b/drivers/cdrom/sonycd535.c
--- a/drivers/cdrom/sonycd535.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/cdrom/sonycd535.c	Wed Apr 30 22:28:07 2003
@@ -125,7 +125,6 @@
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/init.h>
-#include <linux/devfs_fs_kernel.h>
 
 #define REALLY_SLOW_IO
 #include <asm/system.h>
@@ -318,15 +317,17 @@
 #endif
 }
 
-static void
+static irqreturn_t
 cdu535_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	disable_interrupts();
-	if (waitqueue_active(&cdu535_irq_wait))
+	if (waitqueue_active(&cdu535_irq_wait)) {
 		wake_up(&cdu535_irq_wait);
-	else
-		printk(CDU535_MESSAGE_NAME
-				": Got an interrupt but nothing was waiting\n");
+		return IRQ_HANDLED;
+	}
+	printk(CDU535_MESSAGE_NAME
+			": Got an interrupt but nothing was waiting\n");
+	return IRQ_NONE;
 }
 
 
@@ -1579,6 +1580,7 @@
 	cdu_disk->first_minor = 0;
 	cdu_disk->fops = &cdu_fops;
 	sprintf(cdu_disk->disk_name, "cdu");
+	sprintf(cdu_disk->devfs_name, "cdu535");
 
 	if (!request_region(sony535_cd_base_io, 4, CDU535_HANDLE)) {
 		printk(KERN_WARNING"sonycd535: Unable to request region 0x%x\n",
@@ -1587,10 +1589,6 @@
 	}
 	cdu_disk->queue = &sonycd535_queue;
 	add_disk(cdu_disk);
-	devfs_register (NULL, CDU535_HANDLE, DEVFS_FL_DEFAULT,
-			cdu_disk->major, cdu_disk->first_minor,
-			S_IFBLK | S_IRUGO | S_IWUGO,
-			cdu_disk->fops, NULL);
 	return 0;
 
 out7:
@@ -1666,7 +1664,6 @@
 	kfree(sony_buffer);
 	kfree(last_sony_subcode);
 	kfree(sony_toc);
-	devfs_remove(CDU535_HANDLE);
 	del_gendisk(cdu_disk);
 	put_disk(cdu_disk);
 	blk_cleanup_queue(&sonycd535_queue);
diff -Nru a/drivers/char/Kconfig b/drivers/char/Kconfig
--- a/drivers/char/Kconfig	Wed Apr 30 22:28:03 2003
+++ b/drivers/char/Kconfig	Wed Apr 30 22:28:03 2003
@@ -487,7 +487,7 @@
 	  box (as opposed to using a serial printer; if the connector at the
 	  printer has 9 or 25 holes ["female"], then it's serial), say Y.
 	  Also read the Printing-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  It is possible to share one parallel port among several devices
 	  (e.g. printer and ZIP drive) and it is safe to compile the
diff -Nru a/drivers/char/amiserial.c b/drivers/char/amiserial.c
--- a/drivers/char/amiserial.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/char/amiserial.c	Wed Apr 30 22:28:20 2003
@@ -50,7 +50,7 @@
   
 #if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT)
 #define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \
- cdevname(tty->device), (info->flags), serial_refcount,info->count,tty->count,s)
+ tty->name, (info->flags), serial_refcount,info->count,tty->count,s)
 #else
 #define DBG_CNT(s)
 #endif
@@ -153,7 +153,7 @@
 
 
 static inline int serial_paranoia_check(struct async_struct *info,
-					kdev_t device, const char *routine)
+					char *name, const char *routine)
 {
 #ifdef SERIAL_PARANOIA_CHECK
 	static const char *badmagic =
@@ -162,11 +162,11 @@
 		"Warning: null async_struct for (%s) in %s\n";
 
 	if (!info) {
-		printk(badinfo, cdevname(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (info->magic != SERIAL_MAGIC) {
-		printk(badmagic, cdevname(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -208,7 +208,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_stop"))
+	if (serial_paranoia_check(info, tty->name, "rs_stop"))
 		return;
 
 	local_irq_save(flags);
@@ -228,7 +228,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_start"))
+	if (serial_paranoia_check(info, tty->name, "rs_start"))
 		return;
 
 	local_irq_save(flags);
@@ -881,7 +881,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_put_char"))
+	if (serial_paranoia_check(info, tty->name, "rs_put_char"))
 		return;
 
 	if (!tty || !info->xmit.buf)
@@ -905,7 +905,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_flush_chars"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
 		return;
 
 	if (info->xmit.head == info->xmit.tail
@@ -931,7 +931,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_write"))
+	if (serial_paranoia_check(info, tty->name, "rs_write"))
 		return 0;
 
 	if (!tty || !info->xmit.buf || !tmp_buf)
@@ -1009,7 +1009,7 @@
 {
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 
-	if (serial_paranoia_check(info, tty->device, "rs_write_room"))
+	if (serial_paranoia_check(info, tty->name, "rs_write_room"))
 		return 0;
 	return CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
 }
@@ -1018,7 +1018,7 @@
 {
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 
-	if (serial_paranoia_check(info, tty->device, "rs_chars_in_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
 		return 0;
 	return CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
 }
@@ -1028,7 +1028,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_flush_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
 		return;
 	local_irq_save(flags);
 	info->xmit.head = info->xmit.tail = 0;
@@ -1048,7 +1048,7 @@
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
         unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_send_char"))
+	if (serial_paranoia_check(info, tty->name, "rs_send_char"))
 		return;
 
 	info->x_char = ch;
@@ -1089,7 +1089,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_throttle"))
+	if (serial_paranoia_check(info, tty->name, "rs_throttle"))
 		return;
 
 	if (I_IXOFF(tty))
@@ -1114,7 +1114,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_unthrottle"))
+	if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
 		return;
 
 	if (I_IXOFF(tty)) {
@@ -1323,7 +1323,7 @@
 	struct async_struct * info = (struct async_struct *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_break"))
+	if (serial_paranoia_check(info, tty->name, "rs_break"))
 		return;
 
 	local_irq_save(flags);
@@ -1344,7 +1344,7 @@
 	struct serial_icounter_struct icount;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_ioctl"))
+	if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
 		return -ENODEV;
 
 	if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
@@ -1519,7 +1519,7 @@
 	struct serial_state *state;
 	unsigned long flags;
 
-	if (!info || serial_paranoia_check(info, tty->device, "rs_close"))
+	if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
 		return;
 
 	state = info->state;
@@ -1598,8 +1598,8 @@
 		rs_wait_until_sent(tty, info->timeout);
 	}
 	shutdown(info);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -1628,7 +1628,7 @@
 	unsigned long orig_jiffies, char_time;
 	int lsr;
 
-	if (serial_paranoia_check(info, tty->device, "rs_wait_until_sent"))
+	if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
 		return;
 
 	if (info->xmit_fifo_size == 0)
@@ -1689,7 +1689,7 @@
 	struct async_struct * info = (struct async_struct *)tty->driver_data;
 	struct serial_state *state = info->state;
 
-	if (serial_paranoia_check(info, tty->device, "rs_hangup"))
+	if (serial_paranoia_check(info, tty->name, "rs_hangup"))
 		return;
 
 	state = info->state;
@@ -1741,7 +1741,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		if (info->flags & ASYNC_NORMAL_ACTIVE)
 			return -EBUSY;
 		if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
@@ -1895,7 +1895,7 @@
 	unsigned long		page;
 
 	MOD_INC_USE_COUNT;
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if ((line < 0) || (line >= NR_PORTS)) {
 		MOD_DEC_USE_COUNT;
 		return -ENODEV;
@@ -1907,12 +1907,11 @@
 	}
 	tty->driver_data = info;
 	info->tty = tty;
-	if (serial_paranoia_check(info, tty->device, "rs_open"))
+	if (serial_paranoia_check(info, tty->name, "rs_open"))
 		return -ENODEV;
 
 #ifdef SERIAL_DEBUG_OPEN
-	printk("rs_open %s%d, count = %d\n", tty->driver.name, info->line,
-	       info->state->count);
+	printk("rs_open %s, count = %d\n", tty->name, info->state->count);
 #endif
 	info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
 
@@ -1961,7 +1960,7 @@
 
 	if ((info->state->count == 1) &&
 	    (info->flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->state->normal_termios;
 		else 
 			*tty->termios = info->state->callout_termios;
@@ -1971,7 +1970,7 @@
 	info->pgrp = current->pgrp;
 
 #ifdef SERIAL_DEBUG_OPEN
-	printk("rs_open ttys%d successful...", info->line);
+	printk("rs_open %s successful...", tty->name);
 #endif
 	return 0;
 }
@@ -2289,9 +2288,10 @@
 	custom.intena = IF_SETCLR | (intena & IF_TBE);
 }
 
-static kdev_t serial_console_device(struct console *c)
+static struct tty_driver *serial_console_device(struct console *c, int *index)
 {
-	return mk_kdev(TTY_MAJOR, 64);
+	*index = 0;
+	return &serial_driver;
 }
 
 static struct console sercons = {
diff -Nru a/drivers/char/applicom.c b/drivers/char/applicom.c
--- a/drivers/char/applicom.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/char/applicom.c	Wed Apr 30 22:28:17 2003
@@ -108,7 +108,7 @@
 static ssize_t ac_write (struct file *, const char *, size_t, loff_t *);
 static int ac_ioctl(struct inode *, struct file *, unsigned int,
 		    unsigned long);
-static void ac_interrupt(int, void *, struct pt_regs *);
+static irqreturn_t ac_interrupt(int, void *, struct pt_regs *);
 
 static struct file_operations ac_fops = {
 	.owner = THIS_MODULE,
@@ -606,11 +606,12 @@
 	} 
 }
 
-static void ac_interrupt(int vec, void *dev_instance, struct pt_regs *regs)
+static irqreturn_t ac_interrupt(int vec, void *dev_instance, struct pt_regs *regs)
 {
 	unsigned int i;
 	unsigned int FlagInt;
 	unsigned int LoopCount;
+	int handled = 0;
 
 	//    printk("Applicom interrupt on IRQ %d occurred\n", vec);
 
@@ -632,6 +633,7 @@
 				continue;
 			}
 
+			handled = 1;
 			FlagInt = 1;
 			writeb(0, apbs[i].RamIO + RAM_IT_TO_PC);
 
@@ -675,6 +677,7 @@
 		else
 			LoopCount++;
 	} while(LoopCount < 2);
+	return IRQ_RETVAL(handled);
 }
 
 
diff -Nru a/drivers/char/cyclades.c b/drivers/char/cyclades.c
--- a/drivers/char/cyclades.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/char/cyclades.c	Wed Apr 30 22:28:05 2003
@@ -892,7 +892,7 @@
 
 static inline int
 serial_paranoia_check(struct cyclades_port *info,
-                        kdev_t device, const char *routine)
+                        char *name, const char *routine)
 {
 #ifdef SERIAL_PARANOIA_CHECK
     static const char *badmagic =
@@ -903,18 +903,18 @@
         "cyc Warning: cyclades_port out of range for (%s) in %s\n";
 
     if (!info) {
-        printk(badinfo, cdevname(device), routine);
+        printk(badinfo, name, routine);
         return 1;
     }
 
     if( (long)info < (long)(&cy_port[0])
     || (long)(&cy_port[NR_PORTS]) < (long)info ){
-        printk(badrange, cdevname(device), routine);
+        printk(badrange, name, routine);
         return 1;
     }
 
     if (info->magic != CYCLADES_MAGIC) {
-        printk(badmagic, cdevname(device), routine);
+        printk(badmagic, name, routine);
         return 1;
     }
 #endif
@@ -1090,7 +1090,7 @@
    whenever the card wants its hand held--chars
    received, out buffer empty, modem change, etc.
  */
-static void
+static irqreturn_t
 cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
   struct tty_struct *tty;
@@ -1113,7 +1113,7 @@
 #ifdef CY_DEBUG_INTERRUPTS
 	printk("cyy_interrupt: spurious interrupt %d\n\r", irq);
 #endif
-        return; /* spurious interrupt */
+        return IRQ_NONE; /* spurious interrupt */
     }
 
     card_base_addr = (unsigned char *)cinfo->base_addr;
@@ -1500,6 +1500,7 @@
    cy_writeb((u_long)card_base_addr + (Cy_ClrIntr<<index), 0);
                                 /* Cy_ClrIntr is 0x1800 */
    spin_unlock(&cinfo->card_lock);
+   return IRQ_HANDLED;
 } /* cyy_interrupt */
 
 /***********************************************************/
@@ -1881,7 +1882,7 @@
 }
 
 #ifdef CONFIG_CYZ_INTR
-static void
+static irqreturn_t
 cyz_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
   struct cyclades_card *cinfo;
@@ -1890,20 +1891,20 @@
 #ifdef CY_DEBUG_INTERRUPTS
 	printk("cyz_interrupt: spurious interrupt %d\n\r", irq);
 #endif
-        return; /* spurious interrupt */
+        return IRQ_NONE; /* spurious interrupt */
     }
 
     if (!ISZLOADED(*cinfo)) {
 #ifdef CY_DEBUG_INTERRUPTS
 	printk("cyz_interrupt: board not yet loaded (IRQ%d).\n\r", irq);
 #endif
-	return;
+	return IRQ_NONE;
     }
 
     /* Handle the interrupts */
     cyz_handle_cmd(cinfo);
 
-    return;
+    return IRQ_HANDLED;
 } /* cyz_interrupt */
 
 static void
@@ -2378,7 +2379,7 @@
      * If this is a callout device, then just make sure the normal
      * device isn't being used.
      */
-    if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+    if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
         if (info->flags & ASYNC_NORMAL_ACTIVE){
             return -EBUSY;
         }
@@ -2579,7 +2580,7 @@
   unsigned long page;
 
     MOD_INC_USE_COUNT;
-    line = minor(tty->device) - tty->driver.minor_start;
+    line = tty->index;
     if ((line < 0) || (NR_PORTS <= line)){
 	MOD_DEC_USE_COUNT;
         return -ENODEV;
@@ -2634,7 +2635,7 @@
 #endif
     tty->driver_data = info;
     info->tty = tty;
-    if (serial_paranoia_check(info, tty->device, "cy_open")){
+    if (serial_paranoia_check(info, tty->name, "cy_open")){
         return -ENODEV;
     }
 #ifdef CY_DEBUG_OPEN
@@ -2683,7 +2684,7 @@
     }
 
     if ((info->count == 1) && (info->flags & ASYNC_SPLIT_TERMIOS)) {
-        if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+        if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
             *tty->termios = info->normal_termios;
         else 
             *tty->termios = info->callout_termios;
@@ -2711,7 +2712,7 @@
   int card,chip,channel,index;
   unsigned long orig_jiffies, char_time;
 	
-    if (serial_paranoia_check(info, tty->device, "cy_wait_until_sent"))
+    if (serial_paranoia_check(info, tty->name, "cy_wait_until_sent"))
 	return;
 
     if (info->xmit_fifo_size == 0)
@@ -2795,7 +2796,7 @@
     printk("cyc:cy_close ttyC%d\n", info->line);
 #endif
 
-    if (!info || serial_paranoia_check(info, tty->device, "cy_close")){
+    if (!info || serial_paranoia_check(info, tty->name, "cy_close")){
         return;
     }
 
@@ -2904,8 +2905,8 @@
 
     CY_UNLOCK(info, flags);
     shutdown(info);
-    if (tty->driver.flush_buffer)
-        tty->driver.flush_buffer(tty);
+    if (tty->driver->flush_buffer)
+        tty->driver->flush_buffer(tty);
     if (tty->ldisc.flush_buffer)
         tty->ldisc.flush_buffer(tty);
     CY_LOCK(info, flags);
@@ -2961,7 +2962,7 @@
     printk("cyc:cy_write ttyC%d\n", info->line); /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_write")){
+    if (serial_paranoia_check(info, tty->name, "cy_write")){
         return 0;
     }
         
@@ -3047,7 +3048,7 @@
     printk("cyc:cy_put_char ttyC%d\n", info->line);
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_put_char"))
+    if (serial_paranoia_check(info, tty->name, "cy_put_char"))
         return;
 
     if (!tty || !info->xmit_buf)
@@ -3081,7 +3082,7 @@
     printk("cyc:cy_flush_chars ttyC%d\n", info->line); /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_flush_chars"))
+    if (serial_paranoia_check(info, tty->name, "cy_flush_chars"))
         return;
 
     if (info->xmit_cnt <= 0 || tty->stopped
@@ -3108,7 +3109,7 @@
     printk("cyc:cy_write_room ttyC%d\n", info->line); /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_write_room"))
+    if (serial_paranoia_check(info, tty->name, "cy_write_room"))
         return 0;
     ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
     if (ret < 0)
@@ -3123,7 +3124,7 @@
   struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
   int card, channel;
                                 
-    if (serial_paranoia_check(info, tty->device, "cy_chars_in_buffer"))
+    if (serial_paranoia_check(info, tty->name, "cy_chars_in_buffer"))
         return 0;
 
     card = info->card;
@@ -4012,7 +4013,7 @@
     struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
     unsigned long flags;
 
-    if (serial_paranoia_check(info, tty->device, "cy_break"))
+    if (serial_paranoia_check(info, tty->name, "cy_break"))
 	return;
 
     CY_LOCK(info, flags);
@@ -4231,7 +4232,7 @@
   int ret_val = 0;
   unsigned long flags;
 
-    if (serial_paranoia_check(info, tty->device, "cy_ioctl"))
+    if (serial_paranoia_check(info, tty->name, "cy_ioctl"))
 	return -ENODEV;
 
 #ifdef CY_DEBUG_OTHER
@@ -4469,7 +4470,7 @@
            tty->ldisc.chars_in_buffer(tty), info->line);
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_throttle")){
+    if (serial_paranoia_check(info, tty->name, "cy_throttle")){
             return;
     }
 
@@ -4525,7 +4526,7 @@
            tty->ldisc.chars_in_buffer(tty), info->line);
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_unthrottle")){
+    if (serial_paranoia_check(info, tty->name, "cy_unthrottle")){
             return;
     }
 
@@ -4579,7 +4580,7 @@
     printk("cyc:cy_stop ttyC%d\n", info->line); /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_stop"))
+    if (serial_paranoia_check(info, tty->name, "cy_stop"))
         return;
         
     cinfo = &cy_card[info->card];
@@ -4619,7 +4620,7 @@
     printk("cyc:cy_start ttyC%d\n", info->line); /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_start"))
+    if (serial_paranoia_check(info, tty->name, "cy_start"))
         return;
         
     cinfo = &cy_card[info->card];
@@ -4657,7 +4658,7 @@
     printk("cyc:cy_flush_buffer ttyC%d\n", info->line); /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_flush_buffer"))
+    if (serial_paranoia_check(info, tty->name, "cy_flush_buffer"))
         return;
 
     card = info->card;
@@ -4696,7 +4697,7 @@
     printk("cyc:cy_hangup ttyC%d\n", info->line); /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_hangup"))
+    if (serial_paranoia_check(info, tty->name, "cy_hangup"))
         return;
 
     cy_flush_buffer(tty);
diff -Nru a/drivers/char/drm/Kconfig b/drivers/char/drm/Kconfig
--- a/drivers/char/drm/Kconfig	Wed Apr 30 22:28:16 2003
+++ b/drivers/char/drm/Kconfig	Wed Apr 30 22:28:16 2003
@@ -39,7 +39,7 @@
 
 config DRM_RADEON
 	tristate "ATI Radeon"
-	depends on DRM && AGP
+	depends on DRM
 	help
 	  Choose this option if you have an ATI Radeon graphics card.  There
 	  are both PCI and AGP versions.  You don't need to choose this to
@@ -56,8 +56,14 @@
 	  for this driver to work.
 
 config DRM_I830
-	tristate "Intel 830M"
+	tristate "Intel 830M, 845G, 852GM, 855GM, 865G"
 	depends on DRM && AGP
+	help
+	  Choose this option if you have a system that has Intel 830M, 845G,
+	  852GM, 855GM or 865G integrated graphics.  If M is selected, the
+	  module will be called i830.  AGP support is required for this driver
+	  to work.
+
 
 config DRM_MGA
 	tristate "Matrox g200/g400"
diff -Nru a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h
--- a/drivers/char/drm/drmP.h	Wed Apr 30 22:28:13 2003
+++ b/drivers/char/drm/drmP.h	Wed Apr 30 22:28:13 2003
@@ -48,7 +48,6 @@
 #include <linux/init.h>
 #include <linux/file.h>
 #include <linux/pci.h>
-#include <linux/wrapper.h>
 #include <linux/version.h>
 #include <linux/jiffies.h>
 #include <linux/smp_lock.h>	/* For (un)lock_kernel */
@@ -96,9 +95,6 @@
 #ifndef __HAVE_DMA_FREELIST
 #define __HAVE_DMA_FREELIST	0
 #endif
-#ifndef __HAVE_DMA_HISTOGRAM
-#define __HAVE_DMA_HISTOGRAM	0
-#endif
 
 #define __REALLY_HAVE_AGP	(__HAVE_AGP && (defined(CONFIG_AGP) || \
 						defined(CONFIG_AGP_MODULE)))
@@ -120,7 +116,6 @@
 #define DRM_LOCK_SLICE	      1	/* Time slice for lock, in jiffies	  */
 
 #define DRM_FLAG_DEBUG	  0x01
-#define DRM_FLAG_NOCTX	  0x02
 
 #define DRM_MEM_DMA	   0
 #define DRM_MEM_SAREA	   1
@@ -340,38 +335,11 @@
 		DRM_LIST_RECLAIM = 5
 	}		  list;	       /* Which list we're on		     */
 
-#if DRM_DMA_HISTOGRAM
-	cycles_t	  time_queued;	   /* Queued to kernel DMA queue     */
-	cycles_t	  time_dispatched; /* Dispatched to hardware	     */
-	cycles_t	  time_completed;  /* Completed by hardware	     */
-	cycles_t	  time_freed;	   /* Back on freelist		     */
-#endif
 
 	int		  dev_priv_size; /* Size of buffer private stoarge   */
 	void		  *dev_private;  /* Per-buffer private storage       */
 } drm_buf_t;
 
-#if DRM_DMA_HISTOGRAM
-#define DRM_DMA_HISTOGRAM_SLOTS		  9
-#define DRM_DMA_HISTOGRAM_INITIAL	 10
-#define DRM_DMA_HISTOGRAM_NEXT(current)	 ((current)*10)
-typedef struct drm_histogram {
-	atomic_t	  total;
-
-	atomic_t	  queued_to_dispatched[DRM_DMA_HISTOGRAM_SLOTS];
-	atomic_t	  dispatched_to_completed[DRM_DMA_HISTOGRAM_SLOTS];
-	atomic_t	  completed_to_freed[DRM_DMA_HISTOGRAM_SLOTS];
-
-	atomic_t	  queued_to_completed[DRM_DMA_HISTOGRAM_SLOTS];
-	atomic_t	  queued_to_freed[DRM_DMA_HISTOGRAM_SLOTS];
-
-	atomic_t	  dma[DRM_DMA_HISTOGRAM_SLOTS];
-	atomic_t	  schedule[DRM_DMA_HISTOGRAM_SLOTS];
-	atomic_t	  ctx[DRM_DMA_HISTOGRAM_SLOTS];
-	atomic_t	  lacq[DRM_DMA_HISTOGRAM_SLOTS];
-	atomic_t	  lhld[DRM_DMA_HISTOGRAM_SLOTS];
-} drm_histogram_t;
-#endif
 
 				/* bufs is one longer than it has to be */
 typedef struct drm_waitlist {
@@ -423,6 +391,7 @@
 	struct drm_file	  *prev;
 	struct drm_device *dev;
 	int 		  remove_auth_on_close;
+	unsigned long     lock_count;
 } drm_file_t;
 
 
@@ -452,21 +421,6 @@
 } drm_lock_data_t;
 
 typedef struct drm_device_dma {
-#if 0
-				/* Performance Counters */
-	atomic_t	  total_prio;	/* Total DRM_DMA_PRIORITY	   */
-	atomic_t	  total_bytes;	/* Total bytes DMA'd		   */
-	atomic_t	  total_dmas;	/* Total DMA buffers dispatched	   */
-
-	atomic_t	  total_missed_dma;  /* Missed drm_do_dma	    */
-	atomic_t	  total_missed_lock; /* Missed lock in drm_do_dma   */
-	atomic_t	  total_missed_free; /* Missed drm_free_this_buffer */
-	atomic_t	  total_missed_sched;/* Missed drm_dma_schedule	    */
-
-	atomic_t	  total_tried;	/* Tried next_buffer		    */
-	atomic_t	  total_hit;	/* Sent next_buffer		    */
-	atomic_t	  total_lost;	/* Lost interrupt		    */
-#endif
 
 	drm_buf_entry_t	  bufs[DRM_MAX_ORDER+1];
 	int		  buf_count;
@@ -574,7 +528,6 @@
 
 				/* Memory management */
 	drm_map_list_t	  *maplist;	/* Linked list of regions	   */
-	int		  map_count;	/* Number of mappable regions	   */
 
 	drm_map_t	  **context_sareas;
 	int		  max_context;
@@ -609,9 +562,6 @@
 #endif
 	cycles_t	  ctx_start;
 	cycles_t	  lck_start;
-#if __HAVE_DMA_HISTOGRAM
-	drm_histogram_t	  histo;
-#endif
 
 				/* Callback to X server for context switch
 				   and for heavy-handed reset. */
@@ -667,13 +617,7 @@
 extern int	     DRM(open_helper)(struct inode *inode, struct file *filp,
 				      drm_device_t *dev);
 extern int	     DRM(flush)(struct file *filp);
-extern int	     DRM(release_fuck)(struct inode *inode, struct file *filp);
 extern int	     DRM(fasync)(int fd, struct file *filp, int on);
-extern ssize_t	     DRM(read)(struct file *filp, char *buf, size_t count,
-			       loff_t *off);
-extern int	     DRM(write_string)(drm_device_t *dev, const char *s);
-extern unsigned int  DRM(poll)(struct file *filp,
-			       struct poll_table_struct *wait);
 
 				/* Mapping support (drm_vm.h) */
 extern struct page *DRM(vm_nopage)(struct vm_area_struct *vma,
@@ -694,6 +638,8 @@
 extern int	     DRM(mmap_dma)(struct file *filp,
 				   struct vm_area_struct *vma);
 extern int	     DRM(mmap)(struct file *filp, struct vm_area_struct *vma);
+extern unsigned int  DRM(poll)(struct file *filp, struct poll_table_struct *wait);
+extern ssize_t       DRM(read)(struct file *filp, char *buf, size_t count, loff_t *off);
 
 				/* Memory management support (drm_memory.h) */
 extern void	     DRM(mem_init)(void);
@@ -702,8 +648,6 @@
 extern void	     *DRM(alloc)(size_t size, int area);
 extern void	     *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
 				   int area);
-extern char	     *DRM(strdup)(const char *s, int area);
-extern void	     DRM(strfree)(const char *s, int area);
 extern void	     DRM(free)(void *pt, size_t size, int area);
 extern unsigned long DRM(alloc_pages)(int order, int area);
 extern void	     DRM(free_pages)(unsigned long address, int order,
@@ -778,12 +722,11 @@
 extern int	     DRM(authmagic)(struct inode *inode, struct file *filp,
 				    unsigned int cmd, unsigned long arg);
 
+                                /* Placeholder for ioctls past */
+extern int	     DRM(noop)(struct inode *inode, struct file *filp,
+				  unsigned int cmd, unsigned long arg);
 
 				/* Locking IOCTL support (drm_lock.h) */
-extern int	     DRM(block)(struct inode *inode, struct file *filp,
-				unsigned int cmd, unsigned long arg);
-extern int	     DRM(unblock)(struct inode *inode, struct file *filp,
-				  unsigned int cmd, unsigned long arg);
 extern int	     DRM(lock_take)(__volatile__ unsigned int *lock,
 				    unsigned int context);
 extern int	     DRM(lock_transfer)(drm_device_t *dev,
@@ -792,12 +735,6 @@
 extern int	     DRM(lock_free)(drm_device_t *dev,
 				    __volatile__ unsigned int *lock,
 				    unsigned int context);
-extern int	     DRM(finish)(struct inode *inode, struct file *filp,
-				 unsigned int cmd, unsigned long arg);
-extern int	     DRM(flush_unblock)(drm_device_t *dev, int context,
-					drm_lock_flags_t flags);
-extern int	     DRM(flush_block_and_flush)(drm_device_t *dev, int context,
-						drm_lock_flags_t flags);
 extern int           DRM(notifier)(void *priv);
 
 				/* Buffer management support (drm_bufs.h) */
@@ -823,21 +760,12 @@
 extern void	     DRM(dma_takedown)(drm_device_t *dev);
 extern void	     DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf);
 extern void	     DRM(reclaim_buffers)( struct file *filp );
-#if __HAVE_OLD_DMA
-/* GH: This is a dirty hack for now...
- */
-extern void	     DRM(clear_next_buffer)(drm_device_t *dev);
-extern int	     DRM(select_queue)(drm_device_t *dev,
-				       void (*wrapper)(unsigned long));
-extern int	     DRM(dma_enqueue)(struct file *filp, drm_dma_t *dma);
-extern int	     DRM(dma_get_buffers)(struct file *filp, drm_dma_t *dma);
-#endif
 #if __HAVE_DMA_IRQ
 extern int           DRM(control)( struct inode *inode, struct file *filp,
 				   unsigned int cmd, unsigned long arg );
 extern int           DRM(irq_install)( drm_device_t *dev, int irq );
 extern int           DRM(irq_uninstall)( drm_device_t *dev );
-extern void          DRM(dma_service)( int irq, void *device,
+extern irqreturn_t   DRM(dma_service)( int irq, void *device,
 				       struct pt_regs *regs );
 extern void          DRM(driver_irq_preinstall)( drm_device_t *dev );
 extern void          DRM(driver_irq_postinstall)( drm_device_t *dev );
@@ -852,25 +780,7 @@
 extern void          DRM(dma_immediate_bh)( void *dev );
 #endif
 #endif
-#if DRM_DMA_HISTOGRAM
-extern int	     DRM(histogram_slot)(unsigned long count);
-extern void	     DRM(histogram_compute)(drm_device_t *dev, drm_buf_t *buf);
-#endif
-
-				/* Buffer list support (drm_lists.h) */
-#if __HAVE_DMA_WAITLIST
-extern int	     DRM(waitlist_create)(drm_waitlist_t *bl, int count);
-extern int	     DRM(waitlist_destroy)(drm_waitlist_t *bl);
-extern int	     DRM(waitlist_put)(drm_waitlist_t *bl, drm_buf_t *buf);
-extern drm_buf_t     *DRM(waitlist_get)(drm_waitlist_t *bl);
-#endif
-#if __HAVE_DMA_FREELIST
-extern int	     DRM(freelist_create)(drm_freelist_t *bl, int count);
-extern int	     DRM(freelist_destroy)(drm_freelist_t *bl);
-extern int	     DRM(freelist_put)(drm_device_t *dev, drm_freelist_t *bl,
-				       drm_buf_t *buf);
-extern drm_buf_t     *DRM(freelist_get)(drm_freelist_t *bl, int block);
-#endif
+
 #endif /* __HAVE_DMA */
 
 #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	Wed Apr 30 22:28:03 2003
+++ b/drivers/char/drm/drm_agpsupport.h	Wed Apr 30 22:28:03 2003
@@ -146,7 +146,7 @@
 		return -ENOMEM;
 	}
 
-	entry->handle    = (unsigned long)memory->memory;
+	entry->handle    = (unsigned long)memory->key;
 	entry->memory    = memory;
 	entry->bound     = 0;
 	entry->pages     = pages;
@@ -186,6 +186,7 @@
 	drm_device_t	  *dev	 = priv->dev;
 	drm_agp_binding_t request;
 	drm_agp_mem_t     *entry;
+	int ret;
 
 	if (!dev->agp || !dev->agp->acquired) return -EINVAL;
 	if (copy_from_user(&request, (drm_agp_binding_t *)arg, sizeof(request)))
@@ -193,7 +194,10 @@
 	if (!(entry = DRM(agp_lookup_entry)(dev, request.handle)))
 		return -EINVAL;
 	if (!entry->bound) return -EINVAL;
-	return DRM(unbind_agp)(entry->memory);
+	ret = DRM(unbind_agp)(entry->memory);
+	if (ret == 0)
+	    entry->bound = 0;
+	return ret;
 }
 
 int DRM(agp_bind)(struct inode *inode, struct file *filp,
diff -Nru a/drivers/char/drm/drm_bufs.h b/drivers/char/drm/drm_bufs.h
--- a/drivers/char/drm/drm_bufs.h	Wed Apr 30 22:28:05 2003
+++ b/drivers/char/drm/drm_bufs.h	Wed Apr 30 22:28:05 2003
@@ -128,7 +128,7 @@
 
 	case _DRM_SHM:
 		map->handle = vmalloc_32(map->size);
-		DRM_DEBUG( "%ld %d %p\n",
+		DRM_DEBUG( "%lu %d %p\n",
 			   map->size, DRM(order)( map->size ), map->handle );
 		if ( !map->handle ) {
 			DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
@@ -145,7 +145,7 @@
 #ifdef __alpha__
 		map->offset += dev->hose->mem_space->start;
 #endif
-		map->offset = map->offset + dev->agp->base;
+		map->offset += dev->agp->base;
 		map->mtrr   = dev->agp->agp_mtrr; /* for getmap */
 		break;
 #endif
@@ -154,7 +154,7 @@
 			DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
 			return -EINVAL;
 		}
-		map->offset = map->offset + dev->sg->handle;
+		map->offset += dev->sg->handle;
 		break;
 
 	default:
@@ -269,9 +269,11 @@
 
 	if (entry->seg_count) {
 		for (i = 0; i < entry->seg_count; i++) {
-			DRM(free_pages)(entry->seglist[i],
-					entry->page_order,
-					DRM_MEM_DMA);
+			if (entry->seglist[i]) {
+				DRM(free_pages)(entry->seglist[i],
+					        entry->page_order,
+					        DRM_MEM_DMA);
+			}
 		}
 		DRM(free)(entry->seglist,
 			  entry->seg_count *
@@ -281,9 +283,9 @@
 		entry->seg_count = 0;
 	}
 
-   	if(entry->buf_count) {
-	   	for(i = 0; i < entry->buf_count; i++) {
-			if(entry->buflist[i].dev_private) {
+   	if (entry->buf_count) {
+	   	for (i = 0; i < entry->buf_count; i++) {
+			if (entry->buflist[i].dev_private) {
 				DRM(free)(entry->buflist[i].dev_private,
 					  entry->buflist[i].dev_priv_size,
 					  DRM_MEM_BUFS);
@@ -345,7 +347,7 @@
 	DRM_DEBUG( "count:      %d\n",  count );
 	DRM_DEBUG( "order:      %d\n",  order );
 	DRM_DEBUG( "size:       %d\n",  size );
-	DRM_DEBUG( "agp_offset: %ld\n", agp_offset );
+	DRM_DEBUG( "agp_offset: %lu\n", agp_offset );
 	DRM_DEBUG( "alignment:  %d\n",  alignment );
 	DRM_DEBUG( "page_order: %d\n",  page_order );
 	DRM_DEBUG( "total:      %d\n",  total );
@@ -412,15 +414,12 @@
 			/* Set count correctly so we free the proper amount. */
 			entry->buf_count = count;
 			DRM(cleanup_buf_error)(entry);
+			up( &dev->struct_sem );
+			atomic_dec( &dev->buf_alloc );
+			return -ENOMEM;
 		}
 		memset( buf->dev_private, 0, buf->dev_priv_size );
 
-#if __HAVE_DMA_HISTOGRAM
-		buf->time_queued = 0;
-		buf->time_dispatched = 0;
-		buf->time_completed = 0;
-		buf->time_freed = 0;
-#endif
 		DRM_DEBUG( "buffer %d @ %p\n",
 			   entry->buf_count, buf->address );
 
@@ -565,12 +564,13 @@
 	}
 	memset( entry->seglist, 0, count * sizeof(*entry->seglist) );
 
-	temp_pagelist = DRM(realloc)( dma->pagelist,
-				      dma->page_count * sizeof(*dma->pagelist),
-				      (dma->page_count + (count << page_order))
-				      * sizeof(*dma->pagelist),
-				      DRM_MEM_PAGES );
-	if(!temp_pagelist) {
+	/* Keep the original pagelist until we know all the allocations
+	 * have succeeded
+	 */
+	temp_pagelist = DRM(alloc)( (dma->page_count + (count << page_order))
+				    * sizeof(*dma->pagelist),
+				    DRM_MEM_PAGES );
+	if (!temp_pagelist) {
 		DRM(free)( entry->buflist,
 			   count * sizeof(*entry->buflist),
 			   DRM_MEM_BUFS );
@@ -581,8 +581,9 @@
 		atomic_dec( &dev->buf_alloc );
 		return -ENOMEM;
 	}
-
-	dma->pagelist = temp_pagelist;
+	memcpy(temp_pagelist,
+	       dma->pagelist,
+	       dma->page_count * sizeof(*dma->pagelist));
 	DRM_DEBUG( "pagelist: %d entries\n",
 		   dma->page_count + (count << page_order) );
 
@@ -593,13 +594,25 @@
 
 	while ( entry->buf_count < count ) {
 		page = DRM(alloc_pages)( page_order, DRM_MEM_DMA );
-		if ( !page ) break;
+		if ( !page ) {
+			/* Set count correctly so we free the proper amount. */
+			entry->buf_count = count;
+			entry->seg_count = count;
+			DRM(cleanup_buf_error)(entry);
+			DRM(free)( temp_pagelist,
+				   (dma->page_count + (count << page_order))
+				   * sizeof(*dma->pagelist),
+				   DRM_MEM_PAGES );
+			up( &dev->struct_sem );
+			atomic_dec( &dev->buf_alloc );
+			return -ENOMEM;
+		}
 		entry->seglist[entry->seg_count++] = page;
 		for ( i = 0 ; i < (1 << page_order) ; i++ ) {
 			DRM_DEBUG( "page %d @ 0x%08lx\n",
 				   dma->page_count + page_count,
 				   page + PAGE_SIZE * i );
-			dma->pagelist[dma->page_count + page_count++]
+			temp_pagelist[dma->page_count + page_count++]
 				= page + PAGE_SIZE * i;
 		}
 		for ( offset = 0 ;
@@ -617,12 +630,25 @@
 			buf->pending = 0;
 			init_waitqueue_head( &buf->dma_wait );
 			buf->filp    = 0;
-#if __HAVE_DMA_HISTOGRAM
-			buf->time_queued     = 0;
-			buf->time_dispatched = 0;
-			buf->time_completed  = 0;
-			buf->time_freed      = 0;
-#endif
+
+			buf->dev_priv_size = sizeof(DRIVER_BUF_PRIV_T);
+			buf->dev_private = DRM(alloc)( sizeof(DRIVER_BUF_PRIV_T),
+						       DRM_MEM_BUFS );
+			if(!buf->dev_private) {
+				/* Set count correctly so we free the proper amount. */
+				entry->buf_count = count;
+				entry->seg_count = count;
+				DRM(cleanup_buf_error)(entry);
+				DRM(free)( temp_pagelist,
+					   (dma->page_count + (count << page_order))
+					   * sizeof(*dma->pagelist),
+					   DRM_MEM_PAGES );
+				up( &dev->struct_sem );
+				atomic_dec( &dev->buf_alloc );
+				return -ENOMEM;
+			}
+			memset( buf->dev_private, 0, buf->dev_priv_size );
+
 			DRM_DEBUG( "buffer %d @ %p\n",
 				   entry->buf_count, buf->address );
 		}
@@ -634,9 +660,13 @@
 				     (dma->buf_count + entry->buf_count)
 				     * sizeof(*dma->buflist),
 				     DRM_MEM_BUFS );
-	if(!temp_buflist) {
+	if (!temp_buflist) {
 		/* Free the entry because it isn't valid */
 		DRM(cleanup_buf_error)(entry);
+		DRM(free)( temp_pagelist,
+			   (dma->page_count + (count << page_order))
+			   * sizeof(*dma->pagelist),
+			   DRM_MEM_PAGES );
 		up( &dev->struct_sem );
 		atomic_dec( &dev->buf_alloc );
 		return -ENOMEM;
@@ -647,6 +677,16 @@
 		dma->buflist[i + dma->buf_count] = &entry->buflist[i];
 	}
 
+	/* No allocations failed, so now we can replace the orginal pagelist
+	 * with the new one.
+	 */
+	if (dma->page_count) {
+		DRM(free)(dma->pagelist,
+			  dma->page_count * sizeof(*dma->pagelist),
+			  DRM_MEM_PAGES);
+	}
+	dma->pagelist = temp_pagelist;
+
 	dma->buf_count += entry->buf_count;
 	dma->seg_count += entry->seg_count;
 	dma->page_count += entry->seg_count << page_order;
@@ -715,7 +755,7 @@
 	DRM_DEBUG( "count:      %d\n",  count );
 	DRM_DEBUG( "order:      %d\n",  order );
 	DRM_DEBUG( "size:       %d\n",  size );
-	DRM_DEBUG( "agp_offset: %ld\n", agp_offset );
+	DRM_DEBUG( "agp_offset: %lu\n", agp_offset );
 	DRM_DEBUG( "alignment:  %d\n",  alignment );
 	DRM_DEBUG( "page_order: %d\n",  page_order );
 	DRM_DEBUG( "total:      %d\n",  total );
@@ -789,12 +829,6 @@
 
 		memset( buf->dev_private, 0, buf->dev_priv_size );
 
-# if __HAVE_DMA_HISTOGRAM
-		buf->time_queued = 0;
-		buf->time_dispatched = 0;
-		buf->time_completed = 0;
-		buf->time_freed = 0;
-# endif
 		DRM_DEBUG( "buffer %d @ %p\n",
 			   entry->buf_count, buf->address );
 
diff -Nru a/drivers/char/drm/drm_context.h b/drivers/char/drm/drm_context.h
--- a/drivers/char/drm/drm_context.h	Wed Apr 30 22:28:03 2003
+++ b/drivers/char/drm/drm_context.h	Wed Apr 30 22:28:03 2003
@@ -35,7 +35,10 @@
 
 #include "drmP.h"
 
-#if __HAVE_CTX_BITMAP
+#if !__HAVE_CTX_BITMAP
+#error "__HAVE_CTX_BITMAP must be defined"
+#endif
+
 
 /* ================================================================
  * Context bitmap support
@@ -221,16 +224,11 @@
 
 int DRM(context_switch)( drm_device_t *dev, int old, int new )
 {
-        char buf[64];
-
         if ( test_and_set_bit( 0, &dev->context_flag ) ) {
                 DRM_ERROR( "Reentering -- FIXME\n" );
                 return -EBUSY;
         }
 
-#if __HAVE_DMA_HISTOGRAM
-        dev->ctx_start = get_cycles();
-#endif
 
         DRM_DEBUG( "Context switch from %d to %d\n", old, new );
 
@@ -239,13 +237,6 @@
                 return 0;
         }
 
-        if ( DRM(flags) & DRM_FLAG_NOCTX ) {
-                DRM(context_switch_complete)( dev, new );
-        } else {
-                sprintf( buf, "C %d %d\n", old, new );
-                DRM(write_string)( dev, buf );
-        }
-
         return 0;
 }
 
@@ -261,11 +252,6 @@
 				/* If a context switch is ever initiated
                                    when the kernel holds the lock, release
                                    that lock here. */
-#if __HAVE_DMA_HISTOGRAM
-        atomic_inc( &dev->histo.ctx[DRM(histogram_slot)(get_cycles()
-							- dev->ctx_start)] );
-
-#endif
         clear_bit( 0, &dev->context_flag );
         wake_up( &dev->context_wait );
 
@@ -406,375 +392,3 @@
 	return 0;
 }
 
-
-#else /* __HAVE_CTX_BITMAP */
-
-/* ================================================================
- * Old-style context support
- */
-
-
-int DRM(context_switch)(drm_device_t *dev, int old, int new)
-{
-	char	    buf[64];
-	drm_queue_t *q;
-
-#if 0
-	atomic_inc(&dev->total_ctx);
-#endif
-
-	if (test_and_set_bit(0, &dev->context_flag)) {
-		DRM_ERROR("Reentering -- FIXME\n");
-		return -EBUSY;
-	}
-
-#if __HAVE_DMA_HISTOGRAM
-	dev->ctx_start = get_cycles();
-#endif
-
-	DRM_DEBUG("Context switch from %d to %d\n", old, new);
-
-	if (new >= dev->queue_count) {
-		clear_bit(0, &dev->context_flag);
-		return -EINVAL;
-	}
-
-	if (new == dev->last_context) {
-		clear_bit(0, &dev->context_flag);
-		return 0;
-	}
-
-	q = dev->queuelist[new];
-	atomic_inc(&q->use_count);
-	if (atomic_read(&q->use_count) == 1) {
-		atomic_dec(&q->use_count);
-		clear_bit(0, &dev->context_flag);
-		return -EINVAL;
-	}
-
-	if (DRM(flags) & DRM_FLAG_NOCTX) {
-		DRM(context_switch_complete)(dev, new);
-	} else {
-		sprintf(buf, "C %d %d\n", old, new);
-		DRM(write_string)(dev, buf);
-	}
-
-	atomic_dec(&q->use_count);
-
-	return 0;
-}
-
-int DRM(context_switch_complete)(drm_device_t *dev, int new)
-{
-	drm_device_dma_t *dma = dev->dma;
-
-	dev->last_context = new;  /* PRE/POST: This is the _only_ writer. */
-	dev->last_switch  = jiffies;
-
-	if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
-		DRM_ERROR("Lock isn't held after context switch\n");
-	}
-
-	if (!dma || !(dma->next_buffer && dma->next_buffer->while_locked)) {
-		if (DRM(lock_free)(dev, &dev->lock.hw_lock->lock,
-				  DRM_KERNEL_CONTEXT)) {
-			DRM_ERROR("Cannot free lock\n");
-		}
-	}
-
-#if __HAVE_DMA_HISTOGRAM
-	atomic_inc(&dev->histo.ctx[DRM(histogram_slot)(get_cycles()
-						      - dev->ctx_start)]);
-
-#endif
-	clear_bit(0, &dev->context_flag);
-	wake_up_interruptible(&dev->context_wait);
-
-	return 0;
-}
-
-static int DRM(init_queue)(drm_device_t *dev, drm_queue_t *q, drm_ctx_t *ctx)
-{
-	DRM_DEBUG("\n");
-
-	if (atomic_read(&q->use_count) != 1
-	    || atomic_read(&q->finalization)
-	    || atomic_read(&q->block_count)) {
-		DRM_ERROR("New queue is already in use: u%d f%d b%d\n",
-			  atomic_read(&q->use_count),
-			  atomic_read(&q->finalization),
-			  atomic_read(&q->block_count));
-	}
-
-	atomic_set(&q->finalization,  0);
-	atomic_set(&q->block_count,   0);
-	atomic_set(&q->block_read,    0);
-	atomic_set(&q->block_write,   0);
-	atomic_set(&q->total_queued,  0);
-	atomic_set(&q->total_flushed, 0);
-	atomic_set(&q->total_locks,   0);
-
-	init_waitqueue_head(&q->write_queue);
-	init_waitqueue_head(&q->read_queue);
-	init_waitqueue_head(&q->flush_queue);
-
-	q->flags = ctx->flags;
-
-	DRM(waitlist_create)(&q->waitlist, dev->dma->buf_count);
-
-	return 0;
-}
-
-
-/* drm_alloc_queue:
-PRE: 1) dev->queuelist[0..dev->queue_count] is allocated and will not
-	disappear (so all deallocation must be done after IOCTLs are off)
-     2) dev->queue_count < dev->queue_slots
-     3) dev->queuelist[i].use_count == 0 and
-	dev->queuelist[i].finalization == 0 if i not in use
-POST: 1) dev->queuelist[i].use_count == 1
-      2) dev->queue_count < dev->queue_slots */
-
-static int DRM(alloc_queue)(drm_device_t *dev)
-{
-	int	    i;
-	drm_queue_t *queue;
-	int	    oldslots;
-	int	    newslots;
-				/* Check for a free queue */
-	for (i = 0; i < dev->queue_count; i++) {
-		atomic_inc(&dev->queuelist[i]->use_count);
-		if (atomic_read(&dev->queuelist[i]->use_count) == 1
-		    && !atomic_read(&dev->queuelist[i]->finalization)) {
-			DRM_DEBUG("%d (free)\n", i);
-			return i;
-		}
-		atomic_dec(&dev->queuelist[i]->use_count);
-	}
-				/* Allocate a new queue */
-	down(&dev->struct_sem);
-
-	queue = DRM(alloc)(sizeof(*queue), DRM_MEM_QUEUES);
-	memset(queue, 0, sizeof(*queue));
-	atomic_set(&queue->use_count, 1);
-
-	++dev->queue_count;
-	if (dev->queue_count >= dev->queue_slots) {
-		oldslots = dev->queue_slots * sizeof(*dev->queuelist);
-		if (!dev->queue_slots) dev->queue_slots = 1;
-		dev->queue_slots *= 2;
-		newslots = dev->queue_slots * sizeof(*dev->queuelist);
-
-		dev->queuelist = DRM(realloc)(dev->queuelist,
-					      oldslots,
-					      newslots,
-					      DRM_MEM_QUEUES);
-		if (!dev->queuelist) {
-			up(&dev->struct_sem);
-			DRM_DEBUG("out of memory\n");
-			return -ENOMEM;
-		}
-	}
-	dev->queuelist[dev->queue_count-1] = queue;
-
-	up(&dev->struct_sem);
-	DRM_DEBUG("%d (new)\n", dev->queue_count - 1);
-	return dev->queue_count - 1;
-}
-
-int DRM(resctx)(struct inode *inode, struct file *filp,
-		unsigned int cmd, unsigned long arg)
-{
-	drm_ctx_res_t	res;
-	drm_ctx_t	ctx;
-	int		i;
-
-	DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS);
-	if (copy_from_user(&res, (drm_ctx_res_t *)arg, sizeof(res)))
-		return -EFAULT;
-	if (res.count >= DRM_RESERVED_CONTEXTS) {
-		memset(&ctx, 0, sizeof(ctx));
-		for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
-			ctx.handle = i;
-			if (copy_to_user(&res.contexts[i],
-					 &i,
-					 sizeof(i)))
-				return -EFAULT;
-		}
-	}
-	res.count = DRM_RESERVED_CONTEXTS;
-	if (copy_to_user((drm_ctx_res_t *)arg, &res, sizeof(res)))
-		return -EFAULT;
-	return 0;
-}
-
-int DRM(addctx)(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_t	ctx;
-
-	if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
-		return -EFAULT;
-	if ((ctx.handle = DRM(alloc_queue)(dev)) == DRM_KERNEL_CONTEXT) {
-				/* Init kernel's context and get a new one. */
-		DRM(init_queue)(dev, dev->queuelist[ctx.handle], &ctx);
-		ctx.handle = DRM(alloc_queue)(dev);
-	}
-	DRM(init_queue)(dev, dev->queuelist[ctx.handle], &ctx);
-	DRM_DEBUG("%d\n", ctx.handle);
-	if (copy_to_user((drm_ctx_t *)arg, &ctx, sizeof(ctx)))
-		return -EFAULT;
-	return 0;
-}
-
-int DRM(modctx)(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_t	ctx;
-	drm_queue_t	*q;
-
-	if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
-		return -EFAULT;
-
-	DRM_DEBUG("%d\n", ctx.handle);
-
-	if (ctx.handle < 0 || ctx.handle >= dev->queue_count) return -EINVAL;
-	q = dev->queuelist[ctx.handle];
-
-	atomic_inc(&q->use_count);
-	if (atomic_read(&q->use_count) == 1) {
-				/* No longer in use */
-		atomic_dec(&q->use_count);
-		return -EINVAL;
-	}
-
-	if (DRM_BUFCOUNT(&q->waitlist)) {
-		atomic_dec(&q->use_count);
-		return -EBUSY;
-	}
-
-	q->flags = ctx.flags;
-
-	atomic_dec(&q->use_count);
-	return 0;
-}
-
-int DRM(getctx)(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_t	ctx;
-	drm_queue_t	*q;
-
-	if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
-		return -EFAULT;
-
-	DRM_DEBUG("%d\n", ctx.handle);
-
-	if (ctx.handle >= dev->queue_count) return -EINVAL;
-	q = dev->queuelist[ctx.handle];
-
-	atomic_inc(&q->use_count);
-	if (atomic_read(&q->use_count) == 1) {
-				/* No longer in use */
-		atomic_dec(&q->use_count);
-		return -EINVAL;
-	}
-
-	ctx.flags = q->flags;
-	atomic_dec(&q->use_count);
-
-	if (copy_to_user((drm_ctx_t *)arg, &ctx, sizeof(ctx)))
-		return -EFAULT;
-
-	return 0;
-}
-
-int DRM(switchctx)(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_t	ctx;
-
-	if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
-		return -EFAULT;
-	DRM_DEBUG("%d\n", ctx.handle);
-	return DRM(context_switch)(dev, dev->last_context, ctx.handle);
-}
-
-int DRM(newctx)(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_t	ctx;
-
-	if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
-		return -EFAULT;
-	DRM_DEBUG("%d\n", ctx.handle);
-	DRM(context_switch_complete)(dev, ctx.handle);
-
-	return 0;
-}
-
-int DRM(rmctx)(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_t	ctx;
-	drm_queue_t	*q;
-	drm_buf_t	*buf;
-
-	if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
-		return -EFAULT;
-	DRM_DEBUG("%d\n", ctx.handle);
-
-	if (ctx.handle >= dev->queue_count) return -EINVAL;
-	q = dev->queuelist[ctx.handle];
-
-	atomic_inc(&q->use_count);
-	if (atomic_read(&q->use_count) == 1) {
-				/* No longer in use */
-		atomic_dec(&q->use_count);
-		return -EINVAL;
-	}
-
-	atomic_inc(&q->finalization); /* Mark queue in finalization state */
-	atomic_sub(2, &q->use_count); /* Mark queue as unused (pending
-					 finalization) */
-
-	while (test_and_set_bit(0, &dev->interrupt_flag)) {
-		schedule();
-		if (signal_pending(current)) {
-			clear_bit(0, &dev->interrupt_flag);
-			return -EINTR;
-		}
-	}
-				/* Remove queued buffers */
-	while ((buf = DRM(waitlist_get)(&q->waitlist))) {
-		DRM(free_buffer)(dev, buf);
-	}
-	clear_bit(0, &dev->interrupt_flag);
-
-				/* Wakeup blocked processes */
-	wake_up_interruptible(&q->read_queue);
-	wake_up_interruptible(&q->write_queue);
-	wake_up_interruptible(&q->flush_queue);
-
-				/* Finalization over.  Queue is made
-				   available when both use_count and
-				   finalization become 0, which won't
-				   happen until all the waiting processes
-				   stop waiting. */
-	atomic_dec(&q->finalization);
-	return 0;
-}
-
-#endif /* __HAVE_CTX_BITMAP */
diff -Nru a/drivers/char/drm/drm_dma.h b/drivers/char/drm/drm_dma.h
--- a/drivers/char/drm/drm_dma.h	Wed Apr 30 22:28:11 2003
+++ b/drivers/char/drm/drm_dma.h	Wed Apr 30 22:28:11 2003
@@ -83,22 +83,24 @@
 				  dma->bufs[i].buf_count,
 				  dma->bufs[i].seg_count);
 			for (j = 0; j < dma->bufs[i].seg_count; j++) {
-				DRM(free_pages)(dma->bufs[i].seglist[j],
-						dma->bufs[i].page_order,
-						DRM_MEM_DMA);
+				if (dma->bufs[i].seglist[j]) {
+					DRM(free_pages)(dma->bufs[i].seglist[j],
+							dma->bufs[i].page_order,
+							DRM_MEM_DMA);
+				}
 			}
 			DRM(free)(dma->bufs[i].seglist,
 				  dma->bufs[i].seg_count
 				  * sizeof(*dma->bufs[0].seglist),
 				  DRM_MEM_SEGS);
 		}
-	   	if(dma->bufs[i].buf_count) {
-		   	for(j = 0; j < dma->bufs[i].buf_count; j++) {
-			   if(dma->bufs[i].buflist[j].dev_private) {
-			      DRM(free)(dma->bufs[i].buflist[j].dev_private,
-					dma->bufs[i].buflist[j].dev_priv_size,
-					DRM_MEM_BUFS);
-			   }
+	   	if (dma->bufs[i].buf_count) {
+		   	for (j = 0; j < dma->bufs[i].buf_count; j++) {
+				if (dma->bufs[i].buflist[j].dev_private) {
+					DRM(free)(dma->bufs[i].buflist[j].dev_private,
+						  dma->bufs[i].buflist[j].dev_priv_size,
+						  DRM_MEM_BUFS);
+				}
 			}
 		   	DRM(free)(dma->bufs[i].buflist,
 				  dma->bufs[i].buf_count *
@@ -126,61 +128,6 @@
 }
 
 
-#if __HAVE_DMA_HISTOGRAM
-/* This is slow, but is useful for debugging. */
-int DRM(histogram_slot)(unsigned long count)
-{
-	int value = DRM_DMA_HISTOGRAM_INITIAL;
-	int slot;
-
-	for (slot = 0;
-	     slot < DRM_DMA_HISTOGRAM_SLOTS;
-	     ++slot, value = DRM_DMA_HISTOGRAM_NEXT(value)) {
-		if (count < value) return slot;
-	}
-	return DRM_DMA_HISTOGRAM_SLOTS - 1;
-}
-
-void DRM(histogram_compute)(drm_device_t *dev, drm_buf_t *buf)
-{
-	cycles_t queued_to_dispatched;
-	cycles_t dispatched_to_completed;
-	cycles_t completed_to_freed;
-	int	 q2d, d2c, c2f, q2c, q2f;
-
-	if (buf->time_queued) {
-		queued_to_dispatched	= (buf->time_dispatched
-					   - buf->time_queued);
-		dispatched_to_completed = (buf->time_completed
-					   - buf->time_dispatched);
-		completed_to_freed	= (buf->time_freed
-					   - buf->time_completed);
-
-		q2d = DRM(histogram_slot)(queued_to_dispatched);
-		d2c = DRM(histogram_slot)(dispatched_to_completed);
-		c2f = DRM(histogram_slot)(completed_to_freed);
-
-		q2c = DRM(histogram_slot)(queued_to_dispatched
-					  + dispatched_to_completed);
-		q2f = DRM(histogram_slot)(queued_to_dispatched
-					  + dispatched_to_completed
-					  + completed_to_freed);
-
-		atomic_inc(&dev->histo.total);
-		atomic_inc(&dev->histo.queued_to_dispatched[q2d]);
-		atomic_inc(&dev->histo.dispatched_to_completed[d2c]);
-		atomic_inc(&dev->histo.completed_to_freed[c2f]);
-
-		atomic_inc(&dev->histo.queued_to_completed[q2c]);
-		atomic_inc(&dev->histo.queued_to_freed[q2f]);
-
-	}
-	buf->time_queued     = 0;
-	buf->time_dispatched = 0;
-	buf->time_completed  = 0;
-	buf->time_freed	     = 0;
-}
-#endif
 
 void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf)
 {
@@ -190,9 +137,6 @@
 	buf->pending  = 0;
 	buf->filp     = 0;
 	buf->used     = 0;
-#if __HAVE_DMA_HISTOGRAM
-	buf->time_completed = get_cycles();
-#endif
 
 	if ( __HAVE_DMA_WAITQUEUE && waitqueue_active(&buf->dma_wait)) {
 		wake_up_interruptible(&buf->dma_wait);
@@ -237,276 +181,6 @@
 #endif
 
 
-/* GH: This is a big hack for now...
- */
-#if __HAVE_OLD_DMA
-
-void DRM(clear_next_buffer)(drm_device_t *dev)
-{
-	drm_device_dma_t *dma = dev->dma;
-
-	dma->next_buffer = NULL;
-	if (dma->next_queue && !DRM_BUFCOUNT(&dma->next_queue->waitlist)) {
-		wake_up_interruptible(&dma->next_queue->flush_queue);
-	}
-	dma->next_queue	 = NULL;
-}
-
-int DRM(select_queue)(drm_device_t *dev, void (*wrapper)(unsigned long))
-{
-	int	   i;
-	int	   candidate = -1;
-	int	   j	     = jiffies;
-
-	if (!dev) {
-		DRM_ERROR("No device\n");
-		return -1;
-	}
-	if (!dev->queuelist || !dev->queuelist[DRM_KERNEL_CONTEXT]) {
-				/* This only happens between the time the
-				   interrupt is initialized and the time
-				   the queues are initialized. */
-		return -1;
-	}
-
-				/* Doing "while locked" DMA? */
-	if (DRM_WAITCOUNT(dev, DRM_KERNEL_CONTEXT)) {
-		return DRM_KERNEL_CONTEXT;
-	}
-
-				/* If there are buffers on the last_context
-				   queue, and we have not been executing
-				   this context very long, continue to
-				   execute this context. */
-	if (dev->last_switch <= j
-	    && dev->last_switch + DRM_TIME_SLICE > j
-	    && DRM_WAITCOUNT(dev, dev->last_context)) {
-		return dev->last_context;
-	}
-
-				/* Otherwise, find a candidate */
-	for (i = dev->last_checked + 1; i < dev->queue_count; i++) {
-		if (DRM_WAITCOUNT(dev, i)) {
-			candidate = dev->last_checked = i;
-			break;
-		}
-	}
-
-	if (candidate < 0) {
-		for (i = 0; i < dev->queue_count; i++) {
-			if (DRM_WAITCOUNT(dev, i)) {
-				candidate = dev->last_checked = i;
-				break;
-			}
-		}
-	}
-
-	if (wrapper
-	    && candidate >= 0
-	    && candidate != dev->last_context
-	    && dev->last_switch <= j
-	    && dev->last_switch + DRM_TIME_SLICE > j) {
-		if (dev->timer.expires != dev->last_switch + DRM_TIME_SLICE) {
-			del_timer(&dev->timer);
-			dev->timer.function = wrapper;
-			dev->timer.data	    = (unsigned long)dev;
-			dev->timer.expires  = dev->last_switch+DRM_TIME_SLICE;
-			add_timer(&dev->timer);
-		}
-		return -1;
-	}
-
-	return candidate;
-}
-
-
-int DRM(dma_enqueue)(struct file *filp, drm_dma_t *d)
-{
-	drm_file_t    *priv   = filp->private_data;
-	drm_device_t  *dev    = priv->dev;
-	int		  i;
-	drm_queue_t	  *q;
-	drm_buf_t	  *buf;
-	int		  idx;
-	int		  while_locked = 0;
-	drm_device_dma_t  *dma = dev->dma;
-	DECLARE_WAITQUEUE(entry, current);
-
-	DRM_DEBUG("%d\n", d->send_count);
-
-	if (d->flags & _DRM_DMA_WHILE_LOCKED) {
-		int context = dev->lock.hw_lock->lock;
-
-		if (!_DRM_LOCK_IS_HELD(context)) {
-			DRM_ERROR("No lock held during \"while locked\""
-				  " request\n");
-			return -EINVAL;
-		}
-		if (d->context != _DRM_LOCKING_CONTEXT(context)
-		    && _DRM_LOCKING_CONTEXT(context) != DRM_KERNEL_CONTEXT) {
-			DRM_ERROR("Lock held by %d while %d makes"
-				  " \"while locked\" request\n",
-				  _DRM_LOCKING_CONTEXT(context),
-				  d->context);
-			return -EINVAL;
-		}
-		q = dev->queuelist[DRM_KERNEL_CONTEXT];
-		while_locked = 1;
-	} else {
-		q = dev->queuelist[d->context];
-	}
-
-
-	atomic_inc(&q->use_count);
-	if (atomic_read(&q->block_write)) {
-		add_wait_queue(&q->write_queue, &entry);
-		atomic_inc(&q->block_count);
-		for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
-			if (!atomic_read(&q->block_write)) break;
-			schedule();
-			if (signal_pending(current)) {
-				atomic_dec(&q->use_count);
-				remove_wait_queue(&q->write_queue, &entry);
-				return -EINTR;
-			}
-		}
-		atomic_dec(&q->block_count);
-		current->state = TASK_RUNNING;
-		remove_wait_queue(&q->write_queue, &entry);
-	}
-
-	for (i = 0; i < d->send_count; i++) {
-		idx = d->send_indices[i];
-		if (idx < 0 || idx >= dma->buf_count) {
-			atomic_dec(&q->use_count);
-			DRM_ERROR("Index %d (of %d max)\n",
-				  d->send_indices[i], dma->buf_count - 1);
-			return -EINVAL;
-		}
-		buf = dma->buflist[ idx ];
-		if (buf->filp != filp) {
-			atomic_dec(&q->use_count);
-			DRM_ERROR("Process %d using buffer not owned\n",
-				  current->pid);
-			return -EINVAL;
-		}
-		if (buf->list != DRM_LIST_NONE) {
-			atomic_dec(&q->use_count);
-			DRM_ERROR("Process %d using buffer %d on list %d\n",
-				  current->pid, buf->idx, buf->list);
-		}
-		buf->used	  = d->send_sizes[i];
-		buf->while_locked = while_locked;
-		buf->context	  = d->context;
-		if (!buf->used) {
-			DRM_ERROR("Queueing 0 length buffer\n");
-		}
-		if (buf->pending) {
-			atomic_dec(&q->use_count);
-			DRM_ERROR("Queueing pending buffer:"
-				  " buffer %d, offset %d\n",
-				  d->send_indices[i], i);
-			return -EINVAL;
-		}
-		if (buf->waiting) {
-			atomic_dec(&q->use_count);
-			DRM_ERROR("Queueing waiting buffer:"
-				  " buffer %d, offset %d\n",
-				  d->send_indices[i], i);
-			return -EINVAL;
-		}
-		buf->waiting = 1;
-		if (atomic_read(&q->use_count) == 1
-		    || atomic_read(&q->finalization)) {
-			DRM(free_buffer)(dev, buf);
-		} else {
-			DRM(waitlist_put)(&q->waitlist, buf);
-			atomic_inc(&q->total_queued);
-		}
-	}
-	atomic_dec(&q->use_count);
-
-	return 0;
-}
-
-static int DRM(dma_get_buffers_of_order)(struct file *filp, drm_dma_t *d,
-					 int order)
-{
-	drm_file_t    *priv   = filp->private_data;
-	drm_device_t  *dev    = priv->dev;
-	int		  i;
-	drm_buf_t	  *buf;
-	drm_device_dma_t  *dma = dev->dma;
-
-	for (i = d->granted_count; i < d->request_count; i++) {
-		buf = DRM(freelist_get)(&dma->bufs[order].freelist,
-					d->flags & _DRM_DMA_WAIT);
-		if (!buf) break;
-		if (buf->pending || buf->waiting) {
-			DRM_ERROR("Free buffer %d in use: filp %p (w%d, p%d)\n",
-				  buf->idx,
-				  buf->filp,
-				  buf->waiting,
-				  buf->pending);
-		}
-		buf->filp     = filp;
-		if (copy_to_user(&d->request_indices[i],
-				 &buf->idx,
-				 sizeof(buf->idx)))
-			return -EFAULT;
-
-		if (copy_to_user(&d->request_sizes[i],
-				 &buf->total,
-				 sizeof(buf->total)))
-			return -EFAULT;
-
-		++d->granted_count;
-	}
-	return 0;
-}
-
-
-int DRM(dma_get_buffers)(struct file *filp, drm_dma_t *dma)
-{
-	int		  order;
-	int		  retcode = 0;
-	int		  tmp_order;
-
-	order = DRM(order)(dma->request_size);
-
-	dma->granted_count = 0;
-	retcode		   = DRM(dma_get_buffers_of_order)(filp, dma, order);
-
-	if (dma->granted_count < dma->request_count
-	    && (dma->flags & _DRM_DMA_SMALLER_OK)) {
-		for (tmp_order = order - 1;
-		     !retcode
-			     && dma->granted_count < dma->request_count
-			     && tmp_order >= DRM_MIN_ORDER;
-		     --tmp_order) {
-
-			retcode = DRM(dma_get_buffers_of_order)(filp, dma,
-								tmp_order);
-		}
-	}
-
-	if (dma->granted_count < dma->request_count
-	    && (dma->flags & _DRM_DMA_LARGER_OK)) {
-		for (tmp_order = order + 1;
-		     !retcode
-			     && dma->granted_count < dma->request_count
-			     && tmp_order <= DRM_MAX_ORDER;
-		     ++tmp_order) {
-
-			retcode = DRM(dma_get_buffers_of_order)(filp, dma,
-								tmp_order);
-		}
-	}
-	return 0;
-}
-
-#endif /* __HAVE_OLD_DMA */
 
 
 #if __HAVE_DMA_IRQ
@@ -519,6 +193,13 @@
 		return -EINVAL;
 
 	down( &dev->struct_sem );
+
+	/* Driver must have been initialized */
+	if ( !dev->dev_private ) {
+		up( &dev->struct_sem );
+		return -EINVAL;
+	}
+
 	if ( dev->irq ) {
 		up( &dev->struct_sem );
 		return -EBUSY;
diff -Nru a/drivers/char/drm/drm_drv.h b/drivers/char/drm/drm_drv.h
--- a/drivers/char/drm/drm_drv.h	Wed Apr 30 22:28:15 2003
+++ b/drivers/char/drm/drm_drv.h	Wed Apr 30 22:28:15 2003
@@ -87,6 +87,12 @@
 #ifndef __HAVE_KERNEL_CTX_SWITCH
 #define __HAVE_KERNEL_CTX_SWITCH	0
 #endif
+#ifndef __HAVE_DRIVER_FOPS_READ
+#define __HAVE_DRIVER_FOPS_READ		0
+#endif
+#ifndef __HAVE_DRIVER_FOPS_POLL
+#define __HAVE_DRIVER_FOPS_POLL		0
+#endif
 
 #ifndef DRIVER_PREINIT
 #define DRIVER_PREINIT()
@@ -121,9 +127,9 @@
 	.release = DRM(release),		\
 	.ioctl	 = DRM(ioctl),			\
 	.mmap	 = DRM(mmap),			\
-	.read	 = DRM(read),			\
 	.fasync  = DRM(fasync),			\
 	.poll	 = DRM(poll),			\
+	.read	 = DRM(read),			\
 }
 #endif
 
@@ -167,8 +173,8 @@
 	[DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)]     = { DRM(getstats),    0, 0 },
 
 	[DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)]    = { DRM(setunique),   1, 1 },
-	[DRM_IOCTL_NR(DRM_IOCTL_BLOCK)]         = { DRM(block),       1, 1 },
-	[DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)]       = { DRM(unblock),     1, 1 },
+	[DRM_IOCTL_NR(DRM_IOCTL_BLOCK)]         = { DRM(noop),        1, 1 },
+	[DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)]       = { DRM(noop),        1, 1 },
 	[DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)]    = { DRM(authmagic),   1, 1 },
 
 	[DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)]       = { DRM(addmap),      1, 1 },
@@ -192,7 +198,13 @@
 
 	[DRM_IOCTL_NR(DRM_IOCTL_LOCK)]	        = { DRM(lock),        1, 0 },
 	[DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)]        = { DRM(unlock),      1, 0 },
+
+#if __HAVE_DMA_FLUSH
+	/* Gamma only, really */
 	[DRM_IOCTL_NR(DRM_IOCTL_FINISH)]        = { DRM(finish),      1, 0 },
+#else
+	[DRM_IOCTL_NR(DRM_IOCTL_FINISH)]        = { DRM(noop),      1, 0 },
+#endif
 
 #if __HAVE_DMA
 	[DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)]      = { DRM(addbufs),     1, 1 },
@@ -307,7 +319,6 @@
 	if(dev->maplist == NULL) return -ENOMEM;
 	memset(dev->maplist, 0, sizeof(*dev->maplist));
 	INIT_LIST_HEAD(&dev->maplist->head);
-	dev->map_count = 0;
 
 	dev->vmalist = NULL;
 	dev->sigdata.lock = dev->lock.hw_lock = NULL;
@@ -475,7 +486,9 @@
 #if __HAVE_DMA_QUEUE || __HAVE_MULTIPLE_DMA_QUEUES
 	if ( dev->queuelist ) {
 		for ( i = 0 ; i < dev->queue_count ; i++ ) {
+#if __HAVE_DMA_WAITLIST
 			DRM(waitlist_destroy)( &dev->queuelist[i]->waitlist );
+#endif
 			if ( dev->queuelist[i] ) {
 				DRM(free)( dev->queuelist[i],
 					  sizeof(*dev->queuelist[0]),
@@ -764,7 +777,7 @@
 	DRM_DEBUG( "pid = %d, device = 0x%lx, open_count = %d\n",
 		   current->pid, (long)dev->device, dev->open_count );
 
-	if ( dev->lock.hw_lock &&
+	if ( priv->lock_count && dev->lock.hw_lock &&
 	     _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) &&
 	     dev->lock.filp == filp ) {
 		DRM_DEBUG( "File %p released, freeing lock for context %d\n",
@@ -782,7 +795,7 @@
                                    server. */
 	}
 #if __HAVE_RELEASE
-	else if ( dev->lock.hw_lock ) {
+	else if ( priv->lock_count && dev->lock.hw_lock ) {
 		/* The lock is required to reclaim buffers */
 		DECLARE_WAITQUEUE( entry, current );
 
@@ -802,9 +815,6 @@
 				break;	/* Got lock */
 			}
 				/* Contention */
-#if 0
-			atomic_inc( &dev->total_sleeps );
-#endif
 			schedule();
 			if ( signal_pending( current ) ) {
 				retcode = -ERESTARTSYS;
@@ -925,11 +935,8 @@
 #if __HAVE_MULTIPLE_DMA_QUEUES
 	drm_queue_t *q;
 #endif
-#if __HAVE_DMA_HISTOGRAM
-        cycles_t start;
 
-        dev->lck_start = start = get_cycles();
-#endif
+	++priv->lock_count;
 
         if ( copy_from_user( &lock, (drm_lock_t *)arg, sizeof(lock) ) )
 		return -EFAULT;
@@ -1019,9 +1026,6 @@
 
         DRM_DEBUG( "%d %s\n", lock.context, ret ? "interrupted" : "has lock" );
 
-#if __HAVE_DMA_HISTOGRAM
-        atomic_inc(&dev->histo.lacq[DRM(histogram_slot)(get_cycles()-start)]);
-#endif
         return ret;
 }
 
diff -Nru a/drivers/char/drm/drm_fops.h b/drivers/char/drm/drm_fops.h
--- a/drivers/char/drm/drm_fops.h	Wed Apr 30 22:28:10 2003
+++ b/drivers/char/drm/drm_fops.h	Wed Apr 30 22:28:10 2003
@@ -56,6 +56,7 @@
 	priv->dev	    = dev;
 	priv->ioctl_count   = 0;
 	priv->authenticated = capable(CAP_SYS_ADMIN);
+	priv->lock_count    = 0;
 
 	down(&dev->struct_sem);
 	if (!dev->file_last) {
@@ -111,98 +112,17 @@
 	return 0;
 }
 
-
-/* The drm_read and drm_write_string code (especially that which manages
-   the circular buffer), is based on Alessandro Rubini's LINUX DEVICE
-   DRIVERS (Cambridge: O'Reilly, 1998), pages 111-113. */
-
-ssize_t DRM(read)(struct file *filp, char *buf, size_t count, loff_t *off)
-{
-	drm_file_t    *priv   = filp->private_data;
-	drm_device_t  *dev    = priv->dev;
-	int	      left;
-	int	      avail;
-	int	      send;
-	int	      cur;
-
-	DRM_DEBUG("%p, %p\n", dev->buf_rp, dev->buf_wp);
-
-	while (dev->buf_rp == dev->buf_wp) {
-		DRM_DEBUG("  sleeping\n");
-		if (filp->f_flags & O_NONBLOCK) {
-			return -EAGAIN;
-		}
-		interruptible_sleep_on(&dev->buf_readers);
-		if (signal_pending(current)) {
-			DRM_DEBUG("  interrupted\n");
-			return -ERESTARTSYS;
-		}
-		DRM_DEBUG("  awake\n");
-	}
-
-	left  = (dev->buf_rp + DRM_BSZ - dev->buf_wp) % DRM_BSZ;
-	avail = DRM_BSZ - left;
-	send  = DRM_MIN(avail, count);
-
-	while (send) {
-		if (dev->buf_wp > dev->buf_rp) {
-			cur = DRM_MIN(send, dev->buf_wp - dev->buf_rp);
-		} else {
-			cur = DRM_MIN(send, dev->buf_end - dev->buf_rp);
-		}
-		if (copy_to_user(buf, dev->buf_rp, cur))
-			return -EFAULT;
-		dev->buf_rp += cur;
-		if (dev->buf_rp == dev->buf_end) dev->buf_rp = dev->buf;
-		send -= cur;
-	}
-
-	wake_up_interruptible(&dev->buf_writers);
-	return DRM_MIN(avail, count);;
-}
-
-int DRM(write_string)(drm_device_t *dev, const char *s)
+#if !__HAVE_DRIVER_FOPS_POLL
+unsigned int DRM(poll)(struct file *filp, struct poll_table_struct *wait)
 {
-	int left   = (dev->buf_rp + DRM_BSZ - dev->buf_wp) % DRM_BSZ;
-	int send   = strlen(s);
-	int count;
-
-	DRM_DEBUG("%d left, %d to send (%p, %p)\n",
-		  left, send, dev->buf_rp, dev->buf_wp);
-
-	if (left == 1 || dev->buf_wp != dev->buf_rp) {
-		DRM_ERROR("Buffer not empty (%d left, wp = %p, rp = %p)\n",
-			  left,
-			  dev->buf_wp,
-			  dev->buf_rp);
-	}
-
-	while (send) {
-		if (dev->buf_wp >= dev->buf_rp) {
-			count = DRM_MIN(send, dev->buf_end - dev->buf_wp);
-			if (count == left) --count; /* Leave a hole */
-		} else {
-			count = DRM_MIN(send, dev->buf_rp - dev->buf_wp - 1);
-		}
-		strncpy(dev->buf_wp, s, count);
-		dev->buf_wp += count;
-		if (dev->buf_wp == dev->buf_end) dev->buf_wp = dev->buf;
-		send -= count;
-	}
-
-	if (dev->buf_async) kill_fasync(&dev->buf_async, SIGIO, POLL_IN);
-
-	DRM_DEBUG("waking\n");
-	wake_up_interruptible(&dev->buf_readers);
 	return 0;
 }
+#endif
 
-unsigned int DRM(poll)(struct file *filp, struct poll_table_struct *wait)
-{
-	drm_file_t   *priv = filp->private_data;
-	drm_device_t *dev  = priv->dev;
 
-	poll_wait(filp, &dev->buf_readers, wait);
-	if (dev->buf_wp != dev->buf_rp) return POLLIN | POLLRDNORM;
+#if !__HAVE_DRIVER_FOPS_READ
+ssize_t DRM(read)(struct file *filp, char *buf, size_t count, loff_t *off)
+{
 	return 0;
 }
+#endif
diff -Nru a/drivers/char/drm/drm_init.h b/drivers/char/drm/drm_init.h
--- a/drivers/char/drm/drm_init.h	Wed Apr 30 22:28:16 2003
+++ b/drivers/char/drm/drm_init.h	Wed Apr 30 22:28:16 2003
@@ -49,11 +49,6 @@
 	for (c = s; *c && *c != ':'; c++); /* find : or \0 */
 	if (*c) r = c + 1; else r = NULL;  /* remember remainder */
 	*c = '\0';			   /* terminate */
-	if (!strcmp(s, "noctx")) {
-		DRM(flags) |= DRM_FLAG_NOCTX;
-		DRM_INFO("Server-mediated context switching OFF\n");
-		return;
-	}
 	if (!strcmp(s, "debug")) {
 		DRM(flags) |= DRM_FLAG_DEBUG;
 		DRM_INFO("Debug messages ON\n");
diff -Nru a/drivers/char/drm/drm_ioctl.h b/drivers/char/drm/drm_ioctl.h
--- a/drivers/char/drm/drm_ioctl.h	Wed Apr 30 22:28:06 2003
+++ b/drivers/char/drm/drm_ioctl.h	Wed Apr 30 22:28:06 2003
@@ -196,7 +196,7 @@
 	idx = map.offset;
 
 	down(&dev->struct_sem);
-	if (idx < 0 || idx >= dev->map_count) {
+	if (idx < 0) {
 		up(&dev->struct_sem);
 		return -EINVAL;
 	}
diff -Nru a/drivers/char/drm/drm_lock.h b/drivers/char/drm/drm_lock.h
--- a/drivers/char/drm/drm_lock.h	Wed Apr 30 22:28:11 2003
+++ b/drivers/char/drm/drm_lock.h	Wed Apr 30 22:28:11 2003
@@ -31,19 +31,13 @@
 
 #include "drmP.h"
 
-int DRM(block)(struct inode *inode, struct file *filp, unsigned int cmd,
+int DRM(noop)(struct inode *inode, struct file *filp, unsigned int cmd,
 	       unsigned long arg)
 {
 	DRM_DEBUG("\n");
 	return 0;
 }
 
-int DRM(unblock)(struct inode *inode, struct file *filp, unsigned int cmd,
-		 unsigned long arg)
-{
-	DRM_DEBUG("\n");
-	return 0;
-}
 
 int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context)
 {
@@ -106,113 +100,6 @@
 	}
 	wake_up_interruptible(&dev->lock.lock_queue);
 	return 0;
-}
-
-static int DRM(flush_queue)(drm_device_t *dev, int context)
-{
-	DECLARE_WAITQUEUE(entry, current);
-	int		  ret	= 0;
-	drm_queue_t	  *q	= dev->queuelist[context];
-
-	DRM_DEBUG("\n");
-
-	atomic_inc(&q->use_count);
-	if (atomic_read(&q->use_count) > 1) {
-		atomic_inc(&q->block_write);
-		add_wait_queue(&q->flush_queue, &entry);
-		atomic_inc(&q->block_count);
-		for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
-			if (!DRM_BUFCOUNT(&q->waitlist)) break;
-			schedule();
-			if (signal_pending(current)) {
-				ret = -EINTR; /* Can't restart */
-				break;
-			}
-		}
-		atomic_dec(&q->block_count);
-		current->state = TASK_RUNNING;
-		remove_wait_queue(&q->flush_queue, &entry);
-	}
-	atomic_dec(&q->use_count);
-
-				/* NOTE: block_write is still incremented!
-				   Use drm_flush_unlock_queue to decrement. */
-	return ret;
-}
-
-static int DRM(flush_unblock_queue)(drm_device_t *dev, int context)
-{
-	drm_queue_t	  *q	= dev->queuelist[context];
-
-	DRM_DEBUG("\n");
-
-	atomic_inc(&q->use_count);
-	if (atomic_read(&q->use_count) > 1) {
-		if (atomic_read(&q->block_write)) {
-			atomic_dec(&q->block_write);
-			wake_up_interruptible(&q->write_queue);
-		}
-	}
-	atomic_dec(&q->use_count);
-	return 0;
-}
-
-int DRM(flush_block_and_flush)(drm_device_t *dev, int context,
-			       drm_lock_flags_t flags)
-{
-	int ret = 0;
-	int i;
-
-	DRM_DEBUG("\n");
-
-	if (flags & _DRM_LOCK_FLUSH) {
-		ret = DRM(flush_queue)(dev, DRM_KERNEL_CONTEXT);
-		if (!ret) ret = DRM(flush_queue)(dev, context);
-	}
-	if (flags & _DRM_LOCK_FLUSH_ALL) {
-		for (i = 0; !ret && i < dev->queue_count; i++) {
-			ret = DRM(flush_queue)(dev, i);
-		}
-	}
-	return ret;
-}
-
-int DRM(flush_unblock)(drm_device_t *dev, int context, drm_lock_flags_t flags)
-{
-	int ret = 0;
-	int i;
-
-	DRM_DEBUG("\n");
-
-	if (flags & _DRM_LOCK_FLUSH) {
-		ret = DRM(flush_unblock_queue)(dev, DRM_KERNEL_CONTEXT);
-		if (!ret) ret = DRM(flush_unblock_queue)(dev, context);
-	}
-	if (flags & _DRM_LOCK_FLUSH_ALL) {
-		for (i = 0; !ret && i < dev->queue_count; i++) {
-			ret = DRM(flush_unblock_queue)(dev, i);
-		}
-	}
-
-	return ret;
-}
-
-int DRM(finish)(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		  ret	  = 0;
-	drm_lock_t	  lock;
-
-	DRM_DEBUG("\n");
-
-	if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
-		return -EFAULT;
-	ret = DRM(flush_block_and_flush)(dev, lock.context, lock.flags);
-	DRM(flush_unblock)(dev, lock.context, lock.flags);
-	return ret;
 }
 
 /* If we get here, it means that the process has called DRM_IOCTL_LOCK
diff -Nru a/drivers/char/drm/drm_memory.h b/drivers/char/drm/drm_memory.h
--- a/drivers/char/drm/drm_memory.h	Wed Apr 30 22:28:05 2003
+++ b/drivers/char/drm/drm_memory.h	Wed Apr 30 22:28:05 2003
@@ -31,188 +31,48 @@
 
 #include <linux/config.h>
 #include "drmP.h"
-#include <linux/wrapper.h>
 
-typedef struct drm_mem_stats {
-	const char	  *name;
-	int		  succeed_count;
-	int		  free_count;
-	int		  fail_count;
-	unsigned long	  bytes_allocated;
-	unsigned long	  bytes_freed;
-} drm_mem_stats_t;
-
-static spinlock_t	  DRM(mem_lock)	     = SPIN_LOCK_UNLOCKED;
-static unsigned long	  DRM(ram_available) = 0; /* In pages */
-static unsigned long	  DRM(ram_used)      = 0;
-static drm_mem_stats_t	  DRM(mem_stats)[]   = {
-	[DRM_MEM_DMA]	    = { "dmabufs"  },
-	[DRM_MEM_SAREA]	    = { "sareas"   },
-	[DRM_MEM_DRIVER]    = { "driver"   },
-	[DRM_MEM_MAGIC]	    = { "magic"	   },
-	[DRM_MEM_IOCTLS]    = { "ioctltab" },
-	[DRM_MEM_MAPS]	    = { "maplist"  },
-	[DRM_MEM_VMAS]	    = { "vmalist"  },
-	[DRM_MEM_BUFS]	    = { "buflist"  },
-	[DRM_MEM_SEGS]	    = { "seglist"  },
-	[DRM_MEM_PAGES]	    = { "pagelist" },
-	[DRM_MEM_FILES]	    = { "files"	   },
-	[DRM_MEM_QUEUES]    = { "queues"   },
-	[DRM_MEM_CMDS]	    = { "commands" },
-	[DRM_MEM_MAPPINGS]  = { "mappings" },
-	[DRM_MEM_BUFLISTS]  = { "buflists" },
-	[DRM_MEM_AGPLISTS]  = { "agplist"  },
-	[DRM_MEM_SGLISTS]   = { "sglist"   },
-	[DRM_MEM_TOTALAGP]  = { "totalagp" },
-	[DRM_MEM_BOUNDAGP]  = { "boundagp" },
-	[DRM_MEM_CTXBITMAP] = { "ctxbitmap"},
-	[DRM_MEM_STUB]      = { "stub"     },
-	{ NULL, 0, }		/* Last entry must be null */
-};
+/* Cut down version of drm_memory_debug.h, which used to be called
+ * drm_memory.h.  If you want the debug functionality, change 0 to 1
+ * below.
+ */
+#define DEBUG_MEMORY 0
 
+
+#if DEBUG_MEMORY
+#include "drm_memory_debug.h"
+#else
 void DRM(mem_init)(void)
 {
-	drm_mem_stats_t *mem;
-	struct sysinfo	si;
-
-	for (mem = DRM(mem_stats); mem->name; ++mem) {
-		mem->succeed_count   = 0;
-		mem->free_count	     = 0;
-		mem->fail_count	     = 0;
-		mem->bytes_allocated = 0;
-		mem->bytes_freed     = 0;
-	}
-
-	si_meminfo(&si);
-	DRM(ram_available) = si.totalram;
-	DRM(ram_used)	   = 0;
 }
 
 /* drm_mem_info is called whenever a process reads /dev/drm/mem. */
-
-static int DRM(_mem_info)(char *buf, char **start, off_t offset,
-			  int request, int *eof, void *data)
-{
-	drm_mem_stats_t *pt;
-	int             len = 0;
-
-	if (offset > DRM_PROC_LIMIT) {
-		*eof = 1;
-		return 0;
-	}
-
-	*eof   = 0;
-	*start = &buf[offset];
-
-	DRM_PROC_PRINT("		  total counts			"
-		       " |    outstanding  \n");
-	DRM_PROC_PRINT("type	   alloc freed fail	bytes	   freed"
-		       " | allocs      bytes\n\n");
-	DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu kB         |\n",
-		       "system", 0, 0, 0,
-		       DRM(ram_available) << (PAGE_SHIFT - 10));
-	DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu kB         |\n",
-		       "locked", 0, 0, 0, DRM(ram_used) >> 10);
-	DRM_PROC_PRINT("\n");
-	for (pt = DRM(mem_stats); pt->name; pt++) {
-		DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu %10lu | %6d %10ld\n",
-			       pt->name,
-			       pt->succeed_count,
-			       pt->free_count,
-			       pt->fail_count,
-			       pt->bytes_allocated,
-			       pt->bytes_freed,
-			       pt->succeed_count - pt->free_count,
-			       (long)pt->bytes_allocated
-			       - (long)pt->bytes_freed);
-	}
-
-	if (len > request + offset) return request;
-	*eof = 1;
-	return len - offset;
-}
-
 int DRM(mem_info)(char *buf, char **start, off_t offset,
 		  int len, int *eof, void *data)
 {
-	int ret;
-
-	spin_lock(&DRM(mem_lock));
-	ret = DRM(_mem_info)(buf, start, offset, len, eof, data);
-	spin_unlock(&DRM(mem_lock));
-	return ret;
+	return 0;
 }
 
 void *DRM(alloc)(size_t size, int area)
 {
-	void *pt;
-
-	if (!size) {
-		DRM_MEM_ERROR(area, "Allocating 0 bytes\n");
-		return NULL;
-	}
-
-	if (!(pt = kmalloc(size, GFP_KERNEL))) {
-		spin_lock(&DRM(mem_lock));
-		++DRM(mem_stats)[area].fail_count;
-		spin_unlock(&DRM(mem_lock));
-		return NULL;
-	}
-	spin_lock(&DRM(mem_lock));
-	++DRM(mem_stats)[area].succeed_count;
-	DRM(mem_stats)[area].bytes_allocated += size;
-	spin_unlock(&DRM(mem_lock));
-	return pt;
+	return kmalloc(size, GFP_KERNEL);
 }
 
 void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
 {
 	void *pt;
 
-	if (!(pt = DRM(alloc)(size, area))) return NULL;
+	if (!(pt = kmalloc(size, GFP_KERNEL))) return NULL;
 	if (oldpt && oldsize) {
 		memcpy(pt, oldpt, oldsize);
-		DRM(free)(oldpt, oldsize, area);
+		kfree(oldpt);
 	}
 	return pt;
 }
 
-char *DRM(strdup)(const char *s, int area)
-{
-	char *pt;
-	int	 length = s ? strlen(s) : 0;
-
-	if (!(pt = DRM(alloc)(length+1, area))) return NULL;
-	strcpy(pt, s);
-	return pt;
-}
-
-void DRM(strfree)(const char *s, int area)
-{
-	unsigned int size;
-
-	if (!s) return;
-
-	size = 1 + (s ? strlen(s) : 0);
-	DRM(free)((void *)s, size, area);
-}
-
 void DRM(free)(void *pt, size_t size, int area)
 {
-	int alloc_count;
-	int free_count;
-
-	if (!pt) DRM_MEM_ERROR(area, "Attempt to free NULL pointer\n");
-	else	 kfree(pt);
-	spin_lock(&DRM(mem_lock));
-	DRM(mem_stats)[area].bytes_freed += size;
-	free_count  = ++DRM(mem_stats)[area].free_count;
-	alloc_count =	DRM(mem_stats)[area].succeed_count;
-	spin_unlock(&DRM(mem_lock));
-	if (free_count > alloc_count) {
-		DRM_MEM_ERROR(area, "Excess frees: %d frees, %d allocs\n",
-			      free_count, alloc_count);
-	}
+	kfree(pt);
 }
 
 unsigned long DRM(alloc_pages)(int order, int area)
@@ -222,36 +82,18 @@
 	unsigned long addr;
 	unsigned int  sz;
 
-	spin_lock(&DRM(mem_lock));
-	if ((DRM(ram_used) >> PAGE_SHIFT)
-	    > (DRM_RAM_PERCENT * DRM(ram_available)) / 100) {
-		spin_unlock(&DRM(mem_lock));
-		return 0;
-	}
-	spin_unlock(&DRM(mem_lock));
-
 	address = __get_free_pages(GFP_KERNEL, order);
-	if (!address) {
-		spin_lock(&DRM(mem_lock));
-		++DRM(mem_stats)[area].fail_count;
-		spin_unlock(&DRM(mem_lock));
+	if (!address) 
 		return 0;
-	}
-	spin_lock(&DRM(mem_lock));
-	++DRM(mem_stats)[area].succeed_count;
-	DRM(mem_stats)[area].bytes_allocated += bytes;
-	DRM(ram_used)		             += bytes;
-	spin_unlock(&DRM(mem_lock));
-
 
-				/* Zero outside the lock */
+				/* Zero */
 	memset((void *)address, 0, bytes);
 
 				/* Reserve */
 	for (addr = address, sz = bytes;
 	     sz > 0;
 	     addr += PAGE_SIZE, sz -= PAGE_SIZE) {
-		mem_map_reserve(virt_to_page(addr));
+		SetPageReserved(virt_to_page(addr));
 	}
 
 	return address;
@@ -260,207 +102,56 @@
 void DRM(free_pages)(unsigned long address, int order, int area)
 {
 	unsigned long bytes = PAGE_SIZE << order;
-	int		  alloc_count;
-	int		  free_count;
 	unsigned long addr;
 	unsigned int  sz;
 
-	if (!address) {
-		DRM_MEM_ERROR(area, "Attempt to free address 0\n");
-	} else {
-				/* Unreserve */
-		for (addr = address, sz = bytes;
-		     sz > 0;
-		     addr += PAGE_SIZE, sz -= PAGE_SIZE) {
-			mem_map_unreserve(virt_to_page(addr));
-		}
-		free_pages(address, order);
-	}
+	if (!address) 
+		return;
 
-	spin_lock(&DRM(mem_lock));
-	free_count  = ++DRM(mem_stats)[area].free_count;
-	alloc_count =	DRM(mem_stats)[area].succeed_count;
-	DRM(mem_stats)[area].bytes_freed += bytes;
-	DRM(ram_used)			 -= bytes;
-	spin_unlock(&DRM(mem_lock));
-	if (free_count > alloc_count) {
-		DRM_MEM_ERROR(area,
-			      "Excess frees: %d frees, %d allocs\n",
-			      free_count, alloc_count);
+	/* Unreserve */
+	for (addr = address, sz = bytes;
+	     sz > 0;
+	     addr += PAGE_SIZE, sz -= PAGE_SIZE) {
+		ClearPageReserved(virt_to_page(addr));
 	}
+
+	free_pages(address, order);
 }
 
 void *DRM(ioremap)(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(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;
+	return ioremap(offset, size);
 }
 
 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));
-		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;
+	return ioremap_nocache(offset, size);
 }
 
 void DRM(ioremapfree)(void *pt, unsigned long size)
 {
-	int alloc_count;
-	int free_count;
-
-	if (!pt)
-		DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
-			      "Attempt to free NULL pointer\n");
-	else
-		iounmap(pt);
-
-	spin_lock(&DRM(mem_lock));
-	DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_freed += size;
-	free_count  = ++DRM(mem_stats)[DRM_MEM_MAPPINGS].free_count;
-	alloc_count =	DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
-	spin_unlock(&DRM(mem_lock));
-	if (free_count > alloc_count) {
-		DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
-			      "Excess frees: %d frees, %d allocs\n",
-			      free_count, alloc_count);
-	}
+	iounmap(pt);
 }
 
 #if __REALLY_HAVE_AGP
-
 agp_memory *DRM(alloc_agp)(int pages, u32 type)
 {
-	agp_memory *handle;
-
-	if (!pages) {
-		DRM_MEM_ERROR(DRM_MEM_TOTALAGP, "Allocating 0 pages\n");
-		return NULL;
-	}
-
-	if ((handle = DRM(agp_allocate_memory)(pages, type))) {
-		spin_lock(&DRM(mem_lock));
-		++DRM(mem_stats)[DRM_MEM_TOTALAGP].succeed_count;
-		DRM(mem_stats)[DRM_MEM_TOTALAGP].bytes_allocated
-			+= pages << PAGE_SHIFT;
-		spin_unlock(&DRM(mem_lock));
-		return handle;
-	}
-	spin_lock(&DRM(mem_lock));
-	++DRM(mem_stats)[DRM_MEM_TOTALAGP].fail_count;
-	spin_unlock(&DRM(mem_lock));
-	return NULL;
+	return DRM(agp_allocate_memory)(pages, type);
 }
 
 int DRM(free_agp)(agp_memory *handle, int pages)
 {
-	int           alloc_count;
-	int           free_count;
-	int           retval = -EINVAL;
-
-	if (!handle) {
-		DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
-			      "Attempt to free NULL AGP handle\n");
-		return retval;;
-	}
-
-	if (DRM(agp_free_memory)(handle)) {
-		spin_lock(&DRM(mem_lock));
-		free_count  = ++DRM(mem_stats)[DRM_MEM_TOTALAGP].free_count;
-		alloc_count =   DRM(mem_stats)[DRM_MEM_TOTALAGP].succeed_count;
-		DRM(mem_stats)[DRM_MEM_TOTALAGP].bytes_freed
-			+= pages << PAGE_SHIFT;
-		spin_unlock(&DRM(mem_lock));
-		if (free_count > alloc_count) {
-			DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
-				      "Excess frees: %d frees, %d allocs\n",
-				      free_count, alloc_count);
-		}
-		return 0;
-	}
-	return retval;
+	return DRM(agp_free_memory)(handle) ? 0 : -EINVAL;
 }
 
 int DRM(bind_agp)(agp_memory *handle, unsigned int start)
 {
-	int retcode = -EINVAL;
-
-	if (!handle) {
-		DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
-			      "Attempt to bind NULL AGP handle\n");
-		return retcode;
-	}
-
-	if (!(retcode = DRM(agp_bind_memory)(handle, start))) {
-		spin_lock(&DRM(mem_lock));
-		++DRM(mem_stats)[DRM_MEM_BOUNDAGP].succeed_count;
-		DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_allocated
-			+= handle->page_count << PAGE_SHIFT;
-		spin_unlock(&DRM(mem_lock));
-		return retcode;
-	}
-	spin_lock(&DRM(mem_lock));
-	++DRM(mem_stats)[DRM_MEM_BOUNDAGP].fail_count;
-	spin_unlock(&DRM(mem_lock));
-	return retcode;
+	return DRM(agp_bind_memory)(handle, start);
 }
 
 int DRM(unbind_agp)(agp_memory *handle)
 {
-	int alloc_count;
-	int free_count;
-	int retcode = -EINVAL;
-
-	if (!handle) {
-		DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
-			      "Attempt to unbind NULL AGP handle\n");
-		return retcode;
-	}
-
-	if ((retcode = DRM(agp_unbind_memory)(handle))) return retcode;
-	spin_lock(&DRM(mem_lock));
-	free_count  = ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].free_count;
-	alloc_count = DRM(mem_stats)[DRM_MEM_BOUNDAGP].succeed_count;
-	DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_freed
-		+= handle->page_count << PAGE_SHIFT;
-	spin_unlock(&DRM(mem_lock));
-	if (free_count > alloc_count) {
-		DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
-			      "Excess frees: %d frees, %d allocs\n",
-			      free_count, alloc_count);
-	}
-	return retcode;
+	return DRM(agp_unbind_memory)(handle);
 }
-#endif
+#endif /* agp */
+#endif /* debug_memory */
diff -Nru a/drivers/char/drm/drm_memory_debug.h b/drivers/char/drm/drm_memory_debug.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/char/drm/drm_memory_debug.h	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,445 @@
+/* drm_memory.h -- Memory management wrappers for DRM -*- linux-c -*-
+ * Created: Thu Feb  4 14:00:34 1999 by faith@valinux.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>
+ *    Gareth Hughes <gareth@valinux.com>
+ */
+
+#include <linux/config.h>
+#include "drmP.h"
+
+typedef struct drm_mem_stats {
+	const char	  *name;
+	int		  succeed_count;
+	int		  free_count;
+	int		  fail_count;
+	unsigned long	  bytes_allocated;
+	unsigned long	  bytes_freed;
+} drm_mem_stats_t;
+
+static spinlock_t	  DRM(mem_lock)	     = SPIN_LOCK_UNLOCKED;
+static unsigned long	  DRM(ram_available) = 0; /* In pages */
+static unsigned long	  DRM(ram_used)      = 0;
+static drm_mem_stats_t	  DRM(mem_stats)[]   = {
+	[DRM_MEM_DMA]	    = { "dmabufs"  },
+	[DRM_MEM_SAREA]	    = { "sareas"   },
+	[DRM_MEM_DRIVER]    = { "driver"   },
+	[DRM_MEM_MAGIC]	    = { "magic"	   },
+	[DRM_MEM_IOCTLS]    = { "ioctltab" },
+	[DRM_MEM_MAPS]	    = { "maplist"  },
+	[DRM_MEM_VMAS]	    = { "vmalist"  },
+	[DRM_MEM_BUFS]	    = { "buflist"  },
+	[DRM_MEM_SEGS]	    = { "seglist"  },
+	[DRM_MEM_PAGES]	    = { "pagelist" },
+	[DRM_MEM_FILES]	    = { "files"	   },
+	[DRM_MEM_QUEUES]    = { "queues"   },
+	[DRM_MEM_CMDS]	    = { "commands" },
+	[DRM_MEM_MAPPINGS]  = { "mappings" },
+	[DRM_MEM_BUFLISTS]  = { "buflists" },
+	[DRM_MEM_AGPLISTS]  = { "agplist"  },
+	[DRM_MEM_SGLISTS]   = { "sglist"   },
+	[DRM_MEM_TOTALAGP]  = { "totalagp" },
+	[DRM_MEM_BOUNDAGP]  = { "boundagp" },
+	[DRM_MEM_CTXBITMAP] = { "ctxbitmap"},
+	[DRM_MEM_STUB]      = { "stub"     },
+	{ NULL, 0, }		/* Last entry must be null */
+};
+
+void DRM(mem_init)(void)
+{
+	drm_mem_stats_t *mem;
+	struct sysinfo	si;
+
+	for (mem = DRM(mem_stats); mem->name; ++mem) {
+		mem->succeed_count   = 0;
+		mem->free_count	     = 0;
+		mem->fail_count	     = 0;
+		mem->bytes_allocated = 0;
+		mem->bytes_freed     = 0;
+	}
+
+	si_meminfo(&si);
+	DRM(ram_available) = si.totalram;
+	DRM(ram_used)	   = 0;
+}
+
+/* drm_mem_info is called whenever a process reads /dev/drm/mem. */
+
+static int DRM(_mem_info)(char *buf, char **start, off_t offset,
+			  int request, int *eof, void *data)
+{
+	drm_mem_stats_t *pt;
+	int             len = 0;
+
+	if (offset > DRM_PROC_LIMIT) {
+		*eof = 1;
+		return 0;
+	}
+
+	*eof   = 0;
+	*start = &buf[offset];
+
+	DRM_PROC_PRINT("		  total counts			"
+		       " |    outstanding  \n");
+	DRM_PROC_PRINT("type	   alloc freed fail	bytes	   freed"
+		       " | allocs      bytes\n\n");
+	DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu kB         |\n",
+		       "system", 0, 0, 0,
+		       DRM(ram_available) << (PAGE_SHIFT - 10));
+	DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu kB         |\n",
+		       "locked", 0, 0, 0, DRM(ram_used) >> 10);
+	DRM_PROC_PRINT("\n");
+	for (pt = DRM(mem_stats); pt->name; pt++) {
+		DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu %10lu | %6d %10ld\n",
+			       pt->name,
+			       pt->succeed_count,
+			       pt->free_count,
+			       pt->fail_count,
+			       pt->bytes_allocated,
+			       pt->bytes_freed,
+			       pt->succeed_count - pt->free_count,
+			       (long)pt->bytes_allocated
+			       - (long)pt->bytes_freed);
+	}
+
+	if (len > request + offset) return request;
+	*eof = 1;
+	return len - offset;
+}
+
+int DRM(mem_info)(char *buf, char **start, off_t offset,
+		  int len, int *eof, void *data)
+{
+	int ret;
+
+	spin_lock(&DRM(mem_lock));
+	ret = DRM(_mem_info)(buf, start, offset, len, eof, data);
+	spin_unlock(&DRM(mem_lock));
+	return ret;
+}
+
+void *DRM(alloc)(size_t size, int area)
+{
+	void *pt;
+
+	if (!size) {
+		DRM_MEM_ERROR(area, "Allocating 0 bytes\n");
+		return NULL;
+	}
+
+	if (!(pt = kmalloc(size, GFP_KERNEL))) {
+		spin_lock(&DRM(mem_lock));
+		++DRM(mem_stats)[area].fail_count;
+		spin_unlock(&DRM(mem_lock));
+		return NULL;
+	}
+	spin_lock(&DRM(mem_lock));
+	++DRM(mem_stats)[area].succeed_count;
+	DRM(mem_stats)[area].bytes_allocated += size;
+	spin_unlock(&DRM(mem_lock));
+	return pt;
+}
+
+void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
+{
+	void *pt;
+
+	if (!(pt = DRM(alloc)(size, area))) return NULL;
+	if (oldpt && oldsize) {
+		memcpy(pt, oldpt, oldsize);
+		DRM(free)(oldpt, oldsize, area);
+	}
+	return pt;
+}
+
+void DRM(free)(void *pt, size_t size, int area)
+{
+	int alloc_count;
+	int free_count;
+
+	if (!pt) DRM_MEM_ERROR(area, "Attempt to free NULL pointer\n");
+	else	 kfree(pt);
+	spin_lock(&DRM(mem_lock));
+	DRM(mem_stats)[area].bytes_freed += size;
+	free_count  = ++DRM(mem_stats)[area].free_count;
+	alloc_count =	DRM(mem_stats)[area].succeed_count;
+	spin_unlock(&DRM(mem_lock));
+	if (free_count > alloc_count) {
+		DRM_MEM_ERROR(area, "Excess frees: %d frees, %d allocs\n",
+			      free_count, alloc_count);
+	}
+}
+
+unsigned long DRM(alloc_pages)(int order, int area)
+{
+	unsigned long address;
+	unsigned long bytes	  = PAGE_SIZE << order;
+	unsigned long addr;
+	unsigned int  sz;
+
+	spin_lock(&DRM(mem_lock));
+	if ((DRM(ram_used) >> PAGE_SHIFT)
+	    > (DRM_RAM_PERCENT * DRM(ram_available)) / 100) {
+		spin_unlock(&DRM(mem_lock));
+		return 0;
+	}
+	spin_unlock(&DRM(mem_lock));
+
+	address = __get_free_pages(GFP_KERNEL, order);
+	if (!address) {
+		spin_lock(&DRM(mem_lock));
+		++DRM(mem_stats)[area].fail_count;
+		spin_unlock(&DRM(mem_lock));
+		return 0;
+	}
+	spin_lock(&DRM(mem_lock));
+	++DRM(mem_stats)[area].succeed_count;
+	DRM(mem_stats)[area].bytes_allocated += bytes;
+	DRM(ram_used)		             += bytes;
+	spin_unlock(&DRM(mem_lock));
+
+
+				/* Zero outside the lock */
+	memset((void *)address, 0, bytes);
+
+				/* Reserve */
+	for (addr = address, sz = bytes;
+	     sz > 0;
+	     addr += PAGE_SIZE, sz -= PAGE_SIZE) {
+		SetPageReserved(virt_to_page(addr));
+	}
+
+	return address;
+}
+
+void DRM(free_pages)(unsigned long address, int order, int area)
+{
+	unsigned long bytes = PAGE_SIZE << order;
+	int		  alloc_count;
+	int		  free_count;
+	unsigned long addr;
+	unsigned int  sz;
+
+	if (!address) {
+		DRM_MEM_ERROR(area, "Attempt to free address 0\n");
+	} else {
+				/* Unreserve */
+		for (addr = address, sz = bytes;
+		     sz > 0;
+		     addr += PAGE_SIZE, sz -= PAGE_SIZE) {
+			ClearPageReserved(virt_to_page(addr));
+		}
+		free_pages(address, order);
+	}
+
+	spin_lock(&DRM(mem_lock));
+	free_count  = ++DRM(mem_stats)[area].free_count;
+	alloc_count =	DRM(mem_stats)[area].succeed_count;
+	DRM(mem_stats)[area].bytes_freed += bytes;
+	DRM(ram_used)			 -= bytes;
+	spin_unlock(&DRM(mem_lock));
+	if (free_count > alloc_count) {
+		DRM_MEM_ERROR(area,
+			      "Excess frees: %d frees, %d allocs\n",
+			      free_count, alloc_count);
+	}
+}
+
+void *DRM(ioremap)(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(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));
+		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(ioremapfree)(void *pt, unsigned long size)
+{
+	int alloc_count;
+	int free_count;
+
+	if (!pt)
+		DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
+			      "Attempt to free NULL pointer\n");
+	else
+		iounmap(pt);
+
+	spin_lock(&DRM(mem_lock));
+	DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_freed += size;
+	free_count  = ++DRM(mem_stats)[DRM_MEM_MAPPINGS].free_count;
+	alloc_count =	DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
+	spin_unlock(&DRM(mem_lock));
+	if (free_count > alloc_count) {
+		DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
+			      "Excess frees: %d frees, %d allocs\n",
+			      free_count, alloc_count);
+	}
+}
+
+#if __REALLY_HAVE_AGP
+
+agp_memory *DRM(alloc_agp)(int pages, u32 type)
+{
+	agp_memory *handle;
+
+	if (!pages) {
+		DRM_MEM_ERROR(DRM_MEM_TOTALAGP, "Allocating 0 pages\n");
+		return NULL;
+	}
+
+	if ((handle = DRM(agp_allocate_memory)(pages, type))) {
+		spin_lock(&DRM(mem_lock));
+		++DRM(mem_stats)[DRM_MEM_TOTALAGP].succeed_count;
+		DRM(mem_stats)[DRM_MEM_TOTALAGP].bytes_allocated
+			+= pages << PAGE_SHIFT;
+		spin_unlock(&DRM(mem_lock));
+		return handle;
+	}
+	spin_lock(&DRM(mem_lock));
+	++DRM(mem_stats)[DRM_MEM_TOTALAGP].fail_count;
+	spin_unlock(&DRM(mem_lock));
+	return NULL;
+}
+
+int DRM(free_agp)(agp_memory *handle, int pages)
+{
+	int           alloc_count;
+	int           free_count;
+	int           retval = -EINVAL;
+
+	if (!handle) {
+		DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
+			      "Attempt to free NULL AGP handle\n");
+		return retval;;
+	}
+
+	if (DRM(agp_free_memory)(handle)) {
+		spin_lock(&DRM(mem_lock));
+		free_count  = ++DRM(mem_stats)[DRM_MEM_TOTALAGP].free_count;
+		alloc_count =   DRM(mem_stats)[DRM_MEM_TOTALAGP].succeed_count;
+		DRM(mem_stats)[DRM_MEM_TOTALAGP].bytes_freed
+			+= pages << PAGE_SHIFT;
+		spin_unlock(&DRM(mem_lock));
+		if (free_count > alloc_count) {
+			DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
+				      "Excess frees: %d frees, %d allocs\n",
+				      free_count, alloc_count);
+		}
+		return 0;
+	}
+	return retval;
+}
+
+int DRM(bind_agp)(agp_memory *handle, unsigned int start)
+{
+	int retcode = -EINVAL;
+
+	if (!handle) {
+		DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
+			      "Attempt to bind NULL AGP handle\n");
+		return retcode;
+	}
+
+	if (!(retcode = DRM(agp_bind_memory)(handle, start))) {
+		spin_lock(&DRM(mem_lock));
+		++DRM(mem_stats)[DRM_MEM_BOUNDAGP].succeed_count;
+		DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_allocated
+			+= handle->page_count << PAGE_SHIFT;
+		spin_unlock(&DRM(mem_lock));
+		return retcode;
+	}
+	spin_lock(&DRM(mem_lock));
+	++DRM(mem_stats)[DRM_MEM_BOUNDAGP].fail_count;
+	spin_unlock(&DRM(mem_lock));
+	return retcode;
+}
+
+int DRM(unbind_agp)(agp_memory *handle)
+{
+	int alloc_count;
+	int free_count;
+	int retcode = -EINVAL;
+
+	if (!handle) {
+		DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
+			      "Attempt to unbind NULL AGP handle\n");
+		return retcode;
+	}
+
+	if ((retcode = DRM(agp_unbind_memory)(handle))) return retcode;
+	spin_lock(&DRM(mem_lock));
+	free_count  = ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].free_count;
+	alloc_count = DRM(mem_stats)[DRM_MEM_BOUNDAGP].succeed_count;
+	DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_freed
+		+= handle->page_count << PAGE_SHIFT;
+	spin_unlock(&DRM(mem_lock));
+	if (free_count > alloc_count) {
+		DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
+			      "Excess frees: %d frees, %d allocs\n",
+			      free_count, alloc_count);
+	}
+	return retcode;
+}
+#endif
diff -Nru a/drivers/char/drm/drm_os_linux.h b/drivers/char/drm/drm_os_linux.h
--- a/drivers/char/drm/drm_os_linux.h	Wed Apr 30 22:28:17 2003
+++ b/drivers/char/drm/drm_os_linux.h	Wed Apr 30 22:28:17 2003
@@ -11,8 +11,9 @@
 #define DRM_READ32(map, offset)		readl(((unsigned long)(map)->handle) + (offset))
 #define DRM_WRITE8(map, offset, val)	writeb(val, ((unsigned long)(map)->handle) + (offset))
 #define DRM_WRITE32(map, offset, val)	writel(val, ((unsigned long)(map)->handle) + (offset))
-#define DRM_READMEMORYBARRIER(map)	mb()
-#define DRM_WRITEMEMORYBARRIER(map)	wmb()
+#define DRM_READMEMORYBARRIER()		rmb()
+#define DRM_WRITEMEMORYBARRIER()	wmb()
+#define DRM_MEMORYBARRIER()		mb()
 #define DRM_DEVICE	drm_file_t	*priv	= filp->private_data; \
 			drm_device_t	*dev	= priv->dev
 
diff -Nru a/drivers/char/drm/drm_proc.h b/drivers/char/drm/drm_proc.h
--- a/drivers/char/drm/drm_proc.h	Wed Apr 30 22:28:04 2003
+++ b/drivers/char/drm/drm_proc.h	Wed Apr 30 22:28:04 2003
@@ -49,10 +49,6 @@
 static int	   DRM(vma_info)(char *buf, char **start, off_t offset,
 				 int request, int *eof, void *data);
 #endif
-#if __HAVE_DMA_HISTOGRAM
-static int	   DRM(histo_info)(char *buf, char **start, off_t offset,
-				   int request, int *eof, void *data);
-#endif
 
 struct drm_proc_list {
 	const char *name;
@@ -67,9 +63,6 @@
 #if DRM_DEBUG_CODE
 	{ "vma",     DRM(vma_info)     },
 #endif
-#if __HAVE_DMA_HISTOGRAM
-	{ "histo",   DRM(histo_info)   },
-#endif
 };
 #define DRM_PROC_ENTRIES (sizeof(DRM(proc_list))/sizeof(DRM(proc_list)[0]))
 
@@ -444,31 +437,6 @@
 			       pgprot & _PAGE_GLOBAL   ? 'g' : 'l' );
 #endif
 		DRM_PROC_PRINT("\n");
-#if 0
-		for (i = vma->vm_start; i < vma->vm_end; i += PAGE_SIZE) {
-			pgd = pgd_offset(vma->vm_mm, i);
-			pmd = pmd_offset(pgd, i);
-			preempt_disable();
-			pte = pte_offset_map(pmd, i);
-			if (pte_present(*pte)) {
-				address = __pa(pte_page(*pte))
-					+ (i & (PAGE_SIZE-1));
-				DRM_PROC_PRINT("      0x%08lx -> 0x%08lx"
-					       " %c%c%c%c%c\n",
-					       i,
-					       address,
-					       pte_read(*pte)  ? 'r' : '-',
-					       pte_write(*pte) ? 'w' : '-',
-					       pte_exec(*pte)  ? 'x' : '-',
-					       pte_dirty(*pte) ? 'd' : '-',
-					       pte_young(*pte) ? 'a' : '-' );
-			} else {
-				DRM_PROC_PRINT("      0x%08lx\n", i);
-			}
-			pte_unmap(pte);
-			preempt_enable();
-		}
-#endif
 	}
 
 	if (len > request + offset) return request;
@@ -490,143 +458,3 @@
 #endif
 
 
-#if __HAVE_DMA_HISTOGRAM
-static int DRM(_histo_info)(char *buf, char **start, off_t offset, int request,
-			    int *eof, void *data)
-{
-	drm_device_t	 *dev = (drm_device_t *)data;
-	int              len  = 0;
-	drm_device_dma_t *dma = dev->dma;
-	int		 i;
-	unsigned long	 slot_value = DRM_DMA_HISTOGRAM_INITIAL;
-	unsigned long	 prev_value = 0;
-	drm_buf_t	 *buffer;
-
-	if (offset > DRM_PROC_LIMIT) {
-		*eof = 1;
-		return 0;
-	}
-
-	*start = &buf[offset];
-	*eof   = 0;
-
-	DRM_PROC_PRINT("general statistics:\n");
-	DRM_PROC_PRINT("total	 %10u\n", atomic_read(&dev->histo.total));
-	DRM_PROC_PRINT("open	 %10u\n",
-		       atomic_read(&dev->counts[_DRM_STAT_OPENS]));
-	DRM_PROC_PRINT("close	 %10u\n",
-		       atomic_read(&dev->counts[_DRM_STAT_CLOSES]));
-	DRM_PROC_PRINT("ioctl	 %10u\n",
-		       atomic_read(&dev->counts[_DRM_STAT_IOCTLS]));
-
-	DRM_PROC_PRINT("\nlock statistics:\n");
-	DRM_PROC_PRINT("locks	 %10u\n",
-		       atomic_read(&dev->counts[_DRM_STAT_LOCKS]));
-	DRM_PROC_PRINT("unlocks	 %10u\n",
-		       atomic_read(&dev->counts[_DRM_STAT_UNLOCKS]));
-
-	if (dma) {
-#if 0
-		DRM_PROC_PRINT("\ndma statistics:\n");
-		DRM_PROC_PRINT("prio	 %10u\n",
-			       atomic_read(&dma->total_prio));
-		DRM_PROC_PRINT("bytes	 %10u\n",
-			       atomic_read(&dma->total_bytes));
-		DRM_PROC_PRINT("dmas	 %10u\n",
-			       atomic_read(&dma->total_dmas));
-		DRM_PROC_PRINT("missed:\n");
-		DRM_PROC_PRINT("  dma	 %10u\n",
-			       atomic_read(&dma->total_missed_dma));
-		DRM_PROC_PRINT("  lock	 %10u\n",
-			       atomic_read(&dma->total_missed_lock));
-		DRM_PROC_PRINT("  free	 %10u\n",
-			       atomic_read(&dma->total_missed_free));
-		DRM_PROC_PRINT("  sched	 %10u\n",
-			       atomic_read(&dma->total_missed_sched));
-		DRM_PROC_PRINT("tried	 %10u\n",
-			       atomic_read(&dma->total_tried));
-		DRM_PROC_PRINT("hit	 %10u\n",
-			       atomic_read(&dma->total_hit));
-		DRM_PROC_PRINT("lost	 %10u\n",
-			       atomic_read(&dma->total_lost));
-#endif
-
-		buffer = dma->next_buffer;
-		if (buffer) {
-			DRM_PROC_PRINT("next_buffer %7d\n", buffer->idx);
-		} else {
-			DRM_PROC_PRINT("next_buffer    none\n");
-		}
-		buffer = dma->this_buffer;
-		if (buffer) {
-			DRM_PROC_PRINT("this_buffer %7d\n", buffer->idx);
-		} else {
-			DRM_PROC_PRINT("this_buffer    none\n");
-		}
-	}
-
-
-	DRM_PROC_PRINT("\nvalues:\n");
-	if (dev->lock.hw_lock) {
-		DRM_PROC_PRINT("lock	       0x%08x\n",
-			       dev->lock.hw_lock->lock);
-	} else {
-		DRM_PROC_PRINT("lock		     none\n");
-	}
-	DRM_PROC_PRINT("context_flag   0x%08lx\n", dev->context_flag);
-	DRM_PROC_PRINT("interrupt_flag 0x%08lx\n", dev->interrupt_flag);
-	DRM_PROC_PRINT("dma_flag       0x%08lx\n", dev->dma_flag);
-
-	DRM_PROC_PRINT("queue_count    %10d\n",	 dev->queue_count);
-	DRM_PROC_PRINT("last_context   %10d\n",	 dev->last_context);
-	DRM_PROC_PRINT("last_switch    %10lu\n", dev->last_switch);
-	DRM_PROC_PRINT("last_checked   %10d\n",	 dev->last_checked);
-
-
-	DRM_PROC_PRINT("\n		       q2d	  d2c	     c2f"
-		       "	q2c	   q2f	      dma	 sch"
-		       "	ctx	  lacq	     lhld\n\n");
-	for (i = 0; i < DRM_DMA_HISTOGRAM_SLOTS; i++) {
-		DRM_PROC_PRINT("%s %10lu %10u %10u %10u %10u %10u"
-			       " %10u %10u %10u %10u %10u\n",
-			       i == DRM_DMA_HISTOGRAM_SLOTS - 1 ? ">=" : "< ",
-			       i == DRM_DMA_HISTOGRAM_SLOTS - 1
-			       ? prev_value : slot_value ,
-
-			       atomic_read(&dev->histo
-					   .queued_to_dispatched[i]),
-			       atomic_read(&dev->histo
-					   .dispatched_to_completed[i]),
-			       atomic_read(&dev->histo
-					   .completed_to_freed[i]),
-
-			       atomic_read(&dev->histo
-					   .queued_to_completed[i]),
-			       atomic_read(&dev->histo
-					   .queued_to_freed[i]),
-			       atomic_read(&dev->histo.dma[i]),
-			       atomic_read(&dev->histo.schedule[i]),
-			       atomic_read(&dev->histo.ctx[i]),
-			       atomic_read(&dev->histo.lacq[i]),
-			       atomic_read(&dev->histo.lhld[i]));
-		prev_value = slot_value;
-		slot_value = DRM_DMA_HISTOGRAM_NEXT(slot_value);
-	}
-
-	if (len > request + offset) return request;
-	*eof = 1;
-	return len - offset;
-}
-
-static int DRM(histo_info)(char *buf, char **start, off_t offset, int request,
-			   int *eof, void *data)
-{
-	drm_device_t *dev = (drm_device_t *)data;
-	int	     ret;
-
-	down(&dev->struct_sem);
-	ret = DRM(_histo_info)(buf, start, offset, request, eof, data);
-	up(&dev->struct_sem);
-	return ret;
-}
-#endif
diff -Nru a/drivers/char/drm/gamma.h b/drivers/char/drm/gamma.h
--- a/drivers/char/drm/gamma.h	Wed Apr 30 22:28:03 2003
+++ b/drivers/char/drm/gamma.h	Wed Apr 30 22:28:03 2003
@@ -63,6 +63,12 @@
 #define __HAVE_COUNTER9		_DRM_STAT_SPECIAL
 #define __HAVE_COUNTER10	_DRM_STAT_MISSED
 
+/* Driver customization:
+ */
+#define DRIVER_PRETAKEDOWN() do {					\
+	gamma_do_cleanup_dma( dev );					\
+} while (0)
+
 /* DMA customization:
  */
 #define __HAVE_DMA			1
@@ -71,6 +77,9 @@
 #define __HAVE_OLD_DMA			1
 #define __HAVE_PCI_DMA			1
 
+#define __HAVE_DRIVER_FOPS_READ		1
+#define __HAVE_DRIVER_FOPS_POLL		1
+
 #define __HAVE_MULTIPLE_DMA_QUEUES	1
 #define __HAVE_DMA_WAITQUEUE		1
 
@@ -87,62 +96,19 @@
 
 #define __HAVE_DMA_QUIESCENT		1
 #define DRIVER_DMA_QUIESCENT() do {					\
-	/* FIXME ! */ 							\
-	gamma_dma_quiescent_single(dev);					\
+	drm_gamma_private_t *dev_priv =					\
+		(drm_gamma_private_t *)dev->dev_private;		\
+	if (dev_priv->num_rast == 2)					\
+		gamma_dma_quiescent_dual(dev);				\
+	else 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;\
-	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	Wed Apr 30 22:28:17 2003
+++ b/drivers/char/drm/gamma_dma.c	Wed Apr 30 22:28:17 2003
@@ -139,15 +139,9 @@
 	drm_buf_t	 *buf;
 	int		 retcode = 0;
 	drm_device_dma_t *dma = dev->dma;
-#if DRM_DMA_HISTOGRAM
-	cycles_t	 dma_start, dma_stop;
-#endif
 
 	if (test_and_set_bit(0, &dev->dma_flag)) return -EBUSY;
 
-#if DRM_DMA_HISTOGRAM
-	dma_start = get_cycles();
-#endif
 
 	if (!dma->next_buffer) {
 		DRM_ERROR("No next_buffer\n");
@@ -221,9 +215,6 @@
 	buf->pending	 = 1;
 	buf->waiting	 = 0;
 	buf->list	 = DRM_LIST_PEND;
-#if DRM_DMA_HISTOGRAM
-	buf->time_dispatched = get_cycles();
-#endif
 
 	/* WE NOW ARE ON LOGICAL PAGES!!! - overriding address */
 	address = buf->idx << 12;
@@ -245,10 +236,6 @@
 
 	clear_bit(0, &dev->dma_flag);
 
-#if DRM_DMA_HISTOGRAM
-	dma_stop = get_cycles();
-	atomic_inc(&dev->histo.dma[gamma_histogram_slot(dma_stop - dma_start)]);
-#endif
 
 	return retcode;
 }
@@ -273,9 +260,6 @@
 	int		 missed;
 	int		 expire	   = 20;
 	drm_device_dma_t *dma	   = dev->dma;
-#if DRM_DMA_HISTOGRAM
-	cycles_t	 schedule_start;
-#endif
 
 	if (test_and_set_bit(0, &dev->interrupt_flag)) {
 				/* Not reentrant */
@@ -284,9 +268,6 @@
 	}
 	missed = atomic_read(&dev->counts[10]);
 
-#if DRM_DMA_HISTOGRAM
-	schedule_start = get_cycles();
-#endif
 
 again:
 	if (dev->context_flag) {
@@ -333,10 +314,6 @@
 
 	clear_bit(0, &dev->interrupt_flag);
 
-#if DRM_DMA_HISTOGRAM
-	atomic_inc(&dev->histo.schedule[gamma_histogram_slot(get_cycles()
-							   - schedule_start)]);
-#endif
 	return retcode;
 }
 
@@ -448,10 +425,6 @@
 			}
 		}
 
-#if DRM_DMA_HISTOGRAM
-		buf->time_queued     = get_cycles();
-		buf->time_dispatched = buf->time_queued;
-#endif
 		gamma_dma_dispatch(dev, address, length);
 		atomic_inc(&dev->counts[9]); /* _DRM_STAT_SPECIAL */
 		atomic_add(length, &dev->counts[8]); /* _DRM_STAT_PRIMARY */
@@ -604,6 +577,8 @@
 
 	memset( dev_priv, 0, sizeof(drm_gamma_private_t) );
 
+	dev_priv->num_rast = init->num_rast;
+
 	list_for_each(list, &dev->maplist->head) {
 		drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head);
 		if( r_list->map &&
@@ -664,10 +639,19 @@
 {
 	DRM_DEBUG( "%s\n", __FUNCTION__ );
 
+#if _HAVE_DMA_IRQ
+	/* Make sure interrupts are disabled here because the uninstall ioctl
+	 * may not have been called from userspace and after dev_private
+	 * is freed, it's too late.
+	 */
+	if ( dev->irq ) DRM(irq_uninstall)(dev);
+#endif
+
 	if ( dev->dev_private ) {
 		drm_gamma_private_t *dev_priv = dev->dev_private;
 
-		DRM_IOREMAPFREE( dev_priv->buffers );
+		if ( dev_priv->buffers != NULL )
+			DRM_IOREMAPFREE( dev_priv->buffers );
 
 		DRM(free)( dev->dev_private, sizeof(drm_gamma_private_t),
 			   DRM_MEM_DRIVER );
@@ -684,6 +668,8 @@
 	drm_device_t *dev = priv->dev;
 	drm_gamma_init_t init;
 
+	LOCK_TEST_WITH_RETURN( dev, filp );
+
 	if ( copy_from_user( &init, (drm_gamma_init_t *)arg, sizeof(init) ) )
 		return -EFAULT;
 
@@ -830,4 +816,38 @@
 	dev->context_sareas[request.ctx_id] = map;
 	up(&dev->struct_sem);
 	return 0;
+}
+
+void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
+	drm_gamma_private_t *dev_priv =
+				(drm_gamma_private_t *)dev->dev_private;
+
+	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 2);
+
+	GAMMA_WRITE( GAMMA_GCOMMANDMODE,	0x00000004 );
+	GAMMA_WRITE( GAMMA_GDMACONTROL,		0x00000000 );
+}
+
+void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
+	drm_gamma_private_t *dev_priv =
+				(drm_gamma_private_t *)dev->dev_private;
+
+	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 3);
+
+	GAMMA_WRITE( GAMMA_GINTENABLE,		0x00002001 );
+	GAMMA_WRITE( GAMMA_COMMANDINTENABLE,	0x00000008 );
+	GAMMA_WRITE( GAMMA_GDELAYTIMER,		0x00039090 );
+}
+
+void DRM(driver_irq_uninstall)( drm_device_t *dev ) {
+	drm_gamma_private_t *dev_priv =
+				(drm_gamma_private_t *)dev->dev_private;
+	if (!dev_priv)
+		return;
+
+	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 3);
+
+	GAMMA_WRITE( GAMMA_GDELAYTIMER,		0x00000000 );
+	GAMMA_WRITE( GAMMA_COMMANDINTENABLE,	0x00000000 );
+	GAMMA_WRITE( GAMMA_GINTENABLE,		0x00000000 );
 }
diff -Nru a/drivers/char/drm/gamma_drm.h b/drivers/char/drm/gamma_drm.h
--- a/drivers/char/drm/gamma_drm.h	Wed Apr 30 22:28:17 2003
+++ b/drivers/char/drm/gamma_drm.h	Wed Apr 30 22:28:17 2003
@@ -84,6 +84,7 @@
 	unsigned int mmio2;
 	unsigned int mmio3;
 	unsigned int buffers_offset;
+	int num_rast;
 } 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	Wed Apr 30 22:28:16 2003
+++ b/drivers/char/drm/gamma_drv.c	Wed Apr 30 22:28:16 2003
@@ -39,16 +39,18 @@
 #include "drm_auth.h"
 #include "drm_agpsupport.h"
 #include "drm_bufs.h"
-#include "drm_context.h"
+#include "gamma_context.h"	/* NOTE! */
 #include "drm_dma.h"
+#include "gamma_old_dma.h"	/* NOTE */
 #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 "gamma_lists.h"        /* NOTE */
 #include "drm_lock.h"
+#include "gamma_lock.h"		/* NOTE */
 #include "drm_memory.h"
 #include "drm_proc.h"
 #include "drm_vm.h"
diff -Nru a/drivers/char/drm/gamma_drv.h b/drivers/char/drm/gamma_drv.h
--- a/drivers/char/drm/gamma_drv.h	Wed Apr 30 22:28:08 2003
+++ b/drivers/char/drm/gamma_drv.h	Wed Apr 30 22:28:08 2003
@@ -40,6 +40,7 @@
 	drm_map_t *mmio1;
 	drm_map_t *mmio2;
 	drm_map_t *mmio3;
+	int num_rast;
 } drm_gamma_private_t;
 
 				/* gamma_dma.c */
@@ -48,6 +49,7 @@
 extern int gamma_dma_copy( struct inode *inode, struct file *filp,
 			 unsigned int cmd, unsigned long arg );
 
+extern int gamma_do_cleanup_dma( drm_device_t *dev );
 extern void gamma_dma_ready(drm_device_t *dev);
 extern void gamma_dma_quiescent_single(drm_device_t *dev);
 extern void gamma_dma_quiescent_dual(drm_device_t *dev);
@@ -58,6 +60,38 @@
 		      unsigned int cmd, unsigned long arg);
 extern int  gamma_find_devices(void);
 extern int  gamma_found(void);
+
+/* Gamma-specific code pulled from drm_fops.h:
+ */
+extern int	     DRM(finish)(struct inode *inode, struct file *filp,
+				 unsigned int cmd, unsigned long arg);
+extern int	     DRM(flush_unblock)(drm_device_t *dev, int context,
+					drm_lock_flags_t flags);
+extern int	     DRM(flush_block_and_flush)(drm_device_t *dev, int context,
+						drm_lock_flags_t flags);
+
+/* Gamma-specific code pulled from drm_dma.h:
+ */
+extern void	     DRM(clear_next_buffer)(drm_device_t *dev);
+extern int	     DRM(select_queue)(drm_device_t *dev,
+				       void (*wrapper)(unsigned long));
+extern int	     DRM(dma_enqueue)(struct file *filp, drm_dma_t *dma);
+extern int	     DRM(dma_get_buffers)(struct file *filp, drm_dma_t *dma);
+
+
+/* Gamma-specific code pulled from drm_lists.h (now renamed gamma_lists.h):
+ */
+extern int	     DRM(waitlist_create)(drm_waitlist_t *bl, int count);
+extern int	     DRM(waitlist_destroy)(drm_waitlist_t *bl);
+extern int	     DRM(waitlist_put)(drm_waitlist_t *bl, drm_buf_t *buf);
+extern drm_buf_t     *DRM(waitlist_get)(drm_waitlist_t *bl);
+extern int	     DRM(freelist_create)(drm_freelist_t *bl, int count);
+extern int	     DRM(freelist_destroy)(drm_freelist_t *bl);
+extern int	     DRM(freelist_put)(drm_device_t *dev, drm_freelist_t *bl,
+				       drm_buf_t *buf);
+extern drm_buf_t     *DRM(freelist_get)(drm_freelist_t *bl, int block);
+
+
 
 #define GLINT_DRI_BUF_COUNT 256
 
diff -Nru a/drivers/char/drm/i810.h b/drivers/char/drm/i810.h
--- a/drivers/char/drm/i810.h	Wed Apr 30 22:28:07 2003
+++ b/drivers/char/drm/i810.h	Wed Apr 30 22:28:07 2003
@@ -86,14 +86,18 @@
  */
 #define __HAVE_RELEASE		1
 #define DRIVER_RELEASE() do {						\
-	i810_reclaim_buffers( filp );				\
+	i810_reclaim_buffers( filp );					\
+} while (0)
+
+#define DRIVER_PRETAKEDOWN() do {					\
+	i810_dma_cleanup( dev );					\
 } while (0)
 
 /* DMA customization:
  */
 #define __HAVE_DMA		1
 #define __HAVE_DMA_QUEUE	1
-#define __HAVE_DMA_WAITLIST	1
+#define __HAVE_DMA_WAITLIST	0
 #define __HAVE_DMA_RECLAIM	1
 
 #define __HAVE_DMA_QUIESCENT	1
@@ -104,6 +108,7 @@
 /* Don't need an irq any more.  The template code will make sure that
  * a noop stub is generated for compatibility.
  */
+/* XXX: Add vblank support? */
 #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	Wed Apr 30 22:28:07 2003
+++ b/drivers/char/drm/i810_dma.c	Wed Apr 30 22:28:07 2003
@@ -55,7 +55,7 @@
 {
    	drm_device_dma_t *dma = dev->dma;
       	drm_i810_private_t *dev_priv = dev->dev_private;
-	u32 *temp = (u32 *)dev_priv->hw_status_page;
+	u32 *temp = dev_priv->hw_status_page;
    	int i;
 
    	DRM_DEBUG(  "hw_status: Interrupt Status : %x\n", temp[0]);
@@ -115,9 +115,7 @@
 	.release = DRM(release),
 	.ioctl	 = DRM(ioctl),
 	.mmap	 = i810_mmap_buffers,
-	.read	 = DRM(read),
 	.fasync  = DRM(fasync),
-      	.poll	 = DRM(poll),
 };
 
 int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
@@ -229,11 +227,19 @@
 	return retcode;
 }
 
-static int i810_dma_cleanup(drm_device_t *dev)
+int i810_dma_cleanup(drm_device_t *dev)
 {
 	drm_device_dma_t *dma = dev->dma;
 
-	if(dev->dev_private) {
+#if _HAVE_DMA_IRQ
+	/* Make sure interrupts are disabled here because the uninstall ioctl
+	 * may not have been called from userspace and after dev_private
+	 * is freed, it's too late.
+	 */
+	if (dev->irq) DRM(irq_uninstall)(dev);
+#endif
+
+	if (dev->dev_private) {
 		int i;
 	   	drm_i810_private_t *dev_priv =
 	     		(drm_i810_private_t *) dev->dev_private;
@@ -242,9 +248,9 @@
 		   	DRM(ioremapfree)((void *) dev_priv->ring.virtual_start,
 					 dev_priv->ring.Size);
 		}
-	   	if(dev_priv->hw_status_page != 0UL) {
+	   	if (dev_priv->hw_status_page) {
 		   	pci_free_consistent(dev->pdev, PAGE_SIZE,
-					    (void *)dev_priv->hw_status_page,
+					    dev_priv->hw_status_page,
 					    dev_priv->dma_status_page);
 		   	/* Need to rewrite hardware status page */
 		   	I810_WRITE(0x02080, 0x1ffff000);
@@ -256,7 +262,8 @@
 		for (i = 0; i < dma->buf_count; i++) {
 			drm_buf_t *buf = dma->buflist[ i ];
 			drm_i810_buf_priv_t *buf_priv = buf->dev_private;
-			DRM(ioremapfree)(buf_priv->kernel_virtual, buf->total);
+			if ( buf_priv->kernel_virtual && buf->total )
+				DRM(ioremapfree)(buf_priv->kernel_virtual, buf->total);
 		}
 	}
    	return 0;
@@ -406,16 +413,16 @@
 
    	/* Program Hardware Status Page */
    	dev_priv->hw_status_page =
-		(unsigned long) pci_alloc_consistent(dev->pdev, PAGE_SIZE,
+		pci_alloc_consistent(dev->pdev, PAGE_SIZE,
 						&dev_priv->dma_status_page);
-   	if(dev_priv->hw_status_page == 0UL) {
+   	if (!dev_priv->hw_status_page) {
 		dev->dev_private = (void *)dev_priv;
 		i810_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);
+   	memset(dev_priv->hw_status_page, 0, PAGE_SIZE);
+   	DRM_DEBUG("hw status page @ %p\n", dev_priv->hw_status_page);
 
 	I810_WRITE(0x02080, dev_priv->dma_status_page);
    	DRM_DEBUG("Enabled hardware status page\n");
@@ -900,7 +907,7 @@
 	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;
+      	u32 *hw_status = dev_priv->hw_status_page;
    	drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
      					dev_priv->sarea_priv;
 	drm_i810_vertex_t vertex;
@@ -976,7 +983,7 @@
    	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;
-      	u32 *hw_status = (u32 *)dev_priv->hw_status_page;
+      	u32 *hw_status = dev_priv->hw_status_page;
    	drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
      					dev_priv->sarea_priv;
 
@@ -992,7 +999,7 @@
 	int		  retcode   = 0;
 	drm_i810_dma_t	  d;
    	drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
-   	u32 *hw_status = (u32 *)dev_priv->hw_status_page;
+   	u32 *hw_status = dev_priv->hw_status_page;
    	drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
      					dev_priv->sarea_priv;
 
@@ -1101,7 +1108,7 @@
 	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;
+	u32 *hw_status = dev_priv->hw_status_page;
 	drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
 		dev_priv->sarea_priv;
 	drm_i810_mc_t mc;
diff -Nru a/drivers/char/drm/i810_drv.c b/drivers/char/drm/i810_drv.c
--- a/drivers/char/drm/i810_drv.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/char/drm/i810_drv.c	Wed Apr 30 22:28:18 2003
@@ -49,7 +49,6 @@
 #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"
diff -Nru a/drivers/char/drm/i810_drv.h b/drivers/char/drm/i810_drv.h
--- a/drivers/char/drm/i810_drv.h	Wed Apr 30 22:28:17 2003
+++ b/drivers/char/drm/i810_drv.h	Wed Apr 30 22:28:17 2003
@@ -38,8 +38,6 @@
 	int currently_mapped;
 	void *virtual;
 	void *kernel_virtual;
-	int map_count;
-   	struct vm_area_struct *vma;
 } drm_i810_buf_priv_t;
 
 typedef struct _drm_i810_ring_buffer{
@@ -61,7 +59,7 @@
 	drm_i810_sarea_t *sarea_priv;
    	drm_i810_ring_buffer_t ring;
 
-      	unsigned long hw_status_page;
+      	void *hw_status_page;
    	unsigned long counter;
 
 	dma_addr_t dma_status_page;
@@ -86,6 +84,7 @@
 			unsigned int cmd, unsigned long arg);
 extern int  i810_dma_init(struct inode *inode, struct file *filp,
 			  unsigned int cmd, unsigned long arg);
+extern int  i810_dma_cleanup(drm_device_t *dev);
 extern int  i810_flush_ioctl(struct inode *inode, struct file *filp,
 			     unsigned int cmd, unsigned long arg);
 extern void i810_reclaim_buffers(struct file *filp);
diff -Nru a/drivers/char/drm/i830.h b/drivers/char/drm/i830.h
--- a/drivers/char/drm/i830.h	Wed Apr 30 22:28:07 2003
+++ b/drivers/char/drm/i830.h	Wed Apr 30 22:28:07 2003
@@ -87,14 +87,18 @@
  */
 #define __HAVE_RELEASE		1
 #define DRIVER_RELEASE() do {						\
-	i830_reclaim_buffers( filp );				\
+	i830_reclaim_buffers( filp );					\
+} while (0)
+
+#define DRIVER_PRETAKEDOWN() do {					\
+	i830_dma_cleanup( dev );					\
 } while (0)
 
 /* DMA customization:
  */
 #define __HAVE_DMA		1
 #define __HAVE_DMA_QUEUE	1
-#define __HAVE_DMA_WAITLIST	1
+#define __HAVE_DMA_WAITLIST	0
 #define __HAVE_DMA_RECLAIM	1
 
 #define __HAVE_DMA_QUIESCENT	1
@@ -107,43 +111,15 @@
  * the card, but are subject to subtle interactions between bios,
  * hardware and the driver.
  */
+/* XXX: Add vblank support? */
 #define USE_IRQS 0
 
-
 #if USE_IRQS
 #define __HAVE_DMA_IRQ		1
 #define __HAVE_SHARED_IRQ	1
-
-#define DRIVER_PREINSTALL() do {			\
-	drm_i830_private_t *dev_priv =			\
-		(drm_i830_private_t *)dev->dev_private;	\
-							\
-   	I830_WRITE16( I830REG_HWSTAM, 0xffff );	\
-        I830_WRITE16( I830REG_INT_MASK_R, 0x0 );	\
-      	I830_WRITE16( I830REG_INT_ENABLE_R, 0x0 );	\
-} while (0)
-
-
-#define DRIVER_POSTINSTALL() do {				\
-	drm_i830_private_t *dev_priv =				\
-		(drm_i830_private_t *)dev->dev_private;		\
-   	I830_WRITE16( I830REG_INT_ENABLE_R, 0x2 );		\
-   	atomic_set(&dev_priv->irq_received, 0);			\
-   	atomic_set(&dev_priv->irq_emitted, 0);			\
-	init_waitqueue_head(&dev_priv->irq_queue);		\
-} while (0)
-
-
-/* This gets called too late to be useful: dev_priv has already been
- * freed.
- */
-#define DRIVER_UNINSTALL() do {					\
-} while (0)
-
 #else
 #define __HAVE_DMA_IRQ          0
 #endif
-
 
 
 /* Buffer customization:
diff -Nru a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c
--- a/drivers/char/drm/i830_dma.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/char/drm/i830_dma.c	Wed Apr 30 22:28:04 2003
@@ -52,19 +52,11 @@
 #define up_write up
 #endif
 
-#ifndef LockPage
-#define LockPage(page)		set_bit(PG_locked, &(page)->flags)
-#endif
-#ifndef UnlockPage
-#define UnlockPage(page)	unlock_page(page)
-#endif
-
-
 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;
+	u32 *temp = dev_priv->hw_status_page;
    	int i;
 
    	DRM_DEBUG(  "hw_status: Interrupt Status : %x\n", temp[0]);
@@ -123,9 +115,7 @@
 	.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)
@@ -176,10 +166,10 @@
 					    buf->bus_address);
 	dev_priv->mmap_buffer = NULL;
 	filp->f_op = old_fops;
-	if ((unsigned long)buf_priv->virtual > -1024UL) {
+	if (IS_ERR(buf_priv->virtual)) {
 		/* Real error */
 		DRM_ERROR("mmap error\n");
-		retcode = (signed int)buf_priv->virtual;
+		retcode = PTR_ERR(buf_priv->virtual);
 		buf_priv->virtual = 0;
 	}
 	up_write( &current->mm->mmap_sem );
@@ -237,35 +227,35 @@
 	return retcode;
 }
 
-static int i830_dma_cleanup(drm_device_t *dev)
+int i830_dma_cleanup(drm_device_t *dev)
 {
 	drm_device_dma_t *dma = dev->dma;
 
-	if(dev->dev_private) {
+#if _HAVE_DMA_IRQ
+	/* Make sure interrupts are disabled here because the uninstall ioctl
+	 * may not have been called from userspace and after dev_private
+	 * is freed, it's too late.
+	 */
+	if (dev->irq) DRM(irq_uninstall)(dev);
+#endif
+
+	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) {
+	   	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) {
+	   	if (dev_priv->hw_status_page) {
 			pci_free_consistent(dev->pdev, PAGE_SIZE,
-					    (void *)dev_priv->hw_status_page,
+					    dev_priv->hw_status_page,
 					    dev_priv->dma_status_page);
 		   	/* Need to rewrite hardware status page */
 		   	I830_WRITE(0x02080, 0x1ffff000);
 		}
 
-		/* Disable interrupts here because after dev_private
-		 * is freed, it's too late.
-		 */
-		if (dev->irq) {
-			I830_WRITE16( I830REG_INT_MASK_R, 0xffff );
-			I830_WRITE16( I830REG_INT_ENABLE_R, 0x0 );
-		}
-
 	   	DRM(free)(dev->dev_private, sizeof(drm_i830_private_t), 
 			 DRM_MEM_DRIVER);
 	   	dev->dev_private = NULL;
@@ -273,7 +263,8 @@
 		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);
+			if ( buf_priv->kernel_virtual && buf->total )
+				DRM(ioremapfree)(buf_priv->kernel_virtual, buf->total);
 		}
 	}
    	return 0;
@@ -443,18 +434,18 @@
 
    	/* Program Hardware Status Page */
    	dev_priv->hw_status_page =
-		(unsigned long) pci_alloc_consistent(dev->pdev, PAGE_SIZE,
+		pci_alloc_consistent(dev->pdev, PAGE_SIZE,
 						&dev_priv->dma_status_page);
-   	if(dev_priv->hw_status_page == 0UL) {
+   	if (!dev_priv->hw_status_page) {
 		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);
+   	memset(dev_priv->hw_status_page, 0, PAGE_SIZE);
+	DRM_DEBUG("hw status page @ %p\n", dev_priv->hw_status_page);
    
-   	I830_WRITE(0x02080, virt_to_bus((void *)dev_priv->hw_status_page));
+   	I830_WRITE(0x02080, dev_priv->dma_status_page);
 	DRM_DEBUG("Enabled hardware status page\n");
    
    	/* Now we need to init our freelist */
@@ -1344,7 +1335,7 @@
 	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;
+      	u32 *hw_status = dev_priv->hw_status_page;
    	drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) 
      					dev_priv->sarea_priv; 
 	drm_i830_vertex_t vertex;
@@ -1469,7 +1460,7 @@
    	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;
+      	u32 *hw_status = dev_priv->hw_status_page;
    	drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) 
      					dev_priv->sarea_priv; 
 
@@ -1485,7 +1476,7 @@
 	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;
+   	u32 *hw_status = dev_priv->hw_status_page;
    	drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) 
      					dev_priv->sarea_priv; 
 
diff -Nru a/drivers/char/drm/i830_drv.c b/drivers/char/drm/i830_drv.c
--- a/drivers/char/drm/i830_drv.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/char/drm/i830_drv.c	Wed Apr 30 22:28:07 2003
@@ -51,7 +51,6 @@
 #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"
diff -Nru a/drivers/char/drm/i830_drv.h b/drivers/char/drm/i830_drv.h
--- a/drivers/char/drm/i830_drv.h	Wed Apr 30 22:28:12 2003
+++ b/drivers/char/drm/i830_drv.h	Wed Apr 30 22:28:12 2003
@@ -38,8 +38,6 @@
 	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{
@@ -61,7 +59,7 @@
 	drm_i830_sarea_t *sarea_priv;
    	drm_i830_ring_buffer_t ring;
 
-      	unsigned long hw_status_page;
+      	void * hw_status_page;
    	unsigned long counter;
 
 	dma_addr_t dma_status_page;
@@ -99,6 +97,7 @@
 			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_dma_cleanup(drm_device_t *dev);
 extern int  i830_flush_ioctl(struct inode *inode, struct file *filp,
 			     unsigned int cmd, unsigned long arg);
 extern void i830_reclaim_buffers(struct file *filp);
diff -Nru a/drivers/char/drm/i830_irq.c b/drivers/char/drm/i830_irq.c
--- a/drivers/char/drm/i830_irq.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/char/drm/i830_irq.c	Wed Apr 30 22:28:14 2003
@@ -40,12 +40,12 @@
 	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);
-	printk("%s: %x\n", __FUNCTION__, temp);
-	
-   	if(temp == 0) 
-	   return;
+	DRM_DEBUG("%x\n", temp);
+
+   	if (temp == 0) 
+		return;
 
 	I830_WRITE16(I830REG_INT_IDENTITY_R, temp); 
 
@@ -175,3 +175,34 @@
 	return i830_wait_irq( dev, irqwait.irq_seq );
 }
 
+
+/* drm_dma.h hooks
+*/
+void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
+	drm_i830_private_t *dev_priv =
+		(drm_i830_private_t *)dev->dev_private;
+
+	I830_WRITE16( I830REG_HWSTAM, 0xffff );
+	I830_WRITE16( I830REG_INT_MASK_R, 0x0 );
+	I830_WRITE16( I830REG_INT_ENABLE_R, 0x0 );
+	atomic_set(&dev_priv->irq_received, 0);
+	atomic_set(&dev_priv->irq_emitted, 0);
+	init_waitqueue_head(&dev_priv->irq_queue);
+}
+
+void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
+	drm_i830_private_t *dev_priv =
+		(drm_i830_private_t *)dev->dev_private;
+
+	I830_WRITE16( I830REG_INT_ENABLE_R, 0x2 );
+}
+
+void DRM(driver_irq_uninstall)( drm_device_t *dev ) {
+	drm_i830_private_t *dev_priv =
+		(drm_i830_private_t *)dev->dev_private;
+	if (!dev_priv)
+		return;
+
+	I830_WRITE16( I830REG_INT_MASK_R, 0xffff );
+	I830_WRITE16( I830REG_INT_ENABLE_R, 0x0 );
+}
diff -Nru a/drivers/char/drm/mga.h b/drivers/char/drm/mga.h
--- a/drivers/char/drm/mga.h	Wed Apr 30 22:28:03 2003
+++ b/drivers/char/drm/mga.h	Wed Apr 30 22:28:03 2003
@@ -72,7 +72,7 @@
 /* Driver customization:
  */
 #define DRIVER_PRETAKEDOWN() do {					\
-	if ( dev->dev_private ) mga_do_cleanup_dma( dev );		\
+	mga_do_cleanup_dma( dev );					\
 } while (0)
 
 /* DMA customization:
diff -Nru a/drivers/char/drm/mga_dma.c b/drivers/char/drm/mga_dma.c
--- a/drivers/char/drm/mga_dma.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/char/drm/mga_dma.c	Wed Apr 30 22:28:16 2003
@@ -639,12 +639,23 @@
 {
 	DRM_DEBUG( "\n" );
 
+#if _HAVE_DMA_IRQ
+	/* Make sure interrupts are disabled here because the uninstall ioctl
+	 * may not have been called from userspace and after dev_private
+	 * is freed, it's too late.
+	 */
+	if ( dev->irq ) DRM(irq_uninstall)(dev);
+#endif
+
 	if ( dev->dev_private ) {
 		drm_mga_private_t *dev_priv = dev->dev_private;
 
-		DRM_IOREMAPFREE( dev_priv->warp );
-		DRM_IOREMAPFREE( dev_priv->primary );
-		DRM_IOREMAPFREE( dev_priv->buffers );
+		if ( dev_priv->warp != NULL )
+			DRM_IOREMAPFREE( dev_priv->warp );
+		if ( dev_priv->primary != NULL )
+			DRM_IOREMAPFREE( dev_priv->primary );
+		if ( dev_priv->buffers != NULL )
+			DRM_IOREMAPFREE( dev_priv->buffers );
 
 		if ( dev_priv->head != NULL ) {
 			mga_freelist_cleanup( dev );
@@ -662,6 +673,8 @@
 {
 	DRM_DEVICE;
 	drm_mga_init_t init;
+
+	LOCK_TEST_WITH_RETURN( dev, filp );
 
 	DRM_COPY_FROM_USER_IOCTL( init, (drm_mga_init_t *)data, sizeof(init) );
 
diff -Nru a/drivers/char/drm/mga_drv.h b/drivers/char/drm/mga_drv.h
--- a/drivers/char/drm/mga_drv.h	Wed Apr 30 22:28:16 2003
+++ b/drivers/char/drm/mga_drv.h	Wed Apr 30 22:28:16 2003
@@ -131,7 +131,7 @@
 extern int mga_warp_install_microcode( drm_mga_private_t *dev_priv );
 extern int mga_warp_init( drm_mga_private_t *dev_priv );
 
-#define mga_flush_write_combine()	DRM_WRITEMEMORYBARRIER(dev_priv->primary)
+#define mga_flush_write_combine()	DRM_WRITEMEMORYBARRIER()
 
 #if defined(__linux__) && defined(__alpha__)
 #define MGA_BASE( reg )		((unsigned long)(dev_priv->mmio->handle))
@@ -142,12 +142,12 @@
 
 #define MGA_READ( reg )		(_MGA_READ((u32 *)MGA_ADDR(reg)))
 #define MGA_READ8( reg )	(_MGA_READ((u8 *)MGA_ADDR(reg)))
-#define MGA_WRITE( reg, val )	do { DRM_WRITEMEMORYBARRIER(dev_priv->mmio); MGA_DEREF( reg ) = val; } while (0)
-#define MGA_WRITE8( reg, val )  do { DRM_WRITEMEMORYBARRIER(dev_priv->mmio); MGA_DEREF8( reg ) = val; } while (0)
+#define MGA_WRITE( reg, val )	do { DRM_WRITEMEMORYBARRIER(); MGA_DEREF( reg ) = val; } while (0)
+#define MGA_WRITE8( reg, val )  do { DRM_WRITEMEMORYBARRIER(); MGA_DEREF8( reg ) = val; } while (0)
 
 static inline u32 _MGA_READ(u32 *addr)
 {
-	DRM_READMEMORYBARRIER(dev_priv->mmio);
+	DRM_MEMORYBARRIER();
 	return *(volatile u32 *)addr;
 }
 #else
diff -Nru a/drivers/char/drm/mga_irq.c b/drivers/char/drm/mga_irq.c
--- a/drivers/char/drm/mga_irq.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/char/drm/mga_irq.c	Wed Apr 30 22:28:03 2003
@@ -36,7 +36,7 @@
 #include "mga_drm.h"
 #include "mga_drv.h"
 
-void mga_dma_service( DRM_IRQ_ARGS )
+irqreturn_t mga_dma_service( DRM_IRQ_ARGS )
 {
 	drm_device_t *dev = (drm_device_t *) arg;
 	drm_mga_private_t *dev_priv = 
@@ -51,7 +51,9 @@
 		atomic_inc(&dev->vbl_received);
 		DRM_WAKEUP(&dev->vbl_queue);
 		DRM(vbl_send_signals)( dev );
+		return IRQ_HANDLED;
 	}
+	return IRQ_NONE;
 }
 
 int mga_vblank_wait(drm_device_t *dev, unsigned int *sequence)
@@ -93,8 +95,9 @@
 void mga_driver_irq_uninstall( drm_device_t *dev ) {
   	drm_mga_private_t *dev_priv = 
 	   (drm_mga_private_t *)dev->dev_private;
-	if ( dev_priv ) {
-		/* Disable *all* interrupts */
-		MGA_WRITE( MGA_IEN, 0 );
-	}
+	if (!dev_priv)
+		return;
+
+	/* Disable *all* interrupts */
+	MGA_WRITE( MGA_IEN, 0 );
 }
diff -Nru a/drivers/char/drm/r128.h b/drivers/char/drm/r128.h
--- a/drivers/char/drm/r128.h	Wed Apr 30 22:28:07 2003
+++ b/drivers/char/drm/r128.h	Wed Apr 30 22:28:07 2003
@@ -85,7 +85,7 @@
 } while (0)
 
 #define DRIVER_PRETAKEDOWN() do {					\
-	if ( dev->dev_private ) r128_do_cleanup_cce( dev );		\
+	r128_do_cleanup_cce( dev );					\
 } while (0)
 
 /* DMA customization:
diff -Nru a/drivers/char/drm/r128_cce.c b/drivers/char/drm/r128_cce.c
--- a/drivers/char/drm/r128_cce.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/char/drm/r128_cce.c	Wed Apr 30 22:28:05 2003
@@ -613,15 +613,27 @@
 
 int r128_do_cleanup_cce( drm_device_t *dev )
 {
+
+#if _HAVE_DMA_IRQ
+	/* Make sure interrupts are disabled here because the uninstall ioctl
+	 * may not have been called from userspace and after dev_private
+	 * is freed, it's too late.
+	 */
+	if ( dev->irq ) DRM(irq_uninstall)(dev);
+#endif
+
 	if ( dev->dev_private ) {
 		drm_r128_private_t *dev_priv = dev->dev_private;
 
 #if __REALLY_HAVE_SG
 		if ( !dev_priv->is_pci ) {
 #endif
-			DRM_IOREMAPFREE( dev_priv->cce_ring );
-			DRM_IOREMAPFREE( dev_priv->ring_rptr );
-			DRM_IOREMAPFREE( dev_priv->buffers );
+			if ( dev_priv->cce_ring != NULL )
+				DRM_IOREMAPFREE( dev_priv->cce_ring );
+			if ( dev_priv->ring_rptr != NULL )
+				DRM_IOREMAPFREE( dev_priv->ring_rptr );
+			if ( dev_priv->buffers != NULL )
+				DRM_IOREMAPFREE( dev_priv->buffers );
 #if __REALLY_HAVE_SG
 		} else {
 			if (!DRM(ati_pcigart_cleanup)( dev,
@@ -645,6 +657,8 @@
 	drm_r128_init_t init;
 
 	DRM_DEBUG( "\n" );
+
+	LOCK_TEST_WITH_RETURN( dev, filp );
 
 	DRM_COPY_FROM_USER_IOCTL( init, (drm_r128_init_t *)data, sizeof(init) );
 
diff -Nru a/drivers/char/drm/r128_drv.h b/drivers/char/drm/r128_drv.h
--- a/drivers/char/drm/r128_drv.h	Wed Apr 30 22:28:20 2003
+++ b/drivers/char/drm/r128_drv.h	Wed Apr 30 22:28:20 2003
@@ -440,7 +440,7 @@
 #if defined(__powerpc__)
 #define r128_flush_write_combine()	(void) GET_RING_HEAD( &dev_priv->ring )
 #else
-#define r128_flush_write_combine()	DRM_WRITEMEMORYBARRIER(dev_priv->ring_rptr)
+#define r128_flush_write_combine()	DRM_WRITEMEMORYBARRIER()
 #endif
 
 
diff -Nru a/drivers/char/drm/r128_irq.c b/drivers/char/drm/r128_irq.c
--- a/drivers/char/drm/r128_irq.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/char/drm/r128_irq.c	Wed Apr 30 22:28:20 2003
@@ -36,7 +36,7 @@
 #include "r128_drm.h"
 #include "r128_drv.h"
 
-void r128_dma_service( DRM_IRQ_ARGS )
+irqreturn_t r128_dma_service( DRM_IRQ_ARGS )
 {
 	drm_device_t *dev = (drm_device_t *) arg;
 	drm_r128_private_t *dev_priv = 
@@ -51,7 +51,9 @@
 		atomic_inc(&dev->vbl_received);
 		DRM_WAKEUP(&dev->vbl_queue);
 		DRM(vbl_send_signals)( dev );
+		return IRQ_HANDLED;
 	}
+	return IRQ_NONE;
 }
 
 int DRM(vblank_wait)(drm_device_t *dev, unsigned int *sequence)
@@ -93,8 +95,9 @@
 void r128_driver_irq_uninstall( drm_device_t *dev ) {
   	drm_r128_private_t *dev_priv = 
 	   (drm_r128_private_t *)dev->dev_private;
-	if ( dev_priv ) {
-		/* Disable *all* interrupts */
-		R128_WRITE( R128_GEN_INT_CNTL, 0 );
-	}
+	if (!dev_priv)
+		return;
+
+	/* Disable *all* interrupts */
+	R128_WRITE( R128_GEN_INT_CNTL, 0 );
 }
diff -Nru a/drivers/char/drm/radeon.h b/drivers/char/drm/radeon.h
--- a/drivers/char/drm/radeon.h	Wed Apr 30 22:28:16 2003
+++ b/drivers/char/drm/radeon.h	Wed Apr 30 22:28:16 2003
@@ -78,6 +78,7 @@
  *       Added packets R200_EMIT_PP_CUBIC_FACES_[0..5] and
  *       R200_EMIT_PP_CUBIC_OFFSETS_[0..5].  (brian)
  * 1.8 - Remove need to call cleanup ioctls on last client exit (keith)
+ *       Add 'GET' queries for starting additional clients on different VT's.
  */
 #define DRIVER_IOCTLS							     \
  [DRM_IOCTL_NR(DRM_IOCTL_DMA)]               = { radeon_cp_buffers,  1, 0 }, \
diff -Nru a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c
--- a/drivers/char/drm/radeon_cp.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/char/drm/radeon_cp.c	Wed Apr 30 22:28:05 2003
@@ -36,12 +36,6 @@
 
 #define RADEON_FIFO_DEBUG	0
 
-#if defined(__alpha__) || defined(__powerpc__)
-# define PCIGART_ENABLED
-#else
-# undef PCIGART_ENABLED
-#endif
-
 
 /* CP microcode (from ATI) */
 static u32 R200_cp_microcode[][2] = {
@@ -777,7 +771,7 @@
 
 	cur_read_ptr = RADEON_READ( RADEON_CP_RB_RPTR );
 	RADEON_WRITE( RADEON_CP_RB_WPTR, cur_read_ptr );
-	*dev_priv->ring.head = cur_read_ptr;
+	SET_RING_HEAD( dev_priv, cur_read_ptr );
 	dev_priv->ring.tail = cur_read_ptr;
 }
 
@@ -889,13 +883,18 @@
 	/* Initialize the ring buffer's read and write pointers */
 	cur_read_ptr = RADEON_READ( RADEON_CP_RB_RPTR );
 	RADEON_WRITE( RADEON_CP_RB_WPTR, cur_read_ptr );
-	*dev_priv->ring.head = cur_read_ptr;
+	SET_RING_HEAD( dev_priv, cur_read_ptr );
 	dev_priv->ring.tail = cur_read_ptr;
 
+#if __REALLY_HAVE_AGP
 	if ( !dev_priv->is_pci ) {
 		RADEON_WRITE( RADEON_CP_RB_RPTR_ADDR,
-			      dev_priv->ring_rptr->offset );
-	} else {
+			      dev_priv->ring_rptr->offset
+			      - dev->agp->base
+			      + dev_priv->agp_vm_start);
+	} else
+#endif
+	{
 		drm_sg_mem_t *entry = dev->sg;
 		unsigned long tmp_ofs, page_ofs;
 
@@ -920,7 +919,7 @@
 					 + RADEON_SCRATCH_REG_OFFSET );
 
 	dev_priv->scratch = ((__volatile__ u32 *)
-			     dev_priv->ring.head +
+			     dev_priv->ring_rptr->handle +
 			     (RADEON_SCRATCH_REG_OFFSET / sizeof(u32)));
 
 	RADEON_WRITE( RADEON_SCRATCH_UMSK, 0x7 );
@@ -990,17 +989,6 @@
 
 	dev_priv->is_pci = init->is_pci;
 
-#if !defined(PCIGART_ENABLED)
-	/* PCI support is not 100% working, so we disable it here.
-	 */
-	if ( dev_priv->is_pci ) {
-		DRM_ERROR( "PCI GART not yet supported for Radeon!\n" );
-		dev->dev_private = (void *)dev_priv;
-		radeon_do_cleanup_cp(dev);
-		return DRM_ERR(EINVAL);
-	}
-#endif
-
 	if ( dev_priv->is_pci && !dev->sg ) {
 		DRM_ERROR( "PCI GART memory not allocated!\n" );
 		dev->dev_private = (void *)dev_priv;
@@ -1097,6 +1085,13 @@
 					 RADEON_ROUND_PREC_8TH_PIX);
 
 	DRM_GETSAREA();
+
+	dev_priv->fb_offset = init->fb_offset;
+	dev_priv->mmio_offset = init->mmio_offset;
+	dev_priv->ring_offset = init->ring_offset;
+	dev_priv->ring_rptr_offset = init->ring_rptr_offset;
+	dev_priv->buffers_offset = init->buffers_offset;
+	dev_priv->agp_textures_offset = init->agp_textures_offset;
 	
 	if(!dev_priv->sarea) {
 		DRM_ERROR("could not find sarea!\n");
@@ -1204,9 +1199,6 @@
 	DRM_DEBUG( "dev_priv->agp_buffers_offset 0x%lx\n",
 		   dev_priv->agp_buffers_offset );
 
-	dev_priv->ring.head = ((__volatile__ u32 *)
-			       dev_priv->ring_rptr->handle);
-
 	dev_priv->ring.start = (u32 *)dev_priv->cp_ring->handle;
 	dev_priv->ring.end = ((u32 *)dev_priv->cp_ring->handle
 			      + init->ring_size / sizeof(u32));
@@ -1217,7 +1209,6 @@
 		(dev_priv->ring.size / sizeof(u32)) - 1;
 
 	dev_priv->ring.high_mark = RADEON_RING_HIGH_MARK;
-	dev_priv->ring.ring_rptr = dev_priv->ring_rptr;
 
 #if __REALLY_HAVE_SG
 	if ( dev_priv->is_pci ) {
@@ -1275,13 +1266,24 @@
 {
 	DRM_DEBUG( "\n" );
 
+#if _HAVE_DMA_IRQ
+	/* Make sure interrupts are disabled here because the uninstall ioctl
+	 * may not have been called from userspace and after dev_private
+	 * is freed, it's too late.
+	 */
+	if ( dev->irq ) DRM(irq_uninstall)(dev);
+#endif
+
 	if ( dev->dev_private ) {
 		drm_radeon_private_t *dev_priv = dev->dev_private;
 
 		if ( !dev_priv->is_pci ) {
-			DRM_IOREMAPFREE( dev_priv->cp_ring );
-			DRM_IOREMAPFREE( dev_priv->ring_rptr );
-			DRM_IOREMAPFREE( dev_priv->buffers );
+			if ( dev_priv->cp_ring != NULL )
+				DRM_IOREMAPFREE( dev_priv->cp_ring );
+			if ( dev_priv->ring_rptr != NULL )
+				DRM_IOREMAPFREE( dev_priv->ring_rptr );
+			if ( dev_priv->buffers != NULL )
+				DRM_IOREMAPFREE( dev_priv->buffers );
 		} else {
 #if __REALLY_HAVE_SG
 			if (!DRM(ati_pcigart_cleanup)( dev,
@@ -1304,6 +1306,8 @@
 	DRM_DEVICE;
 	drm_radeon_init_t init;
 
+	LOCK_TEST_WITH_RETURN( dev, filp );
+
 	DRM_COPY_FROM_USER_IOCTL( init, (drm_radeon_init_t *)data, sizeof(init) );
 
 	switch ( init.func ) {
@@ -1592,10 +1596,10 @@
 {
 	drm_radeon_ring_buffer_t *ring = &dev_priv->ring;
 	int i;
-	u32 last_head = GET_RING_HEAD(ring);
+	u32 last_head = GET_RING_HEAD( dev_priv );
 
 	for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) {
-		u32 head = GET_RING_HEAD(ring);
+		u32 head = GET_RING_HEAD( dev_priv );
 
 		ring->space = (head - ring->tail) * sizeof(u32);
 		if ( ring->space <= 0 )
diff -Nru a/drivers/char/drm/radeon_drm.h b/drivers/char/drm/radeon_drm.h
--- a/drivers/char/drm/radeon_drm.h	Wed Apr 30 22:28:11 2003
+++ b/drivers/char/drm/radeon_drm.h	Wed Apr 30 22:28:11 2003
@@ -532,6 +532,10 @@
 #define RADEON_PARAM_LAST_CLEAR            4
 #define RADEON_PARAM_IRQ_NR                5
 #define RADEON_PARAM_AGP_BASE              6 /* card offset of agp base */
+#define RADEON_PARAM_REGISTER_HANDLE       7 /* for drmMap() */
+#define RADEON_PARAM_STATUS_HANDLE         8
+#define RADEON_PARAM_SAREA_HANDLE          9
+#define RADEON_PARAM_AGP_TEX_HANDLE        10
 
 typedef struct drm_radeon_getparam {
 	int param;
diff -Nru a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h
--- a/drivers/char/drm/radeon_drv.h	Wed Apr 30 22:28:09 2003
+++ b/drivers/char/drm/radeon_drv.h	Wed Apr 30 22:28:09 2003
@@ -31,8 +31,8 @@
 #ifndef __RADEON_DRV_H__
 #define __RADEON_DRV_H__
 
-#define GET_RING_HEAD(ring)		DRM_READ32(  (ring)->ring_rptr, 0 ) /* (ring)->head */
-#define SET_RING_HEAD(ring,val)		DRM_WRITE32( (ring)->ring_rptr, 0, (val) ) /* (ring)->head */
+#define GET_RING_HEAD(dev_priv)		DRM_READ32(  (dev_priv)->ring_rptr, 0 )
+#define SET_RING_HEAD(dev_priv,val)	DRM_WRITE32( (dev_priv)->ring_rptr, 0, (val) )
 
 typedef struct drm_radeon_freelist {
    	unsigned int age;
@@ -47,13 +47,11 @@
 	int size;
 	int size_l2qw;
 
-	volatile u32 *head;
 	u32 tail;
 	u32 tail_mask;
 	int space;
 
 	int high_mark;
-	drm_local_map_t *ring_rptr;
 } drm_radeon_ring_buffer_t;
 
 typedef struct drm_radeon_depth_clear_t {
@@ -126,6 +124,13 @@
 	u32 depth_pitch_offset;
 
 	drm_radeon_depth_clear_t depth_clear;
+	
+	unsigned long fb_offset;
+	unsigned long mmio_offset;
+	unsigned long ring_offset;
+	unsigned long ring_rptr_offset;
+	unsigned long buffers_offset;
+	unsigned long agp_textures_offset;
 
 	drm_local_map_t *sarea;
 	drm_local_map_t *fb;
@@ -775,7 +780,7 @@
 #define RING_SPACE_TEST_WITH_RETURN( dev_priv )				\
 do {									\
 	if (!(dev_priv->stats.boxes & RADEON_BOX_DMA_IDLE)) {		\
-		u32 head = GET_RING_HEAD(&dev_priv->ring);		\
+		u32 head = GET_RING_HEAD( dev_priv );			\
 		if (head == dev_priv->ring.tail)			\
 			dev_priv->stats.boxes |= RADEON_BOX_DMA_IDLE;	\
 	}								\
@@ -847,8 +852,8 @@
 
 #define COMMIT_RING() do {						\
 	/* Flush writes to ring */					\
-	DRM_READMEMORYBARRIER(dev_priv->mmio);					\
-	GET_RING_HEAD( &dev_priv->ring );				\
+	DRM_MEMORYBARRIER();						\
+	GET_RING_HEAD( dev_priv );					\
 	RADEON_WRITE( RADEON_CP_RB_WPTR, dev_priv->ring.tail );		\
 	/* read from PCI bus to ensure correct posting */		\
 	RADEON_READ( RADEON_CP_RB_RPTR );				\
diff -Nru a/drivers/char/drm/radeon_irq.c b/drivers/char/drm/radeon_irq.c
--- a/drivers/char/drm/radeon_irq.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/char/drm/radeon_irq.c	Wed Apr 30 22:28:17 2003
@@ -54,7 +54,7 @@
  * tied to dma at all, this is just a hangover from dri prehistory.
  */
 
-void DRM(dma_service)( DRM_IRQ_ARGS )
+irqreturn_t DRM(dma_service)( DRM_IRQ_ARGS )
 {
 	drm_device_t *dev = (drm_device_t *) arg;
 	drm_radeon_private_t *dev_priv = 
@@ -67,7 +67,7 @@
 	stat = RADEON_READ(RADEON_GEN_INT_STATUS)
 	     & (RADEON_SW_INT_TEST | RADEON_CRTC_VBLANK_STAT);
 	if (!stat)
-		return;
+		return IRQ_NONE;
 
 	/* SW interrupt */
 	if (stat & RADEON_SW_INT_TEST) {
@@ -83,6 +83,7 @@
 
 	/* Acknowledge interrupts we handle */
 	RADEON_WRITE(RADEON_GEN_INT_STATUS, stat);
+	return IRQ_HANDLED;
 }
 
 static __inline__ void radeon_acknowledge_irqs(drm_radeon_private_t *dev_priv)
@@ -249,8 +250,9 @@
 void DRM(driver_irq_uninstall)( drm_device_t *dev ) {
 	drm_radeon_private_t *dev_priv =
 		(drm_radeon_private_t *)dev->dev_private;
-	if ( dev_priv ) {
-		/* Disable *all* interrupts */
-		RADEON_WRITE( RADEON_GEN_INT_CNTL, 0 );
-	}
+	if (!dev_priv)
+		return;
+
+	/* Disable *all* interrupts */
+	RADEON_WRITE( RADEON_GEN_INT_CNTL, 0 );
 }
diff -Nru a/drivers/char/drm/radeon_state.c b/drivers/char/drm/radeon_state.c
--- a/drivers/char/drm/radeon_state.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/char/drm/radeon_state.c	Wed Apr 30 22:28:15 2003
@@ -2191,6 +2191,19 @@
 	case RADEON_PARAM_AGP_BASE:
 		value = dev_priv->agp_vm_start;
 		break;
+	case RADEON_PARAM_REGISTER_HANDLE:
+		value = dev_priv->mmio_offset;
+		break;
+	case RADEON_PARAM_STATUS_HANDLE:
+		value = dev_priv->ring_rptr_offset;
+		break;
+	case RADEON_PARAM_SAREA_HANDLE:
+		/* The lock is the first dword in the sarea. */
+		value = (int)dev->lock.hw_lock; 
+		break;	
+	case RADEON_PARAM_AGP_TEX_HANDLE:
+		value = dev_priv->agp_textures_offset;
+		break;
 	default:
 		return DRM_ERR(EINVAL);
 	}
diff -Nru a/drivers/char/drm/sis_drv.c b/drivers/char/drm/sis_drv.c
--- a/drivers/char/drm/sis_drv.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/char/drm/sis_drv.c	Wed Apr 30 22:28:03 2003
@@ -41,7 +41,6 @@
 #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"
diff -Nru a/drivers/char/dz.c b/drivers/char/dz.c
--- a/drivers/char/dz.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/char/dz.c	Wed Apr 30 22:28:04 2003
@@ -1112,8 +1112,8 @@
 	 */
 	shutdown(info);
 
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer (tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer (tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer (tty);
 	tty->closing = 0;
@@ -1183,7 +1183,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		if (info->flags & DZ_NORMAL_ACTIVE)
 			return -EBUSY;
     
@@ -1271,7 +1271,7 @@
 	struct dz_serial *info;
 	int retval, line;
 
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 
 	/*
 	 * The dz lines for the mouse/keyboard must be opened using their
@@ -1301,7 +1301,7 @@
 		return retval;
 
 	if ((info->count == 1) && (info->flags & DZ_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->normal_termios;
 		else 
 			*tty->termios = info->callout_termios;
@@ -1335,7 +1335,7 @@
 #if (LINUX_VERSION_CODE > 0x2032D && defined(CONFIG_DEVFS_FS))
 	serial_driver.name = "ttyS";
 #else
-	serial_driver.name = "tts/%d";
+	serial_driver.name = "tts/";
 #endif
 	serial_driver.major = TTY_MAJOR;
 	serial_driver.minor_start = 64;
@@ -1376,7 +1376,7 @@
 #if (LINUX_VERSION_CODE > 0x2032D && defined(CONFIG_DEVFS_FS))
 	callout_driver.name = "cua";
 #else
-	callout_driver.name = "cua/%d";
+	callout_driver.name = "cua/";
 #endif
 	callout_driver.major = TTYAUX_MAJOR;
 	callout_driver.subtype = SERIAL_TYPE_CALLOUT;
@@ -1425,10 +1425,8 @@
 		printk("ttyS%02d at 0x%08x (irq = %d)\n", info->line,
 		       info->port, SERIAL);
 
-		tty_register_device(&serial_driver,
-		                   serial_driver.minor_start + info->line);
-		tty_register_device(&callout_driver,
-		                   callout_driver.minor_start + info->line);
+		tty_register_device(&serial_driver, info->line);
+		tty_register_device(&callout_driver, info->line);
 	}
 
 	/* Reset the chip */
@@ -1504,9 +1502,10 @@
 	}
 }
 
-static kdev_t dz_console_device(struct console *c)
+static struct tty_driver *dz_console_device(struct console *c, int *index)
 {
-	return mk_kdev(TTY_MAJOR, 64 + c->index);
+	*index = c->index;
+	return &serial_driver;
 }
 
 static int __init dz_console_setup(struct console *co, char *options)
diff -Nru a/drivers/char/epca.c b/drivers/char/epca.c
--- a/drivers/char/epca.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/char/epca.c	Wed Apr 30 22:28:10 2003
@@ -503,7 +503,7 @@
 	struct channel *ch;
 	unsigned long flags;
 
-	if (tty->driver.subtype == SERIAL_TYPE_INFO) 
+	if (tty->driver->subtype == SERIAL_TYPE_INFO) 
 	{
 		return;
 	}
@@ -574,8 +574,8 @@
 			tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */
 		}
 	
-		if (tty->driver.flush_buffer)
-			tty->driver.flush_buffer(tty);
+		if (tty->driver->flush_buffer)
+			tty->driver->flush_buffer(tty);
 
 		if (tty->ldisc.flush_buffer)
 			tty->ldisc.flush_buffer(tty);
@@ -681,8 +681,8 @@
 
 		save_flags(flags);
 		cli();
-		if (tty->driver.flush_buffer)
-			tty->driver.flush_buffer(tty);
+		if (tty->driver->flush_buffer)
+			tty->driver->flush_buffer(tty);
 
 		if (tty->ldisc.flush_buffer)
 			tty->ldisc.flush_buffer(tty);
@@ -729,7 +729,7 @@
 
 	/* Stop users from hurting themselves on control minor */
 
-	if (tty->driver.subtype == SERIAL_TYPE_INFO) 
+	if (tty->driver->subtype == SERIAL_TYPE_INFO) 
 	{
 		return (0) ;
 	}
@@ -1238,7 +1238,7 @@
 	   device isn't being used.
 	-------------------------------------------------------------------- */
 
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) 
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) 
 	{ /* A cud device has been opened */
 		if (ch->asyncflags & ASYNC_NORMAL_ACTIVE)
 			return -EBUSY;
@@ -1368,12 +1368,12 @@
 
 	/* Nothing "real" happens in open of control device */
 
-	if (tty->driver.subtype == SERIAL_TYPE_INFO) 
+	if (tty->driver->subtype == SERIAL_TYPE_INFO) 
 	{
 		return (0) ;
 	}
 
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if (line < 0 || line >= nbdevs) 
 	{
 		printk(KERN_ERR "<Error> - pc_open : line out of range in pc_open\n");
@@ -1453,7 +1453,7 @@
 	/* Should this be here except for SPLIT termios ? */
 	if (ch->count == 1) 
 	{
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = ch->normal_termios;
 		else 
 			*tty->termios = ch->callout_termios;
@@ -2712,7 +2712,7 @@
 			the driver will wait on carrier detect.
 		------------------------------------------------------------------- */
 
-		if ((ts->c_cflag & CLOCAL) || (tty->driver.subtype == SERIAL_TYPE_CALLOUT))
+		if ((ts->c_cflag & CLOCAL) || (tty->driver->subtype == SERIAL_TYPE_CALLOUT))
 		{ /* Begin it is a cud device or a ttyD device with CLOCAL on */
 			ch->asyncflags &= ~ASYNC_CHECK_CD;
 		} /* End it is a cud device or a ttyD device with CLOCAL on */
@@ -2888,7 +2888,7 @@
 	if (bc->orun) 
 	{
 		bc->orun = 0;
-		printk(KERN_WARNING "overrun! DigiBoard device minor = %d\n",minor(tty->device));
+		printk(KERN_WARNING "overrun! DigiBoard device %s\n",tty->name);
 	}
 
 	rxwinon(ch);
@@ -2960,7 +2960,7 @@
 	struct channel *ch = (struct channel *) tty->driver_data;
 	
 	/* The control device has it's own set of commands */
-	if (tty->driver.subtype == SERIAL_TYPE_INFO) 
+	if (tty->driver->subtype == SERIAL_TYPE_INFO) 
 	{ /* Begin if subtype is the control device */
 
 		switch (cmd) 
diff -Nru a/drivers/char/esp.c b/drivers/char/esp.c
--- a/drivers/char/esp.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/char/esp.c	Wed Apr 30 22:28:03 2003
@@ -135,7 +135,7 @@
   
 #if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT)
 #define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \
- cdevname(tty->device), (info->flags), serial_refcount,info->count,tty->count,s)
+ tty->name, (info->flags), serial_refcount,info->count,tty->count,s)
 #else
 #define DBG_CNT(s)
 #endif
@@ -175,7 +175,7 @@
 static DECLARE_MUTEX(tmp_buf_sem);
 
 static inline int serial_paranoia_check(struct esp_struct *info,
-					kdev_t device, const char *routine)
+					char *name, const char *routine)
 {
 #ifdef SERIAL_PARANOIA_CHECK
 	static const char badmagic[] = KERN_WARNING
@@ -184,11 +184,11 @@
 		"Warning: null esp_struct for (%s) in %s\n";
 
 	if (!info) {
-		printk(badinfo, cdevname(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (info->magic != ESP_MAGIC) {
-		printk(badmagic, cdevname(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -219,7 +219,7 @@
 	struct esp_struct *info = (struct esp_struct *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_stop"))
+	if (serial_paranoia_check(info, tty->name, "rs_stop"))
 		return;
 	
 	save_flags(flags); cli();
@@ -237,7 +237,7 @@
 	struct esp_struct *info = (struct esp_struct *)tty->driver_data;
 	unsigned long flags;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_start"))
+	if (serial_paranoia_check(info, tty->name, "rs_start"))
 		return;
 	
 	save_flags(flags); cli();
@@ -653,7 +653,8 @@
 /*
  * This is the serial driver's interrupt routine
  */
-static void rs_interrupt_single(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t rs_interrupt_single(int irq, void *dev_id,
+					struct pt_regs *regs)
 {
 	struct esp_struct * info;
 	unsigned err_status;
@@ -670,7 +671,7 @@
 	
 	if (!info->tty) {
 		sti();
-		return;
+		return IRQ_NONE;
 	}
 
 	if (scratch & 0x04) { /* error */
@@ -753,6 +754,7 @@
 	printk("end.\n");
 #endif
 	sti();
+	return IRQ_HANDLED;
 }
 
 /*
@@ -1256,7 +1258,7 @@
 	struct esp_struct *info = (struct esp_struct *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_put_char"))
+	if (serial_paranoia_check(info, tty->name, "rs_put_char"))
 		return;
 
 	if (!tty || !info->xmit_buf)
@@ -1279,7 +1281,7 @@
 	struct esp_struct *info = (struct esp_struct *)tty->driver_data;
 	unsigned long flags;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_flush_chars"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
 		return;
 
 	if (info->xmit_cnt <= 0 || tty->stopped || !info->xmit_buf)
@@ -1301,7 +1303,7 @@
 	struct esp_struct *info = (struct esp_struct *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_write"))
+	if (serial_paranoia_check(info, tty->name, "rs_write"))
 		return 0;
 
 	if (!tty || !info->xmit_buf || !tmp_buf)
@@ -1368,7 +1370,7 @@
 	struct esp_struct *info = (struct esp_struct *)tty->driver_data;
 	int	ret;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_write_room"))
+	if (serial_paranoia_check(info, tty->name, "rs_write_room"))
 		return 0;
 	ret = ESP_XMIT_SIZE - info->xmit_cnt - 1;
 	if (ret < 0)
@@ -1380,7 +1382,7 @@
 {
 	struct esp_struct *info = (struct esp_struct *)tty->driver_data;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_chars_in_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
 		return 0;
 	return info->xmit_cnt;
 }
@@ -1389,7 +1391,7 @@
 {
 	struct esp_struct *info = (struct esp_struct *)tty->driver_data;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_flush_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
 		return;
 	cli();
 	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
@@ -1418,7 +1420,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_throttle"))
+	if (serial_paranoia_check(info, tty->name, "rs_throttle"))
 		return;
 	
 	cli();
@@ -1440,7 +1442,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_unthrottle"))
+	if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
 		return;
 	
 	cli();
@@ -1841,7 +1843,7 @@
 	struct esp_struct * info = (struct esp_struct *)tty->driver_data;
 	unsigned long flags;
 	
-	if (serial_paranoia_check(info, tty->device, "esp_break"))
+	if (serial_paranoia_check(info, tty->name, "esp_break"))
 		return;
 
 	save_flags(flags); cli();
@@ -1864,7 +1866,7 @@
 	struct async_icount cprev, cnow;	/* kernel counter temps */
 	struct serial_icounter_struct *p_cuser;	/* user space */
 
-	if (serial_paranoia_check(info, tty->device, "rs_ioctl"))
+	if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
 		return -ENODEV;
 
 	if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
@@ -2037,7 +2039,7 @@
 	struct esp_struct * info = (struct esp_struct *)tty->driver_data;
 	unsigned long flags;
 
-	if (!info || serial_paranoia_check(info, tty->device, "rs_close"))
+	if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
 		return;
 	
 	save_flags(flags); cli();
@@ -2112,8 +2114,8 @@
 		rs_wait_until_sent(tty, info->timeout);
 	}
 	shutdown(info);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -2140,7 +2142,7 @@
 	unsigned long orig_jiffies, char_time;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_wait_until_sent"))
+	if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
 		return;
 
 	orig_jiffies = jiffies;
@@ -2179,7 +2181,7 @@
 {
 	struct esp_struct * info = (struct esp_struct *)tty->driver_data;
 	
-	if (serial_paranoia_check(info, tty->device, "esp_hangup"))
+	if (serial_paranoia_check(info, tty->name, "esp_hangup"))
 		return;
 	
 	rs_flush_buffer(tty);
@@ -2226,7 +2228,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		if (info->flags & ASYNC_NORMAL_ACTIVE)
 			return -EBUSY;
 		if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
@@ -2354,7 +2356,7 @@
 	struct esp_struct	*info;
 	int 			retval, line;
 
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if ((line < 0) || (line >= NR_PORTS))
 		return -ENODEV;
 
@@ -2366,13 +2368,12 @@
 		info = info->next_port;
 
 	if (!info) {
-		serial_paranoia_check(info, tty->device, "esp_open");
+		serial_paranoia_check(info, tty->name, "esp_open");
 		return -ENODEV;
 	}
 
 #ifdef SERIAL_DEBUG_OPEN
-	printk("esp_open %s%d, count = %d\n", tty->driver.name, info->line,
-	       info->count);
+	printk("esp_open %s, count = %d\n", tty->name, info->count);
 #endif
 	MOD_INC_USE_COUNT;
 	info->count++;
@@ -2402,7 +2403,7 @@
 	}
 
 	if ((info->count == 1) && (info->flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->normal_termios;
 		else 
 			*tty->termios = info->callout_termios;
@@ -2413,7 +2414,7 @@
 	info->pgrp = current->pgrp;
 
 #ifdef SERIAL_DEBUG_OPEN
-	printk("esp_open ttys%d successful...", info->line);
+	printk("esp_open %s successful...", tty->name);
 #endif
 	return 0;
 }
diff -Nru a/drivers/char/ftape/lowlevel/fdc-io.c b/drivers/char/ftape/lowlevel/fdc-io.c
--- a/drivers/char/ftape/lowlevel/fdc-io.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/char/ftape/lowlevel/fdc-io.c	Wed Apr 30 22:28:06 2003
@@ -1298,18 +1298,20 @@
 	TRACE_EXIT 0;
 }
 
-static void ftape_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t ftape_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	void (*handler) (void) = *fdc.hook;
+	int handled = 0;
 	TRACE_FUN(ft_t_any);
 
 	*fdc.hook = NULL;
 	if (handler) {
+		handled = 1;
 		handler();
 	} else {
 		TRACE(ft_t_bug, "Unexpected ftape interrupt");
 	}
-	TRACE_EXIT;
+	return IRQ_RETVAL(handled);
 }
 
 int fdc_grab_irq_and_dma(void)
diff -Nru a/drivers/char/ftape/lowlevel/ftape-buffer.c b/drivers/char/ftape/lowlevel/ftape-buffer.c
--- a/drivers/char/ftape/lowlevel/ftape-buffer.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/char/ftape/lowlevel/ftape-buffer.c	Wed Apr 30 22:28:07 2003
@@ -27,7 +27,6 @@
 #include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/mman.h>
-#include <linux/wrapper.h>
 #include <asm/dma.h>
 
 #include <linux/ftape.h>
@@ -50,7 +49,7 @@
 		struct page *page;
 
 		for (page = virt_to_page(addr); page < virt_to_page(addr+size); page++)
-			mem_map_reserve(page);
+			SetPageReserved(page);
 	}
 	return (void *)addr;
 }
@@ -62,7 +61,7 @@
 
 		for (page = virt_to_page((unsigned long)addr);
 		     page < virt_to_page((unsigned long)addr+size); page++)
-			mem_map_unreserve(page);
+			ClearPageReserved(page);
 		free_pages((unsigned long) addr, get_order(size));
 	}
 }
diff -Nru a/drivers/char/ftape/lowlevel/ftape-ctl.c b/drivers/char/ftape/lowlevel/ftape-ctl.c
--- a/drivers/char/ftape/lowlevel/ftape-ctl.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/char/ftape/lowlevel/ftape-ctl.c	Wed Apr 30 22:28:18 2003
@@ -29,7 +29,6 @@
 #include <linux/errno.h>
 #include <linux/mm.h>
 #include <linux/mman.h>
-#include <linux/wrapper.h>
 
 #include <linux/ftape.h>
 #include <linux/qic117.h>
diff -Nru a/drivers/char/ftape/zftape/zftape-init.c b/drivers/char/ftape/zftape/zftape-init.c
--- a/drivers/char/ftape/zftape/zftape-init.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/char/ftape/zftape/zftape-init.c	Wed Apr 30 22:28:08 2003
@@ -33,7 +33,6 @@
 #include <linux/kmod.h>
 #endif
 #include <linux/fcntl.h>
-#include <linux/wrapper.h>
 #include <linux/smp_lock.h>
 #include <linux/devfs_fs_kernel.h>
 
diff -Nru a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c
--- a/drivers/char/generic_serial.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/char/generic_serial.c	Wed Apr 30 22:28:09 2003
@@ -112,7 +112,7 @@
 
 	if (!tty) return 0;
 
-	port = tty->driver;
+	port = tty->driver_data;
 
 	if (!port) return 0;
 
@@ -622,7 +622,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == GS_TYPE_CALLOUT) {
+	if (tty->driver->subtype == GS_TYPE_CALLOUT) {
 		if (port->flags & ASYNC_NORMAL_ACTIVE)
 			return -EBUSY;
 		if ((port->flags & ASYNC_CALLOUT_ACTIVE) &&
@@ -794,8 +794,8 @@
 
 	port->flags &= ~GS_ACTIVE;
 
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
diff -Nru a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
--- a/drivers/char/hvc_console.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/char/hvc_console.c	Wed Apr 30 22:28:16 2003
@@ -69,7 +69,7 @@
 
 static int hvc_open(struct tty_struct *tty, struct file * filp)
 {
-	int line = minor(tty->device) - tty->driver.minor_start;
+	int line = tty->index;
 	struct hvc_struct *hp;
 	unsigned long flags;
 
@@ -253,7 +253,7 @@
 
 	hvc_driver.magic = TTY_DRIVER_MAGIC;
 	hvc_driver.driver_name = "hvc";
-	hvc_driver.name = "hvc/%d";
+	hvc_driver.name = "hvc/";
 	hvc_driver.major = HVC_MAJOR;
 	hvc_driver.minor_start = HVC_MINOR;
 	hvc_driver.num = hvc_count(&hvc_offset);
@@ -277,7 +277,7 @@
 	for (i = 0; i < hvc_driver.num; i++) {
 		hvc_struct[i].lock = SPIN_LOCK_UNLOCKED;
 		hvc_struct[i].index = i;
-		tty_register_device(&hvc_driver, hvc_driver.minor_start + i);
+		tty_register_device(&hvc_driver, i);
 	}
 
 	if (tty_register_driver(&hvc_driver))
@@ -324,9 +324,10 @@
 	}
 }
 
-static kdev_t hvc_console_device(struct console *c)
+static struct tty_driver *hvc_console_device(struct console *c, int *index)
 {
-	return mk_kdev(HVC_MAJOR, HVC_MINOR + c->index);
+	*index = c->index;
+	return &hvc_driver;
 }
 
 static int __init hvc_console_setup(struct console *co, char *options)
diff -Nru a/drivers/char/hw_random.c b/drivers/char/hw_random.c
--- a/drivers/char/hw_random.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/char/hw_random.c	Wed Apr 30 22:28:07 2003
@@ -47,7 +47,7 @@
 /*
  * core module and version information
  */
-#define RNG_VERSION "0.9.0"
+#define RNG_VERSION "1.0.0"
 #define RNG_MODULE_NAME "hw_random"
 #define RNG_DRIVER_NAME   RNG_MODULE_NAME " hardware driver " RNG_VERSION
 #define PFX RNG_MODULE_NAME ": "
@@ -499,7 +499,7 @@
 
 		spin_unlock (&rng_lock);
 
-		while (have_data > 0) {
+		while (have_data && size) {
 			if (put_user((u8)data, buf++)) {
 				ret = ret ? : -EFAULT;
 				break;
diff -Nru a/drivers/char/ip2main.c b/drivers/char/ip2main.c
--- a/drivers/char/ip2main.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/char/ip2main.c	Wed Apr 30 22:28:20 2003
@@ -274,7 +274,7 @@
 
 static void set_irq(int, int);
 static void ip2_interrupt_bh(i2eBordStrPtr pB);
-static void ip2_interrupt(int irq, void *dev_id, struct pt_regs * regs);
+static irqreturn_t ip2_interrupt(int irq, void *dev_id, struct pt_regs * regs);
 static void ip2_poll(unsigned long arg);
 static inline void service_all_boards(void);
 static void do_input(void *p);
@@ -366,7 +366,7 @@
 
 #if defined(MODULE) && defined(IP2DEBUG_OPEN)
 #define DBG_CNT(s) printk(KERN_DEBUG "(%s): [%x] refc=%d, ttyc=%d, modc=%x -> %s\n", \
-		    cdevname(tty->device),(pCh->flags),ref_count, \
+		    tty->name,(pCh->flags),ref_count, \
 		    tty->count,/*GET_USE_COUNT(module)*/0,s)
 #else
 #define DBG_CNT(s)
@@ -1339,11 +1339,12 @@
 /*                                                                            */
 /*                                                                            */
 /******************************************************************************/
-static void
+static irqreturn_t
 ip2_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
 	int i;
 	i2eBordStrPtr  pB;
+	int handled = 0;
 
 	ip2trace (ITRC_NO_PORT, ITRC_INTR, 99, 1, irq );
 
@@ -1355,6 +1356,7 @@
 //			IRQ = 0 for polled boards, we won't poll "IRQ" boards
 
 		if ( pB && (pB->i2eUsingIrq == irq) ) {
+			handled = 1;
 #ifdef USE_IQI
 
 		    if (NO_MAIL_HERE != ( pB->i2eStartMail = iiGetMail(pB))) {
@@ -1379,6 +1381,7 @@
 	++irq_counter;
 
 	ip2trace (ITRC_NO_PORT, ITRC_INTR, ITRC_RETURN, 0 );
+	return IRQ_RETVAL(handled);
 }
 
 /******************************************************************************/
@@ -1564,9 +1567,9 @@
 	wait_queue_t wait;
 	int rc = 0;
 	int do_clocal = 0;
-	i2ChanStrPtr  pCh = DevTable[minor(tty->device)];
+	i2ChanStrPtr  pCh = DevTable[tty->index];
 
-	ip2trace (minor(tty->device), ITRC_OPEN, ITRC_ENTER, 0 );
+	ip2trace (tty->index, ITRC_OPEN, ITRC_ENTER, 0 );
 
 	if ( pCh == NULL ) {
 		return -ENODEV;
@@ -1578,9 +1581,8 @@
 
 #ifdef IP2DEBUG_OPEN
 	printk(KERN_DEBUG \
-			"IP2:open(tty=%p,pFile=%p):dev=%x,maj=%d,min=%d,ch=%d,idx=%d\n",
-	       tty, pFile, tty->device, major(tty->device), minor(tty->device),
-			 pCh->infl.hd.i2sChannel, pCh->port_index);
+			"IP2:open(tty=%p,pFile=%p):dev=%s,ch=%d,idx=%d\n",
+	       tty, pFile, tty->name, pCh->infl.hd.i2sChannel, pCh->port_index);
 	open_sanity_check ( pCh, pCh->pMyBord );
 #endif
 
@@ -1616,7 +1618,7 @@
 	 *    (These are the only tests the standard serial driver makes for
 	 *    callout devices.)
 	 */
-	if ( tty->driver.subtype == SERIAL_TYPE_CALLOUT ) {
+	if ( tty->driver->subtype == SERIAL_TYPE_CALLOUT ) {
 		if ( pCh->flags & ASYNC_NORMAL_ACTIVE ) {
 			return -EBUSY;
 		}
@@ -1719,7 +1721,7 @@
 	if ( tty->count == 1 ) {
 		i2QueueCommands(PTYPE_INLINE, pCh, 0, 2, CMD_CTSFL_DSAB, CMD_RTSFL_DSAB);
 		if ( pCh->flags & ASYNC_SPLIT_TERMIOS ) {
-			if ( tty->driver.subtype == SERIAL_TYPE_NORMAL ) {
+			if ( tty->driver->subtype == SERIAL_TYPE_NORMAL ) {
 				*tty->termios = pCh->NormalTermios;
 			} else {
 				*tty->termios = pCh->CalloutTermios;
@@ -1771,7 +1773,7 @@
 	ip2trace (CHANN, ITRC_CLOSE, ITRC_ENTER, 0 );
 
 #ifdef IP2DEBUG_OPEN
-	printk(KERN_DEBUG "IP2:close ttyF%02X:\n",minor(tty->device));
+	printk(KERN_DEBUG "IP2:close %s:\n",tty->name);
 #endif
 
 	if ( tty_hung_up_p ( pFile ) ) {
@@ -1827,8 +1829,8 @@
 
 	serviceOutgoingFifo ( pCh->pMyBord );
 
-	if ( tty->driver.flush_buffer ) 
-		tty->driver.flush_buffer(tty);
+	if ( tty->driver->flush_buffer ) 
+		tty->driver->flush_buffer(tty);
 	if ( tty->ldisc.flush_buffer )  
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -2180,7 +2182,7 @@
 static void
 ip2_start ( PTTY tty )
 {
- 	i2ChanStrPtr  pCh = DevTable[minor(tty->device)];
+ 	i2ChanStrPtr  pCh = DevTable[tty->index];
 
  	i2QueueCommands(PTYPE_BYPASS, pCh, 0, 1, CMD_RESUME);
  	i2QueueCommands(PTYPE_BYPASS, pCh, 100, 1, CMD_UNSUSPEND);
@@ -2193,7 +2195,7 @@
 static void
 ip2_stop ( PTTY tty )
 {
- 	i2ChanStrPtr  pCh = DevTable[minor(tty->device)];
+ 	i2ChanStrPtr  pCh = DevTable[tty->index];
 
  	i2QueueCommands(PTYPE_BYPASS, pCh, 100, 1, CMD_SUSPEND);
 #ifdef IP2DEBUG_WRITE
@@ -2221,7 +2223,7 @@
 ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg )
 {
 	wait_queue_t wait;
-	i2ChanStrPtr pCh = DevTable[minor(tty->device)];
+	i2ChanStrPtr pCh = DevTable[tty->index];
 	struct async_icount cprev, cnow;	/* kernel counter temps */
 	struct serial_icounter_struct *p_cuser;	/* user space */
 	int rc = 0;
diff -Nru a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
--- a/drivers/char/ipmi/ipmi_devintf.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/char/ipmi/ipmi_devintf.c	Wed Apr 30 22:28:15 2003
@@ -437,10 +437,7 @@
 static int ipmi_major = 0;
 MODULE_PARM(ipmi_major, "i");
 
-static devfs_handle_t devfs_handle;
-
 #define MAX_DEVICES 10
-static devfs_handle_t handles[MAX_DEVICES];
 
 static void ipmi_new_smi(int if_num)
 {
@@ -451,10 +448,9 @@
 
 	snprintf(name, sizeof(name), "ipmidev/%d", if_num);
 
-	handles[if_num] = devfs_register(NULL, name, DEVFS_FL_NONE,
-					 ipmi_major, if_num,
-					 S_IFCHR | S_IRUSR | S_IWUSR,
-					 &ipmi_fops, NULL);
+	devfs_register(NULL, name, 0, ipmi_major, if_num,
+			S_IFCHR | S_IRUSR | S_IWUSR,
+			&ipmi_fops, NULL);
 }
 
 static void ipmi_smi_gone(int if_num)
@@ -462,7 +458,7 @@
 	if (if_num > MAX_DEVICES)
 		return;
 
-	devfs_unregister(handles[if_num]);
+	devfs_remove("ipmidev/%d", if_num);
 }
 
 static struct ipmi_smi_watcher smi_watcher =
@@ -488,7 +484,7 @@
 		ipmi_major = rv;
 	}
 
-	devfs_handle = devfs_mk_dir(DEVICE_NAME);
+	devfs_mk_dir(DEVICE_NAME);
 
 	rv = ipmi_smi_watcher_register(&smi_watcher);
 	if (rv) {
@@ -507,7 +503,7 @@
 static __exit void cleanup_ipmi(void)
 {
 	ipmi_smi_watcher_unregister(&smi_watcher);
-	devfs_unregister(devfs_handle);
+	devfs_remove(DEVICE_NAME);
 	unregister_chrdev(ipmi_major, DEVICE_NAME);
 }
 module_exit(cleanup_ipmi);
diff -Nru a/drivers/char/ipmi/ipmi_kcs_intf.c b/drivers/char/ipmi/ipmi_kcs_intf.c
--- a/drivers/char/ipmi/ipmi_kcs_intf.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/char/ipmi/ipmi_kcs_intf.c	Wed Apr 30 22:28:03 2003
@@ -629,6 +629,7 @@
 	atomic_set(&kcs_info->req_events, 1);
 }
 
+#if 0
 static int new_user(void *send_info)
 {
 	if (!try_module_get(THIS_MODULE))
@@ -640,6 +641,7 @@
 {
 	module_put(THIS_MODULE);
 }
+#endif
 
 static int initialized = 0;
 
@@ -740,7 +742,7 @@
 	spin_unlock_irqrestore(&(kcs_info->kcs_lock), flags);
 }
 
-static void kcs_irq_handler(int irq, void *data, struct pt_regs *regs)
+static irqreturn_t kcs_irq_handler(int irq, void *data, struct pt_regs *regs)
 {
 	struct kcs_info *kcs_info = (struct kcs_info *) data;
 	unsigned long   flags;
@@ -759,6 +761,7 @@
 	kcs_event_handler(kcs_info, 0);
  out:
 	spin_unlock_irqrestore(&(kcs_info->kcs_lock), flags);
+	return IRQ_HANDLED;
 }
 
 static struct ipmi_smi_handlers handlers =
diff -Nru a/drivers/char/isicom.c b/drivers/char/isicom.c
--- a/drivers/char/isicom.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/char/isicom.c	Wed Apr 30 22:28:03 2003
@@ -338,7 +338,7 @@
  *
  */
  
-static inline int isicom_paranoia_check(struct isi_port const * port, kdev_t dev, 
+static inline int isicom_paranoia_check(struct isi_port const * port, char *name, 
 					const char * routine)
 {
 #ifdef ISICOM_DEBUG 
@@ -347,11 +347,11 @@
 	static const char * badport = 
 			KERN_WARNING "ISICOM: Warning: NULL isicom port for dev %s in %s.\n";		
 	if (!port) {
-		printk(badport, cdevname(dev), routine);
+		printk(badport, name, routine);
 		return 1;
 	}
 	if (port->magic != ISICOM_MAGIC) {
-		printk(badmagic, cdevname(dev), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}	
 #endif	
@@ -509,7 +509,8 @@
 } 		
  		
 /* main interrupt handler routine */ 		
-static void isicom_interrupt(int irq, void * dev_id, struct pt_regs * regs)
+static irqreturn_t isicom_interrupt(int irq, void *dev_id,
+					struct pt_regs *regs)
 {
 	struct isi_board * card;
 	struct isi_port * port;
@@ -534,7 +535,7 @@
 
 	if (!card || !(card->status & FIRMWARE_LOADED)) {
 /*		printk(KERN_DEBUG "ISICOM: interrupt: not handling irq%d!.\n", irq);*/
-		return;
+		return IRQ_NONE;
 	}
 	
 	base = card->base;
@@ -561,7 +562,7 @@
 			ClearInterrupt(base);
 		else
 			outw(0x0000, base+0x04); /* enable interrupts */		
-		return;			
+		return IRQ_HANDLED;			
 	}
 	port = card->ports + channel;
 	if (!(port->flags & ASYNC_INITIALIZED)) {
@@ -569,7 +570,7 @@
 			ClearInterrupt(base);
 		else
 			outw(0x0000, base+0x04); /* enable interrupts */
-		return;
+		return IRQ_HANDLED;
 	}	
 		
 	tty = port->tty;
@@ -702,7 +703,7 @@
 		ClearInterrupt(base);
 	else
 		outw(0x0000, base+0x04); /* enable interrupts */	
-	return;
+	return IRQ_HANDLED;
 } 
 
  /* called with interrupts disabled */ 
@@ -907,7 +908,7 @@
 	
 	/* trying to open a callout device... check for constraints */
 	
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 #ifdef ISICOM_DEBUG
 		printk(KERN_DEBUG "ISICOM: bl_ti_rdy: callout open.\n");	
 #endif		
@@ -1021,7 +1022,7 @@
 #ifdef ISICOM_DEBUG	
 	printk(KERN_DEBUG "ISICOM: open start!!!.\n");
 #endif	
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	
 #ifdef ISICOM_DEBUG	
 	printk(KERN_DEBUG "line = %d.\n", line);
@@ -1049,7 +1050,7 @@
 		return -ENODEV;
 	}	
 	port = &isi_ports[line];	
-	if (isicom_paranoia_check(port, tty->device, "isicom_open"))
+	if (isicom_paranoia_check(port, tty->name, "isicom_open"))
 		return -ENODEV;
 		
 #ifdef ISICOM_DEBUG		
@@ -1072,7 +1073,7 @@
 		return error;
 		
 	if ((port->count == 1) && (port->flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = port->normal_termios;
 		else 
 			*tty->termios = port->callout_termios;
@@ -1146,7 +1147,7 @@
 	
 	if (!port)
 		return;
-	if (isicom_paranoia_check(port, tty->device, "isicom_close"))
+	if (isicom_paranoia_check(port, tty->name, "isicom_close"))
 		return;
 	
 #ifdef ISICOM_DEBUG		
@@ -1196,8 +1197,8 @@
 		outw(card->port_status, card->base + 0x02);
 	}	
 	isicom_shutdown_port(port);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -1232,7 +1233,7 @@
 	printk(KERN_DEBUG "ISICOM: isicom_write for port%d: %d bytes.\n",
 			port->channel+1, count);
 #endif	  	
-	if (isicom_paranoia_check(port, tty->device, "isicom_write"))
+	if (isicom_paranoia_check(port, tty->name, "isicom_write"))
 		return 0;
 	
 	if (!tty || !port->xmit_buf || !tmp_buf)
@@ -1290,7 +1291,7 @@
 	struct isi_port * port = (struct isi_port *) tty->driver_data;
 	unsigned long flags;
 	
-	if (isicom_paranoia_check(port, tty->device, "isicom_put_char"))
+	if (isicom_paranoia_check(port, tty->name, "isicom_put_char"))
 		return;
 	
 	if (!tty || !port->xmit_buf)
@@ -1317,7 +1318,7 @@
 {
 	struct isi_port * port = (struct isi_port *) tty->driver_data;
 	
-	if (isicom_paranoia_check(port, tty->device, "isicom_flush_chars"))
+	if (isicom_paranoia_check(port, tty->name, "isicom_flush_chars"))
 		return;
 	
 	if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
@@ -1334,7 +1335,7 @@
 {
 	struct isi_port * port = (struct isi_port *) tty->driver_data;
 	int free;
-	if (isicom_paranoia_check(port, tty->device, "isicom_write_room"))
+	if (isicom_paranoia_check(port, tty->name, "isicom_write_room"))
 		return 0;
 	
 	free = SERIAL_XMIT_SIZE - port->xmit_cnt - 1;
@@ -1347,7 +1348,7 @@
 static int isicom_chars_in_buffer(struct tty_struct * tty)
 {
 	struct isi_port * port = (struct isi_port *) tty->driver_data;
-	if (isicom_paranoia_check(port, tty->device, "isicom_chars_in_buffer"))
+	if (isicom_paranoia_check(port, tty->name, "isicom_chars_in_buffer"))
 		return 0;
 	return port->xmit_cnt;
 }
@@ -1495,7 +1496,7 @@
 	struct isi_port * port = (struct isi_port *) tty->driver_data;
 	int retval;
 
-	if (isicom_paranoia_check(port, tty->device, "isicom_ioctl"))
+	if (isicom_paranoia_check(port, tty->name, "isicom_ioctl"))
 		return -ENODEV;
 
 	switch(cmd) {
@@ -1556,7 +1557,7 @@
 	struct isi_port * port = (struct isi_port *) tty->driver_data;
 	unsigned long flags;
 	
-	if (isicom_paranoia_check(port, tty->device, "isicom_set_termios"))
+	if (isicom_paranoia_check(port, tty->name, "isicom_set_termios"))
 		return;
 	
 	if (tty->termios->c_cflag == old_termios->c_cflag &&
@@ -1581,7 +1582,7 @@
 	struct isi_board * card = port->card;
 	unsigned long flags;
 	
-	if (isicom_paranoia_check(port, tty->device, "isicom_throttle"))
+	if (isicom_paranoia_check(port, tty->name, "isicom_throttle"))
 		return;
 	
 	/* tell the card that this port cannot handle any more data for now */
@@ -1598,7 +1599,7 @@
 	struct isi_board * card = port->card;
 	unsigned long flags;
 	
-	if (isicom_paranoia_check(port, tty->device, "isicom_unthrottle"))
+	if (isicom_paranoia_check(port, tty->name, "isicom_unthrottle"))
 		return;
 	
 	/* tell the card that this port is ready to accept more data */
@@ -1613,7 +1614,7 @@
 {
 	struct isi_port * port = (struct isi_port *) tty->driver_data;
 
-	if (isicom_paranoia_check(port, tty->device, "isicom_stop"))
+	if (isicom_paranoia_check(port, tty->name, "isicom_stop"))
 		return;
 	
 	/* this tells the transmitter not to consider this port for
@@ -1626,7 +1627,7 @@
 {
 	struct isi_port * port = (struct isi_port *) tty->driver_data;
 	
-	if (isicom_paranoia_check(port, tty->device, "isicom_start"))
+	if (isicom_paranoia_check(port, tty->name, "isicom_start"))
 		return;
 	
 	/* this tells the transmitter to consider this port for
@@ -1650,7 +1651,7 @@
 {
 	struct isi_port * port = (struct isi_port *) tty->driver_data;
 	
-	if (isicom_paranoia_check(port, tty->device, "isicom_hangup"))
+	if (isicom_paranoia_check(port, tty->name, "isicom_hangup"))
 		return;
 	
 	isicom_shutdown_port(port);
@@ -1666,7 +1667,7 @@
 	struct isi_port * port = (struct isi_port *) tty->driver_data;
 	unsigned long flags;
 	
-	if (isicom_paranoia_check(port, tty->device, "isicom_flush_buffer"))
+	if (isicom_paranoia_check(port, tty->name, "isicom_flush_buffer"))
 		return;
 	
 	save_flags(flags); cli();
diff -Nru a/drivers/char/istallion.c b/drivers/char/istallion.c
--- a/drivers/char/istallion.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/char/istallion.c	Wed Apr 30 22:28:11 2003
@@ -1031,11 +1031,11 @@
 	int		brdnr, portnr, rc;
 
 #if DEBUG
-	printk("stli_open(tty=%x,filp=%x): device=%x\n", (int) tty,
-		(int) filp, tty->device);
+	printk("stli_open(tty=%x,filp=%x): device=%s\n", (int) tty,
+		(int) filp, tty->name);
 #endif
 
-	minordev = minor(tty->device);
+	minordev = tty->index;
 	brdnr = MINOR2BRD(minordev);
 	if (brdnr >= stli_nrbrds)
 		return(-ENODEV);
@@ -1115,7 +1115,7 @@
  *	previous opens still in effect. If we are a normal serial device
  *	then also we might have to wait for carrier.
  */
-	if (tty->driver.subtype == STL_DRVTYPCALLOUT) {
+	if (tty->driver->subtype == STL_DRVTYPCALLOUT) {
 		if (portp->flags & ASYNC_NORMAL_ACTIVE)
 			return(-EBUSY);
 		if (portp->flags & ASYNC_CALLOUT_ACTIVE) {
@@ -1139,7 +1139,7 @@
 	}
 
 	if ((portp->refcount == 1) && (portp->flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == STL_DRVTYPSERIAL)
+		if (tty->driver->subtype == STL_DRVTYPSERIAL)
 			*tty->termios = portp->normaltermios;
 		else
 			*tty->termios = portp->callouttermios;
diff -Nru a/drivers/char/keyboard.c b/drivers/char/keyboard.c
--- a/drivers/char/keyboard.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/char/keyboard.c	Wed Apr 30 22:28:08 2003
@@ -601,7 +601,7 @@
 		return;
 	if ((kbd->kbdmode == VC_RAW || 
 	     kbd->kbdmode == VC_MEDIUMRAW) && 
-	     value != K_SAK)
+	     value != KVAL(K_SAK))
 		return;		/* SAK is allowed even in raw mode */
 	fn_handler[value](vc, regs);
 }
@@ -1089,7 +1089,7 @@
 		clear_bit(keycode, key_down);
 
 	if (rep && (!vc_kbd_mode(kbd, VC_REPEAT) || (tty && 
-		(!L_ECHO(tty) && tty->driver.chars_in_buffer(tty))))) {
+		(!L_ECHO(tty) && tty->driver->chars_in_buffer(tty))))) {
 		/*
 		 * Don't repeat a key if the input buffers are not empty and the
 		 * characters get aren't echoed locally. This makes key repeat 
diff -Nru a/drivers/char/lp.c b/drivers/char/lp.c
--- a/drivers/char/lp.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/char/lp.c	Wed Apr 30 22:28:03 2003
@@ -733,15 +733,9 @@
 	parport_release (dev);
 }
 
-static kdev_t lp_console_device (struct console *c)
-{
-	return mk_kdev(LP_MAJOR, CONSOLE_LP);
-}
-
 static struct console lpcons = {
 	.name		= "lp",
 	.write		= lp_console_write,
-	.device		= lp_console_device,
 	.flags		= CON_PRINTBUFFER,
 };
 
diff -Nru a/drivers/char/lp_old98.c b/drivers/char/lp_old98.c
--- a/drivers/char/lp_old98.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/char/lp_old98.c	Wed Apr 30 22:28:07 2003
@@ -441,15 +441,9 @@
 	}
 }
 
-static kdev_t lp_old98_console_device(struct console *console)
-{
-	return mk_kdev(LP_MAJOR, 0);
-}
-
 static struct console lp_old98_console = {
 	.name	= "lp_old98",
 	.write	= lp_old98_console_write,
-	.device	= lp_old98_console_device,
 	.flags	= CON_PRINTBUFFER,
 	.index	= -1,
 };
diff -Nru a/drivers/char/mem.c b/drivers/char/mem.c
--- a/drivers/char/mem.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/char/mem.c	Wed Apr 30 22:28:09 2003
@@ -22,6 +22,7 @@
 #include <linux/tty.h>
 #include <linux/capability.h>
 #include <linux/smp_lock.h>
+#include <linux/devfs_fs_kernel.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
diff -Nru a/drivers/char/misc.c b/drivers/char/misc.c
--- a/drivers/char/misc.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/char/misc.c	Wed Apr 30 22:28:17 2003
@@ -167,7 +167,6 @@
 int misc_register(struct miscdevice * misc)
 {
 	struct miscdevice *c;
-	char buf[256];
 	
 	if (misc->next || misc->prev)
 		return -EBUSY;
@@ -193,18 +192,16 @@
 		}
 		misc->minor = i;
 	}
+
 	if (misc->minor < DYNAMIC_MINORS)
 		misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
+	if (misc->devfs_name[0] == '\0') {
+		snprintf(misc->devfs_name, sizeof(misc->devfs_name),
+				"misc/%s", misc->name);
+	}
 
-
-	/* yuck, yet another stupid special-casing.  We should rather
-	   add ->devfs_name to avoid this mess. */
-	snprintf(buf, sizeof(buf), strchr(misc->name, '/') ?
-			"%s" : "misc/%s", misc->name);
-	misc->devfs_handle = devfs_register(NULL, buf, 0,
-			MISC_MAJOR, misc->minor,
-			S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP,
-			misc->fops, NULL);
+	devfs_register(NULL, misc->devfs_name, 0, MISC_MAJOR, misc->minor,
+			S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP, misc->fops, NULL);
 
 	/*
 	 * Add it to the front, so that later devices can "override"
@@ -238,7 +235,7 @@
 	misc->next->prev = misc->prev;
 	misc->next = NULL;
 	misc->prev = NULL;
-	devfs_unregister (misc->devfs_handle);
+	devfs_remove(misc->devfs_name);
 	if (i < DYNAMIC_MINORS && i>0) {
 		misc_minors[i>>3] &= ~(1 << (misc->minor & 7));
 	}
diff -Nru a/drivers/char/moxa.c b/drivers/char/moxa.c
--- a/drivers/char/moxa.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/char/moxa.c	Wed Apr 30 22:28:17 2003
@@ -189,7 +189,7 @@
 
 #define WAKEUP_CHARS		256
 
-#define PORTNO(x)		(minor((x)->device) - (x)->driver.minor_start)
+#define PORTNO(x)		((x)->index)
 
 static int verbose = 0;
 static int ttymajor = MOXAMAJOR;
@@ -585,7 +585,7 @@
 	tty->driver_data = ch;
 	ch->tty = tty;
 	if (ch->count == 1 && (ch->asyncflags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = ch->normal_termios;
 		else
 			*tty->termios = ch->callout_termios;
@@ -644,8 +644,8 @@
 		ch->count = 1;
 	}
 	if (--ch->count < 0) {
-		printk("moxa_close: bad serial port count, minor=%d\n",
-		       minor(tty->device));
+		printk("moxa_close: bad serial port count, device=%s\n",
+		       tty->name);
 		ch->count = 0;
 	}
 	if (ch->count) {
@@ -671,8 +671,8 @@
 	shut_down(ch);
 	MoxaPortFlushData(port, 2);
 
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -1094,7 +1094,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		if (ch->asyncflags & ASYNC_NORMAL_ACTIVE)
 			return (-EBUSY);
 		if ((ch->asyncflags & ASYNC_CALLOUT_ACTIVE) &&
diff -Nru a/drivers/char/mwave/mwavedd.c b/drivers/char/mwave/mwavedd.c
--- a/drivers/char/mwave/mwavedd.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/char/mwave/mwavedd.c	Wed Apr 30 22:28:06 2003
@@ -502,8 +502,6 @@
 	&dev_attr_uart_irq,
 	&dev_attr_uart_io,
 };
-static int nr_registered_attrs;
-static int device_registered;
 
 /*
 * mwave_init is called on module load
@@ -518,13 +516,13 @@
 
 	PRINTK_1(TRACE_MWAVE, "mwavedd::mwave_exit entry\n");
 
-	for (i = 0; i < nr_registered_attrs; i++)
+	for (i = 0; i < pDrvData->nr_registered_attrs; i++)
 		device_remove_file(&mwave_device, mwave_dev_attrs[i]);
-	nr_registered_attrs = 0;
+	pDrvData->nr_registered_attrs = 0;
 
-	if (device_registered) {
+	if (pDrvData->device_registered) {
 		device_unregister(&mwave_device);
-		device_registered = 0;
+		pDrvData->device_registered = FALSE;
 	}
 
 	if ( pDrvData->sLine >= 0 ) {
@@ -650,7 +648,7 @@
 
 	if (device_register(&mwave_device))
 		goto cleanup_error;
-	device_registered = 1;
+	pDrvData->device_registered = TRUE;
 	for (i = 0; i < ARRAY_SIZE(mwave_dev_attrs); i++) {
 		if(device_create_file(&mwave_device, mwave_dev_attrs[i])) {
 			PRINTK_ERROR(KERN_ERR_MWAVE
@@ -659,7 +657,7 @@
 					mwave_dev_attrs[i]->attr.name);
 			goto cleanup_error;
 		}
-		nr_registered_attrs++;
+		pDrvData->nr_registered_attrs++;
 	}
 
 	/* SUCCESS! */
diff -Nru a/drivers/char/mwave/mwavedd.h b/drivers/char/mwave/mwavedd.h
--- a/drivers/char/mwave/mwavedd.h	Wed Apr 30 22:28:10 2003
+++ b/drivers/char/mwave/mwavedd.h	Wed Apr 30 22:28:10 2003
@@ -140,6 +140,8 @@
 	MWAVE_IPC IPCs[16];
 	BOOLEAN bMwaveDevRegistered;
 	short sLine;
+	int nr_registered_attrs;
+	int device_registered;
 
 } MWAVE_DEVICE_DATA, *pMWAVE_DEVICE_DATA;
 
diff -Nru a/drivers/char/mwave/tp3780i.c b/drivers/char/mwave/tp3780i.c
--- a/drivers/char/mwave/tp3780i.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/char/mwave/tp3780i.c	Wed Apr 30 22:28:04 2003
@@ -96,13 +96,14 @@
 }
 
 
-static void UartInterrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t UartInterrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	PRINTK_3(TRACE_TP3780I,
 		"tp3780i::UartInterrupt entry irq %x dev_id %x\n", irq, (int) dev_id);
+	return IRQ_HANDLED;
 }
 
-static void DspInterrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t DspInterrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd;
 	DSP_3780I_CONFIG_SETTINGS *pSettings = &pDrvData->rBDData.rDspSettings;
@@ -150,6 +151,7 @@
 			"tp3780i::DspInterrupt, return false from dsp3780i_GetIPCSource\n");
 	}
 	PRINTK_1(TRACE_TP3780I, "tp3780i::DspInterrupt exit\n");
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/char/mxser.c b/drivers/char/mxser.c
--- a/drivers/char/mxser.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/char/mxser.c	Wed Apr 30 22:28:12 2003
@@ -94,7 +94,7 @@
 #define 	UART_MCR_AFE		0x20
 #define 	UART_LSR_SPECIAL	0x1E
 
-#define PORTNO(x)		(minor((x)->device) - (x)->driver.minor_start)
+#define PORTNO(x)		((x)->index)
 
 #define RELEVANT_IFLAG(iflag)	(iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
 
@@ -348,7 +348,7 @@
 static void mxser_stop(struct tty_struct *);
 static void mxser_start(struct tty_struct *);
 static void mxser_hangup(struct tty_struct *);
-static void mxser_interrupt(int, void *, struct pt_regs *);
+static irqreturn_t mxser_interrupt(int, void *, struct pt_regs *);
 static inline void mxser_receive_chars(struct mxser_struct *, int *);
 static inline void mxser_transmit_chars(struct mxser_struct *);
 static inline void mxser_check_modem_status(struct mxser_struct *, int);
@@ -758,7 +758,7 @@
 		return (retval);
 
 	if ((info->count == 1) && (info->flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->normal_termios;
 		else
 			*tty->termios = info->callout_termios;
@@ -862,8 +862,8 @@
 		}
 	}
 	mxser_shutdown(info);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -1362,13 +1362,14 @@
 /*
  * This is the serial driver's generic interrupt routine
  */
-static void mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	int status, i;
 	struct mxser_struct *info;
 	struct mxser_struct *port;
 	int max, irqbits, bits, msr;
 	int pass_counter = 0;
+	int handled = 0;
 
 	port = 0;
 	for (i = 0; i < MXSER_BOARDS; i++) {
@@ -1379,15 +1380,16 @@
 	}
 
 	if (i == MXSER_BOARDS)
-		return;
+		return IRQ_NONE;
 	if (port == 0)
-		return;
+		return IRQ_NONE;
 	max = mxser_numports[mxsercfg[i].board_type];
 
 	while (1) {
 		irqbits = inb(port->vector) & port->vectormask;
 		if (irqbits == port->vectormask)
 			break;
+		handled = 1;
 		for (i = 0, bits = 1; i < max; i++, irqbits |= bits, bits <<= 1) {
 			if (irqbits == port->vectormask)
 				break;
@@ -1417,6 +1419,7 @@
 			break;	/* Prevent infinite loops */
 		}
 	}
+	return IRQ_RETVAL(handled);
 }
 
 static inline void mxser_receive_chars(struct mxser_struct *info,
@@ -1574,7 +1577,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		if (info->flags & ASYNC_NORMAL_ACTIVE)
 			return (-EBUSY);
 		if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
diff -Nru a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c
--- a/drivers/char/n_hdlc.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/char/n_hdlc.c	Wed Apr 30 22:28:06 2003
@@ -9,7 +9,7 @@
  *	Al Longyear <longyear@netcom.com>, Paul Mackerras <Paul.Mackerras@cs.anu.edu.au>
  *
  * Original release 01/11/99
- * $Id: n_hdlc.c,v 4.2 2002/10/10 14:52:41 paulkf Exp $
+ * $Id: n_hdlc.c,v 4.6 2003/04/21 19:14:07 paulkf Exp $
  *
  * This code is released under the GNU General Public License (GPL)
  *
@@ -78,7 +78,7 @@
  */
 
 #define HDLC_MAGIC 0x239e
-#define HDLC_VERSION "$Revision: 4.2 $"
+#define HDLC_VERSION "$Revision: 4.6 $"
 
 #include <linux/version.h>
 #include <linux/config.h>
@@ -171,9 +171,9 @@
 /*
  * HDLC buffer list manipulation functions
  */
-void n_hdlc_buf_list_init(N_HDLC_BUF_LIST *list);
-void n_hdlc_buf_put(N_HDLC_BUF_LIST *list,N_HDLC_BUF *buf);
-N_HDLC_BUF* n_hdlc_buf_get(N_HDLC_BUF_LIST *list);
+static void n_hdlc_buf_list_init(N_HDLC_BUF_LIST *list);
+static void n_hdlc_buf_put(N_HDLC_BUF_LIST *list,N_HDLC_BUF *buf);
+static N_HDLC_BUF* n_hdlc_buf_get(N_HDLC_BUF_LIST *list);
 
 /* Local functions */
 
@@ -299,7 +299,6 @@
 			n_hdlc->tty = n_hdlc->backup_tty;
 		} else {
 			n_hdlc_release (n_hdlc);
-			MOD_DEC_USE_COUNT;
 		}
 	}
 	
@@ -320,9 +319,9 @@
 	struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
 
 	if (debuglevel >= DEBUG_LEVEL_INFO)	
-		printk("%s(%d)n_hdlc_tty_open() called (major=%u,minor=%u)\n",
+		printk("%s(%d)n_hdlc_tty_open() called (device=%s)\n",
 		__FILE__,__LINE__,
-		major(tty->device), minor(tty->device));
+		tty->name);
 		
 	/* There should not be an existing table for this slot. */
 	if (n_hdlc) {
@@ -339,8 +338,6 @@
 	tty->disc_data = n_hdlc;
 	n_hdlc->tty    = tty;
 	
-	MOD_INC_USE_COUNT;
-	
 #if defined(TTY_NO_WRITE_SPLIT)
 	/* change tty_io write() to not split large writes into 8K chunks */
 	set_bit(TTY_NO_WRITE_SPLIT,&tty->flags);
@@ -351,8 +348,8 @@
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer (tty);
 
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer (tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer (tty);
 		
 	if (debuglevel >= DEBUG_LEVEL_INFO)	
 		printk("%s(%d)n_hdlc_tty_open() success\n",__FILE__,__LINE__);
@@ -406,7 +403,7 @@
 			
 		/* Send the next block of data to device */
 		tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
-		actual = tty->driver.write(tty, 0, tbuf->buf, tbuf->count);
+		actual = tty->driver->write(tty, 0, tbuf->buf, tbuf->count);
 		    
 		/* if transmit error, throw frame away by */
 		/* pretending it was accepted by driver */
@@ -783,8 +780,8 @@
 
 	case TIOCOUTQ:
 		/* get the pending tx byte count in the driver */
-		count = tty->driver.chars_in_buffer ?
-				tty->driver.chars_in_buffer(tty) : 0;
+		count = tty->driver->chars_in_buffer ?
+				tty->driver->chars_in_buffer(tty) : 0;
 		/* add size of next output frame in queue */
 		spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock,flags);
 		if (n_hdlc->tx_buf_list.head)
@@ -903,7 +900,7 @@
  * Arguments:	 	list	pointer to buffer list
  * Return Value:	None	
  */
-void n_hdlc_buf_list_init(N_HDLC_BUF_LIST *list)
+static void n_hdlc_buf_list_init(N_HDLC_BUF_LIST *list)
 {
 	memset(list,0,sizeof(N_HDLC_BUF_LIST));
 	spin_lock_init(&list->spinlock);
@@ -920,7 +917,7 @@
  * 
  * Return Value:	None	
  */
-void n_hdlc_buf_put(N_HDLC_BUF_LIST *list,N_HDLC_BUF *buf)
+static void n_hdlc_buf_put(N_HDLC_BUF_LIST *list,N_HDLC_BUF *buf)
 {
 	unsigned long flags;
 	spin_lock_irqsave(&list->spinlock,flags);
@@ -950,7 +947,7 @@
  * 
  * 	pointer to HDLC buffer if available, otherwise NULL
  */
-N_HDLC_BUF* n_hdlc_buf_get(N_HDLC_BUF_LIST *list)
+static N_HDLC_BUF* n_hdlc_buf_get(N_HDLC_BUF_LIST *list)
 {
 	unsigned long flags;
 	N_HDLC_BUF *buf;
@@ -971,7 +968,25 @@
 
 static int __init n_hdlc_init(void)
 {
-	static struct tty_ldisc	n_hdlc_ldisc;
+	static struct tty_ldisc	n_hdlc_ldisc = {
+		TTY_LDISC_MAGIC,    /* magic */
+		"hdlc",             /* name */
+		0,                  /* num */
+		0,                  /* flags */
+		n_hdlc_tty_open,    /* open */
+		n_hdlc_tty_close,   /* close */
+		0,                  /* flush_buffer */
+		0,                  /* chars_in_buffer */
+		n_hdlc_tty_read,    /* read */
+		n_hdlc_tty_write,   /* write */
+		n_hdlc_tty_ioctl,   /* ioctl */
+		0,                  /* set_termios */
+		n_hdlc_tty_poll,    /* poll */
+		n_hdlc_tty_receive, /* receive_buf */
+		n_hdlc_tty_room,    /* receive_room */
+		n_hdlc_tty_wakeup,  /* write_wakeup */
+		THIS_MODULE         /* owner */
+	};
 	int    status;
 
 	/* range check maxframe arg */
@@ -982,21 +997,6 @@
 
 	printk("HDLC line discipline: version %s, maxframe=%u\n", 
 		szVersion, maxframe);
-
-	/* Register the tty discipline */
-	
-	memset(&n_hdlc_ldisc, 0, sizeof (n_hdlc_ldisc));
-	n_hdlc_ldisc.magic		= TTY_LDISC_MAGIC;
-	n_hdlc_ldisc.name          	= "hdlc";
-	n_hdlc_ldisc.open		= n_hdlc_tty_open;
-	n_hdlc_ldisc.close		= n_hdlc_tty_close;
-	n_hdlc_ldisc.read		= n_hdlc_tty_read;
-	n_hdlc_ldisc.write		= n_hdlc_tty_write;
-	n_hdlc_ldisc.ioctl		= n_hdlc_tty_ioctl;
-	n_hdlc_ldisc.poll		= n_hdlc_tty_poll;
-	n_hdlc_ldisc.receive_room	= n_hdlc_tty_room;
-	n_hdlc_ldisc.receive_buf	= n_hdlc_tty_receive;
-	n_hdlc_ldisc.write_wakeup	= n_hdlc_tty_wakeup;
 
 	status = tty_register_ldisc(N_HDLC, &n_hdlc_ldisc);
 	if (!status)
diff -Nru a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c
--- a/drivers/char/n_r3964.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/char/n_r3964.c	Wed Apr 30 22:28:17 2003
@@ -418,9 +418,9 @@
    if(tty==NULL)
       return;
 
-   if(tty->driver.put_char)
+   if(tty->driver->put_char)
    {
-      tty->driver.put_char(tty, ch);
+      tty->driver->put_char(tty, ch);
    }
    pInfo->bcc ^= ch;
 }
@@ -432,9 +432,9 @@
    if(tty==NULL)
       return;
 
-   if(tty->driver.flush_chars)
+   if(tty->driver->flush_chars)
    {
-      tty->driver.flush_chars(tty);
+      tty->driver->flush_chars(tty);
    }
 }
 
@@ -507,8 +507,8 @@
       return;
    }
 
-   if(tty->driver.write_room)
-      room=tty->driver.write_room(tty);
+   if(tty->driver->write_room)
+      room=tty->driver->write_room(tty);
 
    TRACE_PS("transmit_block %x, room %d, length %d", 
           (int)pBlock, room, pBlock->length);
diff -Nru a/drivers/char/n_tty.c b/drivers/char/n_tty.c
--- a/drivers/char/n_tty.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/char/n_tty.c	Wed Apr 30 22:28:03 2003
@@ -117,8 +117,8 @@
 {
 	if (tty->count &&
 	    test_and_clear_bit(TTY_THROTTLED, &tty->flags) && 
-	    tty->driver.unthrottle)
-		tty->driver.unthrottle(tty);
+	    tty->driver->unthrottle)
+		tty->driver->unthrottle(tty);
 }
 
 /*
@@ -183,7 +183,7 @@
 {
 	int	space, spaces;
 
-	space = tty->driver.write_room(tty);
+	space = tty->driver->write_room(tty);
 	if (!space)
 		return -1;
 
@@ -195,7 +195,7 @@
 			if (O_ONLCR(tty)) {
 				if (space < 2)
 					return -1;
-				tty->driver.put_char(tty, '\r');
+				tty->driver->put_char(tty, '\r');
 				tty->column = 0;
 			}
 			tty->canon_column = tty->column;
@@ -217,7 +217,7 @@
 				if (space < spaces)
 					return -1;
 				tty->column += spaces;
-				tty->driver.write(tty, 0, "        ", spaces);
+				tty->driver->write(tty, 0, "        ", spaces);
 				return 0;
 			}
 			tty->column += spaces;
@@ -234,7 +234,7 @@
 			break;
 		}
 	}
-	tty->driver.put_char(tty, c);
+	tty->driver->put_char(tty, c);
 	return 0;
 }
 
@@ -250,7 +250,7 @@
 	int 	i;
 	char	*cp;
 
-	space = tty->driver.write_room(tty);
+	space = tty->driver->write_room(tty);
 	if (!space)
 		return 0;
 	if (nr > space)
@@ -296,9 +296,9 @@
 		}
 	}
 break_out:
-	if (tty->driver.flush_chars)
-		tty->driver.flush_chars(tty);
-	i = tty->driver.write(tty, 0, buf, i);	
+	if (tty->driver->flush_chars)
+		tty->driver->flush_chars(tty);
+	i = tty->driver->write(tty, 0, buf, i);	
 	return i;
 }
 
@@ -306,7 +306,7 @@
 
 static inline void put_char(unsigned char c, struct tty_struct *tty)
 {
-	tty->driver.put_char(tty, c);
+	tty->driver->put_char(tty, c);
 }
 
 /* Must be called only when L_ECHO(tty) is true. */
@@ -452,8 +452,8 @@
 		kill_pg(tty->pgrp, sig, 1);
 	if (flush || !L_NOFLSH(tty)) {
 		n_tty_flush_buffer(tty);
-		if (tty->driver.flush_buffer)
-			tty->driver.flush_buffer(tty);
+		if (tty->driver->flush_buffer)
+			tty->driver->flush_buffer(tty);
 	}
 }
 
@@ -782,8 +782,8 @@
 				break;
 			}
 		}
-		if (tty->driver.flush_chars)
-			tty->driver.flush_chars(tty);
+		if (tty->driver->flush_chars)
+			tty->driver->flush_chars(tty);
 	}
 
 	if (!tty->icanon && (tty->read_cnt >= tty->minimum_to_wake)) {
@@ -800,8 +800,8 @@
 	if (n_tty_receive_room(tty) < TTY_THRESHOLD_THROTTLE) {
 		/* check TTY_THROTTLED first so it indicates our state */
 		if (!test_and_set_bit(TTY_THROTTLED, &tty->flags) &&
-		    tty->driver.throttle)
-			tty->driver.throttle(tty);
+		    tty->driver->throttle)
+			tty->driver->throttle(tty);
 	}
 }
 
@@ -869,7 +869,7 @@
 		tty->raw = 1;
 		if ((I_IGNBRK(tty) || (!I_BRKINT(tty) && !I_PARMRK(tty))) &&
 		    (I_IGNPAR(tty) || !I_INPCK(tty)) &&
-		    (tty->driver.flags & TTY_DRIVER_REAL_RAW))
+		    (tty->driver->flags & TTY_DRIVER_REAL_RAW))
 			tty->real_raw = 1;
 		else
 			tty->real_raw = 0;
@@ -1205,10 +1205,10 @@
 					break;
 				b++; nr--;
 			}
-			if (tty->driver.flush_chars)
-				tty->driver.flush_chars(tty);
+			if (tty->driver->flush_chars)
+				tty->driver->flush_chars(tty);
 		} else {
-			c = tty->driver.write(tty, 1, b, nr);
+			c = tty->driver->write(tty, 1, b, nr);
 			if (c < 0) {
 				retval = c;
 				goto break_out;
@@ -1251,7 +1251,7 @@
 		else
 			tty->minimum_to_wake = 1;
 	}
-	if (tty->driver.chars_in_buffer(tty) < WAKEUP_CHARS)
+	if (tty->driver->chars_in_buffer(tty) < WAKEUP_CHARS)
 		mask |= POLLOUT | POLLWRNORM;
 	return mask;
 }
diff -Nru a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
--- a/drivers/char/pcmcia/synclink_cs.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/char/pcmcia/synclink_cs.c	Wed Apr 30 22:28:07 2003
@@ -1,7 +1,7 @@
 /*
  * linux/drivers/char/pcmcia/synclink_cs.c
  *
- * $Id: synclink_cs.c,v 4.4 2002/10/10 14:53:37 paulkf Exp $
+ * $Id: synclink_cs.c,v 4.6 2003/04/21 17:46:55 paulkf Exp $
  *
  * Device driver for Microgate SyncLink PC Card
  * multiprotocol serial adapter.
@@ -442,9 +442,9 @@
 /*
  * ioctl handlers
  */
-static int set_modem_info(MGSLPC_INFO *info, unsigned int cmd,
-			  unsigned int *value);
-static int get_modem_info(MGSLPC_INFO *info, unsigned int *value);
+static int tiocmget(struct tty_struct *tty, struct file *file);
+static int tiocmset(struct tty_struct *tty, struct file *file,
+		    unsigned int set, unsigned int clear);
 static int get_stats(MGSLPC_INFO *info, struct mgsl_icount *user_icount);
 static int get_params(MGSLPC_INFO *info, MGSL_PARAMS *user_params);
 static int set_params(MGSLPC_INFO *info, MGSL_PARAMS *new_params);
@@ -496,7 +496,7 @@
 MODULE_LICENSE("GPL");
 
 static char *driver_name = "SyncLink PC Card driver";
-static char *driver_version = "$Revision: 4.4 $";
+static char *driver_version = "$Revision: 4.6 $";
 
 static struct tty_driver serial_driver, callout_driver;
 static int serial_refcount;
@@ -527,12 +527,6 @@
 static dev_info_t dev_info = "synclink_cs";
 static dev_link_t *dev_list = NULL;
 
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
 /*
  * 1st function defined in .text section. Calling this function in
  * init_module() followed by a breakpoint allows a remote debugger
@@ -848,7 +842,7 @@
 }
 
 static inline int mgslpc_paranoia_check(MGSLPC_INFO *info,
-					kdev_t device, const char *routine)
+					char *name, const char *routine)
 {
 #ifdef MGSLPC_PARANOIA_CHECK
 	static const char *badmagic =
@@ -857,11 +851,11 @@
 		"Warning: null mgslpc_info for (%s) in %s\n";
 
 	if (!info) {
-		printk(badinfo, cdevname(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (info->magic != MGSLPC_MAGIC) {
-		printk(badmagic, cdevname(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -901,7 +895,7 @@
 	MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data;
 	unsigned long flags;
 	
-	if (mgslpc_paranoia_check(info, tty->device, "tx_pause"))
+	if (mgslpc_paranoia_check(info, tty->name, "tx_pause"))
 		return;
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("tx_pause(%s)\n",info->device_name);	
@@ -917,7 +911,7 @@
 	MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data;
 	unsigned long flags;
 	
-	if (mgslpc_paranoia_check(info, tty->device, "tx_release"))
+	if (mgslpc_paranoia_check(info, tty->name, "tx_release"))
 		return;
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("tx_release(%s)\n",info->device_name);	
@@ -1703,7 +1697,7 @@
 			__FILE__,__LINE__,ch,info->device_name);
 	}
 
-	if (mgslpc_paranoia_check(info, tty->device, "mgslpc_put_char"))
+	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_put_char"))
 		return;
 
 	if (!tty || !info->tx_buf)
@@ -1734,7 +1728,7 @@
 		printk( "%s(%d):mgslpc_flush_chars() entry on %s tx_count=%d\n",
 			__FILE__,__LINE__,info->device_name,info->tx_count);
 	
-	if (mgslpc_paranoia_check(info, tty->device, "mgslpc_flush_chars"))
+	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_flush_chars"))
 		return;
 
 	if (info->tx_count <= 0 || tty->stopped ||
@@ -1773,7 +1767,7 @@
 		printk( "%s(%d):mgslpc_write(%s) count=%d\n",
 			__FILE__,__LINE__,info->device_name,count);
 	
-	if (mgslpc_paranoia_check(info, tty->device, "mgslpc_write") ||
+	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write") ||
 	    !tty || !info->tx_buf)
 		goto cleanup;
 
@@ -1835,7 +1829,7 @@
 	MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data;
 	int ret;
 				
-	if (mgslpc_paranoia_check(info, tty->device, "mgslpc_write_room"))
+	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write_room"))
 		return 0;
 
 	if (info->params.mode == MGSL_MODE_HDLC) {
@@ -1867,7 +1861,7 @@
 		printk("%s(%d):mgslpc_chars_in_buffer(%s)\n",
 			 __FILE__,__LINE__, info->device_name );
 			 
-	if (mgslpc_paranoia_check(info, tty->device, "mgslpc_chars_in_buffer"))
+	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_chars_in_buffer"))
 		return 0;
 		
 	if (info->params.mode == MGSL_MODE_HDLC)
@@ -1893,7 +1887,7 @@
 		printk("%s(%d):mgslpc_flush_buffer(%s) entry\n",
 			 __FILE__,__LINE__, info->device_name );
 	
-	if (mgslpc_paranoia_check(info, tty->device, "mgslpc_flush_buffer"))
+	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_flush_buffer"))
 		return;
 		
 	spin_lock_irqsave(&info->lock,flags); 
@@ -1918,7 +1912,7 @@
 		printk("%s(%d):mgslpc_send_xchar(%s,%d)\n",
 			 __FILE__,__LINE__, info->device_name, ch );
 			 
-	if (mgslpc_paranoia_check(info, tty->device, "mgslpc_send_xchar"))
+	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_send_xchar"))
 		return;
 
 	info->x_char = ch;
@@ -1941,7 +1935,7 @@
 		printk("%s(%d):mgslpc_throttle(%s) entry\n",
 			 __FILE__,__LINE__, info->device_name );
 
-	if (mgslpc_paranoia_check(info, tty->device, "mgslpc_throttle"))
+	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_throttle"))
 		return;
 	
 	if (I_IXOFF(tty))
@@ -1966,7 +1960,7 @@
 		printk("%s(%d):mgslpc_unthrottle(%s) entry\n",
 			 __FILE__,__LINE__, info->device_name );
 
-	if (mgslpc_paranoia_check(info, tty->device, "mgslpc_unthrottle"))
+	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_unthrottle"))
 		return;
 	
 	if (I_IXOFF(tty)) {
@@ -2326,94 +2320,56 @@
 	return rc;
 }
 
-/* Return state of the serial control/status signals
- * 	
- * Arguments:	 	info	pointer to device instance data
- * 			value	pointer to int to hold returned info
- * 	
- * Return Value:	0 if success, otherwise error code
+/* return the state of the serial control and status signals
  */
-static int get_modem_info(MGSLPC_INFO * info, unsigned int *value)
+static int tiocmget(struct tty_struct *tty, struct file *file)
 {
+	MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data;
 	unsigned int result;
  	unsigned long flags;
-	int err;
- 
+
 	spin_lock_irqsave(&info->lock,flags);
  	get_signals(info);
 	spin_unlock_irqrestore(&info->lock,flags);
 
-	result = ((info->serial_signals & SerialSignal_RTS) ? TIOCM_RTS:0) |
-		 ((info->serial_signals & SerialSignal_DTR) ? TIOCM_DTR:0) |
-		 ((info->serial_signals & SerialSignal_DCD) ? TIOCM_CAR:0) |
-		 ((info->serial_signals & SerialSignal_RI)  ? TIOCM_RNG:0) |
-		 ((info->serial_signals & SerialSignal_DSR) ? TIOCM_DSR:0) |
-		 ((info->serial_signals & SerialSignal_CTS) ? TIOCM_CTS:0);
+	result = ((info->serial_signals & SerialSignal_RTS) ? TIOCM_RTS:0) +
+		((info->serial_signals & SerialSignal_DTR) ? TIOCM_DTR:0) +
+		((info->serial_signals & SerialSignal_DCD) ? TIOCM_CAR:0) +
+		((info->serial_signals & SerialSignal_RI)  ? TIOCM_RNG:0) +
+		((info->serial_signals & SerialSignal_DSR) ? TIOCM_DSR:0) +
+		((info->serial_signals & SerialSignal_CTS) ? TIOCM_CTS:0);
 
 	if (debug_level >= DEBUG_LEVEL_INFO)
-		printk("mgslpc_get_modem_info %s value=%08X\n", info->device_name, result);
-			
-	PUT_USER(err,result,value);
-	return err ? -EFAULT : 0;
+		printk("%s(%d):%s tiocmget() value=%08X\n",
+			 __FILE__,__LINE__, info->device_name, result );
+	return result;
 }
 
-/* Set the state of the modem control signals (DTR/RTS)
- * 	
- * Arguments:
- * 
- * 	info	pointer to device instance data
- * 	cmd	signal command: TIOCMBIS = set bit TIOCMBIC = clear bit
- *		TIOCMSET = set/clear signal values
- * 	value	bit mask for command
- * 	
- * Return Value:	0 if success, otherwise error code
+/* set modem control signals (DTR/RTS)
  */
-static int set_modem_info(MGSLPC_INFO * info, unsigned int cmd,
-			  unsigned int *value)
+static int tiocmset(struct tty_struct *tty, struct file *file,
+		    unsigned int set, unsigned int clear)
 {
- 	int error;
- 	unsigned int arg;
+	MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data;
  	unsigned long flags;
- 
+
 	if (debug_level >= DEBUG_LEVEL_INFO)
-		printk("mgslpc_set_modem_info %s\n", info->device_name);
-			
- 	GET_USER(error,arg,value);
- 	if (error)
- 		return error;
-		
- 	switch (cmd) {
- 	case TIOCMBIS: 
- 		if (arg & TIOCM_RTS)
- 			info->serial_signals |= SerialSignal_RTS;
- 		if (arg & TIOCM_DTR)
- 			info->serial_signals |= SerialSignal_DTR;
- 		break;
- 	case TIOCMBIC:
- 		if (arg & TIOCM_RTS)
- 			info->serial_signals &= ~SerialSignal_RTS;
- 		if (arg & TIOCM_DTR)
- 			info->serial_signals &= ~SerialSignal_DTR;
- 		break;
- 	case TIOCMSET:
- 		if (arg & TIOCM_RTS)
- 			info->serial_signals |= SerialSignal_RTS;
-		else
- 			info->serial_signals &= ~SerialSignal_RTS;
-		
- 		if (arg & TIOCM_DTR)
- 			info->serial_signals |= SerialSignal_DTR;
-		else
- 			info->serial_signals &= ~SerialSignal_DTR;
- 		break;
- 	default:
- 		return -EINVAL;
- 	}
-	
+		printk("%s(%d):%s tiocmset(%x,%x)\n",
+			__FILE__,__LINE__,info->device_name, set, clear);
+
+	if (set & TIOCM_RTS)
+		info->serial_signals |= SerialSignal_RTS;
+	if (set & TIOCM_DTR)
+		info->serial_signals |= SerialSignal_DTR;
+	if (clear & TIOCM_RTS)
+		info->serial_signals &= ~SerialSignal_RTS;
+	if (clear & TIOCM_DTR)
+		info->serial_signals &= ~SerialSignal_DTR;
+
 	spin_lock_irqsave(&info->lock,flags);
  	set_signals(info);
 	spin_unlock_irqrestore(&info->lock,flags);
-	
+
 	return 0;
 }
 
@@ -2431,7 +2387,7 @@
 		printk("%s(%d):mgslpc_break(%s,%d)\n",
 			 __FILE__,__LINE__, info->device_name, break_state);
 			 
-	if (mgslpc_paranoia_check(info, tty->device, "mgslpc_break"))
+	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_break"))
 		return;
 
 	spin_lock_irqsave(&info->lock,flags);
@@ -2462,7 +2418,7 @@
 		printk("%s(%d):mgslpc_ioctl %s cmd=%08X\n", __FILE__,__LINE__,
 			info->device_name, cmd );
 	
-	if (mgslpc_paranoia_check(info, tty->device, "mgslpc_ioctl"))
+	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_ioctl"))
 		return -ENODEV;
 
 	if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
@@ -2482,12 +2438,6 @@
 	unsigned long flags;
 	
 	switch (cmd) {
-	case TIOCMGET:
-		return get_modem_info(info, (unsigned int *) arg);
-	case TIOCMBIS:
-	case TIOCMBIC:
-	case TIOCMSET:
-		return set_modem_info(info, cmd, (unsigned int *) arg);
 	case MGSL_IOCGPARAMS:
 		return get_params(info,(MGSL_PARAMS *)arg);
 	case MGSL_IOCSPARAMS:
@@ -2560,7 +2510,7 @@
 	
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):mgslpc_set_termios %s\n", __FILE__,__LINE__,
-			tty->driver.name );
+			tty->driver->name );
 	
 	/* just return if nothing has changed */
 	if ((tty->termios->c_cflag == old_termios->c_cflag)
@@ -2604,7 +2554,7 @@
 {
 	MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data;
 
-	if (!info || mgslpc_paranoia_check(info, tty->device, "mgslpc_close"))
+	if (!info || mgslpc_paranoia_check(info, tty->name, "mgslpc_close"))
 		return;
 	
 	if (debug_level >= DEBUG_LEVEL_INFO)
@@ -2659,8 +2609,8 @@
  	if (info->flags & ASYNC_INITIALIZED)
  		mgslpc_wait_until_sent(tty, info->timeout);
 
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 		
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
@@ -2686,8 +2636,7 @@
 cleanup:			
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__,
-			tty->driver.name, info->count);
-	MOD_DEC_USE_COUNT;
+			tty->driver->name, info->count);
 }
 
 /* Wait until the transmitter is empty.
@@ -2704,7 +2653,7 @@
 		printk("%s(%d):mgslpc_wait_until_sent(%s) entry\n",
 			 __FILE__,__LINE__, info->device_name );
       
-	if (mgslpc_paranoia_check(info, tty->device, "mgslpc_wait_until_sent"))
+	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_wait_until_sent"))
 		return;
 
 	if (!(info->flags & ASYNC_INITIALIZED))
@@ -2766,7 +2715,7 @@
 		printk("%s(%d):mgslpc_hangup(%s)\n",
 			 __FILE__,__LINE__, info->device_name );
 			 
-	if (mgslpc_paranoia_check(info, tty->device, "mgslpc_hangup"))
+	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_hangup"))
 		return;
 
 	mgslpc_flush_buffer(tty);
@@ -2792,9 +2741,9 @@
 	
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):block_til_ready on %s\n",
-			 __FILE__,__LINE__, tty->driver.name );
+			 __FILE__,__LINE__, tty->driver->name );
 
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		/* this is a callout device */
 		/* just verify that normal device is not in use */
 		if (info->flags & ASYNC_NORMAL_ACTIVE)
@@ -2840,7 +2789,7 @@
 	
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):block_til_ready before block on %s count=%d\n",
-			 __FILE__,__LINE__, tty->driver.name, info->count );
+			 __FILE__,__LINE__, tty->driver->name, info->count );
 
 	spin_lock_irqsave(&info->lock, flags);
 	if (!tty_hung_up_p(filp)) {
@@ -2884,7 +2833,7 @@
 		
 		if (debug_level >= DEBUG_LEVEL_INFO)
 			printk("%s(%d):block_til_ready blocking on %s count=%d\n",
-				 __FILE__,__LINE__, tty->driver.name, info->count );
+				 __FILE__,__LINE__, tty->driver->name, info->count );
 				 
 		schedule();
 	}
@@ -2898,7 +2847,7 @@
 	
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
-			 __FILE__,__LINE__, tty->driver.name, info->count );
+			 __FILE__,__LINE__, tty->driver->name, info->count );
 			 
 	if (!retval)
 		info->flags |= ASYNC_NORMAL_ACTIVE;
@@ -2913,7 +2862,7 @@
 	unsigned long flags;
 
 	/* verify range of specified line number */	
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if ((line < 0) || (line >= mgslpc_device_count)) {
 		printk("%s(%d):mgslpc_open with illegal line #%d.\n",
 			__FILE__,__LINE__,line);
@@ -2932,15 +2881,13 @@
 	
 	tty->driver_data = info;
 	info->tty = tty;
-	if (mgslpc_paranoia_check(info, tty->device, "mgslpc_open"))
+	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_open"))
 		return -ENODEV;
 		
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
-			 __FILE__,__LINE__,tty->driver.name, info->count);
+			 __FILE__,__LINE__,tty->driver->name, info->count);
 
-	MOD_INC_USE_COUNT;
-	
 	/* If port is closing, signal caller to try again */
 	if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){
 		if (info->flags & ASYNC_CLOSING)
@@ -2978,7 +2925,7 @@
 
 	if ((info->count == 1) &&
 	    info->flags & ASYNC_SPLIT_TERMIOS) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->normal_termios;
 		else 
 			*tty->termios = info->callout_termios;
@@ -2995,7 +2942,6 @@
 	
 cleanup:			
 	if (retval) {
-		MOD_DEC_USE_COUNT;
 		if(info->count)
 			info->count--;
 	}
@@ -3247,6 +3193,7 @@
 	
     memset(&serial_driver, 0, sizeof(struct tty_driver));
     serial_driver.magic = TTY_DRIVER_MAGIC;
+    serial_driver.owner = THIS_MODULE;
     serial_driver.driver_name = "synclink_cs";
     serial_driver.name = "ttySLP";
     serial_driver.major = ttymajor;
@@ -3282,6 +3229,8 @@
     serial_driver.stop = tx_pause;
     serial_driver.start = tx_release;
     serial_driver.hangup = mgslpc_hangup;
+    serial_driver.tiocmget = tiocmget;
+    serial_driver.tiocmset = tiocmset;
 	
     /*
      * The callout device is just like normal device except for
@@ -4386,7 +4335,7 @@
 {
 	MGSLPC_INFO *info = d->priv;
 	int err;
-	long flags;
+	unsigned long flags;
 
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("mgslpc_sppp_open(%s)\n",info->netname);	
@@ -4398,7 +4347,6 @@
 		return -EBUSY;
 	}
 	info->netcount=1;
-	MOD_INC_USE_COUNT;
 	spin_unlock_irqrestore(&info->netlock, flags);
 
 	/* claim resources and init adapter */
@@ -4421,7 +4369,6 @@
 open_fail:
 	spin_lock_irqsave(&info->netlock, flags);
 	info->netcount=0;
-	MOD_DEC_USE_COUNT;
 	spin_unlock_irqrestore(&info->netlock, flags);
 	return err;
 }
@@ -4429,7 +4376,7 @@
 void mgslpc_sppp_tx_timeout(struct net_device *dev)
 {
 	MGSLPC_INFO *info = dev->priv;
-	long flags;
+	unsigned long flags;
 
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("mgslpc_sppp_tx_timeout(%s)\n",info->netname);	
@@ -4491,7 +4438,6 @@
 
 	spin_lock_irqsave(&info->netlock, flags);
 	info->netcount=0;
-	MOD_DEC_USE_COUNT;
 	spin_unlock_irqrestore(&info->netlock, flags);
 	return 0;
 }
diff -Nru a/drivers/char/pcxx.c b/drivers/char/pcxx.c
--- a/drivers/char/pcxx.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/char/pcxx.c	Wed Apr 30 22:28:11 2003
@@ -405,7 +405,7 @@
 	int boardnum;
 	int retval;
 
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 
 	if(line < 0 || line >= nbdevs) {
 		printk("line out of range in pcxe_open\n");
@@ -482,7 +482,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		if (ch->asyncflags & ASYNC_NORMAL_ACTIVE)
 			return -EBUSY;
 		if (ch->asyncflags & ASYNC_CALLOUT_ACTIVE) {
@@ -517,7 +517,7 @@
 	save_flags(flags);
 	cli();
 	if((ch->count == 1) && (ch->asyncflags & ASYNC_SPLIT_TERMIOS)) {
-		if(tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if(tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = ch->normal_termios;
 		else 
 			*tty->termios = ch->callout_termios;
@@ -617,8 +617,8 @@
 			tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */
 		}
 	
-		if(tty->driver.flush_buffer)
-			tty->driver.flush_buffer(tty);
+		if(tty->driver->flush_buffer)
+			tty->driver->flush_buffer(tty);
 		if(tty->ldisc.flush_buffer)
 			tty->ldisc.flush_buffer(tty);
 		shutdown(info);
@@ -2070,7 +2070,7 @@
 
 	if(bc->orun) {
 		bc->orun = 0;
-		printk("overrun! DigiBoard device minor=%d\n",minor(tty->device));
+		printk("overrun! DigiBoard device %s\n", tty->name);
 	}
 
 	rxwinon(ch);
diff -Nru a/drivers/char/pty.c b/drivers/char/pty.c
--- a/drivers/char/pty.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/char/pty.c	Wed Apr 30 22:28:07 2003
@@ -52,23 +52,23 @@
 
 #ifdef CONFIG_UNIX98_PTYS
 /* These are global because they are accessed in tty_io.c */
-struct tty_driver ptm_driver[UNIX98_NR_MAJORS];
-struct tty_driver pts_driver[UNIX98_NR_MAJORS];
+struct tty_driver ptm_driver;
+struct tty_driver pts_driver;
 
-static struct tty_struct *ptm_table[UNIX98_NR_MAJORS][NR_PTYS];
-static struct termios *ptm_termios[UNIX98_NR_MAJORS][NR_PTYS];
-static struct termios *ptm_termios_locked[UNIX98_NR_MAJORS][NR_PTYS];
-static struct tty_struct *pts_table[UNIX98_NR_MAJORS][NR_PTYS];
-static struct termios *pts_termios[UNIX98_NR_MAJORS][NR_PTYS];
-static struct termios *pts_termios_locked[UNIX98_NR_MAJORS][NR_PTYS];
-static struct pty_struct ptm_state[UNIX98_NR_MAJORS][NR_PTYS];
+static struct tty_struct *ptm_table[UNIX98_NR_MAJORS*NR_PTYS];
+static struct termios *ptm_termios[UNIX98_NR_MAJORS*NR_PTYS];
+static struct termios *ptm_termios_locked[UNIX98_NR_MAJORS*NR_PTYS];
+static struct tty_struct *pts_table[UNIX98_NR_MAJORS*NR_PTYS];
+static struct termios *pts_termios[UNIX98_NR_MAJORS*NR_PTYS];
+static struct termios *pts_termios_locked[UNIX98_NR_MAJORS*NR_PTYS];
+static struct pty_struct ptm_state[UNIX98_NR_MAJORS*NR_PTYS];
 #endif
 
 static void pty_close(struct tty_struct * tty, struct file * filp)
 {
 	if (!tty)
 		return;
-	if (tty->driver.subtype == PTY_TYPE_MASTER) {
+	if (tty->driver->subtype == PTY_TYPE_MASTER) {
 		if (tty->count > 1)
 			printk("master pty_close: count = %d!!\n", tty->count);
 	} else {
@@ -84,18 +84,12 @@
 	wake_up_interruptible(&tty->link->read_wait);
 	wake_up_interruptible(&tty->link->write_wait);
 	set_bit(TTY_OTHER_CLOSED, &tty->link->flags);
-	if (tty->driver.subtype == PTY_TYPE_MASTER) {
+	if (tty->driver->subtype == PTY_TYPE_MASTER) {
 		set_bit(TTY_OTHER_CLOSED, &tty->flags);
 #ifdef CONFIG_UNIX98_PTYS
-		{
-			unsigned int major = major(tty->device) - UNIX98_PTY_MASTER_MAJOR;
-			if ( major < UNIX98_NR_MAJORS ) {
-				devpts_pty_kill( minor(tty->device)
-			  - tty->driver.minor_start + tty->driver.name_base );
-			}
-		}
+		if (tty->driver == &ptm_driver)
+			devpts_pty_kill(tty->index);
 #endif
-		tty_unregister_device (&tty->link->driver, minor(tty->device));
 		tty_vhangup(tty->link);
 	}
 }
@@ -221,7 +215,7 @@
 	/* The ldisc must report 0 if no characters available to be read */
 	count = to->ldisc.chars_in_buffer(to);
 
-	if (tty->driver.subtype == PTY_TYPE_SLAVE) return count;
+	if (tty->driver->subtype == PTY_TYPE_SLAVE) return count;
 
 	/* Master side driver ... if the other side's read buffer is less than 
 	 * half full, return 0 to allow writers to proceed; otherwise return
@@ -239,8 +233,7 @@
 #ifdef CONFIG_UNIX98_PTYS
 static int pty_get_device_number(struct tty_struct *tty, unsigned int *value)
 {
-	unsigned int result = minor(tty->device)
-		- tty->driver.minor_start + tty->driver.name_base;
+	unsigned int result = tty->index;
 	return put_user(result, value);
 }
 #endif
@@ -314,10 +307,8 @@
 	retval = -ENODEV;
 	if (!tty || !tty->link)
 		goto out;
-	line = minor(tty->device) - tty->driver.minor_start;
-	if ((line < 0) || (line >= NR_PTYS))
-		goto out;
-	pty = (struct pty_struct *)(tty->driver.driver_state) + line;
+	line = tty->index;
+	pty = (struct pty_struct *)(tty->driver->driver_state) + line;
 	tty->driver_data = pty;
 
 	retval = -EIO;
@@ -357,7 +348,7 @@
 	pty_driver.owner = THIS_MODULE;
 	pty_driver.driver_name = "pty_master";
 #ifdef CONFIG_DEVFS_FS
-	pty_driver.name = "pty/m%d";
+	pty_driver.name = "pty/m";
 #else
 	pty_driver.name = "pty";
 #endif
@@ -392,7 +383,7 @@
 	pty_slave_driver.driver_name = "pty_slave";
 	pty_slave_driver.proc_entry = 0;
 #ifdef CONFIG_DEVFS_FS
-	pty_slave_driver.name = "pty/s%d";
+	pty_slave_driver.name = "pty/s";
 #else
 	pty_slave_driver.name = "ttyp";
 #endif
@@ -427,52 +418,41 @@
 #ifdef CONFIG_UNIX98_PTYS
 	devfs_mk_dir("pts");
 	printk("pty: %d Unix98 ptys configured\n", UNIX98_NR_MAJORS*NR_PTYS);
-	for ( i = 0 ; i < UNIX98_NR_MAJORS ; i++ ) {
-		int j;
+	ptm_driver = pty_driver;
+	ptm_driver.name = "ptm";
+	ptm_driver.proc_entry = 0;
+	ptm_driver.major = UNIX98_PTY_MASTER_MAJOR;
+	ptm_driver.minor_start = 0;
+	ptm_driver.num = UNIX98_NR_MAJORS * NR_PTYS;
+	ptm_driver.other = &pts_driver;
+	ptm_driver.flags |= TTY_DRIVER_NO_DEVFS;
+	ptm_driver.table = ptm_table;
+	ptm_driver.termios = ptm_termios;
+	ptm_driver.termios_locked = ptm_termios_locked;
+	ptm_driver.driver_state = ptm_state;
 
-		ptm_driver[i] = pty_driver;
-		ptm_driver[i].name = "ptm";
-		ptm_driver[i].proc_entry = 0;
-		ptm_driver[i].major = UNIX98_PTY_MASTER_MAJOR+i;
-		ptm_driver[i].minor_start = 0;
-		ptm_driver[i].name_base = i*NR_PTYS;
-		ptm_driver[i].num = NR_PTYS;
-		ptm_driver[i].other = &pts_driver[i];
-		ptm_driver[i].flags |= TTY_DRIVER_NO_DEVFS;
-		ptm_driver[i].table = ptm_table[i];
-		ptm_driver[i].termios = ptm_termios[i];
-		ptm_driver[i].termios_locked = ptm_termios_locked[i];
-		ptm_driver[i].driver_state = ptm_state[i];
-
-		for (j = 0; j < NR_PTYS; j++)
-			init_waitqueue_head(&ptm_state[i][j].open_wait);
-		
-		pts_driver[i] = pty_slave_driver;
-#ifdef CONFIG_DEVFS_FS
-		pts_driver[i].name = "pts/%d";
-#else
-		pts_driver[i].name = "pts";
-#endif
-		pts_driver[i].proc_entry = 0;
-		pts_driver[i].major = UNIX98_PTY_SLAVE_MAJOR+i;
-		pts_driver[i].minor_start = 0;
-		pts_driver[i].name_base = i*NR_PTYS;
-		pts_driver[i].num = ptm_driver[i].num;
-		pts_driver[i].other = &ptm_driver[i];
-		pts_driver[i].table = pts_table[i];
-		pts_driver[i].termios = pts_termios[i];
-		pts_driver[i].termios_locked = pts_termios_locked[i];
-		pts_driver[i].driver_state = ptm_state[i];
-		
-		ptm_driver[i].ioctl = pty_unix98_ioctl;
-		
-		if (tty_register_driver(&ptm_driver[i]))
-			panic("Couldn't register Unix98 ptm driver major %d",
-			      ptm_driver[i].major);
-		if (tty_register_driver(&pts_driver[i]))
-			panic("Couldn't register Unix98 pts driver major %d",
-			      pts_driver[i].major);
-	}
+	for (i = 0; i < UNIX98_NR_MAJORS*NR_PTYS; i++)
+		init_waitqueue_head(&ptm_state[i].open_wait);
+	
+	pts_driver = pty_slave_driver;
+	pts_driver.name = "pts";
+	pts_driver.proc_entry = 0;
+	pts_driver.major = UNIX98_PTY_SLAVE_MAJOR;
+	pts_driver.minor_start = 0;
+	pts_driver.num = UNIX98_NR_MAJORS * NR_PTYS;
+	pts_driver.other = &ptm_driver;
+	pts_driver.flags |= TTY_DRIVER_NO_DEVFS;
+	pts_driver.table = pts_table;
+	pts_driver.termios = pts_termios;
+	pts_driver.termios_locked = pts_termios_locked;
+	pts_driver.driver_state = ptm_state;
+	
+	ptm_driver.ioctl = pty_unix98_ioctl;
+	
+	if (tty_register_driver(&ptm_driver))
+		panic("Couldn't register Unix98 ptm driver");
+	if (tty_register_driver(&pts_driver))
+		panic("Couldn't register Unix98 pts driver");
 #endif
 	return 0;
 }
diff -Nru a/drivers/char/rio/func.h b/drivers/char/rio/func.h
--- a/drivers/char/rio/func.h	Wed Apr 30 22:28:09 2003
+++ b/drivers/char/rio/func.h	Wed Apr 30 22:28:09 2003
@@ -139,7 +139,7 @@
 int riotopen(struct tty_struct * tty, struct file * filp);
 int riotclose(void  *ptr);
 int RIOCookMode(struct ttystatics *);
-int riotioctl(struct rio_info *, dev_t, register int, register caddr_t); 
+int riotioctl(struct rio_info *, struct tty_struct *, register int, register caddr_t); 
 void ttyseth(struct Port *, struct ttystatics *, struct old_sgttyb *sg);
 
 /* riotable.c */
@@ -166,8 +166,8 @@
 #endif
 
 extern int    rio_pcicopy(char *src, char *dst, int n);
-extern int rio_minor (kdev_t device);
-extern int rio_ismodem (kdev_t device);
+extern int rio_minor (struct tty_struct *tty);
+extern int rio_ismodem (struct tty_struct *tty);
 extern void rio_udelay (int usecs);
 
 extern void rio_start_card_running (struct Host * HostP);
diff -Nru a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
--- a/drivers/char/rio/rio_linux.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/char/rio/rio_linux.c	Wed Apr 30 22:28:11 2003
@@ -293,7 +293,7 @@
 /* This doesn't work. Who's paranoid around here? Not me! */
 
 static inline int rio_paranoia_check(struct rio_port const * port,
-				    kdev_t device, const char *routine)
+				    char *name, const char *routine)
 {
 
   static const char *badmagic =
@@ -302,11 +302,11 @@
     KERN_ERR "rio: Warning: null rio port for device %s in %s\n";
  
   if (!port) {
-    printk (badinfo, cdevname(device), routine);
+    printk (badinfo, name, routine);
     return 1;
   }
   if (port->magic != RIO_MAGIC) {
-    printk (badmagic, cdevname(device), routine);
+    printk (badmagic, name, routine);
     return 1;
   }
 
@@ -372,18 +372,15 @@
 }
 
 
-int rio_minor (kdev_t device)
+int rio_minor(struct tty_struct *tty)
 {
-  return minor (device) + 
-    256 * ((major (device) == RIO_NORMAL_MAJOR1) ||
-	   (major (device) == RIO_CALLOUT_MAJOR1));
+	return tty->index + (tty->driver->termios - rio_termios);
 }
 
 
-int rio_ismodem (kdev_t device)
+int rio_ismodem(struct tty_struct *tty)
 {
-  return (major (device) == RIO_NORMAL_MAJOR0) ||
-         (major (device) == RIO_NORMAL_MAJOR1);
+	return tty->driver == &rio_driver || tty->driver == &rio_driver2;
 }
 
 
@@ -423,7 +420,7 @@
 
   tty = ((struct Port *)ptr)->gs.tty;
 
-  modem = (major(tty->device) == RIO_NORMAL_MAJOR0) || (major(tty->device) == RIO_NORMAL_MAJOR1);
+  modem = rio_ismodem(tty);
 
   rv = RIOParam( (struct Port *) ptr, CONFIG, modem, 1);
 
@@ -448,7 +445,7 @@
 }
 
 
-static void rio_interrupt (int irq, void *ptr, struct pt_regs *regs)
+static irqreturn_t rio_interrupt (int irq, void *ptr, struct pt_regs *regs)
 {
   struct Host *HostP;
   func_enter ();
@@ -509,7 +506,7 @@
   if (test_and_set_bit (RIO_BOARD_INTR_LOCK, &HostP->locks)) {
     printk (KERN_ERR "Recursive interrupt! (host %d/irq%d)\n", 
             (int) ptr, HostP->Ivec);
-    return;
+    return IRQ_HANDLED;
   }
 
   RIOServiceHost(p, HostP, irq);
@@ -521,6 +518,7 @@
   rio_dprintk (RIO_DEBUG_IFLOW, "rio: exit rio_interrupt (%d/%d)\n", 
                irq, HostP->Ivec); 
   func_exit ();
+  return IRQ_HANDLED;
 }
 
 
@@ -942,7 +940,9 @@
   rio_driver.hangup = gs_hangup;
 
   rio_driver2 = rio_driver;
-  rio_driver.major = RIO_NORMAL_MAJOR1;
+  rio_driver2.major = RIO_NORMAL_MAJOR1;
+  rio_driver2.termios += 256;
+  rio_driver2.termios_locked += 256;
 
   rio_callout_driver = rio_driver;
   rio_callout_driver.name = "cusr";
@@ -951,6 +951,8 @@
 
   rio_callout_driver2 = rio_callout_driver;
   rio_callout_driver2.major = RIO_CALLOUT_MAJOR1;
+  rio_callout_driver2.termios += 256;
+  rio_callout_driver2.termios_locked += 256;
 
   rio_dprintk (RIO_DEBUG_INIT, "set_termios = %p\n", gs_set_termios);
 
diff -Nru a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c
--- a/drivers/char/rio/riotty.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/char/rio/riotty.c	Wed Apr 30 22:28:08 2003
@@ -159,8 +159,8 @@
 	*/
 	tty->driver_data = NULL;
         
-	SysPort = rio_minor (tty->device);
-	Modem   = rio_ismodem (tty->device);
+	SysPort = rio_minor(tty);
+	Modem   = rio_ismodem(tty);
 
 	if ( p->RIOFailed ) {
 		rio_dprintk (RIO_DEBUG_TTY, "System initialisation failed\n");
@@ -549,7 +549,7 @@
 	else 
 		end_time = jiffies + MAX_SCHEDULE_TIMEOUT;
 
-	Modem = rio_ismodem(tty->device);
+	Modem = rio_ismodem(tty);
 #if 0
 	/* What F.CKING cache? Even then, a higly idle multiprocessor,
 	   system with large caches this won't work . Better find out when 
@@ -882,11 +882,7 @@
 ** its all about.
 */
 int
-riotioctl(p, dev, cmd, arg)
-struct rio_info *		p;
-dev_t dev;
-register int cmd;
-register caddr_t arg;
+riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg)
 {
 	register struct		Port *PortP;
 	register struct		ttystatics *tp;
@@ -898,8 +894,8 @@
 	short				vpix_cflag;
 	short				divisor;
 	int					baud;
-	uint				SysPort = dev;
-	int					Modem = rio_ismodem(dev);
+	uint				SysPort = rio_minor(tty);
+	int				Modem = rio_ismodem(tty);
 	int					ioctl_processed;
 
 	rio_dprintk (RIO_DEBUG_TTY, "port ioctl SysPort %d command 0x%x argument 0x%x %s\n",
diff -Nru a/drivers/char/riscom8.c b/drivers/char/riscom8.c
--- a/drivers/char/riscom8.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/char/riscom8.c	Wed Apr 30 22:28:09 2003
@@ -131,7 +131,7 @@
 
 
 static inline int rc_paranoia_check(struct riscom_port const * port,
-				    kdev_t device, const char *routine)
+				    char *name, const char *routine)
 {
 #ifdef RISCOM_PARANOIA_CHECK
 	static const char badmagic[] = KERN_INFO
@@ -140,11 +140,11 @@
 		"rc: Warning: null riscom port for device %s in %s\n";
 
 	if (!port) {
-		printk(badinfo, cdevname(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (port->magic != RISCOM8_MAGIC) {
-		printk(badmagic, cdevname(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -590,23 +590,24 @@
 }
 
 /* The main interrupt processing routine */
-static void rc_interrupt(int irq, void * dev_id, struct pt_regs * regs)
+static irqreturn_t rc_interrupt(int irq, void * dev_id, struct pt_regs * regs)
 {
 	unsigned char status;
 	unsigned char ack;
 	struct riscom_board *bp;
 	unsigned long loop = 0;
-	
+	int handled = 0;
+
 	bp = IRQ_to_board[irq];
 	
 	if (!bp || !(bp->flags & RC_BOARD_ACTIVE))  {
-		return;
+		return IRQ_NONE;
 	}
 	
 	while ((++loop < 16) && ((status = ~(rc_in(bp, RC_BSR))) &
 				 (RC_BSR_TOUT | RC_BSR_TINT |
 				  RC_BSR_MINT | RC_BSR_RINT))) {
-	
+		handled = 1;
 		if (status & RC_BSR_TOUT) 
 			printk(KERN_WARNING "rc%d: Got timeout. Hardware "
 					    "error?\n", board_No(bp));
@@ -648,6 +649,7 @@
 		rc_out(bp, CD180_EOIR, 0);   /* Mark end of interrupt */
 		rc_out(bp, RC_CTOUT, 0);     /* Clear timeout flag    */
 	}
+	return IRQ_RETVAL(handled);
 }
 
 /*
@@ -991,7 +993,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == RISCOM_TYPE_CALLOUT) {
+	if (tty->driver->subtype == RISCOM_TYPE_CALLOUT) {
 		if (port->flags & ASYNC_NORMAL_ACTIVE)
 			return -EBUSY;
 		if ((port->flags & ASYNC_CALLOUT_ACTIVE) &&
@@ -1089,13 +1091,13 @@
 	struct riscom_board * bp;
 	unsigned long flags;
 	
-	board = RC_BOARD(minor(tty->device));
+	board = RC_BOARD(tty->index);
 	if (board >= RC_NBOARD || !(rc_board[board].flags & RC_BOARD_PRESENT))
 		return -ENODEV;
 	
 	bp = &rc_board[board];
-	port = rc_port + board * RC_NPORT + RC_PORT(minor(tty->device));
-	if (rc_paranoia_check(port, tty->device, "rc_open"))
+	port = rc_port + board * RC_NPORT + RC_PORT(tty->index);
+	if (rc_paranoia_check(port, tty->name, "rc_open"))
 		return -ENODEV;
 	
 	if ((error = rc_setup_board(bp))) 
@@ -1112,7 +1114,7 @@
 		return error;
 	
 	if ((port->count == 1) && (port->flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == RISCOM_TYPE_NORMAL)
+		if (tty->driver->subtype == RISCOM_TYPE_NORMAL)
 			*tty->termios = port->normal_termios;
 		else
 			*tty->termios = port->callout_termios;
@@ -1134,7 +1136,7 @@
 	unsigned long flags;
 	unsigned long timeout;
 	
-	if (!port || rc_paranoia_check(port, tty->device, "close"))
+	if (!port || rc_paranoia_check(port, tty->name, "close"))
 		return;
 	
 	save_flags(flags); cli();
@@ -1198,8 +1200,8 @@
 		}
 	}
 	rc_shutdown_port(bp, port);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -1226,7 +1228,7 @@
 	int c, total = 0;
 	unsigned long flags;
 				
-	if (rc_paranoia_check(port, tty->device, "rc_write"))
+	if (rc_paranoia_check(port, tty->name, "rc_write"))
 		return 0;
 	
 	bp = port_Board(port);
@@ -1302,7 +1304,7 @@
 	struct riscom_port *port = (struct riscom_port *)tty->driver_data;
 	unsigned long flags;
 
-	if (rc_paranoia_check(port, tty->device, "rc_put_char"))
+	if (rc_paranoia_check(port, tty->name, "rc_put_char"))
 		return;
 
 	if (!tty || !port->xmit_buf)
@@ -1324,7 +1326,7 @@
 	struct riscom_port *port = (struct riscom_port *)tty->driver_data;
 	unsigned long flags;
 				
-	if (rc_paranoia_check(port, tty->device, "rc_flush_chars"))
+	if (rc_paranoia_check(port, tty->name, "rc_flush_chars"))
 		return;
 	
 	if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
@@ -1343,7 +1345,7 @@
 	struct riscom_port *port = (struct riscom_port *)tty->driver_data;
 	int	ret;
 				
-	if (rc_paranoia_check(port, tty->device, "rc_write_room"))
+	if (rc_paranoia_check(port, tty->name, "rc_write_room"))
 		return 0;
 
 	ret = SERIAL_XMIT_SIZE - port->xmit_cnt - 1;
@@ -1356,7 +1358,7 @@
 {
 	struct riscom_port *port = (struct riscom_port *)tty->driver_data;
 				
-	if (rc_paranoia_check(port, tty->device, "rc_chars_in_buffer"))
+	if (rc_paranoia_check(port, tty->name, "rc_chars_in_buffer"))
 		return 0;
 	
 	return port->xmit_cnt;
@@ -1367,7 +1369,7 @@
 	struct riscom_port *port = (struct riscom_port *)tty->driver_data;
 	unsigned long flags;
 				
-	if (rc_paranoia_check(port, tty->device, "rc_flush_buffer"))
+	if (rc_paranoia_check(port, tty->name, "rc_flush_buffer"))
 		return;
 
 	save_flags(flags); cli();
@@ -1531,7 +1533,7 @@
 	struct riscom_port *port = (struct riscom_port *)tty->driver_data;
 	int retval;
 				
-	if (rc_paranoia_check(port, tty->device, "rc_ioctl"))
+	if (rc_paranoia_check(port, tty->name, "rc_ioctl"))
 		return -ENODEV;
 	
 	switch (cmd) {
@@ -1581,7 +1583,7 @@
 	struct riscom_board *bp;
 	unsigned long flags;
 				
-	if (rc_paranoia_check(port, tty->device, "rc_throttle"))
+	if (rc_paranoia_check(port, tty->name, "rc_throttle"))
 		return;
 	
 	bp = port_Board(port);
@@ -1604,7 +1606,7 @@
 	struct riscom_board *bp;
 	unsigned long flags;
 				
-	if (rc_paranoia_check(port, tty->device, "rc_unthrottle"))
+	if (rc_paranoia_check(port, tty->name, "rc_unthrottle"))
 		return;
 	
 	bp = port_Board(port);
@@ -1627,7 +1629,7 @@
 	struct riscom_board *bp;
 	unsigned long flags;
 				
-	if (rc_paranoia_check(port, tty->device, "rc_stop"))
+	if (rc_paranoia_check(port, tty->name, "rc_stop"))
 		return;
 	
 	bp = port_Board(port);
@@ -1645,7 +1647,7 @@
 	struct riscom_board *bp;
 	unsigned long flags;
 				
-	if (rc_paranoia_check(port, tty->device, "rc_start"))
+	if (rc_paranoia_check(port, tty->name, "rc_start"))
 		return;
 	
 	bp = port_Board(port);
@@ -1684,7 +1686,7 @@
 	struct riscom_port *port = (struct riscom_port *)tty->driver_data;
 	struct riscom_board *bp;
 				
-	if (rc_paranoia_check(port, tty->device, "rc_hangup"))
+	if (rc_paranoia_check(port, tty->name, "rc_hangup"))
 		return;
 	
 	bp = port_Board(port);
@@ -1702,7 +1704,7 @@
 	struct riscom_port *port = (struct riscom_port *)tty->driver_data;
 	unsigned long flags;
 				
-	if (rc_paranoia_check(port, tty->device, "rc_set_termios"))
+	if (rc_paranoia_check(port, tty->name, "rc_set_termios"))
 		return;
 	
 	if (tty->termios->c_cflag == old_termios->c_cflag &&
diff -Nru a/drivers/char/rocket.c b/drivers/char/rocket.c
--- a/drivers/char/rocket.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/char/rocket.c	Wed Apr 30 22:28:12 2003
@@ -176,15 +176,15 @@
 static void rp_start(struct tty_struct *tty);
 
 static inline int rocket_paranoia_check(struct r_port *info,
-					kdev_t device, const char *routine)
+					char *name, const char *routine)
 {
 #ifdef ROCKET_PARANOIA_CHECK
 	static const char *badmagic =
-		"Warning: bad magic number for rocketport struct (%d, %d) in %s\n";
+		"Warning: bad magic number for rocketport struct %s in %s\n";
 	if (!info)
 		return 1;
 	if (info->magic != RPORT_MAGIC) {
-		printk(badmagic, major(device), minor(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -710,7 +710,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		if (info->flags & ROCKET_NORMAL_ACTIVE)
 			return -EBUSY;
 		if ((info->flags & ROCKET_CALLOUT_ACTIVE) &&
@@ -822,7 +822,7 @@
 	CHANNEL_t	*cp;
 	unsigned long page;
 	
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if ((line < 0) || (line >= MAX_RP_PORTS))
 		return -ENODEV;
 	if (!tmp_buf) {
@@ -946,7 +946,7 @@
 	}
 
 	if ((info->count == 1) && (info->flags & ROCKET_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->normal_termios;
 		else 
 			*tty->termios = info->callout_termios;
@@ -963,7 +963,7 @@
 	int timeout;
 	CHANNEL_t	*cp;
 
-	if (rocket_paranoia_check(info, tty->device, "rp_close"))
+	if (rocket_paranoia_check(info, tty->name, "rp_close"))
 		return;
 
 #ifdef ROCKET_DEBUG_OPEN
@@ -1048,8 +1048,8 @@
 	if (C_HUPCL(tty)) {
 		sClrDTR(cp);
 	}
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 
@@ -1093,7 +1093,7 @@
 	unsigned cflag;
 	
 
-	if (rocket_paranoia_check(info, tty->device, "rp_set_termios"))
+	if (rocket_paranoia_check(info, tty->name, "rp_set_termios"))
 		return;
 
 	cflag = tty->termios->c_cflag;
@@ -1145,7 +1145,7 @@
 	struct r_port * info = (struct r_port *)tty->driver_data;
 	unsigned long flags;
 	
-	if (rocket_paranoia_check(info, tty->device, "rp_break"))
+	if (rocket_paranoia_check(info, tty->name, "rp_break"))
 		return;
 
 	save_flags(flags); cli();
@@ -1295,7 +1295,7 @@
 	struct r_port * info = (struct r_port *)tty->driver_data;
 
 	if (cmd != RCKP_GET_PORTS &&
-	    rocket_paranoia_check(info, tty->device, "rp_ioctl"))
+	    rocket_paranoia_check(info, tty->name, "rp_ioctl"))
 		return -ENODEV;
 
 	switch (cmd) {
@@ -1325,25 +1325,12 @@
 	return 0;
 }
 
-#if (defined(ROCKET_DEBUG_FLOW) || defined(ROCKET_DEBUG_THROTTLE))
-static char *rp_tty_name(struct tty_struct *tty, char *buf)
-{
-	if (tty)
-		sprintf(buf, "%s%d", tty->driver.name,
-			minor(tty->device) - tty->driver.minor_start +
-			tty->driver.name_base);
-	else
-		strcpy(buf, "NULL tty");
-	return buf;
-}
-#endif
-
 static void rp_send_xchar(struct tty_struct *tty, char ch)
 {
 	struct r_port *info = (struct r_port *)tty->driver_data;
 	CHANNEL_t *cp;
 
-	if (rocket_paranoia_check(info, tty->device, "rp_send_xchar"))
+	if (rocket_paranoia_check(info, tty->name, "rp_send_xchar"))
 		return;
 
 	cp = &info->channel;
@@ -1360,11 +1347,11 @@
 #ifdef ROCKET_DEBUG_THROTTLE
 	char	buf[64];
 	
-	printk("throttle %s: %d....\n", rp_tty_name(tty, buf),
+	printk("throttle %s: %d....\n", tty->name,
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (rocket_paranoia_check(info, tty->device, "rp_throttle"))
+	if (rocket_paranoia_check(info, tty->name, "rp_throttle"))
 		return;
 
 	cp = &info->channel;
@@ -1381,11 +1368,11 @@
 #ifdef ROCKET_DEBUG_THROTTLE
 	char	buf[64];
 	
-	printk("unthrottle %s: %d....\n", rp_tty_name(tty, buf),
+	printk("unthrottle %s: %d....\n", tty->name,
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (rocket_paranoia_check(info, tty->device, "rp_throttle"))
+	if (rocket_paranoia_check(info, tty->name, "rp_throttle"))
 		return;
 
 	cp = &info->channel;
@@ -1409,11 +1396,11 @@
 #ifdef ROCKET_DEBUG_FLOW
 	char	buf[64];
 	
-	printk("stop %s: %d %d....\n", rp_tty_name(tty, buf),
+	printk("stop %s: %d %d....\n", tty->name,
 	       info->xmit_cnt, info->xmit_fifo_room);
 #endif
 
-	if (rocket_paranoia_check(info, tty->device, "rp_stop"))
+	if (rocket_paranoia_check(info, tty->name, "rp_stop"))
 		return;
 
 	if (sGetTxCnt(&info->channel))
@@ -1426,11 +1413,11 @@
 #ifdef ROCKET_DEBUG_FLOW
 	char	buf[64];
 	
-	printk("start %s: %d %d....\n", rp_tty_name(tty, buf),
+	printk("start %s: %d %d....\n", tty->name,
 	       info->xmit_cnt, info->xmit_fifo_room);
 #endif
 
-	if (rocket_paranoia_check(info, tty->device, "rp_stop"))
+	if (rocket_paranoia_check(info, tty->name, "rp_stop"))
 		return;
 
 	sEnTransmit(&info->channel);
@@ -1448,7 +1435,7 @@
 	int check_time, exit_time;
 	int txcnt;
 	
-	if (rocket_paranoia_check(info, tty->device, "rp_wait_until_sent"))
+	if (rocket_paranoia_check(info, tty->name, "rp_wait_until_sent"))
 		return;
 
 	cp = &info->channel;
@@ -1498,7 +1485,7 @@
 	CHANNEL_t	*cp;
 	struct r_port * info = (struct r_port *)tty->driver_data;
 	
-	if (rocket_paranoia_check(info, tty->device, "rp_hangup"))
+	if (rocket_paranoia_check(info, tty->name, "rp_hangup"))
 		return;
 
 #if (defined(ROCKET_DEBUG_OPEN) || defined(ROCKET_DEBUG_HANGUP))
@@ -1553,7 +1540,7 @@
 	struct r_port * info = (struct r_port *)tty->driver_data;
 	CHANNEL_t	*cp;
 
-	if (rocket_paranoia_check(info, tty->device, "rp_put_char"))
+	if (rocket_paranoia_check(info, tty->name, "rp_put_char"))
 		return;
 
 #ifdef ROCKET_DEBUG_WRITE
@@ -1586,7 +1573,7 @@
 	int		c, retval = 0;
 	unsigned long	flags;
 
-	if (count <= 0 || rocket_paranoia_check(info, tty->device, "rp_write"))
+	if (count <= 0 || rocket_paranoia_check(info, tty->name, "rp_write"))
 		return 0;
 
 #ifdef ROCKET_DEBUG_WRITE
@@ -1687,7 +1674,7 @@
 	struct r_port * info = (struct r_port *)tty->driver_data;
 	int	ret;
 
-	if (rocket_paranoia_check(info, tty->device, "rp_write_room"))
+	if (rocket_paranoia_check(info, tty->name, "rp_write_room"))
 		return 0;
 
 	ret = XMIT_BUF_SIZE - info->xmit_cnt - 1;
@@ -1708,7 +1695,7 @@
 	struct r_port * info = (struct r_port *)tty->driver_data;
 	CHANNEL_t	*cp;
 
-	if (rocket_paranoia_check(info, tty->device, "rp_chars_in_buffer"))
+	if (rocket_paranoia_check(info, tty->name, "rp_chars_in_buffer"))
 		return 0;
 
 	cp = &info->channel;
@@ -1724,7 +1711,7 @@
 	struct r_port * info = (struct r_port *)tty->driver_data;
 	CHANNEL_t	*cp;
 
-	if (rocket_paranoia_check(info, tty->device, "rp_flush_buffer"))
+	if (rocket_paranoia_check(info, tty->name, "rp_flush_buffer"))
 		return;
 
 	cli();
@@ -2026,7 +2013,7 @@
 	memset(&rocket_driver, 0, sizeof(struct tty_driver));
 	rocket_driver.magic = TTY_DRIVER_MAGIC;
 #ifdef CONFIG_DEVFS_FS
-	rocket_driver.name = "tts/R%d";
+	rocket_driver.name = "tts/R";
 #else
 	rocket_driver.name = "ttyR";
 #endif
@@ -2068,7 +2055,7 @@
 	 */
 	callout_driver = rocket_driver;
 #ifdef CONFIG_DEVFS_FS
-	callout_driver.name = "cua/R%d";
+	callout_driver.name = "cua/R";
 #else
 	callout_driver.name = "cur";
 #endif
diff -Nru a/drivers/char/rtc.c b/drivers/char/rtc.c
--- a/drivers/char/rtc.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/char/rtc.c	Wed Apr 30 22:28:08 2003
@@ -180,7 +180,7 @@
  *	(See ./arch/XXXX/kernel/time.c for the set_rtc_mmss() function.)
  */
 
-static void rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	/*
 	 *	Can be an alarm interrupt, update complete interrupt,
@@ -207,6 +207,8 @@
 	wake_up_interruptible(&rtc_wait);	
 
 	kill_fasync (&rtc_async_queue, SIGIO, POLL_IN);
+
+	return IRQ_HANDLED;
 }
 #endif
 
diff -Nru a/drivers/char/ser_a2232.c b/drivers/char/ser_a2232.c
--- a/drivers/char/ser_a2232.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/char/ser_a2232.c	Wed Apr 30 22:28:06 2003
@@ -456,7 +456,7 @@
 	int retval;
 	struct a2232_port *port;
 
-	line = minor(tty->device);
+	line = tty->index;
 	port = &a2232_ports[line];
 	
 	tty->driver_data = port;
@@ -480,7 +480,7 @@
 	}
 
 	if ((port->gs.count == 1) && (port->gs.flags & ASYNC_SPLIT_TERMIOS)){
-		if (tty->driver.subtype == A2232_TTY_SUBTYPE_NORMAL)
+		if (tty->driver->subtype == A2232_TTY_SUBTYPE_NORMAL)
 			*tty->termios = port->gs.normal_termios;
 		else 
 			*tty->termios = port->gs.callout_termios;
diff -Nru a/drivers/char/serial167.c b/drivers/char/serial167.c
--- a/drivers/char/serial167.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/char/serial167.c	Wed Apr 30 22:28:08 2003
@@ -237,30 +237,30 @@
 }
 
 static inline int
-serial_paranoia_check(struct cyclades_port *info, kdev_t device,
+serial_paranoia_check(struct cyclades_port *info, char *name,
 		      const char *routine)
 {
 #ifdef SERIAL_PARANOIA_CHECK
     static const char *badmagic =
-	"Warning: bad magic number for serial struct (%d, %d) in %s\n";
+	"Warning: bad magic number for serial struct (%s) in %s\n";
     static const char *badinfo =
-	"Warning: null cyclades_port for (%d, %d) in %s\n";
+	"Warning: null cyclades_port for (%s) in %s\n";
     static const char *badrange =
-	"Warning: cyclades_port out of range for (%d, %d) in %s\n";
+	"Warning: cyclades_port out of range for (%s) in %s\n";
 
     if (!info) {
-	printk(badinfo, major(device), minor(device), routine);
+	printk(badinfo, name, routine);
 	return 1;
     }
 
     if( (long)info < (long)(&cy_port[0])
     || (long)(&cy_port[NR_PORTS]) < (long)info ){
-	printk(badrange, major(device), minor(device), routine);
+	printk(badrange, name, routine);
 	return 1;
     }
 
     if (info->magic != CYCLADES_MAGIC) {
-	printk(badmagic, major(device), minor(device), routine);
+	printk(badmagic, name, routine);
 	return 1;
     }
 #endif
@@ -339,10 +339,10 @@
   unsigned long flags;
 
 #ifdef SERIAL_DEBUG_OTHER
-    printk("cy_stop ttyS%d\n", info->line); /* */
+    printk("cy_stop %s\n", tty->name); /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_stop"))
+    if (serial_paranoia_check(info, tty->name, "cy_stop"))
 	return;
 	
     channel = info->line;
@@ -364,10 +364,10 @@
   unsigned long flags;
 
 #ifdef SERIAL_DEBUG_OTHER
-    printk("cy_start ttyS%d\n", info->line); /* */
+    printk("cy_start %s\n", tty->name); /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_start"))
+    if (serial_paranoia_check(info, tty->name, "cy_start"))
 	return;
 	
     channel = info->line;
@@ -1171,10 +1171,10 @@
   unsigned long flags;
 
 #ifdef SERIAL_DEBUG_IO
-    printk("cy_put_char ttyS%d(0x%02x)\n", info->line, ch);
+    printk("cy_put_char %s(0x%02x)\n", tty->name, ch);
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_put_char"))
+    if (serial_paranoia_check(info, tty->name, "cy_put_char"))
 	return;
 
     if (!tty || !info->xmit_buf)
@@ -1202,10 +1202,10 @@
   int channel;
 				
 #ifdef SERIAL_DEBUG_IO
-    printk("cy_flush_chars ttyS%d\n", info->line); /* */
+    printk("cy_flush_chars %s\n", tty->name); /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_flush_chars"))
+    if (serial_paranoia_check(info, tty->name, "cy_flush_chars"))
 	return;
 
     if (info->xmit_cnt <= 0 || tty->stopped
@@ -1236,10 +1236,10 @@
   int c, total = 0;
 
 #ifdef SERIAL_DEBUG_IO
-    printk("cy_write ttyS%d\n", info->line); /* */
+    printk("cy_write %s\n", tty->name); /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_write")){
+    if (serial_paranoia_check(info, tty->name, "cy_write")){
 	return 0;
     }
 	
@@ -1312,10 +1312,10 @@
   int	ret;
 				
 #ifdef SERIAL_DEBUG_IO
-    printk("cy_write_room ttyS%d\n", info->line); /* */
+    printk("cy_write_room %s\n", tty->name); /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_write_room"))
+    if (serial_paranoia_check(info, tty->name, "cy_write_room"))
 	return 0;
     ret = PAGE_SIZE - info->xmit_cnt - 1;
     if (ret < 0)
@@ -1330,10 +1330,10 @@
   struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
 				
 #ifdef SERIAL_DEBUG_IO
-    printk("cy_chars_in_buffer ttyS%d %d\n", info->line, info->xmit_cnt); /* */
+    printk("cy_chars_in_buffer %s %d\n", tty->name, info->xmit_cnt); /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_chars_in_buffer"))
+    if (serial_paranoia_check(info, tty->name, "cy_chars_in_buffer"))
 	return 0;
 
     return info->xmit_cnt;
@@ -1347,10 +1347,10 @@
   unsigned long flags;
 				
 #ifdef SERIAL_DEBUG_IO
-    printk("cy_flush_buffer ttyS%d\n", info->line); /* */
+    printk("cy_flush_buffer %s\n", tty->name); /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_flush_buffer"))
+    if (serial_paranoia_check(info, tty->name, "cy_flush_buffer"))
 	return;
     local_irq_save(flags);
 	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
@@ -1379,10 +1379,10 @@
 	
     printk("throttle %s: %d....\n", tty_name(tty, buf),
 	   tty->ldisc.chars_in_buffer(tty));
-    printk("cy_throttle ttyS%d\n", info->line);
+    printk("cy_throttle %s\n", tty->name);
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_nthrottle")){
+    if (serial_paranoia_check(info, tty->name, "cy_nthrottle")){
 	    return;
     }
 
@@ -1415,10 +1415,10 @@
 	
     printk("throttle %s: %d....\n", tty_name(tty, buf),
 	   tty->ldisc.chars_in_buffer(tty));
-    printk("cy_unthrottle ttyS%d\n", info->line);
+    printk("cy_unthrottle %s\n", tty->name);
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_nthrottle")){
+    if (serial_paranoia_check(info, tty->name, "cy_nthrottle")){
 	    return;
     }
 
@@ -1743,7 +1743,7 @@
   int ret_val = 0;
 
 #ifdef SERIAL_DEBUG_OTHER
-    printk("cy_ioctl ttyS%d, cmd = %x arg = %lx\n", info->line, cmd, arg); /* */
+    printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty->name, cmd, arg); /* */
 #endif
 
     switch (cmd) {
@@ -1836,7 +1836,7 @@
   struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
 
 #ifdef SERIAL_DEBUG_OTHER
-    printk("cy_set_termios ttyS%d\n", info->line);
+    printk("cy_set_termios %s\n", tty->name);
 #endif
 
     if (tty->termios->c_cflag == old_termios->c_cflag)
@@ -1865,15 +1865,15 @@
 
 /* CP('C'); */
 #ifdef SERIAL_DEBUG_OTHER
-    printk("cy_close ttyS%d\n", info->line);
+    printk("cy_close %s\n", tty->name);
 #endif
 
     if (!info
-    || serial_paranoia_check(info, tty->device, "cy_close")){
+    || serial_paranoia_check(info, tty->name, "cy_close")){
         return;
     }
 #ifdef SERIAL_DEBUG_OPEN
-    printk("cy_close ttyS%d, count = %d\n", info->line, info->count);
+    printk("cy_close %s, count = %d\n", tty->name, info->count);
 #endif
 
     if ((tty->count == 1) && (info->count != 1)) {
@@ -1913,8 +1913,8 @@
     if (info->flags & ASYNC_INITIALIZED)
 	tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */
     shutdown(info);
-    if (tty->driver.flush_buffer)
-	tty->driver.flush_buffer(tty);
+    if (tty->driver->flush_buffer)
+	tty->driver->flush_buffer(tty);
     if (tty->ldisc.flush_buffer)
 	tty->ldisc.flush_buffer(tty);
     info->event = 0;
@@ -1954,10 +1954,10 @@
   struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
 	
 #ifdef SERIAL_DEBUG_OTHER
-    printk("cy_hangup ttyS%d\n", info->line); /* */
+    printk("cy_hangup %s\n", tty->name); /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->device, "cy_hangup"))
+    if (serial_paranoia_check(info, tty->name, "cy_hangup"))
 	return;
     
     shutdown(info);
@@ -2008,7 +2008,7 @@
      * If this is a callout device, then just make sure the normal
      * device isn't being used.
      */
-    if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+    if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 	if (info->flags & ASYNC_NORMAL_ACTIVE){
 	    return -EBUSY;
 	}
@@ -2048,8 +2048,8 @@
     retval = 0;
     add_wait_queue(&info->open_wait, &wait);
 #ifdef SERIAL_DEBUG_OPEN
-    printk("block_til_ready before block: ttyS%d, count = %d\n",
-	   info->line, info->count);/**/
+    printk("block_til_ready before block: %s, count = %d\n",
+	   tty->name, info->count);/**/
 #endif
     info->count--;
 #ifdef SERIAL_DEBUG_COUNT
@@ -2098,8 +2098,8 @@
 	    break;
 	}
 #ifdef SERIAL_DEBUG_OPEN
-	printk("block_til_ready blocking: ttyS%d, count = %d\n",
-	       info->line, info->count);/**/
+	printk("block_til_ready blocking: %s, count = %d\n",
+	       tty->name, info->count);/**/
 #endif
 	schedule();
     }
@@ -2113,8 +2113,8 @@
     }
     info->blocked_open--;
 #ifdef SERIAL_DEBUG_OPEN
-    printk("block_til_ready after blocking: ttyS%d, count = %d\n",
-	   info->line, info->count);/**/
+    printk("block_til_ready after blocking: %s, count = %d\n",
+	   tty->name, info->count);/**/
 #endif
     if (retval)
 	    return retval;
@@ -2133,7 +2133,7 @@
   int retval, line;
 
 /* CP('O'); */
-    line = minor(tty->device) - tty->driver.minor_start;
+    line = tty->index;
     if ((line < 0) || (NR_PORTS <= line)){
         return -ENODEV;
     }
@@ -2142,13 +2142,13 @@
         return -ENODEV;
     }
 #ifdef SERIAL_DEBUG_OTHER
-    printk("cy_open ttyS%d\n", info->line); /* */
+    printk("cy_open %s\n", tty->name); /* */
 #endif
-    if (serial_paranoia_check(info, tty->device, "cy_open")){
+    if (serial_paranoia_check(info, tty->name, "cy_open")){
         return -ENODEV;
     }
 #ifdef SERIAL_DEBUG_OPEN
-    printk("cy_open ttyS%d, count = %d\n", info->line, info->count);/**/
+    printk("cy_open %s, count = %d\n", tty->name, info->count);/**/
 #endif
     info->count++;
 #ifdef SERIAL_DEBUG_COUNT
@@ -2165,7 +2165,7 @@
     }
 
     if ((info->count == 1) && (info->flags & ASYNC_SPLIT_TERMIOS)) {
-	if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+	if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 	    *tty->termios = info->normal_termios;
 	else 
 	    *tty->termios = info->callout_termios;
@@ -2396,7 +2396,7 @@
     memset(&cy_serial_driver, 0, sizeof(struct tty_driver));
     cy_serial_driver.magic = TTY_DRIVER_MAGIC;
 #ifdef CONFIG_DEVFS_FS
-    cy_serial_driver.name = "tts/%d";
+    cy_serial_driver.name = "tts/";
 #else
     cy_serial_driver.name = "ttyS";
 #endif
@@ -2435,7 +2435,7 @@
      */
     cy_callout_driver = cy_serial_driver;
 #ifdef CONFIG_DEVFS_FS
-    cy_callout_driver.name = "cua/%d";
+    cy_callout_driver.name = "cua/";
 #else
     cy_callout_driver.name = "cua";
 #endif
@@ -2814,9 +2814,10 @@
 	local_irq_restore(flags);
 }
 
-static kdev_t serial167_console_device(struct console *c)
+static struct tty_driver *serial167_console_device(struct console *c, int *index)
 {
-	return mk_kdev(TTY_MAJOR, 64 + c->index);
+	*index = c->index;
+	return &cy_serial_driver;
 }
 
 
diff -Nru a/drivers/char/serial_tx3912.c b/drivers/char/serial_tx3912.c
--- a/drivers/char/serial_tx3912.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/char/serial_tx3912.c	Wed Apr 30 22:28:10 2003
@@ -547,7 +547,7 @@
 		return -EIO;
 	}
 
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	rs_dprintk (TX3912_UART_DEBUG_OPEN, "%d: opening line %d. tty=%p ctty=%p)\n", 
 	            (int) current->pid, line, tty, current->tty);
 
@@ -602,7 +602,7 @@
 	/* tty->low_latency = 1; */
 
 	if ((port->gs.count == 1) && (port->gs.flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = port->gs.normal_termios;
 		else 
 			*tty->termios = port->gs.callout_termios;
@@ -1004,9 +1004,10 @@
     	}
 }
 
-static kdev_t serial_console_device(struct console *c)
+static struct tty_driver *serial_console_device(struct console *c, int *index)
 {
-	return mk_kdev(TTY_MAJOR, 64 + c->index);
+	*index = c->index;
+	return &rs_driver;
 }
 
 static __init int serial_console_setup(struct console *co, char *options)
diff -Nru a/drivers/char/sh-sci.c b/drivers/char/sh-sci.c
--- a/drivers/char/sh-sci.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/char/sh-sci.c	Wed Apr 30 22:28:18 2003
@@ -812,7 +812,7 @@
 	struct sci_port *port;
 	int retval, line;
 
-	line = minor(tty->device) - SCI_MINOR_START;
+	line = tty->index;
 
 	if ((line < 0) || (line >= SCI_NPORTS))
 		return -ENODEV;
@@ -853,7 +853,7 @@
 	}
 
 	if ((port->gs.count == 1) && (port->gs.flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = port->gs.normal_termios;
 		else 
 			*tty->termios = port->gs.callout_termios;
@@ -1021,7 +1021,7 @@
 	sci_driver.magic = TTY_DRIVER_MAGIC;
 	sci_driver.driver_name = "sci";
 #ifdef CONFIG_DEVFS_FS
-	sci_driver.name = "ttsc/%d";
+	sci_driver.name = "ttsc/";
 #else
 	sci_driver.name = "ttySC";
 #endif
@@ -1060,7 +1060,7 @@
 
 	sci_callout_driver = sci_driver;
 #ifdef CONFIG_DEVFS_FS
-	sci_callout_driver.name = "cusc/%d";
+	sci_callout_driver.name = "cusc/";
 #else
 	sci_callout_driver.name = "cusc";
 #endif
@@ -1179,9 +1179,10 @@
 	put_string(sercons_port, s, count);
 }
 
-static kdev_t serial_console_device(struct console *c)
+static struct tty_driver *serial_console_device(struct console *c, int *index)
 {
-	return mk_kdev(SCI_MAJOR, SCI_MINOR_START + c->index);
+	*index = c->index;
+	return &sci_driver;
 }
 
 /*
diff -Nru a/drivers/char/sonypi.c b/drivers/char/sonypi.c
--- a/drivers/char/sonypi.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/char/sonypi.c	Wed Apr 30 22:28:13 2003
@@ -305,7 +305,7 @@
 }
 
 /* Interrupt handler: some event is available */
-void sonypi_irq(int irq, void *dev_id, struct pt_regs *regs) {
+static irqreturn_t sonypi_irq(int irq, void *dev_id, struct pt_regs *regs) {
 	u8 v1, v2, event = 0;
 	int i, j;
 
@@ -334,7 +334,7 @@
 	if (verbose)
 		printk(KERN_WARNING 
 		       "sonypi: unknown event port1=0x%02x,port2=0x%02x\n",v1,v2);
-	return;
+	return IRQ_NONE;
 
 found:
 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
@@ -354,6 +354,7 @@
 	}
 #endif /* CONFIG_INPUT || CONFIG_INPUT_MODULE */
 	sonypi_pushq(event);
+	return IRQ_HANDLED;
 }
 
 /* External camera command (exported to the motion eye v4l driver) */
diff -Nru a/drivers/char/specialix.c b/drivers/char/specialix.c
--- a/drivers/char/specialix.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/char/specialix.c	Wed Apr 30 22:28:16 2003
@@ -204,13 +204,13 @@
 
 #ifdef SPECIALIX_TIMER
 static struct timer_list missed_irq_timer;
-static void sx_interrupt(int irq, void * dev_id, struct pt_regs * regs);
+static irqreturn_t sx_interrupt(int irq, void * dev_id, struct pt_regs * regs);
 #endif
 
 
 
 static inline int sx_paranoia_check(struct specialix_port const * port,
-				    kdev_t device, const char *routine)
+				    char *name, const char *routine)
 {
 #ifdef SPECIALIX_PARANOIA_CHECK
 	static const char *badmagic =
@@ -219,11 +219,11 @@
 		KERN_ERR "sx: Warning: null specialix port for device %s in %s\n";
  
 	if (!port) {
-		printk(badinfo, cdevname(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (port->magic != SPECIALIX_MAGIC) {
-		printk(badmagic, cdevname(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -876,7 +876,7 @@
 
 
 /* The main interrupt processing routine */
-static void sx_interrupt(int irq, void * dev_id, struct pt_regs * regs)
+static irqreturn_t sx_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	unsigned char status;
 	unsigned char ack;
@@ -890,7 +890,7 @@
 #ifdef SPECIALIX_DEBUG 
 		printk (KERN_DEBUG "sx: False interrupt. irq %d.\n", irq);
 #endif
-		return;
+		return IRQ_NONE;
 	}
 
 	saved_reg = bp->reg;
@@ -933,6 +933,7 @@
 	}
 	bp->reg = saved_reg;
 	outb (bp->reg, bp->base + SX_ADDR_REG);
+	return IRQ_HANDLED;
 }
 
 
@@ -1349,7 +1350,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SPECIALIX_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SPECIALIX_TYPE_CALLOUT) {
 		if (port->flags & ASYNC_NORMAL_ACTIVE)
 			return -EBUSY;
 		if ((port->flags & ASYNC_CALLOUT_ACTIVE) &&
@@ -1454,20 +1455,20 @@
 	struct specialix_board * bp;
 	unsigned long flags;
 	
-	board = SX_BOARD(minor(tty->device));
+	board = SX_BOARD(tty->index);
 
 	if (board >= SX_NBOARD || !(sx_board[board].flags & SX_BOARD_PRESENT))
 		return -ENODEV;
 	
 	bp = &sx_board[board];
-	port = sx_port + board * SX_NPORT + SX_PORT(minor(tty->device));
+	port = sx_port + board * SX_NPORT + SX_PORT(tty->index);
 
 #ifdef DEBUG_SPECIALIX
 	printk (KERN_DEBUG "Board = %d, bp = %p, port = %p, portno = %d.\n", 
-	        board, bp, port, SX_PORT(minor(tty->device)));
+	        board, bp, port, SX_PORT(tty->index));
 #endif
 
-	if (sx_paranoia_check(port, tty->device, "sx_open"))
+	if (sx_paranoia_check(port, tty->name, "sx_open"))
 		return -ENODEV;
 
 	if ((error = sx_setup_board(bp)))
@@ -1484,7 +1485,7 @@
 		return error;
 
 	if ((port->count == 1) && (port->flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SPECIALIX_TYPE_NORMAL)
+		if (tty->driver->subtype == SPECIALIX_TYPE_NORMAL)
 			*tty->termios = port->normal_termios;
 		else
 			*tty->termios = port->callout_termios;
@@ -1506,7 +1507,7 @@
 	unsigned long flags;
 	unsigned long timeout;
 	
-	if (!port || sx_paranoia_check(port, tty->device, "close"))
+	if (!port || sx_paranoia_check(port, tty->name, "close"))
 		return;
 	
 	save_flags(flags); cli();
@@ -1576,8 +1577,8 @@
 
 	}
 	sx_shutdown_port(bp, port);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -1605,7 +1606,7 @@
 	int c, total = 0;
 	unsigned long flags;
 				
-	if (sx_paranoia_check(port, tty->device, "sx_write"))
+	if (sx_paranoia_check(port, tty->name, "sx_write"))
 		return 0;
 	
 	bp = port_Board(port);
@@ -1679,7 +1680,7 @@
 	struct specialix_port *port = (struct specialix_port *)tty->driver_data;
 	unsigned long flags;
 
-	if (sx_paranoia_check(port, tty->device, "sx_put_char"))
+	if (sx_paranoia_check(port, tty->name, "sx_put_char"))
 		return;
 
 	if (!tty || !port->xmit_buf)
@@ -1704,7 +1705,7 @@
 	struct specialix_port *port = (struct specialix_port *)tty->driver_data;
 	unsigned long flags;
 				
-	if (sx_paranoia_check(port, tty->device, "sx_flush_chars"))
+	if (sx_paranoia_check(port, tty->name, "sx_flush_chars"))
 		return;
 	
 	if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
@@ -1724,7 +1725,7 @@
 	struct specialix_port *port = (struct specialix_port *)tty->driver_data;
 	int	ret;
 				
-	if (sx_paranoia_check(port, tty->device, "sx_write_room"))
+	if (sx_paranoia_check(port, tty->name, "sx_write_room"))
 		return 0;
 
 	ret = SERIAL_XMIT_SIZE - port->xmit_cnt - 1;
@@ -1738,7 +1739,7 @@
 {
 	struct specialix_port *port = (struct specialix_port *)tty->driver_data;
 				
-	if (sx_paranoia_check(port, tty->device, "sx_chars_in_buffer"))
+	if (sx_paranoia_check(port, tty->name, "sx_chars_in_buffer"))
 		return 0;
 	
 	return port->xmit_cnt;
@@ -1750,7 +1751,7 @@
 	struct specialix_port *port = (struct specialix_port *)tty->driver_data;
 	unsigned long flags;
 				
-	if (sx_paranoia_check(port, tty->device, "sx_flush_buffer"))
+	if (sx_paranoia_check(port, tty->name, "sx_flush_buffer"))
 		return;
 
 	save_flags(flags); cli();
@@ -1976,7 +1977,7 @@
 	int error;
 	int retval;
 				
-	if (sx_paranoia_check(port, tty->device, "sx_ioctl"))
+	if (sx_paranoia_check(port, tty->name, "sx_ioctl"))
 		return -ENODEV;
 	
 	switch (cmd) {
@@ -2035,7 +2036,7 @@
 	struct specialix_board *bp;
 	unsigned long flags;
 				
-	if (sx_paranoia_check(port, tty->device, "sx_throttle"))
+	if (sx_paranoia_check(port, tty->name, "sx_throttle"))
 		return;
 	
 	bp = port_Board(port);
@@ -2070,7 +2071,7 @@
 	struct specialix_board *bp;
 	unsigned long flags;
 				
-	if (sx_paranoia_check(port, tty->device, "sx_unthrottle"))
+	if (sx_paranoia_check(port, tty->name, "sx_unthrottle"))
 		return;
 	
 	bp = port_Board(port);
@@ -2098,7 +2099,7 @@
 	struct specialix_board *bp;
 	unsigned long flags;
 				
-	if (sx_paranoia_check(port, tty->device, "sx_stop"))
+	if (sx_paranoia_check(port, tty->name, "sx_stop"))
 		return;
 	
 	bp = port_Board(port);
@@ -2117,7 +2118,7 @@
 	struct specialix_board *bp;
 	unsigned long flags;
 				
-	if (sx_paranoia_check(port, tty->device, "sx_start"))
+	if (sx_paranoia_check(port, tty->name, "sx_start"))
 		return;
 	
 	bp = port_Board(port);
@@ -2158,7 +2159,7 @@
 	struct specialix_port *port = (struct specialix_port *)tty->driver_data;
 	struct specialix_board *bp;
 				
-	if (sx_paranoia_check(port, tty->device, "sx_hangup"))
+	if (sx_paranoia_check(port, tty->name, "sx_hangup"))
 		return;
 	
 	bp = port_Board(port);
@@ -2177,7 +2178,7 @@
 	struct specialix_port *port = (struct specialix_port *)tty->driver_data;
 	unsigned long flags;
 				
-	if (sx_paranoia_check(port, tty->device, "sx_set_termios"))
+	if (sx_paranoia_check(port, tty->name, "sx_set_termios"))
 		return;
 	
 	if (tty->termios->c_cflag == old_termios->c_cflag &&
diff -Nru a/drivers/char/stallion.c b/drivers/char/stallion.c
--- a/drivers/char/stallion.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/char/stallion.c	Wed Apr 30 22:28:14 2003
@@ -530,7 +530,6 @@
 static int	stl_getbrdstruct(unsigned long arg);
 static int	stl_waitcarrier(stlport_t *portp, struct file *filp);
 static void	stl_delay(int len);
-static void	stl_intr(int irq, void *dev_id, struct pt_regs *regs);
 static void	stl_eiointr(stlbrd_t *brdp);
 static void	stl_echatintr(stlbrd_t *brdp);
 static void	stl_echmcaintr(stlbrd_t *brdp);
@@ -1017,11 +1016,11 @@
 	int		brdnr, panelnr, portnr, rc;
 
 #if DEBUG
-	printk("stl_open(tty=%x,filp=%x): device=%x\n", (int) tty,
-		(int) filp, tty->device);
+	printk("stl_open(tty=%x,filp=%x): device=%s\n", (int) tty,
+		(int) filp, tty->name);
 #endif
 
-	minordev = minor(tty->device);
+	minordev = tty->index;
 	brdnr = MINOR2BRD(minordev);
 	if (brdnr >= stl_nrbrds)
 		return(-ENODEV);
@@ -1090,7 +1089,7 @@
  *	previous opens still in effect. If we are a normal serial device
  *	then also we might have to wait for carrier.
  */
-	if (tty->driver.subtype == STL_DRVTYPCALLOUT) {
+	if (tty->driver->subtype == STL_DRVTYPCALLOUT) {
 		if (portp->flags & ASYNC_NORMAL_ACTIVE)
 			return(-EBUSY);
 		if (portp->flags & ASYNC_CALLOUT_ACTIVE) {
@@ -1114,7 +1113,7 @@
 	}
 
 	if ((portp->refcount == 1) && (portp->flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == STL_DRVTYPSERIAL)
+		if (tty->driver->subtype == STL_DRVTYPSERIAL)
 			*tty->termios = portp->normaltermios;
 		else
 			*tty->termios = portp->callouttermios;
@@ -2085,10 +2084,11 @@
  *	calls off to the approrpriate board interrupt handlers.
  */
 
-static void stl_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t stl_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	stlbrd_t	*brdp;
 	int		i;
+	int handled = 0;
 
 #if DEBUG
 	printk("stl_intr(irq=%d,regs=%x)\n", irq, (int) regs);
@@ -2099,8 +2099,10 @@
 			continue;
 		if (brdp->state == 0)
 			continue;
+		handled = 1;
 		(* brdp->isr)(brdp);
 	}
+	return IRQ_RETVAL(handled);
 }
 
 /*****************************************************************************/
diff -Nru a/drivers/char/sx.c b/drivers/char/sx.c
--- a/drivers/char/sx.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/char/sx.c	Wed Apr 30 22:28:08 2003
@@ -441,7 +441,7 @@
 /* This doesn't work. Who's paranoid around here? Not me! */
 
 static inline int sx_paranoia_check(struct sx_port const * port,
-				    kdev_t device, const char *routine)
+				    char *name, const char *routine)
 {
 
 	static const char *badmagic =
@@ -450,11 +450,11 @@
 	  KERN_ERR "sx: Warning: null sx port for device %s in %s\n";
  
 	if (!port) {
-		printk(badinfo, cdevname(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (port->magic != SX_MAGIC) {
-		printk(badmagic, cdevname(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 
@@ -1202,7 +1202,7 @@
  * Small, elegant, clear.
  */
 
-static void sx_interrupt (int irq, void *ptr, struct pt_regs *regs)
+static irqreturn_t sx_interrupt (int irq, void *ptr, struct pt_regs *regs)
 {
 	struct sx_board *board = ptr;
 	struct sx_port *port;
@@ -1269,12 +1269,14 @@
 		}
 	}
 
-	if (!sx_initialized) return;
-	if (!(board->flags & SX_BOARD_INITIALIZED)) return;
+	if (!sx_initialized)
+		return IRQ_HANDLED;
+	if (!(board->flags & SX_BOARD_INITIALIZED))
+		return IRQ_HANDLED;
 
 	if (test_and_set_bit (SX_BOARD_INTR_LOCK, &board->locks)) {
 		printk (KERN_ERR "Recursive interrupt! (%d)\n", board->irq);
-		return;
+		return IRQ_HANDLED;
 	}
 
 	 for (i=0;i<board->nports;i++) {
@@ -1298,6 +1300,7 @@
 
 	sx_dprintk (SX_DEBUG_FLOW, "sx: exit sx_interrupt (%d/%d)\n", irq, board->irq); 
 	/*  func_exit ();  */
+	return IRQ_HANDLED;
 }
 
 
@@ -1434,7 +1437,7 @@
 		return -EIO;
 	}
 
-	line = minor(tty->device);
+	line = tty->index;
 	sx_dprintk (SX_DEBUG_OPEN, "%d: opening line %d. tty=%p ctty=%p, np=%d)\n", 
 	            current->pid, line, tty, current->tty, sx_nports);
 
@@ -1500,7 +1503,7 @@
 	/* tty->low_latency = 1; */
 
 	if ((port->gs.count == 1) && (port->gs.flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = port->gs.normal_termios;
 		else 
 			*tty->termios = port->gs.callout_termios;
diff -Nru a/drivers/char/synclink.c b/drivers/char/synclink.c
--- a/drivers/char/synclink.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/char/synclink.c	Wed Apr 30 22:28:07 2003
@@ -1,7 +1,7 @@
 /*
  * linux/drivers/char/synclink.c
  *
- * $Id: synclink.c,v 4.4 2002/10/10 14:53:36 paulkf Exp $
+ * $Id: synclink.c,v 4.6 2003/04/21 17:46:54 paulkf Exp $
  *
  * Device driver for Microgate SyncLink ISA and PCI
  * high speed multiprotocol serial adapters.
@@ -854,9 +854,9 @@
 /*
  * ioctl call handlers
  */
-static int set_modem_info(struct mgsl_struct * info, unsigned int cmd,
-			  unsigned int *value);
-static int get_modem_info(struct mgsl_struct * info, unsigned int *value);
+static int tiocmget(struct tty_struct *tty, struct file *file);
+static int tiocmset(struct tty_struct *tty, struct file *file,
+		    unsigned int set, unsigned int clear);
 static int mgsl_get_stats(struct mgsl_struct * info, struct mgsl_icount
 	*user_icount);
 static int mgsl_get_params(struct mgsl_struct * info, MGSL_PARAMS *user_params);
@@ -917,7 +917,7 @@
 MODULE_PARM(txholdbufs,"1-" __MODULE_STRING(MAX_TOTAL_DEVICES) "i");
 
 static char *driver_name = "SyncLink serial driver";
-static char *driver_version = "$Revision: 4.4 $";
+static char *driver_version = "$Revision: 4.6 $";
 
 static int synclink_init_one (struct pci_dev *dev,
 				     const struct pci_device_id *ent);
@@ -978,7 +978,7 @@
 static DECLARE_MUTEX(tmp_buf_sem);
 
 static inline int mgsl_paranoia_check(struct mgsl_struct *info,
-					kdev_t device, const char *routine)
+					char *name, const char *routine)
 {
 #ifdef MGSL_PARANOIA_CHECK
 	static const char *badmagic =
@@ -987,11 +987,11 @@
 		"Warning: null mgsl_struct for (%s) in %s\n";
 
 	if (!info) {
-		printk(badinfo, cdevname(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (info->magic != MGSL_MAGIC) {
-		printk(badmagic, cdevname(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -1008,7 +1008,7 @@
 	struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data;
 	unsigned long flags;
 	
-	if (mgsl_paranoia_check(info, tty->device, "mgsl_stop"))
+	if (mgsl_paranoia_check(info, tty->name, "mgsl_stop"))
 		return;
 	
 	if ( debug_level >= DEBUG_LEVEL_INFO )
@@ -1031,7 +1031,7 @@
 	struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data;
 	unsigned long flags;
 	
-	if (mgsl_paranoia_check(info, tty->device, "mgsl_start"))
+	if (mgsl_paranoia_check(info, tty->name, "mgsl_start"))
 		return;
 	
 	if ( debug_level >= DEBUG_LEVEL_INFO )
@@ -1704,7 +1704,7 @@
  * 	
  * Return Value: None
  */
-static void mgsl_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t mgsl_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
 	struct mgsl_struct * info;
 	u16 UscVector;
@@ -1716,7 +1716,7 @@
 
 	info = (struct mgsl_struct *)dev_id;	
 	if (!info)
-		return;
+		return IRQ_NONE;
 		
 	spin_lock(&info->irq_spinlock);
 
@@ -1766,7 +1766,7 @@
 	if ( debug_level >= DEBUG_LEVEL_ISR )	
 		printk("%s(%d):mgsl_interrupt(%d)exit.\n",
 			__FILE__,__LINE__,irq);
-
+	return IRQ_HANDLED;
 }	/* end of mgsl_interrupt() */
 
 /* startup()
@@ -2048,7 +2048,7 @@
 			__FILE__,__LINE__,ch,info->device_name);
 	}		
 	
-	if (mgsl_paranoia_check(info, tty->device, "mgsl_put_char"))
+	if (mgsl_paranoia_check(info, tty->name, "mgsl_put_char"))
 		return;
 
 	if (!tty || !info->xmit_buf)
@@ -2086,7 +2086,7 @@
 		printk( "%s(%d):mgsl_flush_chars() entry on %s xmit_cnt=%d\n",
 			__FILE__,__LINE__,info->device_name,info->xmit_cnt);
 	
-	if (mgsl_paranoia_check(info, tty->device, "mgsl_flush_chars"))
+	if (mgsl_paranoia_check(info, tty->name, "mgsl_flush_chars"))
 		return;
 
 	if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
@@ -2139,7 +2139,7 @@
 		printk( "%s(%d):mgsl_write(%s) count=%d\n",
 			__FILE__,__LINE__,info->device_name,count);
 	
-	if (mgsl_paranoia_check(info, tty->device, "mgsl_write"))
+	if (mgsl_paranoia_check(info, tty->name, "mgsl_write"))
 		goto cleanup;
 
 	if (!tty || !info->xmit_buf || !tmp_buf)
@@ -2315,7 +2315,7 @@
 	struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data;
 	int	ret;
 				
-	if (mgsl_paranoia_check(info, tty->device, "mgsl_write_room"))
+	if (mgsl_paranoia_check(info, tty->name, "mgsl_write_room"))
 		return 0;
 	ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
 	if (ret < 0)
@@ -2353,7 +2353,7 @@
 		printk("%s(%d):mgsl_chars_in_buffer(%s)\n",
 			 __FILE__,__LINE__, info->device_name );
 			 
-	if (mgsl_paranoia_check(info, tty->device, "mgsl_chars_in_buffer"))
+	if (mgsl_paranoia_check(info, tty->name, "mgsl_chars_in_buffer"))
 		return 0;
 		
 	if (debug_level >= DEBUG_LEVEL_INFO)
@@ -2388,7 +2388,7 @@
 		printk("%s(%d):mgsl_flush_buffer(%s) entry\n",
 			 __FILE__,__LINE__, info->device_name );
 	
-	if (mgsl_paranoia_check(info, tty->device, "mgsl_flush_buffer"))
+	if (mgsl_paranoia_check(info, tty->name, "mgsl_flush_buffer"))
 		return;
 		
 	spin_lock_irqsave(&info->irq_spinlock,flags); 
@@ -2420,7 +2420,7 @@
 		printk("%s(%d):mgsl_send_xchar(%s,%d)\n",
 			 __FILE__,__LINE__, info->device_name, ch );
 			 
-	if (mgsl_paranoia_check(info, tty->device, "mgsl_send_xchar"))
+	if (mgsl_paranoia_check(info, tty->name, "mgsl_send_xchar"))
 		return;
 
 	info->x_char = ch;
@@ -2449,7 +2449,7 @@
 		printk("%s(%d):mgsl_throttle(%s) entry\n",
 			 __FILE__,__LINE__, info->device_name );
 
-	if (mgsl_paranoia_check(info, tty->device, "mgsl_throttle"))
+	if (mgsl_paranoia_check(info, tty->name, "mgsl_throttle"))
 		return;
 	
 	if (I_IXOFF(tty))
@@ -2479,7 +2479,7 @@
 		printk("%s(%d):mgsl_unthrottle(%s) entry\n",
 			 __FILE__,__LINE__, info->device_name );
 
-	if (mgsl_paranoia_check(info, tty->device, "mgsl_unthrottle"))
+	if (mgsl_paranoia_check(info, tty->name, "mgsl_unthrottle"))
 		return;
 	
 	if (I_IXOFF(tty)) {
@@ -2921,110 +2921,58 @@
 	return rc;
 }
 
-/* get_modem_info()
- * 
- * 	Read the state of the serial control and
- * 	status signals and return to caller.
- * 	
- * Arguments:	 	info	pointer to device instance data
- * 			value	pointer to int to hold returned info
- * 	
- * Return Value:	0 if success, otherwise error code
+/* return the state of the serial control and status signals
  */
-static int get_modem_info(struct mgsl_struct * info, unsigned int *value)
+static int tiocmget(struct tty_struct *tty, struct file *file)
 {
-	unsigned int result = 0;
+	struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data;
+	unsigned int result;
  	unsigned long flags;
-	int err;
- 
+
 	spin_lock_irqsave(&info->irq_spinlock,flags);
  	usc_get_serial_signals(info);
 	spin_unlock_irqrestore(&info->irq_spinlock,flags);
 
-	if (info->serial_signals & SerialSignal_RTS)
-		result |= TIOCM_RTS;
-	if (info->serial_signals & SerialSignal_DTR)
-		result |= TIOCM_DTR;
-	if (info->serial_signals & SerialSignal_DCD)
-		result |= TIOCM_CAR;
-	if (info->serial_signals & SerialSignal_RI)
-		result |= TIOCM_RNG;
-	if (info->serial_signals & SerialSignal_DSR)
-		result |= TIOCM_DSR;
-	if (info->serial_signals & SerialSignal_CTS)
-		result |= TIOCM_CTS;
+	result = ((info->serial_signals & SerialSignal_RTS) ? TIOCM_RTS:0) +
+		((info->serial_signals & SerialSignal_DTR) ? TIOCM_DTR:0) +
+		((info->serial_signals & SerialSignal_DCD) ? TIOCM_CAR:0) +
+		((info->serial_signals & SerialSignal_RI)  ? TIOCM_RNG:0) +
+		((info->serial_signals & SerialSignal_DSR) ? TIOCM_DSR:0) +
+		((info->serial_signals & SerialSignal_CTS) ? TIOCM_CTS:0);
 
 	if (debug_level >= DEBUG_LEVEL_INFO)
-		printk("%s(%d):mgsl_get_modem_info %s value=%08X\n",
+		printk("%s(%d):%s tiocmget() value=%08X\n",
 			 __FILE__,__LINE__, info->device_name, result );
-			
-	PUT_USER(err,result,value);
-	return err;
-}	/* end of get_modem_info() */
+	return result;
+}
 
-/* set_modem_info()
- * 
- * 	Set the state of the modem control signals (DTR/RTS)
- * 	
- * Arguments:
- * 
- * 	info	pointer to device instance data
- * 	cmd	signal command: TIOCMBIS = set bit TIOCMBIC = clear bit
- *		TIOCMSET = set/clear signal values
- * 	value	bit mask for command
- * 	
- * Return Value:	0 if success, otherwise error code
+/* set modem control signals (DTR/RTS)
  */
-static int set_modem_info(struct mgsl_struct * info, unsigned int cmd,
-			  unsigned int *value)
+static int tiocmset(struct tty_struct *tty, struct file *file,
+		    unsigned int set, unsigned int clear)
 {
- 	int error;
- 	unsigned int arg;
+	struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data;
  	unsigned long flags;
- 
+
 	if (debug_level >= DEBUG_LEVEL_INFO)
-		printk("%s(%d):mgsl_set_modem_info %s\n", __FILE__,__LINE__,
-			info->device_name );
-			
- 	GET_USER(error,arg,value);
- 	if (error)
- 		return error;
-		
- 	switch (cmd) {
- 	case TIOCMBIS: 
- 		if (arg & TIOCM_RTS)
- 			info->serial_signals |= SerialSignal_RTS;
- 		if (arg & TIOCM_DTR)
- 			info->serial_signals |= SerialSignal_DTR;
- 		break;
- 	case TIOCMBIC:
- 		if (arg & TIOCM_RTS)
- 			info->serial_signals &= ~SerialSignal_RTS;
- 		if (arg & TIOCM_DTR)
- 			info->serial_signals &= ~SerialSignal_DTR;
- 		break;
- 	case TIOCMSET:
- 		if (arg & TIOCM_RTS)
- 			info->serial_signals |= SerialSignal_RTS;
-		else
- 			info->serial_signals &= ~SerialSignal_RTS;
-		
- 		if (arg & TIOCM_DTR)
- 			info->serial_signals |= SerialSignal_DTR;
-		else
- 			info->serial_signals &= ~SerialSignal_DTR;
- 		break;
- 	default:
- 		return -EINVAL;
- 	}
-	
+		printk("%s(%d):%s tiocmset(%x,%x)\n",
+			__FILE__,__LINE__,info->device_name, set, clear);
+
+	if (set & TIOCM_RTS)
+		info->serial_signals |= SerialSignal_RTS;
+	if (set & TIOCM_DTR)
+		info->serial_signals |= SerialSignal_DTR;
+	if (clear & TIOCM_RTS)
+		info->serial_signals &= ~SerialSignal_RTS;
+	if (clear & TIOCM_DTR)
+		info->serial_signals &= ~SerialSignal_DTR;
+
 	spin_lock_irqsave(&info->irq_spinlock,flags);
  	usc_set_serial_signals(info);
 	spin_unlock_irqrestore(&info->irq_spinlock,flags);
-	
+
 	return 0;
-	
-}	/* end of set_modem_info() */
+}
 
 /* mgsl_break()		Set or clear transmit break condition
  *
@@ -3041,7 +2989,7 @@
 		printk("%s(%d):mgsl_break(%s,%d)\n",
 			 __FILE__,__LINE__, info->device_name, break_state);
 			 
-	if (mgsl_paranoia_check(info, tty->device, "mgsl_break"))
+	if (mgsl_paranoia_check(info, tty->name, "mgsl_break"))
 		return;
 
 	spin_lock_irqsave(&info->irq_spinlock,flags);
@@ -3073,7 +3021,7 @@
 		printk("%s(%d):mgsl_ioctl %s cmd=%08X\n", __FILE__,__LINE__,
 			info->device_name, cmd );
 	
-	if (mgsl_paranoia_check(info, tty->device, "mgsl_ioctl"))
+	if (mgsl_paranoia_check(info, tty->name, "mgsl_ioctl"))
 		return -ENODEV;
 
 	if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
@@ -3093,12 +3041,6 @@
 	unsigned long flags;
 	
 	switch (cmd) {
-		case TIOCMGET:
-			return get_modem_info(info, (unsigned int *) arg);
-		case TIOCMBIS:
-		case TIOCMBIC:
-		case TIOCMSET:
-			return set_modem_info(info, cmd, (unsigned int *) arg);
 		case MGSL_IOCGPARAMS:
 			return mgsl_get_params(info,(MGSL_PARAMS *)arg);
 		case MGSL_IOCSPARAMS:
@@ -3183,7 +3125,7 @@
 	
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):mgsl_set_termios %s\n", __FILE__,__LINE__,
-			tty->driver.name );
+			tty->driver->name );
 	
 	/* just return if nothing has changed */
 	if ((tty->termios->c_cflag == old_termios->c_cflag)
@@ -3240,7 +3182,7 @@
 {
 	struct mgsl_struct * info = (struct mgsl_struct *)tty->driver_data;
 
-	if (!info || mgsl_paranoia_check(info, tty->device, "mgsl_close"))
+	if (!info || mgsl_paranoia_check(info, tty->name, "mgsl_close"))
 		return;
 	
 	if (debug_level >= DEBUG_LEVEL_INFO)
@@ -3295,8 +3237,8 @@
  	if (info->flags & ASYNC_INITIALIZED)
  		mgsl_wait_until_sent(tty, info->timeout);
 
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 		
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
@@ -3322,8 +3264,7 @@
 cleanup:			
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
-			tty->driver.name, info->count);
-	MOD_DEC_USE_COUNT;
+			tty->driver->name, info->count);
 			
 }	/* end of mgsl_close() */
 
@@ -3350,7 +3291,7 @@
 		printk("%s(%d):mgsl_wait_until_sent(%s) entry\n",
 			 __FILE__,__LINE__, info->device_name );
       
-	if (mgsl_paranoia_check(info, tty->device, "mgsl_wait_until_sent"))
+	if (mgsl_paranoia_check(info, tty->name, "mgsl_wait_until_sent"))
 		return;
 
 	if (!(info->flags & ASYNC_INITIALIZED))
@@ -3419,7 +3360,7 @@
 		printk("%s(%d):mgsl_hangup(%s)\n",
 			 __FILE__,__LINE__, info->device_name );
 			 
-	if (mgsl_paranoia_check(info, tty->device, "mgsl_hangup"))
+	if (mgsl_paranoia_check(info, tty->name, "mgsl_hangup"))
 		return;
 
 	mgsl_flush_buffer(tty);
@@ -3456,9 +3397,9 @@
 	
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):block_til_ready on %s\n",
-			 __FILE__,__LINE__, tty->driver.name );
+			 __FILE__,__LINE__, tty->driver->name );
 
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		/* this is a callout device */
 		/* just verify that normal device is not in use */
 		if (info->flags & ASYNC_NORMAL_ACTIVE)
@@ -3504,7 +3445,7 @@
 	
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):block_til_ready before block on %s count=%d\n",
-			 __FILE__,__LINE__, tty->driver.name, info->count );
+			 __FILE__,__LINE__, tty->driver->name, info->count );
 
 	spin_lock_irqsave(&info->irq_spinlock, flags);
 	if (!tty_hung_up_p(filp)) {
@@ -3548,7 +3489,7 @@
 		
 		if (debug_level >= DEBUG_LEVEL_INFO)
 			printk("%s(%d):block_til_ready blocking on %s count=%d\n",
-				 __FILE__,__LINE__, tty->driver.name, info->count );
+				 __FILE__,__LINE__, tty->driver->name, info->count );
 				 
 		schedule();
 	}
@@ -3562,7 +3503,7 @@
 	
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
-			 __FILE__,__LINE__, tty->driver.name, info->count );
+			 __FILE__,__LINE__, tty->driver->name, info->count );
 			 
 	if (!retval)
 		info->flags |= ASYNC_NORMAL_ACTIVE;
@@ -3589,7 +3530,7 @@
 	unsigned long flags;
 
 	/* verify range of specified line number */	
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if ((line < 0) || (line >= mgsl_device_count)) {
 		printk("%s(%d):mgsl_open with illegal line #%d.\n",
 			__FILE__,__LINE__,line);
@@ -3608,15 +3549,13 @@
 	
 	tty->driver_data = info;
 	info->tty = tty;
-	if (mgsl_paranoia_check(info, tty->device, "mgsl_open"))
+	if (mgsl_paranoia_check(info, tty->name, "mgsl_open"))
 		return -ENODEV;
 		
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
-			 __FILE__,__LINE__,tty->driver.name, info->count);
+			 __FILE__,__LINE__,tty->driver->name, info->count);
 
-	MOD_INC_USE_COUNT;
-	
 	/* If port is closing, signal caller to try again */
 	if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){
 		if (info->flags & ASYNC_CLOSING)
@@ -3666,7 +3605,7 @@
 
 	if ((info->count == 1) &&
 	    info->flags & ASYNC_SPLIT_TERMIOS) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->normal_termios;
 		else 
 			*tty->termios = info->callout_termios;
@@ -3683,7 +3622,6 @@
 	
 cleanup:			
 	if (retval) {
-		MOD_DEC_USE_COUNT;
 		if(info->count)
 			info->count--;
 	}
@@ -4571,6 +4509,7 @@
 	
 	memset(&serial_driver, 0, sizeof(struct tty_driver));
 	serial_driver.magic = TTY_DRIVER_MAGIC;
+	serial_driver.owner = THIS_MODULE;
 	serial_driver.driver_name = "synclink";
 	serial_driver.name = "ttySL";
 	serial_driver.major = ttymajor;
@@ -4606,6 +4545,8 @@
 	serial_driver.stop = mgsl_stop;
 	serial_driver.start = mgsl_start;
 	serial_driver.hangup = mgsl_hangup;
+	serial_driver.tiocmget = tiocmget;
+	serial_driver.tiocmset = tiocmset;
 	
 	/*
 	 * The callout device is just like normal device except for
@@ -4667,7 +4608,7 @@
 		/* Copy user configuration info to device instance data */
 		info->io_base = (unsigned int)io[i];
 		info->irq_level = (unsigned int)irq[i];
-		info->irq_level = irq_cannonicalize(info->irq_level);
+		info->irq_level = irq_canonicalize(info->irq_level);
 		info->dma_level = (unsigned int)dma[i];
 		info->bus_type = MGSL_BUS_TYPE_ISA;
 		info->io_addr_size = 16;
@@ -8003,7 +7944,6 @@
 		return -EBUSY;
 	}
 	info->netcount=1;
-	MOD_INC_USE_COUNT;
 	spin_unlock_irqrestore(&info->netlock, flags);
 
 	/* claim resources and init adapter */
@@ -8026,7 +7966,6 @@
 open_fail:
 	spin_lock_irqsave(&info->netlock, flags);
 	info->netcount=0;
-	MOD_DEC_USE_COUNT;
 	spin_unlock_irqrestore(&info->netlock, flags);
 	return err;
 }
@@ -8092,7 +8031,6 @@
 
 	spin_lock_irqsave(&info->netlock, flags);
 	info->netcount=0;
-	MOD_DEC_USE_COUNT;
 	spin_unlock_irqrestore(&info->netlock, flags);
 	return 0;
 }
diff -Nru a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
--- a/drivers/char/synclinkmp.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/char/synclinkmp.c	Wed Apr 30 22:28:05 2003
@@ -1,5 +1,5 @@
 /*
- * $Id: synclinkmp.c,v 4.6 2002/10/10 14:50:47 paulkf Exp $
+ * $Id: synclinkmp.c,v 4.8 2003/04/21 17:46:55 paulkf Exp $
  *
  * Device driver for Microgate SyncLink Multiport
  * high speed multiprotocol serial adapter.
@@ -503,7 +503,7 @@
 MODULE_PARM(dosyncppp,"1-" __MODULE_STRING(MAX_DEVICES) "i");
 
 static char *driver_name = "SyncLink MultiPort driver";
-static char *driver_version = "$Revision: 4.6 $";
+static char *driver_version = "$Revision: 4.8 $";
 
 static int synclinkmp_init_one(struct pci_dev *dev,const struct pci_device_id *ent);
 static void synclinkmp_remove_one(struct pci_dev *dev);
@@ -592,8 +592,9 @@
 static int  map_status(int signals);
 static int  modem_input_wait(SLMP_INFO *info,int arg);
 static int  wait_mgsl_event(SLMP_INFO *info, int *mask_ptr);
-static int  get_modem_info(SLMP_INFO *info, unsigned int *value);
-static int  set_modem_info(SLMP_INFO *info, unsigned int cmd,unsigned int *value);
+static int  tiocmget(struct tty_struct *tty, struct file *file);
+static int  tiocmset(struct tty_struct *tty, struct file *file,
+		     unsigned int set, unsigned int clear);
 static void set_break(struct tty_struct *tty, int break_state);
 
 static void add_device(SLMP_INFO *info);
@@ -651,7 +652,6 @@
 static void isr_txdmaok(SLMP_INFO *info);
 static void isr_txdmaerror(SLMP_INFO *info);
 static void isr_io_pin(SLMP_INFO *info, u16 status);
-static void synclinkmp_interrupt(int irq, void *dev_id, struct pt_regs * regs);
 
 static int  alloc_dma_bufs(SLMP_INFO *info);
 static void free_dma_bufs(SLMP_INFO *info);
@@ -709,7 +709,7 @@
 static void* synclinkmp_get_text_ptr() {return synclinkmp_get_text_ptr;}
 
 static inline int sanity_check(SLMP_INFO *info,
-			       kdev_t device, const char *routine)
+			       char *name, const char *routine)
 {
 #ifdef SANITY_CHECK
 	static const char *badmagic =
@@ -718,11 +718,11 @@
 		"Warning: null synclinkmp_struct for (%s) in %s\n";
 
 	if (!info) {
-		printk(badinfo, cdevname(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (info->magic != MGSL_MAGIC) {
-		printk(badmagic, cdevname(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -739,7 +739,7 @@
 	int retval, line;
 	unsigned long flags;
 
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if ((line < 0) || (line >= synclinkmp_device_count)) {
 		printk("%s(%d): open with illegal line #%d.\n",
 			__FILE__,__LINE__,line);
@@ -763,14 +763,12 @@
 
 	tty->driver_data = info;
 	info->tty = tty;
-	if (sanity_check(info, tty->device, "open"))
+	if (sanity_check(info, tty->name, "open"))
 		return -ENODEV;
 
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):%s open(), old ref count = %d\n",
-			 __FILE__,__LINE__,tty->driver.name, info->count);
-
-	MOD_INC_USE_COUNT;
+			 __FILE__,__LINE__,tty->driver->name, info->count);
 
 	/* If port is closing, signal caller to try again */
 	if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){
@@ -809,7 +807,7 @@
 
 	if ((info->count == 1) &&
 	    info->flags & ASYNC_SPLIT_TERMIOS) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->normal_termios;
 		else
 			*tty->termios = info->callout_termios;
@@ -826,7 +824,6 @@
 
 cleanup:
 	if (retval) {
-		MOD_DEC_USE_COUNT;
 		if(info->count)
 			info->count--;
 	}
@@ -841,7 +838,7 @@
 {
 	SLMP_INFO * info = (SLMP_INFO *)tty->driver_data;
 
-	if (!info || sanity_check(info, tty->device, "close"))
+	if (!info || sanity_check(info, tty->name, "close"))
 		return;
 
 	if (debug_level >= DEBUG_LEVEL_INFO)
@@ -897,8 +894,8 @@
  	if (info->flags & ASYNC_INITIALIZED)
  		wait_until_sent(tty, info->timeout);
 
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
@@ -924,8 +921,7 @@
 cleanup:
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
-			tty->driver.name, info->count);
-	MOD_DEC_USE_COUNT;
+			tty->driver->name, info->count);
 }
 
 /* Called by tty_hangup() when a hangup is signaled.
@@ -939,7 +935,7 @@
 		printk("%s(%d):%s hangup()\n",
 			 __FILE__,__LINE__, info->device_name );
 
-	if (sanity_check(info, tty->device, "hangup"))
+	if (sanity_check(info, tty->name, "hangup"))
 		return;
 
 	flush_buffer(tty);
@@ -961,7 +957,7 @@
 
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):%s set_termios()\n", __FILE__,__LINE__,
-			tty->driver.name );
+			tty->driver->name );
 
 	/* just return if nothing has changed */
 	if ((tty->termios->c_cflag == old_termios->c_cflag)
@@ -1023,7 +1019,7 @@
 		printk("%s(%d):%s write() count=%d\n",
 		       __FILE__,__LINE__,info->device_name,count);
 
-	if (sanity_check(info, tty->device, "write"))
+	if (sanity_check(info, tty->name, "write"))
 		goto cleanup;
 
 	if (!tty || !info->tx_buf)
@@ -1112,7 +1108,7 @@
 			__FILE__,__LINE__,info->device_name,ch);
 	}
 
-	if (sanity_check(info, tty->device, "put_char"))
+	if (sanity_check(info, tty->name, "put_char"))
 		return;
 
 	if (!tty || !info->tx_buf)
@@ -1145,7 +1141,7 @@
 		printk("%s(%d):%s send_xchar(%d)\n",
 			 __FILE__,__LINE__, info->device_name, ch );
 
-	if (sanity_check(info, tty->device, "send_xchar"))
+	if (sanity_check(info, tty->name, "send_xchar"))
 		return;
 
 	info->x_char = ch;
@@ -1172,7 +1168,7 @@
 		printk("%s(%d):%s wait_until_sent() entry\n",
 			 __FILE__,__LINE__, info->device_name );
 
-	if (sanity_check(info, tty->device, "wait_until_sent"))
+	if (sanity_check(info, tty->name, "wait_until_sent"))
 		return;
 
 	if (!(info->flags & ASYNC_INITIALIZED))
@@ -1231,7 +1227,7 @@
 	SLMP_INFO *info = (SLMP_INFO *)tty->driver_data;
 	int ret;
 
-	if (sanity_check(info, tty->device, "write_room"))
+	if (sanity_check(info, tty->name, "write_room"))
 		return 0;
 
 	if (info->params.mode == MGSL_MODE_HDLC) {
@@ -1260,7 +1256,7 @@
 		printk( "%s(%d):%s flush_chars() entry tx_count=%d\n",
 			__FILE__,__LINE__,info->device_name,info->tx_count);
 
-	if (sanity_check(info, tty->device, "flush_chars"))
+	if (sanity_check(info, tty->name, "flush_chars"))
 		return;
 
 	if (info->tx_count <= 0 || tty->stopped || tty->hw_stopped ||
@@ -1299,7 +1295,7 @@
 		printk("%s(%d):%s flush_buffer() entry\n",
 			 __FILE__,__LINE__, info->device_name );
 
-	if (sanity_check(info, tty->device, "flush_buffer"))
+	if (sanity_check(info, tty->name, "flush_buffer"))
 		return;
 
 	spin_lock_irqsave(&info->lock,flags);
@@ -1320,7 +1316,7 @@
 	SLMP_INFO *info = (SLMP_INFO *)tty->driver_data;
 	unsigned long flags;
 
-	if (sanity_check(info, tty->device, "tx_hold"))
+	if (sanity_check(info, tty->name, "tx_hold"))
 		return;
 
 	if ( debug_level >= DEBUG_LEVEL_INFO )
@@ -1340,7 +1336,7 @@
 	SLMP_INFO *info = (SLMP_INFO *)tty->driver_data;
 	unsigned long flags;
 
-	if (sanity_check(info, tty->device, "tx_release"))
+	if (sanity_check(info, tty->name, "tx_release"))
 		return;
 
 	if ( debug_level >= DEBUG_LEVEL_INFO )
@@ -1377,7 +1373,7 @@
 		printk("%s(%d):%s ioctl() cmd=%08X\n", __FILE__,__LINE__,
 			info->device_name, cmd );
 
-	if (sanity_check(info, tty->device, "ioctl"))
+	if (sanity_check(info, tty->name, "ioctl"))
 		return -ENODEV;
 
 	if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
@@ -1387,12 +1383,6 @@
 	}
 
 	switch (cmd) {
-	case TIOCMGET:
-		return get_modem_info(info, (unsigned int *) arg);
-	case TIOCMBIS:
-	case TIOCMBIC:
-	case TIOCMSET:
-		return set_modem_info(info, cmd, (unsigned int *) arg);
 	case MGSL_IOCGPARAMS:
 		return get_params(info,(MGSL_PARAMS *)arg);
 	case MGSL_IOCSPARAMS:
@@ -1575,7 +1565,7 @@
 {
 	SLMP_INFO *info = (SLMP_INFO *)tty->driver_data;
 
-	if (sanity_check(info, tty->device, "chars_in_buffer"))
+	if (sanity_check(info, tty->name, "chars_in_buffer"))
 		return 0;
 
 	if (debug_level >= DEBUG_LEVEL_INFO)
@@ -1596,7 +1586,7 @@
 		printk("%s(%d):%s throttle() entry\n",
 			 __FILE__,__LINE__, info->device_name );
 
-	if (sanity_check(info, tty->device, "throttle"))
+	if (sanity_check(info, tty->name, "throttle"))
 		return;
 
 	if (I_IXOFF(tty))
@@ -1621,7 +1611,7 @@
 		printk("%s(%d):%s unthrottle() entry\n",
 			 __FILE__,__LINE__, info->device_name );
 
-	if (sanity_check(info, tty->device, "unthrottle"))
+	if (sanity_check(info, tty->name, "unthrottle"))
 		return;
 
 	if (I_IXOFF(tty)) {
@@ -1652,7 +1642,7 @@
 		printk("%s(%d):%s set_break(%d)\n",
 			 __FILE__,__LINE__, info->device_name, break_state);
 
-	if (sanity_check(info, tty->device, "set_break"))
+	if (sanity_check(info, tty->name, "set_break"))
 		return;
 
 	spin_lock_irqsave(&info->lock,flags);
@@ -1717,7 +1707,7 @@
 {
 	SLMP_INFO *info = d->priv;
 	int err;
-	long flags;
+	unsigned long flags;
 
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("sppp_cb_open(%s)\n",info->netname);
@@ -1729,7 +1719,6 @@
 		return -EBUSY;
 	}
 	info->netcount=1;
-	MOD_INC_USE_COUNT;
 	spin_unlock_irqrestore(&info->netlock, flags);
 
 	/* claim resources and init adapter */
@@ -1752,7 +1741,6 @@
 open_fail:
 	spin_lock_irqsave(&info->netlock, flags);
 	info->netcount=0;
-	MOD_DEC_USE_COUNT;
 	spin_unlock_irqrestore(&info->netlock, flags);
 	return err;
 }
@@ -1760,7 +1748,7 @@
 static void sppp_cb_tx_timeout(struct net_device *dev)
 {
 	SLMP_INFO *info = dev->priv;
-	long flags;
+	unsigned long flags;
 
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("sppp_tx_timeout(%s)\n",info->netname);
@@ -1818,7 +1806,6 @@
 
 	spin_lock_irqsave(&info->netlock, flags);
 	info->netcount=0;
-	MOD_DEC_USE_COUNT;
 	spin_unlock_irqrestore(&info->netlock, flags);
 	return 0;
 }
@@ -2458,7 +2445,8 @@
  * 	dev_id		device ID supplied during interrupt registration
  * 	regs		interrupted processor context
  */
-static void synclinkmp_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t synclinkmp_interrupt(int irq, void *dev_id,
+					struct pt_regs *regs)
 {
 	SLMP_INFO * info;
 	unsigned char status, status0, status1=0;
@@ -2474,7 +2462,7 @@
 
 	info = (SLMP_INFO *)dev_id;
 	if (!info)
-		return;
+		return IRQ_NONE;
 
 	spin_lock(&info->lock);
 
@@ -2576,6 +2564,7 @@
 	if ( debug_level >= DEBUG_LEVEL_ISR )
 		printk("%s(%d):synclinkmp_interrupt(%d)exit.\n",
 			__FILE__,__LINE__,irq);
+	return IRQ_HANDLED;
 }
 
 /* Initialize and start device.
@@ -3146,11 +3135,11 @@
 
 /* return the state of the serial control and status signals
  */
-static int get_modem_info(SLMP_INFO * info, unsigned int *value)
+static int tiocmget(struct tty_struct *tty, struct file *file)
 {
+	SLMP_INFO *info = (SLMP_INFO *)tty->driver_data;
 	unsigned int result;
  	unsigned long flags;
-	int err;
 
 	spin_lock_irqsave(&info->lock,flags);
  	get_signals(info);
@@ -3164,61 +3153,31 @@
 		((info->serial_signals & SerialSignal_CTS) ? TIOCM_CTS:0);
 
 	if (debug_level >= DEBUG_LEVEL_INFO)
-		printk("%s(%d):%s synclinkmp_get_modem_info() value=%08X\n",
+		printk("%s(%d):%s tiocmget() value=%08X\n",
 			 __FILE__,__LINE__, info->device_name, result );
-
-	PUT_USER(err,result,value);
-	return err;
+	return result;
 }
 
 /* set modem control signals (DTR/RTS)
- *
- * 	cmd	signal command: TIOCMBIS = set bit TIOCMBIC = clear bit
- *		TIOCMSET = set/clear signal values
- * 	value	bit mask for command
  */
-static int set_modem_info(SLMP_INFO * info, unsigned int cmd,
-			  unsigned int *value)
+static int tiocmset(struct tty_struct *tty, struct file *file,
+		    unsigned int set, unsigned int clear)
 {
- 	int error;
- 	unsigned int arg;
+	SLMP_INFO *info = (SLMP_INFO *)tty->driver_data;
  	unsigned long flags;
 
 	if (debug_level >= DEBUG_LEVEL_INFO)
-		printk("%s(%d):%s synclinkmp_set_modem_info()\n",
-			__FILE__,__LINE__,info->device_name );
+		printk("%s(%d):%s tiocmset(%x,%x)\n",
+			__FILE__,__LINE__,info->device_name, set, clear);
 
- 	GET_USER(error,arg,value);
- 	if (error)
- 		return error;
-
- 	switch (cmd) {
- 	case TIOCMBIS:
- 		if (arg & TIOCM_RTS)
- 			info->serial_signals |= SerialSignal_RTS;
- 		if (arg & TIOCM_DTR)
- 			info->serial_signals |= SerialSignal_DTR;
- 		break;
- 	case TIOCMBIC:
- 		if (arg & TIOCM_RTS)
- 			info->serial_signals &= ~SerialSignal_RTS;
- 		if (arg & TIOCM_DTR)
- 			info->serial_signals &= ~SerialSignal_DTR;
- 		break;
- 	case TIOCMSET:
- 		if (arg & TIOCM_RTS)
- 			info->serial_signals |= SerialSignal_RTS;
-		else
- 			info->serial_signals &= ~SerialSignal_RTS;
-
- 		if (arg & TIOCM_DTR)
- 			info->serial_signals |= SerialSignal_DTR;
-		else
- 			info->serial_signals &= ~SerialSignal_DTR;
- 		break;
- 	default:
- 		return -EINVAL;
- 	}
+	if (set & TIOCM_RTS)
+		info->serial_signals |= SerialSignal_RTS;
+	if (set & TIOCM_DTR)
+		info->serial_signals |= SerialSignal_DTR;
+	if (clear & TIOCM_RTS)
+		info->serial_signals &= ~SerialSignal_RTS;
+	if (clear & TIOCM_DTR)
+		info->serial_signals &= ~SerialSignal_DTR;
 
 	spin_lock_irqsave(&info->lock,flags);
  	set_signals(info);
@@ -3241,9 +3200,9 @@
 
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):%s block_til_ready()\n",
-			 __FILE__,__LINE__, tty->driver.name );
+			 __FILE__,__LINE__, tty->driver->name );
 
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		/* this is a callout device */
 		/* just verify that normal device is not in use */
 		if (info->flags & ASYNC_NORMAL_ACTIVE)
@@ -3289,7 +3248,7 @@
 
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):%s block_til_ready() before block, count=%d\n",
-			 __FILE__,__LINE__, tty->driver.name, info->count );
+			 __FILE__,__LINE__, tty->driver->name, info->count );
 
 	spin_lock_irqsave(&info->lock, flags);
 	if (!tty_hung_up_p(filp)) {
@@ -3333,7 +3292,7 @@
 
 		if (debug_level >= DEBUG_LEVEL_INFO)
 			printk("%s(%d):%s block_til_ready() count=%d\n",
-				 __FILE__,__LINE__, tty->driver.name, info->count );
+				 __FILE__,__LINE__, tty->driver->name, info->count );
 
 		schedule();
 	}
@@ -3347,7 +3306,7 @@
 
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):%s block_til_ready() after, count=%d\n",
-			 __FILE__,__LINE__, tty->driver.name, info->count );
+			 __FILE__,__LINE__, tty->driver->name, info->count );
 
 	if (!retval)
 		info->flags |= ASYNC_NORMAL_ACTIVE;
@@ -3875,6 +3834,7 @@
 
 	memset(&serial_driver, 0, sizeof(struct tty_driver));
 	serial_driver.magic = TTY_DRIVER_MAGIC;
+	serial_driver.owner = THIS_MODULE;
 	serial_driver.driver_name = "synclinkmp";
 	serial_driver.name = "ttySLM";
 	serial_driver.major = ttymajor;
@@ -3910,6 +3870,8 @@
 	serial_driver.stop = tx_hold;
 	serial_driver.start = tx_release;
 	serial_driver.hangup = hangup;
+	serial_driver.tiocmget = tiocmget;
+	serial_driver.tiocmset = tiocmset;
 
 	/*
 	 * The callout device is just like normal device except for
diff -Nru a/drivers/char/tpqic02.c b/drivers/char/tpqic02.c
--- a/drivers/char/tpqic02.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/char/tpqic02.c	Wed Apr 30 22:28:09 2003
@@ -509,7 +509,7 @@
 static int wait_for_ready(time_t timeout)
 {
 	int stat;
-	time_t spin_t;
+	unsigned long spin_t;
 
 	/* Wait for ready or exception, without driving the loadavg up too much.
 	 * In most cases, the tape drive already has READY asserted,
@@ -1604,7 +1604,7 @@
  * When we are finished, set flags to indicate end, disable timer.
  * NOTE: This *must* be fast! 
  */
-static void qic02_tape_interrupt(int irq, void *dev_id,
+static irqreturn_t qic02_tape_interrupt(int irq, void *dev_id,
 				 struct pt_regs *regs)
 {
 	int stat, r, i;
@@ -1622,7 +1622,7 @@
 			if (((stat & (AR_STAT_DMADONE)) == 0) &&
 			    ((stat & (QIC02_STAT_EXCEPTION)) != 0)) {
 				TIMERCONT;
-				return;	/* "Linux with IRQ sharing" */
+				return IRQ_NONE;/* "Linux with IRQ sharing" */
 			}
 		}
 
@@ -1642,7 +1642,7 @@
 			dma_mode = 0;	/* wake up rw() */
 			status_expect_int = NO;
 			wake_up(&qic02_tape_transfer);
-			return;
+			return IRQ_HANDLED;
 		}
 		/* return if tape controller not ready, or
 		 * if dma channel hasn't finished last byte yet.
@@ -1668,7 +1668,7 @@
 		release_dma_lock(flags);
 
 		if (r)
-			return;
+			return IRQ_HANDLED;
 
 		/* finish DMA cycle */
 
@@ -1688,6 +1688,7 @@
 	} else {
 		printk(TPQIC02_NAME ": Unexpected interrupt, stat == %x\n", inb(QIC02_STAT_PORT));
 	}
+	return IRQ_HANDLED;
 }				/* qic02_tape_interrupt */
 
 
diff -Nru a/drivers/char/tty_io.c b/drivers/char/tty_io.c
--- a/drivers/char/tty_io.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/char/tty_io.c	Wed Apr 30 22:28:10 2003
@@ -126,8 +126,8 @@
 struct tty_ldisc ldiscs[NR_LDISCS];	/* line disc dispatch table	*/
 
 #ifdef CONFIG_UNIX98_PTYS
-extern struct tty_driver ptm_driver[];	/* Unix98 pty masters; for /dev/ptmx */
-extern struct tty_driver pts_driver[];	/* Unix98 pty slaves;  for /dev/ptmx */
+extern struct tty_driver ptm_driver;	/* Unix98 pty masters; for /dev/ptmx */
+extern struct tty_driver pts_driver;	/* Unix98 pty slaves;  for /dev/ptmx */
 #endif
 
 extern void disable_early_printk(void);
@@ -172,31 +172,17 @@
 	kfree(tty);
 }
 
-/*
- * This routine returns the name of tty.
- */
-static char *
-_tty_make_name(struct tty_struct *tty, const char *name, char *buf)
-{
-	int idx = (tty)? minor(tty->device) - tty->driver.minor_start:0;
+#define TTY_NUMBER(tty) ((tty)->index + (tty)->driver->name_base)
 
+char *tty_name(struct tty_struct *tty, char *buf)
+{
 	if (!tty) /* Hmm.  NULL pointer.  That's fun. */
 		strcpy(buf, "NULL tty");
 	else
-		sprintf(buf, name,
-			idx + tty->driver.name_base);
-		
+		strcpy(buf, tty->name);
 	return buf;
 }
 
-#define TTY_NUMBER(tty) (minor((tty)->device) - (tty)->driver.minor_start + \
-			 (tty)->driver.name_base)
-
-char *tty_name(struct tty_struct *tty, char *buf)
-{
-	return _tty_make_name(tty, (tty)?tty->driver.name:NULL, buf);
-}
-
 EXPORT_SYMBOL(tty_name);
 
 inline int tty_paranoia_check(struct tty_struct *tty, kdev_t device,
@@ -231,14 +217,14 @@
 		count++;
 	}
 	file_list_unlock();
-	if (tty->driver.type == TTY_DRIVER_TYPE_PTY &&
-	    tty->driver.subtype == PTY_TYPE_SLAVE &&
+	if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
+	    tty->driver->subtype == PTY_TYPE_SLAVE &&
 	    tty->link && tty->link->count)
 		count++;
 	if (tty->count != count) {
 		printk(KERN_WARNING "Warning: dev (%s) tty->count(%d) "
 				    "!= #fd's(%d) in %s\n",
-		       cdevname(tty->device), tty->count, count, routine);
+		       tty->name, tty->count, count, routine);
 		return count;
        }	
 #endif
@@ -319,29 +305,23 @@
 		module_put(o_ldisc.owner);
 	}
 	
-	if (tty->ldisc.num != o_ldisc.num && tty->driver.set_ldisc)
-		tty->driver.set_ldisc(tty);
+	if (tty->ldisc.num != o_ldisc.num && tty->driver->set_ldisc)
+		tty->driver->set_ldisc(tty);
 	return retval;
 }
 
 /*
  * This routine returns a tty driver structure, given a device number
  */
-struct tty_driver *get_tty_driver(kdev_t device)
+struct tty_driver *get_tty_driver(dev_t device, int *index)
 {
-	int	major, minor;
 	struct tty_driver *p;
-	
-	minor = minor(device);
-	major = major(device);
 
 	list_for_each_entry(p, &tty_drivers, tty_drivers) {
-		if (p->major != major)
-			continue;
-		if (minor < p->minor_start)
-			continue;
-		if (minor >= p->minor_start + p->num)
+		dev_t base = MKDEV(p->major, p->minor_start);
+		if (device < base || device >= base + p->num)
 			continue;
+		*index = device - base;
 		return p;
 	}
 	return NULL;
@@ -466,8 +446,8 @@
 		local_irq_save(flags); // FIXME: is this safe?
 		if (tty->ldisc.flush_buffer)
 			tty->ldisc.flush_buffer(tty);
-		if (tty->driver.flush_buffer)
-			tty->driver.flush_buffer(tty);
+		if (tty->driver->flush_buffer)
+			tty->driver->flush_buffer(tty);
 		if ((test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags)) &&
 		    tty->ldisc.write_wakeup)
 			(tty->ldisc.write_wakeup)(tty);
@@ -481,8 +461,8 @@
 	 * Shutdown the current line discipline, and reset it to
 	 * N_TTY.
 	 */
-	if (tty->driver.flags & TTY_DRIVER_RESET_TERMIOS)
-		*tty->termios = tty->driver.init_termios;
+	if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS)
+		*tty->termios = tty->driver->init_termios;
 	if (tty->ldisc.num != ldiscs[N_TTY].num) {
 		if (tty->ldisc.close)
 			(tty->ldisc.close)(tty);
@@ -525,11 +505,11 @@
 	 *	So we just call close() the right number of times.
 	 */
 	if (cons_filp) {
-		if (tty->driver.close)
+		if (tty->driver->close)
 			for (n = 0; n < closecount; n++)
-				tty->driver.close(tty, cons_filp);
-	} else if (tty->driver.hangup)
-		(tty->driver.hangup)(tty);
+				tty->driver->close(tty, cons_filp);
+	} else if (tty->driver->hangup)
+		(tty->driver->hangup)(tty);
 	unlock_kernel();
 }
 
@@ -589,7 +569,7 @@
 	tty = current->tty;
 	if (tty) {
 		tty_pgrp = tty->pgrp;
-		if (on_exit && tty->driver.type != TTY_DRIVER_TYPE_PTY)
+		if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY)
 			tty_vhangup(tty);
 	} else {
 		if (current->tty_old_pgrp) {
@@ -626,8 +606,8 @@
 		tty->ctrl_status |= TIOCPKT_STOP;
 		wake_up_interruptible(&tty->link->read_wait);
 	}
-	if (tty->driver.stop)
-		(tty->driver.stop)(tty);
+	if (tty->driver->stop)
+		(tty->driver->stop)(tty);
 }
 
 void start_tty(struct tty_struct *tty)
@@ -640,8 +620,8 @@
 		tty->ctrl_status |= TIOCPKT_START;
 		wake_up_interruptible(&tty->link->read_wait);
 	}
-	if (tty->driver.start)
-		(tty->driver.start)(tty);
+	if (tty->driver->start)
+		(tty->driver->start)(tty);
 	if ((test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags)) &&
 	    tty->ldisc.write_wakeup)
 		(tty->ldisc.write_wakeup)(tty);
@@ -768,7 +748,7 @@
 		tty = (struct tty_struct *)file->private_data;
 	if (tty_paranoia_check(tty, inode->i_rdev, "tty_write"))
 		return -EIO;
-	if (!tty || !tty->driver.write || (test_bit(TTY_IO_ERROR, &tty->flags)))
+	if (!tty || !tty->driver->write || (test_bit(TTY_IO_ERROR, &tty->flags)))
 		return -EIO;
 #if 0
 	if (!is_console && L_TOSTOP(tty) && (tty->pgrp > 0) &&
@@ -802,26 +782,24 @@
 
 static void release_mem(struct tty_struct *tty, int idx);
 
+static inline void tty_line_name(struct tty_driver *driver, int index, char *p)
+{
+	sprintf(p, "%s%d", driver->name, index + driver->name_base);
+}
+
 /*
  * WSH 06/09/97: Rewritten to remove races and properly clean up after a
  * failed open.  The new code protects the open with a semaphore, so it's
  * really quite straightforward.  The semaphore locking can probably be
  * relaxed for the (most common) case of reopening a tty.
  */
-static int init_dev(kdev_t device, struct tty_struct **ret_tty)
+static int init_dev(struct tty_driver *driver, int idx,
+	struct tty_struct **ret_tty)
 {
 	struct tty_struct *tty, *o_tty;
 	struct termios *tp, **tp_loc, *o_tp, **o_tp_loc;
 	struct termios *ltp, **ltp_loc, *o_ltp, **o_ltp_loc;
-	struct tty_driver *driver;	
 	int retval=0;
-	int idx;
-
-	driver = get_tty_driver(device);
-	if (!driver)
-		return -ENODEV;
-
-	idx = minor(device) - driver->minor_start;
 
 	/* 
 	 * Check whether we need to acquire the tty semaphore to avoid
@@ -854,8 +832,10 @@
 	if(!tty)
 		goto fail_no_mem;
 	initialize_tty_struct(tty);
-	tty->device = device;
-	tty->driver = *driver;
+	tty->device = MKDEV(driver->major, driver->minor_start) + idx;
+	tty->driver = driver;
+	tty->index = idx;
+	tty_line_name(driver, idx, tty->name);
 
 	tp_loc = &driver->termios[idx];
 	if (!*tp_loc) {
@@ -880,9 +860,11 @@
 		if (!o_tty)
 			goto free_mem_out;
 		initialize_tty_struct(o_tty);
-		o_tty->device = mk_kdev(driver->other->major,
-					driver->other->minor_start + idx);
-		o_tty->driver = *driver->other;
+		o_tty->device = MKDEV(driver->other->major,
+					driver->other->minor_start) + idx;
+		o_tty->driver = driver->other;
+		o_tty->index = idx;
+		tty_line_name(driver->other, idx, o_tty->name);
 
 		o_tp_loc  = &driver->other->termios[idx];
 		if (!*o_tp_loc) {
@@ -981,7 +963,7 @@
 		tty->link->count++;
 	}
 	tty->count++;
-	tty->driver = *driver; /* N.B. why do this every time?? */
+	tty->driver = driver; /* N.B. why do this every time?? */
 
 success:
 	*ret_tty = tty;
@@ -1026,32 +1008,32 @@
 	struct termios *tp;
 
 	if ((o_tty = tty->link) != NULL) {
-		o_tty->driver.table[idx] = NULL;
-		if (o_tty->driver.flags & TTY_DRIVER_RESET_TERMIOS) {
-			tp = o_tty->driver.termios[idx];
-			o_tty->driver.termios[idx] = NULL;
+		o_tty->driver->table[idx] = NULL;
+		if (o_tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) {
+			tp = o_tty->driver->termios[idx];
+			o_tty->driver->termios[idx] = NULL;
 			kfree(tp);
 		}
 		o_tty->magic = 0;
-		(*o_tty->driver.refcount)--;
+		(*o_tty->driver->refcount)--;
 		file_list_lock();
 		list_del(&o_tty->tty_files);
 		file_list_unlock();
 		free_tty_struct(o_tty);
 	}
 
-	tty->driver.table[idx] = NULL;
-	if (tty->driver.flags & TTY_DRIVER_RESET_TERMIOS) {
-		tp = tty->driver.termios[idx];
-		tty->driver.termios[idx] = NULL;
+	tty->driver->table[idx] = NULL;
+	if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) {
+		tp = tty->driver->termios[idx];
+		tty->driver->termios[idx] = NULL;
 		kfree(tp);
 	}
 	tty->magic = 0;
-	(*tty->driver.refcount)--;
+	(*tty->driver->refcount)--;
 	file_list_lock();
 	list_del(&tty->tty_files);
 	file_list_unlock();
-	module_put(tty->driver.owner);
+	module_put(tty->driver->owner);
 	free_tty_struct(tty);
 }
 
@@ -1078,32 +1060,32 @@
 
 	tty_fasync(-1, filp, 0);
 
-	idx = minor(tty->device) - tty->driver.minor_start;
-	pty_master = (tty->driver.type == TTY_DRIVER_TYPE_PTY &&
-		      tty->driver.subtype == PTY_TYPE_MASTER);
+	idx = tty->index;
+	pty_master = (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
+		      tty->driver->subtype == PTY_TYPE_MASTER);
 	o_tty = tty->link;
 
 #ifdef TTY_PARANOIA_CHECK
-	if (idx < 0 || idx >= tty->driver.num) {
+	if (idx < 0 || idx >= tty->driver->num) {
 		printk(KERN_DEBUG "release_dev: bad idx when trying to "
-				  "free (%s)\n", cdevname(tty->device));
+				  "free (%s)\n", tty->name);
 		return;
 	}
-	if (tty != tty->driver.table[idx]) {
+	if (tty != tty->driver->table[idx]) {
 		printk(KERN_DEBUG "release_dev: driver.table[%d] not tty "
-				  "for (%s)\n", idx, cdevname(tty->device));
+				  "for (%s)\n", idx, tty->name);
 		return;
 	}
-	if (tty->termios != tty->driver.termios[idx]) {
+	if (tty->termios != tty->driver->termios[idx]) {
 		printk(KERN_DEBUG "release_dev: driver.termios[%d] not termios "
 		       "for (%s)\n",
-		       idx, cdevname(tty->device));
+		       idx, tty->name);
 		return;
 	}
-	if (tty->termios_locked != tty->driver.termios_locked[idx]) {
+	if (tty->termios_locked != tty->driver->termios_locked[idx]) {
 		printk(KERN_DEBUG "release_dev: driver.termios_locked[%d] not "
 		       "termios_locked for (%s)\n",
-		       idx, cdevname(tty->device));
+		       idx, tty->name);
 		return;
 	}
 #endif
@@ -1114,24 +1096,24 @@
 #endif
 
 #ifdef TTY_PARANOIA_CHECK
-	if (tty->driver.other) {
-		if (o_tty != tty->driver.other->table[idx]) {
+	if (tty->driver->other) {
+		if (o_tty != tty->driver->other->table[idx]) {
 			printk(KERN_DEBUG "release_dev: other->table[%d] "
 					  "not o_tty for (%s)\n",
-			       idx, cdevname(tty->device));
+			       idx, tty->name);
 			return;
 		}
-		if (o_tty->termios != tty->driver.other->termios[idx]) {
+		if (o_tty->termios != tty->driver->other->termios[idx]) {
 			printk(KERN_DEBUG "release_dev: other->termios[%d] "
 					  "not o_termios for (%s)\n",
-			       idx, cdevname(tty->device));
+			       idx, tty->name);
 			return;
 		}
 		if (o_tty->termios_locked != 
-		      tty->driver.other->termios_locked[idx]) {
+		      tty->driver->other->termios_locked[idx]) {
 			printk(KERN_DEBUG "release_dev: other->termios_locked["
 					  "%d] not o_termios_locked for (%s)\n",
-			       idx, cdevname(tty->device));
+			       idx, tty->name);
 			return;
 		}
 		if (o_tty->link != tty) {
@@ -1141,8 +1123,8 @@
 	}
 #endif
 
-	if (tty->driver.close)
-		tty->driver.close(tty, filp);
+	if (tty->driver->close)
+		tty->driver->close(tty, filp);
 
 	/*
 	 * Sanity check: if tty->count is going to zero, there shouldn't be
@@ -1320,6 +1302,8 @@
 {
 	struct tty_struct *tty;
 	int noctty, retval;
+	struct tty_driver *driver;
+	int index;
 	kdev_t device;
 	unsigned short saved_flags;
 	char	buf[64];
@@ -1331,58 +1315,60 @@
 	if (IS_TTY_DEV(device)) {
 		if (!current->tty)
 			return -ENXIO;
-		device = current->tty->device;
+		driver = current->tty->driver;
+		index = current->tty->index;
 		filp->f_flags |= O_NONBLOCK; /* Don't let /dev/tty block */
 		/* noctty = 1; */
+		goto got_driver;
 	}
 #ifdef CONFIG_VT
 	if (IS_CONSOLE_DEV(device)) {
 		extern int fg_console;
-		device = mk_kdev(TTY_MAJOR, fg_console + 1);
+		extern struct tty_driver console_driver;
+		driver = &console_driver;
+		index = fg_console;
 		noctty = 1;
+		goto got_driver;
 	}
 #endif
 	if (IS_SYSCONS_DEV(device)) {
 		struct console *c = console_drivers;
-		while(c && !c->device)
-			c = c->next;
-		if (!c)
-                        return -ENODEV;
-                device = c->device(c);
-		filp->f_flags |= O_NONBLOCK; /* Don't let /dev/console block */
-		noctty = 1;
+		for (c = console_drivers; c; c = c->next) {
+			if (!c->device)
+				continue;
+			driver = c->device(c, &index);
+			if (!driver)
+				continue;
+			/* Don't let /dev/console block */
+			filp->f_flags |= O_NONBLOCK;
+			noctty = 1;
+			goto got_driver;
+		}
+		return -ENODEV;
 	}
 
 	if (IS_PTMX_DEV(device)) {
 #ifdef CONFIG_UNIX98_PTYS
-		/* find a free pty. */
-		int major, minor;
-		struct tty_driver *driver;
-
 		/* find a device that is not in use. */
 		retval = -1;
-		for (major = 0 ; major < UNIX98_NR_MAJORS ; major++) {
-			driver = &ptm_driver[major];
-			for (minor = driver->minor_start;
-			     minor < driver->minor_start + driver->num;
-			     minor++) {
-				device = mk_kdev(driver->major, minor);
-				if (!init_dev(device, &tty))
-					goto ptmx_found; /* ok! */
-			}
-		}
+		driver = &ptm_driver;
+		for (index = 0; index < driver->num ; index++)
+			if (!init_dev(driver, index, &tty))
+				goto ptmx_found; /* ok! */
 		return -EIO; /* no free ptys */
-
 	ptmx_found:
 		set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
-		minor -= driver->minor_start;
-		devpts_pty_new(driver->other->name_base + minor, MKDEV(driver->other->major, minor + driver->other->minor_start));
+		devpts_pty_new(index, MKDEV(pts_driver.major, pts_driver.minor_start) + index);
 		noctty = 1;
 #else
 		return -ENODEV;
 #endif  /* CONFIG_UNIX_98_PTYS */
 	} else {
-		retval = init_dev(device, &tty);
+		driver = get_tty_driver(kdev_t_to_nr(device), &index);
+		if (!driver)
+			return -ENODEV;
+got_driver:
+		retval = init_dev(driver, index, &tty);
 		if (retval)
 			return retval;
 	}
@@ -1390,14 +1376,14 @@
 	filp->private_data = tty;
 	file_move(filp, &tty->tty_files);
 	check_tty_count(tty, "tty_open");
-	if (tty->driver.type == TTY_DRIVER_TYPE_PTY &&
-	    tty->driver.subtype == PTY_TYPE_MASTER)
+	if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
+	    tty->driver->subtype == PTY_TYPE_MASTER)
 		noctty = 1;
 #ifdef TTY_DEBUG_HANGUP
 	printk(KERN_DEBUG "opening %s...", tty_name(tty, buf));
 #endif
-	if (tty->driver.open)
-		retval = tty->driver.open(tty, filp);
+	if (tty->driver->open)
+		retval = tty->driver->open(tty, filp);
 	else
 		retval = -ENODEV;
 	filp->f_flags = saved_flags;
@@ -1434,8 +1420,8 @@
 		tty->session = current->session;
 		tty->pgrp = current->pgrp;
 	}
-	if ((tty->driver.type == TTY_DRIVER_TYPE_SERIAL) &&
-	    (tty->driver.subtype == SERIAL_TYPE_CALLOUT) &&
+	if ((tty->driver->type == TTY_DRIVER_TYPE_SERIAL) &&
+	    (tty->driver->subtype == SERIAL_TYPE_CALLOUT) &&
 	    (tty->count == 1)) {
 		static int nr_warns;
 		if (nr_warns < 5) {
@@ -1527,8 +1513,8 @@
 	if (!memcmp(&tmp_ws, &tty->winsize, sizeof(*arg)))
 		return 0;
 #ifdef CONFIG_VT
-	if (tty->driver.type == TTY_DRIVER_TYPE_CONSOLE) {
-		unsigned int currcons = minor(tty->device) - tty->driver.minor_start;
+	if (tty->driver->type == TTY_DRIVER_TYPE_CONSOLE) {
+		unsigned int currcons = tty->index;
 		if (vc_resize(currcons, tmp_ws.ws_col, tmp_ws.ws_row))
 			return -ENXIO;
 	}
@@ -1674,10 +1660,10 @@
 {
 	set_current_state(TASK_INTERRUPTIBLE);
 
-	tty->driver.break_ctl(tty, -1);
+	tty->driver->break_ctl(tty, -1);
 	if (!signal_pending(current))
 		schedule_timeout(duration);
-	tty->driver.break_ctl(tty, 0);
+	tty->driver->break_ctl(tty, 0);
 	if (signal_pending(current))
 		return -EINTR;
 	return 0;
@@ -1688,8 +1674,8 @@
 {
 	int retval = -EINVAL;
 
-	if (tty->driver.tiocmget) {
-		retval = tty->driver.tiocmget(tty, file);
+	if (tty->driver->tiocmget) {
+		retval = tty->driver->tiocmget(tty, file);
 
 		if (retval >= 0)
 			retval = put_user(retval, (int *)arg);
@@ -1703,7 +1689,7 @@
 {
 	int retval = -EINVAL;
 
-	if (tty->driver.tiocmset) {
+	if (tty->driver->tiocmset) {
 		unsigned int set, clear, val;
 
 		retval = get_user(val, (unsigned int *)arg);
@@ -1724,10 +1710,10 @@
 			break;
 		}
 
-		set &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2;
-		clear &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2;
+		set &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP;
+		clear &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP;
 
-		retval = tty->driver.tiocmset(tty, file, set, clear);
+		retval = tty->driver->tiocmset(tty, file, set, clear);
 	}
 	return retval;
 }
@@ -1746,28 +1732,28 @@
 		return -EINVAL;
 
 	real_tty = tty;
-	if (tty->driver.type == TTY_DRIVER_TYPE_PTY &&
-	    tty->driver.subtype == PTY_TYPE_MASTER)
+	if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
+	    tty->driver->subtype == PTY_TYPE_MASTER)
 		real_tty = tty->link;
 
 	/*
 	 * Break handling by driver
 	 */
-	if (!tty->driver.break_ctl) {
+	if (!tty->driver->break_ctl) {
 		switch(cmd) {
 		case TIOCSBRK:
 		case TIOCCBRK:
-			if (tty->driver.ioctl)
-				return tty->driver.ioctl(tty, file, cmd, arg);
+			if (tty->driver->ioctl)
+				return tty->driver->ioctl(tty, file, cmd, arg);
 			return -EINVAL;
 			
 		/* These two ioctl's always return success; even if */
 		/* the driver doesn't support them. */
 		case TCSBRK:
 		case TCSBRKP:
-			if (!tty->driver.ioctl)
+			if (!tty->driver->ioctl)
 				return 0;
-			retval = tty->driver.ioctl(tty, file, cmd, arg);
+			retval = tty->driver->ioctl(tty, file, cmd, arg);
 			if (retval == -ENOIOCTLCMD)
 				retval = 0;
 			return retval;
@@ -1840,11 +1826,11 @@
 		 * Break handling
 		 */
 		case TIOCSBRK:	/* Turn break on, unconditionally */
-			tty->driver.break_ctl(tty, -1);
+			tty->driver->break_ctl(tty, -1);
 			return 0;
 			
 		case TIOCCBRK:	/* Turn break off, unconditionally */
-			tty->driver.break_ctl(tty, 0);
+			tty->driver->break_ctl(tty, 0);
 			return 0;
 		case TCSBRK:   /* SVID version: non-zero arg --> no break */
 			/*
@@ -1866,8 +1852,8 @@
 		case TIOCMBIS:
 			return tty_tiocmset(tty, file, cmd, arg);
 	}
-	if (tty->driver.ioctl) {
-		int retval = (tty->driver.ioctl)(tty, file, cmd, arg);
+	if (tty->driver->ioctl) {
+		int retval = (tty->driver->ioctl)(tty, file, cmd, arg);
 		if (retval != -ENOIOCTLCMD)
 			return retval;
 	}
@@ -1917,8 +1903,8 @@
 	session  = tty->session;
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	read_lock(&tasklist_lock);
 	for_each_task_pid(session, PIDTYPE_SID, p, l, pid) {
 		if (p->tty == tty || session > 0) {
@@ -2098,58 +2084,100 @@
  */
 static void tty_default_put_char(struct tty_struct *tty, unsigned char ch)
 {
-	tty->driver.write(tty, 0, &ch, 1);
+	tty->driver->write(tty, 0, &ch, 1);
 }
 
 #ifdef CONFIG_DEVFS_FS
-static void tty_register_devfs(struct tty_driver *driver, unsigned minor)
+static void tty_register_devfs(struct tty_driver *driver, unsigned index)
 {
-	umode_t mode = S_IFCHR | S_IRUSR | S_IWUSR;
-	kdev_t dev = mk_kdev(driver->major, minor);
-	int idx = minor - driver->minor_start;
+	dev_t dev = MKDEV(driver->major, driver->minor_start) + index;
 	char buf[32];
 
-	if ((minor < driver->minor_start) || 
-	    (minor >= driver->minor_start + driver->num)) {
-		printk(KERN_ERR "Attempt to register invalid minor number "
-		       "with devfs (%d:%d).\n", (int)driver->major,(int)minor);
+	if (index >= driver->num) {
+		printk(KERN_ERR "Attempt to register invalid tty line number "
+		       "with devfs (%d).\n", index);
 		return;
 	}
 
-	if (IS_TTY_DEV(dev) || IS_PTMX_DEV(dev)) 
-		mode |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
-
-	sprintf(buf, driver->name, idx + driver->name_base);
-	devfs_register(NULL, buf, 0, driver->major, minor, mode,
-		       &tty_fops, NULL);
+	tty_line_name(driver, index, buf);
+	devfs_register(NULL, buf, 0, MAJOR(dev), MINOR(dev),
+		S_IFCHR | S_IRUSR | S_IWUSR, &tty_fops, NULL);
 }
 
-static void tty_unregister_devfs(struct tty_driver *driver, unsigned minor)
+static void tty_unregister_devfs(struct tty_driver *driver, int index)
 {
-	devfs_remove(driver->name,
-		     minor - driver->minor_start + driver->name_base);
+	char path[64];
+	tty_line_name(driver, index, path);
+	devfs_remove(path);
 }
 #else
-# define tty_register_devfs(driver, minor)	do { } while (0)
-# define tty_unregister_devfs(driver, minor)	do { } while (0)
+# define tty_register_devfs(driver, index)	do { } while (0)
+# define tty_unregister_devfs(driver, index)	do { } while (0)
 #endif /* CONFIG_DEVFS_FS */
 
 /*
  * Register a tty device described by <driver>, with minor number <minor>.
  */
-void tty_register_device(struct tty_driver *driver, unsigned minor)
+void tty_register_device(struct tty_driver *driver, unsigned index)
 {
-	tty_register_devfs(driver, minor);
+	tty_register_devfs(driver, index);
 }
 
-void tty_unregister_device(struct tty_driver *driver, unsigned minor)
+void tty_unregister_device(struct tty_driver *driver, unsigned index)
 {
-	tty_unregister_devfs(driver, minor);
+	tty_unregister_devfs(driver, index);
 }
 
 EXPORT_SYMBOL(tty_register_device);
 EXPORT_SYMBOL(tty_unregister_device);
 
+/* that should be handled by register_chrdev_region() */
+static int get_range(struct tty_driver *driver)
+{
+	dev_t from = MKDEV(driver->major, driver->minor_start);
+	dev_t to = from + driver->num;
+	dev_t n, next;
+	int error = 0;
+
+	for (n = from; MAJOR(n) < MAJOR(to); n = next) {
+		next = MKDEV(MAJOR(n)+1, 0);
+		error = register_chrdev_region(MAJOR(n), MINOR(n),
+			       next - n, driver->name, &tty_fops);
+		if (error)
+			goto fail;
+	}
+	if (n != to)
+		error = register_chrdev_region(MAJOR(n), MINOR(n),
+			       to - n, driver->name, &tty_fops);
+	if (!error)
+		return 0;
+fail:
+	to = n;
+	for (n = from; MAJOR(n) < MAJOR(to); n = next) {
+		next = MKDEV(MAJOR(n)+1, 0);
+		unregister_chrdev_region(MAJOR(n), MINOR(n),
+			       next - n, driver->name);
+	}
+	return error;
+}
+
+/* that should be handled by unregister_chrdev_region() */
+static void put_range(struct tty_driver *driver)
+{
+	dev_t from = MKDEV(driver->major, driver->minor_start);
+	dev_t to = from + driver->num;
+	dev_t n, next;
+
+	for (n = from; MAJOR(n) < MAJOR(to); n = next) {
+		next = MKDEV(MAJOR(n)+1, 0);
+		unregister_chrdev_region(MAJOR(n), MINOR(n),
+			       next - n, driver->name);
+	}
+	if (n != to)
+		unregister_chrdev_region(MAJOR(n), MINOR(n),
+			       to - n, driver->name);
+}
+
 /*
  * Called by a tty driver to register itself.
  */
@@ -2161,12 +2189,16 @@
 	if (driver->flags & TTY_DRIVER_INSTALLED)
 		return 0;
 
-	error = register_chrdev_region(driver->major, driver->minor_start,
+	if (!driver->major) {
+		error = register_chrdev_region(0, driver->minor_start,
 				       driver->num, driver->name, &tty_fops);
+		if (error > 0)
+			driver->major = error;
+	} else {
+		error = get_range(driver);
+	}
 	if (error < 0)
 		return error;
-	else if(driver->major == 0)
-		driver->major = error;
 
 	if (!driver->put_char)
 		driver->put_char = tty_default_put_char;
@@ -2175,7 +2207,7 @@
 	
 	if ( !(driver->flags & TTY_DRIVER_NO_DEVFS) ) {
 		for(i = 0; i < driver->num; i++)
-		    tty_register_device(driver, driver->minor_start + i);
+		    tty_register_device(driver, i);
 	}
 	proc_tty_register_driver(driver);
 	return error;
@@ -2186,16 +2218,13 @@
  */
 int tty_unregister_driver(struct tty_driver *driver)
 {
-	int retval, i;
+	int i;
 	struct termios *tp;
 
 	if (*driver->refcount)
 		return -EBUSY;
 
-	retval = unregister_chrdev_region(driver->major, driver->minor_start,
-					  driver->num, driver->name);
-	if (retval)
-		return retval;
+	put_range(driver);
 
 	list_del(&driver->tty_drivers);
 
@@ -2215,7 +2244,8 @@
 			driver->termios_locked[i] = NULL;
 			kfree(tp);
 		}
-		tty_unregister_device(driver, driver->minor_start + i);
+		if (!(driver->flags & TTY_DRIVER_NO_DEVFS))
+			tty_unregister_device(driver, i);
 	}
 	proc_tty_unregister_driver(driver);
 	return 0;
@@ -2254,26 +2284,20 @@
 	}
 }
 
-static struct tty_driver dev_tty_driver, dev_syscons_driver;
-#ifdef CONFIG_UNIX98_PTYS
-static struct tty_driver dev_ptmx_driver;
-#endif
 #ifdef CONFIG_VT
-static struct tty_driver dev_console_driver;
 extern int vty_init(void);
 #endif
 
-struct device_class tty_devclass = {
+static struct class tty_class = {
 	.name	= "tty",
 };
-EXPORT_SYMBOL(tty_devclass);
 
-static int __init tty_devclass_init(void)
+static int __init tty_class_init(void)
 {
-	return devclass_register(&tty_devclass);
+	return class_register(&tty_class);
 }
 
-postcore_initcall(tty_devclass_init);
+postcore_initcall(tty_class_init);
 
 /*
  * Ok, now we can initialize the rest of the tty devices and can count
@@ -2281,64 +2305,37 @@
  */
 void __init tty_init(void)
 {
-	/*
-	 * dev_tty_driver and dev_console_driver are actually magic
-	 * devices which get redirected at open time.  Nevertheless,
-	 * we register them so that register_chrdev is called
-	 * appropriately.
-	 */
-	memset(&dev_tty_driver, 0, sizeof(struct tty_driver));
-	dev_tty_driver.magic = TTY_DRIVER_MAGIC;
-	dev_tty_driver.owner = THIS_MODULE;
-	dev_tty_driver.driver_name = "/dev/tty";
-	dev_tty_driver.name = dev_tty_driver.driver_name + 5;
-	dev_tty_driver.name_base = 0;
-	dev_tty_driver.major = TTYAUX_MAJOR;
-	dev_tty_driver.minor_start = 0;
-	dev_tty_driver.num = 1;
-	dev_tty_driver.type = TTY_DRIVER_TYPE_SYSTEM;
-	dev_tty_driver.subtype = SYSTEM_TYPE_TTY;
-	
-	if (tty_register_driver(&dev_tty_driver))
+	if (register_chrdev_region(TTYAUX_MAJOR, 0, 1,
+				   "/dev/tty", &tty_fops) < 0)
 		panic("Couldn't register /dev/tty driver\n");
 
-	dev_syscons_driver = dev_tty_driver;
-	dev_syscons_driver.owner = THIS_MODULE;
-	dev_syscons_driver.driver_name = "/dev/console";
-	dev_syscons_driver.name = dev_syscons_driver.driver_name + 5;
-	dev_syscons_driver.major = TTYAUX_MAJOR;
-	dev_syscons_driver.minor_start = 1;
-	dev_syscons_driver.type = TTY_DRIVER_TYPE_SYSTEM;
-	dev_syscons_driver.subtype = SYSTEM_TYPE_SYSCONS;
+	devfs_register (NULL, "tty", 0, TTYAUX_MAJOR, 0,
+			S_IFCHR | S_IRUGO | S_IWUGO, &tty_fops, NULL);
 
-	if (tty_register_driver(&dev_syscons_driver))
+	if (register_chrdev_region(TTYAUX_MAJOR, 1, 1,
+				   "/dev/console", &tty_fops) < 0)
 		panic("Couldn't register /dev/console driver\n");
 
-#ifdef CONFIG_UNIX98_PTYS
-	dev_ptmx_driver = dev_tty_driver;
-	dev_ptmx_driver.owner = THIS_MODULE;
-	dev_ptmx_driver.driver_name = "/dev/ptmx";
-	dev_ptmx_driver.name = dev_ptmx_driver.driver_name + 5;
-	dev_ptmx_driver.major= TTYAUX_MAJOR;
-	dev_ptmx_driver.minor_start = 2;
-	dev_ptmx_driver.type = TTY_DRIVER_TYPE_SYSTEM;
-	dev_ptmx_driver.subtype = SYSTEM_TYPE_SYSPTMX;
+	devfs_register (NULL, "console", 0, TTYAUX_MAJOR, 1,
+			S_IFCHR | S_IRUSR | S_IWUSR, &tty_fops, NULL);
 
-	if (tty_register_driver(&dev_ptmx_driver))
+#ifdef CONFIG_UNIX98_PTYS
+	if (register_chrdev_region(TTYAUX_MAJOR, 2, 1,
+				   "/dev/ptmx", &tty_fops) < 0)
 		panic("Couldn't register /dev/ptmx driver\n");
+
+	devfs_register (NULL, "ptmx", 0, TTYAUX_MAJOR, 2,
+			S_IFCHR | S_IRUGO | S_IWUGO, &tty_fops, NULL);
 #endif
 	
 #ifdef CONFIG_VT
-	dev_console_driver = dev_tty_driver;
-	dev_console_driver.owner = THIS_MODULE;
-	dev_console_driver.driver_name = "/dev/vc/0";
-	dev_console_driver.name = dev_console_driver.driver_name + 5;
-	dev_console_driver.major = TTY_MAJOR;
-	dev_console_driver.type = TTY_DRIVER_TYPE_SYSTEM;
-	dev_console_driver.subtype = SYSTEM_TYPE_CONSOLE;
-
-	if (tty_register_driver(&dev_console_driver))
+	if (register_chrdev_region(TTY_MAJOR, 0, 1,
+				   "/dev/vc/0", &tty_fops) < 0)
 		panic("Couldn't register /dev/tty0 driver\n");
+
+	devfs_register (NULL, "vc/0", 0, TTY_MAJOR, 0,
+			S_IFCHR | S_IRUSR | S_IWUSR, &tty_fops, NULL);
+
 	vty_init();
 #endif
 
diff -Nru a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c
--- a/drivers/char/tty_ioctl.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/char/tty_ioctl.c	Wed Apr 30 22:28:20 2003
@@ -45,7 +45,7 @@
 	
 	printk(KERN_DEBUG "%s wait until sent...\n", tty_name(tty, buf));
 #endif
-	if (!tty->driver.chars_in_buffer)
+	if (!tty->driver->chars_in_buffer)
 		return;
 	add_wait_queue(&tty->write_wait, &wait);
 	if (!timeout)
@@ -53,17 +53,17 @@
 	do {
 #ifdef TTY_DEBUG_WAIT_UNTIL_SENT
 		printk(KERN_DEBUG "waiting %s...(%d)\n", tty_name(tty, buf),
-		       tty->driver.chars_in_buffer(tty));
+		       tty->driver->chars_in_buffer(tty));
 #endif
 		set_current_state(TASK_INTERRUPTIBLE);
 		if (signal_pending(current))
 			goto stop_waiting;
-		if (!tty->driver.chars_in_buffer(tty))
+		if (!tty->driver->chars_in_buffer(tty))
 			break;
 		timeout = schedule_timeout(timeout);
 	} while (timeout);
-	if (tty->driver.wait_until_sent)
-		tty->driver.wait_until_sent(tty, timeout);
+	if (tty->driver->wait_until_sent)
+		tty->driver->wait_until_sent(tty, timeout);
 stop_waiting:
 	set_current_state(TASK_RUNNING);
 	remove_wait_queue(&tty->write_wait, &wait);
@@ -131,8 +131,8 @@
 		}
 	}
 
-	if (tty->driver.set_termios)
-		(*tty->driver.set_termios)(tty, &old_termios);
+	if (tty->driver->set_termios)
+		(*tty->driver->set_termios)(tty, &old_termios);
 
 	if (tty->ldisc.set_termios)
 		(*tty->ldisc.set_termios)(tty, &old_termios);
@@ -346,13 +346,13 @@
 {
 	int	was_stopped = tty->stopped;
 
-	if (tty->driver.send_xchar) {
-		tty->driver.send_xchar(tty, ch);
+	if (tty->driver->send_xchar) {
+		tty->driver->send_xchar(tty, ch);
 		return;
 	}
 	if (was_stopped)
 		start_tty(tty);
-	tty->driver.write(tty, 0, &ch, 1);
+	tty->driver->write(tty, 0, &ch, 1);
 	if (was_stopped)
 		stop_tty(tty);
 }
@@ -363,8 +363,8 @@
 	struct tty_struct * real_tty;
 	int retval;
 
-	if (tty->driver.type == TTY_DRIVER_TYPE_PTY &&
-	    tty->driver.subtype == PTY_TYPE_MASTER)
+	if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
+	    tty->driver->subtype == PTY_TYPE_MASTER)
 		real_tty = tty->link;
 	else
 		real_tty = tty;
@@ -450,16 +450,16 @@
 					tty->ldisc.flush_buffer(tty);
 				/* fall through */
 			case TCOFLUSH:
-				if (tty->driver.flush_buffer)
-					tty->driver.flush_buffer(tty);
+				if (tty->driver->flush_buffer)
+					tty->driver->flush_buffer(tty);
 				break;
 			default:
 				return -EINVAL;
 			}
 			return 0;
 		case TIOCOUTQ:
-			return put_user(tty->driver.chars_in_buffer ?
-					tty->driver.chars_in_buffer(tty) : 0,
+			return put_user(tty->driver->chars_in_buffer ?
+					tty->driver->chars_in_buffer(tty) : 0,
 					(int *) arg);
 		case TIOCINQ:
 			retval = tty->read_cnt;
@@ -482,8 +482,8 @@
 		{
 			int pktmode;
 
-			if (tty->driver.type != TTY_DRIVER_TYPE_PTY ||
-			    tty->driver.subtype != PTY_TYPE_MASTER)
+			if (tty->driver->type != TTY_DRIVER_TYPE_PTY ||
+			    tty->driver->subtype != PTY_TYPE_MASTER)
 				return -ENOTTY;
 			if (get_user(pktmode, (int *) arg))
 				return -EFAULT;
diff -Nru a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c
--- a/drivers/char/vme_scc.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/char/vme_scc.c	Wed Apr 30 22:28:03 2003
@@ -131,7 +131,7 @@
 	scc_driver.magic = TTY_DRIVER_MAGIC;
 	scc_driver.driver_name = "scc";
 #ifdef CONFIG_DEVFS_FS
-	scc_driver.name = "tts/%d";
+	scc_driver.name = "tts/";
 #else
 	scc_driver.name = "ttyS";
 #endif
@@ -168,7 +168,7 @@
 
 	scc_callout_driver = scc_driver;
 #ifdef CONFIG_DEVFS_FS
-	scc_callout_driver.name = "cua/%d";
+	scc_callout_driver.name = "cua/";
 #else
 	scc_callout_driver.name = "cua";
 #endif
@@ -842,7 +842,7 @@
 
 static int scc_open (struct tty_struct * tty, struct file * filp)
 {
-	int line = minor(tty->device) - SCC_MINOR_BASE;
+	int line = tty->index;
 	int retval;
 	struct scc_port *port = &scc_ports[line];
 	int i, channel = port->channel;
@@ -950,7 +950,7 @@
 	}
 
 	if ((port->gs.count == 1) && (port->gs.flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = port->gs.normal_termios;
 		else 
 			*tty->termios = port->gs.callout_termios;
@@ -1069,9 +1069,10 @@
 	local_irq_restore(flags);
 }
 
-static kdev_t scc_console_device(struct console *c)
+static struct tty_driver *scc_console_device(struct console *c, int *index)
 {
-	return mk_kdev(TTY_MAJOR, SCC_MINOR_BASE + c->index);
+	*index = c->index;
+	return &scc_driver;
 }
 
 
diff -Nru a/drivers/char/vt.c b/drivers/char/vt.c
--- a/drivers/char/vt.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/char/vt.c	Wed Apr 30 22:28:16 2003
@@ -2180,9 +2180,12 @@
 	clear_bit(0, &printing);
 }
 
-static kdev_t vt_console_device(struct console *c)
+struct tty_driver console_driver;
+
+static struct tty_driver *vt_console_device(struct console *c, int *index)
 {
-	return mk_kdev(TTY_MAJOR, c->index ? c->index : fg_console + 1);
+	*index = c->index ? c->index-1 : fg_console;
+	return &console_driver;
 }
 
 struct console vt_console_driver = {
@@ -2216,7 +2219,7 @@
 	int lines;
 	int ret;
 
-	if (tty->driver.type != TTY_DRIVER_TYPE_CONSOLE)
+	if (tty->driver->type != TTY_DRIVER_TYPE_CONSOLE)
 		return -EINVAL;
 	if (current->tty != tty && !capable(CAP_SYS_ADMIN))
 		return -EPERM;
@@ -2345,7 +2348,7 @@
 	int console_num;
 	if (!tty)
 		return;
-	console_num = minor(tty->device) - (tty->driver.minor_start);
+	console_num = tty->index;
 	if (!vc_cons_allocated(console_num))
 		return;
 	set_vc_kbd_led(kbd_table + console_num, VC_SCROLLOCK);
@@ -2360,7 +2363,7 @@
 	int console_num;
 	if (!tty)
 		return;
-	console_num = minor(tty->device) - (tty->driver.minor_start);
+	console_num = tty->index;
 	if (!vc_cons_allocated(console_num))
 		return;
 	clr_vc_kbd_led(kbd_table + console_num, VC_SCROLLOCK);
@@ -2392,7 +2395,7 @@
 	unsigned int	currcons;
 	int i;
 
-	currcons = minor(tty->device) - tty->driver.minor_start;
+	currcons = tty->index;
 
 	i = vc_allocate(currcons);
 	if (i)
@@ -2418,7 +2421,7 @@
 	if (!tty)
 		return;
 	if (tty->count != 1) return;
-	vcs_make_devfs (minor(tty->device) - tty->driver.minor_start, 1);
+	vcs_make_devfs (tty->index, 1);
 	vt = (struct vt_struct*)tty->driver_data;
 	if (vt)
 		vc_cons[vt->vc_num].d->vc_tty = NULL;
@@ -2455,7 +2458,6 @@
  * the appropriate escape-sequence.
  */
 
-struct tty_driver console_driver;
 static int console_refcount;
 
 static int __init con_init(void)
@@ -2515,7 +2517,7 @@
 	memset(&console_driver, 0, sizeof(struct tty_driver));
 	console_driver.magic = TTY_DRIVER_MAGIC;
 	console_driver.owner = THIS_MODULE;
-	console_driver.name = "vc/%d";
+	console_driver.name = "vc/";
 	console_driver.name_base = 1;
 	console_driver.major = TTY_MAJOR;
 	console_driver.minor_start = 1;
@@ -2664,8 +2666,7 @@
 	int i;
 
 	for (i = 0; i < console_driver.num; i++)
-		tty_register_device (&console_driver,
-				    console_driver.minor_start + i);
+		tty_register_device (&console_driver, i);
 }
 
 /*
diff -Nru a/drivers/char/watchdog/acquirewdt.c b/drivers/char/watchdog/acquirewdt.c
--- a/drivers/char/watchdog/acquirewdt.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/char/watchdog/acquirewdt.c	Wed Apr 30 22:28:11 2003
@@ -29,6 +29,7 @@
 #include <linux/watchdog.h>
 #include <linux/ioport.h>
 #include <linux/notifier.h>
+#include <linux/fs.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
 #include <linux/spinlock.h>
diff -Nru a/drivers/char/watchdog/advantechwdt.c b/drivers/char/watchdog/advantechwdt.c
--- a/drivers/char/watchdog/advantechwdt.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/char/watchdog/advantechwdt.c	Wed Apr 30 22:28:08 2003
@@ -29,6 +29,7 @@
 #include <linux/types.h>
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
+#include <linux/fs.h>
 #include <linux/ioport.h>
 #include <linux/notifier.h>
 #include <linux/reboot.h>
diff -Nru a/drivers/char/watchdog/eurotechwdt.c b/drivers/char/watchdog/eurotechwdt.c
--- a/drivers/char/watchdog/eurotechwdt.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/char/watchdog/eurotechwdt.c	Wed Apr 30 22:28:05 2003
@@ -46,6 +46,7 @@
 #include <linux/types.h>
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
+#include <linux/fs.h>
 #include <linux/ioport.h>
 #include <linux/notifier.h>
 #include <linux/reboot.h>
@@ -187,7 +188,7 @@
  * Kernel methods.
  */
  
-void eurwdt_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t eurwdt_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	printk(KERN_CRIT "timeout WDT timeout\n");
  
@@ -197,6 +198,7 @@
 	printk(KERN_CRIT "Initiating system reboot.\n");
 	machine_restart(NULL);
 #endif
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/char/watchdog/ib700wdt.c b/drivers/char/watchdog/ib700wdt.c
--- a/drivers/char/watchdog/ib700wdt.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/char/watchdog/ib700wdt.c	Wed Apr 30 22:28:17 2003
@@ -38,6 +38,7 @@
 #include <linux/watchdog.h>
 #include <linux/ioport.h>
 #include <linux/notifier.h>
+#include <linux/fs.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
 #include <linux/spinlock.h>
diff -Nru a/drivers/char/watchdog/machzwd.c b/drivers/char/watchdog/machzwd.c
--- a/drivers/char/watchdog/machzwd.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/char/watchdog/machzwd.c	Wed Apr 30 22:28:05 2003
@@ -35,6 +35,7 @@
 #include <linux/jiffies.h>
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
+#include <linux/fs.h>
 #include <linux/ioport.h>
 #include <linux/notifier.h>
 #include <linux/reboot.h>
diff -Nru a/drivers/char/watchdog/mixcomwd.c b/drivers/char/watchdog/mixcomwd.c
--- a/drivers/char/watchdog/mixcomwd.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/char/watchdog/mixcomwd.c	Wed Apr 30 22:28:06 2003
@@ -41,6 +41,7 @@
 #include <linux/miscdevice.h>
 #include <linux/ioport.h>
 #include <linux/watchdog.h>
+#include <linux/fs.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
 #include <asm/uaccess.h>
diff -Nru a/drivers/char/watchdog/pcwd.c b/drivers/char/watchdog/pcwd.c
--- a/drivers/char/watchdog/pcwd.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/char/watchdog/pcwd.c	Wed Apr 30 22:28:04 2003
@@ -52,6 +52,7 @@
 #include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
+#include <linux/fs.h>
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
 #include <linux/init.h>
diff -Nru a/drivers/char/watchdog/sbc60xxwdt.c b/drivers/char/watchdog/sbc60xxwdt.c
--- a/drivers/char/watchdog/sbc60xxwdt.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/char/watchdog/sbc60xxwdt.c	Wed Apr 30 22:28:12 2003
@@ -61,6 +61,7 @@
 #include <linux/jiffies.h>
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
+#include <linux/fs.h>
 #include <linux/ioport.h>
 #include <linux/notifier.h>
 #include <linux/reboot.h>
diff -Nru a/drivers/char/watchdog/sc520_wdt.c b/drivers/char/watchdog/sc520_wdt.c
--- a/drivers/char/watchdog/sc520_wdt.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/char/watchdog/sc520_wdt.c	Wed Apr 30 22:28:09 2003
@@ -53,6 +53,7 @@
 #include <linux/timer.h>
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
+#include <linux/fs.h>
 #include <linux/ioport.h>
 #include <linux/notifier.h>
 #include <linux/reboot.h>
diff -Nru a/drivers/char/watchdog/softdog.c b/drivers/char/watchdog/softdog.c
--- a/drivers/char/watchdog/softdog.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/char/watchdog/softdog.c	Wed Apr 30 22:28:08 2003
@@ -41,6 +41,7 @@
 #include <linux/types.h>
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
+#include <linux/fs.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
 #include <asm/uaccess.h>
diff -Nru a/drivers/char/watchdog/w83877f_wdt.c b/drivers/char/watchdog/w83877f_wdt.c
--- a/drivers/char/watchdog/w83877f_wdt.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/char/watchdog/w83877f_wdt.c	Wed Apr 30 22:28:11 2003
@@ -47,6 +47,7 @@
 #include <linux/jiffies.h>
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
+#include <linux/fs.h>
 #include <linux/ioport.h>
 #include <linux/notifier.h>
 #include <linux/reboot.h>
diff -Nru a/drivers/char/watchdog/wafer5823wdt.c b/drivers/char/watchdog/wafer5823wdt.c
--- a/drivers/char/watchdog/wafer5823wdt.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/char/watchdog/wafer5823wdt.c	Wed Apr 30 22:28:17 2003
@@ -29,6 +29,7 @@
 #include <linux/module.h>
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
+#include <linux/fs.h>
 #include <linux/ioport.h>
 #include <linux/notifier.h>
 #include <linux/reboot.h>
diff -Nru a/drivers/char/watchdog/wdt.c b/drivers/char/watchdog/wdt.c
--- a/drivers/char/watchdog/wdt.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/char/watchdog/wdt.c	Wed Apr 30 22:28:09 2003
@@ -37,6 +37,7 @@
 #include <linux/types.h>
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
+#include <linux/fs.h>
 #include <linux/ioport.h>
 #include <linux/notifier.h>
 #include <linux/reboot.h>
@@ -178,7 +179,7 @@
  *	a failure condition occurring.
  */
  
-void wdt_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t wdt_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	/*
 	 *	Read the status register see what is up and
@@ -210,7 +211,8 @@
 #endif		
 #else
 		printk(KERN_CRIT "Reset in 5ms.\n");
-#endif		
+#endif
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/char/watchdog/wdt_pci.c b/drivers/char/watchdog/wdt_pci.c
--- a/drivers/char/watchdog/wdt_pci.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/char/watchdog/wdt_pci.c	Wed Apr 30 22:28:11 2003
@@ -161,7 +161,7 @@
  *	a failure condition occurring.
  */
  
-static void wdtpci_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t wdtpci_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	/*
 	 *	Read the status register see what is up and
@@ -193,7 +193,8 @@
 #endif		
 #else
 		printk(KERN_CRIT "Reset in 5ms.\n");
-#endif		
+#endif
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/eisa/Kconfig b/drivers/eisa/Kconfig
--- a/drivers/eisa/Kconfig	Wed Apr 30 22:28:07 2003
+++ b/drivers/eisa/Kconfig	Wed Apr 30 22:28:07 2003
@@ -1,6 +1,17 @@
 #
 # EISA configuration
 #
+config EISA_VLB_PRIMING
+	bool "Vesa Local Bus priming"
+	depends on X86_PC && EISA
+	default n
+	---help---
+	  Activate this option if your system contains a Vesa Local
+	  Bus (VLB) card that identify itself as an EISA card (such as
+	  the Adaptec AHA-284x).
+
+	  When in doubt, say N.
+
 config EISA_PCI_EISA
 	bool "Generic PCI/EISA bridge"
 	depends on PCI && EISA
@@ -12,9 +23,12 @@
 
 	  When in doubt, say Y.
 
+# Using EISA_VIRTUAL_ROOT on something other than an Alpha or
+# an X86_PC may lead to crashes...
+
 config EISA_VIRTUAL_ROOT
 	bool "EISA virtual root device"
-	depends on EISA
+	depends on EISA && (ALPHA || X86_PC)
 	default y
 	---help---
 	  Activate this option if your system only have EISA bus
diff -Nru a/drivers/eisa/Makefile b/drivers/eisa/Makefile
--- a/drivers/eisa/Makefile	Wed Apr 30 22:28:09 2003
+++ b/drivers/eisa/Makefile	Wed Apr 30 22:28:09 2003
@@ -1,5 +1,8 @@
 # Makefile for the Linux device tree
 
+# Being anal sometimes saves a crash/reboot cycle... ;-)
+EXTRA_CFLAGS    := -Werror
+
 obj-$(CONFIG_EISA)	        += eisa-bus.o
 obj-${CONFIG_EISA_PCI_EISA}     += pci_eisa.o
 
diff -Nru a/drivers/eisa/eisa-bus.c b/drivers/eisa/eisa-bus.c
--- a/drivers/eisa/eisa-bus.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/eisa/eisa-bus.c	Wed Apr 30 22:28:06 2003
@@ -56,13 +56,22 @@
         u16 rev;
 	int i;
 
-	sig[0] = inb (addr);
-
-	if (sig[0] & 0x80)
-                return NULL;
-
-	for (i = 1; i < 4; i++)
+	for (i = 0; i < 4; i++) {
+#ifdef CONFIG_EISA_VLB_PRIMING
+		/*
+		 * This ugly stuff is used to wake up VL-bus cards
+		 * (AHA-284x is the only known example), so we can
+		 * read the EISA id.
+		 *
+		 * Thankfully, this only exists on x86...
+		 */
+		outb(0x80 + i, addr);
+#endif
 		sig[i] = inb (addr + i);
+
+		if (!i && (sig[0] & 0x80))
+			return NULL;
+	}
 	
         sig_str[0] = ((sig[0] >> 2) & 0x1f) + ('A' - 1);
         sig_str[1] = (((sig[0] & 3) << 3) | (sig[1] >> 5)) + ('A' - 1);
@@ -123,47 +132,28 @@
 
 static DEVICE_ATTR(signature, S_IRUGO, eisa_show_sig, NULL);
 
-static void __init eisa_register_device (struct eisa_root_device *root,
-					 char *sig, int slot)
+static int __init eisa_register_device (struct eisa_root_device *root,
+					struct eisa_device *edev,
+					char *sig, int slot)
 {
-	struct eisa_device *edev;
-
-	if (!(edev = kmalloc (sizeof (*edev), GFP_KERNEL)))
-		return;
-
-	memset (edev, 0, sizeof (*edev));
-	memcpy (edev->id.sig, sig, 7);
+	memcpy (edev->id.sig, sig, EISA_SIG_LEN);
 	edev->slot = slot;
 	edev->base_addr = SLOT_ADDRESS (root, slot);
+	edev->dma_mask = 0xffffffff; /* Default DMA mask */
 	eisa_name_device (edev);
 	edev->dev.parent = root->dev;
 	edev->dev.bus = &eisa_bus_type;
+	edev->dev.dma_mask = &edev->dma_mask;
 	sprintf (edev->dev.bus_id, "%02X:%02X", root->bus_nr, slot);
 
-	/* Don't register resource for slot 0, since this will surely
-	 * fail... :-( */
+	edev->res.name  = edev->dev.name;
 
-	if (slot) {
-		edev->res.name  = edev->dev.name;
-		edev->res.start = edev->base_addr;
-		edev->res.end   = edev->res.start + 0xfff;
-		edev->res.flags = IORESOURCE_IO;
-
-		if (request_resource (root->res, &edev->res)) {
-			printk (KERN_WARNING \
-				"Cannot allocate resource for EISA slot %d\n",
-				slot);
-			kfree (edev);
-			return;
-		}
-	}
-	
-	if (device_register (&edev->dev)) {
-		kfree (edev);
-		return;
-	}
+	if (device_register (&edev->dev))
+		return -1;
 
 	device_create_file (&edev->dev, &dev_attr_signature);
+
+	return 0;
 }
 
 static int __init eisa_probe (struct eisa_root_device *root)
@@ -171,54 +161,106 @@
         int i, c;
         char *str;
         unsigned long sig_addr;
+	struct eisa_device *edev;
 
         printk (KERN_INFO "EISA: Probing bus %d at %s\n",
 		root->bus_nr, root->dev->name);
 	
         for (c = 0, i = 0; i <= root->slots; i++) {
-                sig_addr = SLOT_ADDRESS (root, i) + EISA_VENDOR_ID_OFFSET;
-                if ((str = decode_eisa_sig (sig_addr))) {
-			if (!i)
-				printk (KERN_INFO "EISA: Motherboard %s detected\n",
-					str);
-			else {
-				printk (KERN_INFO "EISA: slot %d : %s detected.\n",
-					i, str);
+		if (!(edev = kmalloc (sizeof (*edev), GFP_KERNEL))) {
+			printk (KERN_ERR "EISA: Out of memory for slot %d\n",
+				i);
+			continue;
+		}
+		
+		memset (edev, 0, sizeof (*edev));
 
-				c++;
-			}
+		/* Don't register resource for slot 0, since this is
+		 * very likely to fail... :-( Instead, grab the EISA
+		 * id, now we can display something in /proc/ioports.
+		 */
+
+		if (i) {
+			edev->res.name  = NULL;
+			edev->res.start = SLOT_ADDRESS (root, i);
+			edev->res.end   = edev->res.start + 0xfff;
+			edev->res.flags = IORESOURCE_IO;
+		} else {
+			edev->res.name  = NULL;
+			edev->res.start = SLOT_ADDRESS (root, i) + EISA_VENDOR_ID_OFFSET;
+			edev->res.end   = edev->res.start + 3;
+			edev->res.flags = IORESOURCE_BUSY;
+		}
+	
+		if (request_resource (root->res, &edev->res)) {
+			printk (KERN_WARNING \
+				"Cannot allocate resource for EISA slot %d\n",
+				i);
+			kfree (edev);
+			continue;
+		}
+
+		sig_addr = SLOT_ADDRESS (root, i) + EISA_VENDOR_ID_OFFSET;
+
+                if (!(str = decode_eisa_sig (sig_addr))) {
+			release_resource (&edev->res);
+			kfree (edev);
+			continue;
+		}
+		
+		if (!i)
+			printk (KERN_INFO "EISA: Motherboard %s detected\n",
+				str);
+		else {
+			printk (KERN_INFO "EISA: slot %d : %s detected.\n",
+				i, str);
 
-			eisa_register_device (root, str, i);
-                }
+			c++;
+		}
+
+		if (eisa_register_device (root, edev, str, i)) {
+			printk (KERN_ERR "EISA: Failed to register %s\n", str);
+			release_resource (&edev->res);
+			kfree (edev);
+		}
         }
         printk (KERN_INFO "EISA: Detected %d card%s.\n", c, c == 1 ? "" : "s");
 
 	return 0;
 }
 
-
-static LIST_HEAD (eisa_root_head);
+static struct resource eisa_root_res = {
+	.name  = "EISA root resource",
+	.start = 0,
+	.end   = 0xffffffff,
+	.flags = IORESOURCE_IO,
+};
 
 static int eisa_bus_count;
 
-int eisa_root_register (struct eisa_root_device *root)
+int __init eisa_root_register (struct eisa_root_device *root)
 {
-	struct list_head *node;
-	struct eisa_root_device *tmp_root;
+	int err;
 
-	/* Check if this bus base address has been already
-	 * registered. This prevents the virtual root device from
-	 * registering after the real one has, for example... */
-	
-	list_for_each (node, &eisa_root_head) {
-		tmp_root = list_entry (node, struct eisa_root_device, node);
-		if (tmp_root->bus_base_addr == root->bus_base_addr)
-			return -1; /* Space already taken, buddy... */
-	}
+	/* Use our own resources to check if this bus base address has
+	 * been already registered. This prevents the virtual root
+	 * device from registering after the real one has, for
+	 * example... */
+	
+	root->eisa_root_res.name  = eisa_root_res.name;
+	root->eisa_root_res.start = root->res->start;
+	root->eisa_root_res.end   = root->res->end;
+	root->eisa_root_res.flags = IORESOURCE_BUSY;
+
+	if ((err = request_resource (&eisa_root_res, &root->eisa_root_res)))
+		return err;
 	
 	root->bus_nr = eisa_bus_count++;
-	list_add_tail (&root->node, &eisa_root_head);
-	return eisa_probe (root);
+
+	if ((err = eisa_probe (root)))
+		release_resource (&root->eisa_root_res);
+
+	return err;
 }
 
 static int __init eisa_init (void)
diff -Nru a/drivers/eisa/eisa.ids b/drivers/eisa/eisa.ids
--- a/drivers/eisa/eisa.ids	Wed Apr 30 22:28:03 2003
+++ b/drivers/eisa/eisa.ids	Wed Apr 30 22:28:03 2003
@@ -162,6 +162,17 @@
 CPQ0501 "Compaq DESKPRO/M System Board"
 CPQ0509 "Compaq DESKPRO/M System Board with Audio"
 CPQ0511 "Compaq SYSTEMPRO/LT System Board"
+CPQ0521 "Compaq DESKPRO XL System Board"
+CPQ0531 "Compaq ProSignia 500 System Board"
+CPQ0541 "Compaq ProSignia 300 System Board"
+CPQ0551 "Compaq ProLiant 2500 Server"
+CPQ0552 "Compaq ProLiant 2500 System Board"
+CPQ0553 "Compaq ProLiant 1600 System Board"
+CPQ0559 "Compaq ProLiant 1500 System Board"
+CPQ0561 "Compaq ProLiant 3000 System Board"
+CPQ0571 "Compaq ProSignia 200 Server"
+CPQ0579 "Compaq ProLiant 800 Server"
+CPQ0589 "Compaq ProLiant 850R"
 CPQ0601 "Compaq ProSignia Server"
 CPQ0609 "Compaq ProSignia Server"
 CPQ0611 "Compaq ProSignia Server"
@@ -169,6 +180,30 @@
 CPQ0629 "Compaq ProSignia Server (ASSY # 3154)"
 CPQ0631 "Compaq ProLiant 1000 Server"
 CPQ0639 "Compaq ProLiant 1000 Server"
+CPQ0671 "Compaq ProSignia 200"
+CPQ0679 "Compaq ProLiant 1850R"
+CPQ0680 "Compaq ProLiant CL1850 System Board"
+CPQ0681 "ProLiant CL380"
+CPQ0685 "Compaq ProLiant DL360"
+CPQ0686 "Compaq ProSignia 780"
+CPQ0687 "Compaq ProSignia 740"
+CPQ0688 "Compaq ProLiant 800 System Board"
+CPQ0689 "Compaq ProLiant 1600 System Board"
+CPQ0690 "Compaq ProLiant ML370"
+CPQ0691 "Compaq ProLiant 800"
+CPQ0692 "Compaq ProLiant DL380"
+CPQ0701 "Compaq ProSignia VS"
+CPQ0709 "Compaq ProLiant 3000 System Board"
+CPQ0711 "Compaq ProSignia VS"
+CPQ0712 "Compaq ProLiant ML530"
+CPQ0714 "Compaq ProLiant ML570"
+CPQ0715 "Compaq ProLiant DL580"
+CPQ0718 "Compaq TaskSmart N2400"
+CPQ071D "Compaq TaskSmart C2500"
+CPQ0808 "Compaq ProLiant 5500"
+CPQ0809 "Compaq ProLiant 6500 System Board"
+CPQ0810 "Compaq ProLiant 6400R System Board"
+CPQ0811 "Compaq ProLiant 1500 System Board"
 CPQ1001 "Compaq Portable 486"
 CPQ1009 "Compaq Portable 486/66"
 CPQ1201 "Compaq DESKPRO 486/25"
@@ -178,6 +213,16 @@
 CPQ1501 "Compaq SYSTEMPRO/XL Server"
 CPQ1509 "Compaq ProLiant 4000 Server"
 CPQ1519 "Compaq ProLiant 2000 Server"
+CPQ1529 "Compaq ProLiant 4500 Server"
+CPQ1561 "Compaq ProLiant 5000 System Board"
+CPQ1563 "Compaq ProLiant 6000 System Board"
+CPQ1565 "Compaq ProLiant 6500 System Board"
+CPQ1601 "Compaq ProLiant 7000"
+CPQ1602 "Compaq ProLiant 6000"
+CPQ1603 "Compaq Standard Peripherals Board"
+CPQ1608 "Compaq ProLiant 8500"
+CPQ1609 "Compaq ProLiant 8000"
+CPQ1669 "Compaq ProLiant 7000 System Board"
 CPQ3001 "Compaq Advanced VGA"
 CPQ3011 "Compaq QVision 1024/E Video Controller"
 CPQ3021 "Compaq QVision 1024/I Video Controller"
@@ -189,27 +234,43 @@
 CPQ4002 "Compaq Intelligent Drive Array Controller-2"
 CPQ4010 "Compaq 32-Bit Intelligent Drive Array Expansion Controller"
 CPQ4020 "Compaq SMART Array Controller"
+CPQ4030 "Compaq SMART-2/E Array Controller"
 CPQ4300 "Compaq Advanced ESDI Fixed Disk Controller"
 CPQ4401 "Compaq Integrated SCSI-2 Options Port"
 CPQ4410 "Compaq Integrated 32-Bit Fast-SCSI-2 Controller"
 CPQ4411 "Compaq 32-Bit Fast-SCSI-2 Controller"
 CPQ4420 "Compaq 6260 SCSI-2 Controller"
+CPQ4430 "Compaq 32-Bit Fast-Wide SCSI-2/E Controller"
+CPQ4431 "Compaq 32-Bit Fast-Wide SCSI-2/E Controller"
 CPQ5000 "Compaq 386/33 System Processor Board used as Secondary"
+CPQ5251 "Compaq 5/133 System Processor Board-2MB"
+CPQ5253 "Compaq 5/166 System Processor Board-2MB"
+CPQ5255 "Compaq 5/133 System Processor Board-1MB"
+CPQ525D "Compaq 5/100 System Processor Board-1MB"
 CPQ5281 "Compaq 486/50 System Processor Board used as Secondary"
 CPQ5282 "Compaq 486/50 System Processor Board used as Secondary"
 CPQ5287 "Compaq 5/66 System Processor Board used as Secondary"
+CPQ528A "Compaq 5/100 System Processor Board w/ Transaction Blaster"
+CPQ528B "Compaq 5/100 System Processor Board"
 CPQ528F "Compaq 486DX2/66 System Processor Board used as Secondary"
+CPQ529B "Compaq 5/90 System Processor Board"
+CPQ529F "Compaq 5/133 System Processor Board"
+CPQ52A0 "Compaq System Processor"
 CPQ5900 "Compaq 486/33 System Processor Board used as Secondary"
 CPQ5A00 "Compaq 486/33 System Processor Board (ASSY # 002013) used as Secondary"
 CPQ5B00 "Compaq 486DX2/66 System Processor Board used as Secondary"
 CPQ5C00 "Compaq 486/33 System Processor Board used as Secondary"
 CPQ6000 "Compaq 32-Bit DualSpeed Token Ring Controller"
 CPQ6001 "Compaq 32-Bit DualSpeed Token Ring Controller"
-CPQ6100 "Compaq 32-Bit NetFlex Controller"
+CPQ6002 "Compaq NetFlex-2 TR"
+CPQ6100 "Compaq NetFlex ENET-TR"
 CPQ6101 "Compaq NetFlex-2 Controller"
 CPQ6200 "Compaq DualPort Ethernet Controller"
+CPQ6300 "Compaq NetFlex-2 DualPort TR"
 CPQ7000 "Compaq 32-Bit Server Manager/R Board"
 CPQ7001 "Compaq 32-Bit Server Manager/R Board"
+CPQ7100 "Compaq Remote Insight Board"
+CPQ7200 "Compaq StorageWorks Fibre Channel Host Bus Adapter/E"
 CPQ9004 "Compaq 386/33 Processor Board"
 CPQ9005 "Compaq 386/25 Processor Board"
 CPQ9013 "Compaq 486DX2/66 System Processor Board used as Primary"
@@ -232,16 +293,60 @@
 CPQ9045 "Compaq 5/60 Processor Board"
 CPQ9046 "Compaq 5/60 Processor Board"
 CPQ9047 "Compaq 5/60 Processor Board"
+CPQ9251 "Compaq 5/133 System Processor Board-2MB"
+CPQ9253 "Compaq 5/166 System Processor Board-2MB"
+CPQ9255 "Compaq 5/133 System Processor Board-1MB"
+CPQ925D "Compaq 5/100 System Processor Board-1MB"
+CPQ925F "ProLiant 2500 Dual Pentium Pro Processor Board"
+CPQ9267 "Compaq Pentium II Processor Board"
+CPQ9278 "Compaq Processor Board"
+CPQ9279 "Compaq Processor Board"
+CPQ9280 "Compaq Processor Board"
 CPQ9281 "Compaq 486/50 System Processor Board used as Primary"
 CPQ9282 "Compaq 486/50 System Processor Board used as Primary"
+CPQ9283 "Processor Modules"
+CPQ9285 "Processor Modules"
+CPQ9286 "Compaq Slot-1 Terminator Board"
 CPQ9287 "Compaq 5/66 System Processor Board used as Primary"
+CPQ928A "Compaq 5/100 System Processor Board w/ Transaction Blaster"
+CPQ928B "Compaq 5/100 System Processor Board"
 CPQ928F "Compaq 486DX2/66 System Processor Board used as Primary"
+CPQ929B "Compaq 5/90 System Processor Board"
+CPQ929F "Compaq 5/133 System Processor Board"
+CPQ92A0 "Compaq ProLiant 1500 Processor Board"
+CPQ92A4 "Compaq System Processor Board"
+CPQ92B0 "Compaq Processor Board"
+CPQ92B1 "Compaq FRC Processor Board"
+CPQ92B2 "Compaq Terminator Board"
+CPQ92B3 "6/200 FlexSMP Dual Processor Board"
+CPQ92B4 "Compaq Processor Board"
+CPQ92B5 "Compaq Terminator Board"
+CPQ92B6 "Compaq Processor Board"
+CPQ92B7 "Compaq Processor(s)"
+CPQ92B8 "Compaq Terminator Board"
+CPQ92B9 "Compaq Terminator Board"
+CPQ9351 "Compaq 5/133 System Processor Board-2MB"
+CPQ9353 "Compaq 5/166 System Processor Board-2MB"
+CPQ9355 "Compaq 5/133 System Processor Board-1MB"
+CPQ935D "Compaq 5/100 System Processor Board-1MB"
 CPQ9381 "Compaq 486/50 System Processor Board"
 CPQ9382 "Compaq 486/50 System Processor Board"
 CPQ9387 "Compaq 5/66 System Processor Board"
+CPQ938A "Compaq 5/100 System Processor Board w/ Transaction Blaster"
+CPQ938B "Compaq 5/100 System Processor Board"
+CPQ939B "Compaq 5/90 System Processor Board"
+CPQ939F "Compaq 5/133 System Processor Board"
+CPQ9451 "Compaq 5/133 System Processor Board-2MB"
+CPQ9453 "Compaq 5/166 System Processor Board-2MB"
+CPQ9455 "Compaq 5/133 System Processor Board-1MB"
+CPQ945D "Compaq 5/100 System Processor Board-1MB"
 CPQ9481 "Compaq 486/50 System Processor Board"
 CPQ9482 "Compaq 486/50 System Processor Board"
 CPQ9487 "Compaq 5/66 System Processor Board"
+CPQ948A "Compaq 5/100 System Processor Board w/ Transaction Blaster"
+CPQ948B "Compaq 5/100 System Processor Board"
+CPQ949B "Compaq 5/90 System Processor Board"
+CPQ949F "Compaq 5/133 System Processor Board"
 CPQ9901 "Compaq 486SX/16 Processor Board"
 CPQ9902 "Compaq 486SX/16 Processor Board"
 CPQ9903 "Compaq 486SX/25 Processor Board"
@@ -261,12 +366,21 @@
 CPQ9991 "Compaq 386/33 Desktop Processor Board"
 CPQ9999 "Compaq 486/33 System Processor Board used as Primary"
 CPQ999A "Compaq 486/33 Desktop Processor Board"
+CPQ9A83 "Compaq DESKPRO XL Processor Board"
+CPQ9AA1 "Compaq ProSignia 500 Processor Board"
+CPQ9AA2 "Compaq ProSignia 300 Processor Board"
 CPQA000 "Compaq Enhanced Option Slot Serial Board"
 CPQA010 "Compaq Enhanced Option Slot Modem Board"
+CPQA015 "Compaq Integrated Remote Console (IRC)"
 CPQA020 "Compaq Integrated CD Rom Adapter"
 CPQA030 "Compaq Integrated CD Rom Adapter"
+CPQA040 "Compaq Automatic Server Recovery (ASR)"
+CPQA045 "Compaq Integrated Management Display Information"
 CPQF000 "Compaq Fixed Disk Drive Feature"
 CPQF100 "Compaq Ethernet 16TP Controller"
+CPQF110 "Compaq Token Ring 16TR Controller"
+CPQF120 "Compaq NetFlex-3/E Controller"
+CPQF140 "Compaq NetFlex-3/E Controller"
 CPQFA0D "Compaq SYSTEMPRO 4-Socket System Memory Board"
 CPQFA0E "Compaq SYSTEMPRO 6-Socket System Memory Board"
 CPQFA0F "Compaq DESKPRO 486/25 System Memory Board"
@@ -274,8 +388,11 @@
 CPQFA1B "Compaq DESKPRO 486/50 System Memory Board"
 CPQFA1C "Compaq System Memory Expansion Board"
 CPQFA1D "Compaq SYSTEMPRO/XL Memory Expansion Board"
+CPQFA1E "Compaq Memory Expansion Board"
 CPQFB03 "Compaq Async/Parallel Printer Intf Assy 000990"
 CPQFB07 "Compaq DESKPRO 2400 Baud Modem"
+CPQFB09 "Compaq SpeedPaq 144/I Modem"
+CPQFB11 "Compaq Internal 28.8/33.6 Data+Fax Modem"
 CPQFC0B "Compaq Advanced Graphics 1024 Board"
 CPQFD08 "Compaq 135Mb, 150/250Mb Tape Adapter"
 CPQFD13 "Compaq 15MHz ESDI Fixed Disk Controller 001283"
diff -Nru a/drivers/fc4/soc.c b/drivers/fc4/soc.c
--- a/drivers/fc4/soc.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/fc4/soc.c	Wed Apr 30 22:28:04 2003
@@ -40,7 +40,6 @@
 
 #include <asm/openprom.h>
 #include <asm/oplib.h>
-#include <asm/auxio.h>
 #include <asm/pgtable.h>
 #include <asm/irq.h>
 
@@ -335,7 +334,7 @@
 	}
 }
 
-static void soc_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t soc_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	u32 cmd;
 	unsigned long flags;
@@ -349,6 +348,8 @@
 		if (cmd & SOC_CMD_REQ_QALL) soc_request (s, cmd);
 	}
 	spin_unlock_irqrestore(&s->lock, flags);
+
+	return IRQ_HANDLED;
 }
 
 #define TOKEN(proto, port, token) (((proto)<<12)|(token)|(port))
diff -Nru a/drivers/fc4/socal.c b/drivers/fc4/socal.c
--- a/drivers/fc4/socal.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/fc4/socal.c	Wed Apr 30 22:28:08 2003
@@ -36,7 +36,6 @@
 
 #include <asm/openprom.h>
 #include <asm/oplib.h>
-#include <asm/auxio.h>
 #include <asm/pgtable.h>
 #include <asm/irq.h>
 
@@ -405,7 +404,7 @@
 	}
 }
 
-static void socal_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t socal_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	u32 cmd;
 	unsigned long flags;
@@ -429,6 +428,8 @@
 			socal_request (s, cmd);
 	}
 	spin_unlock_irqrestore(&s->lock, flags);
+
+	return IRQ_HANDLED;
 }
 
 #define TOKEN(proto, port, token) (((proto)<<12)|(token)|(port))
diff -Nru a/drivers/hotplug/cpci_hotplug_core.c b/drivers/hotplug/cpci_hotplug_core.c
--- a/drivers/hotplug/cpci_hotplug_core.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/hotplug/cpci_hotplug_core.c	Wed Apr 30 22:28:08 2003
@@ -446,7 +446,7 @@
 }
 
 /* This is the interrupt mode interrupt handler */
-void
+irqreturn_t
 cpci_hp_intr(int irq, void *data, struct pt_regs *regs)
 {
 	dbg("entered cpci_hp_intr");
@@ -455,7 +455,7 @@
 	if((controller->irq_flags & SA_SHIRQ) &&
 	    !controller->ops->check_irq(controller->dev_id)) {
 		dbg("exited cpci_hp_intr, not our interrupt");
-		return;
+		return IRQ_NONE;
 	}
 
 	/* Disable ENUM interrupt */
@@ -465,6 +465,7 @@
 	dbg("Signal event_semaphore");
 	up(&event_semaphore);
 	dbg("exited cpci_hp_intr");
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/hotplug/cpqphp.h b/drivers/hotplug/cpqphp.h
--- a/drivers/hotplug/cpqphp.h	Wed Apr 30 22:28:15 2003
+++ b/drivers/hotplug/cpqphp.h	Wed Apr 30 22:28:15 2003
@@ -29,6 +29,7 @@
 #define _CPQPHP_H
 
 #include "pci_hotplug.h"
+#include <linux/interrupt.h>
 #include <asm/io.h>		/* for read? and write? functions */
 
 
@@ -408,7 +409,7 @@
 
 /* controller functions */
 extern void	cpqhp_pushbutton_thread		(unsigned long event_pointer);
-extern void	cpqhp_ctrl_intr			(int IRQ, struct controller *ctrl_input, struct pt_regs *regs);
+extern irqreturn_t cpqhp_ctrl_intr		(int IRQ, void *data, struct pt_regs *regs);
 extern int	cpqhp_find_available_resources	(struct controller *ctrl, void *rom_start);
 extern int	cpqhp_event_start_thread	(void);
 extern void	cpqhp_event_stop_thread		(void);
diff -Nru a/drivers/hotplug/cpqphp_core.c b/drivers/hotplug/cpqphp_core.c
--- a/drivers/hotplug/cpqphp_core.c	Wed Apr 30 22:28:02 2003
+++ b/drivers/hotplug/cpqphp_core.c	Wed Apr 30 22:28:02 2003
@@ -1148,8 +1148,7 @@
 
 	/* set up the interrupt */
 	dbg("HPC interrupt = %d \n", ctrl->interrupt);
-	if (request_irq(ctrl->interrupt,
-			(void (*)(int, void *, struct pt_regs *)) &cpqhp_ctrl_intr,
+	if (request_irq(ctrl->interrupt, cpqhp_ctrl_intr,
 			SA_SHIRQ, MY_NAME, ctrl)) {
 		err("Can't get irq %d for the hotplug pci controller\n", ctrl->interrupt);
 		rc = -ENODEV;
diff -Nru a/drivers/hotplug/cpqphp_ctrl.c b/drivers/hotplug/cpqphp_ctrl.c
--- a/drivers/hotplug/cpqphp_ctrl.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/hotplug/cpqphp_ctrl.c	Wed Apr 30 22:28:07 2003
@@ -916,8 +916,9 @@
 }
 
 
-void cpqhp_ctrl_intr(int IRQ, struct controller * ctrl, struct pt_regs *regs)
+irqreturn_t cpqhp_ctrl_intr(int IRQ, void *data, struct pt_regs *regs)
 {
+	struct controller *ctrl = data;
 	u8 schedule_flag = 0;
 	u16 misc;
 	u32 Diff;
@@ -929,7 +930,7 @@
 	// Check to see if it was our interrupt
 	//*********************************
 	if (!(misc & 0x000C)) {
-		return;
+		return IRQ_NONE;
 	}
 
 	if (misc & 0x0004) {
@@ -974,7 +975,7 @@
 		up(&event_semaphore);
 		dbg("Signal event_semaphore\n");
 	}
-
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
--- a/drivers/i2c/busses/i2c-viapro.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/i2c/busses/i2c-viapro.c	Wed Apr 30 22:28:13 2003
@@ -42,23 +42,24 @@
 #include <linux/init.h>
 #include <asm/io.h>
 
-#define SMBBA1	    0x90
-#define SMBBA2      0x80
-#define SMBBA3      0xD0
+#define SMBBA1	   	 0x90
+#define SMBBA2     	 0x80
+#define SMBBA3     	 0xD0
 
 /* SMBus address offsets */
-#define SMBHSTSTS (0 + vt596_smba)
-#define SMBHSLVSTS (1 + vt596_smba)
-#define SMBHSTCNT (2 + vt596_smba)
-#define SMBHSTCMD (3 + vt596_smba)
-#define SMBHSTADD (4 + vt596_smba)
-#define SMBHSTDAT0 (5 + vt596_smba)
-#define SMBHSTDAT1 (6 + vt596_smba)
-#define SMBBLKDAT (7 + vt596_smba)
-#define SMBSLVCNT (8 + vt596_smba)
-#define SMBSHDWCMD (9 + vt596_smba)
-#define SMBSLVEVT (0xA + vt596_smba)
-#define SMBSLVDAT (0xC + vt596_smba)
+static unsigned short vt596_smba;
+#define SMBHSTSTS	(vt596_smba + 0)
+#define SMBHSLVSTS	(vt596_smba + 1)
+#define SMBHSTCNT	(vt596_smba + 2)
+#define SMBHSTCMD	(vt596_smba + 3)
+#define SMBHSTADD	(vt596_smba + 4)
+#define SMBHSTDAT0	(vt596_smba + 5)
+#define SMBHSTDAT1	(vt596_smba + 6)
+#define SMBBLKDAT	(vt596_smba + 7)
+#define SMBSLVCNT	(vt596_smba + 8)
+#define SMBSHDWCMD	(vt596_smba + 9)
+#define SMBSLVEVT	(vt596_smba + 0xA)
+#define SMBSLVDAT	(vt596_smba + 0xC)
 
 /* PCI Address Constants */
 
@@ -68,14 +69,14 @@
 static unsigned short smb_cf_hstcfg = 0xD2;
 
 #define SMBHSTCFG   (smb_cf_hstcfg)
-#define SMBSLVC     (SMBHSTCFG+1)
-#define SMBSHDW1    (SMBHSTCFG+2)
-#define SMBSHDW2    (SMBHSTCFG+3)
-#define SMBREV      (SMBHSTCFG+4)
+#define SMBSLVC     (smb_cf_hstcfg + 1)
+#define SMBSHDW1    (smb_cf_hstcfg + 2)
+#define SMBSHDW2    (smb_cf_hstcfg + 3)
+#define SMBREV      (smb_cf_hstcfg + 4)
 
 /* Other settings */
-#define MAX_TIMEOUT 500
-#define  ENABLE_INT9 0
+#define MAX_TIMEOUT	500
+#define ENABLE_INT9	0
 
 /* VT82C596 constants */
 #define VT596_QUICK      0x00
@@ -84,144 +85,33 @@
 #define VT596_WORD_DATA  0x0C
 #define VT596_BLOCK_DATA 0x14
 
-/* insmod parameters */
 
 /* If force is set to anything different from 0, we forcibly enable the
    VT596. DANGEROUS! */
-static int force = 0;
+static int force;
 MODULE_PARM(force, "i");
 MODULE_PARM_DESC(force, "Forcibly enable the SMBus. DANGEROUS!");
 
 /* If force_addr is set to anything different from 0, we forcibly enable
    the VT596 at the given address. VERY DANGEROUS! */
-static int force_addr = 0;
+static int force_addr;
 MODULE_PARM(force_addr, "i");
 MODULE_PARM_DESC(force_addr,
 		 "Forcibly enable the SMBus at the given address. "
 		 "EXTREMELY DANGEROUS!");
 
-static void vt596_do_pause(unsigned int amount);
-static int vt596_transaction(void);
-s32 vt596_access(struct i2c_adapter * adap, u16 addr, unsigned short flags, 
-	char read_write, u8 command, int size, union i2c_smbus_data * data);
-u32 vt596_func(struct i2c_adapter *adapter);
-
-static struct i2c_algorithm smbus_algorithm = {
-	.name		= "Non-I2C SMBus adapter",
-	.id		= I2C_ALGO_SMBUS,
-	.smbus_xfer	= vt596_access,
-	.functionality	= vt596_func,
-};
-
-static struct i2c_adapter vt596_adapter = {
-	.owner		= THIS_MODULE,
-	.id		= I2C_ALGO_SMBUS | I2C_HW_SMBUS_VIA2,
-	.algo		= &smbus_algorithm,
-	.dev		= {
-		.name	= "unset",
-	},
-};
-
-
-
-
-static unsigned short vt596_smba = 0;
-
-
-/* Detect whether a compatible device can be found, and initialize it. */
-int vt596_setup(struct pci_dev *VT596_dev, struct pci_device_id const *id)
-{
-	unsigned char temp;
-	
-	dev_info(&VT596_dev->dev, "Found Via %s device\n", VT596_dev->dev.name);
-
-	/* Determine the address of the SMBus areas */
-	if (force_addr) {
-		vt596_smba = force_addr & 0xfff0;
-		force = 0;
-	} else {
-		if ((pci_read_config_word(VT596_dev, id->driver_data, &vt596_smba))
-		    || !(vt596_smba & 0x1)) {
-			/* try 2nd address and config reg. for 596 */
-			if((id->device == PCI_DEVICE_ID_VIA_82C596_3) &&
-			   (!pci_read_config_word(VT596_dev, SMBBA2, &vt596_smba)) &&
-			   (vt596_smba & 0x1)) {
-				smb_cf_hstcfg = 0x84;
-			} else {
-			        /* no matches at all */
-			        dev_err(&VT596_dev->dev, "Cannot configure "
-					"SMBus I/O Base address\n");
-			        return(-ENODEV);
-			}
-		}
-		vt596_smba &= 0xfff0;
-		if(vt596_smba == 0) {
-			dev_err(&VT596_dev->dev, "SMBus base address "
-				"uninitialized - upgrade BIOS or use "
-				"force_addr=0xaddr\n");
-			return -ENODEV;
-		}
-	}
-
-	if (!request_region(vt596_smba, 8, "viapro-smbus")) {
-		dev_err(&VT596_dev->dev, "SMBus region 0x%x already in use!\n",
-		        vt596_smba);
-		return(-ENODEV);
-	}
-
-	pci_read_config_byte(VT596_dev, SMBHSTCFG, &temp);
-	/* If force_addr is set, we program the new address here. Just to make
-	   sure, we disable the VT596 first. */
-	if (force_addr) {
-		pci_write_config_byte(VT596_dev, SMBHSTCFG, temp & 0xfe);
-		pci_write_config_word(VT596_dev, id->driver_data, vt596_smba);
-		pci_write_config_byte(VT596_dev, SMBHSTCFG, temp | 0x01);
-		dev_warn(&VT596_dev->dev, "WARNING: SMBus interface set to new "
-		     "address 0x%04x!\n", vt596_smba);
-	} else if ((temp & 1) == 0) {
-		if (force) {
-			/* NOTE: This assumes I/O space and other allocations 
-			 * WERE done by the Bios!  Don't complain if your 
-			 * hardware does weird things after enabling this. 
-			 * :') Check for Bios updates before resorting to 
-			 * this.
-			 */
-			pci_write_config_byte(VT596_dev, SMBHSTCFG,
-					      temp | 1);
-			dev_info(&VT596_dev->dev, "Enabling SMBus device\n");
-		} else {
-			dev_err(&VT596_dev->dev, "SMBUS: Error: Host SMBus "
-				"controller not enabled! - upgrade BIOS or "
-				"use force=1\n");
-			return(-ENODEV);
-		}
-	}
-
-	if ((temp & 0x0E) == 8)
-		dev_dbg(&VT596_dev->dev, "using Interrupt 9 for SMBus.\n");
-	else if ((temp & 0x0E) == 0)
-		dev_dbg(&VT596_dev->dev, "using Interrupt SMI# for SMBus.\n");
-	else
-		dev_dbg(&VT596_dev->dev, "Illegal Interrupt configuration "
-			"(or code out of date)!\n");
-
-	pci_read_config_byte(VT596_dev, SMBREV, &temp);
-	dev_dbg(&VT596_dev->dev, "SMBREV = 0x%X\n", temp);
-	dev_dbg(&VT596_dev->dev, "VT596_smba = 0x%X\n", vt596_smba);
-
-	return(0);
-}
 
+static struct i2c_adapter vt596_adapter;
 
 /* Internally used pause function */
-void vt596_do_pause(unsigned int amount)
+static void vt596_do_pause(unsigned int amount)
 {
 	current->state = TASK_INTERRUPTIBLE;
 	schedule_timeout(amount);
 }
 
 /* Another internally used function */
-int vt596_transaction(void)
+static int vt596_transaction(void)
 {
 	int temp;
 	int result = 0;
@@ -296,15 +186,16 @@
 }
 
 /* Return -1 on error. */
-s32 vt596_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, 
-		char read_write, u8 command, int size, 
-		union i2c_smbus_data * data)
+static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
+		unsigned short flags,  char read_write, u8 command,
+		int size,  union i2c_smbus_data *data)
 {
 	int i, len;
 
 	switch (size) {
 	case I2C_SMBUS_PROC_CALL:
-		dev_info(&vt596_adapter.dev, "I2C_SMBUS_PROC_CALL not supported!\n");
+		dev_info(&vt596_adapter.dev,
+			 "I2C_SMBUS_PROC_CALL not supported!\n");
 		return -1;
 	case I2C_SMBUS_QUICK:
 		outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
@@ -363,7 +254,6 @@
 	if ((read_write == I2C_SMBUS_WRITE) || (size == VT596_QUICK))
 		return 0;
 
-
 	switch (size) {
 	case VT596_BYTE:
 		/* Where is the result put? I assume here it is in
@@ -388,15 +278,127 @@
 	return 0;
 }
 
-
-u32 vt596_func(struct i2c_adapter *adapter)
+static u32 vt596_func(struct i2c_adapter *adapter)
 {
 	return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
 	    I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
 	    I2C_FUNC_SMBUS_BLOCK_DATA;
 }
 
+static struct i2c_algorithm smbus_algorithm = {
+	.name		= "Non-I2C SMBus adapter",
+	.id		= I2C_ALGO_SMBUS,
+	.smbus_xfer	= vt596_access,
+	.functionality	= vt596_func,
+};
+
+static struct i2c_adapter vt596_adapter = {
+	.owner		= THIS_MODULE,
+	.id		= I2C_ALGO_SMBUS | I2C_HW_SMBUS_VIA2,
+	.algo		= &smbus_algorithm,
+	.dev		= {
+		.name	= "unset",
+	},
+};
+
+static int __devinit vt596_probe(struct pci_dev *pdev,
+				 const struct pci_device_id *id)
+{
+	unsigned char temp;
+	int error = -ENODEV;
+	
+	/* Determine the address of the SMBus areas */
+	if (force_addr) {
+		vt596_smba = force_addr & 0xfff0;
+		force = 0;
+		goto found;
+	}
+
+	if ((pci_read_config_word(pdev, id->driver_data, &vt596_smba)) ||
+	    !(vt596_smba & 0x1)) {
+		/* try 2nd address and config reg. for 596 */
+		if (id->device == PCI_DEVICE_ID_VIA_82C596_3 &&
+		    !pci_read_config_word(pdev, SMBBA2, &vt596_smba) &&
+		    (vt596_smba & 0x1)) {
+			smb_cf_hstcfg = 0x84;
+		} else {
+			/* no matches at all */
+			dev_err(&pdev->dev, "Cannot configure "
+				"SMBus I/O Base address\n");
+			return -ENODEV;
+		}
+	}
 
+	vt596_smba &= 0xfff0;
+	if (vt596_smba == 0) {
+		dev_err(&pdev->dev, "SMBus base address "
+			"uninitialized - upgrade BIOS or use "
+			"force_addr=0xaddr\n");
+		return -ENODEV;
+	}
+
+ found:
+	if (!request_region(vt596_smba, 8, "viapro-smbus")) {
+		dev_err(&pdev->dev, "SMBus region 0x%x already in use!\n",
+		        vt596_smba);
+		return -ENODEV;
+	}
+
+	pci_read_config_byte(pdev, SMBHSTCFG, &temp);
+	/* If force_addr is set, we program the new address here. Just to make
+	   sure, we disable the VT596 first. */
+	if (force_addr) {
+		pci_write_config_byte(pdev, SMBHSTCFG, temp & 0xfe);
+		pci_write_config_word(pdev, id->driver_data, vt596_smba);
+		pci_write_config_byte(pdev, SMBHSTCFG, temp | 0x01);
+		dev_warn(&pdev->dev, "WARNING: SMBus interface set to new "
+		     "address 0x%04x!\n", vt596_smba);
+	} else if ((temp & 1) == 0) {
+		if (force) {
+			/* NOTE: This assumes I/O space and other allocations 
+			 * WERE done by the Bios!  Don't complain if your 
+			 * hardware does weird things after enabling this. 
+			 * :') Check for Bios updates before resorting to 
+			 * this.
+			 */
+			pci_write_config_byte(pdev, SMBHSTCFG, temp | 1);
+			dev_info(&pdev->dev, "Enabling SMBus device\n");
+		} else {
+			dev_err(&pdev->dev, "SMBUS: Error: Host SMBus "
+				"controller not enabled! - upgrade BIOS or "
+				"use force=1\n");
+			goto release_region;
+		}
+	}
+
+	if ((temp & 0x0E) == 8)
+		dev_dbg(&pdev->dev, "using Interrupt 9 for SMBus.\n");
+	else if ((temp & 0x0E) == 0)
+		dev_dbg(&pdev->dev, "using Interrupt SMI# for SMBus.\n");
+	else
+		dev_dbg(&pdev->dev, "Illegal Interrupt configuration "
+			"(or code out of date)!\n");
+
+	pci_read_config_byte(pdev, SMBREV, &temp);
+	dev_dbg(&pdev->dev, "SMBREV = 0x%X\n", temp);
+	dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba);
+
+	vt596_adapter.dev.parent = &pdev->dev;
+	snprintf(vt596_adapter.dev.name, DEVICE_NAME_SIZE,
+			"SMBus Via Pro adapter at %04x", vt596_smba);
+	
+	return i2c_add_adapter(&vt596_adapter);
+
+ release_region:
+	release_region(vt596_smba, 8);
+	return error;
+}
+
+static void __devexit vt596_remove(struct pci_dev *pdev)
+{
+	i2c_del_adapter(&vt596_adapter);
+	release_region(vt596_smba, 8);
+}
 
 static struct pci_device_id vt596_ids[] __devinitdata = {
 	{
@@ -451,29 +453,6 @@
 	{ 0, }
 };
 
-static int __devinit vt596_probe(struct pci_dev *dev, const struct pci_device_id *id)
-{
-	int retval;
-
-	retval = vt596_setup(dev, id);
-	if (retval)
-		return retval;
-
-	vt596_adapter.dev.parent = &dev->dev;
-
-	snprintf(vt596_adapter.dev.name, DEVICE_NAME_SIZE,
-			"SMBus Via Pro adapter at %04x", vt596_smba);
-	
-	retval = i2c_add_adapter(&vt596_adapter);
-
-	return retval;
-}
-
-static void __devexit vt596_remove(struct pci_dev *dev)
-{
-	i2c_del_adapter(&vt596_adapter);
-}
-
 static struct pci_driver vt596_driver = {
 	.name		= "vt596 smbus",
 	.id_table	= vt596_ids,
@@ -490,14 +469,12 @@
 static void __exit i2c_vt596_exit(void)
 {
 	pci_unregister_driver(&vt596_driver);
-	release_region(vt596_smba, 8);
 }
 
-
-
-MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
+MODULE_AUTHOR(
+    "Frodo Looijaard <frodol@dds.nl> and "
+    "Philip Edelbrock <phil@netroedge.com>");
 MODULE_DESCRIPTION("vt82c596 SMBus driver");
-
 MODULE_LICENSE("GPL");
 
 module_init(i2c_vt596_init);
diff -Nru a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
--- a/drivers/i2c/chips/Kconfig	Wed Apr 30 22:28:10 2003
+++ b/drivers/i2c/chips/Kconfig	Wed Apr 30 22:28:10 2003
@@ -22,6 +22,16 @@
 	  in the lm_sensors package, which you can download at 
 	  http://www.lm-sensors.nu
 
+config SENSORS_IT87
+	tristate "  National Semiconductors IT87 and compatibles"
+	depends on I2C && EXPERIMENTAL
+	help
+	  The module will be called it87.
+
+	  You will also need the latest user-space utilties: you can find them
+	  in the lm_sensors package, which you can download at 
+	  http://www.lm-sensors.nu
+
 config SENSORS_LM75
 	tristate "  National Semiconductors LM75 and compatibles"
 	depends on I2C && EXPERIMENTAL
@@ -66,8 +76,8 @@
 
 config I2C_SENSOR
 	tristate
-	default y if SENSORS_ADM1021=y || SENSORS_LM75=y || SENSORS_VIA686A=y || SENSORS_W83781D=y
-	default m if SENSORS_ADM1021=m || SENSORS_LM75=m || SENSORS_VIA686A=m || SENSORS_W83781D=m
+	default y if SENSORS_ADM1021=y || SENSORS_IT87=y || SENSORS_LM75=y || SENSORS_VIA686A=y || SENSORS_W83781D=y
+	default m if SENSORS_ADM1021=m || SENSORS_IT87=m || SENSORS_LM75=m || SENSORS_VIA686A=m || SENSORS_W83781D=m
 	default n
 
 endmenu
diff -Nru a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
--- a/drivers/i2c/chips/Makefile	Wed Apr 30 22:28:03 2003
+++ b/drivers/i2c/chips/Makefile	Wed Apr 30 22:28:03 2003
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_SENSORS_ADM1021)	+= adm1021.o
+obj-$(CONFIG_SENSORS_IT87)	+= it87.o
 obj-$(CONFIG_SENSORS_LM75)	+= lm75.o
 obj-$(CONFIG_SENSORS_VIA686A)	+= via686a.o
 obj-$(CONFIG_SENSORS_W83781D)	+= w83781d.o
diff -Nru a/drivers/i2c/chips/adm1021.c b/drivers/i2c/chips/adm1021.c
--- a/drivers/i2c/chips/adm1021.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/i2c/chips/adm1021.c	Wed Apr 30 22:28:03 2003
@@ -39,12 +39,12 @@
 #define ADM1021_ALARM_RTEMP_NA		0x04
 
 /* Addresses to scan */
-static unsigned short normal_i2c[] = { SENSORS_I2C_END };
+static unsigned short normal_i2c[] = { I2C_CLIENT_END };
 static unsigned short normal_i2c_range[] = { 0x18, 0x1a, 0x29, 0x2b,
-	0x4c, 0x4e, SENSORS_I2C_END
+	0x4c, 0x4e, I2C_CLIENT_END
 };
-static unsigned int normal_isa[] = { SENSORS_ISA_END };
-static unsigned int normal_isa_range[] = { SENSORS_ISA_END };
+static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
+static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066);
@@ -414,128 +414,6 @@
 	}
 
 	up(&data->update_lock);
-}
-
-
-/* FIXME, remove these four functions, they are here to verify the sysfs
- * conversion is correct, or not */
-__attribute__((unused))
-static void adm1021_temp(struct i2c_client *client, int operation,
-			 int ctl_name, int *nrels_mag, long *results)
-{
-	struct adm1021_data *data = i2c_get_clientdata(client);
-
-	if (operation == SENSORS_PROC_REAL_INFO)
-		*nrels_mag = 0;
-	else if (operation == SENSORS_PROC_REAL_READ) {
-		adm1021_update_client(client);
-		results[0] = TEMP_FROM_REG(data->temp_max);
-		results[1] = TEMP_FROM_REG(data->temp_hyst);
-		results[2] = TEMP_FROM_REG(data->temp_input);
-		*nrels_mag = 3;
-	} else if (operation == SENSORS_PROC_REAL_WRITE) {
-		if (*nrels_mag >= 1) {
-			data->temp_max = TEMP_TO_REG(results[0]);
-			adm1021_write_value(client, ADM1021_REG_TOS_W,
-					    data->temp_max);
-		}
-		if (*nrels_mag >= 2) {
-			data->temp_hyst = TEMP_TO_REG(results[1]);
-			adm1021_write_value(client, ADM1021_REG_THYST_W,
-					    data->temp_hyst);
-		}
-	}
-}
-
-__attribute__((unused))
-static void adm1021_remote_temp(struct i2c_client *client, int operation,
-				int ctl_name, int *nrels_mag, long *results)
-{
-	struct adm1021_data *data = i2c_get_clientdata(client);
-	int prec = 0;
-
-	if (operation == SENSORS_PROC_REAL_INFO)
-		if (data->type == adm1023) { *nrels_mag = 3; }
-                 else { *nrels_mag = 0; }
-	else if (operation == SENSORS_PROC_REAL_READ) {
-		adm1021_update_client(client);
-		results[0] = TEMP_FROM_REG(data->remote_temp_max);
-		results[1] = TEMP_FROM_REG(data->remote_temp_hyst);
-		results[2] = TEMP_FROM_REG(data->remote_temp_input);
-		if (data->type == adm1023) {
-			results[0] = results[0]*1000 + ((data->remote_temp_os_prec >> 5) * 125);
-			results[1] = results[1]*1000 + ((data->remote_temp_hyst_prec >> 5) * 125);
-			results[2] = (TEMP_FROM_REG(data->remote_temp_offset)*1000) + ((data->remote_temp_offset_prec >> 5) * 125);
-			results[3] = (TEMP_FROM_REG(data->remote_temp_input)*1000) + ((data->remote_temp_prec >> 5) * 125);
-			*nrels_mag = 4;
-		} else {
- 			*nrels_mag = 3;
-		}
-	} else if (operation == SENSORS_PROC_REAL_WRITE) {
-		if (*nrels_mag >= 1) {
-			if (data->type == adm1023) {
-				prec = ((results[0]-((results[0]/1000)*1000))/125)<<5;
-				adm1021_write_value(client, ADM1021_REG_REM_TOS_PREC, prec);
-				results[0] = results[0]/1000;
-				data->remote_temp_os_prec=prec;
-			}
-			data->remote_temp_max = TEMP_TO_REG(results[0]);
-			adm1021_write_value(client, ADM1021_REG_REMOTE_TOS_W, data->remote_temp_max);
-		}
-		if (*nrels_mag >= 2) {
-			if (data->type == adm1023) {
-				prec = ((results[1]-((results[1]/1000)*1000))/125)<<5;
-				adm1021_write_value(client, ADM1021_REG_REM_THYST_PREC, prec);
-				results[1] = results[1]/1000;
-				data->remote_temp_hyst_prec=prec;
-			}
-			data->remote_temp_hyst = TEMP_TO_REG(results[1]);
-			adm1021_write_value(client, ADM1021_REG_REMOTE_THYST_W, data->remote_temp_hyst);
-		}
-		if (*nrels_mag >= 3) {
-			if (data->type == adm1023) {
-				prec = ((results[2]-((results[2]/1000)*1000))/125)<<5;
-				adm1021_write_value(client, ADM1021_REG_REM_OFFSET_PREC, prec);
-				results[2]=results[2]/1000;
-				data->remote_temp_offset_prec=prec;
-				data->remote_temp_offset=results[2];
-				adm1021_write_value(client, ADM1021_REG_REM_OFFSET, data->remote_temp_offset);
-			}
-		}
-	}
-}
-
-__attribute__((unused))
-static void adm1021_die_code(struct i2c_client *client, int operation,
-			     int ctl_name, int *nrels_mag, long *results)
-{
-	struct adm1021_data *data = i2c_get_clientdata(client);
-
-	if (operation == SENSORS_PROC_REAL_INFO)
-		*nrels_mag = 0;
-	else if (operation == SENSORS_PROC_REAL_READ) {
-		adm1021_update_client(client);
-		results[0] = data->die_code;
-		*nrels_mag = 1;
-	} else if (operation == SENSORS_PROC_REAL_WRITE) {
-		/* Can't write to it */
-	}
-}
-
-__attribute__((unused))
-static void adm1021_alarms(struct i2c_client *client, int operation,
-			   int ctl_name, int *nrels_mag, long *results)
-{
-	struct adm1021_data *data = i2c_get_clientdata(client);
-	if (operation == SENSORS_PROC_REAL_INFO)
-		*nrels_mag = 0;
-	else if (operation == SENSORS_PROC_REAL_READ) {
-		adm1021_update_client(client);
-		results[0] = data->alarms;
-		*nrels_mag = 1;
-	} else if (operation == SENSORS_PROC_REAL_WRITE) {
-		/* Can't write to it */
-	}
 }
 
 static int __init sensors_adm1021_init(void)
diff -Nru a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/i2c/chips/it87.c	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,924 @@
+/*
+    it87.c - Part of lm_sensors, Linux kernel modules for hardware
+             monitoring.
+
+    Supports: IT8705F  Super I/O chip w/LPC interface
+              IT8712F  Super I/O chup w/LPC interface & SMbus
+              Sis950   A clone of the IT8705F
+
+    Copyright (c) 2001 Chris Gauthron <chrisg@0-in.com> 
+    Largely inspired by lm78.c of the same package
+
+    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; either version 2 of the License, or
+    (at your option) any later version.
+
+    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.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+/*
+    djg@pdp8.net David Gesswein 7/18/01
+    Modified to fix bug with not all alarms enabled.
+    Added ability to read battery voltage and select temperature sensor
+    type at module load time.
+*/
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/i2c-sensor.h>
+#include <asm/io.h>
+
+
+/* Addresses to scan */
+static unsigned short normal_i2c[] = { I2C_CLIENT_END };
+static unsigned short normal_i2c_range[] = { 0x20, 0x2f, I2C_CLIENT_END };
+static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END };
+static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
+
+/* Insmod parameters */
+SENSORS_INSMOD_4(it87, it8705, it8712, sis950);
+
+
+/* Update battery voltage after every reading if true */
+static int update_vbat = 0;
+
+
+/* Enable Temp1 as thermal resistor */
+/* Enable Temp2 as thermal diode */
+/* Enable Temp3 as thermal resistor */
+static int temp_type = 0x2a;
+
+/* Many IT87 constants specified below */
+
+/* Length of ISA address segment */
+#define IT87_EXTENT 8
+
+/* Where are the ISA address/data registers relative to the base address */
+#define IT87_ADDR_REG_OFFSET 5
+#define IT87_DATA_REG_OFFSET 6
+
+/*----- The IT87 registers -----*/
+
+#define IT87_REG_CONFIG        0x00
+
+#define IT87_REG_ALARM1        0x01
+#define IT87_REG_ALARM2        0x02
+#define IT87_REG_ALARM3        0x03
+
+#define IT87_REG_VID           0x0a
+#define IT87_REG_FAN_DIV       0x0b
+
+/* Monitors: 9 voltage (0 to 7, battery), 3 temp (1 to 3), 3 fan (1 to 3) */
+
+#define IT87_REG_FAN(nr)       (0x0c + (nr))
+#define IT87_REG_FAN_MIN(nr)   (0x0f + (nr))
+#define IT87_REG_FAN_CTRL      0x13
+
+#define IT87_REG_VIN(nr)       (0x20 + (nr))
+#define IT87_REG_TEMP(nr)      (0x28 + (nr))
+
+#define IT87_REG_VIN_MAX(nr)   (0x30 + (nr) * 2)
+#define IT87_REG_VIN_MIN(nr)   (0x31 + (nr) * 2)
+#define IT87_REG_TEMP_HIGH(nr) (0x3e + (nr) * 2)
+#define IT87_REG_TEMP_LOW(nr)  (0x3f + (nr) * 2)
+
+#define IT87_REG_I2C_ADDR      0x48
+
+#define IT87_REG_VIN_ENABLE    0x50
+#define IT87_REG_TEMP_ENABLE   0x51
+
+#define IT87_REG_CHIPID        0x58
+
+static inline u8 IN_TO_REG(long val, int inNum)
+{
+	/* to avoid floating point, we multiply everything by 100.
+	 val is guaranteed to be positive, so we can achieve the effect of 
+	 rounding by (...*10+5)/10.  Note that the *10 is hidden in the 
+	 /250 (which should really be /2500).
+	 At the end, we need to /100 because we *100 everything and we need
+	 to /10 because of the rounding thing, so we /1000.   */
+	if (inNum <= 1)
+		return (u8)
+		    SENSORS_LIMIT(((val * 210240 - 13300) / 250 + 5) / 1000, 
+				  0, 255);
+	else if (inNum == 2)
+		return (u8)
+		    SENSORS_LIMIT(((val * 157370 - 13300) / 250 + 5) / 1000, 
+				  0, 255);
+	else if (inNum == 3)
+		return (u8)
+		    SENSORS_LIMIT(((val * 101080 - 13300) / 250 + 5) / 1000, 
+				  0, 255);
+	else
+		return (u8) SENSORS_LIMIT(((val * 41714 - 13300) / 250 + 5)
+					  / 1000, 0, 255);
+}
+
+static inline long IN_FROM_REG(u8 val, int inNum)
+{
+	/* to avoid floating point, we multiply everything by 100.
+	 val is guaranteed to be positive, so we can achieve the effect of
+	 rounding by adding 0.5.  Or, to avoid fp math, we do (...*10+5)/10.
+	 We need to scale with *100 anyway, so no need to /100 at the end. */
+	if (inNum <= 1)
+		return (long) (((250000 * val + 13300) / 210240 * 10 + 5) /10);
+	else if (inNum == 2)
+		return (long) (((250000 * val + 13300) / 157370 * 10 + 5) /10);
+	else if (inNum == 3)
+		return (long) (((250000 * val + 13300) / 101080 * 10 + 5) /10);
+	else
+		return (long) (((250000 * val + 13300) / 41714 * 10 + 5) /10);
+}
+
+static inline u8 FAN_TO_REG(long rpm, int div)
+{
+	if (rpm == 0)
+		return 255;
+	rpm = SENSORS_LIMIT(rpm, 1, 1000000);
+	return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1,
+			     254);
+}
+
+#define FAN_FROM_REG(val,div) ((val)==0?-1:(val)==255?0:1350000/((val)*(div)))
+
+#define TEMP_TO_REG(val) (SENSORS_LIMIT(((val)<0?(((val)-5)/10):\
+					((val)+5)/10),0,255))
+#define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*10)
+
+#define VID_FROM_REG(val) ((val)==0x1f?0:(val)>=0x10?510-(val)*10:\
+				205-(val)*5)
+#define ALARMS_FROM_REG(val) (val)
+
+#define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1)
+#define DIV_FROM_REG(val) (1 << (val))
+
+/* Initial limits. Use the config file to set better limits. */
+#define IT87_INIT_IN_0 170
+#define IT87_INIT_IN_1 250
+#define IT87_INIT_IN_2 (330 / 2)
+#define IT87_INIT_IN_3 (((500)   * 100)/168)
+#define IT87_INIT_IN_4 (((1200)  * 10)/38)
+#define IT87_INIT_IN_5 (((1200)  * 10)/72)
+#define IT87_INIT_IN_6 (((500)   * 10)/56)
+#define IT87_INIT_IN_7 (((500)   * 100)/168)
+
+#define IT87_INIT_IN_PERCENTAGE 10
+
+#define IT87_INIT_IN_MIN_0 \
+	(IT87_INIT_IN_0 - IT87_INIT_IN_0 * IT87_INIT_IN_PERCENTAGE / 100)
+#define IT87_INIT_IN_MAX_0 \
+	(IT87_INIT_IN_0 + IT87_INIT_IN_0 * IT87_INIT_IN_PERCENTAGE / 100)
+#define IT87_INIT_IN_MIN_1 \
+	(IT87_INIT_IN_1 - IT87_INIT_IN_1 * IT87_INIT_IN_PERCENTAGE / 100)
+#define IT87_INIT_IN_MAX_1 \
+	(IT87_INIT_IN_1 + IT87_INIT_IN_1 * IT87_INIT_IN_PERCENTAGE / 100)
+#define IT87_INIT_IN_MIN_2 \
+	(IT87_INIT_IN_2 - IT87_INIT_IN_2 * IT87_INIT_IN_PERCENTAGE / 100)
+#define IT87_INIT_IN_MAX_2 \
+	(IT87_INIT_IN_2 + IT87_INIT_IN_2 * IT87_INIT_IN_PERCENTAGE / 100)
+#define IT87_INIT_IN_MIN_3 \
+	(IT87_INIT_IN_3 - IT87_INIT_IN_3 * IT87_INIT_IN_PERCENTAGE / 100)
+#define IT87_INIT_IN_MAX_3 \
+	(IT87_INIT_IN_3 + IT87_INIT_IN_3 * IT87_INIT_IN_PERCENTAGE / 100)
+#define IT87_INIT_IN_MIN_4 \
+	(IT87_INIT_IN_4 - IT87_INIT_IN_4 * IT87_INIT_IN_PERCENTAGE / 100)
+#define IT87_INIT_IN_MAX_4 \
+	(IT87_INIT_IN_4 + IT87_INIT_IN_4 * IT87_INIT_IN_PERCENTAGE / 100)
+#define IT87_INIT_IN_MIN_5 \
+	(IT87_INIT_IN_5 - IT87_INIT_IN_5 * IT87_INIT_IN_PERCENTAGE / 100)
+#define IT87_INIT_IN_MAX_5 \
+	(IT87_INIT_IN_5 + IT87_INIT_IN_5 * IT87_INIT_IN_PERCENTAGE / 100)
+#define IT87_INIT_IN_MIN_6 \
+	(IT87_INIT_IN_6 - IT87_INIT_IN_6 * IT87_INIT_IN_PERCENTAGE / 100)
+#define IT87_INIT_IN_MAX_6 \
+	(IT87_INIT_IN_6 + IT87_INIT_IN_6 * IT87_INIT_IN_PERCENTAGE / 100)
+#define IT87_INIT_IN_MIN_7 \
+	(IT87_INIT_IN_7 - IT87_INIT_IN_7 * IT87_INIT_IN_PERCENTAGE / 100)
+#define IT87_INIT_IN_MAX_7 \
+	(IT87_INIT_IN_7 + IT87_INIT_IN_7 * IT87_INIT_IN_PERCENTAGE / 100)
+
+#define IT87_INIT_FAN_MIN_1 3000
+#define IT87_INIT_FAN_MIN_2 3000
+#define IT87_INIT_FAN_MIN_3 3000
+
+#define IT87_INIT_TEMP_HIGH_1 600
+#define IT87_INIT_TEMP_LOW_1  200
+#define IT87_INIT_TEMP_HIGH_2 600
+#define IT87_INIT_TEMP_LOW_2  200
+#define IT87_INIT_TEMP_HIGH_3 600 
+#define IT87_INIT_TEMP_LOW_3  200
+
+/* For each registered IT87, we need to keep some data in memory. That
+   data is pointed to by it87_list[NR]->data. The structure itself is
+   dynamically allocated, at the same time when a new it87 client is
+   allocated. */
+struct it87_data {
+	struct semaphore lock;
+	enum chips type;
+
+	struct semaphore update_lock;
+	char valid;		/* !=0 if following fields are valid */
+	unsigned long last_updated;	/* In jiffies */
+
+	u8 in[9];		/* Register value */
+	u8 in_max[9];		/* Register value */
+	u8 in_min[9];		/* Register value */
+	u8 fan[3];		/* Register value */
+	u8 fan_min[3];		/* Register value */
+	u8 temp[3];		/* Register value */
+	u8 temp_high[3];	/* Register value */
+	u8 temp_low[3];		/* Register value */
+	u8 fan_div[3];		/* Register encoding, shifted right */
+	u8 vid;			/* Register encoding, combined */
+	u32 alarms;		/* Register encoding, combined */
+};
+
+
+static int it87_attach_adapter(struct i2c_adapter *adapter);
+static int it87_detect(struct i2c_adapter *adapter, int address, int kind);
+static int it87_detach_client(struct i2c_client *client);
+
+static int it87_read_value(struct i2c_client *client, u8 register);
+static int it87_write_value(struct i2c_client *client, u8 register,
+			u8 value);
+static void it87_update_client(struct i2c_client *client);
+static void it87_init_client(struct i2c_client *client);
+
+
+static struct i2c_driver it87_driver = {
+	.owner		= THIS_MODULE,
+	.name		= "IT87xx",
+	.id		= I2C_DRIVERID_IT87,
+	.flags		= I2C_DF_NOTIFY,
+	.attach_adapter	= it87_attach_adapter,
+	.detach_client	= it87_detach_client,
+};
+
+static int it87_id = 0;
+
+static ssize_t show_in(struct device *dev, char *buf, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct it87_data *data = i2c_get_clientdata(client);
+	it87_update_client(client);
+	return sprintf(buf, "%ld\n", IN_FROM_REG(data->in[nr], nr)*10 );
+}
+
+static ssize_t show_in_min(struct device *dev, char *buf, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct it87_data *data = i2c_get_clientdata(client);
+	it87_update_client(client);
+	return sprintf(buf, "%ld\n", IN_FROM_REG(data->in_min[nr], nr)*10 );
+}
+
+static ssize_t show_in_max(struct device *dev, char *buf, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct it87_data *data = i2c_get_clientdata(client);
+	it87_update_client(client);
+	return sprintf(buf, "%ld\n", IN_FROM_REG(data->in_max[nr], nr)*10 );
+}
+
+static ssize_t set_in_min(struct device *dev, const char *buf, 
+		size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct it87_data *data = i2c_get_clientdata(client);
+	unsigned long val = simple_strtoul(buf, NULL, 10)/10;
+	data->in_min[nr] = IN_TO_REG(val,nr);
+	it87_write_value(client, IT87_REG_VIN_MIN(nr), 
+			data->in_min[nr]);
+	return count;
+}
+static ssize_t set_in_max(struct device *dev, const char *buf, 
+		size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct it87_data *data = i2c_get_clientdata(client);
+	unsigned long val = simple_strtoul(buf, NULL, 10)/10;
+	data->in_max[nr] = IN_TO_REG(val,nr);
+	it87_write_value(client, IT87_REG_VIN_MAX(nr), 
+			data->in_max[nr]);
+	return count;
+}
+
+#define show_in_offset(offset)					\
+static ssize_t							\
+	show_in##offset (struct device *dev, char *buf)		\
+{								\
+	return show_in(dev, buf, 0x##offset);			\
+}								\
+static ssize_t							\
+	show_in##offset##_min (struct device *dev, char *buf)	\
+{								\
+	return show_in_min(dev, buf, 0x##offset);		\
+}								\
+static ssize_t							\
+	show_in##offset##_max (struct device *dev, char *buf)	\
+{								\
+	return show_in_max(dev, buf, 0x##offset);		\
+}								\
+static ssize_t set_in##offset##_min (struct device *dev, 	\
+		const char *buf, size_t count) 			\
+{								\
+	return set_in_min(dev, buf, count, 0x##offset);		\
+}								\
+static ssize_t set_in##offset##_max (struct device *dev,	\
+			const char *buf, size_t count)		\
+{								\
+	return set_in_max(dev, buf, count, 0x##offset);		\
+}								\
+static DEVICE_ATTR(in_input##offset, S_IRUGO, show_in##offset, NULL) 	\
+static DEVICE_ATTR(in_min##offset, S_IRUGO | S_IWUSR, 		\
+		show_in##offset##_min, set_in##offset##_min)	\
+static DEVICE_ATTR(in_max##offset, S_IRUGO | S_IWUSR, 		\
+		show_in##offset##_max, set_in##offset##_max)
+
+show_in_offset(0);
+show_in_offset(1);
+show_in_offset(2);
+show_in_offset(3);
+show_in_offset(4);
+
+/* 3 temperatures */
+static ssize_t show_temp(struct device *dev, char *buf, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct it87_data *data = i2c_get_clientdata(client);
+	it87_update_client(client);
+	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])*10 );
+}
+/* more like overshoot temperature */
+static ssize_t show_temp_max(struct device *dev, char *buf, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct it87_data *data = i2c_get_clientdata(client);
+	it87_update_client(client);
+	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[nr])*10);
+}
+/* more like hysteresis temperature */
+static ssize_t show_temp_min(struct device *dev, char *buf, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct it87_data *data = i2c_get_clientdata(client);
+	it87_update_client(client);
+	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[nr])*10);
+}
+static ssize_t set_temp_max(struct device *dev, const char *buf, 
+		size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct it87_data *data = i2c_get_clientdata(client);
+	int val = simple_strtol(buf, NULL, 10)/10;
+	data->temp_high[nr] = TEMP_TO_REG(val);
+	it87_write_value(client, IT87_REG_TEMP_HIGH(nr), data->temp_high[nr]);
+	return count;
+}
+static ssize_t set_temp_min(struct device *dev, const char *buf, 
+		size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct it87_data *data = i2c_get_clientdata(client);
+	int val = simple_strtol(buf, NULL, 10)/10;
+	data->temp_low[nr] = TEMP_TO_REG(val);
+	it87_write_value(client, IT87_REG_TEMP_LOW(nr), data->temp_low[nr]);
+	return count;
+}
+#define show_temp_offset(offset)					\
+static ssize_t show_temp_##offset (struct device *dev, char *buf)	\
+{									\
+	return show_temp(dev, buf, 0x##offset - 1);			\
+}									\
+static ssize_t								\
+show_temp_##offset##_max (struct device *dev, char *buf)		\
+{									\
+	return show_temp_max(dev, buf, 0x##offset - 1);			\
+}									\
+static ssize_t								\
+show_temp_##offset##_min (struct device *dev, char *buf)		\
+{									\
+	return show_temp_min(dev, buf, 0x##offset - 1);			\
+}									\
+static ssize_t set_temp_##offset##_max (struct device *dev, 		\
+		const char *buf, size_t count) 				\
+{									\
+	return set_temp_max(dev, buf, count, 0x##offset - 1);		\
+}									\
+static ssize_t set_temp_##offset##_min (struct device *dev, 		\
+		const char *buf, size_t count) 				\
+{									\
+	return set_temp_min(dev, buf, count, 0x##offset - 1);		\
+}									\
+static DEVICE_ATTR(temp_input##offset, S_IRUGO, show_temp_##offset, NULL) \
+static DEVICE_ATTR(temp_max##offset, S_IRUGO | S_IWUSR, 		\
+		show_temp_##offset##_max, set_temp_##offset##_max) 	\
+static DEVICE_ATTR(temp_min##offset, S_IRUGO | S_IWUSR, 		\
+		show_temp_##offset##_min, set_temp_##offset##_min)	
+
+show_temp_offset(1);
+show_temp_offset(2);
+show_temp_offset(3);
+
+/* 2 Fans */
+static ssize_t show_fan(struct device *dev, char *buf, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct it87_data *data = i2c_get_clientdata(client);
+	it87_update_client(client);
+	return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], 
+				DIV_FROM_REG(data->fan_div[nr])) );
+}
+static ssize_t show_fan_min(struct device *dev, char *buf, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct it87_data *data = i2c_get_clientdata(client);
+	it87_update_client(client);
+	return sprintf(buf,"%d\n",
+		FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])) );
+}
+static ssize_t show_fan_div(struct device *dev, char *buf, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct it87_data *data = i2c_get_clientdata(client);
+	it87_update_client(client);
+	return sprintf(buf,"%d\n", DIV_FROM_REG(data->fan_div[nr]) );
+}
+static ssize_t set_fan_min(struct device *dev, const char *buf, 
+		size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct it87_data *data = i2c_get_clientdata(client);
+	int val = simple_strtol(buf, NULL, 10);
+	data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
+	it87_write_value(client, IT87_REG_FAN_MIN(nr+1), data->fan_min[nr]);
+	return count;
+}
+static ssize_t set_fan_div(struct device *dev, const char *buf, 
+		size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct it87_data *data = i2c_get_clientdata(client);
+	int val = simple_strtol(buf, NULL, 10);
+	int old = it87_read_value(client, IT87_REG_FAN_DIV);
+	data->fan_div[nr] = DIV_TO_REG(val);
+	old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4);
+	it87_write_value(client, IT87_REG_FAN_DIV, old);
+	return count;
+}
+
+#define show_fan_offset(offset)						\
+static ssize_t show_fan_##offset (struct device *dev, char *buf)	\
+{									\
+	return show_fan(dev, buf, 0x##offset - 1);			\
+}									\
+static ssize_t show_fan_##offset##_min (struct device *dev, char *buf)	\
+{									\
+	return show_fan_min(dev, buf, 0x##offset - 1);			\
+}									\
+static ssize_t show_fan_##offset##_div (struct device *dev, char *buf)	\
+{									\
+	return show_fan_div(dev, buf, 0x##offset - 1);			\
+}									\
+static ssize_t set_fan_##offset##_min (struct device *dev, 		\
+	const char *buf, size_t count) 					\
+{									\
+	return set_fan_min(dev, buf, count, 0x##offset - 1);		\
+}									\
+static ssize_t set_fan_##offset##_div (struct device *dev, 		\
+		const char *buf, size_t count) 				\
+{									\
+	return set_fan_div(dev, buf, count, 0x##offset - 1);		\
+}									\
+static DEVICE_ATTR(fan_input##offset, S_IRUGO, show_fan_##offset, NULL) \
+static DEVICE_ATTR(fan_min##offset, S_IRUGO | S_IWUSR, 			\
+		show_fan_##offset##_min, set_fan_##offset##_min) 	\
+static DEVICE_ATTR(fan_div##offset, S_IRUGO | S_IWUSR, 			\
+		show_fan_##offset##_div, set_fan_##offset##_div)
+
+show_fan_offset(1);
+show_fan_offset(2);
+
+/* Alarm */
+static ssize_t show_alarm(struct device *dev, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct it87_data *data = i2c_get_clientdata(client);
+	it87_update_client(client);
+	return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms));
+}
+static DEVICE_ATTR(alarm, S_IRUGO | S_IWUSR, show_alarm, NULL);
+
+/* This function is called when:
+     * it87_driver is inserted (when this module is loaded), for each
+       available adapter
+     * when a new adapter is inserted (and it87_driver is still present) */
+static int it87_attach_adapter(struct i2c_adapter *adapter)
+{
+	return i2c_detect(adapter, &addr_data, it87_detect);
+}
+
+/* This function is called by i2c_detect */
+int it87_detect(struct i2c_adapter *adapter, int address, int kind)
+{
+	int i;
+	struct i2c_client *new_client = NULL;
+	struct it87_data *data;
+	int err = 0;
+	const char *name = "";
+	const char *client_name = "";
+	int is_isa = i2c_is_isa_adapter(adapter);
+
+	if (!is_isa && 
+	    !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+		goto ERROR0;
+
+	/* Reserve the ISA region */
+	if (is_isa)
+		if (!request_region(address, IT87_EXTENT, name))
+			goto ERROR0;
+
+	/* Probe whether there is anything available on this address. Already
+	   done for SMBus clients */
+	if (kind < 0) {
+		if (is_isa) {
+
+#define REALLY_SLOW_IO
+			/* We need the timeouts for at least some IT87-like chips. But only
+			   if we read 'undefined' registers. */
+			i = inb_p(address + 1);
+			if (inb_p(address + 2) != i)
+				goto ERROR1;
+			if (inb_p(address + 3) != i)
+				goto ERROR1;
+			if (inb_p(address + 7) != i)
+				goto ERROR1;
+#undef REALLY_SLOW_IO
+
+			/* Let's just hope nothing breaks here */
+			i = inb_p(address + 5) & 0x7f;
+			outb_p(~i & 0x7f, address + 5);
+			if ((inb_p(address + 5) & 0x7f) != (~i & 0x7f)) {
+				outb_p(i, address + 5);
+				return 0;
+			}
+		}
+	}
+
+	/* OK. For now, we presume we have a valid client. We now create the
+	   client structure, even though we cannot fill it completely yet.
+	   But it allows us to access it87_{read,write}_value. */
+
+	if (!(new_client = kmalloc((sizeof(struct i2c_client)) +
+					sizeof(struct it87_data),
+					GFP_KERNEL))) {
+		err = -ENOMEM;
+		goto ERROR1;
+	}
+
+	data = (struct it87_data *) (new_client + 1);
+	if (is_isa)
+		init_MUTEX(&data->lock);
+	i2c_set_clientdata(new_client, data);
+	new_client->addr = address;
+	new_client->adapter = adapter;
+	new_client->driver = &it87_driver;
+	new_client->flags = 0;
+
+	/* Now, we do the remaining detection. */
+
+	if (kind < 0) {
+		if (it87_read_value(new_client, IT87_REG_CONFIG) & 0x80)
+			goto ERROR1;
+		if (!is_isa
+			&& (it87_read_value(new_client, IT87_REG_I2C_ADDR) !=
+			address)) goto ERROR1;
+	}
+
+	/* Determine the chip type. */
+	if (kind <= 0) {
+		i = it87_read_value(new_client, IT87_REG_CHIPID);
+		if (i == 0x90) {
+			kind = it87;
+		}
+		else {
+			if (kind == 0)
+				printk
+				    ("it87.o: Ignoring 'force' parameter for unknown chip at "
+				     "adapter %d, address 0x%02x\n",
+				     i2c_adapter_id(adapter), address);
+			goto ERROR1;
+		}
+	}
+
+	if (kind == it87) {
+		name = "it87";
+		client_name = "IT87 chip";
+	} /* else if (kind == it8712) {
+		name = "it8712";
+		client_name = "IT87-J chip";
+	} */ else {
+		dev_dbg(&adapter->dev, "Internal error: unknown kind (%d)?!?",
+			kind);
+		goto ERROR1;
+	}
+
+	/* Fill in the remaining client fields and put it into the global list */
+	strncpy(new_client->dev.name, name, DEVICE_NAME_SIZE);
+
+	data->type = kind;
+
+	new_client->id = it87_id++;
+	data->valid = 0;
+	init_MUTEX(&data->update_lock);
+
+	/* Tell the I2C layer a new client has arrived */
+	if ((err = i2c_attach_client(new_client)))
+		goto ERROR1;
+
+	/* register sysfs hooks */
+	device_create_file(&new_client->dev, &dev_attr_in_input0);
+	device_create_file(&new_client->dev, &dev_attr_in_input1);
+	device_create_file(&new_client->dev, &dev_attr_in_input2);
+	device_create_file(&new_client->dev, &dev_attr_in_input3);
+	device_create_file(&new_client->dev, &dev_attr_in_input4);
+	device_create_file(&new_client->dev, &dev_attr_in_min0);
+	device_create_file(&new_client->dev, &dev_attr_in_min1);
+	device_create_file(&new_client->dev, &dev_attr_in_min2);
+	device_create_file(&new_client->dev, &dev_attr_in_min3);
+	device_create_file(&new_client->dev, &dev_attr_in_min4);
+	device_create_file(&new_client->dev, &dev_attr_in_max0);
+	device_create_file(&new_client->dev, &dev_attr_in_max1);
+	device_create_file(&new_client->dev, &dev_attr_in_max2);
+	device_create_file(&new_client->dev, &dev_attr_in_max3);
+	device_create_file(&new_client->dev, &dev_attr_in_max4);
+	device_create_file(&new_client->dev, &dev_attr_temp_input1);
+	device_create_file(&new_client->dev, &dev_attr_temp_input2);
+	device_create_file(&new_client->dev, &dev_attr_temp_input3);
+	device_create_file(&new_client->dev, &dev_attr_temp_max1);
+	device_create_file(&new_client->dev, &dev_attr_temp_max2);
+	device_create_file(&new_client->dev, &dev_attr_temp_max3);
+	device_create_file(&new_client->dev, &dev_attr_temp_min1);
+	device_create_file(&new_client->dev, &dev_attr_temp_min2);
+	device_create_file(&new_client->dev, &dev_attr_temp_min3);
+	device_create_file(&new_client->dev, &dev_attr_fan_input1);
+	device_create_file(&new_client->dev, &dev_attr_fan_input2);
+	device_create_file(&new_client->dev, &dev_attr_fan_min1);
+	device_create_file(&new_client->dev, &dev_attr_fan_min2);
+	device_create_file(&new_client->dev, &dev_attr_fan_div1);
+	device_create_file(&new_client->dev, &dev_attr_fan_div2);
+	device_create_file(&new_client->dev, &dev_attr_alarm);
+
+	/* Initialize the IT87 chip */
+	it87_init_client(new_client);
+	return 0;
+
+ERROR1:
+	kfree(new_client);
+
+	if (is_isa)
+		release_region(address, IT87_EXTENT);
+ERROR0:
+	return err;
+}
+
+static int it87_detach_client(struct i2c_client *client)
+{
+	int err;
+
+	if ((err = i2c_detach_client(client))) {
+		dev_err(&client->dev,
+			"Client deregistration failed, client not detached.\n");
+		return err;
+	}
+
+	if(i2c_is_isa_client(client))
+		release_region(client->addr, IT87_EXTENT);
+	kfree(client);
+
+	return 0;
+}
+
+/* The SMBus locks itself, but ISA access must be locked explicitely! 
+   We don't want to lock the whole ISA bus, so we lock each client
+   separately.
+   We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks,
+   would slow down the IT87 access and should not be necessary. 
+   There are some ugly typecasts here, but the good new is - they should
+   nowhere else be necessary! */
+static int it87_read_value(struct i2c_client *client, u8 reg)
+{
+	struct it87_data *data = i2c_get_clientdata(client);
+
+	int res;
+	if (i2c_is_isa_client(client)) {
+		down(&data->lock);
+		outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET);
+		res = inb_p(client->addr + IT87_DATA_REG_OFFSET);
+		up(&data->lock);
+		return res;
+	} else
+		return i2c_smbus_read_byte_data(client, reg);
+}
+
+/* The SMBus locks itself, but ISA access muse be locked explicitely! 
+   We don't want to lock the whole ISA bus, so we lock each client
+   separately.
+   We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks,
+   would slow down the IT87 access and should not be necessary. 
+   There are some ugly typecasts here, but the good new is - they should
+   nowhere else be necessary! */
+static int it87_write_value(struct i2c_client *client, u8 reg, u8 value)
+{
+	struct it87_data *data = i2c_get_clientdata(client);
+
+	if (i2c_is_isa_client(client)) {
+		down(&data->lock);
+		outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET);
+		outb_p(value, client->addr + IT87_DATA_REG_OFFSET);
+		up(&data->lock);
+		return 0;
+	} else
+		return i2c_smbus_write_byte_data(client, reg, value);
+}
+
+/* Called when we have found a new IT87. It should set limits, etc. */
+static void it87_init_client(struct i2c_client *client)
+{
+	/* Reset all except Watchdog values and last conversion values
+	   This sets fan-divs to 2, among others */
+	it87_write_value(client, IT87_REG_CONFIG, 0x80);
+	it87_write_value(client, IT87_REG_VIN_MIN(0),
+			 IN_TO_REG(IT87_INIT_IN_MIN_0, 0));
+	it87_write_value(client, IT87_REG_VIN_MAX(0),
+			 IN_TO_REG(IT87_INIT_IN_MAX_0, 0));
+	it87_write_value(client, IT87_REG_VIN_MIN(1),
+			 IN_TO_REG(IT87_INIT_IN_MIN_1, 1));
+	it87_write_value(client, IT87_REG_VIN_MAX(1),
+			 IN_TO_REG(IT87_INIT_IN_MAX_1, 1));
+	it87_write_value(client, IT87_REG_VIN_MIN(2),
+			 IN_TO_REG(IT87_INIT_IN_MIN_2, 2));
+	it87_write_value(client, IT87_REG_VIN_MAX(2),
+			 IN_TO_REG(IT87_INIT_IN_MAX_2, 2));
+	it87_write_value(client, IT87_REG_VIN_MIN(3),
+			 IN_TO_REG(IT87_INIT_IN_MIN_3, 3));
+	it87_write_value(client, IT87_REG_VIN_MAX(3),
+			 IN_TO_REG(IT87_INIT_IN_MAX_3, 3));
+	it87_write_value(client, IT87_REG_VIN_MIN(4),
+			 IN_TO_REG(IT87_INIT_IN_MIN_4, 4));
+	it87_write_value(client, IT87_REG_VIN_MAX(4),
+			 IN_TO_REG(IT87_INIT_IN_MAX_4, 4));
+	it87_write_value(client, IT87_REG_VIN_MIN(5),
+			 IN_TO_REG(IT87_INIT_IN_MIN_5, 5));
+	it87_write_value(client, IT87_REG_VIN_MAX(5),
+			 IN_TO_REG(IT87_INIT_IN_MAX_5, 5));
+	it87_write_value(client, IT87_REG_VIN_MIN(6),
+			 IN_TO_REG(IT87_INIT_IN_MIN_6, 6));
+	it87_write_value(client, IT87_REG_VIN_MAX(6),
+			 IN_TO_REG(IT87_INIT_IN_MAX_6, 6));
+	it87_write_value(client, IT87_REG_VIN_MIN(7),
+			 IN_TO_REG(IT87_INIT_IN_MIN_7, 7));
+	it87_write_value(client, IT87_REG_VIN_MAX(7),
+			 IN_TO_REG(IT87_INIT_IN_MAX_7, 7));
+	/* Note: Battery voltage does not have limit registers */
+	it87_write_value(client, IT87_REG_FAN_MIN(1),
+			 FAN_TO_REG(IT87_INIT_FAN_MIN_1, 2));
+	it87_write_value(client, IT87_REG_FAN_MIN(2),
+			 FAN_TO_REG(IT87_INIT_FAN_MIN_2, 2));
+	it87_write_value(client, IT87_REG_FAN_MIN(3),
+			 FAN_TO_REG(IT87_INIT_FAN_MIN_3, 2));
+	it87_write_value(client, IT87_REG_TEMP_HIGH(1),
+			 TEMP_TO_REG(IT87_INIT_TEMP_HIGH_1));
+	it87_write_value(client, IT87_REG_TEMP_LOW(1),
+			 TEMP_TO_REG(IT87_INIT_TEMP_LOW_1));
+	it87_write_value(client, IT87_REG_TEMP_HIGH(2),
+			 TEMP_TO_REG(IT87_INIT_TEMP_HIGH_2));
+	it87_write_value(client, IT87_REG_TEMP_LOW(2),
+			 TEMP_TO_REG(IT87_INIT_TEMP_LOW_2));
+	it87_write_value(client, IT87_REG_TEMP_HIGH(3),
+			 TEMP_TO_REG(IT87_INIT_TEMP_HIGH_3));
+	it87_write_value(client, IT87_REG_TEMP_LOW(3),
+			 TEMP_TO_REG(IT87_INIT_TEMP_LOW_3));
+
+	/* Enable voltage monitors */
+	it87_write_value(client, IT87_REG_VIN_ENABLE, 0xff);
+
+	/* Enable Temp1-Temp3 */
+	it87_write_value(client, IT87_REG_TEMP_ENABLE,
+			(it87_read_value(client, IT87_REG_TEMP_ENABLE) & 0xc0)
+			| (temp_type & 0x3f));
+
+	/* Enable fans */
+	it87_write_value(client, IT87_REG_FAN_CTRL,
+			(it87_read_value(client, IT87_REG_FAN_CTRL) & 0x8f)
+			| 0x70);
+
+	/* Start monitoring */
+	it87_write_value(client, IT87_REG_CONFIG,
+			 (it87_read_value(client, IT87_REG_CONFIG) & 0xb7)
+			 | (update_vbat ? 0x41 : 0x01));
+}
+
+static void it87_update_client(struct i2c_client *client)
+{
+	struct it87_data *data = i2c_get_clientdata(client);
+	int i;
+
+	down(&data->update_lock);
+
+	if ((jiffies - data->last_updated > HZ + HZ / 2) ||
+	    (jiffies < data->last_updated) || !data->valid) {
+
+		if (update_vbat) {
+			/* Cleared after each update, so reenable.  Value
+		 	  returned by this read will be previous value */	
+			it87_write_value(client, IT87_REG_CONFIG,
+			   it87_read_value(client, IT87_REG_CONFIG) | 0x40);
+		}
+		for (i = 0; i <= 7; i++) {
+			data->in[i] =
+			    it87_read_value(client, IT87_REG_VIN(i));
+			data->in_min[i] =
+			    it87_read_value(client, IT87_REG_VIN_MIN(i));
+			data->in_max[i] =
+			    it87_read_value(client, IT87_REG_VIN_MAX(i));
+		}
+		data->in[8] =
+		    it87_read_value(client, IT87_REG_VIN(8));
+		/* Temperature sensor doesn't have limit registers, set
+		   to min and max value */
+		data->in_min[8] = 0;
+		data->in_max[8] = 255;
+
+		for (i = 1; i <= 3; i++) {
+			data->fan[i - 1] =
+			    it87_read_value(client, IT87_REG_FAN(i));
+			data->fan_min[i - 1] =
+			    it87_read_value(client, IT87_REG_FAN_MIN(i));
+		}
+		for (i = 1; i <= 3; i++) {
+			data->temp[i - 1] =
+			    it87_read_value(client, IT87_REG_TEMP(i));
+			data->temp_high[i - 1] =
+			    it87_read_value(client, IT87_REG_TEMP_HIGH(i));
+			data->temp_low[i - 1] =
+			    it87_read_value(client, IT87_REG_TEMP_LOW(i));
+		}
+
+		/* The 8705 does not have VID capability */
+		/*if (data->type == it8712) {
+			data->vid = it87_read_value(client, IT87_REG_VID);
+			data->vid &= 0x1f;
+		}
+		else */ {
+			data->vid = 0x1f;
+		}
+
+		i = it87_read_value(client, IT87_REG_FAN_DIV);
+		data->fan_div[0] = i & 0x07;
+		data->fan_div[1] = (i >> 3) & 0x07;
+		data->fan_div[2] = 1;
+
+		data->alarms =
+			it87_read_value(client, IT87_REG_ALARM1) |
+			(it87_read_value(client, IT87_REG_ALARM2) << 8) |
+			(it87_read_value(client, IT87_REG_ALARM3) << 16);
+
+		data->last_updated = jiffies;
+		data->valid = 1;
+	}
+
+	up(&data->update_lock);
+}
+
+static int __init sm_it87_init(void)
+{
+	return i2c_add_driver(&it87_driver);
+}
+
+static void __exit sm_it87_exit(void)
+{
+	i2c_del_driver(&it87_driver);
+}
+
+
+MODULE_AUTHOR("Chris Gauthron <chrisg@0-in.com>");
+MODULE_DESCRIPTION("IT8705F, IT8712F, Sis950 driver");
+MODULE_PARM(update_vbat, "i");
+MODULE_PARM_DESC(update_vbat, "Update vbat if set else return powerup value");
+MODULE_PARM(temp_type, "i");
+MODULE_PARM_DESC(temp_type, "Temperature sensor type, normally leave unset");
+MODULE_LICENSE("GPL");
+
+module_init(sm_it87_init);
+module_exit(sm_it87_exit);
diff -Nru a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c
--- a/drivers/i2c/chips/lm75.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/i2c/chips/lm75.c	Wed Apr 30 22:28:03 2003
@@ -28,10 +28,10 @@
 
 
 /* Addresses to scan */
-static unsigned short normal_i2c[] = { SENSORS_I2C_END };
-static unsigned short normal_i2c_range[] = { 0x48, 0x4f, SENSORS_I2C_END };
-static unsigned int normal_isa[] = { SENSORS_ISA_END };
-static unsigned int normal_isa_range[] = { SENSORS_ISA_END };
+static unsigned short normal_i2c[] = { I2C_CLIENT_END };
+static unsigned short normal_i2c_range[] = { 0x48, 0x4f, I2C_CLIENT_END };
+static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
+static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_1(lm75);
diff -Nru a/drivers/i2c/chips/via686a.c b/drivers/i2c/chips/via686a.c
--- a/drivers/i2c/chips/via686a.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/i2c/chips/via686a.c	Wed Apr 30 22:28:04 2003
@@ -51,10 +51,10 @@
 /* Addresses to scan.
    Note that we can't determine the ISA address until we have initialized
    our module */
-static unsigned short normal_i2c[] = { SENSORS_I2C_END };
-static unsigned short normal_i2c_range[] = { SENSORS_I2C_END };
-static unsigned int normal_isa[] = { 0x0000, SENSORS_ISA_END };
-static unsigned int normal_isa_range[] = { SENSORS_ISA_END };
+static unsigned short normal_i2c[] = { I2C_CLIENT_END };
+static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
+static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END };
+static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_1(via686a);
diff -Nru a/drivers/i2c/chips/w83781d.c b/drivers/i2c/chips/w83781d.c
--- a/drivers/i2c/chips/w83781d.c	Wed Apr 30 22:28:02 2003
+++ b/drivers/i2c/chips/w83781d.c	Wed Apr 30 22:28:02 2003
@@ -46,14 +46,14 @@
 #define W83781D_RT			1
 
 /* Addresses to scan */
-static unsigned short normal_i2c[] = { SENSORS_I2C_END };
-static unsigned short normal_i2c_range[] = { 0x20, 0x2f, SENSORS_I2C_END };
-static unsigned int normal_isa[] = { 0x0290, SENSORS_ISA_END };
-static unsigned int normal_isa_range[] = { SENSORS_ISA_END };
+static unsigned short normal_i2c[] = { I2C_CLIENT_END };
+static unsigned short normal_i2c_range[] = { 0x20, 0x2f, I2C_CLIENT_END };
+static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END };
+static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_6(w83781d, w83782d, w83783s, w83627hf, as99127f, w83697hf);
-SENSORS_MODULE_PARM(force_subclients, "List of subclient addresses: "
+I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: "
 		    "{bus, clientaddr, subclientaddr1, subclientaddr2}");
 
 static int init = 1;
diff -Nru a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
--- a/drivers/i2c/i2c-core.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/i2c/i2c-core.c	Wed Apr 30 22:28:05 2003
@@ -618,8 +618,8 @@
  * ----------------------------------------------------
  */
 int i2c_probe(struct i2c_adapter *adapter,
-                   struct i2c_client_address_data *address_data,
-                   i2c_client_found_addr_proc *found_proc)
+	      struct i2c_client_address_data *address_data,
+	      int (*found_proc) (struct i2c_adapter *, int, int))
 {
 	int addr,i,found,err;
 	int adap_id = i2c_adapter_id(adapter);
@@ -644,7 +644,7 @@
 			     (addr == address_data->force[i+1])) {
 				DEB2(printk(KERN_DEBUG "i2c-core.o: found force parameter for adapter %d, addr %04x\n",
 				            adap_id,addr));
-				if ((err = found_proc(adapter,addr,0,0)))
+				if ((err = found_proc(adapter,addr,0)))
 					return err;
 				found = 1;
 			}
@@ -732,7 +732,7 @@
 		/* OK, so we really should examine this address. First check
 		   whether there is some client here at all! */
 		if (i2c_smbus_xfer(adapter,addr,0,0,0,I2C_SMBUS_QUICK,NULL) >= 0)
-			if ((err = found_proc(adapter,addr,0,-1)))
+			if ((err = found_proc(adapter,addr,-1)))
 				return err;
 	}
 	return 0;
diff -Nru a/drivers/i2c/i2c-elektor.c b/drivers/i2c/i2c-elektor.c
--- a/drivers/i2c/i2c-elektor.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/i2c/i2c-elektor.c	Wed Apr 30 22:28:03 2003
@@ -132,9 +132,10 @@
 }
 
 
-static void pcf_isa_handler(int this_irq, void *dev_id, struct pt_regs *regs) {
+static irqreturn_t pcf_isa_handler(int this_irq, void *dev_id, struct pt_regs *regs) {
 	pcf_pending = 1;
 	wake_up_interruptible(&pcf_wait);
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/i2c/i2c-sensor.c b/drivers/i2c/i2c-sensor.c
--- a/drivers/i2c/i2c-sensor.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/i2c/i2c-sensor.c	Wed Apr 30 22:28:09 2003
@@ -35,14 +35,14 @@
 
 /* Very inefficient for ISA detects, and won't work for 10-bit addresses! */
 int i2c_detect(struct i2c_adapter *adapter,
-		   struct i2c_address_data *address_data,
-		   i2c_found_addr_proc * found_proc)
+	       struct i2c_address_data *address_data,
+	       int (*found_proc) (struct i2c_adapter *, int, int))
 {
 	int addr, i, found, j, err;
 	struct i2c_force_data *this_force;
 	int is_isa = i2c_is_isa_adapter(adapter);
 	int adapter_id =
-	    is_isa ? SENSORS_ISA_BUS : i2c_adapter_id(adapter);
+	    is_isa ? ANY_I2C_ISA_BUS : i2c_adapter_id(adapter);
 
 	/* Forget it if we can't probe using SMBUS_QUICK */
 	if ((!is_isa) &&
@@ -59,9 +59,9 @@
 		   detection at all */
 		found = 0;
 		for (i = 0; !found && (this_force = address_data->forces + i, this_force->force); i++) {
-			for (j = 0; !found && (this_force->force[j] != SENSORS_I2C_END); j += 2) {
+			for (j = 0; !found && (this_force->force[j] != I2C_CLIENT_END); j += 2) {
 				if ( ((adapter_id == this_force->force[j]) ||
-				      ((this_force->force[j] == SENSORS_ANY_I2C_BUS) && !is_isa)) &&
+				      ((this_force->force[j] == ANY_I2C_BUS) && !is_isa)) &&
 				      (addr == this_force->force[j + 1]) ) {
 					dev_dbg(&adapter->dev, "found force parameter for adapter %d, addr %04x\n", adapter_id, addr);
 					if ((err = found_proc(adapter, addr, this_force->kind)))
@@ -75,18 +75,18 @@
 
 		/* If this address is in one of the ignores, we can forget about it
 		   right now */
-		for (i = 0; !found && (address_data->ignore[i] != SENSORS_I2C_END); i += 2) {
+		for (i = 0; !found && (address_data->ignore[i] != I2C_CLIENT_END); i += 2) {
 			if ( ((adapter_id == address_data->ignore[i]) ||
-			      ((address_data->ignore[i] == SENSORS_ANY_I2C_BUS) &&
+			      ((address_data->ignore[i] == ANY_I2C_BUS) &&
 			       !is_isa)) &&
 			      (addr == address_data->ignore[i + 1])) {
 				dev_dbg(&adapter->dev, "found ignore parameter for adapter %d, addr %04x\n", adapter_id, addr);
 				found = 1;
 			}
 		}
-		for (i = 0; !found && (address_data->ignore_range[i] != SENSORS_I2C_END); i += 3) {
+		for (i = 0; !found && (address_data->ignore_range[i] != I2C_CLIENT_END); i += 3) {
 			if ( ((adapter_id == address_data->ignore_range[i]) ||
-			      ((address_data-> ignore_range[i] == SENSORS_ANY_I2C_BUS) & 
+			      ((address_data-> ignore_range[i] == ANY_I2C_BUS) & 
 			       !is_isa)) &&
 			     (addr >= address_data->ignore_range[i + 1]) &&
 			     (addr <= address_data->ignore_range[i + 2])) {
@@ -100,13 +100,13 @@
 		/* Now, we will do a detection, but only if it is in the normal or 
 		   probe entries */
 		if (is_isa) {
-			for (i = 0; !found && (address_data->normal_isa[i] != SENSORS_ISA_END); i += 1) {
+			for (i = 0; !found && (address_data->normal_isa[i] != I2C_CLIENT_ISA_END); i += 1) {
 				if (addr == address_data->normal_isa[i]) {
 					dev_dbg(&adapter->dev, "found normal isa entry for adapter %d, addr %04x\n", adapter_id, addr);
 					found = 1;
 				}
 			}
-			for (i = 0; !found && (address_data->normal_isa_range[i] != SENSORS_ISA_END); i += 3) {
+			for (i = 0; !found && (address_data->normal_isa_range[i] != I2C_CLIENT_ISA_END); i += 3) {
 				if ((addr >= address_data->normal_isa_range[i]) &&
 				    (addr <= address_data->normal_isa_range[i + 1]) &&
 				    ((addr - address_data->normal_isa_range[i]) % address_data->normal_isa_range[i + 2] == 0)) {
@@ -115,13 +115,13 @@
 				}
 			}
 		} else {
-			for (i = 0; !found && (address_data->normal_i2c[i] != SENSORS_I2C_END); i += 1) {
+			for (i = 0; !found && (address_data->normal_i2c[i] != I2C_CLIENT_END); i += 1) {
 				if (addr == address_data->normal_i2c[i]) {
 					found = 1;
 					dev_dbg(&adapter->dev, "found normal i2c entry for adapter %d, addr %02x", adapter_id, addr);
 				}
 			}
-			for (i = 0; !found && (address_data->normal_i2c_range[i] != SENSORS_I2C_END); i += 2) {
+			for (i = 0; !found && (address_data->normal_i2c_range[i] != I2C_CLIENT_END); i += 2) {
 				if ((addr >= address_data->normal_i2c_range[i]) &&
 				    (addr <= address_data->normal_i2c_range[i + 1])) {
 					dev_dbg(&adapter->dev, "found normal i2c_range entry for adapter %d, addr %04x\n", adapter_id, addr);
@@ -131,19 +131,19 @@
 		}
 
 		for (i = 0;
-		     !found && (address_data->probe[i] != SENSORS_I2C_END);
+		     !found && (address_data->probe[i] != I2C_CLIENT_END);
 		     i += 2) {
 			if (((adapter_id == address_data->probe[i]) ||
 			     ((address_data->
-			       probe[i] == SENSORS_ANY_I2C_BUS) & !is_isa))
+			       probe[i] == ANY_I2C_BUS) & !is_isa))
 			    && (addr == address_data->probe[i + 1])) {
 				dev_dbg(&adapter->dev, "found probe parameter for adapter %d, addr %04x\n", adapter_id, addr);
 				found = 1;
 			}
 		}
-		for (i = 0; !found && (address_data->probe_range[i] != SENSORS_I2C_END); i += 3) {
+		for (i = 0; !found && (address_data->probe_range[i] != I2C_CLIENT_END); i += 3) {
 			if ( ((adapter_id == address_data->probe_range[i]) ||
-			      ((address_data->probe_range[i] == SENSORS_ANY_I2C_BUS) & !is_isa)) &&
+			      ((address_data->probe_range[i] == ANY_I2C_BUS) & !is_isa)) &&
 			     (addr >= address_data->probe_range[i + 1]) &&
 			     (addr <= address_data->probe_range[i + 2])) {
 				found = 1;
@@ -163,20 +163,8 @@
 	return 0;
 }
 
-static int __init i2c_sensor_init(void)
-{
-	return 0;
-}
-
-static void __exit i2c_sensor_exit(void)
-{
-}
-
 EXPORT_SYMBOL(i2c_detect);
 
 MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>");
 MODULE_DESCRIPTION("i2c-sensor driver");
 MODULE_LICENSE("GPL");
-
-module_init(i2c_sensor_init);
-module_exit(i2c_sensor_exit);
diff -Nru a/drivers/ide/Kconfig b/drivers/ide/Kconfig
--- a/drivers/ide/Kconfig	Wed Apr 30 22:28:09 2003
+++ b/drivers/ide/Kconfig	Wed Apr 30 22:28:09 2003
@@ -22,7 +22,7 @@
 	  topics, is contained in <file:Documentation/ide.txt>. For detailed
 	  information about hard drives, consult the Disk-HOWTO and the
 	  Multi-Disk-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  To fine-tune ATA/IDE drive/interface parameters for improved
 	  performance, look for the hdparm package at
@@ -1017,7 +1017,7 @@
 	  If you are unsure, then just choose the Enhanced IDE/MFM/RLL driver
 	  instead of this one. For more detailed information, read the
 	  Disk-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 config IDEDMA_AUTO
 	bool
diff -Nru a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
--- a/drivers/ide/ide-cd.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/ide/ide-cd.c	Wed Apr 30 22:28:08 2003
@@ -3366,7 +3366,8 @@
 	DRIVER(drive)->busy++;
 	g->minors = 1;
 	g->minor_shift = 0;
-	strcpy(g->devfs_name, drive->devfs_name);
+	snprintf(g->devfs_name, sizeof(g->devfs_name),
+			"%s/cd", drive->devfs_name);
 	g->driverfs_dev = &drive->gendev;
 	g->flags = GENHD_FL_CD;
 	if (ide_cdrom_setup(drive)) {
diff -Nru a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
--- a/drivers/ide/ide-disk.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/ide/ide-disk.c	Wed Apr 30 22:28:08 2003
@@ -58,7 +58,6 @@
 #include <linux/genhd.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
-#include <linux/buffer_head.h>
 
 #define _IDE_DISK
 
@@ -73,16 +72,6 @@
 
 #include "legacy/pdc4030.h"
 
-static int driver_blocked;
-
-static inline u32 idedisk_read_24 (ide_drive_t *drive)
-{
-	u8 hcyl = HWIF(drive)->INB(IDE_HCYL_REG);
-	u8 lcyl = HWIF(drive)->INB(IDE_LCYL_REG);
-	u8 sect = HWIF(drive)->INB(IDE_SECTOR_REG);
-	return (hcyl<<16)|(lcyl<<8)|sect;
-}
-
 /*
  * lba_capacity_is_ok() performs a sanity check on the claimed "lba_capacity"
  * value for this drive (from its reported identification information).
@@ -133,8 +122,24 @@
 	return 0;	/* lba_capacity value may be bad */
 }
 
+static int idedisk_start_tag(ide_drive_t *drive, struct request *rq)
+{
+	unsigned long flags;
+	int ret = 1;
+
+	spin_lock_irqsave(&ide_lock, flags);
+
+	if (ata_pending_commands(drive) < drive->queue_depth)
+		ret = blk_queue_start_tag(&drive->queue, rq);
+
+	spin_unlock_irqrestore(&ide_lock, flags);
+	return ret;
+}
+
 #ifndef CONFIG_IDE_TASKFILE_IO
 
+static int driver_blocked;
+
 /*
  * read_intr() is the handler for disk read/multread interrupts
  */
@@ -345,20 +350,6 @@
 	return DRIVER(drive)->error(drive, "multwrite_intr", stat);
 }
 
-static int idedisk_start_tag(ide_drive_t *drive, struct request *rq)
-{
-	unsigned long flags;
-	int ret = 1;
-
-	spin_lock_irqsave(&ide_lock, flags);
-
-	if (ata_pending_commands(drive) < drive->queue_depth)
-		ret = blk_queue_start_tag(&drive->queue, rq);
-
-	spin_unlock_irqrestore(&ide_lock, flags);
-	return ret;
-}
-
 /*
  * do_rw_disk() issues READ and WRITE commands to a disk,
  * using LBA if supported, or CHS otherwise, to address sectors.
@@ -745,7 +736,7 @@
 		args.tfRegister[IDE_FEATURE_OFFSET] = sectors;
 		args.tfRegister[IDE_NSECTOR_OFFSET] = rq->tag << 3;
 		args.hobRegister[IDE_FEATURE_OFFSET_HOB] = sectors >> 8;
-		args.hobRegister[IDE_NSECT_OFFSET_HOB] = 0;
+		args.hobRegister[IDE_NSECTOR_OFFSET_HOB] = 0;
 	} else {
 		args.tfRegister[IDE_NSECTOR_OFFSET] = sectors;
 		args.hobRegister[IDE_NSECTOR_OFFSET_HOB] = sectors >> 8;
@@ -813,9 +804,9 @@
 			if (drive->addressing == 1) {
 				__u64 sectors = 0;
 				u32 low = 0, high = 0;
-				low = idedisk_read_24(drive);
+				low = ide_read_24(drive);
 				hwif->OUTB(drive->ctl|0x80, IDE_CONTROL_REG);
-				high = idedisk_read_24(drive);
+				high = ide_read_24(drive);
 				sectors = ((__u64)high << 24) | low;
 				printk(", LBAsect=%llu, high=%d, low=%d",
 				       (unsigned long long) sectors,
@@ -1743,7 +1734,6 @@
 		memset(&args, 0, sizeof(ide_task_t));
 		args.tfRegister[IDE_COMMAND_OFFSET] = WIN_DOORUNLOCK;
 		args.command_type = ide_cmd_type_parser(&args);
-		invalidate_bdev(inode->i_bdev, 0);
 		if (drive->doorlocking && ide_raw_taskfile(drive, &args, NULL))
 			drive->doorlocking = 0;
 	}
diff -Nru a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
--- a/drivers/ide/ide-io.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/ide/ide-io.c	Wed Apr 30 22:28:15 2003
@@ -1112,7 +1112,7 @@
  *	on the hwgroup and the process begins again.
  */
  
-void ide_intr (int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t ide_intr (int irq, void *dev_id, struct pt_regs *regs)
 {
 	unsigned long flags;
 	ide_hwgroup_t *hwgroup = (ide_hwgroup_t *)dev_id;
@@ -1126,7 +1126,7 @@
 
 	if (!ide_ack_intr(hwif)) {
 		spin_unlock_irqrestore(&ide_lock, flags);
-		return;
+		return IRQ_NONE;
 	}
 
 	if ((handler = hwgroup->handler) == NULL ||
@@ -1165,7 +1165,7 @@
 #endif /* CONFIG_BLK_DEV_IDEPCI */
 		}
 		spin_unlock_irqrestore(&ide_lock, flags);
-		return;
+		return IRQ_HANDLED;
 	}
 	drive = hwgroup->drive;
 	if (!drive) {
@@ -1176,7 +1176,7 @@
 		 * [Note - this can occur if the drive is hot unplugged]
 		 */
 		spin_unlock_irqrestore(&ide_lock, flags);
-		return;
+		return IRQ_HANDLED;
 	}
 	if (!drive_is_ready(drive)) {
 		/*
@@ -1187,7 +1187,7 @@
 		 * enough advance overhead that the latter isn't a problem.
 		 */
 		spin_unlock_irqrestore(&ide_lock, flags);
-		return;
+		return IRQ_HANDLED;
 	}
 	if (!hwgroup->busy) {
 		hwgroup->busy = 1;	/* paranoia */
@@ -1222,6 +1222,7 @@
 		}
 	}
 	spin_unlock_irqrestore(&ide_lock, flags);
+	return IRQ_HANDLED;
 }
 
 EXPORT_SYMBOL(ide_intr);
diff -Nru a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
--- a/drivers/ide/ide-iops.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/ide/ide-iops.c	Wed Apr 30 22:28:07 2003
@@ -263,7 +263,7 @@
 
 EXPORT_SYMBOL(default_hwif_transport);
 
-u32 read_24 (ide_drive_t *drive)
+u32 ide_read_24 (ide_drive_t *drive)
 {
 	u8 hcyl = HWIF(drive)->INB(IDE_HCYL_REG);
 	u8 lcyl = HWIF(drive)->INB(IDE_LCYL_REG);
@@ -271,7 +271,7 @@
 	return (hcyl<<16)|(lcyl<<8)|sect;
 }
 
-EXPORT_SYMBOL(read_24);
+EXPORT_SYMBOL(ide_read_24);
 
 void SELECT_DRIVE (ide_drive_t *drive)
 {
diff -Nru a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
--- a/drivers/ide/ide-probe.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/ide/ide-probe.c	Wed Apr 30 22:28:10 2003
@@ -1214,7 +1214,7 @@
 	spin_unlock_irq(&ide_lock);
 out_up:
 	up(&ide_cfg_sem);
-	return 0;
+	return 1;
 }
 
 static int ata_lock(dev_t dev, void *data)
diff -Nru a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
--- a/drivers/ide/ide-tape.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/ide/ide-tape.c	Wed Apr 30 22:28:07 2003
@@ -1404,7 +1404,7 @@
  */
 static void idetape_onstream_mode_sense_tape_parameter_page(ide_drive_t *drive, int debug);
 static int idetape_chrdev_release (struct inode *inode, struct file *filp);
-static void idetape_write_release (struct inode *inode);
+static void idetape_write_release (ide_drive_t *drive, unsigned int minor);
 
 /*
  * Too bad. The drive wants to send us data which we are not ready to accept.
@@ -4292,18 +4292,6 @@
 		set_bit(IDETAPE_IGNORE_DSC, &tape->flags);
 }
 
-/*
- *	Character device interface functions
- */
-static ide_drive_t *get_drive_ptr (kdev_t i_rdev)
-{
-	unsigned int i = minor(i_rdev) & ~0xc0;
-
-	if (i >= MAX_HWIFS * MAX_DRIVES)
-		return NULL;
-	return (idetape_chrdevs[i].drive);
-}
-
 static int idetape_onstream_space_over_filemarks_backward (ide_drive_t *drive,short mt_op,int mt_count)
 {
 	idetape_tape_t *tape = drive->driver_data;
@@ -4591,7 +4579,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);
+	ide_drive_t *drive = file->private_data;
 	idetape_tape_t *tape = drive->driver_data;
 	ssize_t bytes_read,temp, actually_read = 0, rc;
 
@@ -4819,8 +4807,9 @@
 				     size_t count, loff_t *ppos)
 {
 	struct inode *inode = file->f_dentry->d_inode;
-	ide_drive_t *drive = get_drive_ptr(inode->i_rdev);
+	ide_drive_t *drive = file->private_data;
 	idetape_tape_t *tape = drive->driver_data;
+	unsigned int minor = minor(inode->i_rdev);
 	ssize_t retval, actually_written = 0;
 	int position;
 
@@ -4852,7 +4841,7 @@
 				"EOM early warning");
 #endif
 			if (tape->chrdev_direction == idetape_direction_write)
-				idetape_write_release(inode);
+				idetape_write_release(drive, minor);
 			return -ENOSPC;
 		}
 	}
@@ -5293,7 +5282,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);
+	ide_drive_t *drive = file->private_data;
 	idetape_tape_t *tape = drive->driver_data;
 	struct mtop mtop;
 	struct mtget mtget;
@@ -5465,17 +5454,18 @@
  */
 static int idetape_chrdev_open (struct inode *inode, struct file *filp)
 {
+	unsigned int minor = minor(inode->i_rdev), i = minor & ~0xc0;
 	ide_drive_t *drive;
 	idetape_tape_t *tape;
 	idetape_pc_t 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 */
 	
-	if ((drive = get_drive_ptr(inode->i_rdev)) == NULL)
+	if (i >= MAX_HWIFS * MAX_DRIVES)
 		return -ENXIO;
+	drive = idetape_chrdevs[i].drive;
 	tape = drive->driver_data;
 
 	if (test_and_set_bit(IDETAPE_BUSY, &tape->flags))
@@ -5519,11 +5509,9 @@
 	return 0;
 }
 
-static void idetape_write_release (struct inode *inode)
+static void idetape_write_release (ide_drive_t *drive, unsigned int minor)
 {
-	ide_drive_t *drive = get_drive_ptr(inode->i_rdev);
 	idetape_tape_t *tape = drive->driver_data;
-	unsigned int minor = minor(inode->i_rdev);
 
 	idetape_empty_write_pipeline(drive);
 	tape->merge_stage = __idetape_kmalloc_stage(tape, 1, 0);
@@ -5537,8 +5525,6 @@
 	idetape_flush_tape_buffers(drive);
 	idetape_write_header(drive, minor >= 128);
 	idetape_flush_tape_buffers(drive);
-
-	return;
 }
 
 /*
@@ -5546,7 +5532,7 @@
  */
 static int idetape_chrdev_release (struct inode *inode, struct file *filp)
 {
-	ide_drive_t *drive = get_drive_ptr(inode->i_rdev);
+	ide_drive_t *drive = file->private_data;
 	idetape_tape_t *tape;
 	idetape_pc_t pc;
 	unsigned int minor = minor(inode->i_rdev);
@@ -5558,9 +5544,8 @@
 		printk(KERN_INFO "ide-tape: Reached idetape_chrdev_release\n");
 #endif /* IDETAPE_DEBUG_LOG */
 
-	if (tape->chrdev_direction == idetape_direction_write) {
-		idetape_write_release(inode);
-	}
+	if (tape->chrdev_direction == idetape_direction_write)
+		idetape_write_release(drive, minor);
 	if (tape->chrdev_direction == idetape_direction_read) {
 		if (minor < 128)
 			idetape_discard_read_pipeline(drive, 1);
@@ -6270,7 +6255,6 @@
 static int idetape_attach (ide_drive_t *drive)
 {
 	idetape_tape_t *tape;
-	char devfs_name[64];
 	int minor;
 
 	if (!strstr("ide-tape", drive->driver_req))
@@ -6306,17 +6290,14 @@
 	idetape_setup(drive, tape, minor);
 	idetape_chrdevs[minor].drive = drive;
 
-	sprintf(devfs_name, "%s/mt", drive->devfs_name);
-	tape->de_r = devfs_register (NULL, devfs_name, 0,
-			HWIF(drive)->major, minor,
+	devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor)
 			S_IFCHR | S_IRUGO | S_IWUGO,
-			&idetape_fops, NULL);
-
-	sprintf(devfs_name, "%s/mtn", drive->devfs_name);
-	tape->de_n = devfs_register (NULL, devfs_name, 0,
-			HWIF(drive)->major, minor + 128,
+			&idetape_fops, NULL,
+			"%s/mt", drive->devfs_name);
+	devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor + 128),
 			S_IFCHR | S_IRUGO | S_IWUGO,
-			&idetape_fops, NULL);
+			&idetape_fops, NULL,
+			"%s/mtn", drive->devfs_name);
 
 	drive->disk->number = devfs_register_tape(drive->devfs_name);
 	drive->disk->fops = &idetape_block_ops;
diff -Nru a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
--- a/drivers/ide/ide-taskfile.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/ide/ide-taskfile.c	Wed Apr 30 22:28:03 2003
@@ -61,15 +61,6 @@
 #define task_map_rq(rq, flags)		ide_map_buffer((rq), (flags))
 #define task_unmap_rq(rq, buf, flags)	ide_unmap_buffer((rq), (buf), (flags))
 
-inline u32 task_read_24 (ide_drive_t *drive)
-{
-	return	(HWIF(drive)->INB(IDE_HCYL_REG)<<16) |
-		(HWIF(drive)->INB(IDE_LCYL_REG)<<8) |
-		 HWIF(drive)->INB(IDE_SECTOR_REG);
-}
-
-EXPORT_SYMBOL(task_read_24);
-
 static void ata_bswap_data (void *buffer, int wcount)
 {
 	u16 *p = buffer;
@@ -189,15 +180,15 @@
 		case WIN_WRITEDMA_ONCE:
 		case WIN_WRITEDMA:
 		case WIN_WRITEDMA_EXT:
-			if (hwif->ide_dma_write(drive))
-				return ide_stopped;
+			if (!hwif->ide_dma_write(drive))
+				return ide_started;
 			break;
 		case WIN_READDMA_ONCE:
 		case WIN_READDMA:
 		case WIN_READDMA_EXT:
 		case WIN_IDENTIFY_DMA:
-			if (hwif->ide_dma_read(drive))
-				return ide_stopped;
+			if (!hwif->ide_dma_read(drive))
+				return ide_started;
 			break;
 		case WIN_READDMA_QUEUED:
 		case WIN_READDMA_QUEUED_EXT:
@@ -216,88 +207,6 @@
 EXPORT_SYMBOL(do_rw_taskfile);
 
 /*
- * Error reporting, in human readable form (luxurious, but a memory hog).
- */
-u8 taskfile_dump_status (ide_drive_t *drive, const char *msg, u8 stat)
-{
-	ide_hwif_t *hwif = HWIF(drive);
-	unsigned long flags;
-	u8 err = 0;
-
-	local_irq_set(flags);
-	printk("%s: %s: status=0x%02x", drive->name, msg, stat);
-#if FANCY_STATUS_DUMPS
-	printk(" { ");
-	if (stat & BUSY_STAT) {
-		printk("Busy ");
-	} else {
-		if (stat & READY_STAT)	printk("DriveReady ");
-		if (stat & WRERR_STAT)	printk("DeviceFault ");
-		if (stat & SEEK_STAT)	printk("SeekComplete ");
-		if (stat & DRQ_STAT)	printk("DataRequest ");
-		if (stat & ECC_STAT)	printk("CorrectedError ");
-		if (stat & INDEX_STAT)	printk("Index ");
-		if (stat & ERR_STAT)	printk("Error ");
-	}
-	printk("}");
-#endif  /* FANCY_STATUS_DUMPS */
-	printk("\n");
-	if ((stat & (BUSY_STAT|ERR_STAT)) == ERR_STAT) {
-		err = hwif->INB(IDE_ERROR_REG);
-		printk("%s: %s: error=0x%02x", drive->name, msg, err);
-#if FANCY_STATUS_DUMPS
-		if (drive->media == ide_disk)
-			goto media_out;
-
-		printk(" { ");
-		if (err & ABRT_ERR)	printk("DriveStatusError ");
-		if (err & ICRC_ERR)	printk("Bad%s", (err & ABRT_ERR) ? "CRC " : "Sector ");
-		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("}");
-		if ((err & (BBD_ERR | ABRT_ERR)) == BBD_ERR ||
-		    (err & (ECC_ERR|ID_ERR|MARK_ERR))) {
-			if (drive->addressing == 1) {
-				u64 sectors = 0;
-				u32 high = 0;
-				u32 low = task_read_24(drive);
-				hwif->OUTB(0x80, IDE_CONTROL_REG);
-				high = task_read_24(drive);
-				sectors = ((u64)high << 24) | low;
-				printk(", LBAsect=%lld", (long long) sectors);
-			} else {
-				u8 cur  = hwif->INB(IDE_SELECT_REG);
-				u8 low  = hwif->INB(IDE_LCYL_REG);
-				u8 high = hwif->INB(IDE_HCYL_REG);
-				u8 sect = hwif->INB(IDE_SECTOR_REG);
-				/* using LBA? */
-				if (cur & 0x40) {
-					printk(", LBAsect=%d", (u32)
-						((cur&0xf)<<24)|(high<<16)|
-						(low<<8)|sect);
-				} else {
-					printk(", CHS=%d/%d/%d",
-						((high<<8) + low),
-						(cur & 0xf), sect);
-				}
-			}
-			if (HWGROUP(drive)->rq)
-				printk(", sector=%llu",
-					(unsigned long long)HWGROUP(drive)->rq->sector);
-		}
-media_out:
-#endif  /* FANCY_STATUS_DUMPS */
-		printk("\n");
-	}
-	local_irq_restore(flags);
-	return err;
-}
-
-EXPORT_SYMBOL(taskfile_dump_status);
-
-/*
  * Clean up after success/failure of an explicit taskfile operation.
  */
 void ide_end_taskfile (ide_drive_t *drive, u8 stat, u8 err)
@@ -356,99 +265,6 @@
 }
 
 EXPORT_SYMBOL(ide_end_taskfile);
-
-/*
- * try_to_flush_leftover_data() is invoked in response to a drive
- * unexpectedly having its DRQ_STAT bit set.  As an alternative to
- * resetting the drive, this routine tries to clear the condition
- * by read a sector's worth of data from the drive.  Of course,
- * this may not help if the drive is *waiting* for data from *us*.
- */
-void task_try_to_flush_leftover_data (ide_drive_t *drive)
-{
-	int i = (drive->mult_count ? drive->mult_count : 1) * SECTOR_WORDS;
-
-	if (drive->media != ide_disk)
-		return;
-	while (i > 0) {
-		u32 buffer[16];
-		unsigned int wcount = (i > 16) ? 16 : i;
-		i -= wcount;
-		taskfile_input_data(drive, buffer, wcount);
-	}
-}
-
-EXPORT_SYMBOL(task_try_to_flush_leftover_data);
-
-/*
- * taskfile_error() takes action based on the error returned by the drive.
- */
-ide_startstop_t taskfile_error (ide_drive_t *drive, const char *msg, u8 stat)
-{
-	ide_hwif_t *hwif;
-	struct request *rq;
-	u8 err;
-
-        err = taskfile_dump_status(drive, msg, stat);
-	if (drive == NULL || (rq = HWGROUP(drive)->rq) == NULL)
-		return ide_stopped;
-
-	hwif = HWIF(drive);
-	/* retry only "normal" I/O: */
-	if (rq->flags & REQ_DRIVE_TASKFILE) {
-		rq->errors = 1;
-		ide_end_taskfile(drive, stat, err);
-		return ide_stopped;
-	}
-	if (stat & BUSY_STAT || ((stat & WRERR_STAT) && !drive->nowerr)) {
-		/* other bits are useless when BUSY */
-		rq->errors |= ERROR_RESET;
-	} else {
-		if (drive->media != ide_disk)
-			goto media_out;
-		if (stat & ERR_STAT) {
-			/* err has different meaning on cdrom and tape */
-			if (err == ABRT_ERR) {
-				if (drive->select.b.lba &&
-				    (hwif->INB(IDE_COMMAND_REG) == WIN_SPECIFY))
-					/* some newer drives don't
-					 * support WIN_SPECIFY
-					 */
-					return ide_stopped;
-			} else if ((err & BAD_CRC) == BAD_CRC) {
-				/* UDMA crc error -- just retry the operation */
-				drive->crc_count++;
-			} else if (err & (BBD_ERR | ECC_ERR)) {
-				/* retries won't help these */
-				rq->errors = ERROR_MAX;
-			} else if (err & TRK0_ERR) {
-				/* help it find track zero */
-				rq->errors |= ERROR_RECAL;
-			}
-                }
-media_out:
-                if ((stat & DRQ_STAT) && rq_data_dir(rq) != WRITE)
-                        task_try_to_flush_leftover_data(drive);
-	}
-	if (hwif->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT)) {
-		/* force an abort */
-		hwif->OUTB(WIN_IDLEIMMEDIATE, IDE_COMMAND_REG);
-	}
-	if (rq->errors >= ERROR_MAX) {
-		DRIVER(drive)->end_request(drive, 0, 0);
-	} else {
-		if ((rq->errors & ERROR_RESET) == ERROR_RESET) {
-			++rq->errors;
-			return ide_do_reset(drive);
-		}
-		if ((rq->errors & ERROR_RECAL) == ERROR_RECAL)
-			drive->special.b.recalibrate = 1;
-		++rq->errors;
-	}
-	return ide_stopped;
-}
-
-EXPORT_SYMBOL(taskfile_error);
 
 /*
  * set_multmode_intr() is invoked on completion of a WIN_SETMULT cmd.
diff -Nru a/drivers/ide/ide.c b/drivers/ide/ide.c
--- a/drivers/ide/ide.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/ide/ide.c	Wed Apr 30 22:28:06 2003
@@ -359,13 +359,6 @@
 
 EXPORT_SYMBOL(current_capacity);
 
-static inline u32 read_24 (ide_drive_t *drive)
-{
-	return  (HWIF(drive)->INB(IDE_HCYL_REG)<<16) |
-		(HWIF(drive)->INB(IDE_LCYL_REG)<<8) |
-		 HWIF(drive)->INB(IDE_SECTOR_REG);
-}
-
 /*
  * Error reporting, in human readable form (luxurious, but a memory hog).
  */
@@ -412,9 +405,9 @@
 				    (drive->addressing == 1)) {
 					u64 sectors = 0;
 					u32 high = 0;
-					u32 low = read_24(drive);
+					u32 low = ide_read_24(drive);
 					hwif->OUTB(drive->ctl|0x80, IDE_CONTROL_REG);
-					high = read_24(drive);
+					high = ide_read_24(drive);
 
 					sectors = ((u64)high << 24) | low;
 					printk(", LBAsect=%llu, high=%d, low=%d",
diff -Nru a/drivers/ide/legacy/hd.c b/drivers/ide/legacy/hd.c
--- a/drivers/ide/legacy/hd.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/ide/legacy/hd.c	Wed Apr 30 22:28:03 2003
@@ -679,7 +679,7 @@
  * be forgotten about...
  */
 
-static void hd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t hd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	void (*handler)(void) = do_hd;
 
@@ -689,6 +689,7 @@
 		handler = unexpected_hd_interrupt;
 	handler();
 	local_irq_enable();
+	return IRQ_HANDLED;
 }
 
 static struct block_device_operations hd_fops = {
diff -Nru a/drivers/ide/legacy/hd98.c b/drivers/ide/legacy/hd98.c
--- a/drivers/ide/legacy/hd98.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/ide/legacy/hd98.c	Wed Apr 30 22:28:13 2003
@@ -46,8 +46,6 @@
 #include <asm/io.h>
 #include <asm/uaccess.h>
 
-#define MAJOR_NR HD_MAJOR
-#define DEVICE_NR(device) (minor(device)>>6)
 #include <linux/blk.h>
 
 #include "io_ports.h"
@@ -100,6 +98,9 @@
 #define ICRC_ERR		0x80	/* new meaning:  CRC error during transfer */
 
 static spinlock_t hd_lock = SPIN_LOCK_UNLOCKED;
+static struct request_queue hd_queue;
+
+#define CURRENT elv_next_request(&hd_queue)
 
 #define TIMEOUT_VALUE	(6*HZ)
 #define	HD_DELAY	0
@@ -115,26 +116,24 @@
 static void recal_intr(void);
 static void bad_rw_intr(void);
 
-static char recalibrate[MAX_HD];
-static char special_op[MAX_HD];
-
 static int reset;
 static int hd_error;
 
-#define SUBSECTOR(block) (CURRENT->current_nr_sectors > 0)
-
 /*
  *  This struct defines the HD's and their types.
  */
 struct hd_i_struct {
 	unsigned int head,sect,cyl,wpcom,lzone,ctl;
+	int unit;
+	int recalibrate;
+	int special_op;
 };
 	
 #ifdef HD_TYPE
-struct hd_i_struct hd_info[] = { HD_TYPE };
+static struct hd_i_struct hd_info[] = { HD_TYPE };
 static int NR_HD = ((sizeof (hd_info))/(sizeof (struct hd_i_struct)));
 #else
-struct hd_i_struct hd_info[MAX_HD];
+static struct hd_i_struct hd_info[MAX_HD];
 static int NR_HD;
 #endif
 
@@ -195,11 +194,11 @@
 
 static void dump_status (const char *msg, unsigned int stat)
 {
-	char devc;
-
-	devc = CURRENT ? 'a' + DEVICE_NR(CURRENT->rq_dev) : '?';
+	char *name = CURRENT ?
+			CURRENT->rq_dev->bd_disk->disk_name :
+			"hd?";
 #ifdef VERBOSE_ERRORS
-	printk("hd%c: %s: status=0x%02x { ", devc, msg, stat & 0xff);
+	printk("%s: %s: status=0x%02x { ", name, msg, stat & 0xff);
 	if (stat & BUSY_STAT)	printk("Busy ");
 	if (stat & READY_STAT)	printk("DriveReady ");
 	if (stat & WRERR_STAT)	printk("WriteFault ");
@@ -213,7 +212,7 @@
 		hd_error = 0;
 	} else {
 		hd_error = inb(HD_ERROR);
-		printk("hd%c: %s: error=0x%02x { ", devc, msg, hd_error & 0xff);
+		printk("%s: %s: error=0x%02x { ", name, msg, hd_error & 0xff);
 		if (hd_error & BBD_ERR)		printk("BadSector ");
 		if (hd_error & ECC_ERR)		printk("UncorrectableError ");
 		if (hd_error & ID_ERR)		printk("SectorIdNotFound ");
@@ -230,12 +229,12 @@
 		printk("\n");
 	}
 #else
-	printk("hd%c: %s: status=0x%02x.\n", devc, msg, stat & 0xff);
+	printk("%s: %s: status=0x%02x.\n", name, msg, stat & 0xff);
 	if ((stat & ERR_STAT) == 0) {
 		hd_error = 0;
 	} else {
 		hd_error = inb(HD_ERROR);
-		printk("hd%c: %s: error=0x%02x.\n", devc, msg, hd_error & 0xff);
+		printk("%s: %s: error=0x%02x.\n", name, msg, hd_error & 0xff);
 	}
 #endif
 }
@@ -290,9 +289,13 @@
 	return 0;
 }
 
-static void hd_out(unsigned int drive,unsigned int nsect,unsigned int sect,
-		unsigned int head,unsigned int cyl,unsigned int cmd,
-		void (*intr_addr)(void))
+static void hd_out(struct hd_i_struct *disk,
+		   unsigned int nsect,
+		   unsigned int sect,
+		   unsigned int head,
+		   unsigned int cyl,
+		   unsigned int cmd,
+		   void (*intr_addr)(void))
 {
 	unsigned short port;
 
@@ -302,19 +305,19 @@
 #endif
 	if (reset)
 		return;
-	if (!controller_ready(drive, head)) {
+	if (!controller_ready(disk->unit, head)) {
 		reset = 1;
 		return;
 	}
 	SET_HANDLER(intr_addr);
-	outb(hd_info[drive].ctl,HD_CMD);
+	outb(disk->ctl,HD_CMD);
 	port=HD_DATA + 2;
-	outb(hd_info[drive].wpcom>>2, port); port += 2;
+	outb(disk->wpcom>>2, port); port += 2;
 	outb(nsect, port); port += 2;
 	outb(sect, port); port += 2;
 	outb(cyl, port); port += 2;
 	outb(cyl>>8, port); port += 2;
-	outb(0xA0|(drive<<4)|head, port); port += 2;
+	outb(0xA0|(disk->unit<<4)|head, port); port += 2;
 	outb(cmd, port);
 }
 
@@ -363,9 +366,10 @@
 			goto repeat;
 	}
 	if (++i < NR_HD) {
-		special_op[i] = recalibrate[i] = 1;
-		hd_out(i,hd_info[i].sect,hd_info[i].sect,hd_info[i].head-1,
-			hd_info[i].cyl,WIN_SPECIFY,&reset_hd);
+		struct hd_i_struct *disk = &hd_info[i];
+		disk->special_op = disk->recalibrate = 1;
+		hd_out(disk, disk->sect, disk->sect, disk->head-1,
+			disk->cyl, WIN_SPECIFY, &reset_hd);
 		if (reset)
 			goto repeat;
 	} else
@@ -398,18 +402,19 @@
  */
 static void bad_rw_intr(void)
 {
-	int dev;
+	struct request *req = CURRENT;
+	struct hd_i_struct *disk;
 
-	if (!CURRENT)
+	if (!req)
 		return;
-	dev = DEVICE_NR(CURRENT->rq_dev);
-	if (++CURRENT->errors >= MAX_ERRORS || (hd_error & BBD_ERR)) {
-		end_request(CURRENT, 0);
-		special_op[dev] = recalibrate[dev] = 1;
-	} else if (CURRENT->errors % RESET_FREQ == 0)
+	disk = req->rq_disk->private_data;
+	if (++req->errors >= MAX_ERRORS || (hd_error & BBD_ERR)) {
+		end_request(req, 0);
+		disk->special_op = disk->recalibrate = 1;
+	} else if (req->errors % RESET_FREQ == 0)
 		reset = 1;
-	else if ((hd_error & TRK0_ERR) || CURRENT->errors % RECAL_FREQ == 0)
-		special_op[dev] = recalibrate[dev] = 1;
+	else if ((hd_error & TRK0_ERR) || req->errors % RECAL_FREQ == 0)
+		disk->special_op = disk->recalibrate = 1;
 	/* Otherwise just retry */
 }
 
@@ -427,6 +432,7 @@
 static void read_intr(void)
 {
 	int i, retries = 100000;
+	struct request *req;
 
 	do {
 		i = (unsigned) inb(HD_STATUS);
@@ -442,19 +448,20 @@
 	hd_request();
 	return;
 ok_to_read:
-	insw(HD_DATA,CURRENT->buffer,256);
-	CURRENT->sector++;
-	CURRENT->buffer += 512;
-	CURRENT->errors = 0;
-	i = --CURRENT->nr_sectors;
-	--CURRENT->current_nr_sectors;
+	req = CURRENT;
+	insw(HD_DATA,req->buffer,256);
+	req->sector++;
+	req->buffer += 512;
+	req->errors = 0;
+	i = --req->nr_sectors;
+	--req->current_nr_sectors;
 #ifdef DEBUG
-	printk("hd%c: read: sector %ld, remaining = %ld, buffer=0x%08lx\n",
-		dev+'a', CURRENT->sector, CURRENT->nr_sectors,
-		(unsigned long) CURRENT->buffer+512);
+	printk("%s: read: sector %ld, remaining = %ld, buffer=%p\n",
+		req->rq_disk->disk_name, req->sector, req->nr_sectors,
+		req->buffer+512);
 #endif
-	if (CURRENT->current_nr_sectors <= 0)
-		end_request(CURRENT, 1);
+	if (req->current_nr_sectors <= 0)
+		end_request(req, 1);
 	if (i > 0) {
 		SET_HANDLER(&read_intr);
 		return;
@@ -472,6 +479,7 @@
 {
 	int i;
 	int retries = 100000;
+	struct request *req = CURRENT;
 
 	do {
 		i = (unsigned) inb(HD_STATUS);
@@ -479,7 +487,7 @@
 			continue;
 		if (!OK_STATUS(i))
 			break;
-		if ((CURRENT->nr_sectors <= 1) || (i & DRQ_STAT))
+		if ((req->nr_sectors <= 1) || (i & DRQ_STAT))
 			goto ok_to_write;
 	} while (--retries > 0);
 	dump_status("write_intr", i);
@@ -487,15 +495,15 @@
 	hd_request();
 	return;
 ok_to_write:
-	CURRENT->sector++;
-	i = --CURRENT->nr_sectors;
-	--CURRENT->current_nr_sectors;
-	CURRENT->buffer += 512;
-	if (!i || (CURRENT->bio && !SUBSECTOR(i)))
-		end_request(CURRENT, 1);
+	req->sector++;
+	i = --req->nr_sectors;
+	--req->current_nr_sectors;
+	req->buffer += 512;
+	if (!i || (req->bio && req->current_nr_sectors < 1))
+		end_request(req, 1);
 	if (i > 0) {
 		SET_HANDLER(&write_intr);
-		outsw(HD_DATA,CURRENT->buffer,256);
+		outsw(HD_DATA,req->buffer,256);
 		local_irq_enable();
 	} else {
 #if (HD_DELAY > 0)
@@ -521,8 +529,6 @@
  */
 static void hd_times_out(unsigned long dummy)
 {
-	unsigned int dev;
-
 	do_hd = NULL;
 
 	if (!CURRENT)
@@ -531,11 +537,10 @@
 	disable_irq(HD_IRQ);
 	local_irq_enable();
 	reset = 1;
-	dev = DEVICE_NR(CURRENT->rq_dev);
-	printk("hd%c: timeout\n", dev+'a');
+	printk("%s: timeout\n", CURRENT->rq_disk->disk_name);
 	if (++CURRENT->errors >= MAX_ERRORS) {
 #ifdef DEBUG
-		printk("hd%c: too many errors\n", dev+'a');
+		printk("%s: too many errors\n", CURRENT->rq_disk->disk_name);
 #endif
 		end_request(CURRENT, 0);
 	}
@@ -544,18 +549,18 @@
 	enable_irq(HD_IRQ);
 }
 
-int do_special_op (unsigned int dev)
+int do_special_op(struct hd_i_struct *disk, struct request *req)
 {
-	if (recalibrate[dev]) {
-		recalibrate[dev] = 0;
-		hd_out(dev,hd_info[dev].sect,0,0,0,WIN_RESTORE,&recal_intr);
+	if (disk->recalibrate) {
+		disk->recalibrate = 0;
+		hd_out(disk, disk->sect,0,0,0,WIN_RESTORE,&recal_intr);
 		return reset;
 	}
-	if (hd_info[dev].head > 16) {
-		printk ("hd%c: cannot handle device with more than 16 heads - giving up\n", dev+'a');
-		end_request(CURRENT, 0);
+	if (disk->head > 16) {
+		printk ("%s: cannot handle device with more than 16 heads - giving up\n", req->rq_disk->disk_name);
+		end_request(req, 0);
 	}
-	special_op[dev] = 0;
+	disk->special_op = 0;
 	return 1;
 }
 
@@ -571,7 +576,9 @@
  */
 static void hd_request(void)
 {
-	unsigned int dev, block, nsect, sec, track, head, cyl;
+	unsigned int block, nsect, sec, track, head, cyl;
+	struct hd_i_struct *disk;
+	struct request *req;
 
 	if (do_hd)
 		return;
@@ -583,62 +590,58 @@
 		do_hd = NULL;
 		return;
 	}
+	req = CURRENT;
 
 	if (reset) {
 		local_irq_disable();
 		reset_hd();
 		return;
 	}
-	dev = DEVICE_NR(CURRENT->rq_dev);
-	block = CURRENT->sector;
-	nsect = CURRENT->nr_sectors;
-	if (dev >= NR_HD) {
-		printk("hd: bad disk number: %d\n", dev);
-		end_request(CURRENT, 0);
-		goto repeat;
-	}
-	if (block >= get_capacity(hd_gendisk[dev]) ||
-	    ((block+nsect) > get_capacity(hd_gendisk[dev]))) {
+	disk = req->rq_disk->private_data;
+	block = req->sector;
+	nsect = req->nr_sectors;
+	if (block >= get_capacity(req->rq_disk) ||
+	    ((block+nsect) > get_capacity(req->rq_disk))) {
 		printk("%s: bad access: block=%d, count=%d\n",
-			hd_gendisk[dev]->disk_name, block, nsect);
-		end_request(CURRENT, 0);
+			req->rq_disk->disk_name, block, nsect);
+		end_request(req, 0);
 		goto repeat;
 	}
 
-	if (special_op[dev]) {
-		if (do_special_op(dev))
+	if (disk->special_op) {
+		if (do_special_op(disk, req))
 			goto repeat;
 		return;
 	}
-	sec   = block % hd_info[dev].sect + 1;
-	track = block / hd_info[dev].sect;
-	head  = track % hd_info[dev].head;
-	cyl   = track / hd_info[dev].head;
+	sec   = block % disk->sect + 1;
+	track = block / disk->sect;
+	head  = track % disk->head;
+	cyl   = track / disk->head;
 #ifdef DEBUG
-	printk("hd%c: %sing: CHS=%d/%d/%d, sectors=%d, buffer=0x%08lx\n",
-		dev+'a', (CURRENT->cmd == READ)?"read":"writ",
-		cyl, head, sec, nsect, (unsigned long) CURRENT->buffer);
+	printk("%s: %sing: CHS=%d/%d/%d, sectors=%d, buffer=%p\n",
+		req->rq_disk->disk_name, (req->cmd == READ)?"read":"writ",
+		cyl, head, sec, nsect, req->buffer);
 #endif
-	if(CURRENT->flags & REQ_CMD) {
-		switch (rq_data_dir(CURRENT)) {
+	if (req->flags & REQ_CMD) {
+		switch (rq_data_dir(req)) {
 		case READ:
-			hd_out(dev,nsect,sec,head,cyl,WIN_READ,&read_intr);
+			hd_out(disk,nsect,sec,head,cyl,WIN_READ,&read_intr);
 			if (reset)
 				goto repeat;
 			break;
 		case WRITE:
-			hd_out(dev,nsect,sec,head,cyl,WIN_WRITE,&write_intr);
+			hd_out(disk,nsect,sec,head,cyl,WIN_WRITE,&write_intr);
 			if (reset)
 				goto repeat;
 			if (wait_DRQ()) {
 				bad_rw_intr();
 				goto repeat;
 			}
-			outsw(HD_DATA,CURRENT->buffer,256);
+			outsw(HD_DATA,req->buffer,256);
 			break;
 		default:
 			printk("unknown hd-command\n");
-			end_request(CURRENT, 0);
+			end_request(req, 0);
 			break;
 		}
 	}
@@ -654,37 +657,19 @@
 static int hd_ioctl(struct inode * inode, struct file * file,
 	unsigned int cmd, unsigned long arg)
 {
+	struct hd_i_struct *disk = inode->i_bdev->bd_disk->private_data;
 	struct hd_geometry *loc = (struct hd_geometry *) arg;
-	int dev;
+	struct hd_geometry g; 
 
-	if ((!inode) || kdev_none(inode->i_rdev))
+	if (cmd != HDIO_GETGEO)
 		return -EINVAL;
-	dev = DEVICE_NR(inode->i_rdev);
-	if (dev >= NR_HD)
+	if (!loc)
 		return -EINVAL;
-	switch (cmd) {
-		case HDIO_GETGEO:
-		{
-			struct hd_geometry g; 
-			if (!loc)  return -EINVAL;
-			g.heads = hd_info[dev].head;
-			g.sectors = hd_info[dev].sect;
-			g.cylinders = hd_info[dev].cyl;
-			g.start = get_start_sect(inode->i_bdev);
-			return copy_to_user(loc, &g, sizeof g) ? -EFAULT : 0; 
-		}
-
-		default:
-			return -EINVAL;
-	}
-}
-
-static int hd_open(struct inode * inode, struct file * filp)
-{
-	int target =  DEVICE_NR(inode->i_rdev);
-	if (target >= NR_HD)
-		return -ENODEV;
-	return 0;
+	g.heads = disk->head;
+	g.sectors = disk->sect;
+	g.cylinders = disk->cyl;
+	g.start = get_start_sect(inode->i_bdev);
+	return copy_to_user(loc, &g, sizeof g) ? -EFAULT : 0; 
 }
 
 /*
@@ -692,8 +677,6 @@
  * be forgotten about...
  */
 
-extern struct block_device_operations hd_fops;
-
 static void hd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	void (*handler)(void) = do_hd;
@@ -707,7 +690,6 @@
 }
 
 static struct block_device_operations hd_fops = {
-	.open =		hd_open,
 	.ioctl =	hd_ioctl,
 };
 
@@ -724,15 +706,15 @@
 static int __init hd_init(void)
 {
 	int drive;
-	if (register_blkdev(MAJOR_NR,"hd",&hd_fops)) {
-		printk("hd: unable to get major %d for hard disk\n",MAJOR_NR);
+	if (register_blkdev(HD_MAJOR,"hd")) {
+		printk("hd: unable to get major %d for hard disk\n",HD_MAJOR);
 		return -1;
 	}
-	blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_hd_request, &hd_lock);
-	blk_queue_max_sectors(BLK_DEFAULT_QUEUE(MAJOR_NR), 255);
+	blk_init_queue(&hd_queue, do_hd_request, &hd_lock);
+	blk_queue_max_sectors(&hd_queue, 255);
 	init_timer(&device_timer);
 	device_timer.function = hd_times_out;
-	blk_queue_hardsect_size(QUEUE, 512);
+	blk_queue_hardsect_size(&hd_queue, 512);
 
 #ifdef __i386__
 	if (!NR_HD) {
@@ -771,24 +753,22 @@
 		goto out;
 
 	for (drive=0 ; drive < NR_HD ; drive++) {
-		struct gendisk *disk = alloc_disk();
+		struct gendisk *disk = alloc_disk(64);
+		struct hd_i_struct *p = &hd_info[drive];
 		if (!disk)
 			goto Enomem;
-		disk->major = MAJOR_NR;
+		disk->major = HD_MAJOR;
 		disk->first_minor = drive << 6;
-		disk->minor_shift = 6;
 		disk->fops = &hd_fops;
 		sprintf(disk->disk_name, "hd%c", 'a'+drive);
+		disk->private_data = p;
+		set_capacity(disk, p->head * p->sect * p->cyl);
+		disk->queue = &hd_queue;
+		p->unit = drive;
 		hd_gendisk[drive] = disk;
-	}
-	for (drive=0 ; drive < NR_HD ; drive++) {
-		sector_t size = hd_info[drive].head *
-			hd_info[drive].sect * hd_info[drive].cyl;
-		set_capacity(hd_gendisk[drive], size);
-		printk ("%s: %ldMB, CHS=%d/%d/%d\n",
-			hd_gendisk[drive]->disk_name,
-			size / 2048, hd_info[drive].cyl,
-			hd_info[drive].head, hd_info[drive].sect);
+		printk ("%s: %luMB, CHS=%d/%d/%d\n",
+			disk->disk_name, (unsigned long)get_capacity(disk)/2048,
+			p->cyl, p->head, p->sect);
 	}
 
 	if (request_irq(HD_IRQ, hd_interrupt, SA_INTERRUPT, "hd", NULL)) {
@@ -852,11 +832,8 @@
 		goto out9;
 	}
 
-	for(drive=0; drive < NR_HD; drive++) {
-		struct hd_i_struct *p = hd_info + drive;
-		set_capacity(hd_gendisk[drive], p->head * p->sect * p->cyl);
+	for(drive=0; drive < NR_HD; drive++)
 		add_disk(hd_gendisk[drive]);
-	}
 	return 0;
 
 out9:
@@ -882,8 +859,8 @@
 	NR_HD = 0;
 out:
 	del_timer(&device_timer);
-	unregister_blkdev(MAJOR_NR,"hd");
-	blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
+	unregister_blkdev(HD_MAJOR,"hd");
+	blk_cleanup_queue(&hd_queue);
 	return -1;
 Enomem:
 	while (drive--)
diff -Nru a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
--- a/drivers/ide/legacy/ide-cs.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/ide/legacy/ide-cs.c	Wed Apr 30 22:28:12 2003
@@ -103,14 +103,6 @@
 
 static dev_link_t *dev_list = NULL;
 
-/*====================================================================*/
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
 /*======================================================================
 
     ide_attach() creates an "instance" of the driver, allocating
diff -Nru a/drivers/ide/legacy/pdc4030.c b/drivers/ide/legacy/pdc4030.c
--- a/drivers/ide/legacy/pdc4030.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/ide/legacy/pdc4030.c	Wed Apr 30 22:28:09 2003
@@ -113,7 +113,7 @@
  */
 int pdc4030_cmd(ide_drive_t *drive, u8 cmd)
 {
-	u32 timeout;
+	unsigned long timeout;
 	u8 status_val;
 
 	promise_selectproc(drive);	/* redundant? */
diff -Nru a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
--- a/drivers/ide/ppc/pmac.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/ide/ppc/pmac.c	Wed Apr 30 22:28:04 2003
@@ -702,7 +702,7 @@
 
 static int ide_majors[]  __pmacdata = { 3, 22, 33, 34, 56, 57 };
 
-kdev_t __init
+dev_t __init
 pmac_find_ide_boot(char *bootdevice, int n)
 {
 	int i;
@@ -717,7 +717,7 @@
 		name = pmac_ide[i].node->full_name;
 		if (memcmp(name, bootdevice, n) == 0 && name[n] == 0) {
 			/* XXX should cope with the 2nd drive as well... */
-			return mk_kdev(ide_majors[i], 0);
+			return MKDEV(ide_majors[i], 0);
 		}
 	}
 
diff -Nru a/drivers/ieee1394/Makefile b/drivers/ieee1394/Makefile
--- a/drivers/ieee1394/Makefile	Wed Apr 30 22:28:19 2003
+++ b/drivers/ieee1394/Makefile	Wed Apr 30 22:28:19 2003
@@ -20,4 +20,4 @@
 
 $(obj)/oui.o: $(obj)/oui.c
 $(obj)/oui.c: $(obj)/oui.db $(obj)/oui2c.sh
-	$(CONFIG_SHELL) $(obj)/oui2c.sh < $(obj)/oui.db > $(obj)/oui.c
+	$(CONFIG_SHELL) $(obj)/oui2c.sh < $(obj)/oui.db > $@
diff -Nru a/drivers/ieee1394/amdtp.c b/drivers/ieee1394/amdtp.c
--- a/drivers/ieee1394/amdtp.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/ieee1394/amdtp.c	Wed Apr 30 22:28:11 2003
@@ -268,7 +268,7 @@
 	spinlock_t stream_list_lock;
 };
 
-static struct hpsb_highlevel *amdtp_highlevel;
+static struct hpsb_highlevel amdtp_highlevel;
 
 
 /* FIXME: This doesn't belong here... */
@@ -1169,7 +1169,7 @@
 	struct amdtp_host *host;
 	int i = ieee1394_file_to_instance(file);
 
-	host = hpsb_get_hostinfo_bykey(amdtp_highlevel, i);
+	host = hpsb_get_hostinfo_bykey(&amdtp_highlevel, i);
 	if (host == NULL)
 		return -ENODEV;
 
@@ -1201,7 +1201,7 @@
 
 /* IEEE1394 Subsystem functions */
 
-static void amdtp_add_host(struct hpsb_host *host, struct hpsb_highlevel *hl)
+static void amdtp_add_host(struct hpsb_host *host)
 {
 	struct amdtp_host *ah;
 	int minor;
@@ -1210,7 +1210,7 @@
 	if (strcmp(host->driver->name, OHCI1394_DRIVER_NAME) != 0)
 		return;
 
-	ah = hpsb_create_hostinfo(hl, host, sizeof(*ah));
+	ah = hpsb_create_hostinfo(&amdtp_highlevel, host, sizeof(*ah));
 	if (!ah) {
 		HPSB_ERR("amdtp: Unable able to alloc hostinfo");
 		return;
@@ -1219,7 +1219,7 @@
 	ah->host = host;
 	ah->ohci = host->hostdata;
 
-	hpsb_set_hostinfo_key(hl, host, ah->ohci->id);
+	hpsb_set_hostinfo_key(&amdtp_highlevel, host, ah->ohci->id);
 
 	minor = IEEE1394_MINOR_BLOCK_AMDTP * 16 + ah->ohci->id;
 
@@ -1234,7 +1234,7 @@
 
 static void amdtp_remove_host(struct hpsb_host *host)
 {
-	struct amdtp_host *ah = hpsb_get_hostinfo(amdtp_highlevel, host);
+	struct amdtp_host *ah = hpsb_get_hostinfo(&amdtp_highlevel, host);
 
 	if (ah)
 		devfs_remove("amdtp/%d", ah->ohci->id);
@@ -1242,7 +1242,8 @@
 	return;
 }
 
-static struct hpsb_highlevel_ops amdtp_highlevel_ops = {
+static struct hpsb_highlevel amdtp_highlevel = {
+	.name =		"amdtp",
 	.add_host =	amdtp_add_host,
 	.remove_host =	amdtp_remove_host,
 };
@@ -1268,14 +1269,7 @@
 
 	devfs_mk_dir("amdtp");
 
-	amdtp_highlevel = hpsb_register_highlevel ("amdtp",
-						   &amdtp_highlevel_ops);
-	if (amdtp_highlevel == NULL) {
-		HPSB_ERR("amdtp: unable to register highlevel ops");
-		devfs_remove("amdtp");
-		ieee1394_unregister_chardev(IEEE1394_MINOR_BLOCK_AMDTP);
-		return -EIO;
-	}
+	hpsb_register_highlevel(&amdtp_highlevel);
 
 #ifdef CONFIG_COMPAT
 	ret = register_ioctl32_conversion(AMDTP_IOC_CHANNEL, NULL);
@@ -1304,7 +1298,7 @@
 		HPSB_ERR("amdtp: Error unregistering ioctl32 translations");
 #endif
 
-        hpsb_unregister_highlevel(amdtp_highlevel);
+        hpsb_unregister_highlevel(&amdtp_highlevel);
 	devfs_remove("amdtp");
         ieee1394_unregister_chardev(IEEE1394_MINOR_BLOCK_AMDTP);
 
diff -Nru a/drivers/ieee1394/cmp.c b/drivers/ieee1394/cmp.c
--- a/drivers/ieee1394/cmp.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/ieee1394/cmp.c	Wed Apr 30 22:28:14 2003
@@ -75,7 +75,7 @@
 #define CSR_PCR_MAP      0x900
 #define CSR_PCR_MAP_END  0x9fc
 
-static struct hpsb_highlevel *cmp_highlevel;
+static struct hpsb_highlevel cmp_highlevel;
 
 struct cmp_pcr *
 cmp_register_opcr(struct hpsb_host *host, int opcr_number, int payload,
@@ -85,7 +85,7 @@
 	struct cmp_host *ch;
 	struct plug *plug;
 
-	ch = hpsb_get_hostinfo(cmp_highlevel, host);
+	ch = hpsb_get_hostinfo(&cmp_highlevel, host);
 
 	if (opcr_number >= ch->u.ompr.nplugs ||
 	    ch->opcr[opcr_number].update != NULL)
@@ -108,7 +108,7 @@
 	struct cmp_host *ch;
 	struct plug *plug;
 
-	ch = hpsb_get_hostinfo(cmp_highlevel, host);
+	ch = hpsb_get_hostinfo(&cmp_highlevel, host);
 	plug = (struct plug *)opcr;
 	if (plug - ch->opcr >= ch->u.ompr.nplugs) BUG();
 
@@ -128,9 +128,9 @@
 	}
 }
 
-static void cmp_add_host(struct hpsb_host *host, struct hpsb_highlevel *hl)
+static void cmp_add_host(struct hpsb_host *host)
 {
-	struct cmp_host *ch = hpsb_create_hostinfo(hl, host, sizeof (*ch));
+	struct cmp_host *ch = hpsb_create_hostinfo(&cmp_highlevel, host, sizeof (*ch));
 
 	if (ch == NULL) {
 		HPSB_ERR("Failed to allocate cmp_host");
@@ -149,7 +149,7 @@
 {
 	struct cmp_host *ch;
 
-	ch = hpsb_get_hostinfo(cmp_highlevel, host);
+	ch = hpsb_get_hostinfo(&cmp_highlevel, host);
 	if (ch == NULL) {
 		HPSB_ERR("cmp: Tried to reset unknown host");
 		return;
@@ -168,7 +168,7 @@
 	if (length != 4)
 		return RCODE_TYPE_ERROR;
 
-	ch = hpsb_get_hostinfo(cmp_highlevel, host);
+	ch = hpsb_get_hostinfo(&cmp_highlevel, host);
 	if (csraddr == 0x900) {
 		*buf = cpu_to_be32(ch->u.ompr_quadlet);
 		return RCODE_COMPLETE;   
@@ -201,7 +201,7 @@
 	int plug;
 	struct cmp_host *ch;
 
-	ch = hpsb_get_hostinfo(cmp_highlevel, host);
+	ch = hpsb_get_hostinfo(&cmp_highlevel, host);
 	
 	if (extcode != EXTCODE_COMPARE_SWAP) 
 		return RCODE_TYPE_ERROR;
@@ -258,7 +258,8 @@
 }
 
 
-static struct hpsb_highlevel_ops cmp_highlevel_ops = {
+static struct hpsb_highlevel cmp_highlevel = {
+	.name =		"cmp",
 	.add_host =	cmp_add_host,
         .host_reset =	cmp_host_reset,
 };
@@ -280,14 +281,9 @@
 
 static int __init cmp_init_module (void)
 {
-	cmp_highlevel = hpsb_register_highlevel ("cmp",
-						 &cmp_highlevel_ops);
-	if (cmp_highlevel == NULL) {
-		HPSB_ERR("cmp: unable to register highlevel ops");
-		return -EIO;
-	}
+	hpsb_register_highlevel (&cmp_highlevel);
 
-	hpsb_register_addrspace(cmp_highlevel, &pcr_ops,
+	hpsb_register_addrspace(&cmp_highlevel, &pcr_ops,
 				CSR_REGISTER_BASE + CSR_PCR_MAP,
 				CSR_REGISTER_BASE + CSR_PCR_MAP_END);
 
@@ -298,7 +294,7 @@
 
 static void __exit cmp_exit_module (void)
 {
-        hpsb_unregister_highlevel(cmp_highlevel);
+        hpsb_unregister_highlevel(&cmp_highlevel);
 
 	HPSB_INFO("Unloaded CMP driver");
 }
diff -Nru a/drivers/ieee1394/csr.c b/drivers/ieee1394/csr.c
--- a/drivers/ieee1394/csr.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/ieee1394/csr.c	Wed Apr 30 22:28:05 2003
@@ -90,7 +90,7 @@
 }
 
 
-static void add_host(struct hpsb_host *host, struct hpsb_highlevel *hl)
+static void add_host(struct hpsb_host *host)
 {
         host->csr.lock = SPIN_LOCK_UNLOCKED;
 
@@ -448,7 +448,7 @@
                 /* bandwidth available algorithm adapted from IEEE 1394a-2000 spec */
                 if (arg > 0x1fff) {
                         *store = cpu_to_be32(old);	/* change nothing */
-                        break;
+			break;
                 }
                 data &= 0x1fff;
                 if (arg >= data) {
@@ -647,7 +647,8 @@
 }
 
 
-static struct hpsb_highlevel_ops csr_ops = {
+static struct hpsb_highlevel csr_highlevel = {
+	.name =		"standard registers",
 	.add_host =	add_host,
         .host_reset =	host_reset,
 };
@@ -668,35 +669,29 @@
 	.lock64 = lock64_regs,
 };
 
-static struct hpsb_highlevel *hl;
-
 void init_csr(void)
 {
-        hl = hpsb_register_highlevel("standard registers", &csr_ops);
-        if (hl == NULL) {
-                HPSB_ERR("out of memory during ieee1394 initialization");
-                return;
-        }
+	hpsb_register_highlevel(&csr_highlevel);
 
-        hpsb_register_addrspace(hl, &reg_ops, CSR_REGISTER_BASE,
+        hpsb_register_addrspace(&csr_highlevel, &reg_ops, CSR_REGISTER_BASE,
                                 CSR_REGISTER_BASE + CSR_CONFIG_ROM);
-        hpsb_register_addrspace(hl, &map_ops, 
+        hpsb_register_addrspace(&csr_highlevel, &map_ops, 
                                 CSR_REGISTER_BASE + CSR_CONFIG_ROM,
                                 CSR_REGISTER_BASE + CSR_CONFIG_ROM_END);
         if (fcp) {
-		hpsb_register_addrspace(hl, &fcp_ops,
+		hpsb_register_addrspace(&csr_highlevel, &fcp_ops,
                                 CSR_REGISTER_BASE + CSR_FCP_COMMAND,
                                 CSR_REGISTER_BASE + CSR_FCP_END);
 	}
-        hpsb_register_addrspace(hl, &map_ops,
+        hpsb_register_addrspace(&csr_highlevel, &map_ops,
                                 CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP,
                                 CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP_END);
-        hpsb_register_addrspace(hl, &map_ops,
+        hpsb_register_addrspace(&csr_highlevel, &map_ops,
                                 CSR_REGISTER_BASE + CSR_SPEED_MAP,
                                 CSR_REGISTER_BASE + CSR_SPEED_MAP_END);
 }
 
 void cleanup_csr(void)
 {
-        hpsb_unregister_highlevel(hl);
+        hpsb_unregister_highlevel(&csr_highlevel);
 }
diff -Nru a/drivers/ieee1394/dv1394-private.h b/drivers/ieee1394/dv1394-private.h
--- a/drivers/ieee1394/dv1394-private.h	Wed Apr 30 22:28:11 2003
+++ b/drivers/ieee1394/dv1394-private.h	Wed Apr 30 22:28:11 2003
@@ -455,6 +455,10 @@
 	 */
 	spinlock_t spinlock;
 
+	/* flag to prevent spurious interrupts (which OHCI seems to
+	   generate a lot :) from accessing the struct */
+	int dma_running;
+	
 	/*
 	  3) the sleeping semaphore 'sem' - this is used from process context only,
 	  to serialize various operations on the video_card. Even though only one
@@ -568,7 +572,7 @@
 
 static int do_dv1394_init(struct video_card *video, struct dv1394_init *init);
 static int do_dv1394_init_default(struct video_card *video);
-static int do_dv1394_shutdown(struct video_card *video, int free_user_buf);
+static void do_dv1394_shutdown(struct video_card *video, int free_user_buf);
 
 
 /* NTSC empty packet rate accurate to within 0.01%, 
diff -Nru a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c
--- a/drivers/ieee1394/dv1394.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/ieee1394/dv1394.c	Wed Apr 30 22:28:13 2003
@@ -108,7 +108,6 @@
 #include <asm/page.h>
 #include <linux/sched.h>
 #include <linux/types.h>
-#include <linux/wrapper.h>
 #include <linux/vmalloc.h>
 #include <linux/string.h>
 #include <linux/ioctl32.h>
@@ -176,8 +175,6 @@
 static LIST_HEAD(dv1394_cards);
 static spinlock_t dv1394_cards_lock = SPIN_LOCK_UNLOCKED;
 
-static struct hpsb_highlevel *hl_handle; /* = NULL; */
-
 /* translate from a struct file* to the corresponding struct video_card* */
 
 static inline struct video_card* file_to_video_card(struct file *file)
@@ -689,7 +686,7 @@
 		wmb();
 #endif
 
-		
+		video->dma_running = 1;
 
 		/* set the 'run' bit */
 		reg_write(video->ohci, video->ohci_IsoXmitContextControlSet, 0x8000);
@@ -811,7 +808,9 @@
 		reg_write(video->ohci, video->ohci_IsoRcvCommandPtr,             
 			  video->frames[0]->descriptor_pool_dma | 1); /* Z=1 */
 		wmb();
-		
+
+		video->dma_running = 1;
+
 		/* run */
 		reg_write(video->ohci, video->ohci_IsoRcvContextControlSet, 0x8000);
 		flush_pci_write(video->ohci);
@@ -912,16 +911,16 @@
 	u64 chan_mask;
 	int retval = -EINVAL;
 
-	debug_printk( "dv1394: initialising %d\n", video->id );
+	debug_printk("dv1394: initialising %d\n", video->id);
 	if(init->api_version != DV1394_API_VERSION)
-		goto err;
+		return -EINVAL;
 	
 	/* first sanitize all the parameters */
 	if( (init->n_frames < 2) || (init->n_frames > DV1394_MAX_FRAMES) )
-		goto err;
+		return -EINVAL;
 
 	if( (init->format != DV1394_NTSC) && (init->format != DV1394_PAL) )
-		goto err;
+		return -EINVAL;
 
 	if( (init->syt_offset == 0) || (init->syt_offset > 50) )
 		/* default SYT offset is 3 cycles */
@@ -942,15 +941,15 @@
 	if(new_buf_size % PAGE_SIZE) new_buf_size += PAGE_SIZE - (new_buf_size % PAGE_SIZE);
 
 	/* don't allow the user to allocate the DMA buffer more than once */
-	if(video->dv_buf.kvirt && video->dv_buf_size != new_buf_size)
-		goto err;
-	
+	if(video->dv_buf.kvirt && video->dv_buf_size != new_buf_size) {
+		printk("dv1394: re-sizing the DMA buffer is not allowed\n");
+		return -EINVAL;
+	}
+
 	/* shutdown the card if it's currently active */
 	/* (the card should not be reset if the parameters are screwy) */
-	if( video_card_initialized(video) )
-		do_dv1394_shutdown(video, 0);
-
 
+	do_dv1394_shutdown(video, 0);
 	
 	/* try to claim the ISO channel */
 	spin_lock_irqsave(&video->ohci->IR_channel_lock, flags);
@@ -967,7 +966,6 @@
 	/* initialize misc. fields of video */
 	video->n_frames = init->n_frames;
 	video->pal_or_ntsc = init->format;
-	
 
 	video->cip_accum = 0;
 	video->continuity_counter = 0;
@@ -983,7 +981,6 @@
 	video->current_packet = -1;
 	video->first_frame = 0;
 
-
 	if(video->pal_or_ntsc == DV1394_NTSC) {
 		video->cip_n = init->cip_n != 0 ? init->cip_n : CIP_N_NTSC;
 		video->cip_d = init->cip_d != 0 ? init->cip_d : CIP_D_NTSC;
@@ -996,14 +993,8 @@
 
 	video->syt_offset = init->syt_offset;
 	
-	
 	/* find and claim DMA contexts on the OHCI card */
 
-	/* XXX this should be the last step of initialization, since the interrupt
-	   handler uses ohci_i*_ctx to indicate whether or not it is safe to touch
-	   frames. I'm not making this change quite yet, since it would be better
-	   to clean up the init/shutdown process first.*/
-
 	if(video->ohci_it_ctx == -1) {
 		ohci1394_init_iso_tasklet(&video->it_tasklet, OHCI_ISO_TRANSMIT,
 					  it_tasklet_func, (unsigned long) video);
@@ -1011,14 +1002,12 @@
 		if (ohci1394_register_iso_tasklet(video->ohci, &video->it_tasklet) < 0) {	
 			printk(KERN_ERR "dv1394: could not find an available IT DMA context\n");
 			retval = -EBUSY;
-			goto err_ctx;
-		}
-		else {
-			video->ohci_it_ctx = video->it_tasklet.context;
-			debug_printk("dv1394: claimed IT DMA context %d\n", video->ohci_it_ctx);
+			goto err;
 		}
+		
+		video->ohci_it_ctx = video->it_tasklet.context;
+		debug_printk("dv1394: claimed IT DMA context %d\n", video->ohci_it_ctx);
 	}
-	
 
 	if(video->ohci_ir_ctx == -1) {
 		ohci1394_init_iso_tasklet(&video->ir_tasklet, OHCI_ISO_RECEIVE,
@@ -1027,14 +1016,11 @@
 		if (ohci1394_register_iso_tasklet(video->ohci, &video->ir_tasklet) < 0) {
 			printk(KERN_ERR "dv1394: could not find an available IR DMA context\n");
 			retval = -EBUSY;
-			goto err_ctx;
-		}
-		else {
-			video->ohci_ir_ctx = video->ir_tasklet.context;
-			debug_printk("dv1394: claimed IR DMA context %d\n", video->ohci_ir_ctx);
+			goto err;
 		}
+		video->ohci_ir_ctx = video->ir_tasklet.context;
+		debug_printk("dv1394: claimed IR DMA context %d\n", video->ohci_ir_ctx);
 	}
-
 	
 	/* allocate struct frames */
 	for(i = 0; i < init->n_frames; i++) {
@@ -1043,7 +1029,7 @@
 		if(!video->frames[i]) {
 			printk(KERN_ERR "dv1394: Cannot allocate frame structs\n");
 			retval = -ENOMEM;
-			goto err_frames;
+			goto err;
 		}
 	}
 
@@ -1051,7 +1037,7 @@
 		/* allocate the ringbuffer */
 		retval = dma_region_alloc(&video->dv_buf, new_buf_size, video->ohci->dev, PCI_DMA_TODEVICE);
 		if(retval)
-			goto err_frames;
+			goto err;
 					  
 		video->dv_buf_size = new_buf_size;
 
@@ -1073,7 +1059,7 @@
 		retval = dma_region_alloc(&video->packet_buf, video->packet_buf_size,
 					  video->ohci->dev, PCI_DMA_FROMDEVICE);
 		if(retval)
-			goto err_dv_buf;
+			goto err;
 		
 		debug_printk("dv1394: Allocated %d packets in buffer, total %u pages (%u DMA pages), %lu bytes\n", 
 				 video->n_frames*MAX_PACKETS, video->packet_buf.n_pages,
@@ -1103,30 +1089,8 @@
 	
 	return 0;
 
- err_dv_buf:
-	dma_region_free(&video->dv_buf);
-	
- err_frames:
-	for(i = 0; i < DV1394_MAX_FRAMES; i++) {
-		if(video->frames[i])
-			frame_delete(video->frames[i]);
-	}	
-	video->n_frames = 0;
-
- err_ctx:
-	if(video->ohci_it_ctx != -1) {
-		ohci1394_unregister_iso_tasklet(video->ohci, &video->it_tasklet);
-		video->ohci_it_ctx = -1;
-	}
-	if(video->ohci_ir_ctx != -1) {
-		ohci1394_unregister_iso_tasklet(video->ohci, &video->ir_tasklet);
-		video->ohci_ir_ctx = -1;
-	}
-	
-	spin_lock_irqsave(&video->ohci->IR_channel_lock, flags);
-	video->ohci->ISO_channel_usage &= ~chan_mask;
-	spin_unlock_irqrestore(&video->ohci->IR_channel_lock, flags);
- err:
+err:
+	do_dv1394_shutdown(video, 1);
 	return retval;
 }
 
@@ -1154,10 +1118,15 @@
 {
 	unsigned long flags;
 	int i;
-	
+
 	/* no interrupts */
 	spin_lock_irqsave(&video->spinlock, flags);
 
+	video->dma_running = 0;
+
+	if( (video->ohci_it_ctx == -1) && (video->ohci_ir_ctx == -1) )
+		goto out;
+
 	/* stop DMA if in progress */
 	if( (video->active_frame != -1) ||
 	    (reg_read(video->ohci, video->ohci_IsoXmitContextControlClear) & (1 << 10)) ||
@@ -1197,24 +1166,22 @@
 	}
 	else
 		debug_printk("dv1394: stop_dma: already stopped.\n");
-		
+
+out:
 	spin_unlock_irqrestore(&video->spinlock, flags);
 }
 
 
 
-static int do_dv1394_shutdown(struct video_card *video, int free_dv_buf)
+static void do_dv1394_shutdown(struct video_card *video, int free_dv_buf)
 {
 	int i;
-	unsigned long flags;
 	
 	debug_printk("dv1394: shutdown...\n");
 
 	/* stop DMA if in progress */
 	stop_dma(video);
 	
-	spin_lock_irqsave(&video->spinlock, flags);
-
 	/* release the DMA contexts */
 	if(video->ohci_it_ctx != -1) {
 		video->ohci_IsoXmitContextControlSet = 0;
@@ -1245,8 +1212,6 @@
 		video->ohci_ir_ctx = -1;
 	}
 
-	spin_unlock_irqrestore(&video->spinlock, flags);
-
 	/* release the ISO channel */
 	if(video->channel != -1) {
 		u64 chan_mask;
@@ -1282,9 +1247,7 @@
 	dma_region_free(&video->packet_buf);
 	video->packet_buf_size = 0;
 
-	debug_printk("dv1394: shutdown complete\n");
-
-	return 0;
+	debug_printk("dv1394: shutdown OK\n");
 }
 
 /*
@@ -1770,7 +1733,8 @@
 	}
 
 	case DV1394_IOC_SHUTDOWN:
-		ret = do_dv1394_shutdown(video, 0);
+		do_dv1394_shutdown(video, 0);
+		ret = 0;
 		break;
 
 
@@ -2140,6 +2104,9 @@
 
 	spin_lock(&video->spinlock);
 
+	if(!video->dma_running)
+		goto out;
+
 	irq_printk("ContextControl = %08x, CommandPtr = %08x\n", 
 	       reg_read(video->ohci, video->ohci_IsoXmitContextControlSet),
 	       reg_read(video->ohci, video->ohci_IsoXmitCommandPtr)
@@ -2266,14 +2233,15 @@
 		} /* for(each frame) */
 	}
 
-	spin_unlock(&video->spinlock);
-
 	if(wake) {
 		kill_fasync(&video->fasync, SIGIO, POLL_OUT);
 		
 		/* wake readers/writers/ioctl'ers */
 		wake_up_interruptible(&video->waitq);
 	}
+
+out:
+	spin_unlock(&video->spinlock);
 }
 
 static void ir_tasklet_func(unsigned long data)
@@ -2283,8 +2251,11 @@
 
 	spin_lock(&video->spinlock);
 
-	if( (video->ohci_ir_ctx != -1) 
-	    && (reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & (1 << 10)) ) 
+	if(!video->dma_running)
+		goto out;
+	
+	if( (video->ohci_ir_ctx != -1) &&
+	    (reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & (1 << 10)) )
 	{ 
 
 		int sof=0; /* start-of-frame flag */
@@ -2424,14 +2395,15 @@
 		
 	} /* receive interrupt */
 	
-	spin_unlock(&video->spinlock);
-	
 	if(wake) {
 		kill_fasync(&video->fasync, SIGIO, POLL_IN);
 
 		/* wake readers/writers/ioctl'ers */
 		wake_up_interruptible(&video->waitq);
 	}
+	
+out:
+	spin_unlock(&video->spinlock);
 }
 
 static struct file_operations dv1394_fops=
@@ -2554,6 +2526,7 @@
 
 	clear_bit(0, &video->open);
 	spin_lock_init(&video->spinlock);
+	video->dma_running = 0;
 	init_MUTEX(&video->sem);
 	init_waitqueue_head(&video->waitq);
 	video->fasync = NULL;
@@ -2565,7 +2538,7 @@
 	
 #ifdef CONFIG_DEVFS_FS
 	if (dv1394_devfs_add_entry(video) < 0)
-		goto err_free;
+			goto err_free;
 #endif
 
 	debug_printk("dv1394: dv1394_init() OK on ID %d\n", video->id);
@@ -2645,7 +2618,7 @@
 #endif	
 }
 
-static void dv1394_add_host (struct hpsb_host *host, struct hpsb_highlevel *hl)
+static void dv1394_add_host (struct hpsb_host *host)
 {
 	struct ti_ohci *ohci;
 	char buf[16];
@@ -2718,6 +2691,9 @@
 	
 	spin_lock_irqsave(&video->spinlock, flags);
 
+	if(!video->dma_running)
+		goto out;
+
 	/* check IT context */
 	if(video->ohci_it_ctx != -1) {
 		u32 ctx;
@@ -2790,14 +2766,16 @@
 				   reg_read(video->ohci, video->ohci_IsoRcvCommandPtr));
 		}
 	}
-	
+
+out:
 	spin_unlock_irqrestore(&video->spinlock, flags);
 	
 	/* wake readers/writers/ioctl'ers */
 	wake_up_interruptible(&video->waitq);
 }
 
-static struct hpsb_highlevel_ops hl_ops = {
+static struct hpsb_highlevel dv1394_highlevel = {
+	.name =		"dv1394",
 	.add_host =	dv1394_add_host,
 	.remove_host =	dv1394_remove_host,
 	.host_reset =   dv1394_host_reset,
@@ -2921,7 +2899,7 @@
 
 	hpsb_unregister_protocol(&dv1394_driver);
 
-	hpsb_unregister_highlevel (hl_handle);
+	hpsb_unregister_highlevel(&dv1394_highlevel);
 	ieee1394_unregister_chardev(IEEE1394_MINOR_BLOCK_DV1394);
 #ifdef CONFIG_DEVFS_FS
 	devfs_remove("ieee1394/dv");
@@ -2958,18 +2936,7 @@
 	}
 #endif
 
-	hl_handle = hpsb_register_highlevel ("dv1394", &hl_ops);
-	if (hl_handle == NULL) {
-		printk(KERN_ERR "dv1394: hpsb_register_highlevel failed\n");
-		ieee1394_unregister_chardev(IEEE1394_MINOR_BLOCK_DV1394);
-#ifdef CONFIG_DEVFS_FS
-		devfs_remove("ieee1394/dv");
-#endif
-#ifdef CONFIG_PROC_FS
-		dv1394_procfs_del("dv");
-#endif
-		return -ENOMEM;
-	}
+	hpsb_register_highlevel(&dv1394_highlevel);
 
 	hpsb_register_protocol(&dv1394_driver);
 
diff -Nru a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
--- a/drivers/ieee1394/eth1394.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/ieee1394/eth1394.c	Wed Apr 30 22:28:11 2003
@@ -78,14 +78,14 @@
 	printk(KERN_ERR fmt, ## args)
 
 static char version[] __devinitdata =
-	"$Rev: 886 $ Ben Collins <bcollins@debian.org>";
+	"$Rev: 906 $ Ben Collins <bcollins@debian.org>";
 
 /* Our ieee1394 highlevel driver */
 #define ETHER1394_DRIVER_NAME "ether1394"
 
 static kmem_cache_t *packet_task_cache;
-static struct hpsb_highlevel *hl_handle = NULL;
 
+static struct hpsb_highlevel eth1394_highlevel;
 
 /* Use common.lf to determine header len */
 static int hdr_type_len[] = {
@@ -318,7 +318,7 @@
  * when the module is installed. This is where we add all of our ethernet
  * devices. One for each host.
  */
-static void ether1394_add_host (struct hpsb_host *host, struct hpsb_highlevel *hl)
+static void ether1394_add_host (struct hpsb_host *host)
 {
 	struct host_info *hi = NULL;
 	struct net_device *dev = NULL;
@@ -340,8 +340,9 @@
 	priv = (struct eth1394_priv *)dev->priv;
 
 	priv->host = host;
+	spin_lock_init(&priv->lock);
 
-	hi = hpsb_create_hostinfo(hl, host, sizeof(*hi));
+	hi = hpsb_create_hostinfo(&eth1394_highlevel, host, sizeof(*hi));
 
 	if (hi == NULL)
 		goto out;
@@ -372,7 +373,7 @@
 	if (dev != NULL)
 		kfree (dev);
 	if (hi)
-		hpsb_destroy_hostinfo(hl, host);
+		hpsb_destroy_hostinfo(&eth1394_highlevel, host);
 
 	ETH1394_PRINT_G (KERN_ERR, "Out of memory\n");
 
@@ -382,7 +383,7 @@
 /* Remove a card from our list */
 static void ether1394_remove_host (struct hpsb_host *host)
 {
-	struct host_info *hi = hpsb_get_hostinfo(hl_handle, host);
+	struct host_info *hi = hpsb_get_hostinfo(&eth1394_highlevel, host);
 
 	if (hi != NULL) {
 		struct eth1394_priv *priv = (struct eth1394_priv *)hi->dev->priv;
@@ -400,7 +401,7 @@
 /* A reset has just arisen */
 static void ether1394_host_reset (struct hpsb_host *host)
 {
-	struct host_info *hi = hpsb_get_hostinfo(hl_handle, host);
+	struct host_info *hi = hpsb_get_hostinfo(&eth1394_highlevel, host);
 	struct net_device *dev;
 
 	/* This can happen for hosts that we don't use */
@@ -517,7 +518,7 @@
 	struct sk_buff *skb;
 	char *buf = (char *)data;
 	unsigned long flags;
-	struct host_info *hi = hpsb_get_hostinfo(hl_handle, host);
+	struct host_info *hi = hpsb_get_hostinfo(&eth1394_highlevel, host);
 	struct net_device *dev;
 	struct eth1394_priv *priv;
 
@@ -589,7 +590,7 @@
 	quadlet_t *data;
 	char *buf;
 	unsigned long flags;
-	struct host_info *hi = hpsb_get_hostinfo(hl_handle, iso->host);
+	struct host_info *hi = hpsb_get_hostinfo(&eth1394_highlevel, iso->host);
 	struct net_device *dev;
 	struct eth1394_priv *priv;
 	unsigned int len;
@@ -878,7 +879,8 @@
 };
 
 /* Ieee1394 highlevel driver functions */
-static struct hpsb_highlevel_ops hl_ops = {
+static struct hpsb_highlevel eth1394_highlevel = {
+	.name =		ETHER1394_DRIVER_NAME,
 	.add_host =	ether1394_add_host,
 	.remove_host =	ether1394_remove_host,
 	.host_reset =	ether1394_host_reset,
@@ -890,14 +892,9 @@
 					      0, 0, NULL, NULL);
 
 	/* Register ourselves as a highlevel driver */
-	hl_handle = hpsb_register_highlevel (ETHER1394_DRIVER_NAME, &hl_ops);
+	hpsb_register_highlevel(&eth1394_highlevel);
 
-	if (hl_handle == NULL) {
-		ETH1394_PRINT_G (KERN_ERR, "No more memory for driver\n");
-		return -ENOMEM;
-	}
-
-	hpsb_register_addrspace (hl_handle, &addr_ops, ETHER1394_REGION_ADDR,
+	hpsb_register_addrspace(&eth1394_highlevel, &addr_ops, ETHER1394_REGION_ADDR,
 				 ETHER1394_REGION_ADDR_END);
 
 	return 0;
@@ -905,7 +902,7 @@
 
 static void __exit ether1394_exit_module (void)
 {
-	hpsb_unregister_highlevel (hl_handle);
+	hpsb_unregister_highlevel(&eth1394_highlevel);
 	kmem_cache_destroy(packet_task_cache);
 }
 
diff -Nru a/drivers/ieee1394/highlevel.c b/drivers/ieee1394/highlevel.c
--- a/drivers/ieee1394/highlevel.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/ieee1394/highlevel.c	Wed Apr 30 22:28:16 2003
@@ -38,7 +38,7 @@
 
 
 static LIST_HEAD(hl_drivers);
-static DECLARE_MUTEX(hl_drivers_lock);
+static rwlock_t hl_drivers_lock = RW_LOCK_UNLOCKED;
 
 static LIST_HEAD(addr_space);
 static rwlock_t addr_space_lock = RW_LOCK_UNLOCKED;
@@ -48,20 +48,25 @@
 static struct hpsb_address_serve dummy_zero_addr, dummy_max_addr;
 
 
-/* Internal usage. Must be called with hl_drivers_lock held */
 static struct hl_host_info *hl_get_hostinfo(struct hpsb_highlevel *hl,
 					      struct hpsb_host *host)
 {
-	struct hl_host_info *hi;
+	struct hl_host_info *hi = NULL;
 	struct list_head *lh;
 
+	if (!hl || !host)
+		return NULL;
+
+	read_lock(&hl->host_info_lock);
 	list_for_each (lh, &hl->host_info_list) {
 		hi = list_entry(lh, struct hl_host_info, list);
 		if (hi->host == host)
-			return hi;
+			break;
+		hi = NULL;
 	}
+	read_unlock(&hl->host_info_lock);
 
-	return NULL;
+	return hi;
 }
 
 
@@ -69,16 +74,12 @@
  * hpsb_create_hostinfo. */
 void *hpsb_get_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host)
 {
-	struct hl_host_info *hi;
-	void *data = NULL;
+	struct hl_host_info *hi = hl_get_hostinfo(hl, host);
 
-	read_lock(&hl_drivers_lock);
-	hi = hl_get_hostinfo(hl, host);
 	if (hi)
-		data = hi->data;
-	read_unlock(&hl_drivers_lock);
+		return hi->data;
 
-	return data;
+	return NULL;
 }
 
 
@@ -88,10 +89,9 @@
 {
 	struct hl_host_info *hi;
 	void *data;
+	unsigned long flags;
 
-	read_lock(&hl_drivers_lock);
 	hi = hl_get_hostinfo(hl, host);
-	read_unlock(&hl_drivers_lock);
 	if (hi) {
 		HPSB_ERR("%s called hpsb_create_hostinfo when hostinfo already exists",
 			 hl->name);
@@ -112,9 +112,9 @@
 
 	hi->host = host;
 
-	write_lock_irq(&hl_drivers_lock);
+	write_lock_irqsave(&hl->host_info_lock, flags);
 	list_add_tail(&hi->list, &hl->host_info_list);
-	write_unlock_irq(&hl_drivers_lock);
+	write_unlock_irqrestore(&hl->host_info_lock, flags);
 
 	return data;
 }
@@ -124,23 +124,20 @@
 		      void *data)
 {
 	struct hl_host_info *hi;
-	int ret = -EINVAL;
 
-	write_lock_irq(&hl_drivers_lock);
 	hi = hl_get_hostinfo(hl, host);
 	if (hi) {
 		if (!hi->size && !hi->data) {
 			hi->data = data;
-			ret = 0;
+			return 0;
 		} else
 			HPSB_ERR("%s called hpsb_set_hostinfo when hostinfo already has data",
 				 hl->name);
 	} else
 		HPSB_ERR("%s called hpsb_set_hostinfo when no hostinfo exists",
 			 hl->name);
-	write_unlock_irq(&hl_drivers_lock);
 
-	return ret;
+	return -EINVAL;
 }
 
 
@@ -148,13 +145,14 @@
 {
 	struct hl_host_info *hi;
 
-	write_lock_irq(&hl_drivers_lock);
 	hi = hl_get_hostinfo(hl, host);
 	if (hi) {
+		unsigned long flags;
+		write_lock_irqsave(&hl->host_info_lock, flags);
 		list_del(&hi->list);
+		write_unlock_irqrestore(&hl->host_info_lock, flags);
 		kfree(hi);
 	}
-	write_unlock_irq(&hl_drivers_lock);
 
 	return;
 }
@@ -164,11 +162,9 @@
 {
 	struct hl_host_info *hi;
 
-	write_lock(&hl_drivers_lock);
 	hi = hl_get_hostinfo(hl, host);
 	if (hi)
 		hi->key = key;
-	write_unlock(&hl_drivers_lock);
 
 	return;
 }
@@ -177,15 +173,12 @@
 unsigned long hpsb_get_hostinfo_key(struct hpsb_highlevel *hl, struct hpsb_host *host)
 {
 	struct hl_host_info *hi;
-	unsigned long key = 0;
 
-	read_lock(&hl_drivers_lock);
 	hi = hl_get_hostinfo(hl, host);
 	if (hi)
-		key = hi->key;
-	read_unlock(&hl_drivers_lock);
+		return hi->key;
 
-	return key;
+	return 0;
 }
 
 
@@ -195,7 +188,10 @@
 	struct hl_host_info *hi;
 	void *data = NULL;
 
-	read_lock(&hl_drivers_lock);
+	if (!hl)
+		return NULL;
+
+	read_lock(&hl->host_info_lock);
 	list_for_each (lh, &hl->host_info_list) {
 		hi = list_entry(lh, struct hl_host_info, list);
 		if (hi->key == key) {
@@ -203,80 +199,89 @@
 			break;
 		}
 	}
-	read_unlock(&hl_drivers_lock);
+	read_unlock(&hl->host_info_lock);
 
 	return data;
 }
 
 
-struct hpsb_highlevel *hpsb_register_highlevel(const char *name,
-                                               struct hpsb_highlevel_ops *ops)
+struct hpsb_host *hpsb_get_host_bykey(struct hpsb_highlevel *hl, unsigned long key)
 {
-        struct hpsb_highlevel *hl;
 	struct list_head *lh;
+	struct hl_host_info *hi;
+	struct hpsb_host *host = NULL;
+
+	if (!hl)
+		return NULL;
+
+	read_lock(&hl->host_info_lock);
+	list_for_each (lh, &hl->host_info_list) {
+		hi = list_entry(lh, struct hl_host_info, list);
+		if (hi->key == key) {
+			host = hi->host;
+			break;
+		}
+	}
+	read_unlock(&hl->host_info_lock);
+
+	return host;
+}
 
-        hl = (struct hpsb_highlevel *)kmalloc(sizeof(struct hpsb_highlevel),
-                                              GFP_KERNEL);
-        if (hl == NULL) {
-                return NULL;
-        }
 
-        INIT_LIST_HEAD(&hl->hl_list);
+void hpsb_register_highlevel(struct hpsb_highlevel *hl)
+{
+	struct list_head *lh;
+	unsigned long flags;
+
         INIT_LIST_HEAD(&hl->addr_list);
 	INIT_LIST_HEAD(&hl->host_info_list);
 
-        hl->name = name;
-        hl->op = ops;
+	rwlock_init(&hl->host_info_lock);
 
-	down(&hl_drivers_lock);
+	write_lock_irqsave(&hl_drivers_lock, flags);
         list_add_tail(&hl->hl_list, &hl_drivers);
-	up(&hl_drivers_lock);
+	write_unlock_irqrestore(&hl_drivers_lock, flags);
 
-	if (hl->op->add_host) {
+	if (hl->add_host) {
 		down(&hpsb_hosts_lock);
 		list_for_each (lh, &hpsb_hosts) {
 			struct hpsb_host *host = list_entry(lh, struct hpsb_host, host_list);
-			hl->op->add_host(host, hl);
+			hl->add_host(host);
 		}
 		up(&hpsb_hosts_lock);
 	}
 
-        return hl;
+        return;
 }
 
 void hpsb_unregister_highlevel(struct hpsb_highlevel *hl)
 {
         struct list_head *lh, *next;
         struct hpsb_address_serve *as;
+	unsigned long flags;
 
-        if (hl == NULL) {
-                return;
-        }
-
-        write_lock_irq(&addr_space_lock);
+	write_lock_irqsave(&addr_space_lock, flags);
 	list_for_each_safe (lh, next, &hl->addr_list) {
                 as = list_entry(lh, struct hpsb_address_serve, addr_list);
                 list_del(&as->as_list);
                 kfree(as);
         }
-        write_unlock_irq(&addr_space_lock);
+	write_unlock_irqrestore(&addr_space_lock, flags);
 
-	down(&hl_drivers_lock);
+	write_lock_irqsave(&hl_drivers_lock, flags);
         list_del(&hl->hl_list);
-	up(&hl_drivers_lock);
+	write_unlock_irqrestore(&hl_drivers_lock, flags);
 
-        if (hl->op->remove_host) {
+        if (hl->remove_host) {
 		down(&hpsb_hosts_lock);
 		list_for_each(lh, &hpsb_hosts) {
 			struct hpsb_host *host = list_entry(lh, struct hpsb_host, host_list);
 
-			hl->op->remove_host(host);
+			hl->remove_host(host);
 			hpsb_destroy_hostinfo(hl, host);
 		}
 		up(&hpsb_hosts_lock);
 	}
-
-        kfree(hl);
 }
 
 int hpsb_register_addrspace(struct hpsb_highlevel *hl,
@@ -307,8 +312,10 @@
         write_lock_irqsave(&addr_space_lock, flags);
         entry = addr_space.next;
 
-        while (list_entry(entry, struct hpsb_address_serve, as_list)->end <= start) {
-                if (list_entry(entry->next, struct hpsb_address_serve, as_list)->start >= end) {
+        while (list_entry(entry, struct hpsb_address_serve, as_list)->end
+               <= start) {
+                if (list_entry(entry->next, struct hpsb_address_serve, as_list)
+                    ->start >= end) {
                         list_add(&as->as_list, entry);
                         list_add_tail(&as->addr_list, &hl->addr_list);
                         retval = 1;
@@ -387,14 +394,13 @@
         struct list_head *entry;
         struct hpsb_highlevel *hl;
 
-	down(&hl_drivers_lock);
+        read_lock(&hl_drivers_lock);
         list_for_each(entry, &hl_drivers) {
                 hl = list_entry(entry, struct hpsb_highlevel, hl_list);
-
-		if (hl->op->add_host)
-			hl->op->add_host(host, hl);
+		if (hl->add_host)
+			hl->add_host(host);
         }
-        up(&hl_drivers_lock);
+        read_unlock(&hl_drivers_lock);
 }
 
 void highlevel_remove_host(struct hpsb_host *host)
@@ -402,16 +408,16 @@
         struct list_head *entry;
         struct hpsb_highlevel *hl;
 
-        down(&hl_drivers_lock);
+	read_lock(&hl_drivers_lock);
 	list_for_each(entry, &hl_drivers) {
                 hl = list_entry(entry, struct hpsb_highlevel, hl_list);
 
-		if (hl->op->remove_host) {
-			hl->op->remove_host(host);
+		if (hl->remove_host) {
+			hl->remove_host(host);
 			hpsb_destroy_hostinfo(hl, host);
 		}
         }
-        up(&hl_drivers_lock);
+	read_unlock(&hl_drivers_lock);
 }
 
 void highlevel_host_reset(struct hpsb_host *host)
@@ -419,14 +425,14 @@
         struct list_head *entry;
         struct hpsb_highlevel *hl;
 
-	down(&hl_drivers_lock);
+	read_lock(&hl_drivers_lock);
 	list_for_each(entry, &hl_drivers) {
                 hl = list_entry(entry, struct hpsb_highlevel, hl_list);
 
-                if (hl->op->host_reset)
-                        hl->op->host_reset(host);
+                if (hl->host_reset)
+                        hl->host_reset(host);
         }
-	up(&hl_drivers_lock);
+	read_unlock(&hl_drivers_lock);
 }
 
 void highlevel_iso_receive(struct hpsb_host *host, void *data,
@@ -436,14 +442,17 @@
         struct hpsb_highlevel *hl;
         int channel = (((quadlet_t *)data)[0] >> 8) & 0x3f;
 
-        down(&hl_drivers_lock);
-	list_for_each(entry, &hl_drivers) {
-                hl = list_entry(entry, struct hpsb_highlevel, hl_list);
+        read_lock(&hl_drivers_lock);
+        entry = hl_drivers.next;
 
-                if (hl->op->iso_receive)
-                        hl->op->iso_receive(host, channel, data, length);
+        while (entry != &hl_drivers) {
+                hl = list_entry(entry, struct hpsb_highlevel, hl_list);
+                if (hl->iso_receive) {
+                        hl->iso_receive(host, channel, data, length);
+                }
+                entry = entry->next;
         }
-        up(&hl_drivers_lock);
+        read_unlock(&hl_drivers_lock);
 }
 
 void highlevel_fcp_request(struct hpsb_host *host, int nodeid, int direction,
@@ -453,13 +462,18 @@
         struct hpsb_highlevel *hl;
         int cts = ((quadlet_t *)data)[0] >> 4;
 
-        down(&hl_drivers_lock);
-	list_for_each(entry, &hl_drivers) {
+        read_lock(&hl_drivers_lock);
+        entry = hl_drivers.next;
+
+        while (entry != &hl_drivers) {
                 hl = list_entry(entry, struct hpsb_highlevel, hl_list);
-                if (hl->op->fcp_request)
-                        hl->op->fcp_request(host, nodeid, direction, cts, data, length);
+                if (hl->fcp_request) {
+                        hl->fcp_request(host, nodeid, direction, cts, data,
+                                            length);
+                }
+                entry = entry->next;
         }
-        up(&hl_drivers_lock);
+        read_unlock(&hl_drivers_lock);
 }
 
 int highlevel_read(struct hpsb_host *host, int nodeid, void *data,
diff -Nru a/drivers/ieee1394/highlevel.h b/drivers/ieee1394/highlevel.h
--- a/drivers/ieee1394/highlevel.h	Wed Apr 30 22:28:07 2003
+++ b/drivers/ieee1394/highlevel.h	Wed Apr 30 22:28:07 2003
@@ -3,20 +3,6 @@
 #define IEEE1394_HIGHLEVEL_H
 
 
-struct hpsb_highlevel {
-        struct list_head hl_list;
-
-        /* List of hpsb_address_serve. */
-        struct list_head addr_list;
-
-        const char *name;
-        struct hpsb_highlevel_ops *op;
-
-	/* Used by the highlevel drivers to store data per host */
-	struct list_head host_info_list;
-};
-
-
 struct hpsb_address_serve {
         struct list_head as_list; /* global list */
         
@@ -34,14 +20,16 @@
  * following structures are of interest to actual highlevel drivers.  
  */
 
-struct hpsb_highlevel_ops {
+struct hpsb_highlevel {
+	const char *name;
+
         /* Any of the following pointers can legally be NULL, except for
          * iso_receive which can only be NULL when you don't request
          * channels. */
 
         /* New host initialized.  Will also be called during
          * hpsb_register_highlevel for all hosts already installed. */
-        void (*add_host) (struct hpsb_host *host, struct hpsb_highlevel *hl);
+        void (*add_host) (struct hpsb_host *host);
 
         /* Host about to be removed.  Will also be called during
          * hpsb_unregister_highlevel once for each host. */
@@ -65,6 +53,13 @@
          */
         void (*fcp_request) (struct hpsb_host *host, int nodeid, int direction,
                              int cts, u8 *data, unsigned int length);
+
+
+	struct list_head hl_list;
+	struct list_head addr_list;
+
+	struct list_head host_info_list;
+	rwlock_t host_info_lock;
 };
 
 struct hpsb_address_ops {
@@ -130,8 +125,7 @@
  * Register highlevel driver.  The name pointer has to stay valid at all times
  * because the string is not copied.
  */
-struct hpsb_highlevel *hpsb_register_highlevel(const char *name,
-                                               struct hpsb_highlevel_ops *ops);
+void hpsb_register_highlevel(struct hpsb_highlevel *hl);
 void hpsb_unregister_highlevel(struct hpsb_highlevel *hl);
 
 /*
@@ -154,27 +148,35 @@
  * iso_receive op.
  */
 int hpsb_listen_channel(struct hpsb_highlevel *hl, struct hpsb_host *host, 
-			unsigned int channel);
+                         unsigned int channel);
 void hpsb_unlisten_channel(struct hpsb_highlevel *hl, struct hpsb_host *host,
                            unsigned int channel);
 
 
 /* Retrieve a hostinfo pointer bound to this driver/host */
 void *hpsb_get_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host);
+
 /* Allocate a hostinfo pointer of data_size bound to this driver/host */
 void *hpsb_create_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
 			   size_t data_size);
+
 /* Free and remove the hostinfo pointer bound to this driver/host */
 void hpsb_destroy_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host);
+
 /* Set an alternate lookup key for the hostinfo bound to this driver/host */
 void hpsb_set_hostinfo_key(struct hpsb_highlevel *hl, struct hpsb_host *host, unsigned long key);
+
 /* Retrieve the alternate lookup key for the hostinfo bound to this driver/host */
 unsigned long hpsb_get_hostinfo_key(struct hpsb_highlevel *hl, struct hpsb_host *host);
-/* Retrive a hostinfo pointer bound to this driver using its alternate key */
+
+/* Retrieve a hostinfo pointer bound to this driver using its alternate key */
 void *hpsb_get_hostinfo_bykey(struct hpsb_highlevel *hl, unsigned long key);
+
 /* Set the hostinfo pointer to something useful. Usually follows a call to
  * hpsb_create_hostinfo, where the size is 0. */
 int hpsb_set_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host, void *data);
 
+/* Retrieve hpsb_host using a highlevel handle and a key */
+struct hpsb_host *hpsb_get_host_bykey(struct hpsb_highlevel *hl, unsigned long key);
 
 #endif /* IEEE1394_HIGHLEVEL_H */
diff -Nru a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c
--- a/drivers/ieee1394/hosts.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/ieee1394/hosts.c	Wed Apr 30 22:28:08 2003
@@ -148,9 +148,36 @@
 	return h;
 }
 
+static int alloc_hostnum(void)
+{
+	int hostnum = 0;
+
+	while (1) {
+		struct list_head *lh;
+		int found = 0;
+
+		list_for_each(lh, &hpsb_hosts) {
+			struct hpsb_host *host = list_entry(lh, struct hpsb_host, host_list);
+
+			if (host->id == hostnum) {
+				found = 1;
+				break;
+			}
+		}
+
+		if (!found)
+			return hostnum;
+
+		hostnum++;
+	}
+
+	return 0;
+}
+
 void hpsb_add_host(struct hpsb_host *host)
 {
 	down(&hpsb_hosts_lock);
+	host->id = alloc_hostnum();
         list_add_tail(&host->host_list, &hpsb_hosts);
 	up(&hpsb_hosts_lock);
 
diff -Nru a/drivers/ieee1394/hosts.h b/drivers/ieee1394/hosts.h
--- a/drivers/ieee1394/hosts.h	Wed Apr 30 22:28:05 2003
+++ b/drivers/ieee1394/hosts.h	Wed Apr 30 22:28:05 2003
@@ -66,6 +66,8 @@
 
 	struct pci_dev *pdev;
 
+	int id;
+
 	struct device device;
 };
 
diff -Nru a/drivers/ieee1394/ieee1394.h b/drivers/ieee1394/ieee1394.h
--- a/drivers/ieee1394/ieee1394.h	Wed Apr 30 22:28:06 2003
+++ b/drivers/ieee1394/ieee1394.h	Wed Apr 30 22:28:06 2003
@@ -52,10 +52,13 @@
 #define SPEED_800		0x03
 #define SPEED_1600		0x04
 #define SPEED_3200		0x05
-
+/* The current highest tested speed supported by the subsystem */
+#define SPEED_MAX		SPEED_800
 
 /* Maps speed values above to a string representation */
 extern const char *hpsb_speedto_str[];
+extern const u8 hpsb_speedto_maxrec[];
+
 
 #define SELFID_PWRCL_NO_POWER    0x0
 #define SELFID_PWRCL_PROVIDE_15W 0x1
diff -Nru a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
--- a/drivers/ieee1394/ieee1394_core.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/ieee1394/ieee1394_core.c	Wed Apr 30 22:28:06 2003
@@ -60,6 +60,7 @@
 
 /* Some globals used */
 const char *hpsb_speedto_str[] = { "S100", "S200", "S400", "S800", "S1600", "S3200" };
+const u8 hpsb_speedto_maxrec[] = {   0x7,    0x8,    0x9,   0x10,    0x11,    0x12 };
 
 static void dump_packet(const char *text, quadlet_t *data, int size)
 {
@@ -285,7 +286,7 @@
 
         for (i = 0; i < (nodecount * 64); i += 64) {
                 for (j = 0; j < nodecount; j++) {
-                        map[i+j] = SPEED_400;
+                        map[i+j] = SPEED_MAX;
                 }
         }
 
@@ -1239,6 +1240,7 @@
 
 /** ieee1394_core.c **/
 EXPORT_SYMBOL(hpsb_speedto_str);
+EXPORT_SYMBOL(hpsb_speedto_maxrec);
 EXPORT_SYMBOL(hpsb_set_packet_complete_task);
 EXPORT_SYMBOL(alloc_hpsb_packet);
 EXPORT_SYMBOL(free_hpsb_packet);
@@ -1278,6 +1280,7 @@
 EXPORT_SYMBOL(hpsb_listen_channel);
 EXPORT_SYMBOL(hpsb_unlisten_channel);
 EXPORT_SYMBOL(hpsb_get_hostinfo);
+EXPORT_SYMBOL(hpsb_get_host_bykey);
 EXPORT_SYMBOL(hpsb_create_hostinfo);
 EXPORT_SYMBOL(hpsb_destroy_hostinfo);
 EXPORT_SYMBOL(hpsb_set_hostinfo_key);
@@ -1295,7 +1298,6 @@
 /** nodemgr.c **/
 EXPORT_SYMBOL(hpsb_guid_get_entry);
 EXPORT_SYMBOL(hpsb_nodeid_get_entry);
-EXPORT_SYMBOL(hpsb_check_nodeid);
 EXPORT_SYMBOL(hpsb_node_fill_packet);
 EXPORT_SYMBOL(hpsb_node_read);
 EXPORT_SYMBOL(hpsb_node_write);
diff -Nru a/drivers/ieee1394/ieee1394_types.h b/drivers/ieee1394/ieee1394_types.h
--- a/drivers/ieee1394/ieee1394_types.h	Wed Apr 30 22:28:13 2003
+++ b/drivers/ieee1394/ieee1394_types.h	Wed Apr 30 22:28:13 2003
@@ -79,13 +79,13 @@
 	struct semaphore count;
 };
 
-#define HPSB_TPOOL_INIT(_tp)            	\
-do {                                    	\
+#define HPSB_TPOOL_INIT(_tp)			\
+do {						\
 	CLEAR_BITMAP((_tp)->pool, 64);		\
-	spin_lock_init(&(_tp)->lock);   	\
-	(_tp)->next = 0;                	\
+	spin_lock_init(&(_tp)->lock);		\
+	(_tp)->next = 0;			\
 	(_tp)->allocations = 0;			\
-	sema_init(&(_tp)->count, 63);   	\
+	sema_init(&(_tp)->count, 63);		\
 } while(0)
 
 
diff -Nru a/drivers/ieee1394/iso.c b/drivers/ieee1394/iso.c
--- a/drivers/ieee1394/iso.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/ieee1394/iso.c	Wed Apr 30 22:28:15 2003
@@ -47,8 +47,11 @@
 	int dma_direction;
 
 	/* make sure driver supports the ISO API */
-	if(!host->driver->isoctl)
+	if(!host->driver->isoctl) {
+		printk(KERN_INFO "ieee1394: host driver '%s' does not support the rawiso API\n",
+		       host->driver->name);
 		return NULL;
+	}
 
 	/* sanitize parameters */
 
diff -Nru a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
--- a/drivers/ieee1394/nodemgr.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/ieee1394/nodemgr.c	Wed Apr 30 22:28:11 2003
@@ -19,7 +19,6 @@
 #include <linux/delay.h>
 #include <linux/pci.h>
 #include <asm/atomic.h>
-#include <asm/byteorder.h>
 
 #include "ieee1394_types.h"
 #include "ieee1394.h"
@@ -48,6 +47,7 @@
 	return NULL;
 }
 
+
 /* 
  * Basically what we do here is start off retrieving the bus_info block.
  * From there will fill in some info about the node, verify it is of IEEE
@@ -70,7 +70,6 @@
 
 static DECLARE_MUTEX(nodemgr_serialize);
 
-static struct hpsb_highlevel *nodemgr_hl;
 
 struct host_info {
 	struct hpsb_host *host;
@@ -78,10 +77,24 @@
 	struct completion exited;
 	struct semaphore reset_sem;
 	int pid;
-	int id;
 	char daemon_name[15];
 };
 
+static struct hpsb_highlevel nodemgr_highlevel;
+
+static int nodemgr_driverdata_ne;
+static int nodemgr_driverdata_host;
+
+static struct device_driver nodemgr_driver_ne = {
+	.name	= "ieee1394_node",
+	.bus	= &ieee1394_bus_type,
+};
+
+static struct device_driver nodemgr_driver_host = {
+	.name	= "ieee1394_host",
+	.bus	= &ieee1394_bus_type,
+};
+
 
 #define fw_attr(class, class_type, field, type, format_string)		\
 static ssize_t fw_show_##class##_##field (struct device *dev, char *buf)\
@@ -364,7 +377,9 @@
         struct unit_directory *ud;
 	struct ieee1394_device_id *id;
 
-	if (dev->class_num != DEV_CLASS_UNIT_DIRECTORY)
+	if (dev->driver_data == &nodemgr_driverdata_ne ||
+	    dev->driver_data == &nodemgr_driverdata_host ||
+	    drv == &nodemgr_driver_ne || drv == &nodemgr_driver_host)
 		return 0;
 
 	ud = container_of(dev, struct unit_directory, device);
@@ -448,7 +463,7 @@
 
 		snprintf(ud->device.name, DEVICE_NAME_SIZE,
 			 "IEEE-1394 unit directory %d-" NODE_BUS_FMT "-%u",
-			 hi->id, NODE_BUS_ARGS(ne->nodeid), ud->id);
+			 hi->host->id, NODE_BUS_ARGS(ne->nodeid), ud->id);
 	}
 }
 
@@ -494,18 +509,21 @@
 static struct device nodemgr_dev_template_ud = {
 	.bus		= &ieee1394_bus_type,
 	.release	= nodemgr_release_ud,
-	.class_num	= DEV_CLASS_UNIT_DIRECTORY,
 };
 
+
 static struct device nodemgr_dev_template_ne = {
 	.bus		= &ieee1394_bus_type,
 	.release	= nodemgr_release_ne,
-	.class_num	= DEV_CLASS_NODE,
+	.driver		= &nodemgr_driver_ne,
+	.driver_data	= &nodemgr_driverdata_ne,
 };
 
+
 static struct device nodemgr_dev_template_host = {
 	.bus		= &ieee1394_bus_type,
-	.class_num	= DEV_CLASS_HOST,
+	.driver		= &nodemgr_driver_host,
+	.driver_data	= &nodemgr_driverdata_host,
 };
 
 
@@ -594,7 +612,6 @@
 	ret = -ENXIO;
 	for (; size > 0; size--, address += 4, quadp++) {
 		for (i = 0; i < 3; i++) {
-			
 			ret = hpsb_node_read(ne, address, quadp, 4);
 			if (ret != -EAGAIN)
 				break;
@@ -638,7 +655,6 @@
 		code = CONFIG_ROM_KEY(quad);
 
 		if (code == CONFIG_ROM_VENDOR_ID && length > 0) {
-
 			/* Check if there is a text descriptor leaf
 			   immediately after this.  */
 			size = nodemgr_size_text_leaf(host, nodeid, generation,
@@ -698,7 +714,7 @@
 	snprintf(ne->device.bus_id, BUS_ID_SIZE, "%016Lx",
 		 (unsigned long long)(ne->guid));
 	snprintf(ne->device.name, DEVICE_NAME_SIZE,
-		 "IEEE-1394 device %d-" NODE_BUS_FMT, hi->id,
+		 "IEEE-1394 device %d-" NODE_BUS_FMT, host->id,
 		 NODE_BUS_ARGS(ne->nodeid));
 
 	device_register(&ne->device);
@@ -713,7 +729,7 @@
 
 	HPSB_DEBUG("%s added: ID:BUS[%d-" NODE_BUS_FMT "]  GUID[%016Lx]",
 		   (host->node_id == nodeid) ? "Host" : "Node",
-		   hi->id, NODE_BUS_ARGS(nodeid), (unsigned long long)guid);
+		   host->id, NODE_BUS_ARGS(nodeid), (unsigned long long)guid);
 
         return ne;
 }
@@ -729,7 +745,7 @@
         struct guid_search_baton *search = __data;
         struct node_entry *ne;
 
-        if (dev->class_num != DEV_CLASS_NODE)
+        if (dev->driver_data != &nodemgr_driverdata_ne)
                 return 0;
 
         ne = container_of(dev, struct node_entry, device);
@@ -766,7 +782,7 @@
 	struct nodeid_search_baton *search = __data;
 	struct node_entry *ne;
 
-	if (dev->class_num != DEV_CLASS_NODE)
+	if (dev->driver_data != &nodemgr_driverdata_ne)
 		return 0;
 
 	ne = container_of(dev, struct node_entry, device);
@@ -847,7 +863,7 @@
 			   store?  Only count immediate values and
 			   CSR offsets for now.  */
 			code &= CONFIG_ROM_KEY_TYPE_MASK;
-			if ((code & 0x80) == 0)
+			if ((code & CONFIG_ROM_KEY_TYPE_LEAF) == 0)
 				count++;
 			break;
 		}
@@ -894,20 +910,21 @@
 /* This implementation currently only scans the config rom and its
  * immediate unit directories looking for software_id and
  * software_version entries, in order to get driver autoloading working. */
-static void nodemgr_process_unit_directory(struct host_info *hi, struct node_entry *ne, 
-					   octlet_t address, unsigned int id)
+static struct unit_directory *nodemgr_process_unit_directory
+	(struct host_info *hi, struct node_entry *ne, octlet_t address, unsigned int *id)
 {
 	struct unit_directory *ud;
 	quadlet_t quad;
 	quadlet_t *infop;
 	int length;
+	struct unit_directory *ud_temp = NULL;
 
 	if (!(ud = nodemgr_scan_unit_directory(ne, address)))
 		goto unit_directory_error;
 
 	ud->ne = ne;
 	ud->address = address;
-	ud->id = id;
+	ud->id = (*id)++;
 
 	if (nodemgr_read_quadlet(ne->host, ne->nodeid, ne->generation,
 				 address, &quad))
@@ -983,12 +1000,48 @@
 			/* TODO: read strings... icons? */
 			break;
 
+		case CONFIG_ROM_LOGICAL_UNIT_DIRECTORY:
+			/* TODO: Parent this with it's UD */
+			ud_temp = nodemgr_process_unit_directory(hi, ne, address + value * 4, id);
+
+			/* inherit unspecified values */
+			if (ud_temp != NULL)
+			{
+				if ((ud->flags & UNIT_DIRECTORY_VENDOR_ID) &&
+					!(ud_temp->flags & UNIT_DIRECTORY_VENDOR_ID))
+				{
+					ud_temp->flags |=  UNIT_DIRECTORY_VENDOR_ID;
+					ud_temp->vendor_id = ud->vendor_id;
+					ud_temp->vendor_oui = ud->vendor_oui;
+				}
+				if ((ud->flags & UNIT_DIRECTORY_MODEL_ID) &&
+					!(ud_temp->flags & UNIT_DIRECTORY_MODEL_ID))
+				{
+					ud_temp->flags |=  UNIT_DIRECTORY_MODEL_ID;
+					ud_temp->model_id = ud->model_id;
+				}
+				if ((ud->flags & UNIT_DIRECTORY_SPECIFIER_ID) &&
+					!(ud_temp->flags & UNIT_DIRECTORY_SPECIFIER_ID))
+				{
+					ud_temp->flags |=  UNIT_DIRECTORY_SPECIFIER_ID;
+					ud_temp->specifier_id = ud->specifier_id;
+				}
+				if ((ud->flags & UNIT_DIRECTORY_VERSION) &&
+					!(ud_temp->flags & UNIT_DIRECTORY_VERSION))
+				{
+					ud_temp->flags |=  UNIT_DIRECTORY_VERSION;
+					ud_temp->version = ud->version;
+				}
+			}
+
+			break;
+
 		default:
 			/* Which types of quadlets do we want to
 			   store?  Only count immediate values and
 			   CSR offsets for now.  */
 			code &= CONFIG_ROM_KEY_TYPE_MASK;
-			if ((code & 0x80) == 0)
+			if ((code & CONFIG_ROM_KEY_TYPE_LEAF) == 0)
 				*infop++ = quad;
 			break;
 		}
@@ -1006,11 +1059,12 @@
 		device_create_file(&ud->device, &dev_attr_ud_vendor_oui);
 	nodemgr_create_ud_dev_files(ud);
 
-	return;
+	return ud;
 
 unit_directory_error:	
 	if (ud != NULL)
 		kfree(ud);
+	return NULL;
 }
 
 
@@ -1071,7 +1125,7 @@
 			break;
 
 		case CONFIG_ROM_UNIT_DIRECTORY:
-			nodemgr_process_unit_directory(hi, ne, address + value * 4, ud_id++);
+			nodemgr_process_unit_directory(hi, ne, address + value * 4, &ud_id);
 			break;			
 
 		case CONFIG_ROM_DESCRIPTOR_LEAF:
@@ -1095,7 +1149,9 @@
 	if (!dev)
 		return -ENODEV;
 
-	if (dev->class_num != DEV_CLASS_UNIT_DIRECTORY)
+	/* Have to check driver_data, since on remove, driver == NULL */
+	if (dev->driver_data == &nodemgr_driverdata_ne ||
+	    dev->driver_data == &nodemgr_driverdata_host)
 		return -ENODEV;
 
 	ud = container_of(dev, struct unit_directory, device);
@@ -1137,17 +1193,6 @@
 #endif /* CONFIG_HOTPLUG */
 
 
-static int nodemgr_alloc_host_num(void)
-{
-	int hostnum;
-
-	for (hostnum = 0; hpsb_get_hostinfo_bykey(nodemgr_hl, hostnum); hostnum++)
-		/* Do nothing */;
-
-	return hostnum;
-}
-
-
 int hpsb_register_protocol(struct hpsb_protocol_driver *driver)
 {
 	driver_register(&driver->driver);
@@ -1156,6 +1201,18 @@
 	/*
 	 * Right now registration always succeeds, but maybe we should
 	 * detect clashes in protocols handled by other drivers.
+     * DRD> No because multiple drivers are needed to handle certain devices.
+     * For example, a DV camera is an IEC 61883 device (dv1394) and AV/C (raw1394).
+     * This will become less an issue with libiec61883 using raw1394.
+     *
+     * BenC: But can we handle this with an ALLOW_SHARED flag for a
+     * protocol? When we get an SBP-3 driver, it will be nice if they were
+     * mutually exclusive, since SBP-3 can handle SBP-2 protocol.
+     *
+     * Not to mention that we currently do not seem to support multiple
+     * drivers claiming the same unitdirectory. If we implement both of
+     * those, then we'll need to keep probing when a driver claims a
+     * unitdirectory, but is sharable.
 	 */
 
 	return 0;
@@ -1207,7 +1264,8 @@
 	struct node_entry *ne = __data;
 	struct unit_directory *ud;
 
-	if (dev->class_num != DEV_CLASS_UNIT_DIRECTORY)
+	if (dev->driver_data == &nodemgr_driverdata_ne ||
+	    dev->driver_data == &nodemgr_driverdata_host)
 		return 0;
 
 	ud = container_of(dev, struct unit_directory, device);
@@ -1244,7 +1302,7 @@
 	if (ne->nodeid != nodeid) {
 		snprintf(ne->device.name, DEVICE_NAME_SIZE,
 			 "IEEE-1394 device %d-" NODE_BUS_FMT,
-			 hi->id, NODE_BUS_ARGS(ne->nodeid));
+			 hi->host->id, NODE_BUS_ARGS(ne->nodeid));
 		HPSB_DEBUG("Node " NODE_BUS_FMT " changed to " NODE_BUS_FMT,
 			   NODE_BUS_ARGS(ne->nodeid), NODE_BUS_ARGS(nodeid));
 		ne->nodeid = nodeid;
@@ -1395,7 +1453,7 @@
 	struct cleanup_baton *cleanup = __data;
 	struct node_entry *ne;
 
-	if (dev->class_num != DEV_CLASS_NODE)
+	if (dev->driver_data != &nodemgr_driverdata_ne)
 		return 0;
 
 	ne = container_of(dev, struct node_entry, device);
@@ -1434,9 +1492,9 @@
 	/* If we had a bus reset while we were scanning the bus, it is
 	 * possible that we did not probe all nodes.  In that case, we
 	 * skip the clean up for now, since we could remove nodes that
-	 * were still on the bus.  The bus reset increased
-	 * hi->reset_sem, so there's a bus scan pending which will do
-	 * the clean up eventually. */
+	 * were still on the bus.  The bus reset increased hi->reset_sem,
+	 * so there's a bus scan pending which will do the clean up
+	 * eventually. */
 	if (generation == get_hpsb_generation(host)) {
 		struct cleanup_baton cleanup;
 
@@ -1470,7 +1528,7 @@
 
 /* Because we are a 1394a-2000 compliant IRM, we need to inform all the other
  * nodes of the broadcast channel.  (Really we're only setting the validity
- * bit).  Other IRM responsibilities go in here as well. */
+ * bit). Other IRM responsibilities go in here as well. */
 static void nodemgr_do_irm_duties(struct hpsb_host *host)
 {
 	quadlet_t bc;
@@ -1489,17 +1547,17 @@
 	/* If there is no bus manager then we should set the root node's
 	 * force_root bit to promote bus stability per the 1394
 	 * spec. (8.4.2.6) */
-	if(host->busmgr_id == 0x3f && host->node_count > 1)
-        {
+	if (host->busmgr_id == 0x3f && host->node_count > 1)
+	{
 		u16 root_node = host->node_count - 1;
 		struct node_entry *ne = hpsb_nodeid_get_entry(host, root_node);
-		
-		if(ne->busopt.cmc)
+
+		if (ne->busopt.cmc)
 			hpsb_send_phy_config(host, root_node, -1);
 		else {
 			HPSB_DEBUG("The root node is not cycle master capable; "
 				   "selecting a new root node and resetting...");
-			hpsb_send_phy_config(host, host->node_id, -1);
+			hpsb_send_phy_config(host, NODEID_TO_NODE(host->node_id), -1);
 			hpsb_reset_bus(host, LONG_RESET_FORCE_ROOT);
 		}
 	}
@@ -1508,7 +1566,7 @@
 /* We need to ensure that if we are not the IRM, that the IRM node is capable of
  * everything we can do, otherwise issue a bus reset and try to become the IRM
  * ourselves. */
-static int nodemgr_check_irm_capability(struct hpsb_host *host)
+static int nodemgr_check_irm_capability(struct hpsb_host *host, int cycles)
 {
 	quadlet_t bc;
 	int status;
@@ -1525,10 +1583,19 @@
 		/* The current irm node does not have a valid BROADCAST_CHANNEL
 		 * register and we do, so reset the bus with force_root set */
 		HPSB_DEBUG("Current remote IRM is not 1394a-2000 compliant, resetting...");
-		hpsb_send_phy_config(host, host->node_id, -1);
+
+		if (cycles >= 5) {
+			/* Oh screw it! Just leave the bus as it is */
+			HPSB_DEBUG("Stopping reset loop for IRM sanity");
+			return 1;
+		}
+
+		hpsb_send_phy_config(host, NODEID_TO_NODE(host->node_id), -1);
 		hpsb_reset_bus(host, LONG_RESET_FORCE_ROOT);
+
 		return 0;
 	}
+
 	return 1;
 }
 
@@ -1536,6 +1603,7 @@
 {
 	struct host_info *hi = (struct host_info *)__hi;
 	struct hpsb_host *host = hi->host;
+	int reset_cycles = 0;
 
 	/* No userlevel access needed */
 	daemonize(hi->daemon_name);
@@ -1571,12 +1639,14 @@
 				i = HZ/4;
 		}
 
-		if (!nodemgr_check_irm_capability(host)) {
+		if (!nodemgr_check_irm_capability(host, reset_cycles++)) {
 			/* Do nothing, we are resetting */
 			up(&nodemgr_serialize);
 			continue;
 		}
 
+		reset_cycles = 0;
+
 		nodemgr_node_probe(hi, generation);
 		nodemgr_do_irm_duties(host);
 
@@ -1588,7 +1658,7 @@
 
 caught_signal:
 #ifdef CONFIG_IEEE1394_VERBOSEDEBUG
-	HPSB_DEBUG ("NodeMgr: Exiting thread for %s", hi->host->driver->name);
+	HPSB_DEBUG ("NodeMgr: Exiting thread");
 #endif
 
 	complete_and_exit(&hi->exited, 0);
@@ -1616,18 +1686,6 @@
 	return ne;
 }
 
-struct node_entry *hpsb_check_nodeid(struct hpsb_host *host, nodeid_t nodeid)
-{
-	struct node_entry *ne;
-
-	if (down_trylock(&nodemgr_serialize))
-		return NULL;
-	ne = find_entry_by_nodeid(host, nodeid);
-	up(&nodemgr_serialize);
-
-	return ne;
-}
-
 /* The following four convenience functions use a struct node_entry
  * for addressing a node on the bus.  They are intended for use by any
  * process context, not just the nodemgr thread, so we need to be a
@@ -1681,36 +1739,29 @@
 			 addr, extcode, data, arg);
 }
 
-static void nodemgr_add_host(struct hpsb_host *host, struct hpsb_highlevel *hl)
+static void nodemgr_add_host(struct hpsb_host *host)
 {
 	struct host_info *hi;
 
-	hi = hpsb_create_hostinfo(hl, host, sizeof(*hi));
+	hi = hpsb_create_hostinfo(&nodemgr_highlevel, host, sizeof(*hi));
 
 	if (!hi) {
 		HPSB_ERR ("NodeMgr: out of memory in add host");
 		return;
 	}
 
-	/* Initialize the hostinfo here and start the thread.  The
-	 * thread blocks on the reset semaphore until a bus reset
-	 * happens. */
 	hi->host = host;
 	init_completion(&hi->exited);
         sema_init(&hi->reset_sem, 0);
 
-	hi->id = nodemgr_alloc_host_num();
-
-	hpsb_set_hostinfo_key(hl, host, hi->id);
-
 	memcpy(&host->device, &nodemgr_dev_template_host,
 	       sizeof(host->device));
 	host->device.parent = &host->pdev->dev;
-	snprintf(host->device.bus_id, BUS_ID_SIZE, "fw-host%d", hi->id);
+	snprintf(host->device.bus_id, BUS_ID_SIZE, "fw-host%d", host->id);
 	snprintf(host->device.name, DEVICE_NAME_SIZE, "IEEE-1394 Host %s-%d",
-		 host->driver->name, hi->id);
+		 host->driver->name, host->id);
 
-	sprintf(hi->daemon_name, "knodemgrd_%d", hi->id);
+	sprintf(hi->daemon_name, "knodemgrd_%d", host->id);
 
 	hi->pid = kernel_thread(nodemgr_host_thread, hi,
 				CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
@@ -1718,7 +1769,7 @@
 	if (hi->pid < 0) {
 		HPSB_ERR ("NodeMgr: failed to start %s thread for %s",
 			  hi->daemon_name, host->driver->name);
-		hpsb_destroy_hostinfo(hl, host);
+		hpsb_destroy_hostinfo(&nodemgr_highlevel, host);
 		return;
 	}
 
@@ -1727,7 +1778,7 @@
 
 static void nodemgr_host_reset(struct hpsb_host *host)
 {
-	struct host_info *hi = hpsb_get_hostinfo(nodemgr_hl, host);
+	struct host_info *hi = hpsb_get_hostinfo(&nodemgr_highlevel, host);
 
 	if (hi != NULL) {
 #ifdef CONFIG_IEEE1394_VERBOSEDEBUG
@@ -1742,7 +1793,7 @@
 
 static void nodemgr_remove_host(struct hpsb_host *host)
 {
-	struct host_info *hi = hpsb_get_hostinfo(nodemgr_hl, host);
+	struct host_info *hi = hpsb_get_hostinfo(&nodemgr_highlevel, host);
 
 	if (hi) {
 		if (hi->pid >= 0) {
@@ -1758,7 +1809,8 @@
 	return;
 }
 
-static struct hpsb_highlevel_ops nodemgr_ops = {
+static struct hpsb_highlevel nodemgr_highlevel = {
+	.name =		"Node manager",
 	.add_host =	nodemgr_add_host,
 	.host_reset =	nodemgr_host_reset,
 	.remove_host =	nodemgr_remove_host,
@@ -1767,16 +1819,17 @@
 void init_ieee1394_nodemgr(void)
 {
 	bus_register(&ieee1394_bus_type);
+	driver_register(&nodemgr_driver_host);
+	driver_register(&nodemgr_driver_ne);
 
-        nodemgr_hl = hpsb_register_highlevel("Node manager", &nodemgr_ops);
-        if (!nodemgr_hl) {
-		HPSB_ERR("NodeMgr: out of memory during ieee1394 initialization");
-        }
+	hpsb_register_highlevel(&nodemgr_highlevel);
 }
 
 void cleanup_ieee1394_nodemgr(void)
 {
-        hpsb_unregister_highlevel(nodemgr_hl);
+        hpsb_unregister_highlevel(&nodemgr_highlevel);
 
+	driver_unregister(&nodemgr_driver_ne);
+	driver_unregister(&nodemgr_driver_host);
 	bus_unregister(&ieee1394_bus_type);
 }
diff -Nru a/drivers/ieee1394/nodemgr.h b/drivers/ieee1394/nodemgr.h
--- a/drivers/ieee1394/nodemgr.h	Wed Apr 30 22:28:10 2003
+++ b/drivers/ieee1394/nodemgr.h	Wed Apr 30 22:28:10 2003
@@ -55,6 +55,7 @@
 #define CONFIG_ROM_MODEL_ID			0x17
 #define CONFIG_ROM_NODE_CAPABILITES		0x0C
 #define CONFIG_ROM_UNIT_DIRECTORY		0xd1
+#define CONFIG_ROM_LOGICAL_UNIT_DIRECTORY	0xd4
 #define CONFIG_ROM_SPECIFIER_ID			0x12 
 #define CONFIG_ROM_UNIT_SW_VERSION		0x13
 #define CONFIG_ROM_DESCRIPTOR_LEAF		0x81
@@ -78,11 +79,6 @@
 	u16	max_rec;	/* Maximum packet size node can receive */
 };
 
-enum {
-	DEV_CLASS_NODE,
-	DEV_CLASS_UNIT_DIRECTORY,
-	DEV_CLASS_HOST,
-};
 
 #define UNIT_DIRECTORY_VENDOR_ID	0x01
 #define UNIT_DIRECTORY_MODEL_ID		0x02
@@ -137,8 +133,7 @@
 	const char *vendor_name;
 	const char *vendor_oui;
 
-	u32 capabilities;	
-
+	u32 capabilities;
 	struct hpsb_tlabel_pool *tpool;
 
 	struct device device;
@@ -162,10 +157,6 @@
 /* Same as above, but use the nodeid to get an node entry. This is not
  * fool-proof by itself, since the nodeid can change.  */
 struct node_entry *hpsb_nodeid_get_entry(struct hpsb_host *host, nodeid_t nodeid);
-
-/* Same as above except that it will not block waiting for the nodemgr
- * serialize semaphore.  */
-struct node_entry *hpsb_check_nodeid(struct hpsb_host *host, nodeid_t nodeid);
 
 /*
  * If the entry refers to a local host, this function will return the pointer
diff -Nru a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
--- a/drivers/ieee1394/ohci1394.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/ieee1394/ohci1394.c	Wed Apr 30 22:28:16 2003
@@ -108,7 +108,6 @@
 #include <asm/page.h>
 #include <linux/sched.h>
 #include <linux/types.h>
-#include <linux/wrapper.h>
 #include <linux/vmalloc.h>
 #include <linux/init.h>
 
@@ -165,7 +164,7 @@
 printk(level "%s_%d: " fmt "\n" , OHCI1394_DRIVER_NAME, card , ## args)
 
 static char version[] __devinitdata =
-	"$Rev: 866 $ Ben Collins <bcollins@debian.org>";
+	"$Rev: 908 $ Ben Collins <bcollins@debian.org>";
 
 /* Module Parameters */
 static int phys_dma = 1;
@@ -2214,7 +2213,7 @@
 
 }
 
-static void ohci_irq_handler(int irq, void *dev_id,
+static irqreturn_t ohci_irq_handler(int irq, void *dev_id,
                              struct pt_regs *regs_are_unused)
 {
 	quadlet_t event, node_id;
@@ -2231,7 +2230,8 @@
 	reg_write(ohci, OHCI1394_IntEventClear, event & ~OHCI1394_busReset);
 	spin_unlock_irqrestore(&ohci->event_lock, flags);
 
-	if (!event) return;
+	if (!event)
+		return IRQ_NONE;
 
 	DBGMSG(ohci->id, "IntEvent: %08x", event);
 
@@ -2462,7 +2462,7 @@
 		PRINT(KERN_ERR, ohci->id, "Unhandled interrupt(s) 0x%08x",
 		      event);
 
-	return;
+	return IRQ_HANDLED;
 }
 
 /* Put the buffer back into the dma context */
diff -Nru a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c
--- a/drivers/ieee1394/pcilynx.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/ieee1394/pcilynx.c	Wed Apr 30 22:28:07 2003
@@ -1163,7 +1163,7 @@
  ********************************************************/
 
 
-static void lynx_irq_handler(int irq, void *dev_id,
+static irqreturn_t lynx_irq_handler(int irq, void *dev_id,
                              struct pt_regs *regs_are_unused)
 {
         struct ti_lynx *lynx = (struct ti_lynx *)dev_id;
@@ -1174,7 +1174,8 @@
         linkint = reg_read(lynx, LINK_INT_STATUS);
         intmask = reg_read(lynx, PCI_INT_STATUS);
 
-        if (!(intmask & PCI_INT_INT_PEND)) return;
+        if (!(intmask & PCI_INT_INT_PEND))
+		return IRQ_NONE;
 
         PRINTD(KERN_DEBUG, lynx->id, "interrupt: 0x%08x / 0x%08x", intmask,
                linkint);
@@ -1390,6 +1391,8 @@
 
                 run_pcl(lynx, lynx->rcv_pcl_start, CHANNEL_ASYNC_RCV);
         }
+
+	return IRQ_HANDLED;
 }
 
 
@@ -1893,7 +1896,7 @@
         .name =     PCILYNX_DRIVER_NAME,
         .id_table = pci_table,
         .probe =    add_card,
-        .remove =   __devexit_p(remove_card),
+        .remove =   remove_card,
 };
 
 static struct hpsb_host_driver lynx_driver = {
diff -Nru a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
--- a/drivers/ieee1394/raw1394.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/ieee1394/raw1394.c	Wed Apr 30 22:28:03 2003
@@ -77,11 +77,11 @@
 static spinlock_t host_info_lock = SPIN_LOCK_UNLOCKED;
 static atomic_t internal_generation = ATOMIC_INIT(0);
 
-static struct hpsb_highlevel *hl_handle;
-
 static atomic_t iso_buffer_size;
 static const int iso_buffer_max = 4 * 1024 * 1024; /* 4 MB */
 
+static struct hpsb_highlevel raw1394_highlevel;
+
 static int arm_read (struct hpsb_host *host, int nodeid, quadlet_t *buffer,
              u64 addr, unsigned int length, u16 flags);
 static int arm_write (struct hpsb_host *host, int nodeid, int destid,
@@ -188,7 +188,7 @@
 }
 
 
-static void add_host(struct hpsb_host *host, struct hpsb_highlevel *hl)
+static void add_host(struct hpsb_host *host)
 {
         struct host_info *hi;
         unsigned long flags;
@@ -601,7 +601,7 @@
                 if (fi->listen_channels & (1ULL << channel)) {
                         req->req.error = RAW1394_ERROR_ALREADY;
                 } else {
-                        if(hpsb_listen_channel(hl_handle, fi->host, channel)) {
+                        if(hpsb_listen_channel(&raw1394_highlevel, fi->host, channel)) {
 				req->req.error = RAW1394_ERROR_ALREADY;
 			} else {
 				fi->listen_channels |= 1ULL << channel;
@@ -614,7 +614,7 @@
                 channel = ~channel;
 
                 if (fi->listen_channels & (1ULL << channel)) {
-                        hpsb_unlisten_channel(hl_handle, fi->host, channel);
+                        hpsb_unlisten_channel(&raw1394_highlevel, fi->host, channel);
                         fi->listen_channels &= ~(1ULL << channel);
                 } else {
                         req->req.error = RAW1394_ERROR_INVALID_ARG;
@@ -1679,7 +1679,7 @@
                 spin_unlock_irqrestore(&host_info_lock, flags);
                 return sizeof(struct raw1394_request);
         }
-        retval = hpsb_register_addrspace(hl_handle, &arm_ops, req->req.address,
+        retval = hpsb_register_addrspace(&raw1394_highlevel, &arm_ops, req->req.address,
                 req->req.address + req->req.length);
         if (retval) {
                /* INSERT ENTRY */
@@ -1766,7 +1766,7 @@
                 spin_unlock_irqrestore(&host_info_lock, flags);
                 return sizeof(struct raw1394_request);
         } 
-        retval = hpsb_unregister_addrspace(hl_handle, addr->start);
+        retval = hpsb_unregister_addrspace(&raw1394_highlevel, addr->start);
         if (!retval) {
                 printk(KERN_ERR "raw1394: arm_Unregister failed -> EINVAL\n");
                 spin_unlock_irqrestore(&host_info_lock, flags);
@@ -2379,7 +2379,7 @@
 
         for (i = 0; i < 64; i++) {
                 if (fi->listen_channels & (1ULL << i)) {
-                        hpsb_unlisten_channel(hl_handle, fi->host, i);
+                        hpsb_unlisten_channel(&raw1394_highlevel, fi->host, i);
                 }
         }
 
@@ -2424,7 +2424,7 @@
                 }
                 if (!another_host) {
                         DBGMSG("raw1394_release: call hpsb_arm_unregister");
-                        retval = hpsb_unregister_addrspace(hl_handle, addr->start);
+                        retval = hpsb_unregister_addrspace(&raw1394_highlevel, addr->start);
                         if (!retval) {
                                 ++fail;
                                 printk(KERN_ERR "raw1394_release arm_Unregister failed\n");
@@ -2507,7 +2507,8 @@
 /******************************************************************************/
 
 
-static struct hpsb_highlevel_ops hl_ops = {
+static struct hpsb_highlevel raw1394_highlevel = {
+	.name =		RAW1394_DEVICE_NAME,
         .add_host =    add_host,
         .remove_host = remove_host,
         .host_reset =  host_reset,
@@ -2528,11 +2529,7 @@
 
 static int __init init_raw1394(void)
 {
-        hl_handle = hpsb_register_highlevel(RAW1394_DEVICE_NAME, &hl_ops);
-        if (hl_handle == NULL) {
-                HPSB_ERR("raw1394 failed to register with ieee1394 highlevel");
-                return -ENOMEM;
-        }
+	hpsb_register_highlevel(&raw1394_highlevel);
 
         devfs_register(NULL, RAW1394_DEVICE_NAME, 0,
 			IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16,
@@ -2542,7 +2539,7 @@
                                       THIS_MODULE, &file_ops)) {
                 HPSB_ERR("raw1394 failed to register minor device block");
                 devfs_remove(RAW1394_DEVICE_NAME);
-                hpsb_unregister_highlevel(hl_handle);
+                hpsb_unregister_highlevel(&raw1394_highlevel);
                 return -EBUSY;
         }
 
@@ -2558,7 +2555,7 @@
 	hpsb_unregister_protocol(&raw1394_driver);
         ieee1394_unregister_chardev(IEEE1394_MINOR_BLOCK_RAW1394);
         devfs_remove(RAW1394_DEVICE_NAME);
-        hpsb_unregister_highlevel(hl_handle);
+        hpsb_unregister_highlevel(&raw1394_highlevel);
 }
 
 module_init(init_raw1394);
diff -Nru a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
--- a/drivers/ieee1394/sbp2.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/ieee1394/sbp2.c	Wed Apr 30 22:28:04 2003
@@ -298,7 +298,7 @@
 #include "sbp2.h"
 
 static char version[] __devinitdata =
-	"$Rev: 884 $ James Goodwin <jamesg@filanet.com>";
+	"$Rev: 912 $ James Goodwin <jamesg@filanet.com>";
 
 /*
  * Module load parameter definitions
@@ -311,15 +311,10 @@
  * NOTE: On certain OHCI parts I have seen short packets on async transmit
  * (probably due to PCI latency/throughput issues with the part). You can
  * bump down the speed if you are running into problems.
- *
- * Valid values:
- * max_speed = 2 (default: max speed 400mb)
- * max_speed = 1 (max speed 200mb)
- * max_speed = 0 (max speed 100mb)
  */
-static int max_speed = SPEED_400;
+static int max_speed = SPEED_MAX;
 module_param(max_speed, int, 0644);
-MODULE_PARM_DESC(max_speed, "Force max speed (2 = 400mb default, 1 = 200mb, 0 = 100mb)");
+MODULE_PARM_DESC(max_speed, "Force max speed (3 = 800mb, 2 = 400mb default, 1 = 200mb, 0 = 100mb)");
 
 /*
  * Set serialize_io to 1 if you'd like only one scsi command sent
@@ -454,11 +449,8 @@
 	
 static Scsi_Host_Template scsi_driver_template;
 
-static u8 sbp2_speedto_maxrec[] = { 0x7, 0x8, 0x9 };
-
-static struct hpsb_highlevel *sbp2_hl_handle = NULL;
-
-static struct hpsb_highlevel_ops sbp2_hl_ops = {
+static struct hpsb_highlevel sbp2_highlevel = {
+	.name =		SBP2_DEVICE_NAME,
 	.remove_host =	sbp2_remove_host,
 };
 
@@ -774,21 +766,22 @@
 /* Free our DMA's */
 static void sbp2util_free_command_dma(struct sbp2_command_info *command)
 {
-	struct sbp2scsi_host_info *hi;
+	struct hpsb_host *host;
 
-	hi = hpsb_get_hostinfo_bykey(sbp2_hl_handle, (unsigned long)command->Current_SCpnt->device->host);
-	if (!hi) {
-		printk(KERN_ERR "%s: hi == NULL\n", __FUNCTION__);
+	host = hpsb_get_host_bykey(&sbp2_highlevel,
+			(unsigned long)command->Current_SCpnt->device->host);
+	if (!host) {
+		printk(KERN_ERR "%s: host == NULL\n", __FUNCTION__);
 		return;
 	}
 
 	if (command->cmd_dma) {
 		if (command->dma_type == CMD_DMA_SINGLE) {
-			pci_unmap_single(hi->host->pdev, command->cmd_dma,
+			pci_unmap_single(host->pdev, command->cmd_dma,
 					 command->dma_size, command->dma_dir);
 			SBP2_DMA_FREE("single bulk");
 		} else if (command->dma_type == CMD_DMA_PAGE) {
-			pci_unmap_page(hi->host->pdev, command->cmd_dma,
+			pci_unmap_page(host->pdev, command->cmd_dma,
 				       command->dma_size, command->dma_dir);
 			SBP2_DMA_FREE("single page");
 		} /* XXX: Check for CMD_DMA_NONE bug */
@@ -797,7 +790,7 @@
 	}
 
 	if (command->sge_buffer) {
-		pci_unmap_sg(hi->host->pdev, command->sge_buffer,
+		pci_unmap_sg(host->pdev, command->sge_buffer,
 			     command->dma_size, command->dma_dir);
 		SBP2_DMA_FREE("scatter list");
 		command->sge_buffer = NULL;
@@ -910,7 +903,7 @@
 
 	SBP2_DEBUG("sbp2_add_host");
 
-	hi = hpsb_get_hostinfo(sbp2_hl_handle, host);
+	hi = hpsb_get_hostinfo(&sbp2_highlevel, host);
 	if (hi)
 		return hi;
 
@@ -921,13 +914,13 @@
 		return NULL;
 	}
 
-	hi = hpsb_create_hostinfo(sbp2_hl_handle, host, sizeof(*hi));
+	hi = hpsb_create_hostinfo(&sbp2_highlevel, host, sizeof(*hi));
 	if (!hi) {
 		SBP2_ERR("failed to allocate hostinfo");
 		scsi_unregister(hi->scsi_host);
 	}
 
-	hpsb_set_hostinfo_key(sbp2_hl_handle, host, (unsigned long)scsi_host);
+	hpsb_set_hostinfo_key(&sbp2_highlevel, host, (unsigned long)scsi_host);
 
 	hi->scsi_host = scsi_host;
 	hi->host = host;
@@ -941,7 +934,7 @@
 	if (scsi_add_host(hi->scsi_host, NULL)) {
 		SBP2_ERR("failed to add scsi host");
 		scsi_unregister(hi->scsi_host);
-		hpsb_destroy_hostinfo(sbp2_hl_handle, host);
+		hpsb_destroy_hostinfo(&sbp2_highlevel, host);
 	}
 
 	return hi;
@@ -957,13 +950,12 @@
 
 	SBP2_DEBUG("sbp2_remove_host");
 
-	hi = hpsb_get_hostinfo(sbp2_hl_handle, host);
+	hi = hpsb_get_hostinfo(&sbp2_highlevel, host);
 
 	if (hi) {
 		scsi_remove_host(hi->scsi_host);
 		scsi_unregister(hi->scsi_host);
-	} else
-		SBP2_ERR("attempt to remove unknown host %p", host);
+	}
 }
 
 /*
@@ -1092,7 +1084,7 @@
 	scsi_id->ne = ne;
 	scsi_id->ud = ud;
 	scsi_id->speed_code = SPEED_100;
-	scsi_id->max_payload_size = sbp2_speedto_maxrec[SPEED_100];
+	scsi_id->max_payload_size = hpsb_speedto_maxrec[SPEED_100];
 	ud->device.driver_data = scsi_id;
 
 	atomic_set(&scsi_id->sbp2_login_complete, 0);
@@ -1854,7 +1846,7 @@
 
 	/* Payload size is the lesser of what our speed supports and what
 	 * our host supports.  */
-	scsi_id->max_payload_size = min(sbp2_speedto_maxrec[scsi_id->speed_code],
+	scsi_id->max_payload_size = min(hpsb_speedto_maxrec[scsi_id->speed_code],
 					(u8)(((be32_to_cpu(hi->host->csr.rom[2]) >> 12) & 0xf) - 1));
 
 	SBP2_ERR("Node[" NODE_BUS_FMT "]: Max speed [%s] - Max payload [%u]",
@@ -2565,7 +2557,7 @@
 		return(RCODE_ADDRESS_ERROR);
 	}
 
-	hi = hpsb_get_hostinfo(sbp2_hl_handle, host);
+	hi = hpsb_get_hostinfo(&sbp2_highlevel, host);
 
 	if (!hi) {
 		SBP2_ERR("host info is NULL - this is bad!");
@@ -2712,7 +2704,7 @@
 	/*
 	 * Pull our host info and scsi id instance data from the scsi command
 	 */
-	hi = hpsb_get_hostinfo_bykey(sbp2_hl_handle, (unsigned long)SCpnt->device->host);
+	hi = hpsb_get_hostinfo_bykey(&sbp2_highlevel, (unsigned long)SCpnt->device->host);
 
 	if (!hi) {
 		SBP2_ERR("sbp2scsi_host_info is NULL - this is bad!");
@@ -2941,7 +2933,7 @@
  */
 static int sbp2scsi_abort (Scsi_Cmnd *SCpnt) 
 {
-	struct sbp2scsi_host_info *hi = hpsb_get_hostinfo_bykey(sbp2_hl_handle,
+	struct sbp2scsi_host_info *hi = hpsb_get_hostinfo_bykey(&sbp2_highlevel,
 								(unsigned long)SCpnt->device->host);
 	struct scsi_id_instance_data *scsi_id = hi->scsi_id[SCpnt->device->id];
 	struct sbp2_command_info *command;
@@ -2992,7 +2984,7 @@
  */
 static int sbp2scsi_reset (Scsi_Cmnd *SCpnt) 
 {
-	struct sbp2scsi_host_info *hi = hpsb_get_hostinfo_bykey(sbp2_hl_handle,
+	struct sbp2scsi_host_info *hi = hpsb_get_hostinfo_bykey(&sbp2_highlevel,
 								(unsigned long)SCpnt->device->host);
 	struct scsi_id_instance_data *scsi_id = hi->scsi_id[SCpnt->device->id];
 
@@ -3019,36 +3011,36 @@
 			      int length, int hostno, int inout)
 {
 	Scsi_Device *scd;
-	struct Scsi_Host *host;
-	struct sbp2scsi_host_info *hi;
+	struct Scsi_Host *scsi_host;
+	struct hpsb_host *host;
 	char *pos = buffer;
 
 	/* if someone is sending us data, just throw it away */
 	if (inout)
 		return length;
 
-	host = scsi_host_hn_get(hostno);
-	if (!host)  /* if we couldn't find it, we return an error */
+	scsi_host = scsi_host_hn_get(hostno);
+	if (!scsi_host)  /* if we couldn't find it, we return an error */
 		return -ESRCH;
 
-	hi = hpsb_get_hostinfo_bykey(sbp2_hl_handle, (unsigned long)host);
-	if (!hi) /* shouldn't happen, but... */
+	host = hpsb_get_host_bykey(&sbp2_highlevel, (unsigned long)scsi_host);
+	if (!host) /* shouldn't happen, but... */
 		return -ESRCH;
 
 	SPRINTF("Host scsi%d             : SBP-2 IEEE-1394 (%s)\n", hostno,
-		hi->host->driver->name);
+		host->driver->name);
 	SPRINTF("Driver version         : %s\n", version);
 
 	SPRINTF("\nModule options         :\n");
-	SPRINTF("  max_speed       : %s\n", hpsb_speedto_str[max_speed]);
-	SPRINTF("  max_sectors     : %d\n", max_sectors);
-	SPRINTF("  serialize_io    : %s\n", serialize_io ? "yes" : "no");
-	SPRINTF("  exclusive_login : %s\n", exclusive_login ? "yes" : "no");
+	SPRINTF("  max_speed            : %s\n", hpsb_speedto_str[max_speed]);
+	SPRINTF("  max_sectors          : %d\n", max_sectors);
+	SPRINTF("  serialize_io         : %s\n", serialize_io ? "yes" : "no");
+	SPRINTF("  exclusive_login      : %s\n", exclusive_login ? "yes" : "no");
 
-	SPRINTF("\nAttached devices       : %s\n", !list_empty(&host->my_devices) ?
+	SPRINTF("\nAttached devices       : %s\n", !list_empty(&scsi_host->my_devices) ?
 		"" : "none");
 
-	list_for_each_entry (scd, &host->my_devices, siblings) {
+	list_for_each_entry (scd, &scsi_host->my_devices, siblings) {
 		int i;
 
 		SPRINTF("  [Channel: %02d, Id: %02d, Lun: %02d]  ", scd->channel,
@@ -3070,7 +3062,7 @@
 	SPRINTF("\n");
 
 	/* release the reference count on this host */
-	scsi_host_put(host);
+	scsi_host_put(scsi_host);
 	/* Calculate start of next buffer, and return value. */
 	*start = buffer + offset;
 
@@ -3112,49 +3104,33 @@
 {
 	SBP2_DEBUG("sbp2_module_init");
 
-	/* Module load debug option to force one command at a time
-	 * (serializing I/O) */
+	/* Module load debug option to force one command at a time (serializing I/O) */
 	if (serialize_io) {
 		SBP2_ERR("Driver forced to serialize I/O (serialize_io = 1)");
 		scsi_driver_template.can_queue = 1;
 		scsi_driver_template.cmd_per_lun = 1;
 	}
 
-	/* 
-	 * Set max sectors (module load option). Default is 255 sectors. 
-	 */
+	/* Set max sectors (module load option). Default is 255 sectors. */
 	scsi_driver_template.max_sectors = max_sectors;
 
 
-	/*
-	 * Register our high level driver with 1394 stack
-	 */
-	sbp2_hl_handle = hpsb_register_highlevel(SBP2_DEVICE_NAME,
-						 &sbp2_hl_ops);
-	if (!sbp2_hl_handle) {
-		SBP2_ERR("sbp2 failed to register with ieee1394 highlevel");
-		return(-ENOMEM);
-	}
+	/* Register our high level driver with 1394 stack */
+	hpsb_register_highlevel(&sbp2_highlevel);
 
-	/*
-	 * Register our sbp2 status address space...
-	 */
-	hpsb_register_addrspace(sbp2_hl_handle, &sbp2_ops,
-				SBP2_STATUS_FIFO_ADDRESS,
+	/* Register our sbp2 status address space... */
+	hpsb_register_addrspace(&sbp2_highlevel, &sbp2_ops, SBP2_STATUS_FIFO_ADDRESS,
 				SBP2_STATUS_FIFO_ADDRESS + 
-				SBP2_STATUS_FIFO_ENTRY_TO_OFFSET(
-					SBP2SCSI_MAX_SCSI_IDS+1));
+				SBP2_STATUS_FIFO_ENTRY_TO_OFFSET(SBP2SCSI_MAX_SCSI_IDS+1));
 
-	/*
-	 * Handle data movement if physical dma is not enabled/supported
-	 * on host controller
-	 */
+	/* Handle data movement if physical dma is not enabled/supported
+	 * on host controller */
 #ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
-	hpsb_register_addrspace(sbp2_hl_handle, &sbp2_physdma_ops,
-			0x0ULL, 0xfffffffcULL);
+	hpsb_register_addrspace(&sbp2_highlevel, &sbp2_physdma_ops, 0x0ULL, 0xfffffffcULL);
 #endif
 
 	hpsb_register_protocol(&sbp2_driver);
+
 	return 0;
 }
 
@@ -3163,8 +3139,8 @@
 	SBP2_DEBUG("sbp2_module_exit");
 
 	hpsb_unregister_protocol(&sbp2_driver);
-	if (sbp2_hl_handle)
-		hpsb_unregister_highlevel(sbp2_hl_handle);
+
+	hpsb_unregister_highlevel(&sbp2_highlevel);
 }
 
 module_init(sbp2_module_init);
diff -Nru a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c
--- a/drivers/ieee1394/video1394.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/ieee1394/video1394.c	Wed Apr 30 22:28:05 2003
@@ -39,7 +39,6 @@
 #include <linux/devfs_fs_kernel.h>
 #include <linux/bitops.h>
 #include <linux/types.h>
-#include <linux/wrapper.h>
 #include <linux/vmalloc.h>
 #include <linux/timex.h>
 #include <linux/mm.h>
@@ -67,14 +66,6 @@
 #define vmalloc_32(x) vmalloc(x)
 #endif
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,3))
-#define remap_page_range_1394(vma, start, addr, size, prot) \
-	remap_page_range(start, addr, size, prot)
-#else
-#define remap_page_range_1394(vma, start, addr, size, prot) \
-	remap_page_range(vma, start, addr, size, prot)
-#endif
-
 struct it_dma_prg {
 	struct dma_cmd begin;
 	quadlet_t data[4];
@@ -155,8 +146,7 @@
 void wakeup_dma_ir_ctx(unsigned long l);
 void wakeup_dma_it_ctx(unsigned long l);
 
-static struct hpsb_highlevel *hl_handle = NULL;
-
+static struct hpsb_highlevel video1394_highlevel;
 
 static int free_dma_iso_ctx(struct dma_iso_ctx *d)
 {
@@ -496,11 +486,7 @@
 		if (d->ir_prg[i][d->nb_cmd-1].status & cpu_to_le32(0xFFFF0000)) {
 			reset_ir_status(d, i);
 			d->buffer_status[i] = VIDEO1394_BUFFER_READY;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
-			get_fast_time(&d->buffer_time[i]);
-#else
 			do_gettimeofday(&d->buffer_time[i]);
-#endif
 		}
 	}
 
@@ -1164,7 +1150,7 @@
 	struct ti_ohci *ohci;
 	struct file_ctx *ctx;
 
-	ohci = hpsb_get_hostinfo_bykey(hl_handle, i);
+	ohci = hpsb_get_hostinfo_bykey(&video1394_highlevel, i);
         if (ohci == NULL)
                 return -EIO;
 
@@ -1249,7 +1235,7 @@
 };
 
 
-static void video1394_add_host (struct hpsb_host *host, struct hpsb_highlevel *hl)
+static void video1394_add_host (struct hpsb_host *host)
 {
 	struct ti_ohci *ohci;
 	char name[16];
@@ -1261,13 +1247,13 @@
 
 	ohci = (struct ti_ohci *)host->hostdata;
 
-	if (!hpsb_create_hostinfo(hl, host, 0)) {
+	if (!hpsb_create_hostinfo(&video1394_highlevel, host, 0)) {
 		PRINT(KERN_ERR, ohci->id, "Cannot allocate hostinfo");
 		return;
 	}
 
-	hpsb_set_hostinfo(hl, host, ohci);
-	hpsb_set_hostinfo_key(hl, host, ohci->id);
+	hpsb_set_hostinfo(&video1394_highlevel, host, ohci);
+	hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->id);
 
 	sprintf(name, "%s/%d", VIDEO1394_DRIVER_NAME, ohci->id);
 	minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->id;
@@ -1280,7 +1266,7 @@
 
 static void video1394_remove_host (struct hpsb_host *host)
 {
-	struct ti_ohci *ohci = hpsb_get_hostinfo(hl_handle, host);
+	struct ti_ohci *ohci = hpsb_get_hostinfo(&video1394_highlevel, host);
 
 	if (ohci)
 		devfs_remove("%s/%d", VIDEO1394_DRIVER_NAME, ohci->id);
@@ -1289,7 +1275,8 @@
 }
 
 
-static struct hpsb_highlevel_ops hl_ops = {
+static struct hpsb_highlevel video1394_highlevel = {
+	.name =		VIDEO1394_DRIVER_NAME,
 	.add_host =	video1394_add_host,
 	.remove_host =	video1394_remove_host,
 };
@@ -1428,7 +1415,7 @@
 
 	hpsb_unregister_protocol(&video1394_driver);
 
-	hpsb_unregister_highlevel (hl_handle);
+	hpsb_unregister_highlevel(&video1394_highlevel);
 
 	devfs_remove(VIDEO1394_DRIVER_NAME);
 	ieee1394_unregister_chardev(IEEE1394_MINOR_BLOCK_VIDEO1394);
@@ -1449,13 +1436,7 @@
 
 	devfs_mk_dir(VIDEO1394_DRIVER_NAME);
 
-	hl_handle = hpsb_register_highlevel (VIDEO1394_DRIVER_NAME, &hl_ops);
-	if (hl_handle == NULL) {
-		PRINT_G(KERN_ERR, "No more memory for driver\n");
-		devfs_remove(VIDEO1394_DRIVER_NAME);
-		ieee1394_unregister_chardev(IEEE1394_MINOR_BLOCK_VIDEO1394);
-		return -ENOMEM;
-	}
+	hpsb_register_highlevel(&video1394_highlevel);
 
 	hpsb_register_protocol(&video1394_driver);
 
diff -Nru a/drivers/input/evbug.c b/drivers/input/evbug.c
--- a/drivers/input/evbug.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/input/evbug.c	Wed Apr 30 22:28:08 2003
@@ -88,19 +88,8 @@
 	.id_table =	evbug_ids,
 };
 
-static struct device_interface evbug_intf = {
-	.name		= "debug",
-	.devclass	= &input_devclass,
-};
-
 int __init evbug_init(void)
 {
-	int retval;
-
-	retval = interface_register(&evbug_intf);
-	if(retval < 0)
-		return retval;
-
 	input_register_handler(&evbug_handler);
 	return 0;
 }
@@ -108,7 +97,6 @@
 void __exit evbug_exit(void)
 {
 	input_unregister_handler(&evbug_handler);
-	interface_unregister(&evbug_intf);
 }
 
 module_init(evbug_init);
diff -Nru a/drivers/input/evdev.c b/drivers/input/evdev.c
--- a/drivers/input/evdev.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/input/evdev.c	Wed Apr 30 22:28:13 2003
@@ -19,15 +19,15 @@
 #include <linux/input.h>
 #include <linux/smp_lock.h>
 #include <linux/device.h>
+#include <linux/devfs_fs_kernel.h>
 
-struct evdev{
+struct evdev {
 	int exist;
 	int open;
 	int minor;
 	char name[16];
 	struct input_handle handle;
 	wait_queue_head_t wait;
-	devfs_handle_t devfs;
 	struct list_head list;
 };
 
@@ -76,6 +76,13 @@
 	return input_flush_device(&list->evdev->handle, file);
 }
 
+static void evdev_free(struct evdev *evdev)
+{
+	devfs_remove("input/event%d", evdev->minor);
+	evdev_table[evdev->minor] = NULL;
+	kfree(evdev);
+}
+
 static int evdev_release(struct inode * inode, struct file * file)
 {
 	struct evdev_list *list = file->private_data;
@@ -84,17 +91,13 @@
 	list_del(&list->node);
 
 	if (!--list->evdev->open) {
-		if (list->evdev->exist) {
+		if (list->evdev->exist)
 			input_close_device(&list->evdev->handle);
-		} else {
-			input_unregister_minor(list->evdev->devfs);
-			evdev_table[list->evdev->minor] = NULL;
-			kfree(list->evdev);
-		}
+		else
+			evdev_free(list->evdev);
 	}
 
 	kfree(list);
-
 	return 0;
 }
 
@@ -397,7 +400,7 @@
 	sprintf(evdev->name, "event%d", minor);
 
 	evdev_table[minor] = evdev;
-	evdev->devfs = input_register_minor("input/event%d", minor, EVDEV_MINOR_BASE);
+	input_register_minor("input/event%d", minor, EVDEV_MINOR_BASE);
 
 	return &evdev->handle;
 }
@@ -411,11 +414,8 @@
 	if (evdev->open) {
 		input_close_device(handle);
 		wake_up_interruptible(&evdev->wait);
-	} else {
-		input_unregister_minor(evdev->devfs);
-		evdev_table[evdev->minor] = NULL;
-		kfree(evdev);
-	}
+	} else
+		evdev_free(evdev);
 }
 
 static struct input_device_id evdev_ids[] = {
@@ -435,19 +435,8 @@
 	.id_table =	evdev_ids,
 };
 
-static struct device_interface evdev_intf = {
-	.name		= "event",
-	.devclass	= &input_devclass,
-};
-
 static int __init evdev_init(void)
 {
-	int retval;
-
-	retval = interface_register(&evdev_intf);
-	if(retval < 0)
-		return retval;
-
 	input_register_handler(&evdev_handler);
 	return 0;
 }
@@ -455,7 +444,6 @@
 static void __exit evdev_exit(void)
 {
 	input_unregister_handler(&evdev_handler);
-	interface_unregister(&evdev_intf);
 }
 
 module_init(evdev_init);
diff -Nru a/drivers/input/input.c b/drivers/input/input.c
--- a/drivers/input/input.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/input/input.c	Wed Apr 30 22:28:10 2003
@@ -22,6 +22,7 @@
 #include <linux/interrupt.h>
 #include <linux/poll.h>
 #include <linux/device.h>
+#include <linux/devfs_fs_kernel.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
 MODULE_DESCRIPTION("Input core");
@@ -32,13 +33,12 @@
 EXPORT_SYMBOL(input_register_handler);
 EXPORT_SYMBOL(input_unregister_handler);
 EXPORT_SYMBOL(input_register_minor);
-EXPORT_SYMBOL(input_unregister_minor);
 EXPORT_SYMBOL(input_open_device);
 EXPORT_SYMBOL(input_close_device);
 EXPORT_SYMBOL(input_accept_process);
 EXPORT_SYMBOL(input_flush_device);
 EXPORT_SYMBOL(input_event);
-EXPORT_SYMBOL(input_devclass);
+EXPORT_SYMBOL(input_class);
 
 #define INPUT_MAJOR	13
 #define INPUT_DEVICES	256
@@ -47,7 +47,6 @@
 static LIST_HEAD(input_handler_list);
 
 static struct input_handler *input_table[8];
-static devfs_handle_t input_devfs_handle;
 
 #ifdef CONFIG_PROC_FS
 static struct proc_dir_entry *proc_bus_input_dir;
@@ -542,20 +541,13 @@
 	.open = input_open_file,
 };
 
-devfs_handle_t input_register_minor(char *name, int minor, int minor_base)
+void input_register_minor(char *name, int minor, int minor_base)
 {
 	char devfs_name[16];
-	sprintf(devfs_name, name, minor);
-
-	return devfs_register(NULL, devfs_name, 0,
-			INPUT_MAJOR, minor + minor_base,
-			S_IFCHR|S_IRUGO|S_IWUSR,
-			&input_fops, NULL);
-}
 
-void input_unregister_minor(devfs_handle_t handle)
-{
-	devfs_unregister(handle);
+	sprintf(devfs_name, name, minor);
+	devfs_register(NULL, devfs_name, 0, INPUT_MAJOR, minor_base + minor,
+			S_IFCHR|S_IRUGO|S_IWUSR, &input_fops, NULL);
 }
 
 #ifdef CONFIG_PROC_FS
@@ -675,7 +667,7 @@
 
 #endif
 
-struct device_class input_devclass = {
+struct class input_class = {
 	.name		= "input",
 };
 
@@ -683,7 +675,7 @@
 {
 	struct proc_dir_entry *entry;
 
-	devclass_register(&input_devclass);
+	class_register(&input_class);
 
 #ifdef CONFIG_PROC_FS
 	proc_bus_input_dir = proc_mkdir("input", proc_bus);
@@ -699,8 +691,7 @@
 		return -EBUSY;
 	}
 
-	input_devfs_handle = devfs_mk_dir("input");
-
+	devfs_mk_dir("input");
 	return 0;
 }
 
@@ -711,10 +702,10 @@
 	remove_proc_entry("handlers", proc_bus_input_dir);
 	remove_proc_entry("input", proc_bus);
 #endif
-	devfs_unregister(input_devfs_handle);
+	devfs_remove("input");
         if (unregister_chrdev(INPUT_MAJOR, "input"))
                 printk(KERN_ERR "input: can't unregister char major %d", INPUT_MAJOR);
-	devclass_unregister(&input_devclass);
+	class_unregister(&input_class);
 }
 
 subsys_initcall(input_init);
diff -Nru a/drivers/input/joydev.c b/drivers/input/joydev.c
--- a/drivers/input/joydev.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/input/joydev.c	Wed Apr 30 22:28:09 2003
@@ -26,6 +26,7 @@
 #include <linux/init.h>
 #include <linux/smp_lock.h>
 #include <linux/device.h>
+#include <linux/devfs_fs_kernel.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
 MODULE_DESCRIPTION("Joystick device interfaces");
@@ -45,7 +46,6 @@
 	char name[16];
 	struct input_handle handle;
 	wait_queue_head_t wait;
-	devfs_handle_t devfs;
 	struct list_head list;
 	struct js_corr corr[ABS_MAX];
 	struct JS_DATA_SAVE_TYPE glue;
@@ -141,6 +141,13 @@
 	return retval < 0 ? retval : 0;
 }
 
+static void joydev_free(struct joydev *joydev)
+{
+	devfs_remove("js%d", joydev->minor);
+	joydev_table[joydev->minor] = NULL;
+	kfree(joydev);
+}
+
 static int joydev_release(struct inode * inode, struct file * file)
 {
 	struct joydev_list *list = file->private_data;
@@ -150,17 +157,13 @@
 	list_del(&list->node);
 
 	if (!--list->joydev->open) {
-		if (list->joydev->exist) {
+		if (list->joydev->exist)
 			input_close_device(&list->joydev->handle);
-		} else {
-			input_unregister_minor(list->joydev->devfs);
-			joydev_table[list->joydev->minor] = NULL;
-			kfree(list->joydev);
-		}
+		else
+			joydev_free(list->joydev);
 	}
 
 	kfree(list);
-
 	return 0;
 }
 
@@ -442,7 +445,7 @@
 	}
 
 	joydev_table[minor] = joydev;
-	joydev->devfs = input_register_minor("js%d", minor, JOYDEV_MINOR_BASE);
+	input_register_minor("js%d", minor, JOYDEV_MINOR_BASE);
 
 	return &joydev->handle;
 }
@@ -453,13 +456,10 @@
 
 	joydev->exist = 0;
 
-	if (joydev->open) {
+	if (joydev->open)
 		input_close_device(handle);	
-	} else {
-		input_unregister_minor(joydev->devfs);
-		joydev_table[joydev->minor] = NULL;
-		kfree(joydev);
-	}
+	else
+		joydev_free(joydev);
 }
 
 static struct input_device_id joydev_ids[] = {
@@ -493,19 +493,8 @@
 	.id_table =	joydev_ids,
 };
 
-static struct device_interface joydev_intf = {
-	.name		= "joystick",
-	.devclass	= &input_devclass,
-};
-
 static int __init joydev_init(void)
 {
-	int retval;
-
-	retval = interface_register(&joydev_intf);
-	if(retval < 0)
-		return retval;
-
 	input_register_handler(&joydev_handler);
 	return 0;
 }
@@ -513,7 +502,6 @@
 static void __exit joydev_exit(void)
 {
 	input_unregister_handler(&joydev_handler);
-	interface_unregister(&joydev_intf);
 }
 
 module_init(joydev_init);
diff -Nru a/drivers/input/joystick/iforce/iforce-serio.c b/drivers/input/joystick/iforce/iforce-serio.c
--- a/drivers/input/joystick/iforce/iforce-serio.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/input/joystick/iforce/iforce-serio.c	Wed Apr 30 22:28:03 2003
@@ -78,40 +78,38 @@
 	iforce_serial_xmit((struct iforce *)serio->private);
 }
 
-static void iforce_serio_irq(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs)
+static irqreturn_t iforce_serio_irq(struct serio *serio,
+		unsigned char data, unsigned int flags, struct pt_regs *regs)
 {
 	struct iforce* iforce = serio->private;
 
 	if (!iforce->pkt) {
-		if (data != 0x2b) {
-			return;
-		}
-		iforce->pkt = 1;
-		return;
+		if (data == 0x2b)
+			iforce->pkt = 1;
+		goto out;
 	}
 
 	if (!iforce->id) {
-		if (data > 3 && data != 0xff) {
+		if (data > 3 && data != 0xff)
 			iforce->pkt = 0;
-			return;
-		}
-		iforce->id = data;
-		return;
+		else
+			iforce->id = data;
+		goto out;
 	}
 
 	if (!iforce->len) {
 		if (data > IFORCE_MAX_LENGTH) {
 			iforce->pkt = 0;
 			iforce->id = 0;
-			return;
+		} else {
+			iforce->len = data;
 		}
-		iforce->len = data;
-		return;
+		goto out;
 	}
 
 	if (iforce->idx < iforce->len) {
 		iforce->csum += iforce->data[iforce->idx++] = data;
-		return;
+		goto out;
 	}
 
 	if (iforce->idx == iforce->len) {
@@ -122,6 +120,8 @@
 		iforce->idx = 0;
 		iforce->csum = 0;
 	}
+out:
+	return IRQ_HANDLED;
 }
 
 static void iforce_serio_connect(struct serio *serio, struct serio_dev *dev)
diff -Nru a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c
--- a/drivers/input/joystick/magellan.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/input/joystick/magellan.c	Wed Apr 30 22:28:03 2003
@@ -113,7 +113,8 @@
 	input_sync(dev);
 }
 
-static void magellan_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs)
+static irqreturn_t magellan_interrupt(struct serio *serio,
+		unsigned char data, unsigned int flags, struct pt_regs *regs)
 {
 	struct magellan* magellan = serio->private;
 
@@ -123,7 +124,8 @@
 	} else {
 		if (magellan->idx < MAGELLAN_MAX_LENGTH)
 			magellan->data[magellan->idx++] = data;
-	} 
+	}
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
--- a/drivers/input/joystick/sidewinder.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/input/joystick/sidewinder.c	Wed Apr 30 22:28:16 2003
@@ -573,8 +573,8 @@
 {
 	struct sw *sw;
 	int i, j, k, l;
-	unsigned char buf[SW_LENGTH];
-	unsigned char idbuf[SW_LENGTH];
+	unsigned char *buf = NULL;	/* [SW_LENGTH] */
+	unsigned char *idbuf = NULL;	/* [SW_LENGTH] */
 	unsigned char m = 1;
 	char comment[40];
 
@@ -583,6 +583,11 @@
 	if (!(sw = kmalloc(sizeof(struct sw), GFP_KERNEL))) return;
 	memset(sw, 0, sizeof(struct sw));
 
+	buf = kmalloc(SW_LENGTH, GFP_KERNEL);
+	idbuf = kmalloc(SW_LENGTH, GFP_KERNEL);
+	if (!buf || !idbuf)
+		goto fail1;
+
 	gameport->private = sw;
 
 	sw->gameport = gameport;
@@ -739,6 +744,8 @@
 	return;
 fail2:	gameport_close(gameport);
 fail1:	kfree(sw);
+	kfree(buf);
+	kfree(idbuf);
 }
 
 static void sw_disconnect(struct gameport *gameport)
diff -Nru a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c
--- a/drivers/input/joystick/spaceball.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/input/joystick/spaceball.c	Wed Apr 30 22:28:04 2003
@@ -149,7 +149,8 @@
  * can occur in the axis values.
  */
 
-static void spaceball_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs)
+static irqreturn_t spaceball_interrupt(struct serio *serio,
+		unsigned char data, unsigned int flags, struct pt_regs *regs)
 {
 	struct spaceball *spaceball = serio->private;
 
@@ -158,11 +159,11 @@
 			spaceball_process_packet(spaceball, regs);
 			spaceball->idx = 0;
 			spaceball->escape = 0;
-			return;
+			break;
 		case '^':
 			if (!spaceball->escape) {
 				spaceball->escape = 1;
-				return;
+				break;
 			}
 			spaceball->escape = 0;
 		case 'M':
@@ -177,8 +178,9 @@
 				spaceball->escape = 0;
 			if (spaceball->idx < SPACEBALL_MAX_LENGTH)
 				spaceball->data[spaceball->idx++] = data;
-			return;
+			break;
 	}
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c
--- a/drivers/input/joystick/spaceorb.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/input/joystick/spaceorb.c	Wed Apr 30 22:28:08 2003
@@ -130,7 +130,8 @@
 	input_sync(dev);
 }
 
-static void spaceorb_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs)
+static irqreturn_t spaceorb_interrupt(struct serio *serio,
+		unsigned char data, unsigned int flags, struct pt_regs *regs)
 {
 	struct spaceorb* spaceorb = serio->private;
 
@@ -140,6 +141,7 @@
 	}
 	if (spaceorb->idx < SPACEORB_MAX_LENGTH)
 		spaceorb->data[spaceorb->idx++] = data & 0x7f;
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c
--- a/drivers/input/joystick/stinger.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/input/joystick/stinger.c	Wed Apr 30 22:28:03 2003
@@ -98,7 +98,8 @@
  * packet processing routine.
  */
 
-static void stinger_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs)
+static irqreturn_t stinger_interrupt(struct serio *serio,
+	unsigned char data, unsigned int flags, struct pt_regs *regs)
 {
 	struct stinger* stinger = serio->private;
 
@@ -112,7 +113,7 @@
 		stinger->idx = 0;
 	}
 
-	return;
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c
--- a/drivers/input/joystick/warrior.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/input/joystick/warrior.c	Wed Apr 30 22:28:12 2003
@@ -99,7 +99,8 @@
  * packet processing routine.
  */
 
-static void warrior_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs)
+static irqreturn_t warrior_interrupt(struct serio *serio,
+		unsigned char data, unsigned int flags, struct pt_regs *regs)
 {
 	struct warrior* warrior = serio->private;
 
@@ -117,6 +118,7 @@
 		warrior->idx = 0;
 		warrior->len = 0;
 	}
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
--- a/drivers/input/keyboard/atkbd.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/input/keyboard/atkbd.c	Wed Apr 30 22:28:15 2003
@@ -132,7 +132,8 @@
  * the keyboard into events.
  */
 
-static void atkbd_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs)
+static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
+			unsigned int flags, struct pt_regs *regs)
 {
 	struct atkbd *atkbd = serio->private;
 	int code = data;
@@ -145,7 +146,7 @@
 		printk("atkbd.c: frame/parity error: %02x\n", flags);
 		serio_write(serio, ATKBD_CMD_RESEND);
 		atkbd->resend = 1;
-		return;
+		goto out;
 	}
 	
 	if (!flags)
@@ -154,34 +155,35 @@
 	switch (code) {
 		case ATKBD_RET_ACK:
 			atkbd->ack = 1;
-			return;
+			goto out;
 		case ATKBD_RET_NAK:
 			atkbd->ack = -1;
-			return;
+			goto out;
 	}
 
 	if (atkbd->cmdcnt) {
 		atkbd->cmdbuf[--atkbd->cmdcnt] = code;
-		return;
+		goto out;
 	}
 
 	switch (atkbd->keycode[code]) {
 		case ATKBD_KEY_BAT:
 			serio_rescan(atkbd->serio);
-			return;
+			goto out;
 		case ATKBD_KEY_EMUL0:
 			atkbd->emul = 1;
-			return;
+			goto out;
 		case ATKBD_KEY_EMUL1:
 			atkbd->emul = 2;
-			return;
+			goto out;
 		case ATKBD_KEY_RELEASE:
 			atkbd->release = 1;
-			return;
+			goto out;
 	}
 
 	if (atkbd->emul) {
-		if (--atkbd->emul) return;
+		if (--atkbd->emul)
+			goto out;
 		code |= 0x100;
 	}
 
@@ -197,8 +199,10 @@
 			input_report_key(&atkbd->dev, atkbd->keycode[code], !atkbd->release);
 			input_sync(&atkbd->dev);
 	}
-		
+
 	atkbd->release = 0;
+out:
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c
--- a/drivers/input/keyboard/newtonkbd.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/input/keyboard/newtonkbd.c	Wed Apr 30 22:28:03 2003
@@ -62,7 +62,8 @@
 	char phys[32];
 };
 
-void nkbd_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs)
+irqreturn_t nkbd_interrupt(struct serio *serio,
+		unsigned char data, unsigned int flags, struct pt_regs *regs)
 {
 	struct nkbd *nkbd = serio->private;
 
@@ -75,6 +76,7 @@
 
 	else if (data == 0xe7) /* end of init sequence */
 		printk(KERN_INFO "input: %s on %s\n", nkbd_name, serio->phys);
+	return IRQ_HANDLED;
 
 }
 
diff -Nru a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c
--- a/drivers/input/keyboard/sunkbd.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/input/keyboard/sunkbd.c	Wed Apr 30 22:28:03 2003
@@ -89,18 +89,19 @@
  * is received.
  */
 
-static void sunkbd_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs)
+static irqreturn_t sunkbd_interrupt(struct serio *serio,
+		unsigned char data, unsigned int flags, struct pt_regs *regs)
 {
 	struct sunkbd* sunkbd = serio->private;
 
 	if (sunkbd->reset <= -1) {		/* If cp[i] is 0xff, sunkbd->reset will stay -1. */
 		sunkbd->reset = data;		/* The keyboard sends 0xff 0xff 0xID on powerup */
-		return;
+		goto out;
 	}
 
 	if (sunkbd->layout == -1) {
 		sunkbd->layout = data;
-		return;
+		goto out;
 	}
 
 	switch (data) {
@@ -108,14 +109,14 @@
 		case SUNKBD_RET_RESET:
 			schedule_work(&sunkbd->tq);
 			sunkbd->reset = -1;
-			return;
+			break;
 
 		case SUNKBD_RET_LAYOUT:
 			sunkbd->layout = -1;
-			return;
+			break;
 
 		case SUNKBD_RET_ALLUP: /* All keys released */
-			return;
+			break;
 
 		default:
 			if (sunkbd->keycode[data & SUNKBD_KEY]) {
@@ -127,6 +128,8 @@
                                         data & SUNKBD_KEY, data & SUNKBD_RELEASE ? "released" : "pressed");
                         }
 	}
+out:
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c
--- a/drivers/input/keyboard/xtkbd.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/input/keyboard/xtkbd.c	Wed Apr 30 22:28:10 2003
@@ -63,14 +63,15 @@
 	char phys[32];
 };
 
-void xtkbd_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs)
+irqreturn_t xtkbd_interrupt(struct serio *serio,
+	unsigned char data, unsigned int flags, struct pt_regs *regs)
 {
 	struct xtkbd *xtkbd = serio->private;
 
 	switch (data) {
 		case XTKBD_EMUL0:
 		case XTKBD_EMUL1:
-			return;
+			break;
 		default:
 
 			if (xtkbd->keycode[data & XTKBD_KEY]) {
@@ -81,7 +82,8 @@
 				printk(KERN_WARNING "xtkbd.c: Unknown key (scancode %#x) %s.\n",
 					data & XTKBD_KEY, data & XTKBD_RELEASE ? "released" : "pressed");
 			}
-		}
+	}
+	return IRQ_HANDLED;
 }
 
 void xtkbd_connect(struct serio *serio, struct serio_dev *dev)
diff -Nru a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
--- a/drivers/input/misc/uinput.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/input/misc/uinput.c	Wed Apr 30 22:28:15 2003
@@ -167,7 +167,7 @@
 
 static int uinput_alloc_device(struct file *file, const char *buffer, size_t count)
 {
-	struct uinput_user_dev	user_dev;
+	struct uinput_user_dev	*user_dev;
 	struct input_dev	*dev;
 	struct uinput_device	*udev;
 	int			size,
@@ -178,34 +178,40 @@
 	udev = (struct uinput_device *)file->private_data;
 	dev = udev->dev;
 
-	if (copy_from_user(&user_dev, buffer, sizeof(struct uinput_user_dev))) {
+	user_dev = kmalloc(sizeof(*user_dev), GFP_KERNEL);
+	if (!user_dev) {
+		retval = -ENOMEM;
+		goto exit;
+	}
+
+	if (copy_from_user(user_dev, buffer, sizeof(struct uinput_user_dev))) {
 		retval = -EFAULT;
 		goto exit;
 	}
 
 	if (NULL != dev->name) 
 		kfree(dev->name);
-		
-	size = strnlen(user_dev.name, UINPUT_MAX_NAME_SIZE);
+
+	size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE);
 	dev->name = kmalloc(size + 1, GFP_KERNEL);
 	if (!dev->name) {
 		retval = -ENOMEM;
 		goto exit;
 	}
 
-	strncpy(dev->name, user_dev.name, size);
+	strncpy(dev->name, user_dev->name, size);
 	dev->name[size] = '\0';
-	dev->id.bustype	= user_dev.id.bustype;
-	dev->id.vendor	= user_dev.id.vendor;
-	dev->id.product	= user_dev.id.product;
-	dev->id.version	= user_dev.id.version;
-	dev->ff_effects_max = user_dev.ff_effects_max;
+	dev->id.bustype	= user_dev->id.bustype;
+	dev->id.vendor	= user_dev->id.vendor;
+	dev->id.product	= user_dev->id.product;
+	dev->id.version	= user_dev->id.version;
+	dev->ff_effects_max = user_dev->ff_effects_max;
 
 	size = sizeof(int) * (ABS_MAX + 1);
-	memcpy(dev->absmax, user_dev.absmax, size);
-	memcpy(dev->absmin, user_dev.absmin, size);
-	memcpy(dev->absfuzz, user_dev.absfuzz, size);
-	memcpy(dev->absflat, user_dev.absflat, size);
+	memcpy(dev->absmax, user_dev->absmax, size);
+	memcpy(dev->absmin, user_dev->absmin, size);
+	memcpy(dev->absfuzz, user_dev->absfuzz, size);
+	memcpy(dev->absflat, user_dev->absflat, size);
 
 	/* check if absmin/absmax/absfuzz/absflat are filled as
 	 * told in Documentation/input/input-programming.txt */
@@ -216,6 +222,7 @@
 	}
 
 exit:
+	kfree(user_dev);
 	return retval;
 }
 
diff -Nru a/drivers/input/mouse/inport.c b/drivers/input/mouse/inport.c
--- a/drivers/input/mouse/inport.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/input/mouse/inport.c	Wed Apr 30 22:28:09 2003
@@ -85,7 +85,7 @@
 static int inport_irq = INPORT_IRQ;
 static int inport_used = 0;
 
-static void inport_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 static int inport_open(struct input_dev *dev)
 {
@@ -124,7 +124,7 @@
 	},
 };
 
-static void inport_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	unsigned char buttons;
 
@@ -150,6 +150,7 @@
 	outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
 
 	input_sync(&inport_dev);
+	return IRQ_HANDLED;
 }
 
 #ifndef MODULE
diff -Nru a/drivers/input/mouse/logibm.c b/drivers/input/mouse/logibm.c
--- a/drivers/input/mouse/logibm.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/input/mouse/logibm.c	Wed Apr 30 22:28:09 2003
@@ -75,7 +75,7 @@
 static int logibm_irq = LOGIBM_IRQ;
 static int logibm_used = 0;
 
-static void logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 static int logibm_open(struct input_dev *dev)
 {
@@ -114,7 +114,7 @@
 	},
 };
 
-static void logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	char dx, dy;
 	unsigned char buttons;
@@ -139,6 +139,7 @@
 	input_sync(&logibm_dev);
 
 	outb(LOGIBM_ENABLE_IRQ, LOGIBM_CONTROL_PORT);
+	return IRQ_HANDLED;
 }
 
 #ifndef MODULE
diff -Nru a/drivers/input/mouse/pc110pad.c b/drivers/input/mouse/pc110pad.c
--- a/drivers/input/mouse/pc110pad.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/input/mouse/pc110pad.c	Wed Apr 30 22:28:07 2003
@@ -60,7 +60,7 @@
 static char *pc110pad_name = "IBM PC110 TouchPad";
 static char *pc110pad_phys = "isa15e0/input0";
 
-static void pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs)
+static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs)
 {
 	int value     = inb_p(pc110pad_io);
 	int handshake = inb_p(pc110pad_io + 2);
@@ -71,7 +71,8 @@
 
 	pc110pad_data[pc110pad_count++] = value;
 
-	if (pc110pad_count < 3) return;
+	if (pc110pad_count < 3)
+		return IRQ_HANDLED;
 	
 	input_regs(&pc110pad_dev, regs);
 	input_report_key(&pc110pad_dev, BTN_TOUCH,
@@ -83,6 +84,7 @@
 	input_sync(&pc110pad_dev);
 
 	pc110pad_count = 0;
+	return IRQ_HANDLED;
 }
 
 static void pc110pad_close(struct input_dev *dev)
diff -Nru a/drivers/input/mouse/psmouse.c b/drivers/input/mouse/psmouse.c
--- a/drivers/input/mouse/psmouse.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/input/mouse/psmouse.c	Wed Apr 30 22:28:06 2003
@@ -167,7 +167,8 @@
  * packets or passing them to the command routine as command output.
  */
 
-static void psmouse_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs)
+static irqreturn_t psmouse_interrupt(struct serio *serio,
+		unsigned char data, unsigned int flags, struct pt_regs *regs)
 {
 	struct psmouse *psmouse = serio->private;
 
@@ -186,12 +187,12 @@
 				break;
 		}
 		psmouse->acking = 0;
-		return;
+		goto out;
 	}
 
 	if (psmouse->cmdcnt) {
 		psmouse->cmdbuf[--psmouse->cmdcnt] = data;
-		return;
+		goto out;
 	}
 
 	if (psmouse->pktcnt && time_after(jiffies, psmouse->last + HZ/2)) {
@@ -205,13 +206,15 @@
 	if (psmouse->pktcnt == 3 + (psmouse->type >= PSMOUSE_GENPS)) {
 		psmouse_process_packet(psmouse, regs);
 		psmouse->pktcnt = 0;
-		return;
+		goto out;
 	}
 
 	if (psmouse->pktcnt == 1 && psmouse->packet[0] == PSMOUSE_RET_BAT) {
 		serio_rescan(serio);
-		return;
-	}	
+		goto out;
+	}
+out:
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c
--- a/drivers/input/mouse/sermouse.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/input/mouse/sermouse.c	Wed Apr 30 22:28:12 2003
@@ -204,7 +204,8 @@
  * packets or passing them to the command routine as command output.
  */
 
-static void sermouse_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs)
+static irqreturn_t sermouse_interrupt(struct serio *serio,
+		unsigned char data, unsigned int flags, struct pt_regs *regs)
 {
 	struct sermouse *sermouse = serio->private;
 
@@ -215,6 +216,7 @@
 		sermouse_process_ms(sermouse, data, regs);
 	else
 		sermouse_process_msc(sermouse, data, regs);
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/input/mousedev.c b/drivers/input/mousedev.c
--- a/drivers/input/mousedev.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/input/mousedev.c	Wed Apr 30 22:28:17 2003
@@ -22,6 +22,7 @@
 #include <linux/random.h>
 #include <linux/major.h>
 #include <linux/device.h>
+#include <linux/devfs_fs_kernel.h>
 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
 #include <linux/miscdevice.h>
 #endif
@@ -46,7 +47,6 @@
 	wait_queue_head_t wait;
 	struct list_head list;
 	struct input_handle handle;
-	devfs_handle_t devfs;
 };
 
 struct mousedev_list {
@@ -171,45 +171,52 @@
 	return retval < 0 ? retval : 0;
 }
 
+static void mousedev_free(struct mousedev *mousedev)
+{
+	devfs_remove("input/mouse%d", mousedev->minor);
+	mousedev_table[mousedev->minor] = NULL;
+	kfree(mousedev);
+}
+
+static int mixdev_release(void)
+{
+	struct input_handle *handle;
+
+	list_for_each_entry(handle, &mousedev_handler.h_list, h_node) {
+		struct mousedev *mousedev = handle->private;
+
+		if (!mousedev->open) {
+			if (mousedev->exist)
+				input_close_device(&mousedev->handle);
+			else
+				mousedev_free(mousedev);
+		}
+	}
+
+	return 0;
+}
+
 static int mousedev_release(struct inode * inode, struct file * file)
 {
 	struct mousedev_list *list = file->private_data;
-	struct input_handle *handle;
-	struct mousedev *mousedev;
 
 	mousedev_fasync(-1, file, 0);
 
 	list_del(&list->node);
 
 	if (!--list->mousedev->open) {
-		if (list->mousedev->minor == MOUSEDEV_MIX) {
-			list_for_each_entry(handle, &mousedev_handler.h_list, h_node) {
-				mousedev = handle->private;
-				if (!mousedev->open) {
-					if (mousedev->exist) {
-						input_close_device(&mousedev->handle);
-					} else {
-						input_unregister_minor(mousedev->devfs);
-						mousedev_table[mousedev->minor] = NULL;
-						kfree(mousedev);
-					}
-				}
-			}
-		} else {
-			if (!mousedev_mix.open) {
-				if (list->mousedev->exist) {
-					input_close_device(&list->mousedev->handle);
-				} else {
-					input_unregister_minor(list->mousedev->devfs);
-					mousedev_table[list->mousedev->minor] = NULL;
-					kfree(list->mousedev);
-				}
-			}
+		if (list->mousedev->minor == MOUSEDEV_MIX)
+			return mixdev_release();
+
+		if (!mousedev_mix.open) {
+			if (list->mousedev->exist)
+				input_close_device(&list->mousedev->handle);
+			else
+				mousedev_free(list->mousedev);
 		}
 	}
 	
 	kfree(list);
-
 	return 0;
 }
 
@@ -425,7 +432,7 @@
 		input_open_device(&mousedev->handle);
 
 	mousedev_table[minor] = mousedev;
-	mousedev->devfs = input_register_minor("input/mouse%d", minor, MOUSEDEV_MINOR_BASE);
+	input_register_minor("input/mouse%d", minor, MOUSEDEV_MINOR_BASE);
 
 	return &mousedev->handle;
 }
@@ -441,9 +448,7 @@
 	} else {
 		if (mousedev_mix.open)
 			input_close_device(handle);
-		input_unregister_minor(mousedev->devfs);
-		mousedev_table[mousedev->minor] = NULL;
-		kfree(mousedev);
+		mousedev_free(mousedev);
 	}
 }
 
@@ -487,18 +492,8 @@
 };
 #endif
 
-static struct device_interface mousedev_intf = {
-	.name		= "mouse",
-	.devclass	= &input_devclass,
-};
-
 static int __init mousedev_init(void)
 {
-	int retval;
-
-	if((retval = interface_register(&mousedev_intf)) < 0)
-		return retval;
-
 	input_register_handler(&mousedev_handler);
 
 	memset(&mousedev_mix, 0, sizeof(struct mousedev));
@@ -507,7 +502,7 @@
 	mousedev_table[MOUSEDEV_MIX] = &mousedev_mix;
 	mousedev_mix.exist = 1;
 	mousedev_mix.minor = MOUSEDEV_MIX;
-	mousedev_mix.devfs = input_register_minor("input/mice", MOUSEDEV_MIX, MOUSEDEV_MINOR_BASE);
+	input_register_minor("input/mice", MOUSEDEV_MIX, MOUSEDEV_MINOR_BASE);
 
 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
 	if (!(mousedev_mix.misc = !misc_register(&psaux_mouse)))
@@ -525,9 +520,8 @@
 	if (mousedev_mix.misc)
 		misc_deregister(&psaux_mouse);
 #endif
-	input_unregister_minor(mousedev_mix.devfs);
+	devfs_remove("input/mice");
 	input_unregister_handler(&mousedev_handler);
-	interface_unregister(&mousedev_intf);
 }
 
 module_init(mousedev_init);
diff -Nru a/drivers/input/serio/ct82c710.c b/drivers/input/serio/ct82c710.c
--- a/drivers/input/serio/ct82c710.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/input/serio/ct82c710.c	Wed Apr 30 22:28:03 2003
@@ -64,7 +64,7 @@
 static int ct82c710_data;
 static int ct82c710_status;
 
-static void ct82c710_interrupt(int cpl, void *dev_id, struct pt_regs * regs);
+static irqreturn_t ct82c710_interrupt(int cpl, void *dev_id, struct pt_regs * regs);
 
 /*
  * Wait for device to send output char and flush any input char.
@@ -154,9 +154,9 @@
  * is waiting in the 82C710.
  */
 
-static void ct82c710_interrupt(int cpl, void *dev_id, struct pt_regs * regs)
+static irqreturn_t ct82c710_interrupt(int cpl, void *dev_id, struct pt_regs * regs)
 {
-	serio_interrupt(&ct82c710_port, inb(ct82c710_data), 0, regs);
+	return serio_interrupt(&ct82c710_port, inb(ct82c710_data), 0, regs);
 }
 
 /*
diff -Nru a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
--- a/drivers/input/serio/i8042.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/input/serio/i8042.c	Wed Apr 30 22:28:04 2003
@@ -74,7 +74,7 @@
 	 19, 25, 57, 81, 83, 92, 95, 98, 99,100,101,103,104,106,109,110
 };
 
-static void i8042_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t i8042_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 /*
  * The i8042_wait_read() and i8042_wait_write functions wait for the i8042 to
@@ -332,7 +332,7 @@
  * to the upper layers.
  */
 
-static void i8042_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t i8042_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	unsigned long flags;
 	unsigned char str, data;
@@ -415,6 +415,8 @@
 		serio_interrupt(&i8042_kbd_port, data, dfl, regs);
 	}
 
+	/* FIXME - was it really ours? */
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/input/serio/parkbd.c b/drivers/input/serio/parkbd.c
--- a/drivers/input/serio/parkbd.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/input/serio/parkbd.c	Wed Apr 30 22:28:04 2003
@@ -43,14 +43,14 @@
 #define PARKBD_CLOCK	0x01	/* Strobe & Ack */
 #define PARKBD_DATA	0x02	/* AutoFd & Busy */
 
-static int parkbd = 0;
+static int parkbd;
 static int parkbd_mode = SERIO_8042;
 
-static int parkbd_buffer = 0;
-static int parkbd_counter = 0;
-static int parkbd_last = 0;
-static int parkbd_writing = 0;
-static unsigned long parkbd_start = 0;
+static int parkbd_buffer;
+static int parkbd_counter;
+static unsigned long parkbd_last;
+static int parkbd_writing;
+static unsigned long parkbd_start;
 
 static struct pardevice *parkbd_dev;
 
diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/input/serio/serio.c	Wed Apr 30 22:28:03 2003
@@ -135,13 +135,20 @@
 	wake_up(&serio_wait);
 }
 
-void serio_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs)
-{       
-        if (serio->dev && serio->dev->interrupt) 
-                serio->dev->interrupt(serio, data, flags, regs);
-	else 
-		if (!flags)
+irqreturn_t serio_interrupt(struct serio *serio,
+		unsigned char data, unsigned int flags, struct pt_regs *regs)
+{
+	irqreturn_t ret = IRQ_NONE;
+
+        if (serio->dev && serio->dev->interrupt) {
+                ret = serio->dev->interrupt(serio, data, flags, regs);
+	} else {
+		if (!flags) {
 			serio_rescan(serio);
+			ret = IRQ_HANDLED;
+		}
+	}
+	return ret;
 }
 
 void serio_register_port(struct serio *serio)
diff -Nru a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
--- a/drivers/input/serio/serport.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/input/serio/serport.c	Wed Apr 30 22:28:16 2003
@@ -44,7 +44,7 @@
 static int serport_serio_write(struct serio *serio, unsigned char data)
 {
 	struct serport *serport = serio->driver;
-	return -(serport->tty->driver.write(serport->tty, 0, &data, 1) != 1);
+	return -(serport->tty->driver->write(serport->tty, 0, &data, 1) != 1);
 }
 
 static int serport_serio_open(struct serio *serio)
diff -Nru a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c
--- a/drivers/input/touchscreen/gunze.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/input/touchscreen/gunze.c	Wed Apr 30 22:28:07 2003
@@ -78,7 +78,8 @@
 	input_sync(dev);
 }
 
-static void gunze_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs)
+static irqreturn_t gunze_interrupt(struct serio *serio,
+		unsigned char data, unsigned int flags, struct pt_regs *regs)
 {
 	struct gunze* gunze = serio->private;
 
@@ -88,7 +89,8 @@
 	} else {
 		if (gunze->idx < GUNZE_MAX_LENGTH)
 			gunze->data[gunze->idx++] = data;
-	} 
+	}
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/input/tsdev.c b/drivers/input/tsdev.c
--- a/drivers/input/tsdev.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/input/tsdev.c	Wed Apr 30 22:28:18 2003
@@ -41,6 +41,7 @@
 #include <linux/random.h>
 #include <linux/time.h>
 #include <linux/device.h>
+#include <linux/devfs_fs_kernel.h>
 
 #ifndef CONFIG_INPUT_TSDEV_SCREEN_X
 #define CONFIG_INPUT_TSDEV_SCREEN_X	240
@@ -57,7 +58,6 @@
 	wait_queue_head_t wait;
 	struct list_head list;
 	struct input_handle handle;
-	devfs_handle_t devfs;
 };
 
 /* From Compaq's Touch Screen Specification version 0.2 (draft) */
@@ -115,6 +115,13 @@
 	return 0;
 }
 
+static void tsdev_free(struct tsdev *tsdev)
+{
+	devfs_remove("input/ts%d", tsdev->minor);
+	tsdev_table[tsdev->minor] = NULL;
+	kfree(tsdev);
+}
+
 static int tsdev_release(struct inode *inode, struct file *file)
 {
 	struct tsdev_list *list = file->private_data;
@@ -123,13 +130,10 @@
 	list_del(&list->node);
 
 	if (!--list->tsdev->open) {
-		if (list->tsdev->exist) {
+		if (list->tsdev->exist)
 			input_close_device(&list->tsdev->handle);
-		} else {
-			input_unregister_minor(list->tsdev->devfs);
-			tsdev_table[list->tsdev->minor] = NULL;
-			kfree(list->tsdev);
-		}
+		else
+			tsdev_free(list->tsdev);
 	}
 	kfree(list);
 	return 0;
@@ -325,8 +329,7 @@
 	tsdev->handle.private = tsdev;
 
 	tsdev_table[minor] = tsdev;
-	tsdev->devfs =
-	    input_register_minor("input/ts%d", minor, TSDEV_MINOR_BASE);
+	input_register_minor("input/ts%d", minor, TSDEV_MINOR_BASE);
 
 
 	return &tsdev->handle;
@@ -341,11 +344,8 @@
 	if (tsdev->open) {
 		input_close_device(handle);
 		wake_up_interruptible(&tsdev->wait);
-	} else {
-		input_unregister_minor(tsdev->devfs);
-		tsdev_table[tsdev->minor] = NULL;
-		kfree(tsdev);
-	}
+	} else
+		tsdev_free(tsdev);
 }
 
 static struct input_device_id tsdev_ids[] = {
@@ -378,19 +378,8 @@
 	.id_table =	tsdev_ids,
 };
 
-static struct device_interface tsdev_intf = {
-	.name		= "touchscreen",
-	.devclass	= &input_devclass,
-};
-
 static int __init tsdev_init(void)
 {
-	int retval;
-
-	retval = interface_register(&tsdev_intf);
-	if(retval < 0)
-		return retval;
-
 	input_register_handler(&tsdev_handler);
 	printk(KERN_INFO "ts: Compaq touchscreen protocol output\n");
 	return 0;
@@ -399,7 +388,6 @@
 static void __exit tsdev_exit(void)
 {
 	input_unregister_handler(&tsdev_handler);
-	interface_unregister(&tsdev_intf);
 }
 
 module_init(tsdev_init);
diff -Nru a/drivers/isdn/act2000/act2000_isa.c b/drivers/isdn/act2000/act2000_isa.c
--- a/drivers/isdn/act2000/act2000_isa.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/isdn/act2000/act2000_isa.c	Wed Apr 30 22:28:08 2003
@@ -69,7 +69,7 @@
         return ret;
 }
 
-static void
+static irqreturn_t
 act2000_isa_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
         act2000_card *card = irq2card_map[irq];
@@ -78,7 +78,7 @@
         if (!card) {
                 printk(KERN_WARNING
                        "act2000: Spurious interrupt!\n");
-                return;
+                return IRQ_NONE;
         }
         istatus = (inb(ISA_PORT_ISR) & 0x07);
         if (istatus & ISA_ISR_OUT) {
@@ -95,6 +95,7 @@
         }
 	if (istatus)
 		printk(KERN_DEBUG "act2000: ?IRQ %d %02x\n", irq, istatus);
+	return IRQ_HANDLED;
 }
 
 static void
diff -Nru a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
--- a/drivers/isdn/capi/capi.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/isdn/capi/capi.c	Wed Apr 30 22:28:18 2003
@@ -278,7 +278,6 @@
 	struct capincci *np, **pp;
 #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
 	struct capiminor *mp = 0;
-	kdev_t kdev;
 #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */
 
 	np = kmalloc(sizeof(*np), GFP_ATOMIC);
@@ -297,8 +296,7 @@
 		printk(KERN_DEBUG "set mp->nccip\n");
 #endif
 #if defined(CONFIG_ISDN_CAPI_CAPIFS) || defined(CONFIG_ISDN_CAPI_CAPIFS_MODULE)
-		kdev = mk_kdev(capi_ttymajor, mp->minor);
-		capifs_new_ncci(0, mp->minor, kdev);
+		capifs_new_ncci(0, mp->minor, MKDEV(capi_ttymajor, mp->minor));
 #endif
 	}
 #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */
@@ -1283,7 +1281,7 @@
 	memset(drv, 0, sizeof(struct tty_driver));
 	drv->magic = TTY_DRIVER_MAGIC;
 	drv->driver_name = "capi_nc";
-	drv->name = "capi/%d";
+	drv->name = "capi/";
 	drv->major = capi_ttymajor;
 	drv->minor_start = 0;
 	drv->num = CAPINC_NR_PORTS;
diff -Nru a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c
--- a/drivers/isdn/capi/capidrv.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/isdn/capi/capidrv.c	Wed Apr 30 22:28:08 2003
@@ -1985,7 +1985,7 @@
 static int capidrv_addcontr(u16 contr, struct capi_profile *profp)
 {
 	capidrv_contr *card;
-	long flags;
+	unsigned long flags;
 	isdn_ctrl cmd;
 	char id[20];
 	int i;
diff -Nru a/drivers/isdn/capi/capifs.c b/drivers/isdn/capi/capifs.c
--- a/drivers/isdn/capi/capifs.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/isdn/capi/capifs.c	Wed Apr 30 22:28:06 2003
@@ -9,24 +9,12 @@
  *
  */
 
-#include <linux/version.h>
 #include <linux/fs.h>
-#include <linux/tty.h>
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/stat.h>
-#include <linux/param.h>
+#include <linux/mount.h>
+#include <linux/namei.h>
 #include <linux/module.h>
-#include <linux/string.h>
 #include <linux/init.h>
-#include <linux/kdev_t.h>
-#include <linux/kernel.h>
-#include <linux/major.h>
-#include <linux/slab.h>
 #include <linux/ctype.h>
-#include <linux/smp_lock.h>
-#include <asm/bitops.h>
-#include <asm/uaccess.h>
 
 MODULE_DESCRIPTION("CAPI4Linux: /dev/capi/ filesystem");
 MODULE_AUTHOR("Carsten Paeth");
@@ -34,209 +22,33 @@
 
 static char *revision = "$Revision: 1.14.6.8 $";
 
-struct capifs_ncci {
-	struct inode *inode;
-	char used;
-	char type;
-	unsigned int num;
-	kdev_t kdev;
-};
-
-struct capifs_sb_info {
-	u32 magic;
-	struct super_block *next;
-	struct super_block **back;
+struct options {
 	int setuid;
 	int setgid;
 	uid_t   uid;
 	gid_t   gid;
 	umode_t mode;
-
-	unsigned int max_ncci;
-	struct capifs_ncci *nccis;
 };
+static struct options options = {.mode = 0600};
 
 #define CAPIFS_SUPER_MAGIC (('C'<<8)|'N')
-#define CAPIFS_SBI_MAGIC   (('C'<<24)|('A'<<16)|('P'<<8)|'I')
-
-static inline struct capifs_sb_info *SBI(struct super_block *sb)
-{
-	return (struct capifs_sb_info *)(sb->s_fs_info);
-}
-
-/* ------------------------------------------------------------------ */
-
-static int capifs_root_readdir(struct file *,void *,filldir_t);
-static struct dentry *capifs_root_lookup(struct inode *,struct dentry *);
-static int capifs_revalidate(struct dentry *, int);
-static struct inode *capifs_new_inode(struct super_block *sb);
-
-static struct file_operations capifs_root_operations = {
-	.read		= generic_read_dir,
-	.readdir	= capifs_root_readdir,
-};
-
-struct inode_operations capifs_root_inode_operations = {
-	.lookup = capifs_root_lookup,
-};
-
-static struct dentry_operations capifs_dentry_operations = {
-	.d_revalidate = capifs_revalidate,
-};
-
-/*
- * /dev/capi/%d
- * /dev/capi/r%d
- */
-
-static int capifs_root_readdir(struct file *filp, void *dirent, filldir_t filldir)
-{
-	struct inode * inode = filp->f_dentry->d_inode;
-	struct capifs_sb_info * sbi = SBI(filp->f_dentry->d_inode->i_sb);
-	off_t nr;
-	char numbuf[32];
-
-	lock_kernel();
-
-	nr = filp->f_pos;
-
-	switch(nr)
-	{
-	case 0:
-		if (filldir(dirent, ".", 1, nr, inode->i_ino, DT_DIR) < 0)
-			goto out;
-		filp->f_pos = ++nr;
-		/* fall through */
-	case 1:
-		if (filldir(dirent, "..", 2, nr, inode->i_ino, DT_DIR) < 0)
-			goto out;
-		filp->f_pos = ++nr;
-		/* fall through */
-	default:
-		while (nr < sbi->max_ncci) {
-			int n = nr - 2;
-			struct capifs_ncci *np = &sbi->nccis[n];
-			if (np->inode && np->used) {
-				char *p = numbuf;
-				if (np->type) *p++ = np->type;
-				sprintf(p, "%u", np->num);
-				if ( filldir(dirent, numbuf, strlen(numbuf), nr, nr, DT_UNKNOWN) < 0 )
-					goto out;
-			}
-			filp->f_pos = ++nr;
-		}
-		break;
-	}
-
-out:
-	unlock_kernel();
-	return 0;
-}
-
-/*
- * Revalidate is called on every cache lookup.  We use it to check that
- * the ncci really does still exist.  Never revalidate negative dentries;
- * for simplicity (fix later?)
- */
-static int capifs_revalidate(struct dentry * dentry, int flags)
-{
-	struct capifs_sb_info *sbi;
-
-	if ( !dentry->d_inode )
-		return 0;
-
-	sbi = SBI(dentry->d_inode->i_sb);
-
-	return ( sbi->nccis[dentry->d_inode->i_ino - 2].inode == dentry->d_inode );
-}
-
-static struct dentry *capifs_root_lookup(struct inode * dir, struct dentry * dentry)
-{
-	struct capifs_sb_info *sbi = SBI(dir->i_sb);
-	struct capifs_ncci *np;
-	unsigned int i;
-	char numbuf[32];
-	char *p, *tmp;
-	unsigned int num;
-	char type = 0;
-
-	dentry->d_inode = NULL;	/* Assume failure */
-	dentry->d_op    = &capifs_dentry_operations;
-
-	if (dentry->d_name.len >= sizeof(numbuf) )
-		return NULL;
-	strncpy(numbuf, dentry->d_name.name, dentry->d_name.len);
-	numbuf[dentry->d_name.len] = 0;
-        p = numbuf;
-	if (!isdigit(*p)) type = *p++;
-	tmp = p;
-	num = (unsigned int)simple_strtoul(p, &tmp, 10);
-	if (tmp == p || *tmp)
-		return NULL;
-
-	lock_kernel();
-	for (i = 0, np = sbi->nccis ; i < sbi->max_ncci; i++, np++) {
-		if (np->used && np->num == num && np->type == type)
-			break;
-	}
-	unlock_kernel();
-
-	if ( i >= sbi->max_ncci )
-		return NULL;
-
-	dentry->d_inode = np->inode;
-	if ( dentry->d_inode )
-		atomic_inc(&dentry->d_inode->i_count);
-	
-	d_add(dentry, dentry->d_inode);
-
-	return NULL;
-}
 
 /* ------------------------------------------------------------------ */
 
-static struct super_block *mounts = NULL;
-
-static void capifs_put_super(struct super_block *sb)
-{
-	struct capifs_sb_info *sbi = SBI(sb);
-	struct inode *inode;
-	int i;
-
-	for ( i = 0 ; i < sbi->max_ncci ; i++ ) {
-		if ( (inode = sbi->nccis[i].inode) ) {
-			if (atomic_read(&inode->i_count) != 1 )
-				printk("capifs_put_super: badness: entry %d count %d\n",
-				       i, (unsigned)atomic_read(&inode->i_count));
-			inode->i_nlink--;
-			iput(inode);
-		}
-	}
-
-	*sbi->back = sbi->next;
-	if ( sbi->next )
-		SBI(sbi->next)->back = sbi->back;
-
-	kfree(sbi->nccis);
-	kfree(sbi);
-}
 
-static struct super_operations capifs_sops = {
-	.put_super	= capifs_put_super,
-	.statfs		= simple_statfs,
-};
-
-static int capifs_parse_options(char *options, struct capifs_sb_info *sbi)
+static int capifs_parse_options(char *s, struct options *p)
 {
 	int setuid = 0;
 	int setgid = 0;
 	uid_t uid = 0;
 	gid_t gid = 0;
 	umode_t mode = 0600;
-	unsigned int maxncci = 512;
 	char *this_char, *value;
 
-	while ((this_char = strsep(&options,",")) != NULL) {
+	if (!s)
+		return 0;
+
+	while ((this_char = strsep(&s, ",")) != NULL) {
 		if (!*this_char)
 			continue;
 		if ((value = strchr(this_char,'=')) != NULL)
@@ -264,110 +76,74 @@
 			if (*value)
 				return 1;
 		}
-		else if (!strcmp(this_char,"maxncci")) {
-			if (!value || !*value)
-				return 1;
-			maxncci = simple_strtoul(value,&value,8);
-			if (*value)
-				return 1;
-		}
-		else
-			return 1;
 	}
-	sbi->setuid   = setuid;
-	sbi->setgid   = setgid;
-	sbi->uid      = uid;
-	sbi->gid      = gid;
-	sbi->mode     = mode & ~S_IFMT;
-	sbi->max_ncci = maxncci;
+	p->setuid   = setuid;
+	p->setgid   = setgid;
+	p->uid      = uid;
+	p->gid      = gid;
+	p->mode     = mode & ~S_IFMT;
 
 	return 0;
 }
 
-static int capifs_fill_super(struct super_block *s, void *data, int silent)
+static int capifs_remount(struct super_block *s, int *flags, char *data)
 {
-	struct inode * root_inode;
-	struct dentry * root;
-	struct capifs_sb_info *sbi;
-
-	sbi = (struct capifs_sb_info *) kmalloc(sizeof(struct capifs_sb_info), GFP_KERNEL);
-	if ( !sbi )
-		goto fail;
-
-	memset(sbi, 0, sizeof(struct capifs_sb_info));
-	sbi->magic  = CAPIFS_SBI_MAGIC;
-
-	if ( capifs_parse_options(data,sbi) ) {
-		kfree(sbi);
+	struct options new;
+	if (capifs_parse_options(data, &new)) {
 		printk("capifs: called with bogus options\n");
-		goto fail;
+		return -EINVAL;
 	}
+	options = new;
+	return 0;
+}
+
+
+static struct super_operations capifs_sops =
+{
+	.statfs		= simple_statfs,
+	.remount_fs	= capifs_remount,
+};
+
+static int capifs_fill_super(struct super_block *s, void *data, int silent)
+{
+	struct inode * inode;
 
-	sbi->nccis = kmalloc(sizeof(struct capifs_ncci) * sbi->max_ncci, GFP_KERNEL);
-	if ( !sbi->nccis ) {
-		kfree(sbi);
-		goto fail;
+	if (capifs_parse_options(data, &options)) {
+		printk("capifs: called with bogus options\n");
+		return -EINVAL;
 	}
-	memset(sbi->nccis, 0, sizeof(struct capifs_ncci) * sbi->max_ncci);
 
-	s->s_fs_info = (void *) sbi;
 	s->s_blocksize = 1024;
 	s->s_blocksize_bits = 10;
 	s->s_magic = CAPIFS_SUPER_MAGIC;
 	s->s_op = &capifs_sops;
 
-	/*
-	 * Get the root inode and dentry, but defer checking for errors.
-	 */
-	root_inode = capifs_new_inode(s);
-	if (root_inode) {
-		root_inode->i_ino = 1;
-		root_inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
-		root_inode->i_op = &capifs_root_inode_operations;
-		root_inode->i_fop = &capifs_root_operations;
-		root_inode->i_nlink = 2;
-	} 
-	root = d_alloc_root(root_inode);
+	inode = new_inode(s);
+	if (!inode)
+		return -ENOMEM;
+	inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
+	inode->i_blocks = 0;
+	inode->i_blksize = 1024;
+	inode->i_uid = inode->i_gid = 0;
+	inode->i_ino = 1;
+	inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
+	inode->i_op = &simple_dir_inode_operations;
+	inode->i_fop = &simple_dir_operations;
+	inode->i_nlink = 2;
+	s->s_root = d_alloc_root(inode);
 
-	if (!root) {
+	if (!s->s_root) {
 		printk("capifs: get root dentry failed\n");
-		/*
-	 	* iput() can block, so we clear the super block first.
-	 	*/
-		iput(root_inode);
-		kfree(sbi->nccis);
-		kfree(sbi);
-		goto fail;
+		iput(inode);
+		return -ENOMEM;
 	}
-
-	s->s_root = root;
-
-	sbi->next = mounts;
-	if ( sbi->next )
-		SBI(sbi->next)->back = &(sbi->next);
-	sbi->back = &mounts;
-	mounts = s;
 	return 0;
-fail:
-	return -EINVAL;
-}
-
-static struct inode *capifs_new_inode(struct super_block *sb)
-{
-	struct inode *inode = new_inode(sb);
-	if (inode) {
-		inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
-		inode->i_blocks = 0;
-		inode->i_blksize = 1024;
-		inode->i_uid = inode->i_gid = 0;
-	}
-	return inode;
 }
 
 static struct super_block *capifs_get_sb(struct file_system_type *fs_type,
 	int flags, char *dev_name, void *data)
 {
-	return get_sb_nodev(fs_type, flags, data, capifs_fill_super);
+	return get_sb_single(fs_type, flags, data, capifs_fill_super);
 }
 
 static struct file_system_type capifs_fs_type = {
@@ -377,62 +153,77 @@
 	.kill_sb	= kill_anon_super,
 };
 
-void capifs_new_ncci(char type, unsigned int num, kdev_t device)
+static struct vfsmount *capifs_mnt;
+static int entry_count;
+
+static int grab_instance(void)
 {
-	struct super_block *sb;
-	struct capifs_sb_info *sbi;
-	struct capifs_ncci *np;
-	ino_t ino;
-
-	for ( sb = mounts ; sb ; sb = sbi->next ) {
-		sbi = SBI(sb);
-
-		for (ino = 0, np = sbi->nccis ; ino < sbi->max_ncci; ino++, np++) {
-			if (np->used == 0) {
-				np->used = 1;
-				np->type = type;
-				np->num = num;
-				np->kdev = device;
-				break;
-			}
-		}
-		if ( ino >= sbi->max_ncci )
-			continue;
+	return simple_pin_fs("capifs", &capifs_mnt, &entry_count);
+}
 
-		if ((np->inode = capifs_new_inode(sb)) != NULL) {
-			struct inode *inode = np->inode;
-			inode->i_uid = sbi->setuid ? sbi->uid : current->fsuid;
-			inode->i_gid = sbi->setgid ? sbi->gid : current->fsgid;
-			inode->i_nlink = 1;
-			inode->i_ino = ino + 2;
-			init_special_inode(inode, sbi->mode|S_IFCHR, kdev_t_to_nr(np->kdev));
-		}
-	}
+static void drop_instance(void)
+{
+	return simple_release_fs(&capifs_mnt, &entry_count);
 }
 
-void capifs_free_ncci(char type, unsigned int num)
+static struct dentry *get_node(int type, int num)
+{
+	char s[10];
+	int len;
+	struct dentry *root = capifs_mnt->mnt_root;
+	if (type)
+		len = sprintf(s, "%d", num);
+	else
+		len = sprintf(s, "%c%d", type, num);
+	down(&root->d_inode->i_sem);
+	return lookup_one_len(s, root, len);
+}
+
+void capifs_new_ncci(char type, unsigned int num, dev_t device)
 {
 	struct super_block *sb;
-	struct capifs_sb_info *sbi;
+	struct dentry *dentry;
 	struct inode *inode;
-	struct capifs_ncci *np;
-	ino_t ino;
 
-	for ( sb = mounts ; sb ; sb = sbi->next ) {
-		sbi = SBI(sb);
+	if (grab_instance() < 0)
+		return;
+	sb = capifs_mnt->mnt_sb;
+	inode = new_inode(sb);
+	if (inode) {
+		inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
+		inode->i_blocks = 0;
+		inode->i_blksize = 1024;
+		inode->i_uid = options.setuid ? options.uid : current->fsuid;
+		inode->i_gid = options.setgid ? options.gid : current->fsgid;
+		inode->i_nlink = 1;
+		init_special_inode(inode, S_IFCHR | options.mode, device);
+		dentry = get_node(type, num);
+		if (!IS_ERR(dentry) && !dentry->d_inode) {
+			grab_instance();
+			d_instantiate(dentry, inode);
+		} else
+			iput(inode);
+		up(&sb->s_root->d_inode->i_sem);
+	}
+	drop_instance();
+}
 
-		for (ino = 0, np = sbi->nccis ; ino < sbi->max_ncci; ino++, np++) {
-			if (!np->used || np->type != type || np->num != num)
-				continue;
-			if (np->inode) {
-				inode = np->inode;
-				np->inode = 0;
-				np->used = 0;
+void capifs_free_ncci(char type, unsigned int num)
+{
+	if (grab_instance() == 0) {
+		struct dentry *dentry = get_node(type, num);
+		if (!IS_ERR(dentry)) {
+			struct inode *inode = dentry->d_inode;
+			if (inode) {
 				inode->i_nlink--;
-				iput(inode);
-				break;
+				d_delete(dentry);
+				dput(dentry);
+				drop_instance();
 			}
+			dput(dentry);
 		}
+		up(&capifs_mnt->mnt_root->d_inode->i_sem);
+		drop_instance();
 	}
 }
 
@@ -442,8 +233,6 @@
 	char *p;
 	int err;
 
-	MOD_INC_USE_COUNT;
-
 	if ((p = strchr(revision, ':')) != 0 && p[1]) {
 		strncpy(rev, p + 2, sizeof(rev));
 		rev[sizeof(rev)-1] = 0;
@@ -453,12 +242,8 @@
 		strcpy(rev, "1.0");
 
 	err = register_filesystem(&capifs_fs_type);
-	if (err) {
-		MOD_DEC_USE_COUNT;
-		return err;
-	}
-        printk(KERN_NOTICE "capifs: Rev %s\n", rev);
-	MOD_DEC_USE_COUNT;
+	if (!err)
+		printk(KERN_NOTICE "capifs: Rev %s\n", rev);
 	return 0;
 }
 
diff -Nru a/drivers/isdn/capi/capifs.h b/drivers/isdn/capi/capifs.h
--- a/drivers/isdn/capi/capifs.h	Wed Apr 30 22:28:05 2003
+++ b/drivers/isdn/capi/capifs.h	Wed Apr 30 22:28:05 2003
@@ -7,5 +7,5 @@
  *
  */
 
-void capifs_new_ncci(char type, unsigned int num, kdev_t device);
+void capifs_new_ncci(char type, unsigned int num, dev_t device);
 void capifs_free_ncci(char type, unsigned int num);
diff -Nru a/drivers/isdn/eicon/eicon.h b/drivers/isdn/eicon/eicon.h
--- a/drivers/isdn/eicon/eicon.h	Wed Apr 30 22:28:06 2003
+++ b/drivers/isdn/eicon/eicon.h	Wed Apr 30 22:28:06 2003
@@ -14,6 +14,8 @@
 #ifndef eicon_h
 #define eicon_h
 
+#include <linux/interrupt.h>
+
 #define EICON_IOCTL_SETMMIO   0
 #define EICON_IOCTL_GETMMIO   1
 #define EICON_IOCTL_SETIRQ    2
@@ -364,7 +366,7 @@
 
 extern int eicon_addcard(int, int, int, char *, int);
 extern void eicon_io_transmit(eicon_card *card);
-extern void eicon_irq(int irq, void *dev_id, struct pt_regs *regs);
+extern irqreturn_t eicon_irq(int irq, void *dev_id, struct pt_regs *regs);
 extern void eicon_io_rcv_dispatch(eicon_card *ccard);
 extern void eicon_io_ack_dispatch(eicon_card *ccard);
 #ifdef CONFIG_MCA
diff -Nru a/drivers/isdn/eicon/eicon_idi.c b/drivers/isdn/eicon/eicon_idi.c
--- a/drivers/isdn/eicon/eicon_idi.c	Wed Apr 30 22:28:02 2003
+++ b/drivers/isdn/eicon/eicon_idi.c	Wed Apr 30 22:28:02 2003
@@ -3097,7 +3097,7 @@
 {
 	int l = 0;
 	int ret = 0;
-	int timeout;
+	unsigned long timeout;
 	int i;
         struct sk_buff *skb;
         struct sk_buff *skb2;
diff -Nru a/drivers/isdn/eicon/eicon_io.c b/drivers/isdn/eicon/eicon_io.c
--- a/drivers/isdn/eicon/eicon_io.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/isdn/eicon/eicon_io.c	Wed Apr 30 22:28:06 2003
@@ -501,7 +501,7 @@
 /*
  * IRQ handler 
  */
-void
+irqreturn_t
 eicon_irq(int irq, void *dev_id, struct pt_regs *regs) {
 	eicon_card *ccard = (eicon_card *)dev_id;
         eicon_isa_card *isa_card;
@@ -521,7 +521,7 @@
 
         if (!ccard) {
                 eicon_log(ccard, 1, "eicon_irq: spurious interrupt %d\n", irq);
-                return;
+                return IRQ_NONE;
         }
 
 	if (ccard->type == EICON_CTYPE_QUADRO) {
@@ -554,7 +554,7 @@
 			break;
 		default:
                 	eicon_log(ccard, 1, "eicon_irq: unsupported card-type!\n");
-			return;
+			return IRQ_NONE;
 	}
 
 	if (*irqprobe) {
@@ -577,7 +577,7 @@
 				(*irqprobe)++;
 				break;
 		}
-		return;
+		return IRQ_HANDLED;
 	}
 
 	switch(ccard->type) {
@@ -588,7 +588,7 @@
 		case EICON_CTYPE_S2M:
 			if (!(readb(isa_card->intack))) { /* card did not interrupt */
 				eicon_log(ccard, 1, "eicon: IRQ: card reports no interrupt!\n");
-				return;
+				return IRQ_NONE;
 			} 
 			break;
 	}
@@ -744,6 +744,6 @@
 			break;
 	}
 
-  return;
+  return IRQ_HANDLED;
 }
 #endif
diff -Nru a/drivers/isdn/eicon/linio.c b/drivers/isdn/eicon/linio.c
--- a/drivers/isdn/eicon/linio.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/isdn/eicon/linio.c	Wed Apr 30 22:28:06 2003
@@ -36,7 +36,7 @@
 
 void UxPause(long int ms)
 {
-	int timeout = jiffies + ((ms * HZ) / 1000);
+	unsigned long timeout = jiffies + ((ms * HZ) / 1000);
 
 	while (time_before(jiffies, timeout));
 }
@@ -577,7 +577,7 @@
     return;
 }
 
-void 	Divasintr(int arg, void *unused, struct pt_regs *unused_regs)
+irqreturn_t Divasintr(int arg, void *unused, struct pt_regs *unused_regs)
 {
 	int i;
 	card_t *card = NULL;
@@ -602,7 +602,7 @@
 		}
 	}
 
-	return;
+	return IRQ_HANDLED;
 }
 
 
@@ -680,7 +680,7 @@
 	return flags;
 }
 
-void UxCardUnlock(ux_diva_card_t *card, long ipl)
+void UxCardUnlock(ux_diva_card_t *card, unsigned long ipl)
 {
 	spin_unlock_irqrestore(&diva_lock, ipl);
 }
diff -Nru a/drivers/isdn/eicon/uxio.h b/drivers/isdn/eicon/uxio.h
--- a/drivers/isdn/eicon/uxio.h	Wed Apr 30 22:28:04 2003
+++ b/drivers/isdn/eicon/uxio.h	Wed Apr 30 22:28:04 2003
@@ -59,7 +59,7 @@
  */
 
 long		UxCardLock(ux_diva_card_t *card);
-void	UxCardUnlock(ux_diva_card_t *card, long ipl);
+void	UxCardUnlock(ux_diva_card_t *card, unsigned long ipl);
 
 /*
  * Set the mapping address for PCI cards
diff -Nru a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c
--- a/drivers/isdn/hardware/avm/avm_cs.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/isdn/hardware/avm/avm_cs.c	Wed Apr 30 22:28:03 2003
@@ -118,14 +118,6 @@
     dev_node_t	node;
 } local_info_t;
 
-/*====================================================================*/
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
 /*======================================================================
 
     avmcs_attach() creates an "instance" of the driver, allocating
diff -Nru a/drivers/isdn/hardware/avm/avmcard.h b/drivers/isdn/hardware/avm/avmcard.h
--- a/drivers/isdn/hardware/avm/avmcard.h	Wed Apr 30 22:28:16 2003
+++ b/drivers/isdn/hardware/avm/avmcard.h	Wed Apr 30 22:28:16 2003
@@ -12,6 +12,7 @@
 
 #include <linux/spinlock.h>
 #include <linux/list.h>
+#include <linux/interrupt.h>
 
 #define	AVMB1_PORTLEN		0x1f
 #define AVM_MAXVERSION		8
@@ -555,7 +556,7 @@
 void b1_release_appl(struct capi_ctr *ctrl, u16 appl);
 u16  b1_send_message(struct capi_ctr *ctrl, struct sk_buff *skb);
 void b1_parse_version(avmctrl_info *card);
-void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs);
+irqreturn_t b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs);
 
 int b1ctl_read_proc(char *page, char **start, off_t off,
         		int count, int *eof, struct capi_ctr *ctrl);
@@ -568,7 +569,7 @@
 int b1pciv4_detect(avmcard *card);
 int t1pci_detect(avmcard *card);
 void b1dma_reset(avmcard *card);
-void b1dma_interrupt(int interrupt, void *devptr, struct pt_regs *regs);
+irqreturn_t b1dma_interrupt(int interrupt, void *devptr, struct pt_regs *regs);
 
 int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data);
 void b1dma_reset_ctr(struct capi_ctr *ctrl);
diff -Nru a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
--- a/drivers/isdn/hardware/avm/b1.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/isdn/hardware/avm/b1.c	Wed Apr 30 22:28:16 2003
@@ -491,7 +491,7 @@
 
 /* ------------------------------------------------------------- */
 
-void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
+irqreturn_t b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
 {
 	avmcard *card = devptr;
 	avmctrl_info *cinfo = &card->ctrlinfo[0];
@@ -506,7 +506,7 @@
 	unsigned WindowSize;
 
 	if (!b1_rx_full(card->port))
-	   return;
+	   return IRQ_NONE;
 
 	b1cmd = b1_get_byte(card->port);
 
@@ -619,12 +619,13 @@
 
 	case 0xff:
 		printk(KERN_ERR "%s: card removed ?\n", card->name);
-		return;
+		return IRQ_NONE;
 	default:
 		printk(KERN_ERR "%s: b1_interrupt: 0x%x ???\n",
 				card->name, b1cmd);
-		return;
+		return IRQ_HANDLED;
 	}
+	return IRQ_HANDLED;
 }
 
 /* ------------------------------------------------------------- */
diff -Nru a/drivers/isdn/hardware/avm/b1dma.c b/drivers/isdn/hardware/avm/b1dma.c
--- a/drivers/isdn/hardware/avm/b1dma.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/isdn/hardware/avm/b1dma.c	Wed Apr 30 22:28:12 2003
@@ -618,11 +618,12 @@
 	spin_unlock(&card->lock);
 }
 
-void b1dma_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
+irqreturn_t b1dma_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
 {
 	avmcard *card = devptr;
 
 	b1dma_handle_interrupt(card);
+	return IRQ_HANDLED;
 }
 
 /* ------------------------------------------------------------- */
diff -Nru a/drivers/isdn/hardware/avm/c4.c b/drivers/isdn/hardware/avm/c4.c
--- a/drivers/isdn/hardware/avm/c4.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/isdn/hardware/avm/c4.c	Wed Apr 30 22:28:10 2003
@@ -659,7 +659,7 @@
 
 /* ------------------------------------------------------------- */
 
-static void c4_handle_interrupt(avmcard *card)
+static irqreturn_t c4_handle_interrupt(avmcard *card)
 {
 	u32 status = c4inmeml(card->mbase+DOORBELL);
 
@@ -667,7 +667,7 @@
 		int i;
 		c4outmeml(card->mbase+PCI_OUT_INT_MASK, 0x0c);
 		if (card->nlogcontr == 0)
-			return;
+			return IRQ_HANDLED;
 		printk(KERN_ERR "%s: unexpected reset\n", card->name);
                 for (i=0; i < card->nr_controllers; i++) {
 			avmctrl_info *cinfo = &card->ctrlinfo[i];
@@ -676,12 +676,12 @@
 			capi_ctr_reseted(&cinfo->capi_ctrl);
 		}
 		card->nlogcontr = 0;
-		return;
+		return IRQ_HANDLED;
 	}
 
 	status &= (DBELL_UP_HOST | DBELL_DOWN_HOST);
 	if (!status)
-		return;
+		return IRQ_HANDLED;
 	c4outmeml(card->mbase+DOORBELL, status);
 
 	if ((status & DBELL_UP_HOST) != 0) {
@@ -702,13 +702,14 @@
 			c4_dispatch_tx(card);
 		}
 	}
+	return IRQ_HANDLED;
 }
 
-static void c4_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
+static irqreturn_t c4_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
 {
 	avmcard *card = devptr;
 
-	c4_handle_interrupt(card);
+	return c4_handle_interrupt(card);
 }
 
 /* ------------------------------------------------------------- */
diff -Nru a/drivers/isdn/hardware/avm/t1isa.c b/drivers/isdn/hardware/avm/t1isa.c
--- a/drivers/isdn/hardware/avm/t1isa.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/isdn/hardware/avm/t1isa.c	Wed Apr 30 22:28:10 2003
@@ -124,7 +124,7 @@
         return 0;
 }
 
-static void t1isa_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
+static irqreturn_t t1isa_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
 {
 	avmcard *card = devptr;
 	avmctrl_info *cinfo = &card->ctrlinfo[0];
@@ -252,13 +252,14 @@
 
 		case 0xff:
 			printk(KERN_ERR "%s: card reseted ?\n", card->name);
-			return;
+			return IRQ_HANDLED;
 		default:
 			printk(KERN_ERR "%s: b1_interrupt: 0x%x ???\n",
 					card->name, b1cmd);
-			return;
+			return IRQ_NONE;
 		}
 	}
+	return IRQ_HANDLED;
 }
 
 /* ------------------------------------------------------------- */
diff -Nru a/drivers/isdn/hardware/eicon/diva.c b/drivers/isdn/hardware/eicon/diva.c
--- a/drivers/isdn/hardware/eicon/diva.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/isdn/hardware/eicon/diva.c	Wed Apr 30 22:28:15 2003
@@ -509,22 +509,23 @@
 }
 
 
-void diva_os_irq_wrapper(int irq, void *context, struct pt_regs *regs)
+irqreturn_t diva_os_irq_wrapper(int irq, void *context, struct pt_regs *regs)
 {
 	diva_os_xdi_adapter_t *a = (diva_os_xdi_adapter_t *) context;
 	diva_xdi_clear_interrupts_proc_t clear_int_proc;
 
 	if (!a || !a->xdi_adapter.diva_isr_handler) {
-		return;
+		return IRQ_NONE;
 	}
 
 	if ((clear_int_proc = a->clear_interrupts_proc)) {
 		(*clear_int_proc) (a);
 		a->clear_interrupts_proc = 0;
-		return;
+		return IRQ_HANDLED;
 	}
 
 	(*(a->xdi_adapter.diva_isr_handler)) (&a->xdi_adapter);
+	return IRQ_HANDLED;
 }
 
 static void diva_init_request_array(void)
diff -Nru a/drivers/isdn/hardware/eicon/divasmain.c b/drivers/isdn/hardware/eicon/divasmain.c
--- a/drivers/isdn/hardware/eicon/divasmain.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/isdn/hardware/eicon/divasmain.c	Wed Apr 30 22:28:05 2003
@@ -61,7 +61,7 @@
 static char *DRIVERLNAME = "divas";
 char *DRIVERRELEASE = "2.0";
 
-extern void diva_os_irq_wrapper(int irq, void *context,
+extern irqreturn_t diva_os_irq_wrapper(int irq, void *context,
 				struct pt_regs *regs);
 extern int create_divas_proc(void);
 extern void remove_divas_proc(void);
diff -Nru a/drivers/isdn/hisax/avm_a1.c b/drivers/isdn/hisax/avm_a1.c
--- a/drivers/isdn/hisax/avm_a1.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/isdn/hisax/avm_a1.c	Wed Apr 30 22:28:04 2003
@@ -113,14 +113,16 @@
 	.write_fifo = hscx_write_fifo,
 };
 
-static void
+static irqreturn_t
 avm_a1_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
 	u8 val, sval;
+	int handled = 0;
 
 	spin_lock(&cs->lock);
 	while (((sval = bytein(cs->hw.avm.cfg_reg)) & 0xf) != 0x7) {
+		handled = 1;
 		if (!(sval & AVM_A1_STAT_TIMER)) {
 			byteout(cs->hw.avm.cfg_reg, 0x1E);
 			sval = bytein(cs->hw.avm.cfg_reg);
@@ -144,6 +146,7 @@
 	hscx_write(cs, 0, HSCX_MASK, 0x0);
 	hscx_write(cs, 1, HSCX_MASK, 0x0);
 	spin_unlock(&cs->lock);
+	return IRQ_RETVAL(handled);
 }
 
 static void
diff -Nru a/drivers/isdn/hisax/avm_a1p.c b/drivers/isdn/hisax/avm_a1p.c
--- a/drivers/isdn/hisax/avm_a1p.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/isdn/hisax/avm_a1p.c	Wed Apr 30 22:28:20 2003
@@ -159,7 +159,7 @@
 	.write_fifo = hscx_write_fifo,
 };
 
-static void
+static irqreturn_t
 avm_a1p_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -187,6 +187,7 @@
 	hscx_write(cs, 0, HSCX_MASK, 0x0);
 	hscx_write(cs, 1, HSCX_MASK, 0x0);
 	spin_unlock(&cs->lock);
+	return IRQ_HANDLED;
 }
 
 static void
diff -Nru a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c
--- a/drivers/isdn/hisax/avma1_cs.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/isdn/hisax/avma1_cs.c	Wed Apr 30 22:28:11 2003
@@ -130,14 +130,6 @@
     dev_node_t	node;
 } local_info_t;
 
-/*====================================================================*/
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
 /*======================================================================
 
     avma1cs_attach() creates an "instance" of the driver, allocating
diff -Nru a/drivers/isdn/hisax/bkm_a4t.c b/drivers/isdn/hisax/bkm_a4t.c
--- a/drivers/isdn/hisax/bkm_a4t.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/isdn/hisax/bkm_a4t.c	Wed Apr 30 22:28:08 2003
@@ -137,18 +137,20 @@
 	.write_fifo = jade_write_fifo,
 };
 
-static void
+static irqreturn_t
 bkm_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
 	u8 val = 0;
 	I20_REGISTER_FILE *pI20_Regs;
+	int handled = 0;
 
 	spin_lock(&cs->lock);
 	pI20_Regs = (I20_REGISTER_FILE *) (cs->hw.ax.base);
 
 	/* ISDN interrupt pending? */
 	if (pI20_Regs->i20IntStatus & intISDN) {
+		handled = 1;
 		/* Reset the ISDN interrupt     */
 		pI20_Regs->i20IntStatus = intISDN;
 		/* Disable ISDN interrupt */
@@ -172,6 +174,7 @@
 		pI20_Regs->i20IntCtrl |= intISDN;
 	}
 	spin_unlock(&cs->lock);
+	return IRQ_RETVAL(handled);
 }
 
 static void
diff -Nru a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c
--- a/drivers/isdn/hisax/diva.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/isdn/hisax/diva.c	Wed Apr 30 22:28:17 2003
@@ -319,7 +319,7 @@
 	.read_fifo  = ipacx_bc_read_fifo,
 };
 
-static void
+static irqreturn_t
 diva_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -331,9 +331,10 @@
 	}
 	if (!cnt)
 		printk(KERN_WARNING "Diva: IRQ LOOP\n");
+	return IRQ_HANDLED;
 }
 
-static void
+static irqreturn_t
 diva_ipac_pci_irq(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -341,22 +342,24 @@
 
 	val = readb(cs->hw.diva.pci_cfg);
 	if (!(val & PITA_INT0_STATUS))
-		return; /* other shared IRQ */
+		return IRQ_NONE; /* other shared IRQ */
 	writeb(PITA_INT0_STATUS, cs->hw.diva.pci_cfg); /* Reset pending INT0 */
 
-	ipac_irq(intno, dev_id, regs);
+	return ipac_irq(intno, dev_id, regs);
 }
 
-static void
+static irqreturn_t
 diva_ipacx_pci_irq(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
 	u8 val;
 
 	val = readb(cs->hw.diva.pci_cfg);
-	if (!(val &PITA_INT0_STATUS)) return; // other shared IRQ
+	if (!(val &PITA_INT0_STATUS))
+		return IRQ_NONE; // other shared IRQ
 	interrupt_ipacx(cs);      // handler for chip
 	writeb(PITA_INT0_STATUS, cs->hw.diva.pci_cfg);  // Reset PLX interrupt
+	return IRQ_HANDLED;
 }
 
 static void
diff -Nru a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
--- a/drivers/isdn/hisax/elsa.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/isdn/hisax/elsa.c	Wed Apr 30 22:28:05 2003
@@ -307,7 +307,7 @@
 	return (v & ELSA_TIMER_RUN);
 }
 
-static void
+static irqreturn_t
 elsa_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -317,7 +317,7 @@
 	/* The card tends to generate interrupts while being removed
 	   causing us to just crash the kernel. bad. */
 		printk(KERN_WARNING "Elsa: card not available!\n");
-		return;
+		return IRQ_NONE;
 	}
 #if ARCOFI_USE
 	if (cs->hw.elsa.MFlag) {
@@ -351,9 +351,10 @@
 #endif
 	if (cs->hw.elsa.trig)
 		byteout(cs->hw.elsa.trig, 0x00);
+	return IRQ_HANDLED;
 }
 
-static void
+static irqreturn_t
 elsa_interrupt_ipac(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -361,13 +362,13 @@
 
 	if (!cs) {
 		printk(KERN_WARNING "Elsa: Spurious interrupt!\n");
-		return;
+		return IRQ_NONE;
 	}
 	if (cs->subtyp == ELSA_QS1000PCI || cs->subtyp == ELSA_QS3000PCI) {
 		val = bytein(cs->hw.elsa.cfg + 0x4c); /* PCI IRQ */
 		if (!test_bit(FLG_BUGGY_PLX9050, &cs->HW_Flags) && 
 		    !(val & ELSA_PCI_IRQ_MASK))
-			return;
+			return IRQ_NONE;
 	}
 #if ARCOFI_USE
 	if (cs->hw.elsa.MFlag) {
@@ -380,7 +381,7 @@
 		}
 	}
 #endif
-	ipac_irq(intno, dev_id, regs);
+	return ipac_irq(intno, dev_id, regs);
 }
 
 static void
diff -Nru a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c
--- a/drivers/isdn/hisax/elsa_cs.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/isdn/hisax/elsa_cs.c	Wed Apr 30 22:28:09 2003
@@ -170,14 +170,6 @@
     int                 busy;
 } local_info_t;
 
-/*====================================================================*/
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret};
-    CardServices(ReportError, handle, &err);
-}
-
 /*======================================================================
 
     elsa_cs_attach() creates an "instance" of the driver, allocatingx
diff -Nru a/drivers/isdn/hisax/enternow_pci.c b/drivers/isdn/hisax/enternow_pci.c
--- a/drivers/isdn/hisax/enternow_pci.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/isdn/hisax/enternow_pci.c	Wed Apr 30 22:28:14 2003
@@ -208,7 +208,7 @@
 	return 0;
 }
 
-static void
+static irqreturn_t
 enpci_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -253,6 +253,7 @@
 			write_tiger(cs);
 	}
 	spin_unlock(&cs->lock);
+	return IRQ_HANDLED;
 }
 
 static struct card_ops enpci_ops = {
diff -Nru a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
--- a/drivers/isdn/hisax/hfc_pci.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/isdn/hisax/hfc_pci.c	Wed Apr 30 22:28:08 2003
@@ -869,7 +869,7 @@
 /*********************/
 /* Interrupt handler */
 /*********************/
-static void
+static irqreturn_t
 hfcpci_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -880,17 +880,17 @@
 
 	if (!cs) {
 		printk(KERN_WARNING "HFC-PCI: Spurious interrupt!\n");
-		return;
+		return IRQ_NONE;
 	}
 	if (!(cs->hw.hfcpci.int_m2 & 0x08))
-		return;		/* not initialised */
+		return IRQ_NONE;		/* not initialised */
 
 	if (HFCPCI_ANYINT & (stat = Read_hfc(cs, HFCPCI_STATUS))) {
 		val = Read_hfc(cs, HFCPCI_INT_S1);
 		if (cs->debug & L1_DEB_ISAC)
 			debugl1(cs, "HFC-PCI: stat(%02x) s1(%02x)", stat, val);
 	} else
-		return;
+		return IRQ_NONE;
 
 	if (cs->debug & L1_DEB_ISAC)
 		debugl1(cs, "HFC-PCI irq %x", val);
@@ -964,6 +964,7 @@
 		} else
 			val = 0;
 	}
+	return IRQ_HANDLED;
 }
 
 /********************************************************************/
diff -Nru a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
--- a/drivers/isdn/hisax/hfc_sx.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/isdn/hisax/hfc_sx.c	Wed Apr 30 22:28:04 2003
@@ -661,7 +661,7 @@
 /*********************/
 /* Interrupt handler */
 /*********************/
-static void
+static irqreturn_t
 hfcsx_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -672,17 +672,17 @@
 
 	if (!cs) {
 		printk(KERN_WARNING "HFC-SX: Spurious interrupt!\n");
-		return;
+		return IRQ_NONE;
 	}
 	if (!(cs->hw.hfcsx.int_m2 & 0x08))
-		return;		/* not initialised */
+		return IRQ_NONE;		/* not initialised */
 
 	if (HFCSX_ANYINT & (stat = Read_hfc(cs, HFCSX_STATUS))) {
 		val = Read_hfc(cs, HFCSX_INT_S1);
 		if (cs->debug & L1_DEB_ISAC)
 			debugl1(cs, "HFC-SX: stat(%02x) s1(%02x)", stat, val);
 	} else
-		return;
+		return IRQ_NONE;
 
 	if (cs->debug & L1_DEB_ISAC)
 		debugl1(cs, "HFC-SX irq %x", val);
@@ -756,6 +756,7 @@
 		} else
 			val = 0;
 	}
+	return IRQ_HANDLED;
 }
 
 /********************************************************************/
diff -Nru a/drivers/isdn/hisax/hfcscard.c b/drivers/isdn/hisax/hfcscard.c
--- a/drivers/isdn/hisax/hfcscard.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/isdn/hisax/hfcscard.c	Wed Apr 30 22:28:17 2003
@@ -32,7 +32,7 @@
 	cs->bc_hw_ops->write_reg(cs, data, reg, val);
 }
 
-static void
+static irqreturn_t
 hfcs_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -40,7 +40,7 @@
 
 	if (!cs) {
 		printk(KERN_WARNING "HFCS: Spurious interrupt!\n");
-		return;
+		return IRQ_NONE;
 	}
 	if ((HFCD_ANYINT | HFCD_BUSY_NBUSY) & 
 		(stat = hfcs_read_reg(cs, HFCD_DATA, HFCD_STAT))) {
@@ -52,6 +52,7 @@
 		if (cs->debug & L1_DEB_ISAC)
 			debugl1(cs, "HFCS: irq_no_irq stat(%02x)", stat);
 	}
+	return IRQ_HANDLED;
 }
 
 static void
diff -Nru a/drivers/isdn/hisax/hisax.h b/drivers/isdn/hisax/hisax.h
--- a/drivers/isdn/hisax/hisax.h	Wed Apr 30 22:28:11 2003
+++ b/drivers/isdn/hisax/hisax.h	Wed Apr 30 22:28:11 2003
@@ -28,6 +28,7 @@
 #include <linux/tty.h>
 #include <linux/serial_reg.h>
 #include <linux/netdevice.h>
+#include <linux/interrupt.h>
 
 #define ERROR_STATISTIC
 
@@ -886,7 +887,7 @@
 	void   (*release)    (struct IsdnCardState *);
 	void   (*aux_ind)    (struct IsdnCardState *, void *);
 	void   (*led_handler)(struct IsdnCardState *);
-	void   (*irq_func)   (int, void *, struct pt_regs *);
+	irqreturn_t (*irq_func)   (int, void *, struct pt_regs *);
 };
 
 /* Card specific drivers provide methods to access the
diff -Nru a/drivers/isdn/hisax/hisax_fcclassic.c b/drivers/isdn/hisax/hisax_fcclassic.c
--- a/drivers/isdn/hisax/hisax_fcclassic.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/isdn/hisax/hisax_fcclassic.c	Wed Apr 30 22:28:04 2003
@@ -120,7 +120,7 @@
 
 // ----------------------------------------------------------------------
 
-static void
+static irqreturn_t
 fcclassic_irq(int intno, void *dev, struct pt_regs *regs)
 {
 	struct fritz_adapter *adapter = dev;
@@ -139,6 +139,7 @@
 			isac_irq(&adapter->isac);
 		}
 	}
+	return IRQ_HANDLED;
 }
 
 // ----------------------------------------------------------------------
diff -Nru a/drivers/isdn/hisax/hisax_fcpcipnp.c b/drivers/isdn/hisax/hisax_fcpcipnp.c
--- a/drivers/isdn/hisax/hisax_fcpcipnp.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/isdn/hisax/hisax_fcpcipnp.c	Wed Apr 30 22:28:14 2003
@@ -629,7 +629,7 @@
 
 // ----------------------------------------------------------------------
 
-static void fcpci2_irq(int intno, void *dev, struct pt_regs *regs)
+static irqreturn_t fcpci2_irq(int intno, void *dev, struct pt_regs *regs)
 {
 	struct fritz_adapter *adapter = dev;
 	unsigned char val;
@@ -637,16 +637,17 @@
 	val = inb(adapter->io + AVM_STATUS0);
 	if (!(val & AVM_STATUS0_IRQ_MASK))
 		/* hopefully a shared  IRQ reqest */
-		return;
+		return IRQ_NONE;
 	DBG(2, "STATUS0 %#x", val);
 	if (val & AVM_STATUS0_IRQ_ISAC)
 		isacsx_irq(&adapter->isac);
 
 	if (val & AVM_STATUS0_IRQ_HDLC)
 		hdlc_irq(adapter);
+	return IRQ_HANDLED;
 }
 
-static void fcpci_irq(int intno, void *dev, struct pt_regs *regs)
+static irqreturn_t fcpci_irq(int intno, void *dev, struct pt_regs *regs)
 {
 	struct fritz_adapter *adapter = dev;
 	unsigned char sval;
@@ -654,13 +655,14 @@
 	sval = inb(adapter->io + 2);
 	if ((sval & AVM_STATUS0_IRQ_MASK) == AVM_STATUS0_IRQ_MASK)
 		/* possibly a shared  IRQ reqest */
-		return;
+		return IRQ_NONE;
 	DBG(2, "sval %#x", sval);
 	if (!(sval & AVM_STATUS0_IRQ_ISAC))
 		isac_irq(&adapter->isac);
 
 	if (!(sval & AVM_STATUS0_IRQ_HDLC))
 		hdlc_irq(adapter);
+	return IRQ_HANDLED;
 }
 
 // ----------------------------------------------------------------------
diff -Nru a/drivers/isdn/hisax/hisax_hfcpci.c b/drivers/isdn/hisax/hisax_hfcpci.c
--- a/drivers/isdn/hisax/hisax_hfcpci.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/isdn/hisax/hisax_hfcpci.c	Wed Apr 30 22:28:07 2003
@@ -1321,7 +1321,7 @@
 // ----------------------------------------------------------------------
 // IRQ handler
 
-static void
+static irqreturn_t
 hfcpci_irq(int intno, void *dev, struct pt_regs *regs)
 {
 	struct hfcpci_adapter *adapter = dev;
@@ -1329,11 +1329,11 @@
 	u8 val, stat;
 
 	if (!(adapter->int_m2 & 0x08))
-		return;		/* not initialised */ // XX
+		return IRQ_NONE;		/* not initialised */ // XX
 
 	stat = hfcpci_readb(adapter, HFCPCI_STATUS);
 	if (!(stat & HFCPCI_ANYINT))
-		return;
+		return IRQ_NONE;
 
 	spin_lock(&adapter->hw_lock);
 	while (loop-- > 0) {
@@ -1369,6 +1369,7 @@
 			hfcpci_timer_irq(adapter);
 	}
 	spin_unlock(&adapter->hw_lock);
+	return IRQ_HANDLED;
 }
 
 // ----------------------------------------------------------------------
diff -Nru a/drivers/isdn/hisax/hscx.h b/drivers/isdn/hisax/hscx.h
--- a/drivers/isdn/hisax/hscx.h	Wed Apr 30 22:28:11 2003
+++ b/drivers/isdn/hisax/hscx.h	Wed Apr 30 22:28:11 2003
@@ -10,6 +10,8 @@
  *
  */
 
+#include <linux/interrupt.h>
+
 /* All Registers original Siemens Spec  */
 
 #define HSCX_ISTA 0x20
@@ -37,7 +39,7 @@
 extern void modehscx(struct BCState *bcs, int mode, int bc);
 extern void inithscxisac(struct IsdnCardState *cs);
 extern void hscx_int_main(struct IsdnCardState *cs, u8 val);
-extern void hscxisac_irq(int intno, void *dev_id, struct pt_regs *regs);
+extern irqreturn_t hscxisac_irq(int intno, void *dev_id, struct pt_regs *regs);
 extern int  hscxisac_setup(struct IsdnCardState *cs,
 			   struct dc_hw_ops *isac_ops,
 			   struct bc_hw_ops *hscx_ops);
diff -Nru a/drivers/isdn/hisax/hscx_irq.c b/drivers/isdn/hisax/hscx_irq.c
--- a/drivers/isdn/hisax/hscx_irq.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/isdn/hisax/hscx_irq.c	Wed Apr 30 22:28:18 2003
@@ -185,7 +185,7 @@
 	cs->dc_hw_ops->write_reg(cs, addr, val);
 }
 
-void
+irqreturn_t
 hscxisac_irq(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -221,5 +221,6 @@
 	hscx_write(&cs->bcs[0], HSCX_MASK, 0x0);
 	hscx_write(&cs->bcs[1], HSCX_MASK, 0x0);
 	spin_unlock(&cs->lock);
+	return IRQ_HANDLED;
 }
 
diff -Nru a/drivers/isdn/hisax/ipac.c b/drivers/isdn/hisax/ipac.c
--- a/drivers/isdn/hisax/ipac.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/isdn/hisax/ipac.c	Wed Apr 30 22:28:04 2003
@@ -47,7 +47,7 @@
 	inithscxisac(cs);
 }
 
-void
+irqreturn_t
 ipac_irq(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -90,6 +90,7 @@
 	ipac_write(cs, IPAC_MASK, 0xFF);
 	ipac_write(cs, IPAC_MASK, 0xC0);
 	spin_unlock(&cs->lock);
+	return IRQ_HANDLED;
 }
 
 int
@@ -102,4 +103,5 @@
 	cs->bc_hw_ops = ipac_bc_ops;
 	val = ipac_read(cs, IPAC_ID);
 	printk(KERN_INFO "HiSax: IPAC version %#x\n", val);
+	return 0;
 }
diff -Nru a/drivers/isdn/hisax/ipac.h b/drivers/isdn/hisax/ipac.h
--- a/drivers/isdn/hisax/ipac.h	Wed Apr 30 22:28:17 2003
+++ b/drivers/isdn/hisax/ipac.h	Wed Apr 30 22:28:17 2003
@@ -10,6 +10,8 @@
  *
  */
 
+#include <linux/interrupt.h>
+
 /* All Registers original Siemens Spec  */
 
 #define IPAC_CONF	0xC0
@@ -29,7 +31,7 @@
 #define IPAC_TIMR2	0xCC
 
 void ipac_init(struct IsdnCardState *cs);
-void ipac_irq(int intno, void *dev_id, struct pt_regs *regs);
+irqreturn_t ipac_irq(int intno, void *dev_id, struct pt_regs *regs);
 int  ipac_setup(struct IsdnCardState *cs, struct dc_hw_ops *ipac_dc_ops,
 		struct bc_hw_ops *ipac_bc_ops);
 
diff -Nru a/drivers/isdn/hisax/isurf.c b/drivers/isdn/hisax/isurf.c
--- a/drivers/isdn/hisax/isurf.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/isdn/hisax/isurf.c	Wed Apr 30 22:28:10 2003
@@ -94,7 +94,7 @@
 	.write_reg = WriteISAR,
 };
 
-static void
+static irqreturn_t
 isurf_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -130,6 +130,7 @@
 	writeb(0, cs->hw.isurf.isac + ISAC_MASK);mb();
 	writeb(ISAR_IRQMSK, cs->hw.isurf.isar + ISAR_IRQBIT); mb();
 	spin_unlock(&cs->lock);
+	return IRQ_HANDLED;
 }
 
 static void
diff -Nru a/drivers/isdn/hisax/niccy.c b/drivers/isdn/hisax/niccy.c
--- a/drivers/isdn/hisax/niccy.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/isdn/hisax/niccy.c	Wed Apr 30 22:28:08 2003
@@ -151,7 +151,7 @@
 	.write_fifo = hscx_write_fifo,
 };
 
-static void
+static irqreturn_t
 niccy_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -160,10 +160,10 @@
 		int ival;
 		ival = inl(cs->hw.niccy.cfg_reg + PCI_IRQ_CTRL_REG);
 		if (!(ival & PCI_IRQ_ASSERT)) /* IRQ not for us (shared) */
-			return;
+			return IRQ_NONE;
 		outl(ival, cs->hw.niccy.cfg_reg + PCI_IRQ_CTRL_REG);
 	}
-	hscxisac_irq(intno, dev_id, regs);
+	return hscxisac_irq(intno, dev_id, regs);
 }
 
 void
diff -Nru a/drivers/isdn/hisax/nj_s.c b/drivers/isdn/hisax/nj_s.c
--- a/drivers/isdn/hisax/nj_s.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/isdn/hisax/nj_s.c	Wed Apr 30 22:28:06 2003
@@ -17,7 +17,7 @@
 
 const char *NETjet_S_revision = "$Revision: 2.7.6.6 $";
 
-static void
+static irqreturn_t
 nj_s_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -70,6 +70,7 @@
 	}
 */
 	spin_unlock(&cs->lock);
+	return IRQ_HANDLED;
 }
 
 static int
diff -Nru a/drivers/isdn/hisax/nj_u.c b/drivers/isdn/hisax/nj_u.c
--- a/drivers/isdn/hisax/nj_u.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/isdn/hisax/nj_u.c	Wed Apr 30 22:28:06 2003
@@ -17,7 +17,7 @@
 
 const char *NETjet_U_revision = "$Revision: 2.8.6.6 $";
 
-static void
+static irqreturn_t
 nj_u_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -70,6 +70,7 @@
 	}
 */
 	spin_unlock(&cs->lock);
+	return IRQ_HANDLED;
 }
 
 static int
diff -Nru a/drivers/isdn/hisax/saphir.c b/drivers/isdn/hisax/saphir.c
--- a/drivers/isdn/hisax/saphir.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/isdn/hisax/saphir.c	Wed Apr 30 22:28:03 2003
@@ -132,13 +132,15 @@
 	.write_fifo = hscx_write_fifo,
 };
 
-static void
+static irqreturn_t
 saphir_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
+	irqreturn_t ret;
 
-	hscxisac_irq(intno, dev_id, regs);
+	ret = hscxisac_irq(intno, dev_id, regs);
 	mod_timer(&cs->hw.saphir.timer, jiffies+1*HZ);
+	return ret;
 }
 
 static void
diff -Nru a/drivers/isdn/hisax/sedlbauer.c b/drivers/isdn/hisax/sedlbauer.c
--- a/drivers/isdn/hisax/sedlbauer.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/isdn/hisax/sedlbauer.c	Wed Apr 30 22:28:18 2003
@@ -283,7 +283,7 @@
 	.write_reg  = isar_write,
 };
 
-static void
+static irqreturn_t
 sedlbauer_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -292,12 +292,12 @@
 		/* The card tends to generate interrupts while being removed
 		   causing us to just crash the kernel. bad. */
 		printk(KERN_WARNING "Sedlbauer: card not available!\n");
-		return;
+		return IRQ_NONE;
 	}
-	hscxisac_irq(intno, dev_id, regs);
+	return hscxisac_irq(intno, dev_id, regs);
 }
 
-static void
+static irqreturn_t
 sedlbauer_isar_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -334,6 +334,7 @@
 	isac_write(cs, ISAC_MASK, 0x0);
 	isar_write(cs, 0, ISAR_IRQBIT, ISAR_IRQMSK);
 	spin_unlock(&cs->lock);
+	return IRQ_HANDLED;
 }
 
 static int
diff -Nru a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c
--- a/drivers/isdn/hisax/sedlbauer_cs.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/isdn/hisax/sedlbauer_cs.c	Wed Apr 30 22:28:07 2003
@@ -178,14 +178,6 @@
     int			stop;
 } local_info_t;
 
-/*====================================================================*/
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
 /*======================================================================
 
     sedlbauer_attach() creates an "instance" of the driver, allocating
diff -Nru a/drivers/isdn/hisax/sportster.c b/drivers/isdn/hisax/sportster.c
--- a/drivers/isdn/hisax/sportster.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/isdn/hisax/sportster.c	Wed Apr 30 22:28:05 2003
@@ -111,13 +111,14 @@
 	.write_fifo = hscx_write_fifo,
 };
 
-static void
+static irqreturn_t
 sportster_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
 
 	hscxisac_irq(intno, dev_id, regs);
 	bytein(cs->hw.spt.cfg_reg + SPORTSTER_RES_IRQ +1);
+	return IRQ_HANDLED;
 }
 
 static void
diff -Nru a/drivers/isdn/hisax/teleint.c b/drivers/isdn/hisax/teleint.c
--- a/drivers/isdn/hisax/teleint.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/isdn/hisax/teleint.c	Wed Apr 30 22:28:20 2003
@@ -178,7 +178,7 @@
 	.write_reg = WriteHFC,
 };
 
-static void
+static irqreturn_t
 teleint_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -198,6 +198,7 @@
 	writereg(cs->hw.hfc.addr | 1, cs->hw.hfc.addr, ISAC_MASK, 0xFF);
 	writereg(cs->hw.hfc.addr | 1, cs->hw.hfc.addr, ISAC_MASK, 0x0);
 	spin_unlock(&cs->lock);
+	return IRQ_HANDLED;
 }
 
 static void
diff -Nru a/drivers/isdn/hisax/telespci.c b/drivers/isdn/hisax/telespci.c
--- a/drivers/isdn/hisax/telespci.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/isdn/hisax/telespci.c	Wed Apr 30 22:28:11 2003
@@ -199,7 +199,7 @@
 	.write_fifo = hscx_write_fifo,
 };
 
-static void
+static irqreturn_t
 telespci_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 #define MAXCOUNT 20
@@ -223,6 +223,7 @@
 	hscx_write(cs, 0, HSCX_MASK, 0x0);
 	hscx_write(cs, 1, HSCX_MASK, 0x0);
 	spin_unlock(&cs->lock);
+	return IRQ_HANDLED;
 }
 
 static struct card_ops telespci_ops = {
diff -Nru a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
--- a/drivers/isdn/hisax/w6692.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/isdn/hisax/w6692.c	Wed Apr 30 22:28:16 2003
@@ -287,7 +287,7 @@
 	}
 }
 
-static void
+static irqreturn_t
 w6692_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	struct IsdnCardState *cs = dev_id;
@@ -395,6 +395,7 @@
 		w6692_write_reg(cs, W_IMASK, 0xff);
 	}
 	spin_unlock(&cs->lock);
+	return IRQ_HANDLED;
 }
 
 static void
diff -Nru a/drivers/isdn/hysdn/boardergo.c b/drivers/isdn/hysdn/boardergo.c
--- a/drivers/isdn/hysdn/boardergo.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/isdn/hysdn/boardergo.c	Wed Apr 30 22:28:10 2003
@@ -32,7 +32,7 @@
 /***************************************************/
 /* The cards interrupt handler. Called from system */
 /***************************************************/
-static void
+static irqreturn_t
 ergo_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 {
 	hysdn_card *card = dev_id;	/* parameter from irq */
@@ -41,16 +41,16 @@
 	uchar volatile b;
 
 	if (!card)
-		return;		/* error -> spurious interrupt */
+		return IRQ_NONE;		/* error -> spurious interrupt */
 	if (!card->irq_enabled)
-		return;		/* other device interrupting or irq switched off */
+		return IRQ_NONE;		/* other device interrupting or irq switched off */
 
 	save_flags(flags);
 	cli();			/* no further irqs allowed */
 
 	if (!(bytein(card->iobase + PCI9050_INTR_REG) & PCI9050_INTR_REG_STAT1)) {
 		restore_flags(flags);	/* restore old state */
-		return;		/* no interrupt requested by E1 */
+		return IRQ_NONE;		/* no interrupt requested by E1 */
 	}
 	/* clear any pending ints on the board */
 	dpr = card->dpram;
@@ -62,6 +62,7 @@
 	if (!card->hw_lock)
 		schedule_work(&card->irq_queue);
 	restore_flags(flags);
+	return IRQ_HANDLED;
 }				/* ergo_interrupt */
 
 /******************************************************************************/
diff -Nru a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
--- a/drivers/isdn/i4l/isdn_tty.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/isdn/i4l/isdn_tty.c	Wed Apr 30 22:28:13 2003
@@ -1045,17 +1045,17 @@
 }
 
 static inline int
-isdn_tty_paranoia_check(modem_info * info, kdev_t device, const char *routine)
+isdn_tty_paranoia_check(modem_info * info, char *name, const char *routine)
 {
 #ifdef MODEM_PARANOIA_CHECK
 	if (!info) {
-		printk(KERN_WARNING "isdn_tty: null info_struct for (%d, %d) in %s\n",
-		       major(device), minor(device), routine);
+		printk(KERN_WARNING "isdn_tty: null info_struct for %s in %s\n",
+		       name, routine);
 		return 1;
 	}
 	if (info->magic != ISDN_ASYNC_MAGIC) {
-		printk(KERN_WARNING "isdn_tty: bad magic for modem struct (%d, %d) in %s\n",
-		       major(device), minor(device), routine);
+		printk(KERN_WARNING "isdn_tty: bad magic for modem struct %s in %s\n",
+		       name, routine);
 		return 1;
 	}
 #endif
@@ -1205,7 +1205,7 @@
 	modem_info *info = (modem_info *) tty->driver_data;
 	atemu *m = &info->emu;
 
-	if (isdn_tty_paranoia_check(info, tty->device, "isdn_tty_write"))
+	if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_write"))
 		return 0;
 	if (from_user)
 		down(&info->write_sem);
@@ -1318,7 +1318,7 @@
 	modem_info *info = (modem_info *) tty->driver_data;
 	int ret;
 
-	if (isdn_tty_paranoia_check(info, tty->device, "isdn_tty_write_room"))
+	if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_write_room"))
 		return 0;
 	if (!info->online)
 		return info->xmit_size;
@@ -1331,7 +1331,7 @@
 {
 	modem_info *info = (modem_info *) tty->driver_data;
 
-	if (isdn_tty_paranoia_check(info, tty->device, "isdn_tty_chars_in_buffer"))
+	if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_chars_in_buffer"))
 		return 0;
 	if (!info->online)
 		return 0;
@@ -1351,7 +1351,7 @@
 		return;
 	}
 	info = (modem_info *) tty->driver_data;
-	if (isdn_tty_paranoia_check(info, tty->device, "isdn_tty_flush_buffer")) {
+	if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_flush_buffer")) {
 		restore_flags(flags);
 		return;
 	}
@@ -1369,7 +1369,7 @@
 {
 	modem_info *info = (modem_info *) tty->driver_data;
 
-	if (isdn_tty_paranoia_check(info, tty->device, "isdn_tty_flush_chars"))
+	if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_flush_chars"))
 		return;
 	if ((info->xmit_count) || (skb_queue_len(&info->xmit_queue)))
 		isdn_tty_modem_xmit(info);
@@ -1388,7 +1388,7 @@
 {
 	modem_info *info = (modem_info *) tty->driver_data;
 
-	if (isdn_tty_paranoia_check(info, tty->device, "isdn_tty_throttle"))
+	if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_throttle"))
 		return;
 	if (I_IXOFF(tty))
 		info->x_char = STOP_CHAR(tty);
@@ -1400,7 +1400,7 @@
 {
 	modem_info *info = (modem_info *) tty->driver_data;
 
-	if (isdn_tty_paranoia_check(info, tty->device, "isdn_tty_unthrottle"))
+	if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_unthrottle"))
 		return;
 	if (I_IXOFF(tty)) {
 		if (info->x_char)
@@ -1542,7 +1542,7 @@
 	modem_info *info = (modem_info *) tty->driver_data;
 	int retval;
 
-	if (isdn_tty_paranoia_check(info, tty->device, "isdn_tty_ioctl"))
+	if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_ioctl"))
 		return -ENODEV;
 	if (tty->flags & (1 << TTY_IO_ERROR))
 		return -EIO;
@@ -1655,7 +1655,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == ISDN_SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == ISDN_SERIAL_TYPE_CALLOUT) {
 		if (info->flags & ISDN_ASYNC_NORMAL_ACTIVE)
 			return -EBUSY;
 		if ((info->flags & ISDN_ASYNC_CALLOUT_ACTIVE) &&
@@ -1766,15 +1766,15 @@
 
 	MOD_INC_USE_COUNT;
 
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if (line < 0 || line > ISDN_MAX_CHANNELS)
 		return -ENODEV;
 	info = &isdn_mdm.info[line];
-	if (isdn_tty_paranoia_check(info, tty->device, "isdn_tty_open"))
+	if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_open"))
 		return -ENODEV;
 #ifdef ISDN_DEBUG_MODEM_OPEN
-	printk(KERN_DEBUG "isdn_tty_open %s%d, count = %d\n", tty->driver.name,
-	       info->line, info->count);
+	printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
+	       info->count);
 #endif
 	info->count++;
 	tty->driver_data = info;
@@ -1797,7 +1797,7 @@
 		return retval;
 	}
 	if ((info->count == 1) && (info->flags & ISDN_ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == ISDN_SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == ISDN_SERIAL_TYPE_NORMAL)
 			*tty->termios = info->normal_termios;
 		else
 			*tty->termios = info->callout_termios;
@@ -1822,7 +1822,7 @@
 	ulong flags;
 	ulong timeout;
 
-	if (!info || isdn_tty_paranoia_check(info, tty->device, "isdn_tty_close"))
+	if (!info || isdn_tty_paranoia_check(info, tty->name, "isdn_tty_close"))
 		goto out;
 
 	save_flags(flags);
@@ -1892,8 +1892,8 @@
 	}
 	dev->modempoll--;
 	isdn_tty_shutdown(info);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	info->tty = 0;
@@ -1923,7 +1923,7 @@
 {
 	modem_info *info = (modem_info *) tty->driver_data;
 
-	if (isdn_tty_paranoia_check(info, tty->device, "isdn_tty_hangup"))
+	if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
 		return;
 	isdn_tty_shutdown(info);
 	info->count = 0;
diff -Nru a/drivers/isdn/pcbit/layer2.c b/drivers/isdn/pcbit/layer2.c
--- a/drivers/isdn/pcbit/layer2.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/isdn/pcbit/layer2.c	Wed Apr 30 22:28:13 2003
@@ -524,7 +524,7 @@
 	}
 }
 
-void
+irqreturn_t
 pcbit_irq_handler(int interrupt, void *devptr, struct pt_regs *regs)
 {
 	struct pcbit_dev *dev;
@@ -536,11 +536,11 @@
 
 	if (!dev) {
 		printk(KERN_WARNING "pcbit_irq_handler: wrong device\n");
-		return;
+		return IRQ_NONE;
 	}
 	if (dev->interrupt) {
 		printk(KERN_DEBUG "pcbit: reentering interrupt hander\n");
-		return;
+		return IRQ_HANDLED;
 	}
 	dev->interrupt = 1;
 
@@ -549,7 +549,7 @@
 	if (dev->l2_state == L2_STARTING || dev->l2_state == L2_ERROR) {
 		pcbit_l2_active_conf(dev, info);
 		dev->interrupt = 0;
-		return;
+		return IRQ_HANDLED;
 	}
 	if (info & 0x40U) {     /* E bit set */
 #ifdef DEBUG
@@ -557,11 +557,11 @@
 #endif
 		pcbit_l2_error(dev);
 		dev->interrupt = 0;
-		return;
+		return IRQ_HANDLED;
 	}
 	if (dev->l2_state != L2_RUNNING && dev->l2_state != L2_LOADING) {
 		dev->interrupt = 0;
-		return;
+		return IRQ_HANDLED;
 	}
 	ack_seq = (info >> 3) & 0x07U;
 	read_seq = (info & 0x07U);
@@ -582,6 +582,7 @@
 	info |= dev->send_seq;
 
 	writeb(info, dev->sh_mem + BANK4);
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/isdn/pcbit/layer2.h b/drivers/isdn/pcbit/layer2.h
--- a/drivers/isdn/pcbit/layer2.h	Wed Apr 30 22:28:04 2003
+++ b/drivers/isdn/pcbit/layer2.h	Wed Apr 30 22:28:04 2003
@@ -17,6 +17,8 @@
 #ifndef LAYER2_H
 #define LAYER2_H
 
+#include <linux/interrupt.h>
+
 #include <asm/byteorder.h>
 
 #define BANK1 0x0000U /* PC -> Board */
@@ -122,7 +124,7 @@
 extern int pcbit_l2_write(struct pcbit_dev * dev, ulong msg, ushort refnum, 
                           struct sk_buff *skb, unsigned short hdr_len);
 
-extern void pcbit_irq_handler(int interrupt, void *, struct pt_regs *regs);
+extern irqreturn_t pcbit_irq_handler(int interrupt, void *, struct pt_regs *regs);
 
 extern struct pcbit_dev * dev_pcbit[MAX_PCBIT_CARDS];
 
diff -Nru a/drivers/isdn/sc/init.c b/drivers/isdn/sc/init.c
--- a/drivers/isdn/sc/init.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/isdn/sc/init.c	Wed Apr 30 22:28:13 2003
@@ -36,7 +36,7 @@
 static int sup_irq[] = { 11, 10, 9, 5, 12, 14, 7, 3, 4, 6 };
 #define MAX_IRQS	10
 
-extern void interrupt_handler(int, void *, struct pt_regs *);
+extern irqreturn_t interrupt_handler(int, void *, struct pt_regs *);
 extern int sndpkt(int, int, int, struct sk_buff *);
 extern int command(isdn_ctrl *);
 extern int indicate_status(int, int, ulong, char*);
diff -Nru a/drivers/isdn/sc/interrupt.c b/drivers/isdn/sc/interrupt.c
--- a/drivers/isdn/sc/interrupt.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/isdn/sc/interrupt.c	Wed Apr 30 22:28:11 2003
@@ -19,6 +19,7 @@
 #include "hardware.h"
 #include "message.h"
 #include "card.h"
+#include <linux/interrupt.h>
 
 extern int indicate_status(int, int, ulong, char *);
 extern void check_phystat(unsigned long);
@@ -44,7 +45,8 @@
 /*
  * 
  */
-void interrupt_handler(int interrupt, void * cardptr, struct pt_regs *regs ) {
+irqreturn_t interrupt_handler(int interrupt, void *cardptr, struct pt_regs *regs)
+{
 
 	RspMessage rcvmsg;
 	int channel;
@@ -54,7 +56,7 @@
 
 	if(!IS_VALID_CARD(card)) {
 		pr_debug("Invalid param: %d is not a valid card id\n", card);
-		return;
+		return IRQ_NONE;
 	}
 
 	pr_debug("%s: Entered Interrupt handler\n", adapter[card]->devicename);
@@ -242,4 +244,5 @@
 	}	/* while */
 
 	pr_debug("%s: Exiting Interrupt Handler\n", adapter[card]->devicename);
+	return IRQ_HANDLED;
 }
diff -Nru a/drivers/isdn/tpam/tpam.h b/drivers/isdn/tpam/tpam.h
--- a/drivers/isdn/tpam/tpam.h	Wed Apr 30 22:28:05 2003
+++ b/drivers/isdn/tpam/tpam.h	Wed Apr 30 22:28:05 2003
@@ -17,6 +17,7 @@
 #include <linux/isdnif.h>
 #include <linux/init.h>
 #include <linux/workqueue.h>
+#include <linux/interrupt.h>
 
 /* Maximum number of channels for this board */
 #define TPAM_NBCHANNEL		30
@@ -197,7 +198,7 @@
 /* Function prototypes from tpam_queues.c */
 extern void tpam_enqueue(tpam_card *, struct sk_buff *);
 extern void tpam_enqueue_data(tpam_channel *, struct sk_buff *);
-extern void tpam_irq(int, void *, struct pt_regs *);
+extern irqreturn_t tpam_irq(int, void *, struct pt_regs *);
 extern void tpam_recv_tq(tpam_card *);
 extern void tpam_send_tq(tpam_card *);
 
diff -Nru a/drivers/isdn/tpam/tpam_commands.c b/drivers/isdn/tpam/tpam_commands.c
--- a/drivers/isdn/tpam/tpam_commands.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/isdn/tpam/tpam_commands.c	Wed Apr 30 22:28:04 2003
@@ -173,7 +173,8 @@
  * Return: 0 if OK, <0 on errors.
  */
 static int tpam_command_ioctl_dsprun(tpam_card *card) {
-	u32 signature = 0, timeout, i;
+	u32 signature = 0, i;
+	unsigned long timeout;
 	isdn_ctrl ctrl;
 	struct sk_buff *skb;
 
diff -Nru a/drivers/isdn/tpam/tpam_queues.c b/drivers/isdn/tpam/tpam_queues.c
--- a/drivers/isdn/tpam/tpam_queues.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/isdn/tpam/tpam_queues.c	Wed Apr 30 22:28:03 2003
@@ -74,7 +74,8 @@
  * 	dev_id: the registered board to the irq
  * 	regs: not used.
  */
-void tpam_irq(int irq, void *dev_id, struct pt_regs *regs) {
+irqreturn_t tpam_irq(int irq, void *dev_id, struct pt_regs *regs)
+{
 	tpam_card *card = (tpam_card *)dev_id;
 	u32 ackupload, uploadptr;
 	u32 waiting_too_long;
@@ -115,7 +116,7 @@
 			printk(KERN_ERR "TurboPAM(tpam_irq): "
 			       "alloc_skb failed\n");
 			spin_unlock(&card->lock);
-			return;
+			return IRQ_HANDLED;
 		}
 
 		/* build the skb_header */
@@ -147,7 +148,7 @@
 				spin_unlock(&card->lock);
 				printk(KERN_ERR "TurboPAM(tpam_irq): "
 						"waiting too long...\n");
-				return;
+				return IRQ_HANDLED;
 			}
 		} while (hpic & 0x00000002);
 
@@ -169,7 +170,7 @@
 			skb_queue_tail(&card->recvq, skb);
 			schedule_work(&card->recv_tq);
 		}
-		return;
+		return IRQ_HANDLED;
 	}
 	else {
 		/* it is a ack from the board */
@@ -185,10 +186,8 @@
 
 		/* schedule the send queue for execution */
 		schedule_work(&card->send_tq);
-		return;
 	}
-
-	/* not reached */
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/macintosh/macio-adb.c b/drivers/macintosh/macio-adb.c
--- a/drivers/macintosh/macio-adb.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/macintosh/macio-adb.c	Wed Apr 30 22:28:19 2003
@@ -63,7 +63,7 @@
 
 static int macio_probe(void);
 static int macio_init(void);
-static void macio_adb_interrupt(int irq, void *arg, struct pt_regs *regs);
+static irqreturn_t macio_adb_interrupt(int irq, void *arg, struct pt_regs *regs);
 static int macio_send_request(struct adb_request *req, int sync);
 static int macio_adb_autopoll(int devs);
 static void macio_adb_poll(void);
@@ -198,7 +198,8 @@
 	return 0;
 }
 
-static void macio_adb_interrupt(int irq, void *arg, struct pt_regs *regs)
+static irqreturn_t macio_adb_interrupt(int irq, void *arg,
+				       struct pt_regs *regs)
 {
 	int i, n, err;
 	struct adb_request *req;
@@ -206,9 +207,11 @@
 	int ibuf_len = 0;
 	int complete = 0;
 	int autopoll = 0;
-	
+	int handled = 0;
+
 	spin_lock(&macio_lock);
 	if (in_8(&adb->intr.r) & TAG) {
+		handled = 1;
 		if ((req = current_req) != 0) {
 			/* put the current request in */
 			for (i = 0; i < req->nbytes; ++i)
@@ -229,6 +232,7 @@
 	}
 
 	if (in_8(&adb->intr.r) & DFB) {
+		handled = 1;
 		err = in_8(&adb->error.r);
 		if (current_req && current_req->sent) {
 			/* this is the response to a command */
@@ -266,6 +270,8 @@
 	}
 	if (ibuf_len)
 		adb_input(ibuf, ibuf_len, regs, autopoll);
+
+	return IRQ_RETVAL(handled);
 }
 
 static void macio_adb_poll(void)
diff -Nru a/drivers/macintosh/macserial.c b/drivers/macintosh/macserial.c
--- a/drivers/macintosh/macserial.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/macintosh/macserial.c	Wed Apr 30 22:28:18 2003
@@ -154,8 +154,8 @@
 static int setup_scc(struct mac_serial * info);
 static void dbdma_reset(volatile struct dbdma_regs *dma);
 static void dbdma_flush(volatile struct dbdma_regs *dma);
-static void rs_txdma_irq(int irq, void *dev_id, struct pt_regs *regs);
-static void rs_rxdma_irq(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t rs_txdma_irq(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t rs_rxdma_irq(int irq, void *dev_id, struct pt_regs *regs);
 static void dma_init(struct mac_serial * info);
 static void rxdma_start(struct mac_serial * info, int current);
 static void rxdma_to_tty(struct mac_serial * info);
@@ -183,20 +183,20 @@
 
 static inline int __pmac
 serial_paranoia_check(struct mac_serial *info,
-		      kdev_t device, const char *routine)
+		      char *name, const char *routine)
 {
 #ifdef SERIAL_PARANOIA_CHECK
 	static const char badmagic[] = KERN_WARNING
-		"Warning: bad magic number for serial struct (%d, %d) in %s\n";
+		"Warning: bad magic number for serial struct %s in %s\n";
 	static const char badinfo[] = KERN_WARNING
-		"Warning: null mac_serial for (%d, %d) in %s\n";
+		"Warning: null mac_serial for %s in %s\n";
 
 	if (!info) {
-		printk(badinfo, major(device), minor(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (info->magic != SERIAL_MAGIC) {
-		printk(badmagic, major(device), minor(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -558,18 +558,19 @@
 /*
  * This is the serial driver's generic interrupt routine
  */
-static void rs_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t rs_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
 	struct mac_serial *info = (struct mac_serial *) dev_id;
 	unsigned char zs_intreg;
 	int shift;
 	unsigned long flags;
+	int handled = 0;
 
 	if (!(info->flags & ZILOG_INITIALIZED)) {
 		printk(KERN_WARNING "rs_interrupt: irq %d, port not "
 				    "initialized\n", irq);
 		disable_irq(irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	/* NOTE: The read register 3, which holds the irq status,
@@ -595,6 +596,7 @@
 
 		if ((zs_intreg & CHAN_IRQMASK) == 0)
 			break;
+		handled = 1;
 
 		if (zs_intreg & CHBRxIP) {
 			/* If we are doing DMA, we only ask for interrupts
@@ -610,30 +612,32 @@
 			status_handle(info);
 	}
 	spin_unlock_irqrestore(&info->lock, flags);
+	return IRQ_RETVAL(handled);
 }
 
 /* Transmit DMA interrupt - not used at present */
-static void rs_txdma_irq(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t rs_txdma_irq(int irq, void *dev_id, struct pt_regs *regs)
 {
+	return IRQ_HANDLED;
 }
 
 /*
  * Receive DMA interrupt.
  */
-static void rs_rxdma_irq(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t rs_rxdma_irq(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct mac_serial *info = (struct mac_serial *) dev_id;
 	volatile struct dbdma_cmd *cd;
 
 	if (!info->dma_initted)
-		return;
+		return IRQ_NONE;
 	spin_lock(&info->rx_dma_lock);
 	/* First, confirm that this interrupt is, indeed, coming */
 	/* from Rx DMA */
 	cd = info->rx_cmds[info->rx_cbuf] + 2;
 	if ((in_le16(&cd->xfer_status) & (RUN | ACTIVE)) != (RUN | ACTIVE)) {
 		spin_unlock(&info->rx_dma_lock);
-		return;
+		return IRQ_NONE;
 	}
 	if (info->rx_fbuf != RX_NO_FBUF) {
 		info->rx_cbuf = info->rx_fbuf;
@@ -643,6 +647,7 @@
 			info->rx_fbuf = RX_NO_FBUF;
 	}
 	spin_unlock(&info->rx_dma_lock);
+	return IRQ_HANDLED;
 }
 
 /*
@@ -667,7 +672,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_stop"))
+	if (serial_paranoia_check(info, tty->name, "rs_stop"))
 		return;
 
 #if 0
@@ -691,7 +696,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_start"))
+	if (serial_paranoia_check(info, tty->name, "rs_start"))
 		return;
 
 	spin_lock_irqsave(&info->lock, flags);
@@ -1459,7 +1464,7 @@
 	struct mac_serial *info = (struct mac_serial *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_flush_chars"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
 		return;
 
 	spin_lock_irqsave(&info->lock, flags);
@@ -1477,7 +1482,7 @@
 	struct mac_serial *info = (struct mac_serial *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_write"))
+	if (serial_paranoia_check(info, tty->name, "rs_write"))
 		return 0;
 
 	if (!tty || !info->xmit_buf || !tmp_buf)
@@ -1544,7 +1549,7 @@
 	struct mac_serial *info = (struct mac_serial *)tty->driver_data;
 	int	ret;
 
-	if (serial_paranoia_check(info, tty->device, "rs_write_room"))
+	if (serial_paranoia_check(info, tty->name, "rs_write_room"))
 		return 0;
 	ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
 	if (ret < 0)
@@ -1556,7 +1561,7 @@
 {
 	struct mac_serial *info = (struct mac_serial *)tty->driver_data;
 
-	if (serial_paranoia_check(info, tty->device, "rs_chars_in_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
 		return 0;
 	return info->xmit_cnt;
 }
@@ -1566,7 +1571,7 @@
 	struct mac_serial *info = (struct mac_serial *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_flush_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
 		return;
 	spin_lock_irqsave(&info->lock, flags);
 	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
@@ -1593,7 +1598,7 @@
 	printk(KERN_DEBUG "throttle %ld....\n",tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_throttle"))
+	if (serial_paranoia_check(info, tty->name, "rs_throttle"))
 		return;
 
 	if (I_IXOFF(tty)) {
@@ -1647,7 +1652,7 @@
 			tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_unthrottle"))
+	if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
 		return;
 
 	if (I_IXOFF(tty)) {
@@ -1833,7 +1838,7 @@
 	struct mac_serial *info = (struct mac_serial *) tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_break"))
+	if (serial_paranoia_check(info, tty->name, "rs_break"))
 		return;
 
 	spin_lock_irqsave(&info->lock, flags);
@@ -1854,7 +1859,7 @@
 	if (info->kgdb_channel)
 		return -ENODEV;
 #endif
-	if (serial_paranoia_check(info, tty->device, "rs_ioctl"))
+	if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
 		return -ENODEV;
 
 	if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
@@ -1921,7 +1926,7 @@
 	struct mac_serial * info = (struct mac_serial *)tty->driver_data;
 	unsigned long flags;
 
-	if (!info || serial_paranoia_check(info, tty->device, "rs_close"))
+	if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
 		return;
 
 	spin_lock_irqsave(&info->lock, flags);
@@ -2003,8 +2008,8 @@
 	   specific irqs */
 	spin_unlock_irqrestore(&info->lock, flags);
 
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -2032,7 +2037,7 @@
 	struct mac_serial *info = (struct mac_serial *) tty->driver_data;
 	unsigned long orig_jiffies, char_time;
 
-	if (serial_paranoia_check(info, tty->device, "rs_wait_until_sent"))
+	if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
 		return;
 
 /*	printk("rs_wait_until_sent, timeout:%d, tty_stopped:%d, tx_stopped:%d\n",
@@ -2078,7 +2083,7 @@
 {
 	struct mac_serial * info = (struct mac_serial *)tty->driver_data;
 
-	if (serial_paranoia_check(info, tty->device, "rs_hangup"))
+	if (serial_paranoia_check(info, tty->name, "rs_hangup"))
 		return;
 
 	rs_flush_buffer(tty);
@@ -2120,7 +2125,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		if (info->flags & ZILOG_NORMAL_ACTIVE)
 			return -EBUSY;
 		if ((info->flags & ZILOG_CALLOUT_ACTIVE) &&
@@ -2229,7 +2234,7 @@
 	unsigned long		page;
 
 	MOD_INC_USE_COUNT;
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if ((line < 0) || (line >= zs_channels_found)) {
 		MOD_DEC_USE_COUNT;
 		return -ENODEV;
@@ -2242,10 +2247,10 @@
 		return -ENODEV;
 	}
 #endif
-	if (serial_paranoia_check(info, tty->device, "rs_open"))
+	if (serial_paranoia_check(info, tty->name, "rs_open"))
 		return -ENODEV;
-	OPNDBG("rs_open %s%d, count = %d, tty=%p\n", tty->driver.name,
-	       info->line, info->count, tty);
+	OPNDBG("rs_open %s, count = %d, tty=%p\n", tty->name,
+	       info->count, tty);
 
 	info->count++;
 	tty->driver_data = info;
@@ -2292,7 +2297,7 @@
 	}
 
 	if ((info->count == 1) && (info->flags & ZILOG_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->normal_termios;
 		else 
 			*tty->termios = info->callout_termios;
@@ -2309,7 +2314,7 @@
 	info->session = current->session;
 	info->pgrp = current->pgrp;
 
-	OPNDBG("rs_open ttyS%d successful...\n", info->line);
+	OPNDBG("rs_open %s successful...\n", tty->name);
 	return 0;
 }
 
@@ -2607,7 +2612,7 @@
 	serial_driver.magic = TTY_DRIVER_MAGIC;
 	serial_driver.driver_name = "macserial";
 #ifdef CONFIG_DEVFS_FS
-	serial_driver.name = "tts/%d";
+	serial_driver.name = "tts/";
 #else
 	serial_driver.name = "ttyS";
 #endif /* CONFIG_DEVFS_FS */
@@ -2650,7 +2655,7 @@
 	 */
 	callout_driver = serial_driver;
 #ifdef CONFIG_DEVFS_FS
-	callout_driver.name = "cua/%d";
+	callout_driver.name = "cua/";
 #else
 	callout_driver.name = "cua";
 #endif /* CONFIG_DEVFS_FS */
@@ -2660,9 +2665,9 @@
 	callout_driver.proc_entry = 0;
 
 	if (tty_register_driver(&serial_driver))
-		panic("Couldn't register serial driver\n");
+		printk(KERN_ERR "Error: couldn't register serial driver\n");
 	if (tty_register_driver(&callout_driver))
-		panic("Couldn't register callout driver\n");
+		printk(KERN_ERR "Error: couldn't register callout driver\n");
 
 	for (channel = 0; channel < zs_channels_found; ++channel) {
 #ifdef CONFIG_KGDB
@@ -2835,9 +2840,11 @@
 	/* Don't disable the transmitter. */
 }
 
-static kdev_t serial_console_device(struct console *c)
+extern struct tty_driver serial_driver;
+static struct tty_driver *serial_console_device(struct console *c, int *index)
 {
-	return mk_kdev(TTY_MAJOR, 64 + c->index);
+	*index = c->index;
+	return &serial_driver;
 }
 
 /*
diff -Nru a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c
--- a/drivers/macintosh/via-cuda.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/macintosh/via-cuda.c	Wed Apr 30 22:28:04 2003
@@ -107,7 +107,7 @@
 
 static int cuda_init_via(void);
 static void cuda_start(void);
-static void cuda_interrupt(int irq, void *arg, struct pt_regs *regs);
+static irqreturn_t cuda_interrupt(int irq, void *arg, struct pt_regs *regs);
 static void cuda_input(unsigned char *buf, int nb, struct pt_regs *regs);
 void cuda_poll(void);
 static int cuda_write(struct adb_request *req);
@@ -441,7 +441,7 @@
     local_irq_restore(flags);
 }
 
-static void
+static irqreturn_t
 cuda_interrupt(int irq, void *arg, struct pt_regs *regs)
 {
     int status;
@@ -457,7 +457,7 @@
     out_8(&via[IFR], virq);   
     if ((virq & SR_INT) == 0) {
         spin_unlock(&cuda_lock);
-	return;
+	return IRQ_NONE;
     }
     
     status = (~in_8(&via[B]) & (TIP|TREQ)) | (in_8(&via[ACR]) & SR_OUT);
@@ -595,6 +595,7 @@
     }
     if (ibuf_len)
 	cuda_input(ibuf, ibuf_len, regs);
+    return IRQ_HANDLED;
 }
 
 static void
diff -Nru a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
--- a/drivers/macintosh/via-pmu.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/macintosh/via-pmu.c	Wed Apr 30 22:28:16 2003
@@ -180,8 +180,8 @@
 static int init_pmu(void);
 static int pmu_queue_request(struct adb_request *req);
 static void pmu_start(void);
-static void via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs);
-static void gpio1_interrupt(int irq, void *arg, struct pt_regs *regs);
+static irqreturn_t via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs);
+static irqreturn_t gpio1_interrupt(int irq, void *arg, struct pt_regs *regs);
 static int proc_get_info(char *page, char **start, off_t off,
 			  int count, int *eof, void *data);
 #ifdef CONFIG_PMAC_BACKLIGHT
@@ -1393,7 +1393,7 @@
 	return NULL;
 }
 
-static void __pmac
+static irqreturn_t __pmac
 via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs)
 {
 	unsigned long flags;
@@ -1401,7 +1401,8 @@
 	int nloop = 0;
 	int int_data = -1;
 	struct adb_request *req = NULL;
-	
+	int handled = 0;
+
 	/* This is a bit brutal, we can probably do better */
 	spin_lock_irqsave(&pmu_lock, flags);
 	++disable_poll;
@@ -1410,6 +1411,7 @@
 		intr = in_8(&via[IFR]) & (SR_INT | CB1_INT);
 		if (intr == 0)
 			break;
+		handled = 1;
 		if (++nloop > 1000) {
 			printk(KERN_DEBUG "PMU: stuck in intr loop, "
 			       "intr=%x, ier=%x pmu_state=%d\n",
@@ -1473,15 +1475,19 @@
 		int_data = -1;
 		goto recheck;
 	}
+
+	return IRQ_RETVAL(handled);
 }
 
-static void __pmac
+static irqreturn_t __pmac
 gpio1_interrupt(int irq, void *arg, struct pt_regs *regs)
 {
 	if ((in_8(gpio_reg + 0x9) & 0x02) == 0) {
 		adb_int_pending = 1;
 		via_pmu_interrupt(0, 0, 0);
+		return IRQ_HANDLED;
 	}
+	return IRQ_NONE;
 }
 
 #ifdef CONFIG_PMAC_BACKLIGHT
diff -Nru a/drivers/mca/Kconfig b/drivers/mca/Kconfig
--- a/drivers/mca/Kconfig	Wed Apr 30 22:28:17 2003
+++ b/drivers/mca/Kconfig	Wed Apr 30 22:28:17 2003
@@ -1,6 +1,3 @@
-comment "Micro Channel Architecture Bus support"
-	depends on MCA
-
 config MCA_LEGACY
 	bool "Legacy MCA API Support"
 	depends on MCA
diff -Nru a/drivers/md/Kconfig b/drivers/md/Kconfig
--- a/drivers/md/Kconfig	Wed Apr 30 22:28:04 2003
+++ b/drivers/md/Kconfig	Wed Apr 30 22:28:04 2003
@@ -25,7 +25,7 @@
 
 	  More information about Software RAID on Linux is contained in the
 	  Software RAID mini-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. There you will also learn
+	  <http://www.tldp.org/docs.html#howto>. There you will also learn
 	  where to get the supporting user space utilities raidtools.
 
 	  If unsure, say N.
@@ -57,7 +57,7 @@
 
 	  Information about Software RAID on Linux is contained in the
 	  Software-RAID mini-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. There you will also
+	  <http://www.tldp.org/docs.html#howto>. There you will also
 	  learn where to get the supporting user space utilities raidtools.
 
 	  If you want to compile this as a module ( = code which can be
@@ -81,7 +81,7 @@
 
 	  Information about Software RAID on Linux is contained in the
 	  Software-RAID mini-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  There you will also
+	  <http://www.tldp.org/docs.html#howto>.  There you will also
 	  learn where to get the supporting user space utilities raidtools.
 
 	  If you want to use such a RAID-1 set, say Y. This code is also
@@ -106,7 +106,7 @@
 
 	  Information about Software RAID on Linux is contained in the
 	  Software-RAID mini-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. There you will also
+	  <http://www.tldp.org/docs.html#howto>. There you will also
 	  learn where to get the supporting user space utilities raidtools.
 
 	  If you want to use such a RAID-4/RAID-5 set, say Y. This code is
diff -Nru a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
--- a/drivers/md/dm-ioctl.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/md/dm-ioctl.c	Wed Apr 30 22:28:06 2003
@@ -14,6 +14,7 @@
 #include <linux/wait.h>
 #include <linux/blk.h>
 #include <linux/slab.h>
+#include <linux/devfs_fs_kernel.h>
 
 #include <asm/uaccess.h>
 
@@ -174,16 +175,10 @@
 static int register_with_devfs(struct hash_cell *hc)
 {
 	struct gendisk *disk = dm_disk(hc->md);
-	char *name = kmalloc(DM_NAME_LEN + strlen(DM_DIR) + 1, GFP_KERNEL);
-	if (!name) {
-		return -ENOMEM;
-	}
 
-	sprintf(name, DM_DIR "/%s", hc->name);
-	devfs_register(NULL, name, 0, disk->major, disk->first_minor,
+	devfs_mk_bdev(MKDEV(disk->major, disk->first_minor),
 		       S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP,
-		       &dm_blk_dops, NULL);
-	kfree(name);
+		       DM_DIR "/%s", hc->name);
 	return 0;
 }
 
@@ -455,11 +450,11 @@
 	if (dm_suspended(md))
 		param->flags |= DM_SUSPEND_FLAG;
 
-	param->dev = MKDEV(disk->major, disk->first_minor);
-	bdev = bdget(param->dev);
+	bdev = bdget_disk(disk, 0);
 	if (!bdev)
 		return -ENXIO;
 
+	param->dev = bdev->bd_dev;
 	param->open_count = bdev->bd_openers;
 	bdput(bdev);
 
@@ -1089,9 +1084,10 @@
 };
 
 static struct miscdevice _dm_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name  = DM_NAME,
-	.fops  = &_ctl_fops
+	.minor		= MISC_DYNAMIC_MINOR,
+	.name		= DM_NAME,
+	.devfs_name	= "mapper/control",
+	.fops		= &_ctl_fops
 };
 
 /*
@@ -1112,18 +1108,12 @@
 		return r;
 	}
 
-	r = devfs_mk_symlink(DM_DIR "/control", "../misc/" DM_NAME);
-	if (r) {
-		DMERR("devfs_mk_symlink failed for control device");
-		goto failed;
-	}
 	DMINFO("%d.%d.%d%s initialised: %s", DM_VERSION_MAJOR,
 	       DM_VERSION_MINOR, DM_VERSION_PATCHLEVEL, DM_VERSION_EXTRA,
 	       DM_DRIVER_EMAIL);
 	return 0;
 
       failed:
-	devfs_remove(DM_DIR "/control");
 	if (misc_deregister(&_dm_misc) < 0)
 		DMERR("misc_deregister failed for control device");
 	dm_hash_exit();
@@ -1132,7 +1122,6 @@
 
 void dm_interface_exit(void)
 {
-	devfs_remove(DM_DIR "/control");
 	if (misc_deregister(&_dm_misc) < 0)
 		DMERR("misc_deregister failed for control device");
 	dm_hash_exit();
diff -Nru a/drivers/md/dm-table.c b/drivers/md/dm-table.c
--- a/drivers/md/dm-table.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/md/dm-table.c	Wed Apr 30 22:28:18 2003
@@ -345,26 +345,21 @@
 static int open_dev(struct dm_dev *d, dev_t dev)
 {
 	static char *_claim_ptr = "I belong to device-mapper";
+	struct block_device *bdev;
 
 	int r;
 
 	if (d->bdev)
 		BUG();
 
-	d->bdev = bdget(dev);
-	if (!d->bdev)
-		return -ENOMEM;
-
-	r = blkdev_get(d->bdev, d->mode, 0, BDEV_RAW);
+	bdev = open_by_devnum(dev, d->mode, BDEV_RAW);
+	if (IS_ERR(bdev))
+		return PTR_ERR(bdev);
+	r = bd_claim(bdev, _claim_ptr);
 	if (r)
-		return r;
-
-	r = bd_claim(d->bdev, _claim_ptr);
-	if (r) {
-		blkdev_put(d->bdev, BDEV_RAW);
-		d->bdev = NULL;
-	}
-
+		blkdev_put(bdev, BDEV_RAW);
+	else
+		d->bdev = bdev;
 	return r;
 }
 
diff -Nru a/drivers/md/dm.c b/drivers/md/dm.c
--- a/drivers/md/dm.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/md/dm.c	Wed Apr 30 22:28:15 2003
@@ -15,7 +15,7 @@
 #include <linux/slab.h>
 
 static const char *_name = DM_NAME;
-#define MAX_DEVICES (1 << KDEV_MINOR_BITS)
+#define MAX_DEVICES 1024
 
 static int major = 0;
 static int _major = 0;
diff -Nru a/drivers/md/md.c b/drivers/md/md.c
--- a/drivers/md/md.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/md/md.c	Wed Apr 30 22:28:06 2003
@@ -1046,12 +1046,9 @@
 	int err = 0;
 	struct block_device *bdev;
 
-	bdev = bdget(dev);
-	if (!bdev)
-		return -ENOMEM;
-	err = blkdev_get(bdev, FMODE_READ|FMODE_WRITE, 0, BDEV_RAW);
-	if (err)
-		return err;
+	bdev = open_by_devnum(dev, FMODE_READ|FMODE_WRITE, BDEV_RAW);
+	if (IS_ERR(bdev))
+		return PTR_ERR(bdev);
 	err = bd_claim(bdev, rdev);
 	if (err) {
 		blkdev_put(bdev, BDEV_RAW);
@@ -1687,7 +1684,7 @@
 
 		del_timer_sync(&mddev->safemode_timer);
 
-		invalidate_device(mk_kdev(disk->major, disk->first_minor), 1);
+		invalidate_partition(disk, 0);
 
 		if (ro) {
 			err  = -ENXIO;
@@ -3486,11 +3483,11 @@
 	devfs_mk_dir("md");
 	blk_register_region(MKDEV(MAJOR_NR, 0), MAX_MD_DEVS, THIS_MODULE,
 				md_probe, NULL, NULL);
+
 	for (minor=0; minor < MAX_MD_DEVS; ++minor) {
-		char name[16];
-		sprintf(name, "md/%d", minor);
-		devfs_register(NULL, name, DEVFS_FL_DEFAULT, MAJOR_NR, minor,
-			       S_IFBLK | S_IRUSR | S_IWUSR, &md_fops, NULL);
+		devfs_mk_bdev(MKDEV(MAJOR_NR, minor),
+				S_IFBLK|S_IRUSR|S_IWUSR,
+				"md/%d", minor);
 	}
 
 	register_reboot_notifier(&md_notifier);
diff -Nru a/drivers/md/raid1.c b/drivers/md/raid1.c
--- a/drivers/md/raid1.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/md/raid1.c	Wed Apr 30 22:28:10 2003
@@ -258,7 +258,7 @@
 		r1_bio->sector + (r1_bio->master_bio->bi_size >> 9);
 }
 
-static int end_request(struct bio *bio, unsigned int bytes_done, int error)
+static int raid1_end_request(struct bio *bio, unsigned int bytes_done, int error)
 {
 	int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
 	r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private);
@@ -496,7 +496,7 @@
 
 		read_bio->bi_sector = r1_bio->sector + mirror->rdev->data_offset;
 		read_bio->bi_bdev = mirror->rdev->bdev;
-		read_bio->bi_end_io = end_request;
+		read_bio->bi_end_io = raid1_end_request;
 		read_bio->bi_rw = r1_bio->cmd;
 		read_bio->bi_private = r1_bio;
 
@@ -531,7 +531,7 @@
 
 		mbio->bi_sector	= r1_bio->sector + conf->mirrors[i].rdev->data_offset;
 		mbio->bi_bdev = conf->mirrors[i].rdev->bdev;
-		mbio->bi_end_io	= end_request;
+		mbio->bi_end_io	= raid1_end_request;
 		mbio->bi_rw = r1_bio->cmd;
 		mbio->bi_private = r1_bio;
 
@@ -551,11 +551,11 @@
 	/*
 	 * We have to be a bit careful about the semaphore above, thats
 	 * why we start the requests separately. Since generic_make_request()
-	 * can sleep, this is the safer solution. Imagine, end_request
+	 * can sleep, this is the safer solution. Imagine, raid1_end_request
 	 * decreasing the semaphore before we could have set it up ...
 	 * We could play tricks with the semaphore (presetting it and
 	 * correcting at the end if sum_bios is not 'n' but we have to
-	 * do end_request by hand if all requests finish until we had a
+	 * do raid1_end_request by hand if all requests finish until we had a
 	 * chance to set up the semaphore correctly ... lots of races).
 	 */
 
diff -Nru a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c
--- a/drivers/media/common/saa7146_core.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/media/common/saa7146_core.c	Wed Apr 30 22:28:13 2003
@@ -192,7 +192,7 @@
 /********************************************************************************/
 /* interrupt handler */
 
-static void interrupt_hw(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t interrupt_hw(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct saa7146_dev *dev = (struct saa7146_dev*)dev_id;
 	u32 isr = 0;
@@ -203,7 +203,7 @@
 	/* is this our interrupt? */
 	if ( 0 == isr ) {
 		/* nope, some other device */
-		return;
+		return IRQ_NONE;
 	}
 
 	saa7146_write(dev, ISR, isr);
@@ -254,6 +254,7 @@
 		ERR(("disabling interrupt source(s)!\n"));
 		IER_DISABLE(dev,isr);
 	}
+	return IRQ_HANDLED;
 }
 
 /*********************************************************************************/
diff -Nru a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
--- a/drivers/media/dvb/dvb-core/dvbdev.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/media/dvb/dvb-core/dvbdev.c	Wed Apr 30 22:28:05 2003
@@ -45,7 +45,6 @@
 static int dvbdev_debug = 0;
 #define dprintk if (dvbdev_debug) printk
 
-static devfs_handle_t dvb_devfs_handle;
 static LIST_HEAD(dvb_adapter_list);
 static DECLARE_MUTEX(dvbdev_register_lock);
 
@@ -221,10 +220,8 @@
 	list_add_tail (&dvbdev->list_head, &adap->device_list);
 
 	sprintf(name, "dvb/adapter%d%s%d", adap->num, dnames[type], id);
-	dvbdev->devfs_handle = devfs_register(NULL, name, 0, DVB_MAJOR,
-					      nums2minor(adap->num, type, id),
-					      S_IFCHR | S_IRUSR | S_IWUSR,
-					      dvbdev->fops, dvbdev);
+	devfs_register(NULL, name, 0, DVB_MAJOR, nums2minor(adap->num, type, id),
+			S_IFCHR | S_IRUSR | S_IWUSR, dvbdev->fops, dvbdev);
 
 	dprintk("DVB: register adapter%d/%s @ minor: %i (0x%02x)\n",
 		adap->num, name, nums2minor(adap->num, type, id),
@@ -236,12 +233,12 @@
 
 void dvb_unregister_device(struct dvb_device *dvbdev)
 {
-	if (!dvbdev)
-		return;
-
-	devfs_unregister(dvbdev->devfs_handle);
-	list_del (&dvbdev->list_head);
-	kfree (dvbdev);
+	if (dvbdev) {
+		devfs_remove("dvb/adapter%d%s%d", dvbdev->adapter->num,
+				dnames[dvbdev->type], dvbdev->id);
+		list_del(&dvbdev->list_head);
+		kfree(dvbdev);
+	}
 }
 
 
@@ -289,11 +286,12 @@
 	INIT_LIST_HEAD (&adap->device_list);
 
  	/* fixme: is this correct? */
+	/* No */
 	try_module_get(THIS_MODULE);
 
 	printk ("DVB: registering new adapter (%s).\n", name);
 	
-	adap->devfs_handle = devfs_mk_dir("dvb/adapter%d", num);
+	devfs_mk_dir("dvb/adapter%d", num);
 	adap->num = num;
 	adap->name = name;
 
@@ -307,13 +305,14 @@
 
 int dvb_unregister_adapter(struct dvb_adapter *adap)
 {
-        devfs_unregister (adap->devfs_handle);
 	if (down_interruptible (&dvbdev_register_lock))
 		return -ERESTARTSYS;
+        devfs_remove("dvb/adapter%d", adap->num);
 	list_del (&adap->list_head);
 	up (&dvbdev_register_lock);
 	kfree (adap);
 	/* fixme: is this correct? */
+	/* No. */
 	module_put(THIS_MODULE);
 	return 0;
 }
@@ -322,7 +321,7 @@
 static
 int __init init_dvbdev(void)
 {
-	dvb_devfs_handle = devfs_mk_dir ("dvb");
+	devfs_mk_dir("dvb");
 #ifndef CONFIG_DVB_DEVFS_ONLY
 	if(register_chrdev(DVB_MAJOR,"DVB", &dvb_device_fops)) {
 		printk("video_dev: unable to get major %d\n", DVB_MAJOR);
@@ -339,7 +338,7 @@
 #ifndef CONFIG_DVB_DEVFS_ONLY
 	unregister_chrdev(DVB_MAJOR, "DVB");
 #endif
-        devfs_unregister(dvb_devfs_handle);
+        devfs_remove("dvb");
 }
 
 module_init(init_dvbdev);
diff -Nru a/drivers/media/dvb/dvb-core/dvbdev.h b/drivers/media/dvb/dvb-core/dvbdev.h
--- a/drivers/media/dvb/dvb-core/dvbdev.h	Wed Apr 30 22:28:07 2003
+++ b/drivers/media/dvb/dvb-core/dvbdev.h	Wed Apr 30 22:28:07 2003
@@ -45,7 +45,6 @@
 
 struct dvb_adapter {
 	int num;
-	devfs_handle_t devfs_handle;
 	struct list_head list_head;
 	struct list_head device_list;
 	const char *name;
@@ -55,7 +54,6 @@
 struct dvb_device {
 	struct list_head list_head;
 	struct file_operations *fops;
-	devfs_handle_t devfs_handle;
 	struct dvb_adapter *adapter;
 	int type;
 	u32 id;
diff -Nru a/drivers/media/radio/miropcm20-rds.c b/drivers/media/radio/miropcm20-rds.c
--- a/drivers/media/radio/miropcm20-rds.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/media/radio/miropcm20-rds.c	Wed Apr 30 22:28:04 2003
@@ -13,7 +13,6 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/miscdevice.h>
-#include <linux/devfs_fs_kernel.h>
 #include <asm/uaccess.h>
 #include "miropcm20-rds-core.h"
 
@@ -114,28 +113,17 @@
 static struct miscdevice rds_miscdev = {
 	.minor		= MISC_DYNAMIC_MINOR,
 	.name		= "radiotext",
+	.devfs_name	= "v4l/rds/radiotext",
 	.fops		= &rds_fops,
 };
 
 static int __init miropcm20_rds_init(void)
 {
-	int error;
-
-	error = misc_register(&rds_miscdev);
-	if (error)
-		return error;
-
-	error = devfs_mk_symlink("v4l/rds/radiotext",
-				 "../misc/radiotext");
-	if (error)
-		misc_deregister(&rds_miscdev);
-
-	return error;
+	return misc_register(&rds_miscdev);
 }
 
 static void __exit miropcm20_rds_cleanup(void)
 {
-	devfs_remove("v4l/rds/radiotext");
 	misc_deregister(&rds_miscdev);
 }
 
diff -Nru a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
--- a/drivers/media/video/adv7175.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/media/video/adv7175.c	Wed Apr 30 22:28:17 2003
@@ -39,7 +39,6 @@
 #include <asm/page.h>
 #include <linux/sched.h>
 #include <linux/types.h>
-#include <linux/wrapper.h>
 
 #include <linux/videodev.h>
 #include <linux/version.h>
@@ -164,7 +163,8 @@
 {
 	struct adv7175 *encoder;
 	struct	i2c_client	*client;
-	int rv, i, x_common=39; /* x is number entries init_common - 1 */
+	int rv = 0;
+	int i, x_common=39; /* x is number entries init_common - 1 */
 
 	printk(KERN_INFO "adv717x: video chip found.\n");
 	client=kmalloc(sizeof(*client), GFP_KERNEL);
diff -Nru a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
--- a/drivers/media/video/bt856.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/media/video/bt856.c	Wed Apr 30 22:28:03 2003
@@ -41,7 +41,6 @@
 #include <asm/page.h>
 #include <linux/sched.h>
 #include <linux/types.h>
-#include <linux/wrapper.h>
 
 #include <linux/videodev.h>
 #include <linux/version.h>
diff -Nru a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
--- a/drivers/media/video/bttv-driver.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/media/video/bttv-driver.c	Wed Apr 30 22:28:14 2003
@@ -1279,7 +1279,7 @@
 }
 
 static int
-buffer_setup(struct file *file, int *count, int *size)
+buffer_setup(struct file *file, unsigned int *count, unsigned int *size)
 {
 	struct bttv_fh *fh = file->private_data;
 	
@@ -3156,22 +3156,23 @@
 	spin_unlock(&btv->s_lock);
 }
 
-static void bttv_irq(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t bttv_irq(int irq, void *dev_id, struct pt_regs * regs)
 {
 	u32 stat,astat;
 	u32 dstat;
 	int count;
 	struct bttv *btv;
+	int handled = 0;
 
 	btv=(struct bttv *)dev_id;
 	count=0;
-	while (1) 
-	{
+	while (1) {
 		/* get/clear interrupt status bits */
 		stat=btread(BT848_INT_STAT);
 		astat=stat&btread(BT848_INT_MASK);
 		if (!astat)
-			return;
+			break;
+		handled = 1;
 		btwrite(stat,BT848_INT_STAT);
 
 		/* get device status bits */
@@ -3231,6 +3232,7 @@
 			       "bttv%d: IRQ lockup, cleared int mask\n", btv->nr);
 		}
 	}
+	return IRQ_RETVAL(handled);
 }
 
 
diff -Nru a/drivers/media/video/bttv-vbi.c b/drivers/media/video/bttv-vbi.c
--- a/drivers/media/video/bttv-vbi.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/media/video/bttv-vbi.c	Wed Apr 30 22:28:11 2003
@@ -62,7 +62,8 @@
 	return 0;
 }
 
-static int vbi_buffer_setup(struct file *file, int *count, int *size)
+static int vbi_buffer_setup(struct file *file,
+			unsigned int *count, unsigned int *size)
 {
 	struct bttv_fh *fh = file->private_data;
 	struct bttv *btv = fh->btv;
diff -Nru a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c
--- a/drivers/media/video/cpia.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/media/video/cpia.c	Wed Apr 30 22:28:12 2003
@@ -39,7 +39,6 @@
 #include <linux/pagemap.h>
 #include <asm/io.h>
 #include <asm/semaphore.h>
-#include <linux/wrapper.h>
 
 #ifdef CONFIG_KMOD
 #include <linux/kmod.h>
@@ -234,7 +233,7 @@
 	memset(mem, 0, size); /* Clear the ram out, no junk to the user */
 	adr = (unsigned long) mem;
 	while (size > 0) {
-		mem_map_reserve(vmalloc_to_page((void *)adr));
+		SetPageReserved(vmalloc_to_page((void *)adr));
 		adr += PAGE_SIZE;
 		size -= PAGE_SIZE;
 	}
@@ -251,7 +250,7 @@
 
 	adr = (unsigned long) mem;
 	while ((long) size > 0) {
-		mem_map_unreserve(vmalloc_to_page((void *)adr));
+		ClearPageReserved(vmalloc_to_page((void *)adr));
 		adr += PAGE_SIZE;
 		size -= PAGE_SIZE;
 	}
diff -Nru a/drivers/media/video/meye.c b/drivers/media/video/meye.c
--- a/drivers/media/video/meye.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/media/video/meye.c	Wed Apr 30 22:28:10 2003
@@ -35,7 +35,6 @@
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <linux/delay.h>
-#include <linux/wrapper.h>
 #include <linux/interrupt.h>
 #include <linux/vmalloc.h>
 
@@ -139,7 +138,7 @@
 		memset(mem, 0, size); /* Clear the ram out, no junk to the user */
 	        adr = (unsigned long)mem;
 		while (size > 0) {
-			mem_map_reserve(vmalloc_to_page((void *)adr));
+			SetPageReserved(vmalloc_to_page((void *)adr));
 			adr += PAGE_SIZE;
 			size -= PAGE_SIZE;
 		}
@@ -153,7 +152,7 @@
 	if (mem) {
 	        adr = (unsigned long) mem;
 		while ((long) size > 0) {
-			mem_map_unreserve(vmalloc_to_page((void *)adr));
+			ClearPageReserved(vmalloc_to_page((void *)adr));
 			adr += PAGE_SIZE;
 			size -= PAGE_SIZE;
 		}
diff -Nru a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c
--- a/drivers/media/video/msp3400.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/media/video/msp3400.c	Wed Apr 30 22:28:11 2003
@@ -1208,8 +1208,7 @@
 
 /* ----------------------------------------------------------------------- */
 
-static int msp_attach(struct i2c_adapter *adap, int addr,
-		      unsigned short flags, int kind);
+static int msp_attach(struct i2c_adapter *adap, int addr, int kind);
 static int msp_detach(struct i2c_client *client);
 static int msp_probe(struct i2c_adapter *adap);
 static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg);
@@ -1233,8 +1232,7 @@
 	},
 };
 
-static int msp_attach(struct i2c_adapter *adap, int addr,
-		      unsigned short flags, int kind)
+static int msp_attach(struct i2c_adapter *adap, int addr, int kind)
 {
 	DECLARE_MUTEX_LOCKED(sem);
 	struct msp3400c *msp;
diff -Nru a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
--- a/drivers/media/video/mxb.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/media/video/mxb.c	Wed Apr 30 22:28:04 2003
@@ -177,6 +177,9 @@
 	int	cur_mute;	/* current mute status */
 };
 
+static
+struct saa7146_extension extension;
+
 static int mxb_vbi_bypass(struct saa7146_dev* dev)
 {
 	struct mxb* mxb = (struct mxb*)dev->ext_priv;
@@ -269,6 +272,95 @@
 	return 0;
 }
 
+/* some init data for the saa7740, the so-called 'sound arena module'. 
+   there are no specs available, so we simply use some init values */
+static struct {
+	int	length;
+	char	data[9];
+} mxb_saa7740_init[] = {
+	{ 3, { 0x80, 0x00, 0x00 } },{ 3, { 0x80, 0x89, 0x00 } },
+	{ 3, { 0x80, 0xb0, 0x0a } },{ 3, { 0x00, 0x00, 0x00 } },
+	{ 3, { 0x49, 0x00, 0x00 } },{ 3, { 0x4a, 0x00, 0x00 } },
+	{ 3, { 0x4b, 0x00, 0x00 } },{ 3, { 0x4c, 0x00, 0x00 } },
+	{ 3, { 0x4d, 0x00, 0x00 } },{ 3, { 0x4e, 0x00, 0x00 } },
+	{ 3, { 0x4f, 0x00, 0x00 } },{ 3, { 0x50, 0x00, 0x00 } },
+	{ 3, { 0x51, 0x00, 0x00 } },{ 3, { 0x52, 0x00, 0x00 } },
+	{ 3, { 0x53, 0x00, 0x00 } },{ 3, { 0x54, 0x00, 0x00 } },
+	{ 3, { 0x55, 0x00, 0x00 } },{ 3, { 0x56, 0x00, 0x00 } },
+	{ 3, { 0x57, 0x00, 0x00 } },{ 3, { 0x58, 0x00, 0x00 } },
+	{ 3, { 0x59, 0x00, 0x00 } },{ 3, { 0x5a, 0x00, 0x00 } },
+	{ 3, { 0x5b, 0x00, 0x00 } },{ 3, { 0x5c, 0x00, 0x00 } },
+	{ 3, { 0x5d, 0x00, 0x00 } },{ 3, { 0x5e, 0x00, 0x00 } },
+	{ 3, { 0x5f, 0x00, 0x00 } },{ 3, { 0x60, 0x00, 0x00 } },
+	{ 3, { 0x61, 0x00, 0x00 } },{ 3, { 0x62, 0x00, 0x00 } },
+	{ 3, { 0x63, 0x00, 0x00 } },{ 3, { 0x64, 0x00, 0x00 } },
+	{ 3, { 0x65, 0x00, 0x00 } },{ 3, { 0x66, 0x00, 0x00 } },
+	{ 3, { 0x67, 0x00, 0x00 } },{ 3, { 0x68, 0x00, 0x00 } },
+	{ 3, { 0x69, 0x00, 0x00 } },{ 3, { 0x6a, 0x00, 0x00 } },
+	{ 3, { 0x6b, 0x00, 0x00 } },{ 3, { 0x6c, 0x00, 0x00 } },
+	{ 3, { 0x6d, 0x00, 0x00 } },{ 3, { 0x6e, 0x00, 0x00 } },
+	{ 3, { 0x6f, 0x00, 0x00 } },{ 3, { 0x70, 0x00, 0x00 } },
+	{ 3, { 0x71, 0x00, 0x00 } },{ 3, { 0x72, 0x00, 0x00 } },
+	{ 3, { 0x73, 0x00, 0x00 } },{ 3, { 0x74, 0x00, 0x00 } },
+	{ 3, { 0x75, 0x00, 0x00 } },{ 3, { 0x76, 0x00, 0x00 } },
+	{ 3, { 0x77, 0x00, 0x00 } },{ 3, { 0x41, 0x00, 0x42 } },
+	{ 3, { 0x42, 0x10, 0x42 } },{ 3, { 0x43, 0x20, 0x42 } },
+	{ 3, { 0x44, 0x30, 0x42 } },{ 3, { 0x45, 0x00, 0x01 } },
+	{ 3, { 0x46, 0x00, 0x01 } },{ 3, { 0x47, 0x00, 0x01 } },
+	{ 3, { 0x48, 0x00, 0x01 } },
+	{ 9, { 0x01, 0x03, 0xc5, 0x5c, 0x7a, 0x85, 0x01, 0x00, 0x54 } },
+	{ 9, { 0x21, 0x03, 0xc5, 0x5c, 0x7a, 0x85, 0x01, 0x00, 0x54 } },
+	{ 9, { 0x09, 0x0b, 0xb4, 0x6b, 0x74, 0x85, 0x95, 0x00, 0x34 } },
+	{ 9, { 0x29, 0x0b, 0xb4, 0x6b, 0x74, 0x85, 0x95, 0x00, 0x34 } },
+	{ 9, { 0x11, 0x17, 0x43, 0x62, 0x68, 0x89, 0xd1, 0xff, 0xb0 } },
+	{ 9, { 0x31, 0x17, 0x43, 0x62, 0x68, 0x89, 0xd1, 0xff, 0xb0 } },
+	{ 9, { 0x19, 0x20, 0x62, 0x51, 0x5a, 0x95, 0x19, 0x01, 0x50 } },
+	{ 9, { 0x39, 0x20, 0x62, 0x51, 0x5a, 0x95, 0x19, 0x01, 0x50 } },
+	{ 9, { 0x05, 0x3e, 0xd2, 0x69, 0x4e, 0x9a, 0x51, 0x00, 0xf0 } },
+	{ 9, { 0x25, 0x3e, 0xd2, 0x69, 0x4e, 0x9a, 0x51, 0x00, 0xf0 } },
+	{ 9, { 0x0d, 0x3d, 0xa1, 0x40, 0x7d, 0x9f, 0x29, 0xfe, 0x14 } },
+	{ 9, { 0x2d, 0x3d, 0xa1, 0x40, 0x7d, 0x9f, 0x29, 0xfe, 0x14 } },
+	{ 9, { 0x15, 0x73, 0xa1, 0x50, 0x5d, 0xa6, 0xf5, 0xfe, 0x38 } },
+	{ 9, { 0x35, 0x73, 0xa1, 0x50, 0x5d, 0xa6, 0xf5, 0xfe, 0x38 } },
+	{ 9, { 0x1d, 0xed, 0xd0, 0x68, 0x29, 0xb4, 0xe1, 0x00, 0xb8 } },
+	{ 9, { 0x3d, 0xed, 0xd0, 0x68, 0x29, 0xb4, 0xe1, 0x00, 0xb8 } },
+	{ 3, { 0x80, 0xb3, 0x0a } },
+	{-1, { 0} }
+};
+
+static unsigned char mxb_saa7111_init[25] = {
+	0x00,
+	
+	0x00,	  /* 00 - ID byte */
+	0x00,	  /* 01 - reserved */
+
+	/*front end */
+	0xd8,	  /* 02 - FUSE=x, GUDL=x, MODE=x */
+	0x23,	  /* 03 - HLNRS=0, VBSL=1, WPOFF=0, HOLDG=0, GAFIX=0, GAI1=256, GAI2=256 */
+	0x00,	  /* 04 - GAI1=256 */
+	0x00,	  /* 05 - GAI2=256 */
+
+	/* decoder */
+	0xf0,	  /* 06 - HSB at  xx(50Hz) /  xx(60Hz) pixels after end of last line */
+	0x30,	  /* 07 - HSS at  xx(50Hz) /  xx(60Hz) pixels after end of last line */
+	0xa8,	  /* 08 - AUFD=x, FSEL=x, EXFIL=x, VTRC=x, HPLL=x, VNOI=x */
+	0x02,	  /* 09 - BYPS=x, PREF=x, BPSS=x, VBLB=x, UPTCV=x, APER=x */
+	0x80,	  /* 0a - BRIG=128 */
+	0x47,	  /* 0b - CONT=1.109 */
+	0x40,	  /* 0c - SATN=1.0 */
+	0x00,	  /* 0d - HUE=0 */
+	0x01,	  /* 0e - CDTO=0, CSTD=0, DCCF=0, FCTC=0, CHBW=1 */
+	0x00,	  /* 0f - reserved */
+	0xd0,	  /* 10 - OFTS=x, HDEL=x, VRLN=x, YDEL=x */
+	0x8c,	  /* 11 - GPSW=x, CM99=x, FECO=x, COMPO=x, OEYC=1, OEHV=1, VIPB=0, COLO=0 */
+	0x80,	  /* 12 - xx output control 2 */
+	0x30,	  /* 13 - xx output control 3 */
+	0x00,	  /* 14 - reserved */
+	0x15,	  /* 15 - VBI */
+	0x04,	  /* 16 - VBI */
+	0x00,	  /* 17 - VBI */
+};
+
 /* bring hardware to a sane state. this has to be done, just in case someone
    wants to capture from this device before it has been properly initialized.
    the capture engine would badly fail, because no valid signal arrives on the
@@ -277,100 +369,13 @@
 {
 	struct mxb* mxb = (struct mxb*)dev->ext_priv;
 	
-	struct {
-		int	length;
-		char	data[9];
-	} saa7740_init[] = {
-		{ 3, { 0x80, 0x00, 0x00 } },{ 3, { 0x80, 0x89, 0x00 } },
-		{ 3, { 0x80, 0xb0, 0x0a } },{ 3, { 0x00, 0x00, 0x00 } },
-		{ 3, { 0x49, 0x00, 0x00 } },{ 3, { 0x4a, 0x00, 0x00 } },
-		{ 3, { 0x4b, 0x00, 0x00 } },{ 3, { 0x4c, 0x00, 0x00 } },
-		{ 3, { 0x4d, 0x00, 0x00 } },{ 3, { 0x4e, 0x00, 0x00 } },
-		{ 3, { 0x4f, 0x00, 0x00 } },{ 3, { 0x50, 0x00, 0x00 } },
-		{ 3, { 0x51, 0x00, 0x00 } },{ 3, { 0x52, 0x00, 0x00 } },
-		{ 3, { 0x53, 0x00, 0x00 } },{ 3, { 0x54, 0x00, 0x00 } },
-		{ 3, { 0x55, 0x00, 0x00 } },{ 3, { 0x56, 0x00, 0x00 } },
-		{ 3, { 0x57, 0x00, 0x00 } },{ 3, { 0x58, 0x00, 0x00 } },
-		{ 3, { 0x59, 0x00, 0x00 } },{ 3, { 0x5a, 0x00, 0x00 } },
-		{ 3, { 0x5b, 0x00, 0x00 } },{ 3, { 0x5c, 0x00, 0x00 } },
-		{ 3, { 0x5d, 0x00, 0x00 } },{ 3, { 0x5e, 0x00, 0x00 } },
-		{ 3, { 0x5f, 0x00, 0x00 } },{ 3, { 0x60, 0x00, 0x00 } },
-		{ 3, { 0x61, 0x00, 0x00 } },{ 3, { 0x62, 0x00, 0x00 } },
-		{ 3, { 0x63, 0x00, 0x00 } },{ 3, { 0x64, 0x00, 0x00 } },
-		{ 3, { 0x65, 0x00, 0x00 } },{ 3, { 0x66, 0x00, 0x00 } },
-		{ 3, { 0x67, 0x00, 0x00 } },{ 3, { 0x68, 0x00, 0x00 } },
-		{ 3, { 0x69, 0x00, 0x00 } },{ 3, { 0x6a, 0x00, 0x00 } },
-		{ 3, { 0x6b, 0x00, 0x00 } },{ 3, { 0x6c, 0x00, 0x00 } },
-		{ 3, { 0x6d, 0x00, 0x00 } },{ 3, { 0x6e, 0x00, 0x00 } },
-		{ 3, { 0x6f, 0x00, 0x00 } },{ 3, { 0x70, 0x00, 0x00 } },
-		{ 3, { 0x71, 0x00, 0x00 } },{ 3, { 0x72, 0x00, 0x00 } },
-		{ 3, { 0x73, 0x00, 0x00 } },{ 3, { 0x74, 0x00, 0x00 } },
-		{ 3, { 0x75, 0x00, 0x00 } },{ 3, { 0x76, 0x00, 0x00 } },
-		{ 3, { 0x77, 0x00, 0x00 } },{ 3, { 0x41, 0x00, 0x42 } },
-		{ 3, { 0x42, 0x10, 0x42 } },{ 3, { 0x43, 0x20, 0x42 } },
-		{ 3, { 0x44, 0x30, 0x42 } },{ 3, { 0x45, 0x00, 0x01 } },
-		{ 3, { 0x46, 0x00, 0x01 } },{ 3, { 0x47, 0x00, 0x01 } },
-		{ 3, { 0x48, 0x00, 0x01 } },
-		{ 9, { 0x01, 0x03, 0xc5, 0x5c, 0x7a, 0x85, 0x01, 0x00, 0x54 } },
-		{ 9, { 0x21, 0x03, 0xc5, 0x5c, 0x7a, 0x85, 0x01, 0x00, 0x54 } },
-		{ 9, { 0x09, 0x0b, 0xb4, 0x6b, 0x74, 0x85, 0x95, 0x00, 0x34 } },
-		{ 9, { 0x29, 0x0b, 0xb4, 0x6b, 0x74, 0x85, 0x95, 0x00, 0x34 } },
-		{ 9, { 0x11, 0x17, 0x43, 0x62, 0x68, 0x89, 0xd1, 0xff, 0xb0 } },
-		{ 9, { 0x31, 0x17, 0x43, 0x62, 0x68, 0x89, 0xd1, 0xff, 0xb0 } },
-		{ 9, { 0x19, 0x20, 0x62, 0x51, 0x5a, 0x95, 0x19, 0x01, 0x50 } },
-		{ 9, { 0x39, 0x20, 0x62, 0x51, 0x5a, 0x95, 0x19, 0x01, 0x50 } },
-		{ 9, { 0x05, 0x3e, 0xd2, 0x69, 0x4e, 0x9a, 0x51, 0x00, 0xf0 } },
-		{ 9, { 0x25, 0x3e, 0xd2, 0x69, 0x4e, 0x9a, 0x51, 0x00, 0xf0 } },
-		{ 9, { 0x0d, 0x3d, 0xa1, 0x40, 0x7d, 0x9f, 0x29, 0xfe, 0x14 } },
-		{ 9, { 0x2d, 0x3d, 0xa1, 0x40, 0x7d, 0x9f, 0x29, 0xfe, 0x14 } },
-		{ 9, { 0x15, 0x73, 0xa1, 0x50, 0x5d, 0xa6, 0xf5, 0xfe, 0x38 } },
-		{ 9, { 0x35, 0x73, 0xa1, 0x50, 0x5d, 0xa6, 0xf5, 0xfe, 0x38 } },
-		{ 9, { 0x1d, 0xed, 0xd0, 0x68, 0x29, 0xb4, 0xe1, 0x00, 0xb8 } },
-		{ 9, { 0x3d, 0xed, 0xd0, 0x68, 0x29, 0xb4, 0xe1, 0x00, 0xb8 } },
-		{ 3, { 0x80, 0xb3, 0x0a } },
-		{-1, { 0} }
-	};
-	
-	unsigned char init[25] = {
-		0x00,
-		
-		0x00,	  /* 00 - ID byte */
-		0x00,	  /* 01 - reserved */
-
-		/*front end */
-		0xd8,	  /* 02 - FUSE=x, GUDL=x, MODE=x */
-		0x23,	  /* 03 - HLNRS=0, VBSL=1, WPOFF=0, HOLDG=0, GAFIX=0, GAI1=256, GAI2=256 */
-		0x00,	  /* 04 - GAI1=256 */
-		0x00,	  /* 05 - GAI2=256 */
-
-		/* decoder */
-		0xf0,	  /* 06 - HSB at  xx(50Hz) /  xx(60Hz) pixels after end of last line */
-		0x30,	  /* 07 - HSS at  xx(50Hz) /  xx(60Hz) pixels after end of last line */
-		0xa8,	  /* 08 - AUFD=x, FSEL=x, EXFIL=x, VTRC=x, HPLL=x, VNOI=x */
-		0x02,	  /* 09 - BYPS=x, PREF=x, BPSS=x, VBLB=x, UPTCV=x, APER=x */
-		0x80,	  /* 0a - BRIG=128 */
-		0x47,	  /* 0b - CONT=1.109 */
-		0x40,	  /* 0c - SATN=1.0 */
-		0x00,	  /* 0d - HUE=0 */
-		0x01,	  /* 0e - CDTO=0, CSTD=0, DCCF=0, FCTC=0, CHBW=1 */
-		0x00,	  /* 0f - reserved */
-		0xd0,	  /* 10 - OFTS=x, HDEL=x, VRLN=x, YDEL=x */
-		0x8c,	  /* 11 - GPSW=x, CM99=x, FECO=x, COMPO=x, OEYC=1, OEHV=1, VIPB=0, COLO=0 */
-		0x80,	  /* 12 - xx output control 2 */
-		0x30,	  /* 13 - xx output control 3 */
-		0x00,	  /* 14 - reserved */
-		0x15,	  /* 15 - VBI */
-		0x04,	  /* 16 - VBI */
-		0x00,	  /* 17 - VBI */
-	};
-
 	struct i2c_msg msg;
 
 	int i = 0, err = 0;
 	struct	tea6415c_multiplex vm;	
 
 	/* write configuration to saa7111a */
-	i = i2c_master_send(mxb->saa7111a, init, sizeof(init));
+	i = i2c_master_send(mxb->saa7111a, mxb_saa7111_init, sizeof(mxb_saa7111_init));
 	if (i < 0) {
 		printk("failed to initialize saa7111a. this should never happen.\n");
 	}
@@ -420,16 +425,22 @@
 	   engineered. */
 	msg.addr = 0x1b;
 	msg.flags = 0;
-	msg.len = saa7740_init[0].length;
-	msg.buf = &saa7740_init[0].data[0];
+	msg.len = mxb_saa7740_init[0].length;
+	msg.buf = &mxb_saa7740_init[0].data[0];
 
 	if( 1 == (err = i2c_transfer(&mxb->i2c_adapter, &msg, 1))) {
+		/* the sound arena module is a pos, that's probably the reason
+		   philips refuses to hand out a datasheet for the saa7740...
+		   it seems to screw up the i2c bus, so we disable fast irq
+		   based i2c transactions here and rely on the slow and safe
+		   polling method ... */
+		extension.flags &= ~SAA7146_USE_I2C_IRQ;
 		for(i = 1;;i++) {
-			msg.len = saa7740_init[i].length;		
-			if( -1 == msg.len ) {
+			msg.len = mxb_saa7740_init[i].length;		
+			if (msg.len == -1U) {
 				break;
 			}
-			msg.buf = &saa7740_init[i].data[0];
+			msg.buf = &mxb_saa7740_init[i].data[0];
 			if( 1 != (err = i2c_transfer(&mxb->i2c_adapter, &msg, 1))) {
 				DEB_D(("failed to initialize 'sound arena module'.\n"));
 				goto err;
@@ -1003,9 +1014,6 @@
 };
 
 static
-struct saa7146_extension extension;
-
-static
 struct saa7146_pci_extension_data mxb = {
         .ext_priv = "Multimedia eXtension Board",
         .ext = &extension,
@@ -1023,6 +1031,8 @@
 		.vendor	= 0,
 	}
 };
+
+MODULE_DEVICE_TABLE(pci, pci_tbl);
 
 static
 struct saa7146_ext_vv vv_data = {
diff -Nru a/drivers/media/video/planb.c b/drivers/media/video/planb.c
--- a/drivers/media/video/planb.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/media/video/planb.c	Wed Apr 30 22:28:15 2003
@@ -40,7 +40,6 @@
 #include <linux/vmalloc.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
-#include <linux/wrapper.h>
 #include <linux/videodev.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -146,12 +145,12 @@
 								|GFP_DMA, 0);
 		if (!pb->rawbuf[i])
 			break;
-		mem_map_reserve(virt_to_page(pb->rawbuf[i]));
+		SetPageReserved(virt_to_page(pb->rawbuf[i]));
 	}
 	if (i-- < npage) {
 		printk(KERN_DEBUG "PlanB: init_grab: grab buffer not allocated\n");
 		for (; i > 0; i--) {
-			mem_map_unreserve(virt_to_page(pb->rawbuf[i]));
+			ClearPageReserved(virt_to_page(pb->rawbuf[i]));
 			free_pages((unsigned long)pb->rawbuf[i], 0);
 		}
 		kfree(pb->rawbuf);
@@ -412,7 +411,7 @@
 	}
 	if(pb->rawbuf) {
 		for (i = 0; i < pb->rawbuf_size; i++) {
-			mem_map_unreserve(virt_to_page(pb->rawbuf[i]));
+			ClearPageReserved(virt_to_page(pb->rawbuf[i]));
 			free_pages((unsigned long)pb->rawbuf[i], 0);
 		}
 		kfree(pb->rawbuf);
diff -Nru a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
--- a/drivers/media/video/saa5249.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/media/video/saa5249.c	Wed Apr 30 22:28:14 2003
@@ -149,7 +149,7 @@
 
 static struct i2c_client client_template;
 
-static int saa5249_attach(struct i2c_adapter *adap, int addr, unsigned short flags, int kind)		
+static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
 {
 	int pgbuf;
 	int err;
diff -Nru a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
--- a/drivers/media/video/saa7111.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/media/video/saa7111.c	Wed Apr 30 22:28:08 2003
@@ -66,7 +66,7 @@
 
 /* ----------------------------------------------------------------------- */
 
-static int saa7111_attach(struct i2c_adapter *adap, int addr, unsigned short flags, int kind)
+static int saa7111_attach(struct i2c_adapter *adap, int addr, int kind)
 {
 	int i;
 	struct saa7111 *decoder;
diff -Nru a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
--- a/drivers/media/video/saa7134/saa7134-core.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/media/video/saa7134/saa7134-core.c	Wed Apr 30 22:28:07 2003
@@ -532,7 +532,7 @@
 	printk("\n");
 }
 
-static void saa7134_irq(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t saa7134_irq(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct saa7134_dev *dev = (struct saa7134_dev*) dev_id;
 	unsigned long report,status;
@@ -546,7 +546,7 @@
 			if (irq_debug > 1)
 				printk(KERN_DEBUG "%s/irq: no (more) work\n",
 				       dev->name);
-			return;
+			goto out;
 		}
 		if (irq_debug)
 			print_irqstatus(dev,loop,report,status);
@@ -582,6 +582,8 @@
 		saa_writel(SAA7134_IRQ1,0);
 		saa_writel(SAA7134_IRQ2,0);
 	}
+out:
+	return IRQ_HANDLED;
 }
 
 /* ------------------------------------------------------------------ */
diff -Nru a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c
--- a/drivers/media/video/saa7134/saa7134-ts.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/media/video/saa7134/saa7134-ts.c	Wed Apr 30 22:28:03 2003
@@ -127,7 +127,7 @@
 }
 
 static int
-buffer_setup(struct file *file, int *count, int *size)
+buffer_setup(struct file *file, unsigned int *count, unsigned int *size)
 {
 	*size = TS_PACKET_SIZE * TS_NR_PACKETS;
 	if (0 == *count)
diff -Nru a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
--- a/drivers/media/video/saa7134/saa7134-video.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/media/video/saa7134/saa7134-video.c	Wed Apr 30 22:28:05 2003
@@ -882,7 +882,7 @@
 }
 
 static int
-buffer_setup(struct file *file, int *count, int *size)
+buffer_setup(struct file *file, unsigned int *count, unsigned int *size)
 {
 	struct saa7134_fh *fh = file->private_data;
 
diff -Nru a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
--- a/drivers/media/video/saa7185.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/media/video/saa7185.c	Wed Apr 30 22:28:03 2003
@@ -37,7 +37,6 @@
 #include <asm/page.h>
 #include <linux/sched.h>
 #include <linux/types.h>
-#include <linux/wrapper.h>
 
 #include <linux/videodev.h>
 #include <linux/version.h>
diff -Nru a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c
--- a/drivers/media/video/stradis.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/media/video/stradis.c	Wed Apr 30 22:28:16 2003
@@ -39,7 +39,6 @@
 #include <linux/sched.h>
 #include <asm/types.h>
 #include <linux/types.h>
-#include <linux/wrapper.h>
 #include <linux/interrupt.h>
 #include <asm/uaccess.h>
 #include <linux/vmalloc.h>
@@ -442,11 +441,12 @@
 	}
 }
 
-static void saa7146_irq(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t saa7146_irq(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct saa7146 *saa = (struct saa7146 *) dev_id;
 	u32 stat, astat;
 	int count;
+	int handled = 0;
 
 	count = 0;
 	while (1) {
@@ -454,7 +454,8 @@
 		stat = saaread(SAA7146_ISR);
 		astat = stat & saaread(SAA7146_IER);
 		if (!astat)
-			return;
+			break;
+		handled = 1;
 		saawrite(astat, SAA7146_ISR);
 		if (astat & SAA7146_PSR_DEBI_S) {
 			do_irq_send_data(saa);
@@ -611,6 +612,7 @@
 			       "stradis%d: IRQ loop cleared\n", saa->nr);
 		}
 	}
+	return IRQ_RETVAL(handled);
 }
 
 static int ibm_send_command(struct saa7146 *saa,
diff -Nru a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c
--- a/drivers/media/video/tda7432.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/media/video/tda7432.c	Wed Apr 30 22:28:13 2003
@@ -312,8 +312,7 @@
  * i2c interface functions *
  * *********************** */
 
-static int tda7432_attach(struct i2c_adapter *adap, int addr,
-			  unsigned short flags, int kind)
+static int tda7432_attach(struct i2c_adapter *adap, int addr, int kind)
 {
 	struct tda7432 *t;
 	struct i2c_client *client;
diff -Nru a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c
--- a/drivers/media/video/tda9840.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/media/video/tda9840.c	Wed Apr 30 22:28:12 2003
@@ -178,7 +178,7 @@
 	return 0;
 }
 
-static int tda9840_detect(struct i2c_adapter *adapter, int address, unsigned short flags, int kind)
+static int tda9840_detect(struct i2c_adapter *adapter, int address, int kind)
 {
 	struct	i2c_client *client;
 	int result = 0;
diff -Nru a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c
--- a/drivers/media/video/tda9875.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/media/video/tda9875.c	Wed Apr 30 22:28:08 2003
@@ -240,8 +240,7 @@
 	return(0);
 }
 
-static int tda9875_attach(struct i2c_adapter *adap, int addr,
-			  unsigned short flags, int kind)
+static int tda9875_attach(struct i2c_adapter *adap, int addr, int kind)
 {
 	struct tda9875 *t;
 	struct i2c_client *client;
diff -Nru a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
--- a/drivers/media/video/tda9887.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/media/video/tda9887.c	Wed Apr 30 22:28:03 2003
@@ -345,8 +345,7 @@
 
 /* ---------------------------------------------------------------------- */
 
-static int tda9887_attach(struct i2c_adapter *adap, int addr,
-			  unsigned short flags, int kind)
+static int tda9887_attach(struct i2c_adapter *adap, int addr, int kind)
 {
 	struct tda9887 *t;
 
diff -Nru a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c
--- a/drivers/media/video/tea6415c.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/media/video/tea6415c.c	Wed Apr 30 22:28:14 2003
@@ -55,7 +55,7 @@
 static int tea6415c_id = 0;
 
 /* this function is called by i2c_probe */
-static int tea6415c_detect(struct i2c_adapter *adapter, int address, unsigned short flags, int kind)
+static int tea6415c_detect(struct i2c_adapter *adapter, int address, int kind)
 {
 	struct	i2c_client *client = 0;
 	int err = 0;
diff -Nru a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c
--- a/drivers/media/video/tea6420.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/media/video/tea6420.c	Wed Apr 30 22:28:09 2003
@@ -95,7 +95,7 @@
 }
 
 /* this function is called by i2c_probe */
-static int tea6420_detect(struct i2c_adapter *adapter, int address, unsigned short flags, int kind)
+static int tea6420_detect(struct i2c_adapter *adapter, int address, int kind)
 {
 	struct	i2c_client *client;
 	int err = 0, i = 0;
diff -Nru a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c
--- a/drivers/media/video/tuner-3036.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/media/video/tuner-3036.c	Wed Apr 30 22:28:08 2003
@@ -114,8 +114,7 @@
 /* ---------------------------------------------------------------------- */
 
 static int 
-tuner_attach(struct i2c_adapter *adap, int addr,
-	     unsigned short flags, int kind)
+tuner_attach(struct i2c_adapter *adap, int addr, int kind)
 {
 	static unsigned char buffer[] = { 0x29, 0x32, 0x2a, 0, 0x2b, 0 };
 
diff -Nru a/drivers/media/video/tuner.c b/drivers/media/video/tuner.c
--- a/drivers/media/video/tuner.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/media/video/tuner.c	Wed Apr 30 22:28:15 2003
@@ -776,8 +776,7 @@
 
 /* ---------------------------------------------------------------------- */
 
-static int tuner_attach(struct i2c_adapter *adap, int addr,
-			unsigned short flags, int kind)
+static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
 {
 	struct tuner *t;
 	struct i2c_client *client;
diff -Nru a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
--- a/drivers/media/video/tvaudio.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/media/video/tvaudio.c	Wed Apr 30 22:28:07 2003
@@ -1326,8 +1326,7 @@
 /* ---------------------------------------------------------------------- */
 /* i2c registration                                                       */
 
-static int chip_attach(struct i2c_adapter *adap, int addr,
-		       unsigned short flags, int kind)
+static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
 {
 	struct CHIPSTATE *chip;
 	struct CHIPDESC  *desc;
diff -Nru a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
--- a/drivers/media/video/videodev.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/media/video/videodev.c	Wed Apr 30 22:28:04 2003
@@ -28,6 +28,7 @@
 #include <linux/init.h>
 #include <linux/kmod.h>
 #include <linux/slab.h>
+#include <linux/devfs_fs_kernel.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <asm/semaphore.h>
@@ -375,7 +376,6 @@
 	int base;
 	int end;
 	char *name_base;
-	char name[16];
 	
 	switch(type)
 	{
@@ -426,19 +426,19 @@
 	vfd->minor=i;
 	up(&videodev_lock);
 
-	sprintf (name, "v4l/%s%d", name_base, i - base);
-	vfd->devfs_handle =
-		devfs_register (NULL, name, DEVFS_FL_DEFAULT,
-				VIDEO_MAJOR, vfd->minor,
-				S_IFCHR | S_IRUSR | S_IWUSR,
-				&video_fops,
-				NULL);
+	sprintf(vfd->devfs_name, "v4l/%s%d", name_base, i - base);
+	devfs_register(NULL, vfd->devfs_name, 0, VIDEO_MAJOR, vfd->minor,
+			S_IFCHR | S_IRUSR | S_IWUSR, &video_fops, NULL);
 	init_MUTEX(&vfd->lock);
 	
 #ifdef CONFIG_VIDEO_PROC_FS
-	sprintf (name, "%s%d", name_base, i - base);
-	videodev_proc_create_dev (vfd, name);
+{
+	char name[16];
+	sprintf(name, "%s%d", name_base, i - base);
+	videodev_proc_create_dev(vfd, name);
+}
 #endif
+
 	return 0;
 }
 
@@ -460,7 +460,7 @@
 	videodev_proc_destroy_dev (vfd);
 #endif
 
-	devfs_unregister (vfd->devfs_handle);
+	devfs_remove(vfd->devfs_name);
 	video_device[vfd->minor]=NULL;
 	up(&videodev_lock);
 }
diff -Nru a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c
--- a/drivers/media/video/w9966.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/media/video/w9966.c	Wed Apr 30 22:28:06 2003
@@ -157,7 +157,9 @@
 
 static int w9966_rReg(struct w9966_dev* cam, int reg);
 static int w9966_wReg(struct w9966_dev* cam, int reg, int data);
+#if 0
 static int w9966_rReg_i2c(struct w9966_dev* cam, int reg);
+#endif
 static int w9966_wReg_i2c(struct w9966_dev* cam, int reg, int data);
 static int w9966_findlen(int near, int size, int maxlen);
 static int w9966_calcscale(int size, int min, int max, int* beg, int* end, unsigned char* factor);
@@ -171,7 +173,9 @@
 static inline int  w9966_i2c_getsda(struct w9966_dev* cam);
 static inline int  w9966_i2c_getscl(struct w9966_dev* cam);
 static int w9966_i2c_wbyte(struct w9966_dev* cam, int data);
+#if 0
 static int w9966_i2c_rbyte(struct w9966_dev* cam);
+#endif
 
 static int w9966_v4l_ioctl(struct inode *inode, struct file *file,
 			   unsigned int cmd, unsigned long arg);
@@ -555,7 +559,8 @@
 // Expects a claimed pdev. -1 on error
 static inline int w9966_i2c_setscl(struct w9966_dev* cam, int state)
 {
-	int timeout;
+	unsigned long timeout;
+
 	if (state)
 		cam->i2c_state |= W9966_I2C_W_CLOCK;
 	else
@@ -616,6 +621,7 @@
 
 // Read a data byte with ack from the i2c-bus
 // Expects a claimed pdev. -1 on error
+#if 0
 static int w9966_i2c_rbyte(struct w9966_dev* cam)
 {
 	unsigned char data = 0x00;
@@ -635,9 +641,11 @@
 	}
 	return data;
 }
+#endif
 
 // Read a register from the i2c device.
 // Expects claimed pdev. -1 on error
+#if 0
 static int w9966_rReg_i2c(struct w9966_dev* cam, int reg)
 {
 	int data;
@@ -671,6 +679,7 @@
 	
 	return data;
 }
+#endif
 
 // Write a register to the i2c device.
 // Expects claimed pdev. -1 on error
diff -Nru a/drivers/media/video/zr36067.c b/drivers/media/video/zr36067.c
--- a/drivers/media/video/zr36067.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/media/video/zr36067.c	Wed Apr 30 22:28:19 2003
@@ -59,12 +59,10 @@
 #include <asm/page.h>
 #include <linux/sched.h>
 #include <linux/types.h>
-#include <linux/wrapper.h>
 
 #include <linux/spinlock.h>
 #include <linux/vmalloc.h>
 #include <linux/i2c-old.h>
-#define     MAP_NR(x)       virt_to_page(x)
 #define     ZORAN_HARDWARE  VID_HARDWARE_ZR36067
 
 #include <linux/videodev.h>
@@ -303,7 +301,7 @@
 			zr->v4l_gbuf[i].fbuffer_phys = virt_to_phys(mem);
 			zr->v4l_gbuf[i].fbuffer_bus = virt_to_bus(mem);
 			for (off = 0; off < v4l_bufsize; off += PAGE_SIZE)
-				mem_map_reserve(MAP_NR(mem + off));
+				SetPageReserved(virt_to_page(mem + off));
 			DEBUG1(printk
 			       (KERN_INFO
 				"%s: V4L frame %d mem 0x%lx (bus: 0x%lx)\n",
@@ -366,7 +364,7 @@
 		if (v4l_bufsize <= MAX_KMALLOC_MEM) {
 			mem = zr->v4l_gbuf[i].fbuffer;
 			for (off = 0; off < v4l_bufsize; off += PAGE_SIZE)
-				mem_map_unreserve(MAP_NR(mem + off));
+				ClearPageReserved(virt_to_page(mem + off));
 			kfree((void *) zr->v4l_gbuf[i].fbuffer);
 		}
 #if defined(CONFIG_BIGPHYS_AREA)
@@ -445,7 +443,7 @@
 			zr->jpg_gbuf[i].frag_tab[1] =
 			    ((zr->jpg_bufsize / 4) << 1) | 1;
 			for (off = 0; off < zr->jpg_bufsize; off += PAGE_SIZE)
-				mem_map_reserve(MAP_NR(mem + off));
+				SetPageReserved(virt_to_page(mem + off));
 		} else {
 			/* jpg_bufsize is allreay page aligned */
 			for (j = 0; j < zr->jpg_bufsize / PAGE_SIZE; j++) 
@@ -463,7 +461,7 @@
 				    virt_to_bus((void *) mem);
 				zr->jpg_gbuf[i].frag_tab[2 * j + 1] =
 				    (PAGE_SIZE / 4) << 1;
-				mem_map_reserve(MAP_NR(mem));
+				SetPageReserved(virt_to_page(mem));
 			}
 
 			zr->jpg_gbuf[i].frag_tab[2 * j - 1] |= 1;
@@ -503,7 +501,7 @@
 								  [0]);
 				for (off = 0; off < zr->jpg_bufsize;
 				     off += PAGE_SIZE)
-					mem_map_unreserve(MAP_NR
+					ClearPageReserved(virt_to_page
 							  (mem + off));
 				kfree((void *) mem);
 				zr->jpg_gbuf[i].frag_tab[0] = 0;
@@ -513,7 +511,7 @@
 			for (j = 0; j < zr->jpg_bufsize / PAGE_SIZE; j++) {
 				if (!zr->jpg_gbuf[i].frag_tab[2 * j])
 					break;
-				mem_map_unreserve(MAP_NR
+				ClearPageReserved(virt_to_page
 						  (bus_to_virt
 						   (zr->jpg_gbuf[i].
 						    frag_tab[2 * j])));
@@ -2782,12 +2780,13 @@
 	}
 }
 
-static void zoran_irq(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t zoran_irq(int irq, void *dev_id, struct pt_regs *regs)
 {
 	u32 stat, astat;
 	int count;
 	struct zoran *zr;
 	unsigned long flags;
+	int handled = 0;
 
 	zr = (struct zoran *) dev_id;
 	count = 0;
@@ -2806,7 +2805,7 @@
 		}
 		zr->last_isr = stat;
 		spin_unlock_irqrestore(&zr->lock, flags);
-		return;
+		return IRQ_HANDLED;
 	}
 
 	spin_lock_irqsave(&zr->lock, flags);
@@ -2817,6 +2816,7 @@
 		if (!astat) {
 			break;
 		}
+		handled = 1;
 		if (astat & cardvsync[zr->card]) {	// SW
 
 			if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS
@@ -3010,6 +3010,7 @@
 		zr->last_isr = stat;
 	}
 	spin_unlock_irqrestore(&zr->lock, flags);
+	return IRQ_RETVAL(handled);
 }
 
 /* Check a zoran_params struct for correctness, insert default params */
diff -Nru a/drivers/media/video/zr36120_mem.c b/drivers/media/video/zr36120_mem.c
--- a/drivers/media/video/zr36120_mem.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/media/video/zr36120_mem.c	Wed Apr 30 22:28:11 2003
@@ -21,7 +21,6 @@
 #include <linux/config.h>
 #include <linux/mm.h>
 #include <linux/pci.h>
-#include <linux/wrapper.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <asm/io.h>
@@ -51,7 +50,7 @@
 	if (mem) {
 		unsigned long adr = (unsigned long)mem;
 		while (size > 0) {
-			mem_map_reserve(virt_to_page(phys_to_virt(adr)));
+			SetPageReserved(virt_to_page(phys_to_virt(adr)));
 			adr += PAGE_SIZE;
 			size -= PAGE_SIZE;
 		}
@@ -65,7 +64,7 @@
 		unsigned long adr = (unsigned long)mem;
 		unsigned long siz = size;
 		while (siz > 0) {
-			mem_map_unreserve(virt_to_page(phys_to_virt(adr)));
+			ClearPageReserved(virt_to_page(phys_to_virt(adr)));
 			adr += PAGE_SIZE;
 			siz -= PAGE_SIZE;
 		}
diff -Nru a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
--- a/drivers/message/fusion/mptbase.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/message/fusion/mptbase.c	Wed Apr 30 22:28:06 2003
@@ -179,7 +179,7 @@
 /*
  *  Forward protos...
  */
-static void	mpt_interrupt(int irq, void *bus_id, struct pt_regs *r);
+static irqreturn_t mpt_interrupt(int irq, void *bus_id, struct pt_regs *r);
 static int	mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, MPT_FRAME_HDR *reply);
 
 static int	mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag);
@@ -312,7 +312,7 @@
  *	dispatches (calls) a protocol-specific callback routine to handle
  *	the protocol-specific details of the MPT request completion.
  */
-static void
+static irqreturn_t
 mpt_interrupt(int irq, void *bus_id, struct pt_regs *r)
 {
 	MPT_ADAPTER	*ioc;
@@ -338,7 +338,7 @@
 
 		if (!iocCmp) {
 			printk(KERN_WARNING "mpt_interrupt: Invalid ioc!\n");
-			return;
+			return IRQ_NONE;
 		}
 	}
 
@@ -353,7 +353,7 @@
 	while (1) {
 
 		if ((pa = CHIPREG_READ32(&ioc->chip->ReplyFifo)) == 0xFFFFFFFF)
-			return;
+			return IRQ_HANDLED;
 
 		cb_idx = 0;
 		freeme = 0;
@@ -501,10 +501,12 @@
 			dirqprintk((MYIOC_s_INFO_FMT "ISR processed %d replies.",
 					ioc->name, count));
 			dirqprintk((" Giving this ISR a break!\n"));
-			return;
+			return IRQ_HANDLED;
 		}
 
 	}	/* drain reply FIFO */
+
+	return IRQ_HANDLED;
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
diff -Nru a/drivers/message/i2o/i2o_core.c b/drivers/message/i2o/i2o_core.c
--- a/drivers/message/i2o/i2o_core.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/message/i2o/i2o_core.c	Wed Apr 30 22:28:11 2003
@@ -3463,10 +3463,11 @@
  *	to be rather simple. We keep the controller pointer in the cookie.
  */
  
-static void i2o_pci_interrupt(int irq, void *dev_id, struct pt_regs *r)
+static irqreturn_t i2o_pci_interrupt(int irq, void *dev_id, struct pt_regs *r)
 {
 	struct i2o_controller *c = dev_id;
 	i2o_run_queue(c);
+	return IRQ_HANDLED;
 }	
 
 /**
diff -Nru a/drivers/mtd/chips/sharp.c b/drivers/mtd/chips/sharp.c
--- a/drivers/mtd/chips/sharp.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/mtd/chips/sharp.c	Wed Apr 30 22:28:10 2003
@@ -431,7 +431,7 @@
 	unsigned long adr)
 {
 	int ret;
-	int timeo;
+	unsigned long timeo;
 	int status;
 	DECLARE_WAITQUEUE(wait, current);
 
diff -Nru a/drivers/mtd/devices/blkmtd.c b/drivers/mtd/devices/blkmtd.c
--- a/drivers/mtd/devices/blkmtd.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/mtd/devices/blkmtd.c	Wed Apr 30 22:28:03 2003
@@ -1049,17 +1049,10 @@
 /* Startup */
 static int __init init_blkmtd(void)
 {
-#ifdef MODULE
-  struct file *file = NULL;
-  struct inode *inode;
-#endif
-
-  int maj, min;
   int i, blocksize, blocksize_bits;
   loff_t size;
   int readonly = 0;
   int erase_size = CONFIG_MTD_BLKDEV_ERASESIZE;
-  dev_t rdev;
   struct block_device *bdev;
   int err;
   int mode;
@@ -1092,48 +1085,24 @@
   mode = (readonly) ? O_RDONLY : O_RDWR;
 
 #ifdef MODULE
-
-  file = filp_open(device, mode, 0);
-  if(IS_ERR(file)) {
-    printk("blkmtd: error, can't open device %s\n", device);
-    DEBUG(2, "blkmtd: filp_open returned %ld\n", PTR_ERR(file));
-    return 1;
-  }
-  
-  /* determine is this is a block device and if so get its major and minor
-     numbers */
-  inode = file->f_dentry->d_inode;
-  if(!S_ISBLK(inode->i_mode)) {
-    printk("blkmtd: %s not a block device\n", device);
-    filp_close(file, NULL);
-    return 1;
-  }
-  rdev = inode->i_bdev->bd_dev;
-  filp_close(file, NULL);
+  bdev = open_bdev_excl(device, mode, BDEV_RAW, NULL);
 #else
-  rdev = name_to_dev_t(device);
+  bdev = open_by_devnum(name_to_dev_t(device), FMODE_READ, BDEV_RAW);
 #endif
 
-  maj = MAJOR(rdev);
-  min = MINOR(rdev);
-  DEBUG(1, "blkmtd: found a block device major = %d, minor = %d\n", maj, min);
-
-  if(!rdev) {
-    printk("blkmtd: bad block device: `%s'\n", device);
+  if (IS_ERR(bdev)){
+    printk("blkmtd: error, can't open device %s\n", device);
+    DEBUG(2, "blkmtd: opening bdev returned %ld\n", PTR_ERR(bdev));
     return 1;
   }
 
-  if(maj == MTD_BLOCK_MAJOR) {
+  DEBUG(1, "blkmtd: devname = %s\n", bdevname(bdev, b));
+
+  if(MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) {
     printk("blkmtd: attempting to use an MTD device as a block device\n");
+    blkdev_put(bdev, BDEV_RAW);
     return 1;
   }
-  /* get the block device */
-  bdev = bdget(rdev);
-  err = blkdev_get(bdev, mode, 0, BDEV_RAW);
-  if (err)
-    return 1;
-
-  DEBUG(1, "blkmtd: devname = %s\n", bdevname(bdev, b));
   blocksize = BLOCK_SIZE;
 
   blocksize = bs ? bs : block_size(bdev);
diff -Nru a/drivers/mtd/maps/iq80321.c b/drivers/mtd/maps/iq80321.c
--- a/drivers/mtd/maps/iq80321.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/mtd/maps/iq80321.c	Wed Apr 30 22:28:10 2003
@@ -67,17 +67,17 @@
 }
 
 static struct map_info iq80321_map = {
-	name	= "IQ80321 flash",
-	size	= WINDOW_SIZE,
-	buswidth	= BUSWIDTH,
-	read8	= iq80321_read8,
-	read16	= iq80321_read16,
-	read32	= iq80321_read32,
-	copy_from	= iq80321_copy_from,
-	write8	= iq80321_write8,
-	write16	= iq80321_write16,
-	write32	= iq80321_write32,
-	copy_to	= iq80321_copy_to
+	.name	= "IQ80321 flash",
+	.size	= WINDOW_SIZE,
+	.buswidth	= BUSWIDTH,
+	.read8	= iq80321_read8,
+	.read16	= iq80321_read16,
+	.read32	= iq80321_read32,
+	.copy_from	= iq80321_copy_from,
+	.write8	= iq80321_write8,
+	.write16	= iq80321_write16,
+	.write32	= iq80321_write32,
+	.copy_to	= iq80321_copy_to
 };
 
 static struct mtd_partition iq80321_partitions[4] = {
diff -Nru a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
--- a/drivers/mtd/maps/pcmciamtd.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/mtd/maps/pcmciamtd.c	Wed Apr 30 22:28:04 2003
@@ -106,16 +106,7 @@
 MODULE_PARM_DESC(mem_type, "Set Memory type (0=Flash, 1=RAM, 2=ROM, default=0)");
 
 
-
-static inline void cs_error(client_handle_t handle, int func, int ret)
-{
-	error_info_t err = { func, ret };
-	CardServices(ReportError, handle, &err);
-}
-
-
 /* read/write{8,16} copy_{from,to} routines with window remapping to access whole card */
-
 static caddr_t remap_window(struct map_info *map, unsigned long to)
 {
 	struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
diff -Nru a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
--- a/drivers/mtd/mtdblock.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/mtd/mtdblock.c	Wed Apr 30 22:28:08 2003
@@ -19,7 +19,6 @@
 #define MAJOR_NR MTD_BLOCK_MAJOR
 #define DEVICE_NAME "mtdblock"
 #define DEVICE_NR(device) (device)
-#define LOCAL_END_REQUEST
 #include <linux/blk.h>
 #include <linux/devfs_fs_kernel.h>
 
@@ -528,25 +527,20 @@
         if (!mtd || mtd->type == MTD_ABSENT)
                 return;
 
-#ifdef CONFIG_DEVFS_FS
-        sprintf(name, DEVICE_NAME"/%d", mtd->index);
-        devfs_register(NULL, name, DEVFS_FL_DEFAULT,
-			MTD_BLOCK_MAJOR, mtd->index,
-                        S_IFBLK | S_IRUGO | S_IWUGO,
-                        &mtd_fops, NULL);
-#endif
-
 	disk = alloc_disk(1);
 	if (disk) {
 		disk->major = MAJOR_NR;
 		disk->first_minor = mtd->index;
 		disk->fops = &mtd_fops;
+
 		sprintf(disk->disk_name, "mtdblock%d", mtd->index);
+		sprintf(disk->devfs_name, "mtdblock/%d", mtd->index);
 
 		mtddisk[mtd->index] = disk;
 		set_capacity(disk, mtd->size / 512);
 		disk->private_data = &mtdblks[mtd->index];
 		disk->queue = &mtd_queue;
+
 		add_disk(disk);
 	}
 }
@@ -555,8 +549,6 @@
 {
         if (!mtd || mtd->type == MTD_ABSENT)
                 return;
-
-        devfs_remove(DEVICE_NAME"/%d", mtd->index);
 
         if (mtddisk[mtd->index]) {
 		del_gendisk(mtddisk[mtd->index]);
diff -Nru a/drivers/mtd/mtdblock_ro.c b/drivers/mtd/mtdblock_ro.c
--- a/drivers/mtd/mtdblock_ro.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/mtd/mtdblock_ro.c	Wed Apr 30 22:28:09 2003
@@ -18,7 +18,6 @@
 #include <linux/buffer_head.h>
 #include <linux/genhd.h>
 
-#define LOCAL_END_REQUEST
 #define MAJOR_NR MTD_BLOCK_MAJOR
 #define DEVICE_NAME "mtdblock"
 #include <linux/blk.h>
diff -Nru a/drivers/net/3c501.c b/drivers/net/3c501.c
--- a/drivers/net/3c501.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/3c501.c	Wed Apr 30 22:28:03 2003
@@ -510,7 +510,7 @@
  * TCP window.
  */
 
-static void el_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t el_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
 	struct net_local *lp;
@@ -558,7 +558,7 @@
 			}
 			lp->loading=2;		/* Force a reload */
 			spin_unlock(&lp->lock);
-			return;
+			goto out;
 		}
 
 		if (el_debug > 6)
@@ -606,7 +606,7 @@
 			outb(AX_XMIT, AX_CMD);
 			lp->stats.collisions++;
 			spin_unlock(&lp->lock);
-			return;
+			goto out;
 		}
 		else
 		{
@@ -675,7 +675,8 @@
 	inb(RX_STATUS);		/* Be certain that interrupts are cleared. */
 	inb(TX_STATUS);
 	spin_unlock(&lp->lock);
-	return;
+out:
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/net/3c501.h b/drivers/net/3c501.h
--- a/drivers/net/3c501.h	Wed Apr 30 22:28:08 2003
+++ b/drivers/net/3c501.h	Wed Apr 30 22:28:08 2003
@@ -8,7 +8,7 @@
 static int  el_open(struct net_device *dev);
 static void el_timeout(struct net_device *dev);
 static int  el_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static void el_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t el_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void el_receive(struct net_device *dev);
 static void el_reset(struct net_device *dev);
 static int  el1_close(struct net_device *dev);
diff -Nru a/drivers/net/3c505.c b/drivers/net/3c505.c
--- a/drivers/net/3c505.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/net/3c505.c	Wed Apr 30 22:28:20 2003
@@ -259,7 +259,7 @@
 
 static inline int get_status(unsigned int base_addr)
 {
-	int timeout = jiffies + 10*HZ/100;
+	unsigned long timeout = jiffies + 10*HZ/100;
 	register int stat1;
 	do {
 		stat1 = inb_status(base_addr);
@@ -283,7 +283,7 @@
 
 inline static void adapter_reset(struct net_device *dev)
 {
-	int timeout;
+	unsigned long timeout;
 	elp_device *adapter = dev->priv;
 	unsigned char orig_hcr = adapter->hcr_val;
 
@@ -343,7 +343,7 @@
 /* Primitive functions used by send_pcb() */
 static inline unsigned int send_pcb_slow(unsigned int base_addr, unsigned char byte)
 {
-	unsigned int timeout;
+	unsigned long timeout;
 	outb_command(byte, base_addr);
 	for (timeout = jiffies + 5*HZ/100; time_before(jiffies, timeout);) {
 		if (inb_status(base_addr) & HCRE)
@@ -402,7 +402,7 @@
 static int send_pcb(struct net_device *dev, pcb_struct * pcb)
 {
 	int i;
-	int timeout;
+	unsigned long timeout;
 	elp_device *adapter = dev->priv;
 	unsigned long flags;
 
@@ -488,7 +488,7 @@
 	int i, j;
 	int total_length;
 	int stat;
-	int timeout;
+	unsigned long timeout;
 	unsigned long flags;
 
 	elp_device *adapter = dev->priv;
@@ -662,14 +662,14 @@
  *
  ******************************************************/
 
-static void elp_interrupt(int irq, void *dev_id, struct pt_regs *reg_ptr)
+static irqreturn_t elp_interrupt(int irq, void *dev_id, struct pt_regs *reg_ptr)
 {
 	int len;
 	int dlen;
 	int icount = 0;
 	struct net_device *dev;
 	elp_device *adapter;
-	int timeout;
+	unsigned long timeout;
 
 	dev = dev_id;
 	adapter = (elp_device *) dev->priv;
@@ -855,6 +855,7 @@
 	 * indicate no longer in interrupt routine
 	 */
 	spin_unlock(&adapter->lock);
+	return IRQ_HANDLED;
 }
 
 
@@ -947,7 +948,7 @@
 	if (!send_pcb(dev, &adapter->tx_pcb))
 		printk("%s: couldn't send memory configuration command\n", dev->name);
 	else {
-		int timeout = jiffies + TIMEOUT;
+		unsigned long timeout = jiffies + TIMEOUT;
 		while (adapter->got[CMD_CONFIGURE_ADAPTER_MEMORY] == 0 && time_before(jiffies, timeout));
 		if (time_after_eq(jiffies, timeout))
 			TIMEOUT_MSG(__LINE__);
@@ -966,7 +967,7 @@
 	if (!send_pcb(dev, &adapter->tx_pcb))
 		printk("%s: couldn't send 82586 configure command\n", dev->name);
 	else {
-		int timeout = jiffies + TIMEOUT;
+		unsigned long timeout = jiffies + TIMEOUT;
 		while (adapter->got[CMD_CONFIGURE_82586] == 0 && time_before(jiffies, timeout));
 		if (time_after_eq(jiffies, timeout))
 			TIMEOUT_MSG(__LINE__);
@@ -1150,7 +1151,7 @@
 	if (!send_pcb(dev, &adapter->tx_pcb))
 		printk("%s: couldn't send get statistics command\n", dev->name);
 	else {
-		int timeout = jiffies + TIMEOUT;
+		unsigned long timeout = jiffies + TIMEOUT;
 		while (adapter->got[CMD_NETWORK_STATISTICS] == 0 && time_before(jiffies, timeout));
 		if (time_after_eq(jiffies, timeout)) {
 			TIMEOUT_MSG(__LINE__);
@@ -1317,7 +1318,7 @@
 		if (!send_pcb(dev, &adapter->tx_pcb))
 			printk("%s: couldn't send set_multicast command\n", dev->name);
 		else {
-			int timeout = jiffies + TIMEOUT;
+			unsigned long timeout = jiffies + TIMEOUT;
 			while (adapter->got[CMD_LOAD_MULTICAST_LIST] == 0 && time_before(jiffies, timeout));
 			if (time_after_eq(jiffies, timeout)) {
 				TIMEOUT_MSG(__LINE__);
@@ -1344,7 +1345,7 @@
 		printk("%s: couldn't send 82586 configure command\n", dev->name);
 	}
 	else {
-		int timeout = jiffies + TIMEOUT;
+		unsigned long timeout = jiffies + TIMEOUT;
 		spin_unlock_irqrestore(&adapter->lock, flags);
 		while (adapter->got[CMD_CONFIGURE_82586] == 0 && time_before(jiffies, timeout));
 		if (time_after_eq(jiffies, timeout))
@@ -1396,10 +1397,8 @@
 
 static int __init elp_sense(struct net_device *dev)
 {
-	int timeout;
 	int addr = dev->base_addr;
 	const char *name = dev->name;
-	unsigned long flags;
 	byte orig_HSR;
 
 	if (!request_region(addr, ELP_IO_EXTENT, "3c505"))
@@ -1506,7 +1505,8 @@
 int __init elplus_probe(struct net_device *dev)
 {
 	elp_device *adapter;
-	int i, tries, tries1, timeout, okay;
+	int i, tries, tries1, okay;
+	unsigned long timeout;
 	unsigned long cookie = 0;
 
 	SET_MODULE_OWNER(dev);
diff -Nru a/drivers/net/3c505.h b/drivers/net/3c505.h
--- a/drivers/net/3c505.h	Wed Apr 30 22:28:13 2003
+++ b/drivers/net/3c505.h	Wed Apr 30 22:28:13 2003
@@ -279,7 +279,7 @@
 		unsigned int length;
 		struct sk_buff *skb;
 	        void *target;
-		long int start_time;
+		unsigned long start_time;
 	} current_dma;
 
 	/* flags */
diff -Nru a/drivers/net/3c507.c b/drivers/net/3c507.c
--- a/drivers/net/3c507.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/net/3c507.c	Wed Apr 30 22:28:14 2003
@@ -291,7 +291,7 @@
 static int	el16_probe1(struct net_device *dev, int ioaddr);
 static int	el16_open(struct net_device *dev);
 static int	el16_send_packet(struct sk_buff *skb, struct net_device *dev);
-static void	el16_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t el16_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void el16_rx(struct net_device *dev);
 static int	el16_close(struct net_device *dev);
 static struct net_device_stats *el16_get_stats(struct net_device *dev);
@@ -516,7 +516,7 @@
 
 /*	The typical workload of the driver:
 	Handle the network interface interrupts. */
-static void el16_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t el16_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
 	struct net_local *lp;
@@ -526,7 +526,7 @@
 
 	if (dev == NULL) {
 		printk ("net_interrupt(): irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	ioaddr = dev->base_addr;
@@ -616,6 +616,7 @@
 	/* Enable the 82586's interrupt input. */
 	outb(0x84, ioaddr + MISC_CTRL);
 	spin_unlock(&lp->lock);
+	return IRQ_HANDLED;
 }
 
 static int el16_close(struct net_device *dev)
diff -Nru a/drivers/net/3c509.c b/drivers/net/3c509.c
--- a/drivers/net/3c509.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/3c509.c	Wed Apr 30 22:28:03 2003
@@ -192,7 +192,7 @@
 static ushort read_eeprom(int ioaddr, int index);
 static int el3_open(struct net_device *dev);
 static int el3_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static void el3_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t el3_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void update_stats(struct net_device *dev);
 static struct net_device_stats *el3_get_stats(struct net_device *dev);
 static int el3_rx(struct net_device *dev);
@@ -882,7 +882,7 @@
 }
 
 /* The EL3 interrupt handler. */
-static void
+static irqreturn_t
 el3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *)dev_id;
@@ -892,7 +892,7 @@
 
 	if (dev == NULL) {
 		printk ("el3_interrupt(): irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	lp = (struct el3_private *)dev->priv;
@@ -967,7 +967,7 @@
 			   inw(ioaddr + EL3_STATUS));
 	}
 	spin_unlock(&lp->lock);
-	return;
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/net/3c515.c b/drivers/net/3c515.c
--- a/drivers/net/3c515.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/net/3c515.c	Wed Apr 30 22:28:05 2003
@@ -1,4 +1,3 @@
-
 /*
 	Written 1997-1998 by Donald Becker.
 
@@ -387,7 +386,7 @@
 static int corkscrew_rx(struct net_device *dev);
 static void corkscrew_timeout(struct net_device *dev);
 static int boomerang_rx(struct net_device *dev);
-static void corkscrew_interrupt(int irq, void *dev_id,
+static irqreturn_t corkscrew_interrupt(int irq, void *dev_id,
 				    struct pt_regs *regs);
 static int corkscrew_close(struct net_device *dev);
 static void update_stats(int addr, struct net_device *dev);
@@ -1150,7 +1149,7 @@
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
 
-static void corkscrew_interrupt(int irq, void *dev_id,
+static irqreturn_t corkscrew_interrupt(int irq, void *dev_id,
 				    struct pt_regs *regs)
 {
 	/* Use the now-standard shared IRQ implementation. */
@@ -1289,6 +1288,7 @@
 
 	if (corkscrew_debug > 4)
 		printk("%s: exiting interrupt, status %4.4x.\n", dev->name, status);
+	return IRQ_HANDLED;
 }
 
 static int corkscrew_rx(struct net_device *dev)
diff -Nru a/drivers/net/3c523.c b/drivers/net/3c523.c
--- a/drivers/net/3c523.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/net/3c523.c	Wed Apr 30 22:28:09 2003
@@ -179,7 +179,7 @@
       	dev->name,__LINE__); \
       elmc_id_reset586(); } } }
 
-static void elmc_interrupt(int irq, void *dev_id, struct pt_regs *reg_ptr);
+static irqreturn_t elmc_interrupt(int irq, void *dev_id, struct pt_regs *reg_ptr);
 static int elmc_open(struct net_device *dev);
 static int elmc_close(struct net_device *dev);
 static int elmc_send_packet(struct sk_buff *, struct net_device *);
@@ -876,7 +876,8 @@
  * Interrupt Handler ...
  */
 
-static void elmc_interrupt(int irq, void *dev_id, struct pt_regs *reg_ptr)
+static irqreturn_t
+elmc_interrupt(int irq, void *dev_id, struct pt_regs *reg_ptr)
 {
 	struct net_device *dev = (struct net_device *) dev_id;
 	unsigned short stat;
@@ -884,7 +885,7 @@
 
 	if (dev == NULL) {
 		printk(KERN_ERR "elmc-interrupt: irq %d for unknown device.\n", (int) -(((struct pt_regs *) reg_ptr)->orig_eax + 2));
-		return;
+		return IRQ_NONE;
 	} else if (!netif_running(dev)) {
 		/* The 3c523 has this habit of generating interrupts during the
 		   reset.  I'm not sure if the ni52 has this same problem, but it's
@@ -893,10 +894,10 @@
 		   might have missed a few. */
 
 		elmc_id_attn586();	/* ack inter. and disable any more */
-		return;
+		return IRQ_HANDLED;
 	} else if (!(ELMC_CTRL_INT & inb(dev->base_addr + ELMC_CTRL))) {
 		/* wasn't this device */
-		return;
+		return IRQ_NONE;
 	}
 	/* reading ELMC_CTRL also clears the INT bit. */
 
@@ -943,6 +944,7 @@
 			break;
 		}
 	}
+	return IRQ_HANDLED;
 }
 
 /*******************************************************
diff -Nru a/drivers/net/3c527.c b/drivers/net/3c527.c
--- a/drivers/net/3c527.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/net/3c527.c	Wed Apr 30 22:28:10 2003
@@ -213,7 +213,7 @@
 static int	mc32_open(struct net_device *dev);
 static void	mc32_timeout(struct net_device *dev);
 static int	mc32_send_packet(struct sk_buff *skb, struct net_device *dev);
-static void	mc32_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t mc32_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static int	mc32_close(struct net_device *dev);
 static struct	net_device_stats *mc32_get_stats(struct net_device *dev);
 static void	mc32_set_multicast_list(struct net_device *dev);
@@ -1347,7 +1347,7 @@
  *
  */
 
-static void mc32_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t mc32_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
 	struct net_device *dev = dev_id;
 	struct mc32_local *lp;
@@ -1357,7 +1357,7 @@
 	
 	if (dev == NULL) {
 		printk(KERN_WARNING "%s: irq %d for unknown device.\n", cardname, irq);
-		return;
+		return IRQ_NONE;
 	}
  
 	ioaddr = dev->base_addr;
@@ -1461,7 +1461,7 @@
 	if(rx_event) 
 		mc32_rx_ring(dev);
 
-	return;
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/net/3c59x.c b/drivers/net/3c59x.c
--- a/drivers/net/3c59x.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/3c59x.c	Wed Apr 30 22:28:03 2003
@@ -885,8 +885,8 @@
 static int boomerang_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static int vortex_rx(struct net_device *dev);
 static int boomerang_rx(struct net_device *dev);
-static void vortex_interrupt(int irq, void *dev_id, struct pt_regs *regs);
-static void boomerang_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t vortex_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t boomerang_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static int vortex_close(struct net_device *dev);
 static void dump_tx_ring(struct net_device *dev);
 static void update_stats(long ioaddr, struct net_device *dev);
@@ -2208,14 +2208,16 @@
  * full_bus_master_tx == 0 && full_bus_master_rx == 0
  */
 
-static void vortex_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t
+vortex_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
 	struct vortex_private *vp = (struct vortex_private *)dev->priv;
 	long ioaddr;
 	int status;
 	int work_done = max_interrupt_work;
-	
+	int handled = 0;
+
 	ioaddr = dev->base_addr;
 	spin_lock(&vp->lock);
 
@@ -2226,6 +2228,7 @@
 
 	if ((status & IntLatch) == 0)
 		goto handler_exit;		/* No interrupt: shared IRQs cause this */
+	handled = 1;
 
 	if (status & IntReq) {
 		status |= vp->deferred;
@@ -2302,6 +2305,7 @@
 			   dev->name, status);
 handler_exit:
 	spin_unlock(&vp->lock);
+	return IRQ_RETVAL(handled);
 }
 
 /*
@@ -2309,13 +2313,15 @@
  * full_bus_master_tx == 1 && full_bus_master_rx == 1
  */
 
-static void boomerang_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t
+boomerang_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
 	struct vortex_private *vp = (struct vortex_private *)dev->priv;
 	long ioaddr;
 	int status;
 	int work_done = max_interrupt_work;
+	int handled;
 
 	ioaddr = dev->base_addr;
 
@@ -2330,14 +2336,18 @@
 	if (vortex_debug > 6)
 		printk(KERN_DEBUG "boomerang_interrupt. status=0x%4x\n", status);
 
-	if ((status & IntLatch) == 0)
+	if ((status & IntLatch) == 0) {
+		handled = 0;
 		goto handler_exit;		/* No interrupt: shared IRQs can cause this */
+	}
 
 	if (status == 0xffff) {		/* h/w no longer present (hotplug)? */
 		if (vortex_debug > 1)
 			printk(KERN_DEBUG "boomerang_interrupt(1): status = 0xffff\n");
+		handled = 0;
 		goto handler_exit;
 	}
+	handled = 1;
 
 	if (status & IntReq) {
 		status |= vp->deferred;
@@ -2432,6 +2442,7 @@
 			   dev->name, status);
 handler_exit:
 	spin_unlock(&vp->lock);
+	return IRQ_RETVAL(handled);
 }
 
 static int vortex_rx(struct net_device *dev)
diff -Nru a/drivers/net/68360enet.c b/drivers/net/68360enet.c
--- a/drivers/net/68360enet.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/net/68360enet.c	Wed Apr 30 22:28:05 2003
@@ -147,8 +147,7 @@
 static int scc_enet_open(struct net_device *dev);
 static int scc_enet_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static int scc_enet_rx(struct net_device *dev);
-/* static void scc_enet_interrupt(void *dev_id); */
-static void scc_enet_interrupt(int vec, void *dev_id, struct pt_regs *fp);
+static irqreturn_t scc_enet_interrupt(int vec, void *dev_id, struct pt_regs *fp);
 static int scc_enet_close(struct net_device *dev);
 /* static struct net_device_stats *scc_enet_get_stats(struct net_device *dev); */
 static struct net_device_stats *scc_enet_get_stats(struct net_device *dev);
@@ -316,8 +315,7 @@
 /* The interrupt handler.
  * This is called from the CPM handler, not the MPC core interrupt.
  */
-/* static void scc_enet_interrupt(void *dev_id) */
-static void scc_enet_interrupt(int vec, void *dev_id, struct pt_regs *fp)
+static irqreturn_t scc_enet_interrupt(int vec, void *dev_id, struct pt_regs *fp)
 {
 	struct	net_device *dev = (struct net_device *)dev_id;
 	volatile struct	scc_enet_private *cep;
@@ -454,7 +452,7 @@
 		printk("CPM ENET: BSY can't happen.\n");
 	}
 
-	return;
+	return IRQ_HANDLED;
 }
 
 /* During a receive, the cur_rx points to the current incoming buffer.
diff -Nru a/drivers/net/7990.c b/drivers/net/7990.c
--- a/drivers/net/7990.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/net/7990.c	Wed Apr 30 22:28:13 2003
@@ -397,7 +397,8 @@
         return 0;
 }
 
-static void lance_interrupt (int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t
+lance_interrupt (int irq, void *dev_id, struct pt_regs *regs)
 {
         struct net_device *dev = (struct net_device *)dev_id;
         struct lance_private *lp = (struct lance_private *)dev->priv;
@@ -413,7 +414,7 @@
         
         if (!(csr0 & LE_C0_INTR)) {     /* Check if any interrupt has */
 		spin_lock (&lp->devlock);
-                return;                 /* been generated by the Lance. */
+                return IRQ_NONE;        /* been generated by the Lance. */
 	}
 
         /* Acknowledge all the interrupt sources ASAP */
@@ -451,6 +452,7 @@
         WRITERDP(LE_C0_BABL|LE_C0_CERR|LE_C0_MISS|LE_C0_MERR|LE_C0_IDON|LE_C0_INEA);
 
 	spin_unlock (&lp->devlock);
+	return IRQ_HANDLED;
 }
 
 int lance_open (struct net_device *dev)
diff -Nru a/drivers/net/8139cp.c b/drivers/net/8139cp.c
--- a/drivers/net/8139cp.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/net/8139cp.c	Wed Apr 30 22:28:09 2003
@@ -658,7 +658,8 @@
 	cp->rx_tail = rx_tail;
 }
 
-static void cp_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
+static irqreturn_t
+cp_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_instance;
 	struct cp_private *cp = dev->priv;
@@ -666,7 +667,7 @@
 
 	status = cpr16(IntrStatus);
 	if (!status || (status == 0xFFFF))
-		return;
+		return IRQ_NONE;
 
 	if (netif_msg_intr(cp))
 		printk(KERN_DEBUG "%s: intr, status %04x cmd %02x cpcmd %04x\n",
@@ -693,6 +694,7 @@
 	}
 
 	spin_unlock(&cp->lock);
+	return IRQ_HANDLED;
 }
 
 static void cp_tx (struct cp_private *cp)
@@ -1777,7 +1779,6 @@
 	long pciaddr;
 	unsigned int addr_len, i;
 	u8 pci_rev, cache_size;
-	u16 pci_command;
 	unsigned int board_type = (unsigned int) ent->driver_data;
 
 #ifndef MODULE
@@ -1935,12 +1936,8 @@
 	}
 
 	/* enable busmastering and memory-write-invalidate */
-	pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
-	if (!(pci_command & PCI_COMMAND_INVALIDATE)) {
-		pci_command |= PCI_COMMAND_INVALIDATE;
-		pci_write_config_word(pdev, PCI_COMMAND, pci_command);
-	}
 	pci_set_master(pdev);
+	pci_set_mwi(pdev);
 
 	if (cp->wol_enabled) cp_set_d3_state (cp);
 
diff -Nru a/drivers/net/8139too.c b/drivers/net/8139too.c
--- a/drivers/net/8139too.c	Wed Apr 30 22:28:02 2003
+++ b/drivers/net/8139too.c	Wed Apr 30 22:28:03 2003
@@ -615,7 +615,7 @@
 static void rtl8139_init_ring (struct net_device *dev);
 static int rtl8139_start_xmit (struct sk_buff *skb,
 			       struct net_device *dev);
-static void rtl8139_interrupt (int irq, void *dev_instance,
+static irqreturn_t rtl8139_interrupt (int irq, void *dev_instance,
 			       struct pt_regs *regs);
 static int rtl8139_close (struct net_device *dev);
 static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
@@ -2029,7 +2029,7 @@
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
-static void rtl8139_interrupt (int irq, void *dev_instance,
+static irqreturn_t rtl8139_interrupt (int irq, void *dev_instance,
 			       struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *) dev_instance;
@@ -2038,6 +2038,7 @@
 	void *ioaddr = tp->mmio_addr;
 	int ackstat, status;
 	int link_changed = 0; /* avoid bogus "uninit" warning */
+	int handled = 0;
 
 	spin_lock (&tp->lock);
 
@@ -2053,6 +2054,8 @@
 		      RxFIFOOver | TxErr | TxOK | RxErr | RxOK)) == 0)
 			break;
 
+		handled = 1;
+
 		/* Acknowledge all of the current interrupt sources ASAP, but
 		   an first get an additional status bit from CSCR. */
 		if (status & RxUnderrun)
@@ -2097,6 +2100,7 @@
 
 	DPRINTK ("%s: exiting interrupt, intr_status=%#4.4x.\n",
 		 dev->name, RTL_R16 (IntrStatus));
+	return IRQ_RETVAL(handled);
 }
 
 
diff -Nru a/drivers/net/82596.c b/drivers/net/82596.c
--- a/drivers/net/82596.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/net/82596.c	Wed Apr 30 22:28:13 2003
@@ -357,7 +357,7 @@
 
 static int i596_open(struct net_device *dev);
 static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static void i596_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t i596_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static int i596_close(struct net_device *dev);
 static struct net_device_stats *i596_get_stats(struct net_device *dev);
 static void i596_add_cmd(struct net_device *dev, struct i596_cmd *cmd);
@@ -1018,8 +1018,6 @@
 
 	netif_start_queue(dev);
 
-	MOD_INC_USE_COUNT;
-
 	/* Initialize the 82596 memory */
 	if (init_i596_mem(dev)) {
 		res = -EAGAIN;
@@ -1218,6 +1216,7 @@
 	DEB(DEB_PROBE,printk(KERN_INFO "%s", version));
 
 	/* The 82596-specific entries in the device structure. */
+	SET_MODULE_OWNER(dev);
 	dev->open = i596_open;
 	dev->stop = i596_close;
 	dev->hard_start_xmit = i596_start_xmit;
@@ -1247,24 +1246,25 @@
 	return 0;
 }
 
-static void i596_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t i596_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
 	struct i596_private *lp;
 	short ioaddr;
 	unsigned short status, ack_cmd = 0;
+	int handled = 0;
 
 #ifdef ENABLE_BVME6000_NET
 	if (MACH_IS_BVME6000) {
 		if (*(char *) BVME_LOCAL_IRQ_STAT & BVME_ETHERR) {
 			i596_error(irq, dev_id, regs);
-			return;
+			return IRQ_HANDLED;
 		}
 	}
 #endif
 	if (dev == NULL) {
 		printk(KERN_ERR "i596_interrupt(): irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	ioaddr = dev->base_addr;
@@ -1283,6 +1283,7 @@
 	if ((status & 0x8000) || (status & 0x2000)) {
 		struct i596_cmd *ptr;
 
+		handled = 1;
 		if ((status & 0x8000))
 			DEB(DEB_INTS,printk(KERN_DEBUG "%s: i596 interrupt completed command.\n", dev->name));
 		if ((status & 0x2000))
@@ -1405,7 +1406,7 @@
 	DEB(DEB_INTS,printk(KERN_DEBUG "%s: exiting interrupt.\n", dev->name));
 
 	spin_unlock (&lp->lock);
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 static int i596_close(struct net_device *dev)
@@ -1450,7 +1451,6 @@
 
 	free_irq(dev->irq, dev);
 	remove_rx_bufs(dev);
-	MOD_DEC_USE_COUNT;
 
 	return 0;
 }
diff -Nru a/drivers/net/8390.c b/drivers/net/8390.c
--- a/drivers/net/8390.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/net/8390.c	Wed Apr 30 22:28:04 2003
@@ -421,7 +421,7 @@
  * needed.
  */
 
-void ei_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+irqreturn_t ei_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
 	struct net_device *dev = dev_id;
 	long e8390_base;
@@ -431,7 +431,7 @@
 	if (dev == NULL) 
 	{
 		printk ("net_interrupt(): irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
     
 	e8390_base = dev->base_addr;
@@ -454,7 +454,7 @@
 			   inb_p(e8390_base + EN0_IMR));
 #endif
 		spin_unlock(&ei_local->page_lock);
-		return;
+		return IRQ_NONE;
 	}
     
 	/* Change to page 0 and read the intr status reg. */
@@ -520,7 +520,7 @@
 		}
 	}
 	spin_unlock(&ei_local->page_lock);
-	return;
+	return IRQ_HANDLED;
 }
 
 /**
diff -Nru a/drivers/net/8390.h b/drivers/net/8390.h
--- a/drivers/net/8390.h	Wed Apr 30 22:28:12 2003
+++ b/drivers/net/8390.h	Wed Apr 30 22:28:13 2003
@@ -43,7 +43,7 @@
 extern void NS8390_init(struct net_device *dev, int startp);
 extern int ei_open(struct net_device *dev);
 extern int ei_close(struct net_device *dev);
-extern void ei_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+extern irqreturn_t ei_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 /* You have one of these per-board */
 struct ei_device {
diff -Nru a/drivers/net/Kconfig b/drivers/net/Kconfig
--- a/drivers/net/Kconfig	Wed Apr 30 22:28:16 2003
+++ b/drivers/net/Kconfig	Wed Apr 30 22:28:16 2003
@@ -12,7 +12,7 @@
 	  telephone line with a modem either via UUCP (UUCP is a protocol to
 	  forward mail and news between unix hosts over telephone lines; read
 	  the UUCP-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>) or dialing up a shell
+	  <http://www.tldp.org/docs.html#howto>) or dialing up a shell
 	  account or a BBS, even using term (term is a program which gives you
 	  almost full Internet connectivity if you have a regular dial up
 	  shell account on some Internet connected Unix computer. Read
@@ -32,7 +32,7 @@
 
 	  Make sure to read the NET-3-HOWTO. Eventually, you will have to read
 	  Olaf Kirch's excellent and free book "Network Administrator's
-	  Guide", to be found in <http://www.linuxdoc.org/docs.html#guide>. If
+	  Guide", to be found in <http://www.tldp.org/docs.html#guide>. If
 	  unsure, say Y.
 
 if NETDEVICES
@@ -51,7 +51,7 @@
 	  thing often comes in handy, the default is Y. It won't enlarge your
 	  kernel either. What a deal. Read about it in the Network
 	  Administrator's Guide, available from
-	  <http://www.linuxdoc.org/docs.html#guide>.
+	  <http://www.tldp.org/docs.html#guide>.
 
 	  If you want to compile this as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
@@ -98,7 +98,7 @@
 	  Say Y if you want this and read
 	  <file:Documentation/networking/eql.txt>.  You may also want to read
 	  section 6.2 of the NET-3-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -206,7 +206,7 @@
 	  If your Linux machine will be connected to an Ethernet and you have
 	  an Ethernet network interface card (NIC) installed in your computer,
 	  say Y here and read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. You will then also have
+	  <http://www.tldp.org/docs.html#howto>. You will then also have
 	  to say Y to the driver for your particular NIC.
 
 	  Note that the answer to this question won't directly affect the
@@ -357,7 +357,7 @@
 	  If you want to include a driver to support Nubus or LC-PDS
 	  Ethernet cards using an NS8390 chipset or its equivalent, say Y
 	  and read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 config MAC89x0
 	tristate "Macintosh CS89x0 based ethernet cards"
@@ -366,7 +366,7 @@
 	  Support for CS89x0 chipset based Ethernet cards.  If you have a
 	  Nubus or LC-PDS network (Ethernet) card of this type, say Y and
 	  read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to compile this as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
@@ -382,7 +382,7 @@
 	  the onboard Ethernet in many Quadras as well as some LC-PDS,
 	  a few Nubus and all known Comm Slot Ethernet cards.  If you have
 	  one of these say Y and read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to compile this as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
@@ -397,7 +397,7 @@
 	  Support for the onboard AMD 79C940 MACE Ethernet controller used in
 	  the 660AV and 840AV Macintosh.  If you have one of these Macintoshes
 	  say Y and read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 config MVME147_NET
 	tristate "MVME147 (Lance) Ethernet support"
@@ -516,7 +516,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 config STNIC
 	tristate "National DP83902AV  support"
@@ -595,7 +595,7 @@
 	help
 	  If you have a network (Ethernet) card belonging to this class, say Y
 	  and read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  Note that the answer to this question doesn't directly affect the
 	  kernel: saying N will just cause the configurator to skip all
@@ -608,7 +608,7 @@
 	---help---
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  Also, consider buying a
+	  <http://www.tldp.org/docs.html#howto>.  Also, consider buying a
 	  new card, since the 3c501 is slow, broken, and obsolete: you will
 	  have problems.  Some people suggest to ping ("man ping") a nearby
 	  machine every minute ("man cron") when using this card.
@@ -625,7 +625,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -640,7 +640,7 @@
 	  Information about this network (Ethernet) card can be found in
 	  <file:Documentation/networking/3c505.txt>.  If you have a card of
 	  this type, say Y and read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to compile this as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
@@ -654,7 +654,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -668,7 +668,7 @@
 	---help---
 	  If you have a network (Ethernet) card belonging to the 3Com
 	  EtherLinkIII series, say Y and read the Ethernet-HOWTO, available
-	  from <http://www.linuxdoc.org/docs.html#howto>.
+	  from <http://www.tldp.org/docs.html#howto>.
 
 	  If your card is not working you may need to use the DOS
 	  setup disk to disable Plug & Play mode, and to select the default
@@ -686,7 +686,7 @@
 	help
 	  If you have a 3Com ISA EtherLink XL "Corkscrew" 3c515 Fast Ethernet
 	  network card, say Y and read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to compile this as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
@@ -700,7 +700,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -714,7 +714,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -736,7 +736,7 @@
 	  "Hurricane" (3c555/3cSOHO)                           PCI
 
 	  If you have such a card, say Y and read the Ethernet-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>. More
+	  available from <http://www.tldp.org/docs.html#howto>. More
 	  specific information is in
 	  <file:Documentation/networking/vortex.txt> and in the comments at
 	  the beginning of <file:drivers/net/3c59x.c>.
@@ -758,7 +758,7 @@
 
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -772,7 +772,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. Some LinkSys cards are
+	  <http://www.tldp.org/docs.html#howto>. Some LinkSys cards are
 	  of this type.
 
 	  If you want to compile this driver as a module ( = code which can be
@@ -786,7 +786,7 @@
 	help
 	  If you have a network (Ethernet) card belonging to this class, say Y
 	  and read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  Note that the answer to this question doesn't directly affect the
 	  kernel: saying N will just cause the configurator to skip all
@@ -799,7 +799,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -813,7 +813,7 @@
 	help
 	  If you have a network (Ethernet) card of this type and are running
 	  an MCA based system (PS/2), say Y and read the Ethernet-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>.
+	  available from <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -827,7 +827,7 @@
 	---help---
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  Important: There have been many reports that, with some motherboards
 	  mixing an SMC Ultra and an Adaptec AHA154x SCSI card (or compatible,
@@ -848,7 +848,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -865,7 +865,7 @@
 	  another SMC9192/9194 based chipset.  Say Y if you want it compiled
 	  into the kernel, and read the file
 	  <file:Documentation/networking/smc9.txt> and the Ethernet-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>.
+	  available from <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -879,7 +879,7 @@
 	help
 	  If you have a network (Ethernet) card belonging to this class, such
 	  as the NI5010, NI5210 or NI6210, say Y and read the Ethernet-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>.
+	  available from <http://www.tldp.org/docs.html#howto>.
 
 	  Note that the answer to this question doesn't directly affect the
 	  kernel: saying N will just cause the configurator to skip all
@@ -892,7 +892,7 @@
 	---help---
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. Note that this is still
+	  <http://www.tldp.org/docs.html#howto>. Note that this is still
 	  experimental code.
 
 	  This driver is also available as a module ( = code which can be
@@ -907,7 +907,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -921,7 +921,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -937,7 +937,7 @@
 	---help---
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -952,7 +952,7 @@
 	---help---
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto> as well as
+	  <http://www.tldp.org/docs.html#howto> as well as
 	  <file:drivers/net/depca.c>.
 
 	  If you want to compile this as a module ( = code which can be
@@ -968,7 +968,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to compile this as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
@@ -984,7 +984,7 @@
 	  bus system (that's the way the cards talks to the other components
 	  of your computer) is ISA (as opposed to EISA, VLB or PCI), say Y.
 	  Make sure you know the name of your card. Read the Ethernet-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>.
+	  available from <http://www.tldp.org/docs.html#howto>.
 
 	  If unsure, say Y.
 
@@ -999,7 +999,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -1015,7 +1015,7 @@
 	  cards. If this is for you, say Y and read
 	  <file:Documentation/networking/ewrk3.txt> in the kernel source as
 	  well as the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to compile this as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
@@ -1029,7 +1029,7 @@
 	---help---
 	  If you have an EtherExpress16 network (Ethernet) card, say Y and
 	  read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  Note that the Intel
+	  <http://www.tldp.org/docs.html#howto>.  Note that the Intel
 	  EtherExpress16 card used to be regarded as a very poor choice
 	  because the driver was very unreliable. We now have a new driver
 	  that should do better.
@@ -1048,7 +1048,7 @@
 	  driver supports intel i82595{FX,TX} based boards. Note however
 	  that the EtherExpress PRO/100 Ethernet card has its own separate
 	  driver.  Please read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -1062,7 +1062,7 @@
 	---help---
 	  If you have a Fujitsu FMV-181/182/183/184 network (Ethernet) card,
 	  say Y and read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you use an FMV-183 or FMV-184 and it is not working, you may need
 	  to disable Plug & Play mode of the card.
@@ -1079,7 +1079,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -1093,7 +1093,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -1115,7 +1115,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -1129,7 +1129,7 @@
 	---help---
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  Many Ethernet cards
+	  <http://www.tldp.org/docs.html#howto>.  Many Ethernet cards
 	  without a specific driver are compatible with NE2000.
 
 	  If you have a PCI NE2000 card however, say N here and Y to "PCI
@@ -1152,7 +1152,7 @@
 	  (Ethernet) card, and this is the Linux driver for it. Note that the
 	  IBM Thinkpad 300 is compatible with the Z-Note and is also supported
 	  by this driver. Read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 config SEEQ8005
 	tristate "SEEQ8005 support (EXPERIMENTAL)"
@@ -1160,7 +1160,7 @@
 	help
 	  This is a driver for the SEEQ 8005 network (Ethernet) card.  If this
 	  is for you, read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to compile this as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
@@ -1174,7 +1174,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 config NET_CBUS
 	bool "NEC PC-9800 C-bus cards"
@@ -1248,7 +1248,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -1278,7 +1278,7 @@
 	help
 	  This is another class of network cards which attach directly to the
 	  bus. If you have one of those, say Y and read the Ethernet-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>.
+	  available from <http://www.tldp.org/docs.html#howto>.
 
 	  Note that the answer to this question doesn't directly affect the
 	  kernel: saying N will just cause the configurator to skip all
@@ -1292,7 +1292,7 @@
 	help
 	  If you have a PCnet32 or PCnetPCI based network (Ethernet) card,
 	  answer Y here and read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -1306,7 +1306,7 @@
 	help
 	  If you have an AMD 8111-based PCI lance ethernet card,
 	  answer Y here and read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -1346,7 +1346,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -1360,7 +1360,7 @@
 	help
 	  If you have a network (Ethernet) controller of this type, say Y and
 	  read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to compile this as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
@@ -1374,7 +1374,7 @@
 	help
 	  If you have a network (Ethernet) controller of this type, say Y and
 	  read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to compile this as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
@@ -1389,7 +1389,7 @@
 	  Support for CS89x0 chipset based Ethernet cards. If you have a
 	  network (Ethernet) card of this type, say Y and read the
 	  Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto> as well as
+	  <http://www.tldp.org/docs.html#howto> as well as
 	  <file:Documentation/networking/cs89x0.txt>.
 
 	  If you want to compile this as a module ( = code which can be
@@ -1406,7 +1406,7 @@
 	  PCI/EISA Ethernet switch cards. These include the SE-4 and the SE-6
 	  models.  If you have a network card of this type, say Y and read the
 	  Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  More specific
+	  <http://www.tldp.org/docs.html#howto>.  More specific
 	  information is contained in <file:Documentation/networking/dgrs.txt>.
 
 	  This driver is also available as a module ( = code which can be
@@ -1421,7 +1421,7 @@
 	help
 	  If you have an Intel EtherExpress PRO/100 PCI network (Ethernet)
 	  card, say Y and read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -1523,7 +1523,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -1557,7 +1557,7 @@
 	  with ISA NE2000 cards (they have their own driver, "NE2000/NE1000
 	  support" below). If you have a PCI NE2000 network (Ethernet) card,
 	  say Y and read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver also works for the following NE2000 clone cards:
 	  RealTek RTL-8029  Winbond 89C940  Compex RL2000  KTI ET32P2
@@ -1576,7 +1576,7 @@
 	---help---
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  Note that this driver
+	  <http://www.tldp.org/docs.html#howto>.  Note that this driver
 	  will NOT WORK for NE3200 cards as they are completely different.
 
 	  This driver is also available as a module ( = code which can be
@@ -1591,7 +1591,7 @@
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -1606,7 +1606,7 @@
 	  This is a driver for the Fast Ethernet PCI network cards based on
 	  the RTL8139C+ chips. If you have one of those, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to compile this driver as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
@@ -1621,7 +1621,7 @@
 	  the RTL8139 chips. If you have one of those, say Y and read
 	  <file:Documentation/networking/8139too.txt> as well as the
 	  Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to compile this driver as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
@@ -1675,7 +1675,7 @@
 	  the SiS 900 and SiS 7016 chips. The SiS 900 core is also embedded in
 	  SiS 630 and SiS 540 chipsets.  If you have one of those, say Y and
 	  read the Ethernet-HOWTO, available at
-	  <http://www.linuxdoc.org/docs.html#howto>.  Please read
+	  <http://www.tldp.org/docs.html#howto>.  Please read
 	  <file:Documentation/networking/sis900.txt> and comments at the
 	  beginning of <file:drivers/net/sis900.c> for more information.
 
@@ -1721,7 +1721,7 @@
 	  If you have a PCI Ethernet network card based on the ThunderLAN chip
 	  which is supported by this driver, say Y and read the
 	  Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  Devices currently supported by this driver are Compaq Netelligent,
 	  Compaq NetFlex and Olicom cards.  Please read the file
@@ -1777,7 +1777,7 @@
 	  Cute little network (Ethernet) devices which attach to the parallel
 	  port ("pocket adapters"), commonly used with laptops. If you have
 	  one of those, say Y and read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to plug a network (or some other) card into the PCMCIA
 	  (or PC-card) slot of your laptop instead (PCMCIA is the standard for
@@ -1799,7 +1799,7 @@
 	---help---
 	  This is a network (Ethernet) device which attaches to your parallel
 	  port. Read <file:drivers/net/atp.c> as well as the Ethernet-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>, if you
+	  available from <http://www.tldp.org/docs.html#howto>, if you
 	  want to use this.  If you intend to use this driver, you should have
 	  said N to the "Parallel printer support", because the two drivers
 	  don't like each other.
@@ -1816,7 +1816,7 @@
 	  This is a network (Ethernet) device which attaches to your parallel
 	  port. Read <file:Documentation/networking/DLINK.txt> as well as the
 	  Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, if you want to use
+	  <http://www.tldp.org/docs.html#howto>, if you want to use
 	  this. It is possible to have several devices share a single parallel
 	  port and it is safe to compile the corresponding drivers into the
 	  kernel.
@@ -1834,7 +1834,7 @@
 	  This is a network (Ethernet) device which attaches to your parallel
 	  port. Read <file:Documentation/networking/DLINK.txt> as well as the
 	  Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, if you want to use
+	  <http://www.tldp.org/docs.html#howto>, if you want to use
 	  this. It is possible to have several devices share a single parallel
 	  port and it is safe to compile the corresponding drivers into the
 	  kernel.
@@ -1980,8 +1980,8 @@
 	  as <file:Documentation/networking/net-modules.txt>.
 
 config E1000_NAPI
-	bool "Use Rx Polling (NAPI) (EXPERIMENTAL)"
-	depends on E1000 && EXPERIMENTAL
+	bool "Use Rx Polling (NAPI)"
+	depends on E1000
 
 config MYRI_SBUS
 	tristate "MyriCOM Gigabit Ethernet support"
@@ -2010,7 +2010,7 @@
 	help
 	  If you have a Gigabit Ethernet card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to compile this as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
@@ -2085,6 +2085,50 @@
 
 endmenu
 
+#
+#	10 Gigabit Ethernet
+#
+
+menu "Ethernet (10000 Mbit)"
+	depends on NETDEVICES
+
+config IXGB
+	tristate "Intel(R) PRO/10GbE support"
+	depends on PCI
+	---help---
+	  This driver supports Intel(R) PRO/10GbE family of
+	  adapters, which includes:
+
+	  Controller  Adapter Name                           Board IDs
+	  ----------  ------------                           ---------
+	  82597EX     Intel(R) PRO/10GbE LR Server Adapter   A82505-xxx
+
+	  For more information on how to identify your adapter, go to the
+	  Adapter & Driver ID Guide at:
+
+	  <http://support.intel.com/support/network/adapter/pro100/21397.htm>
+
+	  For general information and support, go to the Intel support
+	  website at:
+
+	  <http://support.intel.com>
+
+	  More specific information on configuring the driver is in 
+	  <file:Documentation/networking/ixgb.txt>.
+
+	  This driver is also available as a module ( = code which can be
+	  inserted in and removed from the running kernel whenever you want).
+	  The module will be called ixgb.  If you want to compile it as a
+	  module, say M here and read <file:Documentation/modules.txt> as well
+	  as <file:Documentation/networking/net-modules.txt>.
+
+config IXGB_NAPI
+	bool "Use Rx Polling (NAPI) (EXPERIMENTAL)"
+	depends on IXGB && EXPERIMENTAL
+
+endmenu
+
+
 config VETH
 	tristate "iSeries Virtual Ethernet driver support"
 	depends on NETDEVICES && PPC_ISERIES
@@ -2201,7 +2245,7 @@
 
 	  If you want to use PLIP, say Y and read the PLIP mini-HOWTO as well
 	  as the NET-3-HOWTO, both available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  Note that the PLIP
+	  <http://www.tldp.org/docs.html#howto>.  Note that the PLIP
 	  protocol has been changed and this PLIP driver won't work together
 	  with the PLIP support in Linux versions 1.0.x.  This option enlarges
 	  your kernel by about 8 KB.
@@ -2225,7 +2269,7 @@
 
 	  To use PPP, you need an additional program called pppd as described
 	  in the PPP-HOWTO, available at
-	  <http://www.linuxdoc.org/docs.html#howto>.  Make sure that you have
+	  <http://www.tldp.org/docs.html#howto>.  Make sure that you have
 	  the version of pppd recommended in <file:Documentation/Changes>.
 	  The PPP option enlarges your kernel by about 16 KB.
 
@@ -2377,7 +2421,7 @@
 	  allows you to use SLIP over a regular dial up shell connection. If
 	  you plan to use SLiRP, make sure to say Y to CSLIP, below. The
 	  NET-3-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, explains how to
+	  <http://www.tldp.org/docs.html#howto>, explains how to
 	  configure SLIP. Note that you don't need this option if you just
 	  want to run term (term is a program which gives you almost full
 	  Internet connectivity if you have a regular dial up shell account on
@@ -2403,7 +2447,7 @@
 	  <ftp://ibiblio.org/pub/Linux/system/network/serial/>) which
 	  allows you to use SLIP over a regular dial up shell connection, you
 	  definitely want to say Y here. The NET-3-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, explains how to configure
+	  <http://www.tldp.org/docs.html#howto>, explains how to configure
 	  CSLIP. This won't enlarge your kernel.
 
 config SLIP_SMART
diff -Nru a/drivers/net/Makefile b/drivers/net/Makefile
--- a/drivers/net/Makefile	Wed Apr 30 22:28:06 2003
+++ b/drivers/net/Makefile	Wed Apr 30 22:28:06 2003
@@ -10,6 +10,7 @@
 
 obj-$(CONFIG_E100) += e100/
 obj-$(CONFIG_E1000) += e1000/
+obj-$(CONFIG_IXGB) += ixgb/
 
 #
 # link order important here
diff -Nru a/drivers/net/a2065.c b/drivers/net/a2065.c
--- a/drivers/net/a2065.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/net/a2065.c	Wed Apr 30 22:28:10 2003
@@ -429,7 +429,8 @@
 	return 0;
 }
 
-static void lance_interrupt (int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t
+lance_interrupt (int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev;
 	struct lance_private *lp;
@@ -445,7 +446,7 @@
 	csr0 = ll->rdp;
 
 	if (!(csr0 & LE_C0_INTR))	/* Check if any interrupt has */
-		return;			/* been generated by the Lance. */
+		return IRQ_NONE;	/* been generated by the Lance. */
 
 	/* Acknowledge all the interrupt sources ASAP */
 	ll->rdp = csr0 & ~(LE_C0_INEA|LE_C0_TDMD|LE_C0_STOP|LE_C0_STRT|
@@ -479,7 +480,7 @@
 	ll->rap = LE_CSR0;
 	ll->rdp = LE_C0_BABL|LE_C0_CERR|LE_C0_MISS|LE_C0_MERR|
 					LE_C0_IDON|LE_C0_INEA;
-
+	return IRQ_HANDLED;
 }
 
 struct net_device *last_dev = 0;
diff -Nru a/drivers/net/ac3200.c b/drivers/net/ac3200.c
--- a/drivers/net/ac3200.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/net/ac3200.c	Wed Apr 30 22:28:11 2003
@@ -167,7 +167,7 @@
 		dev->irq = config2irq(inb(ioaddr + AC_CONFIG));
 		printk(", using");
 	} else {
-		dev->irq = irq_cannonicalize(dev->irq);
+		dev->irq = irq_canonicalize(dev->irq);
 		printk(", assigning");
 	}
 
diff -Nru a/drivers/net/am79c961a.c b/drivers/net/am79c961a.c
--- a/drivers/net/am79c961a.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/net/am79c961a.c	Wed Apr 30 22:28:14 2003
@@ -40,7 +40,8 @@
 
 #include "am79c961a.h"
 
-static void am79c961_interrupt (int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t
+am79c961_interrupt (int irq, void *dev_id, struct pt_regs *regs);
 
 static unsigned int net_debug = NET_DEBUG;
 
@@ -557,22 +558,30 @@
 	netif_wake_queue(dev);
 }
 
-static void
+static irqreturn_t
 am79c961_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *)dev_id;
 	struct dev_priv *priv = (struct dev_priv *)dev->priv;
 	u_int status;
+	int handled = 0;
 
 	status = read_rreg(dev->base_addr, CSR0);
 	write_rreg(dev->base_addr, CSR0, status & (CSR0_TINT|CSR0_RINT|CSR0_MISS|CSR0_IENA));
 
-	if (status & CSR0_RINT)
+	if (status & CSR0_RINT) {
+		handled = 1;
 		am79c961_rx(dev, priv);
-	if (status & CSR0_TINT)
+	}
+	if (status & CSR0_TINT) {
+		handled = 1;
 		am79c961_tx(dev, priv);
-	if (status & CSR0_MISS)
+	}
+	if (status & CSR0_MISS) {
+		handled = 1;
 		priv->stats.rx_dropped ++;
+	}
+	return IRQ_RETVAL(handled);
 }
 
 /*
diff -Nru a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c
--- a/drivers/net/amd8111e.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/net/amd8111e.c	Wed Apr 30 22:28:10 2003
@@ -780,16 +780,18 @@
 /*
 This is device interrupt function. It handles transmit, receive and link change interrupts.
 */
-static void amd8111e_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t
+amd8111e_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 
 	struct net_device * dev = (struct net_device *) dev_id;
 	struct amd8111e_priv *lp = dev->priv;
 	void * mmio = lp->mmio;
 	unsigned int intr0;
+	int handled = 0;
 
 	if(dev == NULL)
-		return;
+		return IRQ_NONE;
 
 	spin_lock (&lp->lock);
 	/* disabling interrupt */
@@ -802,7 +804,8 @@
 
 	if (!(intr0 & INTR))
 		goto err_no_interrupt;
-		 
+
+	handled = 1;
 	/* Current driver processes 3 interrupts : RINT,TINT,LCINT */
 	writel(intr0, mmio + INT0);
 
@@ -823,7 +826,7 @@
 err_no_interrupt:
 	writel( VAL0 | INTREN,mmio + CMD0);
 	spin_unlock(&lp->lock);
-	return;
+	return IRQ_RETVAL(handled);
 
 }
 /*
diff -Nru a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
--- a/drivers/net/appletalk/cops.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/net/appletalk/cops.c	Wed Apr 30 22:28:09 2003
@@ -194,7 +194,7 @@
 static void cops_load (struct net_device *dev);
 static int  cops_nodeid (struct net_device *dev, int nodeid);
 
-static void cops_interrupt (int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t cops_interrupt (int irq, void *dev_id, struct pt_regs *regs);
 static void cops_poll (unsigned long ltdev);
 static void cops_timeout(struct net_device *dev);
 static void cops_rx (struct net_device *dev);
@@ -710,7 +710,7 @@
  *      The typical workload of the driver:
  *      Handle the network interface interrupts.
  */
-static void cops_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t cops_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
         struct net_device *dev = dev_id;
         struct cops_local *lp;
@@ -742,7 +742,7 @@
 		} while((++boguscount < 20) && (status&(TANG_RX_READY|TANG_TX_READY)));
 	}
 
-        return;
+        return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/net/appletalk/ltpc.c b/drivers/net/appletalk/ltpc.c
--- a/drivers/net/appletalk/ltpc.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/net/appletalk/ltpc.c	Wed Apr 30 22:28:06 2003
@@ -789,13 +789,14 @@
 
 /* the handler for the board interrupt */
  
-static void ltpc_interrupt(int irq, void *dev_id, struct pt_regs *reg_ptr)
+static irqreturn_t
+ltpc_interrupt(int irq, void *dev_id, struct pt_regs *reg_ptr)
 {
 	struct net_device *dev = dev_id;
 
 	if (dev==NULL) {
 		printk("ltpc_interrupt: unknown device.\n");
-		return;
+		return IRQ_NONE;
 	}
 
 	inb_p(dev->base_addr+6);  /* disable further interrupts from board */
@@ -804,7 +805,7 @@
  
 	/* idle re-enables interrupts from board */ 
 
-	return;
+	return IRQ_HANDLED;
 }
 
 /***
@@ -1295,7 +1296,7 @@
 
 static void __exit ltpc_cleanup(void)
 {
-	long timeout;
+	unsigned long timeout;
 
 	ltpc_timer.data = 0;  /* signal the poll routine that we're done */
 
diff -Nru a/drivers/net/arcnet/Kconfig b/drivers/net/arcnet/Kconfig
--- a/drivers/net/arcnet/Kconfig	Wed Apr 30 22:28:17 2003
+++ b/drivers/net/arcnet/Kconfig	Wed Apr 30 22:28:17 2003
@@ -18,7 +18,7 @@
 	  support" below.
 
 	  You might also want to have a look at the Ethernet-HOWTO, available
-	  from <http://www.linuxdoc.org/docs.html#howto>(even though ARCnet
+	  from <http://www.tldp.org/docs.html#howto>(even though ARCnet
 	  is not really Ethernet).
 
 	  This driver is also available as a module ( = code which can be
diff -Nru a/drivers/net/ariadne.c b/drivers/net/ariadne.c
--- a/drivers/net/ariadne.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/net/ariadne.c	Wed Apr 30 22:28:11 2003
@@ -127,7 +127,7 @@
 static void ariadne_tx_timeout(struct net_device *dev);
 static int ariadne_rx(struct net_device *dev);
 static void ariadne_reset(struct net_device *dev);
-static void ariadne_interrupt(int irq, void *data, struct pt_regs *fp);
+static irqreturn_t ariadne_interrupt(int irq, void *data, struct pt_regs *fp);
 static int ariadne_close(struct net_device *dev);
 static struct net_device_stats *ariadne_get_stats(struct net_device *dev);
 #ifdef HAVE_MULTICAST
@@ -406,22 +406,23 @@
 }
 
 
-static void ariadne_interrupt(int irq, void *data, struct pt_regs *fp)
+static irqreturn_t ariadne_interrupt(int irq, void *data, struct pt_regs *fp)
 {
     struct net_device *dev = (struct net_device *)data;
     volatile struct Am79C960 *lance = (struct Am79C960*)dev->base_addr;
     struct ariadne_private *priv;
     int csr0, boguscnt;
+    int handled = 0;
 
     if (dev == NULL) {
 	printk("ariadne_interrupt(): irq for unknown device.\n");
-	return;
+	return IRQ_NONE;
     }
 
     lance->RAP = CSR0;			/* PCnet-ISA Controller Status */
 
     if (!(lance->RDP & INTR))		/* Check if any interrupt has been */
-	return;				/* generated by the board. */
+	return IRQ_NONE;		/* generated by the board. */
 
     priv = (struct ariadne_private *)dev->priv;
 
@@ -471,12 +472,15 @@
 	}
 #endif
 
-	if (csr0 & RINT)	/* Rx interrupt */
+	if (csr0 & RINT) {	/* Rx interrupt */
+	    handled = 1;
 	    ariadne_rx(dev);
+	}
 
 	if (csr0 & TINT) {	/* Tx-done interrupt */
 	    int dirty_tx = priv->dirty_tx;
 
+	    handled = 1;
 	    while (dirty_tx < priv->cur_tx) {
 		int entry = dirty_tx % TX_RING_SIZE;
 		int status = lowb(priv->tx_ring[entry]->TMD1);
@@ -532,11 +536,16 @@
 	}
 
 	/* Log misc errors. */
-	if (csr0 & BABL)
+	if (csr0 & BABL) {
+	    handled = 1;
 	    priv->stats.tx_errors++;	/* Tx babble. */
-	if (csr0 & MISS)
+	}
+	if (csr0 & MISS) {
+	    handled = 1;
 	    priv->stats.rx_errors++;	/* Missed a Rx frame. */
+	}
 	if (csr0 & MERR) {
+	    handled = 1;
 	    printk("%s: Bus master arbitration failure, status %4.4x.\n",
 		   dev->name, csr0);
 	    /* Restart the chip. */
@@ -553,7 +562,7 @@
 	printk("%s: exiting interrupt, csr%d=%#4.4x.\n", dev->name, lance->RAP,
 	       lance->RDP);
 #endif
-    return;
+    return IRQ_RETVAL(handled);
 }
 
 
diff -Nru a/drivers/net/at1700.c b/drivers/net/at1700.c
--- a/drivers/net/at1700.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/net/at1700.c	Wed Apr 30 22:28:08 2003
@@ -202,7 +202,7 @@
 static int read_eeprom(long ioaddr, int location);
 static int net_open(struct net_device *dev);
 static int	net_send_packet(struct sk_buff *skb, struct net_device *dev);
-static void net_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t net_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void net_rx(struct net_device *dev);
 static int net_close(struct net_device *dev);
 static struct net_device_stats *net_get_stats(struct net_device *dev);
@@ -696,16 +696,17 @@
 
 /* The typical workload of the driver:
    Handle the network interface interrupts. */
-static void
+static irqreturn_t
 net_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
 	struct net_local *lp;
 	int ioaddr, status;
+	int handled = 0;
 
 	if (dev == NULL) {
 		printk ("at1700_interrupt(): irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	ioaddr = dev->base_addr;
@@ -726,6 +727,7 @@
 		   Tx interrupt. Thus we flag on rx_started, so that we prevent
 		   the interrupt routine (net_interrupt) to dive into net_rx
 		   again. */
+		handled = 1;
 		lp->rx_started = 1;
 		outb(0x00, ioaddr + RX_INTR);	/* Disable RX intr. */
 		net_rx(dev);
@@ -733,6 +735,7 @@
 		lp->rx_started = 0;
 	}
 	if (status & 0x00ff) {
+		handled = 1;
 		if (status & 0x02) {
 			/* More than 16 collisions occurred */
 			if (net_debug > 4)
@@ -760,7 +763,7 @@
 	}
 
 	spin_unlock (&lp->lock);
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 /* We have a good packet(s), get it/them out of the buffers. */
@@ -914,9 +917,11 @@
 
 		memset(mc_filter, 0, sizeof(mc_filter));
 		for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count;
-			 i++, mclist = mclist->next)
-			set_bit(ether_crc_le(ETH_ALEN, mclist->dmi_addr) >> 26,
-					mc_filter);
+			 i++, mclist = mclist->next) {
+			unsigned int bit =
+				ether_crc_le(ETH_ALEN, mclist->dmi_addr) >> 26;
+			mc_filter[bit >> 3] |= (1 << bit);
+		}
 		outb(0x02, ioaddr + RX_MODE);	/* Use normal mode. */
 	}
 
diff -Nru a/drivers/net/atarilance.c b/drivers/net/atarilance.c
--- a/drivers/net/atarilance.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/net/atarilance.c	Wed Apr 30 22:28:06 2003
@@ -344,7 +344,7 @@
 static int lance_open( struct net_device *dev );
 static void lance_init_ring( struct net_device *dev );
 static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev );
-static void lance_interrupt( int irq, void *dev_id, struct pt_regs *fp );
+static irqreturn_t lance_interrupt( int irq, void *dev_id, struct pt_regs *fp );
 static int lance_rx( struct net_device *dev );
 static int lance_close( struct net_device *dev );
 static struct net_device_stats *lance_get_stats( struct net_device *dev );
@@ -860,16 +860,17 @@
 
 /* The LANCE interrupt handler. */
 
-static void lance_interrupt( int irq, void *dev_id, struct pt_regs *fp)
+static irqreturn_t lance_interrupt( int irq, void *dev_id, struct pt_regs *fp)
 {
 	struct net_device *dev = dev_id;
 	struct lance_private *lp;
 	struct lance_ioreg	 *IO;
 	int csr0, boguscnt = 10;
+	int handled = 0;
 
 	if (dev == NULL) {
 		DPRINTK( 1, ( "lance_interrupt(): interrupt for unknown device.\n" ));
-		return;
+		return IRQ_NONE;
 	}
 
 	lp = (struct lance_private *)dev->priv;
@@ -880,6 +881,7 @@
 
 	while( ((csr0 = DREG) & (CSR0_ERR | CSR0_TINT | CSR0_RINT)) &&
 		   --boguscnt >= 0) {
+		handled = 1;
 		/* Acknowledge all of the current interrupt sources ASAP. */
 		DREG = csr0 & ~(CSR0_INIT | CSR0_STRT | CSR0_STOP |
 									CSR0_TDMD | CSR0_INEA);
@@ -966,6 +968,7 @@
 				  dev->name, DREG ));
 
 	spin_unlock (&lp->devlock);
+	return IRQ_RETVAL(handled);
 }
 
 
diff -Nru a/drivers/net/atp.c b/drivers/net/atp.c
--- a/drivers/net/atp.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/net/atp.c	Wed Apr 30 22:28:19 2003
@@ -203,7 +203,7 @@
 static void write_packet(long ioaddr, int length, unsigned char *packet, int pad, int mode);
 static void trigger_send(long ioaddr, int length);
 static int	atp_send_packet(struct sk_buff *skb, struct net_device *dev);
-static void atp_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t atp_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void net_rx(struct net_device *dev);
 static void read_block(long ioaddr, int length, unsigned char *buffer, int data_mode);
 static int net_close(struct net_device *dev);
@@ -560,7 +560,7 @@
 	struct net_local *lp = (struct net_local *)dev->priv;
 	long ioaddr = dev->base_addr;
 	int length;
-	long flags;
+	unsigned long flags;
 
 	length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
 
@@ -596,17 +596,19 @@
 
 /* The typical workload of the driver:
    Handle the network interface interrupts. */
-static void atp_interrupt(int irq, void *dev_instance, struct pt_regs * regs)
+static irqreturn_t
+atp_interrupt(int irq, void *dev_instance, struct pt_regs * regs)
 {
 	struct net_device *dev = (struct net_device *)dev_instance;
 	struct net_local *lp;
 	long ioaddr;
 	static int num_tx_since_rx;
 	int boguscount = max_interrupt_work;
+	int handled = 0;
 
 	if (dev == NULL) {
 		printk(KERN_ERR "ATP_interrupt(): irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 	ioaddr = dev->base_addr;
 	lp = (struct net_local *)dev->priv;
@@ -626,6 +628,7 @@
 		if (net_debug > 5) printk("loop status %02x..", status);
 
 		if (status & (ISR_RxOK<<3)) {
+			handled = 1;
 			write_reg(ioaddr, ISR, ISR_RxOK); /* Clear the Rx interrupt. */
 			do {
 				int read_status = read_nibble(ioaddr, CMR1);
@@ -648,6 +651,7 @@
 					break;
 			} while (--boguscount > 0);
 		} else if (status & ((ISR_TxErr + ISR_TxOK)<<3)) {
+			handled = 1;
 			if (net_debug > 6)  printk("handling Tx done..");
 			/* Clear the Tx interrupt.  We should check for too many failures
 			   and reinitialize the adapter. */
@@ -712,7 +716,7 @@
 	spin_unlock(&lp->lock);
 
 	if (net_debug > 5) printk("exiting interrupt.\n");
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 #ifdef TIMED_CHECKER
diff -Nru a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
--- a/drivers/net/au1000_eth.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/net/au1000_eth.c	Wed Apr 30 22:28:10 2003
@@ -73,7 +73,7 @@
 static int au1000_close(struct net_device *);
 static int au1000_tx(struct sk_buff *, struct net_device *);
 static int au1000_rx(struct net_device *);
-static void au1000_interrupt(int, void *, struct pt_regs *);
+static irqreturn_t au1000_interrupt(int, void *, struct pt_regs *);
 static void au1000_tx_timeout(struct net_device *);
 static int au1000_set_config(struct net_device *dev, struct ifmap *map);
 static void set_rx_mode(struct net_device *);
@@ -1236,16 +1236,17 @@
 /*
  * Au1000 interrupt service routine.
  */
-void au1000_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t au1000_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *) dev_id;
 
 	if (dev == NULL) {
 		printk(KERN_ERR "%s: isr: null dev ptr\n", dev->name);
-		return;
+		return IRQ_NONE;
 	}
 	au1000_tx_ack(dev);
 	au1000_rx(dev);
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/net/b44.c b/drivers/net/b44.c
--- a/drivers/net/b44.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/net/b44.c	Wed Apr 30 22:28:08 2003
@@ -799,12 +799,13 @@
 	return (done ? 0 : 1);
 }
 
-static void b44_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t b44_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
 	struct b44 *bp = dev->priv;
 	unsigned long flags;
 	u32 istat, imask;
+	int handled = 0;
 
 	spin_lock_irqsave(&bp->lock, flags);
 
@@ -816,6 +817,7 @@
 	 */
 	istat &= imask;
 	if (istat) {
+		handled = 1;
 		if (netif_rx_schedule_prep(dev)) {
 			/* NOTE: These writes are posted by the readback of
 			 *       the ISTAT register below.
@@ -832,6 +834,7 @@
 		br32(B44_ISTAT);
 	}
 	spin_unlock_irqrestore(&bp->lock, flags);
+	return IRQ_RETVAL(handled);
 }
 
 static void b44_tx_timeout(struct net_device *dev)
diff -Nru a/drivers/net/bagetlance.c b/drivers/net/bagetlance.c
--- a/drivers/net/bagetlance.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/bagetlance.c	Wed Apr 30 22:28:03 2003
@@ -330,7 +330,7 @@
 static int lance_open( struct net_device *dev );
 static void lance_init_ring( struct net_device *dev );
 static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev );
-static void lance_interrupt( int irq, void *dev_id, struct pt_regs *fp );
+static irqreturn_t lance_interrupt( int irq, void *dev_id, struct pt_regs *fp );
 static int lance_rx( struct net_device *dev );
 static int lance_close( struct net_device *dev );
 static struct net_device_stats *lance_get_stats( struct net_device *dev );
@@ -965,16 +965,17 @@
 
 /* The LANCE interrupt handler. */
 
-static void lance_interrupt( int irq, void *dev_id, struct pt_regs *fp)
+static irqreturn_t lance_interrupt( int irq, void *dev_id, struct pt_regs *fp)
 {
 	struct net_device *dev = dev_id;
 	struct lance_private *lp;
 	struct lance_ioreg	 *IO;
 	int csr0, boguscnt = 10;
+	int handled = 0;
 
 	if (dev == NULL) {
 		DPRINTK( 1, ( "lance_interrupt(): interrupt for unknown device.\n" ));
-		return;
+		return IRQ_NONE;
 	}
 
 	lp = (struct lance_private *)dev->priv;
@@ -992,6 +993,7 @@
 
 	while( ((csr0 = DREG) & (CSR0_ERR | CSR0_TINT | CSR0_RINT)) &&
 		   --boguscnt >= 0) {
+		handled = 1;
 		/* Acknowledge all of the current interrupt sources ASAP. */
 		DREG = csr0 & ~(CSR0_INIT | CSR0_STRT | CSR0_STOP |
 									CSR0_TDMD | CSR0_INEA);
@@ -1083,7 +1085,7 @@
 	DPRINTK( 2, ( "%s: exiting interrupt, csr0=%#04x.\n",
 				  dev->name, DREG ));
 	dev->interrupt = 0;
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 
diff -Nru a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c
--- a/drivers/net/cs89x0.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/net/cs89x0.c	Wed Apr 30 22:28:15 2003
@@ -218,7 +218,7 @@
 static int cs89x0_probe1(struct net_device *dev, int ioaddr);
 static int net_open(struct net_device *dev);
 static int net_send_packet(struct sk_buff *skb, struct net_device *dev);
-static void net_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t net_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void set_multicast_list(struct net_device *dev);
 static void net_timeout(struct net_device *dev);
 static void net_rx(struct net_device *dev);
@@ -1401,12 +1401,13 @@
 /* The typical workload of the driver:
    Handle the network interface interrupts. */
    
-static void net_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t net_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
 	struct net_device *dev = dev_id;
 	struct net_local *lp;
 	int ioaddr, status;
- 
+ 	int handled = 0;
+
 	ioaddr = dev->base_addr;
 	lp = (struct net_local *)dev->priv;
 
@@ -1419,6 +1420,7 @@
            vista, baby!  */
 	while ((status = readword(dev, ISQ_PORT))) {
 		if (net_debug > 4)printk("%s: event=%04x\n", dev->name, status);
+		handled = 1;
 		switch(status & ISQ_EVENT_MASK) {
 		case ISQ_RECEIVER_EVENT:
 			/* Got a packet(s). */
@@ -1485,6 +1487,7 @@
 			break;
 		}
 	}
+	return IRQ_RETVAL(handled);
 }
 
 static void
diff -Nru a/drivers/net/de600.c b/drivers/net/de600.c
--- a/drivers/net/de600.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/net/de600.c	Wed Apr 30 22:28:18 2003
@@ -258,7 +258,7 @@
  * Handle the network interface interrupts.
  */
 
-static void de600_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t de600_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
 	struct net_device	*dev = dev_id;
 	u8		irq_status;
@@ -268,7 +268,7 @@
 	/* This might just as well be deleted now, no crummy drivers present :-) */
 	if ((dev == NULL) || (DE600_IRQ != irq)) {
 		printk(KERN_ERR "%s: bogus interrupt %d\n", dev?dev->name:"DE-600", irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	spin_lock(&de600_lock);
@@ -303,7 +303,7 @@
 	if (retrig)
 		trigger_interrupt(dev);
 	spin_unlock(&de600_lock);
-	return;
+	return IRQ_HANDLED;
 }
 
 static int de600_tx_intr(struct net_device *dev, int irq_status)
diff -Nru a/drivers/net/de600.h b/drivers/net/de600.h
--- a/drivers/net/de600.h	Wed Apr 30 22:28:11 2003
+++ b/drivers/net/de600.h	Wed Apr 30 22:28:11 2003
@@ -125,7 +125,7 @@
 static int	de600_start_xmit(struct sk_buff *skb, struct net_device *dev);
 
 /* Dispatch from interrupts. */
-static void	de600_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t de600_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static int	de600_tx_intr(struct net_device *dev, int irq_status);
 static void	de600_rx_intr(struct net_device *dev);
 
diff -Nru a/drivers/net/de620.c b/drivers/net/de620.c
--- a/drivers/net/de620.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/net/de620.c	Wed Apr 30 22:28:09 2003
@@ -221,7 +221,7 @@
 static int	de620_start_xmit(struct sk_buff *, struct net_device *);
 
 /* Dispatch from interrupts. */
-static void	de620_interrupt(int, void *, struct pt_regs *);
+static irqreturn_t de620_interrupt(int, void *, struct pt_regs *);
 static int	de620_rx_intr(struct net_device *);
 
 /* Initialization */
@@ -591,7 +591,8 @@
  * Handle the network interface interrupts.
  *
  */
-static void de620_interrupt(int irq_in, void *dev_id, struct pt_regs *regs)
+static irqreturn_t
+de620_interrupt(int irq_in, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
 	byte irq_status;
@@ -617,6 +618,7 @@
 		netif_wake_queue(dev);
 		
 	spin_unlock(&de620_lock);
+	return IRQ_HANDLED;
 }
 
 /**************************************
diff -Nru a/drivers/net/declance.c b/drivers/net/declance.c
--- a/drivers/net/declance.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/net/declance.c	Wed Apr 30 22:28:10 2003
@@ -709,7 +709,8 @@
 	spin_unlock(&lp->lock);
 }
 
-static void lance_interrupt(const int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t
+lance_interrupt(const int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *) dev_id;
 	struct lance_private *lp = (struct lance_private *) dev->priv;
@@ -763,6 +764,7 @@
 
 	writereg(&ll->rdp, LE_C0_INEA);
 	writereg(&ll->rdp, LE_C0_INEA);
+	return IRQ_HANDLED;
 }
 
 struct net_device *last_dev = 0;
diff -Nru a/drivers/net/depca.c b/drivers/net/depca.c
--- a/drivers/net/depca.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/net/depca.c	Wed Apr 30 22:28:09 2003
@@ -430,7 +430,7 @@
 */
 static int depca_open(struct net_device *dev);
 static int depca_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static void depca_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t depca_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static int depca_close(struct net_device *dev);
 static int depca_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static void depca_tx_timeout(struct net_device *dev);
@@ -894,7 +894,7 @@
 /*
 ** The DEPCA interrupt handler. 
 */
-static void depca_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t depca_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
 	struct depca_private *lp;
@@ -903,7 +903,7 @@
 
 	if (dev == NULL) {
 		printk("depca_interrupt(): irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	lp = (struct depca_private *) dev->priv;
@@ -938,6 +938,7 @@
 	outb(nicsr, DEPCA_NICSR);
 
 	spin_unlock(&lp->lock);
+	return IRQ_HANDLED;
 }
 
 /* Called with lp->lock held */
diff -Nru a/drivers/net/dgrs.c b/drivers/net/dgrs.c
--- a/drivers/net/dgrs.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/net/dgrs.c	Wed Apr 30 22:28:04 2003
@@ -888,7 +888,7 @@
  *	dev, priv will always refer to the 0th device in Multi-NIC mode.
  */
 
-static void dgrs_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t dgrs_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device	*dev0 = (struct net_device *) dev_id;
 	DGRS_PRIV	*priv0 = (DGRS_PRIV *) dev0->priv;
@@ -971,6 +971,8 @@
 ack_intr:
 	if (priv0->plxreg)
 		OUTL(dev0->base_addr + PLX_LCL2PCI_DOORBELL, 1);
+
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/net/dl2k.c b/drivers/net/dl2k.c
--- a/drivers/net/dl2k.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/net/dl2k.c	Wed Apr 30 22:28:08 2003
@@ -98,7 +98,7 @@
 static void rio_tx_timeout (struct net_device *dev);
 static void alloc_list (struct net_device *dev);
 static int start_xmit (struct sk_buff *skb, struct net_device *dev);
-static void rio_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t rio_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
 static void rio_free_tx (struct net_device *dev, int irq);
 static void tx_error (struct net_device *dev, int tx_status);
 static int receive_packet (struct net_device *dev);
@@ -699,7 +699,7 @@
 	return 0;
 }
 
-static void
+static irqreturn_t
 rio_interrupt (int irq, void *dev_instance, struct pt_regs *rgs)
 {
 	struct net_device *dev = dev_instance;
@@ -707,6 +707,7 @@
 	unsigned int_status;
 	long ioaddr;
 	int cnt = max_intrloop;
+	int handled = 0;
 
 	ioaddr = dev->base_addr;
 	np = dev->priv;
@@ -716,6 +717,7 @@
 		int_status &= DEFAULT_INTR;
 		if (int_status == 0 || --cnt < 0)
 			break;
+		handled = 1;
 		/* Processing received packets */
 		if (int_status & RxDMAComplete)
 			receive_packet (dev);
@@ -736,6 +738,7 @@
 	}
 	if (np->cur_tx != np->old_tx)
 		writel (100, ioaddr + CountDown);
+	return IRQ_RETVAL(handled);
 }
 
 static void 
@@ -744,7 +747,7 @@
 	struct netdev_private *np = (struct netdev_private *) dev->priv;
 	int entry = np->old_tx % TX_RING_SIZE;
 	int tx_use = 0;
-	long flag = 0;
+	unsigned long flag = 0;
 	
 	if (irq)
 		spin_lock(&np->tx_lock);
diff -Nru a/drivers/net/e100/e100_main.c b/drivers/net/e100/e100_main.c
--- a/drivers/net/e100/e100_main.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/net/e100/e100_main.c	Wed Apr 30 22:28:09 2003
@@ -190,7 +190,7 @@
 static int e100_set_mac(struct net_device *, void *);
 struct net_device_stats *e100_get_stats(struct net_device *);
 
-static void e100intr(int, void *, struct pt_regs *);
+static irqreturn_t e100intr(int, void *, struct pt_regs *);
 static void e100_print_brd_conf(struct e100_private *);
 static void e100_set_multi(struct net_device *);
 void e100_set_speed_duplex(struct e100_private *);
@@ -1837,7 +1837,7 @@
  * the RX & TX queues & starts the RU if it has stopped due
  * to no resources.
  */
-void
+irqreturn_t
 e100intr(int irq, void *dev_inst, struct pt_regs *regs)
 {
 	struct net_device *dev;
@@ -1850,7 +1850,7 @@
 	intr_status = readw(&bdp->scb->scb_status);
 	/* If not my interrupt, just return */
 	if (!(intr_status & SCB_STATUS_ACK_MASK) || (intr_status == 0xffff)) {
-		return;
+		return IRQ_NONE;
 	}
 
 	/* disable and ack intr */
@@ -1859,7 +1859,7 @@
 	/* the device is closed, don't continue or else bad things may happen. */
 	if (!netif_running(dev)) {
 		e100_set_intr_mask(bdp);
-		return;
+		return IRQ_NONE;
 	}
 
 	/* SWI intr (triggered by watchdog) is signal to allocate new skb buffers */
@@ -1877,6 +1877,7 @@
 		e100_tx_srv(bdp);
 
 	e100_set_intr_mask(bdp);
+	return IRQ_HANDLED;
 }
 
 /**
diff -Nru a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
--- a/drivers/net/e1000/e1000.h	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/e1000/e1000.h	Wed Apr 30 22:28:03 2003
@@ -63,7 +63,9 @@
 #include <net/pkt_sched.h>
 #include <linux/list.h>
 #include <linux/reboot.h>
+#ifdef NETIF_F_TSO
 #include <net/checksum.h>
+#endif
 #include <linux/workqueue.h>
 #include <linux/mii.h>
 #include <linux/ethtool.h>
diff -Nru a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
--- a/drivers/net/e1000/e1000_main.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/net/e1000/e1000_main.c	Wed Apr 30 22:28:07 2003
@@ -61,7 +61,7 @@
 
 char e1000_driver_name[] = "e1000";
 char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
-char e1000_driver_version[] = "5.0.43-k2";
+char e1000_driver_version[] = "5.0.43-k3";
 char e1000_copyright[] = "Copyright (c) 1999-2003 Intel Corporation.";
 
 /* e1000_pci_tbl - PCI Device ID Table
@@ -154,7 +154,7 @@
 static void e1000_update_stats(struct e1000_adapter *adapter);
 static inline void e1000_irq_disable(struct e1000_adapter *adapter);
 static inline void e1000_irq_enable(struct e1000_adapter *adapter);
-static void e1000_intr(int irq, void *data, struct pt_regs *regs);
+static irqreturn_t e1000_intr(int irq, void *data, struct pt_regs *regs);
 #ifdef CONFIG_E1000_NAPI
 static int e1000_clean(struct net_device *netdev, int *budget);
 static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter,
@@ -455,9 +455,11 @@
 		netdev->features = NETIF_F_SG;
 	}
 
+#ifdef NETIF_F_TSO
 	if((adapter->hw.mac_type >= e1000_82544) &&
 	   (adapter->hw.mac_type != e1000_82547))
 		netdev->features |= NETIF_F_TSO;
+#endif
 
 	if(pci_using_dac)
 		netdev->features |= NETIF_F_HIGHDMA;
@@ -1434,6 +1436,7 @@
 static inline boolean_t
 e1000_tso(struct e1000_adapter *adapter, struct sk_buff *skb, int tx_flags)
 {
+#ifdef NETIF_F_TSO
 	struct e1000_context_desc *context_desc;
 	int i;
 	uint8_t ipcss, ipcso, tucss, tucso, hdr_len;
@@ -1477,6 +1480,7 @@
 
 		return TRUE;
 	}
+#endif
 
 	return FALSE;
 }
@@ -1520,7 +1524,9 @@
 	struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
 	int len = skb->len, offset = 0, size, count = 0, i;
 
+#ifdef NETIF_F_TSO
 	int tso = skb_shinfo(skb)->tso_size;
+#endif
 	int nr_frags = skb_shinfo(skb)->nr_frags;
 	int f;
 	len -= skb->data_len;
@@ -1529,10 +1535,12 @@
 
 	while(len) {
 		size = min(len, E1000_MAX_DATA_PER_TXD);
+#ifdef NETIF_F_TSO
 		/* Workaround for premature desc write-backs
 		 * in TSO mode.  Append 4-byte sentinel desc */
 		if(tso && !nr_frags && size == len && size > 4)
 			size -= 4;
+#endif
 		tx_ring->buffer_info[i].length = size;
 		tx_ring->buffer_info[i].dma =
 			pci_map_single(adapter->pdev,
@@ -1556,10 +1564,12 @@
 
 		while(len) {
 			size = min(len, E1000_MAX_DATA_PER_TXD);
+#ifdef NETIF_F_TSO
 			/* Workaround for premature desc write-backs
 			 * in TSO mode.  Append 4-byte sentinel desc */
 			if(tso && f == (nr_frags-1) && size == len && size > 4)
 				size -= 4;
+#endif
 			tx_ring->buffer_info[i].length = size;
 			tx_ring->buffer_info[i].dma =
 				pci_map_page(adapter->pdev,
@@ -1981,7 +1991,7 @@
  * @pt_regs: CPU registers structure
  **/
 
-static void
+static irqreturn_t
 e1000_intr(int irq, void *data, struct pt_regs *regs)
 {
 	struct net_device *netdev = data;
@@ -1992,7 +2002,7 @@
 #endif
 
 	if(!icr)
-		return;  /* Not our interrupt */
+		return IRQ_NONE;  /* Not our interrupt */
 
 	if(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
 		adapter->hw.get_link_status = 1;
@@ -2016,6 +2026,7 @@
 		   !e1000_clean_tx_irq(adapter))
 			break;
 #endif
+	return IRQ_HANDLED;
 }
 
 #ifdef CONFIG_E1000_NAPI
diff -Nru a/drivers/net/eepro.c b/drivers/net/eepro.c
--- a/drivers/net/eepro.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/net/eepro.c	Wed Apr 30 22:28:13 2003
@@ -307,7 +307,7 @@
 static int	eepro_probe1(struct net_device *dev, short ioaddr);
 static int	eepro_open(struct net_device *dev);
 static int	eepro_send_packet(struct sk_buff *skb, struct net_device *dev);
-static void	eepro_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t eepro_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void 	eepro_rx(struct net_device *dev);
 static void 	eepro_transmit_interrupt(struct net_device *dev);
 static int	eepro_close(struct net_device *dev);
@@ -1104,8 +1104,6 @@
 	/* enabling rx */
 	eepro_en_rx(ioaddr);
 
-	MOD_INC_USE_COUNT;
-
 	return 0;
 }
 
@@ -1178,17 +1176,18 @@
 /*	The typical workload of the driver:
 	Handle the network interface interrupts. */
 
-static void
+static irqreturn_t
 eepro_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
 	struct net_device *dev =  (struct net_device *)dev_id;
 	                      /* (struct net_device *)(irq2dev_map[irq]);*/
 	struct eepro_local *lp;
 	int ioaddr, status, boguscount = 20;
+	int handled = 0;
 
 	if (dev == NULL) {
                 printk (KERN_ERR "eepro_interrupt(): irq %d for unknown device.\\n", irq);
-                return;
+                return IRQ_NONE;
         }
 
 	lp = (struct eepro_local *)dev->priv;
@@ -1202,6 +1201,7 @@
 
 	while (((status = inb(ioaddr + STATUS_REG)) & (RX_INT|TX_INT)) && (boguscount--))
 	{
+		handled = 1;
 		if (status & RX_INT) {
 			if (net_debug > 4)
 				printk(KERN_DEBUG "%s: packet received interrupt.\n", dev->name);
@@ -1233,7 +1233,7 @@
 		printk(KERN_DEBUG "%s: exiting eepro_interrupt routine.\n", dev->name);
 
 	spin_unlock(&lp->lock);
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 static int eepro_close(struct net_device *dev)
@@ -1274,8 +1274,6 @@
 #endif
 
 	/* Update the statistics here. What statistics? */
-
-	MOD_DEC_USE_COUNT;
 
 	return 0;
 }
diff -Nru a/drivers/net/eepro100.c b/drivers/net/eepro100.c
--- a/drivers/net/eepro100.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/net/eepro100.c	Wed Apr 30 22:28:11 2003
@@ -541,7 +541,7 @@
 static void speedo_refill_rx_buffers(struct net_device *dev, int force);
 static int speedo_rx(struct net_device *dev);
 static void speedo_tx_buffer_gc(struct net_device *dev);
-static void speedo_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t speedo_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
 static int speedo_close(struct net_device *dev);
 static struct net_device_stats *speedo_get_stats(struct net_device *dev);
 static int speedo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
@@ -1560,12 +1560,13 @@
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
-static void speedo_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
+static irqreturn_t speedo_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *)dev_instance;
 	struct speedo_private *sp;
 	long ioaddr, boguscnt = max_interrupt_work;
 	unsigned short status;
+	unsigned int handled = 0;
 
 	ioaddr = dev->base_addr;
 	sp = (struct speedo_private *)dev->priv;
@@ -1576,7 +1577,7 @@
 		printk(KERN_ERR"%s: SMP simultaneous entry of an interrupt handler.\n",
 			   dev->name);
 		sp->in_interrupt = 0;	/* Avoid halting machine. */
-		return;
+		return IRQ_NONE;
 	}
 #endif
 
@@ -1593,6 +1594,7 @@
 
 		if ((status & 0xfc00) == 0)
 			break;
+		handled = 1;
 
 
 		if ((status & 0x5000) ||	/* Packet received, or Rx error. */
@@ -1654,7 +1656,7 @@
 			   dev->name, inw(ioaddr + SCBStatus));
 
 	clear_bit(0, (void*)&sp->in_interrupt);
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 static inline struct RxFD *speedo_rx_alloc(struct net_device *dev, int entry)
diff -Nru a/drivers/net/eexpress.c b/drivers/net/eexpress.c
--- a/drivers/net/eexpress.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/eexpress.c	Wed Apr 30 22:28:03 2003
@@ -252,7 +252,7 @@
 static struct net_device_stats *eexp_stats(struct net_device *dev);
 static int eexp_xmit(struct sk_buff *buf, struct net_device *dev);
 
-static void eexp_irq(int irq, void *dev_addr, struct pt_regs *regs);
+static irqreturn_t eexp_irq(int irq, void *dev_addr, struct pt_regs *regs);
 static void eexp_set_multicast(struct net_device *dev);
 
 /*
@@ -761,7 +761,7 @@
 	}
 }
 	
-static void eexp_irq(int irq, void *dev_info, struct pt_regs *regs)
+static irqreturn_t eexp_irq(int irq, void *dev_info, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_info;
 	struct net_local *lp;
@@ -772,7 +772,7 @@
 	{
 		printk(KERN_WARNING "eexpress: irq %d for unknown device\n",
 		       irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	lp = (struct net_local *)dev->priv;
@@ -860,7 +860,7 @@
 	outw(old_write_ptr, ioaddr+WRITE_PTR);
 	
 	spin_unlock(&lp->lock);
-	return;
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/net/epic100.c b/drivers/net/epic100.c
--- a/drivers/net/epic100.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/net/epic100.c	Wed Apr 30 22:28:09 2003
@@ -360,7 +360,7 @@
 static void epic_init_ring(struct net_device *dev);
 static int epic_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static int epic_rx(struct net_device *dev);
-static void epic_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t epic_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
 static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static int epic_close(struct net_device *dev);
 static struct net_device_stats *epic_get_stats(struct net_device *dev);
@@ -973,7 +973,7 @@
 	struct epic_private *ep = dev->priv;
 	int entry, free_count;
 	u32 ctrl_word;
-	long flags;
+	unsigned long flags;
 	
 	if (skb->len < ETH_ZLEN) {
 		skb = skb_padto(skb, ETH_ZLEN);
@@ -1028,12 +1028,13 @@
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
-static void epic_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
+static irqreturn_t epic_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_instance;
 	struct epic_private *ep = dev->priv;
 	long ioaddr = dev->base_addr;
 	int status, boguscnt = max_interrupt_work;
+	unsigned int handled = 0;
 
 	do {
 		status = inl(ioaddr + INTSTAT);
@@ -1047,6 +1048,7 @@
 
 		if ((status & IntrSummary) == 0)
 			break;
+		handled = 1;
 
 		if (status & (RxDone | RxStarted | RxEarlyWarn | RxOverflow))
 			epic_rx(dev);
@@ -1156,7 +1158,7 @@
 		printk(KERN_DEBUG "%s: exiting interrupt, intr_status=%#4.4x.\n",
 			   dev->name, status);
 
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 static int epic_rx(struct net_device *dev)
@@ -1343,9 +1345,11 @@
 
 		memset(mc_filter, 0, sizeof(mc_filter));
 		for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count;
-			 i++, mclist = mclist->next)
-			set_bit(ether_crc_le(ETH_ALEN, mclist->dmi_addr) & 0x3f,
-					mc_filter);
+			 i++, mclist = mclist->next) {
+			unsigned int bit_nr =
+				ether_crc_le(ETH_ALEN, mclist->dmi_addr) & 0x3f;
+			mc_filter[bit_nr >> 3] |= (1 << bit_nr);
+		}
 	}
 	/* ToDo: perhaps we need to stop the Tx and Rx process here? */
 	if (memcmp(mc_filter, ep->mc_filter, sizeof(mc_filter))) {
diff -Nru a/drivers/net/eth16i.c b/drivers/net/eth16i.c
--- a/drivers/net/eth16i.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/net/eth16i.c	Wed Apr 30 22:28:15 2003
@@ -412,7 +412,7 @@
 static int     eth16i_tx(struct sk_buff *skb, struct net_device *dev);
 static void    eth16i_rx(struct net_device *dev);
 static void    eth16i_timeout(struct net_device *dev);
-static void    eth16i_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t eth16i_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void    eth16i_reset(struct net_device *dev);
 static void    eth16i_timeout(struct net_device *dev);
 static void    eth16i_skip_packet(struct net_device *dev);
@@ -1219,11 +1219,12 @@
 	} /* while */
 }
 
-static void eth16i_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t eth16i_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
 	struct eth16i_local *lp;
 	int ioaddr = 0, status;
+	int handled = 0;
 
 	ioaddr = dev->base_addr;
 	lp = (struct eth16i_local *)dev->priv;
@@ -1237,6 +1238,9 @@
 	status = inw(ioaddr + TX_STATUS_REG);      /* Get the status */
 	outw(status, ioaddr + TX_STATUS_REG);      /* Clear status bits */
 
+	if (status)
+		handled = 1;
+
 	if(eth16i_debug > 3)
 		printk(KERN_DEBUG "%s: Interrupt with status %04x.\n", dev->name, status);
 
@@ -1314,7 +1318,7 @@
 	
 	spin_unlock(&lp->lock);
 	
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 static void eth16i_skip_packet(struct net_device *dev)
diff -Nru a/drivers/net/ewrk3.c b/drivers/net/ewrk3.c
--- a/drivers/net/ewrk3.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/net/ewrk3.c	Wed Apr 30 22:28:18 2003
@@ -300,7 +300,7 @@
  */
 static int ewrk3_open(struct net_device *dev);
 static int ewrk3_queue_pkt(struct sk_buff *skb, struct net_device *dev);
-static void ewrk3_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t ewrk3_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static int ewrk3_close(struct net_device *dev);
 static struct net_device_stats *ewrk3_get_stats(struct net_device *dev);
 static void set_multicast_list(struct net_device *dev);
@@ -896,7 +896,7 @@
 /*
    ** The EWRK3 interrupt handler.
  */
-static void ewrk3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t ewrk3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
 	struct ewrk3_private *lp;
@@ -945,6 +945,7 @@
 	outb(cr, EWRK3_CR);
 	ENABLE_IRQs;
 	spin_unlock(&lp->hw_lock);
+	return IRQ_HANDLED;
 }
 
 /* Called with lp->hw_lock held */
diff -Nru a/drivers/net/fealnx.c b/drivers/net/fealnx.c
--- a/drivers/net/fealnx.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/net/fealnx.c	Wed Apr 30 22:28:13 2003
@@ -438,7 +438,7 @@
 static void tx_timeout(struct net_device *dev);
 static void init_ring(struct net_device *dev);
 static int start_tx(struct sk_buff *skb, struct net_device *dev);
-static void intr_handler(int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *regs);
 static int netdev_rx(struct net_device *dev);
 static void set_rx_mode(struct net_device *dev);
 static struct net_device_stats *get_stats(struct net_device *dev);
@@ -1412,12 +1412,13 @@
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
-static void intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
+static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
 {
 	struct net_device *dev = (struct net_device *) dev_instance;
 	struct netdev_private *np = dev->priv;
 	long ioaddr, boguscnt = max_interrupt_work;
 	unsigned int num_tx = 0;
+	int handled = 0;
 
 	writel(0, dev->base_addr + IMR);
 
@@ -1437,6 +1438,8 @@
 		if (!(intr_status & np->imrvalue))
 			break;
 
+		handled = 1;
+
 // 90/1/16 delete,
 //
 //      if (intr_status & FBE)
@@ -1559,7 +1562,7 @@
 
 	writel(np->imrvalue, ioaddr + IMR);
 
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 
@@ -1739,8 +1742,9 @@
 		memset(mc_filter, 0, sizeof(mc_filter));
 		for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count;
 		     i++, mclist = mclist->next) {
-			set_bit((ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26) ^ 0x3F,
-				mc_filter);
+			unsigned int bit;
+			bit = (ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26) ^ 0x3F;
+			mc_filter[bit >> 5] |= (1 << bit);
 		}
 		rx_mode = AB | AM;
 	}
diff -Nru a/drivers/net/gt96100eth.c b/drivers/net/gt96100eth.c
--- a/drivers/net/gt96100eth.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/net/gt96100eth.c	Wed Apr 30 22:28:14 2003
@@ -108,7 +108,7 @@
 static int gt96100_close(struct net_device *dev);
 static int gt96100_tx(struct sk_buff *skb, struct net_device *dev);
 static int gt96100_rx(struct net_device *dev, u32 status);
-static void gt96100_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t gt96100_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void gt96100_tx_timeout(struct net_device *dev);
 static void gt96100_set_rx_mode(struct net_device *dev);
 static struct net_device_stats* gt96100_get_stats(struct net_device *dev);
@@ -1392,16 +1392,17 @@
 }
 
 
-static void
+static irqreturn_t
 gt96100_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *)dev_id;
 	struct gt96100_private *gp = (struct gt96100_private *)dev->priv;
 	u32 status;
-    
+    	int handled = 0;
+
 	if (dev == NULL) {
 		err("%s: null dev ptr\n", __FUNCTION__);
-		return;
+		return IRQ_NONE;
 	}
 
 	dbg(3, "%s: entry, icr=%x\n", __FUNCTION__,
@@ -1420,7 +1421,9 @@
 		if ((status & icrEtherIntSum) == 0 &&
 		    !(status & (icrTxBufferLow|icrTxBufferHigh|icrRxBuffer)))
 			break;
-	
+
+		handled = 1;
+
 		if (status & icrMIIPhySTC) {
 			u32 psr = GT96100ETH_READ(gp, GT96100_ETH_PORT_STATUS);
 			if (gp->last_psr != psr) {
@@ -1487,6 +1490,7 @@
 	    GT96100ETH_READ(gp, GT96100_ETH_INT_CAUSE));
 
 	spin_unlock(&gp->lock);
+	return IRQ_RETVAL(handled);
 }
 
 
diff -Nru a/drivers/net/hamachi.c b/drivers/net/hamachi.c
--- a/drivers/net/hamachi.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/net/hamachi.c	Wed Apr 30 22:28:19 2003
@@ -558,7 +558,7 @@
 static void hamachi_tx_timeout(struct net_device *dev);
 static void hamachi_init_ring(struct net_device *dev);
 static int hamachi_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static void hamachi_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t hamachi_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
 static inline int hamachi_rx(struct net_device *dev);
 static inline int hamachi_tx(struct net_device *dev);
 static void hamachi_error(struct net_device *dev, int intr_status);
@@ -1367,16 +1367,17 @@
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
-static void hamachi_interrupt(int irq, void *dev_instance, struct pt_regs *rgs)
+static irqreturn_t hamachi_interrupt(int irq, void *dev_instance, struct pt_regs *rgs)
 {
 	struct net_device *dev = dev_instance;
 	struct hamachi_private *hmp;
 	long ioaddr, boguscnt = max_interrupt_work;
+	int handled = 0;
 
 #ifndef final_version			/* Can never occur. */
 	if (dev == NULL) {
 		printk (KERN_ERR "hamachi_interrupt(): irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 #endif
 
@@ -1394,6 +1395,8 @@
 		if (intr_status == 0)
 			break;
 
+		handled = 1;
+
 		if (intr_status & IntrRxDone)
 			hamachi_rx(dev);
 
@@ -1466,6 +1469,7 @@
 #endif
 
 	spin_unlock(&hmp->lock);
+	return IRQ_RETVAL(handled);
 }
 
 /* This routine is logically part of the interrupt handler, but separated
diff -Nru a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
--- a/drivers/net/hamradio/6pack.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/net/hamradio/6pack.c	Wed Apr 30 22:28:05 2003
@@ -315,13 +315,13 @@
 		   immediately after data has arrived. */
 		if (sp->duplex == 1) {
 			sp->led_state = 0x70;
-			sp->tty->driver.write(sp->tty, 0, &sp->led_state, 1);
+			sp->tty->driver->write(sp->tty, 0, &sp->led_state, 1);
 			sp->tx_enable = 1;
-			actual = sp->tty->driver.write(sp->tty, 0, sp->xbuff, count);
+			actual = sp->tty->driver->write(sp->tty, 0, sp->xbuff, count);
 			sp->xleft = count - actual;
 			sp->xhead = sp->xbuff + actual;
 			sp->led_state = 0x60;
-			sp->tty->driver.write(sp->tty, 0, &sp->led_state, 1);
+			sp->tty->driver->write(sp->tty, 0, &sp->led_state, 1);
 		} else {
 			sp->xleft = count;
 			sp->xhead = sp->xbuff;
@@ -357,7 +357,7 @@
 	}
 
 	if (sp->tx_enable == 1) {
-		actual = tty->driver.write(tty, 0, sp->xhead, sp->xleft);
+		actual = tty->driver->write(tty, 0, sp->xhead, sp->xleft);
 		sp->xleft -= actual;
 		sp->xhead += actual;
 	}
@@ -394,13 +394,13 @@
 
 	if (((sp->status1 & SIXP_DCD_MASK) == 0) && (random < sp->persistence)) {
 		sp->led_state = 0x70;
-		sp->tty->driver.write(sp->tty, 0, &sp->led_state, 1);
+		sp->tty->driver->write(sp->tty, 0, &sp->led_state, 1);
 		sp->tx_enable = 1;
-		actual = sp->tty->driver.write(sp->tty, 0, sp->xbuff, sp->status2);
+		actual = sp->tty->driver->write(sp->tty, 0, sp->xbuff, sp->status2);
 		sp->xleft -= actual;
 		sp->xhead += actual;
 		sp->led_state = 0x60;
-		sp->tty->driver.write(sp->tty, 0, &sp->led_state, 1);
+		sp->tty->driver->write(sp->tty, 0, &sp->led_state, 1);
 		sp->status2 = 0;
 	} else
 		sp_start_tx_timer(sp);
@@ -566,8 +566,8 @@
 		return -ENFILE;
 	sp->tty = tty;
 	tty->disc_data = sp;
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
@@ -882,7 +882,7 @@
 {
 	unsigned char inbyte = 0xe8;
 
-	sp->tty->driver.write(sp->tty, 0, &inbyte, 1);
+	sp->tty->driver->write(sp->tty, 0, &inbyte, 1);
 
 	del_timer(&sp->resync_t);
 	sp->resync_t.data = (unsigned long) sp;
@@ -924,9 +924,9 @@
 	else { /* output watchdog char if idle */
 		if ((sp->status2 != 0) && (sp->duplex == 1)) {
 			sp->led_state = 0x70;
-			sp->tty->driver.write(sp->tty, 0, &sp->led_state, 1);
+			sp->tty->driver->write(sp->tty, 0, &sp->led_state, 1);
 			sp->tx_enable = 1;
-			actual = sp->tty->driver.write(sp->tty, 0, sp->xbuff, sp->status2);
+			actual = sp->tty->driver->write(sp->tty, 0, sp->xbuff, sp->status2);
 			sp->xleft -= actual;
 			sp->xhead += actual;
 			sp->led_state = 0x60;
@@ -936,7 +936,7 @@
 	}
 
 	/* needed to trigger the TNC watchdog */
-	sp->tty->driver.write(sp->tty, 0, &sp->led_state, 1);
+	sp->tty->driver->write(sp->tty, 0, &sp->led_state, 1);
 
         /* if the state byte has been received, the TNC is present,
            so the resync timer can be reset. */
@@ -977,8 +977,8 @@
 	/* resync the TNC */
 
 	sp->led_state = 0x60;
-	sp->tty->driver.write(sp->tty, 0, &sp->led_state, 1);
-	sp->tty->driver.write(sp->tty, 0, &resync_cmd, 1);
+	sp->tty->driver->write(sp->tty, 0, &sp->led_state, 1);
+	sp->tty->driver->write(sp->tty, 0, &resync_cmd, 1);
 
 
 	/* Start resync timer again -- the TNC might be still absent */
@@ -1006,12 +1006,12 @@
 				if ((sp->status & SIXP_RX_DCD_MASK) ==
 					SIXP_RX_DCD_MASK) {
 					sp->led_state = 0x68;
-					sp->tty->driver.write(sp->tty, 0, &sp->led_state, 1);
+					sp->tty->driver->write(sp->tty, 0, &sp->led_state, 1);
 				}
 			} else {
 				sp->led_state = 0x60;
 				/* fill trailing bytes with zeroes */
-				sp->tty->driver.write(sp->tty, 0, &sp->led_state, 1);
+				sp->tty->driver->write(sp->tty, 0, &sp->led_state, 1);
 				rest = sp->rx_count;
 				if (rest != 0)
 					 for (i = rest; i <= 3; i++)
diff -Nru a/drivers/net/hamradio/Kconfig b/drivers/net/hamradio/Kconfig
--- a/drivers/net/hamradio/Kconfig	Wed Apr 30 22:28:04 2003
+++ b/drivers/net/hamradio/Kconfig	Wed Apr 30 22:28:04 2003
@@ -60,7 +60,7 @@
 	  Currently, this driver supports Ottawa PI/PI2, Paccomm/Gracilis
 	  PackeTwin, and S5SCC/DMA boards. They are detected automatically.
 	  If you have one of these cards, say Y here and read the AX25-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>.
+	  available from <http://www.tldp.org/docs.html#howto>.
 
 	  This driver can operate multiple boards simultaneously. If you
 	  compile it as a module (by saying M instead of Y), it will be called
@@ -88,7 +88,7 @@
 	  in order to communicate with other computers. If you want to use
 	  this, read <file:Documentation/networking/z8530drv.txt> and the
 	  AX25-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. Also make sure to say Y
+	  <http://www.tldp.org/docs.html#howto>. Also make sure to say Y
 	  to "Amateur Radio AX.25 Level 2" support.
 
 	  If you want to compile this as a module ( = code which can be
diff -Nru a/drivers/net/hamradio/baycom_ser_fdx.c b/drivers/net/hamradio/baycom_ser_fdx.c
--- a/drivers/net/hamradio/baycom_ser_fdx.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/net/hamradio/baycom_ser_fdx.c	Wed Apr 30 22:28:10 2003
@@ -279,7 +279,7 @@
 
 /* --------------------------------------------------------------------- */
 
-static void ser12_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t ser12_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *)dev_id;
 	struct baycom_state *bc = (struct baycom_state *)dev->priv;
@@ -288,10 +288,10 @@
 	unsigned int txcount = 0;
 
 	if (!bc || bc->hdrv.magic != HDLCDRV_MAGIC)
-		return;
+		return IRQ_NONE;
 	/* fast way out for shared irq */
 	if ((iir = inb(IIR(dev->base_addr))) & 1) 	
-		return;
+		return IRQ_NONE;
 	/* get current time */
 	do_gettimeofday(&tv);
 	msr = inb(MSR(dev->base_addr));
@@ -362,6 +362,7 @@
 	hdlcdrv_transmitter(dev, &bc->hdrv);
 	hdlcdrv_receiver(dev, &bc->hdrv);
 	local_irq_disable();
+	return IRQ_HANDLED;
 }
 
 /* --------------------------------------------------------------------- */
diff -Nru a/drivers/net/hamradio/baycom_ser_hdx.c b/drivers/net/hamradio/baycom_ser_hdx.c
--- a/drivers/net/hamradio/baycom_ser_hdx.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/hamradio/baycom_ser_hdx.c	Wed Apr 30 22:28:03 2003
@@ -373,17 +373,17 @@
 
 /* --------------------------------------------------------------------- */
 
-static void ser12_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t ser12_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *)dev_id;
 	struct baycom_state *bc = (struct baycom_state *)dev->priv;
 	unsigned char iir;
 
 	if (!dev || !bc || bc->hdrv.magic != HDLCDRV_MAGIC)
-		return;
+		return IRQ_NONE;
 	/* fast way out */
 	if ((iir = inb(IIR(dev->base_addr))) & 1)
-		return;
+		return IRQ_NONE;
 	baycom_int_freq(bc);
 	do {
 		switch (iir & 6) {
@@ -423,6 +423,7 @@
 	hdlcdrv_transmitter(dev, &bc->hdrv);
 	hdlcdrv_receiver(dev, &bc->hdrv);
 	local_irq_disable();
+	return IRQ_HANDLED;
 }
 
 /* --------------------------------------------------------------------- */
diff -Nru a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
--- a/drivers/net/hamradio/dmascc.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/net/hamradio/dmascc.c	Wed Apr 30 22:28:08 2003
@@ -266,7 +266,7 @@
 static struct net_device_stats *scc_get_stats(struct net_device *dev);
 static int scc_set_mac_address(struct net_device *dev, void *sa);
 
-static void scc_isr(int irq, void *dev_id, struct pt_regs * regs);
+static irqreturn_t scc_isr(int irq, void *dev_id, struct pt_regs * regs);
 static inline void z8530_isr(struct scc_info *info);
 static void rx_isr(struct scc_priv *priv);
 static void special_condition(struct scc_priv *priv, int rc);
@@ -674,7 +674,7 @@
     if (reg) outb_p(reg, priv->scc_cmd);
     return inb_p(priv->scc_cmd);
   default:
-    spin_lock_irqsave(&priv->register_lock, flags);
+    spin_lock_irqsave(priv->register_lock, flags);
     outb_p(0, priv->card_base + PI_DREQ_MASK);
     if (reg) outb_p(reg, priv->scc_cmd);
     rc = inb_p(priv->scc_cmd);
@@ -949,7 +949,7 @@
 }
 
 
-static void scc_isr(int irq, void *dev_id, struct pt_regs * regs) {
+static irqreturn_t scc_isr(int irq, void *dev_id, struct pt_regs * regs) {
   struct scc_info *info = dev_id;
 
   spin_lock(info->priv[0].register_lock);
@@ -981,6 +981,7 @@
     }
   } else z8530_isr(info);
   spin_unlock(info->priv[0].register_lock);
+  return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
--- a/drivers/net/hamradio/mkiss.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/net/hamradio/mkiss.c	Wed Apr 30 22:28:18 2003
@@ -384,7 +384,7 @@
 			 break;
 		}
 		ax->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
-		actual = ax->tty->driver.write(ax->tty, 0, ax->xbuff, count);
+		actual = ax->tty->driver->write(ax->tty, 0, ax->xbuff, count);
 		ax->tx_packets++;
 		ax->dev->trans_start = jiffies;
 		ax->xleft = count - actual;
@@ -392,7 +392,7 @@
 	} else {
 		count = kiss_esc(p, (unsigned char *) ax->mkiss->xbuff, len);
 		ax->mkiss->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
-		actual = ax->mkiss->tty->driver.write(ax->mkiss->tty, 0, ax->mkiss->xbuff, count);
+		actual = ax->mkiss->tty->driver->write(ax->mkiss->tty, 0, ax->mkiss->xbuff, count);
 		ax->tx_packets++;
 		ax->mkiss->dev->trans_start = jiffies;
 		ax->mkiss->xleft = count - actual;
@@ -429,7 +429,7 @@
 		return;
 	}
 
-	actual = tty->driver.write(tty, 0, ax->xhead, ax->xleft);
+	actual = tty->driver->write(tty, 0, ax->xhead, ax->xleft);
 	ax->xleft -= actual;
 	ax->xhead += actual;
 }
@@ -475,7 +475,7 @@
 		}
 
 		printk(KERN_ERR "mkiss: %s: transmit timed out, %s?\n", dev->name,
-		       (ax->tty->driver.chars_in_buffer(ax->tty) || ax->xleft) ?
+		       (ax->tty->driver->chars_in_buffer(ax->tty) || ax->xleft) ?
 		       "bad line quality" : "driver error");
 
 		ax->xleft = 0;
@@ -643,8 +643,8 @@
 	ax->mkiss = NULL;
 	tmp_ax    = NULL;
 
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 
diff -Nru a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
--- a/drivers/net/hamradio/yam.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/net/hamradio/yam.c	Wed Apr 30 22:28:14 2003
@@ -714,7 +714,7 @@
 * ISR routine
 ************************************************************************************/
 
-static void yam_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t yam_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev;
 	struct yam_port *yp;
@@ -758,6 +758,7 @@
 			}
 		}
 	}
+	return IRQ_HANDLED;
 }
 
 static int yam_net_get_info(char *buffer, char **start, off_t offset, int length)
diff -Nru a/drivers/net/hp100.c b/drivers/net/hp100.c
--- a/drivers/net/hp100.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/net/hp100.c	Wed Apr 30 22:28:08 2003
@@ -320,7 +320,7 @@
 static void hp100_update_stats(struct net_device *dev);
 static void hp100_clear_stats(struct hp100_private *lp, int ioaddr);
 static void hp100_set_multicast_list(struct net_device *dev);
-static void hp100_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t hp100_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void hp100_start_interface(struct net_device *dev);
 static void hp100_stop_interface(struct net_device *dev);
 static void hp100_load_eeprom(struct net_device *dev, u_short ioaddr);
@@ -2271,7 +2271,7 @@
  *  hardware interrupt handling
  */
 
-static void hp100_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t hp100_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *) dev_id;
 	struct hp100_private *lp = (struct hp100_private *) dev->priv;
@@ -2280,7 +2280,7 @@
 	u_int val;
 
 	if (dev == NULL)
-		return;
+		return IRQ_NONE;
 	ioaddr = dev->base_addr;
 
 	spin_lock(&lp->lock);
@@ -2302,7 +2302,7 @@
 	if (val == 0) {		/* might be a shared interrupt */
 		spin_unlock(&lp->lock);
 		hp100_ints_on();
-		return;
+		return IRQ_NONE;
 	}
 	/* We're only interested in those interrupts we really enabled. */
 	/* val &= hp100_inw( IRQ_MASK ); */
@@ -2394,6 +2394,7 @@
 
 	spin_unlock(&lp->lock);
 	hp100_ints_on();
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/net/ibmlana.c b/drivers/net/ibmlana.c
--- a/drivers/net/ibmlana.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/net/ibmlana.c	Wed Apr 30 22:28:05 2003
@@ -701,14 +701,14 @@
 
 /* general interrupt entry */
 
-static void irq_handler(int irq, void *device, struct pt_regs *regs)
+static irqreturn_t irq_handler(int irq, void *device, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *) device;
 	u16 ival;
 
 	/* in case we're not meant... */
 	if (!(inb(dev->base_addr + BCMREG) & BCMREG_IPEND))
-		return;
+		return IRQ_NONE;
 
 	/* loop through the interrupt bits until everything is clear */
 	while (1) {
@@ -732,6 +732,7 @@
 		}
 		break;
 	}
+	return IRQ_HANDLED;
 }
 
 /* ------------------------------------------------------------------------
diff -Nru a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c
--- a/drivers/net/ioc3-eth.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/net/ioc3-eth.c	Wed Apr 30 22:28:04 2003
@@ -681,7 +681,7 @@
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread.  */
-static void ioc3_interrupt(int irq, void *_dev, struct pt_regs *regs)
+static irqreturn_t ioc3_interrupt(int irq, void *_dev, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *)_dev;
 	struct ioc3_private *ip = dev->priv;
@@ -707,6 +707,7 @@
 
 		eisr = ioc3->eisr & enabled;
 	}
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c
--- a/drivers/net/irda/ali-ircc.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/net/irda/ali-ircc.c	Wed Apr 30 22:28:08 2003
@@ -95,7 +95,6 @@
 static int  ali_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static int  ali_ircc_pmproc(struct pm_dev *dev, pm_request_t rqst, void *data);
 static void ali_ircc_change_speed(struct ali_ircc_cb *self, __u32 baud);
-static void ali_ircc_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void ali_ircc_suspend(struct ali_ircc_cb *self);
 static void ali_ircc_wakeup(struct ali_ircc_cb *self);
 static struct net_device_stats *ali_ircc_net_get_stats(struct net_device *dev);
@@ -632,7 +631,8 @@
  *    An interrupt from the chip has arrived. Time to do some work
  *
  */
-static void ali_ircc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t ali_ircc_interrupt(int irq, void *dev_id,
+					struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *) dev_id;
 	struct ali_ircc_cb *self;
@@ -641,7 +641,7 @@
 		
  	if (!dev) {
 		WARNING("%s: irq %d for unknown device.\n", driver_name, irq);
-		return;
+		return IRQ_NONE;
 	}	
 	
 	self = (struct ali_ircc_cb *) dev->priv;
@@ -656,7 +656,8 @@
 		
 	spin_unlock(&self->lock);
 	
-	IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__);		
+	IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__);
+	return IRQ_HANDLED;
 }
 /*
  * Function ali_ircc_fir_interrupt(irq, struct ali_ircc_cb *self, regs)
diff -Nru a/drivers/net/irda/donauboe.c b/drivers/net/irda/donauboe.c
--- a/drivers/net/irda/donauboe.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/net/irda/donauboe.c	Wed Apr 30 22:28:08 2003
@@ -745,20 +745,20 @@
   return 1;
 }
 
-STATIC void
+STATIC irqreturn_t
 toshoboe_probeinterrupt (int irq, void *dev_id, struct pt_regs *regs)
 {
   struct toshoboe_cb *self = (struct toshoboe_cb *) dev_id;
   __u8 irqstat;
 
   if (self == NULL && toshoboe_invalid_dev(irq)) 
-    return;
+    return IRQ_NONE;
 
   irqstat = INB (OBOE_ISR);
 
 /* was it us */
   if (!(irqstat & OBOE_INT_MASK))
-    return;
+    return IRQ_NONE;
 
 /* Ack all the interrupts */
   OUTB (irqstat, OBOE_ISR);
@@ -791,6 +791,7 @@
   if (irqstat & OBOE_INT_SIP) {
     self->int_sip++;
     PROBE_DEBUG("I"); }
+  return IRQ_HANDLED;
 }
 
 STATIC int
@@ -1193,7 +1194,7 @@
 }
 
 /*interrupt handler */
-STATIC void
+STATIC irqreturn_t
 toshoboe_interrupt (int irq, void *dev_id, struct pt_regs *regs)
 {
   struct toshoboe_cb *self = (struct toshoboe_cb *) dev_id;
@@ -1201,13 +1202,13 @@
   struct sk_buff *skb = NULL;
 
   if (self == NULL && toshoboe_invalid_dev(irq)) 
-    return;
+    return IRQ_NONE;
 
   irqstat = INB (OBOE_ISR);
 
 /* was it us */
   if (!(irqstat & OBOE_INT_MASK))
-      return;
+      return IRQ_NONE;
 
 /* Ack all the interrupts */
   OUTB (irqstat, OBOE_ISR);
@@ -1381,6 +1382,7 @@
       IRDA_DEBUG (1, "%s.sip:%x(%x)%x\n", __FUNCTION__
 	      ,self->int_sip,irqstat,self->txpending);
     }
+  return IRQ_HANDLED;
 }
 
 STATIC int
diff -Nru a/drivers/net/irda/irport.c b/drivers/net/irda/irport.c
--- a/drivers/net/irda/irport.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/net/irda/irport.c	Wed Apr 30 22:28:11 2003
@@ -720,17 +720,18 @@
  *
  *    Interrupt handler
  */
-void irport_interrupt(int irq, void *dev_id, struct pt_regs *regs) 
+irqreturn_t irport_interrupt(int irq, void *dev_id, struct pt_regs *regs) 
 {
 	struct net_device *dev = (struct net_device *) dev_id;
 	struct irport_cb *self;
 	int boguscount = 0;
 	int iobase;
 	int iir, lsr;
+	int handled = 0;
 
 	if (!dev) {
 		WARNING("%s() irq %d for unknown device.\n", __FUNCTION__, irq);
-		return;
+		return IRQ_NONE;
 	}
 	self = (struct irport_cb *) dev->priv;
 
@@ -740,6 +741,8 @@
 
 	iir = inb(iobase+UART_IIR) & UART_IIR_ID;
 	while (iir) {
+		handled = 1;
+
 		/* Clear interrupt */
 		lsr = inb(iobase+UART_LSR);
 
@@ -771,6 +774,7 @@
  	        iir = inb(iobase + UART_IIR) & UART_IIR_ID;
 	}
 	spin_unlock(&self->lock);
+	return IRQ_RETVAL(handled);
 }
 
 static int irport_net_init(struct net_device *dev)
diff -Nru a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c
--- a/drivers/net/irda/irtty-sir.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/irda/irtty-sir.c	Wed Apr 30 22:28:03 2003
@@ -62,7 +62,7 @@
 	ASSERT(priv != NULL, return -1;);
 	ASSERT(priv->magic == IRTTY_MAGIC, return -1;);
 
-	return priv->tty->driver.chars_in_buffer(priv->tty);
+	return priv->tty->driver->chars_in_buffer(priv->tty);
 }
 
 /* Wait (sleep) until underlaying hardware finished transmission
@@ -91,9 +91,9 @@
 	ASSERT(priv->magic == IRTTY_MAGIC, return;);
 
 	tty = priv->tty;
-	if (tty->driver.wait_until_sent) {
+	if (tty->driver->wait_until_sent) {
 		lock_kernel();
-		tty->driver.wait_until_sent(tty, MSECS_TO_JIFFIES(100));
+		tty->driver->wait_until_sent(tty, MSECS_TO_JIFFIES(100));
 		unlock_kernel();
 	}
 	else {
@@ -161,8 +161,8 @@
 	}	
 
 	tty->termios->c_cflag = cflag;
-	if (tty->driver.set_termios)
-		tty->driver.set_termios(tty, &old_termios);
+	if (tty->driver->set_termios)
+		tty->driver->set_termios(tty, &old_termios);
 	unlock_kernel();
 
 	priv->io.speed = speed;
@@ -201,8 +201,8 @@
 	 * This function is not yet defined for all tty driver, so
 	 * let's be careful... Jean II
 	 */
-	ASSERT(priv->tty->driver.tiocmset != NULL, return -1;);
-	priv->tty->driver.tiocmset(priv->tty, NULL, set, clear);
+	ASSERT(priv->tty->driver->tiocmset != NULL, return -1;);
+	priv->tty->driver->tiocmset(priv->tty, NULL, set, clear);
 
 	return 0;
 }
@@ -231,17 +231,17 @@
 	ASSERT(priv->magic == IRTTY_MAGIC, return -1;);
 
 	tty = priv->tty;
-	if (!tty->driver.write)
+	if (!tty->driver->write)
 		return 0;
 	tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
-	if (tty->driver.write_room) {
-		writelen = tty->driver.write_room(tty);
+	if (tty->driver->write_room) {
+		writelen = tty->driver->write_room(tty);
 		if (writelen > len)
 			writelen = len;
 	}
 	else
 		writelen = len;
-	return tty->driver.write(tty, 0, ptr, writelen);
+	return tty->driver->write(tty, 0, ptr, writelen);
 }
 
 /* ------------------------------------------------------- */
@@ -354,8 +354,8 @@
 		cflag |= CREAD;
 
 	tty->termios->c_cflag = cflag;
-	if (tty->driver.set_termios)
-		tty->driver.set_termios(tty, &old_termios);
+	if (tty->driver->set_termios)
+		tty->driver->set_termios(tty, &old_termios);
 	unlock_kernel();
 }
 
@@ -381,8 +381,8 @@
 
 	tty = priv->tty;
 
-	if (tty->driver.start)
-		tty->driver.start(tty);
+	if (tty->driver->start)
+		tty->driver->start(tty);
 	/* Make sure we can receive more data */
 	irtty_stop_receiver(tty, FALSE);
 
@@ -410,8 +410,8 @@
 
 	/* Make sure we don't receive more data */
 	irtty_stop_receiver(tty, TRUE);
-	if (tty->driver.stop)
-		tty->driver.stop(tty);
+	if (tty->driver->stop)
+		tty->driver->stop(tty);
 
 	up(&irtty_sem);
 
@@ -502,7 +502,6 @@
 {
 	struct sir_dev *dev;
 	struct sirtty_cb *priv;
-	char hwname[16];
 	int ret = 0;
 
 	/* unfortunately, there's no tty_ldisc->owner field
@@ -522,11 +521,11 @@
 
 	/* stop the underlying  driver */
 	irtty_stop_receiver(tty, TRUE);
-	if (tty->driver.stop)
-		tty->driver.stop(tty);
+	if (tty->driver->stop)
+		tty->driver->stop(tty);
 
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	
 /* from old irtty - but what is it good for?
  * we _are_ the ldisc and we _don't_ implement flush_buffer!
@@ -535,25 +534,11 @@
  *		tty->ldisc.flush_buffer(tty);
  */
 
-
-	/* create device name - could we use tty_name() here? */
-
-	if (strchr(tty->driver.name, '%')) {
-		sprintf(hwname, tty->driver.name,
-			minor(tty->device) - tty->driver.minor_start +
-			tty->driver.name_base);
-	}
-	else {
-		sprintf(hwname, "%s%d", tty->driver.name,
-			minor(tty->device) - tty->driver.minor_start +
-			tty->driver.name_base);
-	}
-
 	/* apply mtt override */
 	sir_tty_drv.qos_mtt_bits = qos_mtt_bits;
 
 	/* get a sir device instance for this driver */
-	dev = sirdev_get_instance(&sir_tty_drv, hwname);
+	dev = sirdev_get_instance(&sir_tty_drv, tty->name);
 	if (!dev) {
 		ret = -ENODEV;
 		goto out;
@@ -625,8 +610,8 @@
 	/* Stop tty */
 	irtty_stop_receiver(tty, TRUE);
 	tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
-	if (tty->driver.stop)
-		tty->driver.stop(tty);
+	if (tty->driver->stop)
+		tty->driver->stop(tty);
 
 	kfree(priv);
 
diff -Nru a/drivers/net/irda/irtty.c b/drivers/net/irda/irtty.c
--- a/drivers/net/irda/irtty.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/net/irda/irtty.c	Wed Apr 30 22:28:06 2003
@@ -170,14 +170,12 @@
 	tty->disc_data = self;
 
 	/* Give self a name */
-	sprintf(name, "%s%d", tty->driver.name,
-		minor(tty->device) - tty->driver.minor_start +
-		tty->driver.name_base);
+	strcpy(name, tty->name);
 
 	hashbin_insert(irtty, (irda_queue_t *) self, (int) self, NULL);
 
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
@@ -335,7 +333,7 @@
 
 	/* This is unsafe, but currently under discussion - Jean II */
 	self->tty->termios->c_cflag = cflag;
-	self->tty->driver.set_termios(self->tty, &old_termios);
+	self->tty->driver->set_termios(self->tty, &old_termios);
 }
 
 /* 
@@ -388,7 +386,7 @@
 
 	/* This is unsafe, but currently under discussion - Jean II */
 	self->tty->termios->c_cflag = cflag;
-	self->tty->driver.set_termios(self->tty, &old_termios);
+	self->tty->driver->set_termios(self->tty, &old_termios);
 
 	self->io.speed = speed;
 }
@@ -429,7 +427,7 @@
 		 * Make sure all data is sent before changing the speed of the
 		 * serial port.
 		 */
-		if (self->tty->driver.chars_in_buffer(self->tty)) {
+		if (self->tty->driver->chars_in_buffer(self->tty)) {
 			/* Keep state, and try again later */
 			ret = MSECS_TO_JIFFIES(10);
 			break;
@@ -684,8 +682,8 @@
 	dev->trans_start = jiffies;
 	self->stats.tx_bytes += self->tx_buff.len;
 
-	if (self->tty->driver.write)
-		actual = self->tty->driver.write(self->tty, 0, 
+	if (self->tty->driver->write)
+		actual = self->tty->driver->write(self->tty, 0, 
 						 self->tx_buff.data, 
 						 self->tx_buff.len);
 	/* Hide the part we just transmitted */
@@ -738,7 +736,7 @@
 	/* Finished with frame?  */
 	if (self->tx_buff.len > 0)  {
 		/* Write data left in transmit buffer */
-		actual = tty->driver.write(tty, 0, self->tx_buff.data, 
+		actual = tty->driver->write(tty, 0, self->tx_buff.data, 
 					   self->tx_buff.len);
 
 		self->tx_buff.data += actual;
@@ -823,7 +821,7 @@
 	set_fs(get_ds());
 	
 	/* This is probably unsafe, but currently under discussion - Jean II */
-	if (tty->driver.ioctl(tty, NULL, TIOCMSET, (unsigned long) &arg)) { 
+	if (tty->driver->ioctl(tty, NULL, TIOCMSET, (unsigned long) &arg)) { 
 		IRDA_DEBUG(2, "%s(), error doing ioctl!\n", __FUNCTION__);
 	}
 	set_fs(fs);
@@ -923,8 +921,8 @@
 	ASSERT(self != NULL, return 0;);
 	ASSERT(self->magic == IRTTY_MAGIC, return 0;);
 
-	if (self->tty->driver.write)
-		actual = self->tty->driver.write(self->tty, 0, buf, len);
+	if (self->tty->driver->write)
+		actual = self->tty->driver->write(self->tty, 0, buf, len);
 
 	return actual;
 }
@@ -957,9 +955,7 @@
 	irtty_stop_receiver(self, FALSE);
 
 	/* Give self a hardware name */
-	sprintf(hwname, "%s%d", tty->driver.name,
-		minor(tty->device) - tty->driver.minor_start +
-		tty->driver.name_base);
+	sprintf(hwname, "%s", tty->name);
 
 	/* 
 	 * Open new IrLAP layer instance, now that everything should be
diff -Nru a/drivers/net/irda/nsc-ircc.c b/drivers/net/irda/nsc-ircc.c
--- a/drivers/net/irda/nsc-ircc.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/irda/nsc-ircc.c	Wed Apr 30 22:28:03 2003
@@ -131,7 +131,6 @@
 static int  nsc_ircc_pio_write(int iobase, __u8 *buf, int len, int fifo_size);
 static void nsc_ircc_dma_xmit(struct nsc_ircc_cb *self, int iobase);
 static __u8 nsc_ircc_change_speed(struct nsc_ircc_cb *self, __u32 baud);
-static void nsc_ircc_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static int  nsc_ircc_is_receiving(struct nsc_ircc_cb *self);
 static int  nsc_ircc_read_dongle_id (int iobase);
 static void nsc_ircc_init_dongle_interface (int iobase, int dongle_id);
@@ -1781,7 +1780,8 @@
  *    An interrupt from the chip has arrived. Time to do some work
  *
  */
-static void nsc_ircc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t nsc_ircc_interrupt(int irq, void *dev_id,
+				struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *) dev_id;
 	struct nsc_ircc_cb *self;
@@ -1790,7 +1790,7 @@
 
 	if (!dev) {
 		WARNING("%s: irq %d for unknown device.\n", driver_name, irq);
-		return;
+		return IRQ_NONE;
 	}
 	self = (struct nsc_ircc_cb *) dev->priv;
 
@@ -1818,6 +1818,7 @@
 	outb(bsr, iobase+BSR);       /* Restore bank register */
 
 	spin_unlock(&self->lock);
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/net/irda/smc-ircc.c b/drivers/net/irda/smc-ircc.c
--- a/drivers/net/irda/smc-ircc.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/irda/smc-ircc.c	Wed Apr 30 22:28:03 2003
@@ -86,7 +86,7 @@
 static int  ircc_hard_xmit(struct sk_buff *skb, struct net_device *dev);
 static void ircc_dma_xmit(struct ircc_cb *self, int iobase, int bofs);
 static void ircc_change_speed(void *priv, u32 speed);
-static void ircc_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t ircc_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static int  ircc_net_open(struct net_device *dev);
 static int  ircc_net_close(struct net_device *dev);
 static int  ircc_pmproc(struct pm_dev *dev, pm_request_t rqst, void *data);
@@ -979,7 +979,7 @@
  *    An interrupt from the chip has arrived. Time to do some work
  *
  */
-static void ircc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t ircc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *) dev_id;
 	struct irport_cb *irport;
@@ -989,18 +989,18 @@
 	if (dev == NULL) {
 		printk(KERN_WARNING "%s: irq %d for unknown device.\n", 
 		       driver_name, irq);
-		return;
+		return IRQ_NONE;
 	}
 	irport = (struct irport_cb *) dev->priv;
-	ASSERT(irport != NULL, return;);
+	ASSERT(irport != NULL, return IRQ_NONE;);
 	self = (struct ircc_cb *) irport->priv;
-	ASSERT(self != NULL, return;);
+	ASSERT(self != NULL, return IRQ_NONE;);
 
 	/* Check if we should use the SIR interrupt handler */
 	if (self->io->speed < 576000) {
 		/* Will spinlock itself - Jean II */
 		irport_interrupt(irq, dev_id, regs);
-		return;
+		return IRQ_HANDLED;
 	}
 	iobase = self->io->fir_base;
 
@@ -1028,6 +1028,7 @@
 	outb(IRCC_IER_ACTIVE_FRAME|IRCC_IER_EOM, iobase+IRCC_IER);
 
 	spin_unlock(&self->irport->lock);
+	return IRQ_HANDLED;
 }
 
 #if 0 /* unused */
diff -Nru a/drivers/net/irda/toshoboe.c b/drivers/net/irda/toshoboe.c
--- a/drivers/net/irda/toshoboe.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/irda/toshoboe.c	Wed Apr 30 22:28:03 2003
@@ -349,7 +349,7 @@
 }
 
 /*interrupt handler */
-static void
+static irqreturn_t
 toshoboe_interrupt (int irq, void *dev_id, struct pt_regs *regs)
 {
   struct toshoboe_cb *self = (struct toshoboe_cb *) dev_id;
@@ -360,7 +360,7 @@
     {
       printk (KERN_WARNING "%s: irq %d for unknown device.\n",
               driver_name, irq);
-      return;
+      return IRQ_NONE;
     }
 
   IRDA_DEBUG (4, "%s()\n", __FUNCTION__ );
@@ -369,7 +369,7 @@
 
 /* woz it us */
   if (!(irqstat & 0xf8))
-    return;
+    return IRQ_NONE;
 
   outb_p (irqstat, OBOE_ISR);   /*Acknologede it */
 
@@ -456,8 +456,7 @@
       self->stats.rx_errors++;
 
     }
-
-
+  return IRQ_HANDLED;
 }
 
 static int
diff -Nru a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
--- a/drivers/net/irda/vlsi_ir.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/irda/vlsi_ir.c	Wed Apr 30 22:28:03 2003
@@ -1570,7 +1570,8 @@
 
 /********************************************************/
 
-static void vlsi_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
+static irqreturn_t vlsi_interrupt(int irq, void *dev_instance,
+					struct pt_regs *regs)
 {
 	struct net_device *ndev = dev_instance;
 	vlsi_irda_dev_t *idev = ndev->priv;
@@ -1579,6 +1580,7 @@
 	int 		boguscount = 32;
 	unsigned	got_act;
 	unsigned long	flags;
+	int		handled = 0;
 
 	got_act = 0;
 	iobase = ndev->base_addr;
@@ -1591,7 +1593,7 @@
 
 		if (!(irintr&=IRINTR_INT_MASK))		/* not our INT - probably shared */
 			break;
-
+		handled = 1;
 		if (irintr&IRINTR_RPKTINT)
 			vlsi_rx_interrupt(ndev);
 
@@ -1610,7 +1612,7 @@
 
 	if (boguscount <= 0)
 		printk(KERN_WARNING "%s: too much work in interrupt!\n", __FUNCTION__);
-
+	return IRQ_RETVAL(handled);
 }
 
 /********************************************************/
diff -Nru a/drivers/net/irda/w83977af_ir.c b/drivers/net/irda/w83977af_ir.c
--- a/drivers/net/irda/w83977af_ir.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/net/irda/w83977af_ir.c	Wed Apr 30 22:28:08 2003
@@ -97,7 +97,6 @@
 static int  w83977af_pio_write(int iobase, __u8 *buf, int len, int fifo_size);
 static void w83977af_dma_write(struct w83977af_ir *self, int iobase);
 static void w83977af_change_speed(struct w83977af_ir *self, __u32 speed);
-static void w83977af_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static int  w83977af_is_receiving(struct w83977af_ir *self);
 
 static int  w83977af_net_init(struct net_device *dev);
@@ -1118,7 +1117,8 @@
  *    An interrupt from the chip has arrived. Time to do some work
  *
  */
-static void w83977af_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t w83977af_interrupt(int irq, void *dev_id,
+					struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *) dev_id;
 	struct w83977af_ir *self;
@@ -1128,7 +1128,7 @@
 	if (!dev) {
 		printk(KERN_WARNING "%s: irq %d for unknown device.\n", 
 			driver_name, irq);
-		return;
+		return IRQ_NONE;
 	}
 	self = (struct w83977af_ir *) dev->priv;
 
@@ -1153,7 +1153,7 @@
 
 	outb(icr, iobase+ICR);    /* Restore (new) interrupts */
 	outb(set, iobase+SSR);    /* Restore bank register */
-
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/net/isa-skeleton.c b/drivers/net/isa-skeleton.c
--- a/drivers/net/isa-skeleton.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/net/isa-skeleton.c	Wed Apr 30 22:28:18 2003
@@ -109,7 +109,7 @@
 static int	netcard_probe1(struct net_device *dev, int ioaddr);
 static int	net_open(struct net_device *dev);
 static int	net_send_packet(struct sk_buff *skb, struct net_device *dev);
-static void	net_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t net_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void	net_rx(struct net_device *dev);
 static int	net_close(struct net_device *dev);
 static struct	net_device_stats *net_get_stats(struct net_device *dev);
@@ -470,17 +470,22 @@
  * The typical workload of the driver:
  * Handle the network interface interrupts.
  */
-static void net_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t net_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
 	struct net_device *dev = dev_id;
 	struct net_local *np;
 	int ioaddr, status;
+	int handled = 0;
 
 	ioaddr = dev->base_addr;
 
 	np = (struct net_local *)dev->priv;
 	status = inw(ioaddr + 0);
 
+	if (status == 0)
+		goto out;
+	handled = 1;
+
 	if (status & RX_INTR) {
 		/* Got a packet(s). */
 		net_rx(dev);
@@ -497,6 +502,8 @@
 		/* Increment the appropriate 'localstats' field. */
 		np->stats.tx_window_errors++;
 	}
+out:
+	return IRQ_RETVAL(handled);
 }
 
 /* We have a good packet(s), get it/them out of the buffers. */
diff -Nru a/drivers/net/ixgb/Makefile b/drivers/net/ixgb/Makefile
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/net/ixgb/Makefile	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,35 @@
+################################################################################
+#
+# 
+# Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved.
+# 
+# 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; either version 2 of the License, or (at your option) 
+# any later version.
+# 
+# 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.
+# 
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 59 
+# Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+# 
+# The full GNU General Public License is included in this distribution in the
+# file called LICENSE.
+# 
+# Contact Information:
+# Linux NICS <linux.nics@intel.com>
+# Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+#
+################################################################################
+
+#
+# Makefile for the Intel(R) PRO/10GbE driver
+#
+
+obj-$(CONFIG_IXGB) += ixgb.o
+
+ixgb-objs := ixgb_main.o ixgb_hw.o ixgb_ee.o ixgb_ethtool.o ixgb_param.o
diff -Nru a/drivers/net/ixgb/ixgb.h b/drivers/net/ixgb/ixgb.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/net/ixgb/ixgb.h	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,185 @@
+/*******************************************************************************
+
+  
+  Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
+  
+  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; either version 2 of the License, or (at your option) 
+  any later version.
+  
+  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.
+  
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59 
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+  
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+  
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+*******************************************************************************/
+
+#ifndef _IXGB_H_
+#define _IXGB_H_
+
+#include <linux/stddef.h>
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <asm/byteorder.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/pci.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <linux/delay.h>
+#include <linux/timer.h>
+#include <linux/string.h>
+#include <linux/pagemap.h>
+#include <linux/bitops.h>
+#include <linux/in.h>
+#include <linux/ip.h>
+#include <linux/tcp.h>
+#include <linux/udp.h>
+#include <net/pkt_sched.h>
+#include <linux/list.h>
+#include <linux/workqueue.h>
+#include <linux/reboot.h>
+#ifdef NETIF_F_TSO
+#include <net/checksum.h>
+#endif
+
+/* ethtool support */
+#include <linux/ethtool.h>
+#include <linux/if_vlan.h>
+
+struct ixgb_adapter;
+
+#define BAR_0           0
+#define BAR_1           1
+#define BAR_5           5
+#define PCI_DMA_64BIT   0xffffffffffffffffULL
+#define PCI_DMA_32BIT   0x00000000ffffffffULL
+
+#include "ixgb_hw.h"
+#include "ixgb_ee.h"
+#include "ixgb_ids.h"
+
+#if _DEBUG_DRIVER_
+#define IXGB_DBG(args...) printk(KERN_DEBUG "ixgb: " args)
+#else
+#define IXGB_DBG(args...)
+#endif
+
+#define IXGB_ERR(args...) printk(KERN_ERR "ixgb: " args)
+
+/* Supported Rx Buffer Sizes */
+#define IXGB_RXBUFFER_2048  2048
+#define IXGB_RXBUFFER_4096  4096
+#define IXGB_RXBUFFER_8192  8192
+#define IXGB_RXBUFFER_16384 16384
+
+/* How many Tx Descriptors do we need to call netif_wake_queue? */
+#define IXGB_TX_QUEUE_WAKE 16
+
+/* How many Rx Buffers do we bundle into one write to the hardware ? */
+#define IXGB_RX_BUFFER_WRITE    16
+
+/* only works for sizes that are powers of 2 */
+#define IXGB_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
+
+/* wrapper around a pointer to a socket buffer,
+ * so a DMA handle can be stored along with the buffer */
+struct ixgb_buffer {
+	struct sk_buff *skb;
+	uint64_t dma;
+	unsigned long length;
+	unsigned long time_stamp;
+};
+
+struct ixgb_desc_ring {
+	/* pointer to the descriptor ring memory  */
+	void *desc;
+	/* physical address of the descriptor ring  */
+	dma_addr_t dma;
+	/* length of descriptor ring in bytes  */
+	unsigned int size;
+	/* number of descriptors in the ring  */
+	unsigned int count;
+	/* next descriptor to associate a buffer with  */
+	unsigned int next_to_use;
+	/* next descriptor to check for DD status bit  */
+	unsigned int next_to_clean;
+	/* array of buffer information structs  */
+	struct ixgb_buffer *buffer_info;
+};
+
+#define IXGB_DESC_UNUSED(R) \
+((((R)->next_to_clean + (R)->count) - ((R)->next_to_use + 1)) % ((R)->count))
+
+#define IXGB_GET_DESC(R, i, type)       (&(((struct type *)((R).desc))[i]))
+#define IXGB_RX_DESC(R, i)              IXGB_GET_DESC(R, i, ixgb_rx_desc)
+#define IXGB_TX_DESC(R, i)              IXGB_GET_DESC(R, i, ixgb_tx_desc)
+#define IXGB_CONTEXT_DESC(R, i)         IXGB_GET_DESC(R, i, ixgb_context_desc)
+
+/* board specific private data structure */
+
+struct ixgb_adapter {
+	struct timer_list watchdog_timer;
+	struct vlan_group *vlgrp;
+	char *id_string;
+	u32 bd_number;
+	u32 rx_buffer_len;
+	u32 part_num;
+	u16 link_speed;
+	u16 link_duplex;
+	atomic_t irq_sem;
+	struct work_struct tx_timeout_task;
+
+#ifdef ETHTOOL_PHYS_ID
+	struct timer_list blink_timer;
+	unsigned long led_status;
+#endif
+#ifdef _INTERNAL_LOOPBACK_DRIVER_
+	struct ixgb_desc_ring diag_tx_ring;
+	struct ixgb_desc_ring diag_rx_ring;
+#endif
+	/* TX */
+	struct ixgb_desc_ring tx_ring;
+	unsigned long timeo_start;
+	u32 tx_cmd_type;
+	int max_data_per_txd;
+	uint64_t hw_csum_tx_good;
+	uint64_t hw_csum_tx_error;
+	boolean_t tx_csum;
+	u32 tx_int_delay;
+	boolean_t tx_int_delay_enable;
+
+	/* RX */
+	struct ixgb_desc_ring rx_ring;
+	uint64_t hw_csum_rx_error;
+	uint64_t hw_csum_rx_good;
+	u32 rx_int_delay;
+	boolean_t raidc;
+	boolean_t rx_csum;
+
+	/* OS defined structs */
+	struct net_device *netdev;
+	struct pci_dev *pdev;
+	struct net_device_stats net_stats;
+
+	/* structs defined in ixgb_hw.h */
+	struct ixgb_hw hw;
+	struct ixgb_hw_stats stats;
+	u32 pci_state[16];
+	char ifname[IFNAMSIZ];
+};
+
+#endif				/* _IXGB_H_ */
diff -Nru a/drivers/net/ixgb/ixgb_ee.c b/drivers/net/ixgb/ixgb_ee.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/net/ixgb/ixgb_ee.c	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,749 @@
+/*******************************************************************************
+
+  
+  Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
+  
+  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; either version 2 of the License, or (at your option) 
+  any later version.
+  
+  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.
+  
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59 
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+  
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+  
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+*******************************************************************************/
+
+#include "ixgb_hw.h"
+#include "ixgb_ee.h"
+/* Local prototypes */
+static u16 ixgb_shift_in_bits(struct ixgb_hw *hw);
+
+static void ixgb_shift_out_bits(struct ixgb_hw *hw,
+				u16 data, u16 count);
+static void ixgb_standby_eeprom(struct ixgb_hw *hw);
+
+static boolean_t ixgb_wait_eeprom_command(struct ixgb_hw *hw);
+
+static void ixgb_cleanup_eeprom(struct ixgb_hw *hw);
+
+/******************************************************************************
+ * Raises the EEPROM's clock input.
+ *
+ * hw - Struct containing variables accessed by shared code
+ * eecd_reg - EECD's current value
+ *****************************************************************************/
+static void
+ixgb_raise_clock(struct ixgb_hw *hw, u32 * eecd_reg)
+{
+	/* Raise the clock input to the EEPROM (by setting the SK bit), and then
+	 *  wait 50 microseconds.
+	 */
+	*eecd_reg = *eecd_reg | IXGB_EECD_SK;
+	IXGB_WRITE_REG(hw, EECD, *eecd_reg);
+	udelay(50);
+	return;
+}
+
+/******************************************************************************
+ * Lowers the EEPROM's clock input.
+ *
+ * hw - Struct containing variables accessed by shared code 
+ * eecd_reg - EECD's current value
+ *****************************************************************************/
+static void
+ixgb_lower_clock(struct ixgb_hw *hw, u32 * eecd_reg)
+{
+	/* Lower the clock input to the EEPROM (by clearing the SK bit), and then 
+	 * wait 50 microseconds. 
+	 */
+	*eecd_reg = *eecd_reg & ~IXGB_EECD_SK;
+	IXGB_WRITE_REG(hw, EECD, *eecd_reg);
+	udelay(50);
+	return;
+}
+
+/******************************************************************************
+ * Shift data bits out to the EEPROM.
+ *
+ * hw - Struct containing variables accessed by shared code
+ * data - data to send to the EEPROM
+ * count - number of bits to shift out
+ *****************************************************************************/
+static void
+ixgb_shift_out_bits(struct ixgb_hw *hw, u16 data, u16 count)
+{
+	u32 eecd_reg;
+	u32 mask;
+
+	/* We need to shift "count" bits out to the EEPROM. So, value in the
+	 * "data" parameter will be shifted out to the EEPROM one bit at a time.
+	 * In order to do this, "data" must be broken down into bits. 
+	 */
+	mask = 0x01 << (count - 1);
+	eecd_reg = IXGB_READ_REG(hw, EECD);
+	eecd_reg &= ~(IXGB_EECD_DO | IXGB_EECD_DI);
+	do {
+		/* A "1" is shifted out to the EEPROM by setting bit "DI" to a "1",
+		 * and then raising and then lowering the clock (the SK bit controls
+		 * the clock input to the EEPROM).  A "0" is shifted out to the EEPROM
+		 * by setting "DI" to "0" and then raising and then lowering the clock.
+		 */
+		eecd_reg &= ~IXGB_EECD_DI;
+
+		if (data & mask)
+			eecd_reg |= IXGB_EECD_DI;
+
+		IXGB_WRITE_REG(hw, EECD, eecd_reg);
+
+		udelay(50);
+
+		ixgb_raise_clock(hw, &eecd_reg);
+		ixgb_lower_clock(hw, &eecd_reg);
+
+		mask = mask >> 1;
+
+	} while (mask);
+
+	/* We leave the "DI" bit set to "0" when we leave this routine. */
+	eecd_reg &= ~IXGB_EECD_DI;
+	IXGB_WRITE_REG(hw, EECD, eecd_reg);
+	return;
+}
+
+/******************************************************************************
+ * Shift data bits in from the EEPROM
+ *
+ * hw - Struct containing variables accessed by shared code
+ *****************************************************************************/
+static u16
+ixgb_shift_in_bits(struct ixgb_hw *hw)
+{
+	u32 eecd_reg;
+	u32 i;
+	u16 data;
+
+	/* In order to read a register from the EEPROM, we need to shift 16 bits 
+	 * in from the EEPROM. Bits are "shifted in" by raising the clock input to
+	 * the EEPROM (setting the SK bit), and then reading the value of the "DO"
+	 * bit.  During this "shifting in" process the "DI" bit should always be 
+	 * clear..
+	 */
+
+	eecd_reg = IXGB_READ_REG(hw, EECD);
+
+	eecd_reg &= ~(IXGB_EECD_DO | IXGB_EECD_DI);
+	data = 0;
+
+	for (i = 0; i < 16; i++) {
+		data = data << 1;
+		ixgb_raise_clock(hw, &eecd_reg);
+
+		eecd_reg = IXGB_READ_REG(hw, EECD);
+
+		eecd_reg &= ~(IXGB_EECD_DI);
+		if (eecd_reg & IXGB_EECD_DO)
+			data |= 1;
+
+		ixgb_lower_clock(hw, &eecd_reg);
+	}
+
+	return data;
+}
+
+/******************************************************************************
+ * Prepares EEPROM for access
+ *
+ * hw - Struct containing variables accessed by shared code
+ *
+ * Lowers EEPROM clock. Clears input pin. Sets the chip select pin. This 
+ * function should be called before issuing a command to the EEPROM.
+ *****************************************************************************/
+static void
+ixgb_setup_eeprom(struct ixgb_hw *hw)
+{
+	u32 eecd_reg;
+
+	eecd_reg = IXGB_READ_REG(hw, EECD);
+
+	/*  Clear SK and DI  */
+	eecd_reg &= ~(IXGB_EECD_SK | IXGB_EECD_DI);
+	IXGB_WRITE_REG(hw, EECD, eecd_reg);
+
+	/*  Set CS  */
+	eecd_reg |= IXGB_EECD_CS;
+	IXGB_WRITE_REG(hw, EECD, eecd_reg);
+	return;
+}
+
+/******************************************************************************
+ * Returns EEPROM to a "standby" state
+ * 
+ * hw - Struct containing variables accessed by shared code
+ *****************************************************************************/
+static void
+ixgb_standby_eeprom(struct ixgb_hw *hw)
+{
+	u32 eecd_reg;
+
+	eecd_reg = IXGB_READ_REG(hw, EECD);
+
+	/*  Deselct EEPROM  */
+	eecd_reg &= ~(IXGB_EECD_CS | IXGB_EECD_SK);
+	IXGB_WRITE_REG(hw, EECD, eecd_reg);
+	udelay(50);
+
+	/*  Clock high  */
+	eecd_reg |= IXGB_EECD_SK;
+	IXGB_WRITE_REG(hw, EECD, eecd_reg);
+	udelay(50);
+
+	/*  Select EEPROM  */
+	eecd_reg |= IXGB_EECD_CS;
+	IXGB_WRITE_REG(hw, EECD, eecd_reg);
+	udelay(50);
+
+	/*  Clock low  */
+	eecd_reg &= ~IXGB_EECD_SK;
+	IXGB_WRITE_REG(hw, EECD, eecd_reg);
+	udelay(50);
+	return;
+}
+
+/******************************************************************************
+ * Raises then lowers the EEPROM's clock pin
+ *
+ * hw - Struct containing variables accessed by shared code
+ *****************************************************************************/
+static void
+ixgb_clock_eeprom(struct ixgb_hw *hw)
+{
+	u32 eecd_reg;
+
+	eecd_reg = IXGB_READ_REG(hw, EECD);
+
+	/*  Rising edge of clock  */
+	eecd_reg |= IXGB_EECD_SK;
+	IXGB_WRITE_REG(hw, EECD, eecd_reg);
+	udelay(50);
+
+	/*  Falling edge of clock  */
+	eecd_reg &= ~IXGB_EECD_SK;
+	IXGB_WRITE_REG(hw, EECD, eecd_reg);
+	udelay(50);
+	return;
+}
+
+/******************************************************************************
+ * Terminates a command by lowering the EEPROM's chip select pin
+ *
+ * hw - Struct containing variables accessed by shared code
+ *****************************************************************************/
+static void
+ixgb_cleanup_eeprom(struct ixgb_hw *hw)
+{
+	u32 eecd_reg;
+
+	eecd_reg = IXGB_READ_REG(hw, EECD);
+
+	eecd_reg &= ~(IXGB_EECD_CS | IXGB_EECD_DI);
+
+	IXGB_WRITE_REG(hw, EECD, eecd_reg);
+
+	ixgb_clock_eeprom(hw);
+	return;
+}
+
+/******************************************************************************
+ * Waits for the EEPROM to finish the current command.
+ *
+ * hw - Struct containing variables accessed by shared code
+ *
+ * The command is done when the EEPROM's data out pin goes high.
+ * 
+ * Returns:
+ *      TRUE: EEPROM data pin is high before timeout.
+ *      FALSE:  Time expired.
+ *****************************************************************************/
+static boolean_t
+ixgb_wait_eeprom_command(struct ixgb_hw *hw)
+{
+	u32 eecd_reg;
+	u32 i;
+
+	/* Toggle the CS line.  This in effect tells to EEPROM to actually execute 
+	 * the command in question.
+	 */
+	ixgb_standby_eeprom(hw);
+
+	/* Now read DO repeatedly until is high (equal to '1').  The EEEPROM will
+	 * signal that the command has been completed by raising the DO signal.
+	 * If DO does not go high in 10 milliseconds, then error out.
+	 */
+	for (i = 0; i < 200; i++) {
+		eecd_reg = IXGB_READ_REG(hw, EECD);
+
+		if (eecd_reg & IXGB_EECD_DO)
+			return (TRUE);
+
+		udelay(50);
+	}
+	ASSERT(0);
+	return (FALSE);
+}
+
+/******************************************************************************
+ * Verifies that the EEPROM has a valid checksum
+ * 
+ * hw - Struct containing variables accessed by shared code
+ *
+ * Reads the first 64 16 bit words of the EEPROM and sums the values read.
+ * If the the sum of the 64 16 bit words is 0xBABA, the EEPROM's checksum is
+ * valid.
+ *
+ * Returns:
+ *  TRUE: Checksum is valid
+ *  FALSE: Checksum is not valid.
+ *****************************************************************************/
+boolean_t
+ixgb_validate_eeprom_checksum(struct ixgb_hw * hw)
+{
+	u16 checksum = 0;
+	u16 i;
+
+	for (i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++)
+		checksum += ixgb_read_eeprom(hw, i);
+
+	if (checksum == (u16) EEPROM_SUM)
+		return (TRUE);
+	else
+		return (FALSE);
+}
+
+/******************************************************************************
+ * Calculates the EEPROM checksum and writes it to the EEPROM
+ *
+ * hw - Struct containing variables accessed by shared code
+ *
+ * Sums the first 63 16 bit words of the EEPROM. Subtracts the sum from 0xBABA.
+ * Writes the difference to word offset 63 of the EEPROM.
+ *****************************************************************************/
+void
+ixgb_update_eeprom_checksum(struct ixgb_hw *hw)
+{
+	u16 checksum = 0;
+	u16 i;
+
+	for (i = 0; i < EEPROM_CHECKSUM_REG; i++)
+		checksum += ixgb_read_eeprom(hw, i);
+
+	checksum = (u16) EEPROM_SUM - checksum;
+
+	ixgb_write_eeprom(hw, EEPROM_CHECKSUM_REG, checksum);
+	return;
+}
+
+/******************************************************************************
+ * Writes a 16 bit word to a given offset in the EEPROM.
+ *
+ * hw - Struct containing variables accessed by shared code
+ * reg - offset within the EEPROM to be written to
+ * data - 16 bit word to be writen to the EEPROM
+ *
+ * If ixgb_update_eeprom_checksum is not called after this function, the 
+ * EEPROM will most likely contain an invalid checksum.
+ *
+ *****************************************************************************/
+void
+ixgb_write_eeprom(struct ixgb_hw *hw, u16 offset, u16 data)
+{
+	/*  Prepare the EEPROM for writing  */
+	ixgb_setup_eeprom(hw);
+
+	/*  Send the 9-bit EWEN (write enable) command to the EEPROM (5-bit opcode
+	 *  plus 4-bit dummy).  This puts the EEPROM into write/erase mode. 
+	 */
+	ixgb_shift_out_bits(hw, EEPROM_EWEN_OPCODE, 5);
+	ixgb_shift_out_bits(hw, 0, 4);
+
+	/*  Prepare the EEPROM  */
+	ixgb_standby_eeprom(hw);
+
+	/*  Send the Write command (3-bit opcode + 6-bit addr)  */
+	ixgb_shift_out_bits(hw, EEPROM_WRITE_OPCODE, 3);
+	ixgb_shift_out_bits(hw, offset, 6);
+
+	/*  Send the data  */
+	ixgb_shift_out_bits(hw, data, 16);
+
+	ixgb_wait_eeprom_command(hw);
+
+	/*  Recover from write  */
+	ixgb_standby_eeprom(hw);
+
+	/* Send the 9-bit EWDS (write disable) command to the EEPROM (5-bit
+	 * opcode plus 4-bit dummy).  This takes the EEPROM out of write/erase
+	 * mode.
+	 */
+	ixgb_shift_out_bits(hw, EEPROM_EWDS_OPCODE, 5);
+	ixgb_shift_out_bits(hw, 0, 4);
+
+	/*  Done with writing  */
+	ixgb_cleanup_eeprom(hw);
+
+	return;
+}
+
+/******************************************************************************
+ * Reads a 16 bit word from the EEPROM.
+ *
+ * hw - Struct containing variables accessed by shared code
+ * offset - offset of 16 bit word in the EEPROM to read
+ *
+ * Returns:
+ *  The 16-bit value read from the eeprom
+ *****************************************************************************/
+u16
+ixgb_read_eeprom(struct ixgb_hw * hw, u16 offset)
+{
+	u16 data;
+
+	/*  Prepare the EEPROM for reading  */
+	ixgb_setup_eeprom(hw);
+
+	/*  Send the READ command (opcode + addr)  */
+	ixgb_shift_out_bits(hw, EEPROM_READ_OPCODE, 3);
+	/* 
+	 * We have a 64 word EEPROM, there are 6 address bits
+	 */
+	ixgb_shift_out_bits(hw, offset, 6);
+
+	/*  Read the data  */
+	data = ixgb_shift_in_bits(hw);
+
+	/*  End this read operation  */
+	ixgb_standby_eeprom(hw);
+
+	return (data);
+}
+
+/******************************************************************************
+ * Reads eeprom and stores data in shared structure.
+ * Validates eeprom checksum and eeprom signature.
+ *
+ * hw - Struct containing variables accessed by shared code 
+ *
+ * Returns:
+ *      TRUE: if eeprom read is successful
+ *      FALSE: otherwise.
+ *****************************************************************************/
+boolean_t
+ixgb_get_eeprom_data(struct ixgb_hw * hw)
+{
+	u16 i;
+	u16 checksum = 0;
+	struct ixgb_ee_map_type *ee_map;
+
+	DEBUGFUNC("ixgb_get_eeprom_data");
+
+	ee_map = (struct ixgb_ee_map_type *) hw->eeprom;
+
+	DEBUGOUT("ixgb_ee: Reading eeprom data\n");
+	for (i = 0; i < IXGB_EEPROM_SIZE; i++) {
+		u16 ee_data;
+		ee_data = ixgb_read_eeprom(hw, i);
+		checksum += ee_data;
+		hw->eeprom[i] = le16_to_cpu(ee_data);
+	}
+
+	if (checksum != (u16) EEPROM_SUM) {
+		DEBUGOUT("ixgb_ee: Checksum invalid.\n");
+		return (FALSE);
+	}
+
+	if ((ee_map->init_ctrl_reg_1 & le16_to_cpu(EEPROM_ICW1_SIGNATURE_MASK))
+	    != le16_to_cpu(EEPROM_ICW1_SIGNATURE_VALID)) {
+		DEBUGOUT("ixgb_ee: Signature invalid.\n");
+		return (FALSE);
+	}
+
+	return (TRUE);
+}
+
+/******************************************************************************
+ * Local function to check if the eeprom signature is good
+ * If the eeprom signature is good, calls ixgb)get_eeprom_data.
+ *
+ * hw - Struct containing variables accessed by shared code 
+ *
+ * Returns:
+ *      TRUE: eeprom signature was good and the eeprom read was successful
+ *      FALSE: otherwise.
+ ******************************************************************************/
+static boolean_t
+ixgb_check_and_get_eeprom_data(struct ixgb_hw *hw)
+{
+	struct ixgb_ee_map_type *ee_map =
+	    (struct ixgb_ee_map_type *) hw->eeprom;
+
+	if ((ee_map->init_ctrl_reg_1 & le16_to_cpu(EEPROM_ICW1_SIGNATURE_MASK))
+	    == le16_to_cpu(EEPROM_ICW1_SIGNATURE_VALID)) {
+		return (TRUE);
+	} else {
+		return ixgb_get_eeprom_data(hw);
+	}
+}
+
+/******************************************************************************
+ * return the mac address from EEPROM
+ *
+ * hw       - Struct containing variables accessed by shared code 
+ * mac_addr - Ethernet Address if EEPROM contents are valid, 0 otherwise
+ *
+ * Returns: None.
+ ******************************************************************************/
+void
+ixgb_get_ee_mac_addr(struct ixgb_hw *hw, u8 * mac_addr)
+{
+	int i;
+	struct ixgb_ee_map_type *ee_map =
+	    (struct ixgb_ee_map_type *) hw->eeprom;
+
+	DEBUGFUNC("ixgb_get_ee_mac_addr");
+
+	if (ixgb_check_and_get_eeprom_data(hw) == TRUE) {
+		for (i = 0; i < IXGB_ETH_LENGTH_OF_ADDRESS; i++) {
+			mac_addr[i] = ee_map->mac_addr[i];
+			DEBUGOUT2("mac(%d) = %.2X\n", i, mac_addr[i]);
+		}
+	}
+}
+
+/******************************************************************************
+ * return the compatibility flags from EEPROM
+ *
+ * hw - Struct containing variables accessed by shared code 
+ *
+ * Returns: 
+ *          compatibility flags if EEPROM contents are valid, 0 otherwise
+ ******************************************************************************/
+u16
+ixgb_get_ee_compatibility(struct ixgb_hw *hw)
+{
+	struct ixgb_ee_map_type *ee_map =
+	    (struct ixgb_ee_map_type *) hw->eeprom;
+
+	if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
+		return (ee_map->compatibility);
+
+	return (0);
+}
+
+/******************************************************************************
+ * return the Printed Board Assembly number from EEPROM
+ *
+ * hw - Struct containing variables accessed by shared code 
+ *
+ * Returns: 
+ *          PBA number if EEPROM contents are valid, 0 otherwise
+ ******************************************************************************/
+u32
+ixgb_get_ee_pba_number(struct ixgb_hw * hw)
+{
+	if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
+		return (le16_to_cpu(hw->eeprom[EEPROM_PBA_1_2_REG])
+			| (le16_to_cpu(hw->eeprom[EEPROM_PBA_3_4_REG]) << 16));
+
+	return (0);
+}
+
+/******************************************************************************
+ * return the Initialization Control Word 1 from EEPROM
+ *
+ * hw - Struct containing variables accessed by shared code
+ *
+ * Returns:
+ *          Initialization Control Word 1 if EEPROM contents are valid, 0 otherwise
+ ******************************************************************************/
+u16
+ixgb_get_ee_init_ctrl_reg_1(struct ixgb_hw * hw)
+{
+	struct ixgb_ee_map_type *ee_map =
+	    (struct ixgb_ee_map_type *) hw->eeprom;
+
+	if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
+		return (ee_map->init_ctrl_reg_1);
+
+	return (0);
+}
+
+/******************************************************************************
+ * return the Initialization Control Word 2 from EEPROM
+ *
+ * hw - Struct containing variables accessed by shared code 
+ *
+ * Returns: 
+ *          Initialization Control Word 2 if EEPROM contents are valid, 0 otherwise
+ ******************************************************************************/
+u16
+ixgb_get_ee_init_ctrl_reg_2(struct ixgb_hw * hw)
+{
+	struct ixgb_ee_map_type *ee_map =
+	    (struct ixgb_ee_map_type *) hw->eeprom;
+
+	if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
+		return (ee_map->init_ctrl_reg_2);
+
+	return (0);
+}
+
+/******************************************************************************
+ * return the Subsystem Id from EEPROM
+ *
+ * hw - Struct containing variables accessed by shared code 
+ *
+ * Returns: 
+ *          Subsystem Id if EEPROM contents are valid, 0 otherwise
+ ******************************************************************************/
+u16
+ixgb_get_ee_subsystem_id(struct ixgb_hw * hw)
+{
+	struct ixgb_ee_map_type *ee_map =
+	    (struct ixgb_ee_map_type *) hw->eeprom;
+
+	if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
+		return (ee_map->subsystem_id);
+
+	return (0);
+}
+
+/******************************************************************************
+ * return the Sub Vendor Id from EEPROM
+ *
+ * hw - Struct containing variables accessed by shared code 
+ *
+ * Returns: 
+ *          Sub Vendor Id if EEPROM contents are valid, 0 otherwise
+ ******************************************************************************/
+u16
+ixgb_get_ee_subvendor_id(struct ixgb_hw * hw)
+{
+	struct ixgb_ee_map_type *ee_map =
+	    (struct ixgb_ee_map_type *) hw->eeprom;
+
+	if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
+		return (ee_map->subvendor_id);
+
+	return (0);
+}
+
+/******************************************************************************
+ * return the Device Id from EEPROM
+ *
+ * hw - Struct containing variables accessed by shared code 
+ *
+ * Returns: 
+ *          Device Id if EEPROM contents are valid, 0 otherwise
+ ******************************************************************************/
+u16
+ixgb_get_ee_device_id(struct ixgb_hw * hw)
+{
+	struct ixgb_ee_map_type *ee_map =
+	    (struct ixgb_ee_map_type *) hw->eeprom;
+
+	if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
+		return (ee_map->device_id);
+
+	return (0);
+}
+
+/******************************************************************************
+ * return the Vendor Id from EEPROM
+ *
+ * hw - Struct containing variables accessed by shared code 
+ *
+ * Returns: 
+ *          Device Id if EEPROM contents are valid, 0 otherwise
+ ******************************************************************************/
+u16
+ixgb_get_ee_vendor_id(struct ixgb_hw * hw)
+{
+	struct ixgb_ee_map_type *ee_map =
+	    (struct ixgb_ee_map_type *) hw->eeprom;
+
+	if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
+		return (ee_map->vendor_id);
+
+	return (0);
+}
+
+/******************************************************************************
+ * return the Software Defined Pins Register from EEPROM
+ *
+ * hw - Struct containing variables accessed by shared code 
+ *
+ * Returns: 
+ *          SDP Register if EEPROM contents are valid, 0 otherwise
+ ******************************************************************************/
+u16
+ixgb_get_ee_swdpins_reg(struct ixgb_hw * hw)
+{
+	struct ixgb_ee_map_type *ee_map =
+	    (struct ixgb_ee_map_type *) hw->eeprom;
+
+	if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
+		return (ee_map->swdpins_reg);
+
+	return (0);
+}
+
+/******************************************************************************
+ * return the D3 Power Management Bits from EEPROM
+ *
+ * hw - Struct containing variables accessed by shared code 
+ *
+ * Returns: 
+ *          D3 Power Management Bits if EEPROM contents are valid, 0 otherwise
+ ******************************************************************************/
+u8
+ixgb_get_ee_d3_power(struct ixgb_hw * hw)
+{
+	struct ixgb_ee_map_type *ee_map =
+	    (struct ixgb_ee_map_type *) hw->eeprom;
+
+	if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
+		return (ee_map->d3_power);
+
+	return (0);
+}
+
+/******************************************************************************
+ * return the D0 Power Management Bits from EEPROM
+ *
+ * hw - Struct containing variables accessed by shared code 
+ *
+ * Returns: 
+ *          D0 Power Management Bits if EEPROM contents are valid, 0 otherwise
+ ******************************************************************************/
+u8
+ixgb_get_ee_d0_power(struct ixgb_hw * hw)
+{
+	struct ixgb_ee_map_type *ee_map =
+	    (struct ixgb_ee_map_type *) hw->eeprom;
+
+	if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
+		return (ee_map->d0_power);
+
+	return (0);
+}
diff -Nru a/drivers/net/ixgb/ixgb_ee.h b/drivers/net/ixgb/ixgb_ee.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/net/ixgb/ixgb_ee.h	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,104 @@
+/*******************************************************************************
+
+  
+  Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
+  
+  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; either version 2 of the License, or (at your option) 
+  any later version.
+  
+  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.
+  
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59 
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+  
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+  
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+*******************************************************************************/
+
+#ifndef _IXGB_EE_H_
+#define _IXGB_EE_H_
+
+#define IXGB_EEPROM_SIZE    64	/* Size in words */
+
+#define IXGB_ETH_LENGTH_OF_ADDRESS   6
+
+/* EEPROM Commands */
+#define EEPROM_READ_OPCODE  0x6		/* EERPOM read opcode */
+#define EEPROM_WRITE_OPCODE 0x5		/* EERPOM write opcode */
+#define EEPROM_ERASE_OPCODE 0x7		/* EERPOM erase opcode */
+#define EEPROM_EWEN_OPCODE  0x13	/* EERPOM erase/write enable */
+#define EEPROM_EWDS_OPCODE  0x10	/* EERPOM erast/write disable */
+
+/* EEPROM MAP (Word Offsets) */
+#define EEPROM_IA_1_2_REG        0x0000
+#define EEPROM_IA_3_4_REG        0x0001
+#define EEPROM_IA_5_6_REG        0x0002
+#define EEPROM_COMPATIBILITY_REG 0x0003
+#define EEPROM_PBA_1_2_REG       0x0008
+#define EEPROM_PBA_3_4_REG       0x0009
+#define EEPROM_INIT_CONTROL1_REG 0x000A
+#define EEPROM_SUBSYS_ID_REG     0x000B
+#define EEPROM_SUBVEND_ID_REG    0x000C
+#define EEPROM_DEVICE_ID_REG     0x000D
+#define EEPROM_VENDOR_ID_REG     0x000E
+#define EEPROM_INIT_CONTROL2_REG 0x000F
+#define EEPROM_SWDPINS_REG       0x0020
+#define EEPROM_CIRCUIT_CTRL_REG  0x0021
+#define EEPROM_D0_D3_POWER_REG   0x0022
+#define EEPROM_FLASH_VERSION     0x0032
+#define EEPROM_CHECKSUM_REG      0x003F
+
+/* Mask bits for fields in Word 0x0a of the EEPROM */
+
+#define EEPROM_ICW1_SIGNATURE_MASK  0xC000
+#define EEPROM_ICW1_SIGNATURE_VALID 0x4000
+
+/* For checksumming, the sum of all words in the EEPROM should equal 0xBABA. */
+#define EEPROM_SUM 0xBABA
+
+/* EEPROM Map Sizes (Byte Counts) */
+#define PBA_SIZE 4
+
+/* EEPROM Map defines (WORD OFFSETS)*/
+
+/* EEPROM structure */
+struct ixgb_ee_map_type {
+	u8 mac_addr[IXGB_ETH_LENGTH_OF_ADDRESS];
+	u16 compatibility;
+	u16 reserved1[4];
+	u32 pba_number;
+	u16 init_ctrl_reg_1;
+	u16 subsystem_id;
+	u16 subvendor_id;
+	u16 device_id;
+	u16 vendor_id;
+	u16 init_ctrl_reg_2;
+	u16 oem_reserved[16];
+	u16 swdpins_reg;
+	u16 circuit_ctrl_reg;
+	u8 d3_power;
+	u8 d0_power;
+	u16 reserved2[28];
+	u16 checksum;
+};
+
+/* EEPROM Functions */
+u16 ixgb_read_eeprom(struct ixgb_hw *hw, u16 reg);
+
+boolean_t ixgb_validate_eeprom_checksum(struct ixgb_hw *hw);
+
+void ixgb_update_eeprom_checksum(struct ixgb_hw *hw);
+
+void ixgb_write_eeprom(struct ixgb_hw *hw, u16 reg, u16 data);
+
+#endif				/* IXGB_EE_H */
diff -Nru a/drivers/net/ixgb/ixgb_ethtool.c b/drivers/net/ixgb/ixgb_ethtool.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/net/ixgb/ixgb_ethtool.c	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,555 @@
+/*******************************************************************************
+
+  
+  Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
+  
+  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; either version 2 of the License, or (at your option) 
+  any later version.
+  
+  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.
+  
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59 
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+  
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+  
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+*******************************************************************************/
+
+/* ethtool support for ixgb */
+
+#include "ixgb.h"
+
+#include <asm/uaccess.h>
+
+extern char ixgb_driver_name[];
+extern char ixgb_driver_version[];
+
+extern int ixgb_up(struct ixgb_adapter *adapter);
+extern int ixgb_down(struct ixgb_adapter *adapter);
+
+/**
+ * ixgb_ethtool_ioctl - Ethtool Ioctl Support
+ * @netdev: net device structure
+ * @ifr: interface request structure
+ **/
+
+static inline int
+ixgb_eeprom_size(struct ixgb_hw *hw)
+{
+	/* return size in bytes */
+	return (IXGB_EEPROM_SIZE << 1);
+}
+
+#define SUPPORTED_10000baseT_Full (1 << 11)
+#define SPEED_10000 10000
+
+static void
+ixgb_ethtool_gset(struct ixgb_adapter *adapter, struct ethtool_cmd *ecmd)
+{
+	ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
+	ecmd->advertising = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
+	ecmd->port = PORT_FIBRE;
+	ecmd->transceiver = XCVR_EXTERNAL;
+
+	if (netif_carrier_ok(adapter->netdev)) {
+		ecmd->speed = 10000;
+		ecmd->duplex = DUPLEX_FULL;
+	} else {
+		ecmd->speed = -1;
+		ecmd->duplex = -1;
+	}
+
+	ecmd->autoneg = AUTONEG_DISABLE;
+}
+
+static int
+ixgb_ethtool_sset(struct ixgb_adapter *adapter, struct ethtool_cmd *ecmd)
+{
+	if (ecmd->autoneg == AUTONEG_ENABLE ||
+	    ecmd->speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL)
+		return -EINVAL;
+	else {
+		ixgb_down(adapter);
+		ixgb_up(adapter);
+	}
+
+	return 0;
+}
+
+#if 0
+static int
+ixgb_ethtool_promiscuous(struct ixgb_adapter *adapter,
+			 struct ethtool_pmode *pmode)
+{
+	u32 rctl = IXGB_READ_REG(&adapter->hw, RCTL);
+
+	pmode->rctl_old = rctl;
+	if (pmode->upe)
+		rctl |= IXGB_RCTL_UPE;
+	else
+		rctl &= ~IXGB_RCTL_UPE;
+
+	if (pmode->mpe)
+		rctl |= IXGB_RCTL_MPE;
+	else
+		rctl &= ~IXGB_RCTL_MPE;
+
+	IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
+
+	pmode->rctl_new = IXGB_READ_REG(&adapter->hw, RCTL);
+
+	return 0;
+}
+#endif
+
+#define IXGB_REG_DUMP_LEN  136*sizeof(u32)
+static void
+ixgb_ethtool_gdrvinfo(struct ixgb_adapter *adapter,
+		      struct ethtool_drvinfo *drvinfo)
+{
+	strncpy(drvinfo->driver, ixgb_driver_name, 32);
+	strncpy(drvinfo->version, ixgb_driver_version, 32);
+	strncpy(drvinfo->fw_version, "", 32);
+	strncpy(drvinfo->bus_info, adapter->pdev->slot_name, 32);
+#ifdef ETHTOOL_GREGS
+	drvinfo->regdump_len = IXGB_REG_DUMP_LEN;
+#endif				/* ETHTOOL_GREGS */
+	drvinfo->eedump_len = ixgb_eeprom_size(&adapter->hw);
+}
+
+#ifdef  ETHTOOL_GREGS
+#define IXGB_GET_STAT(_A_, _R_) _A_->stats._R_
+static void
+ixgb_ethtool_gregs(struct ixgb_adapter *adapter,
+		   struct ethtool_regs *regs, u8 * regs_buff)
+{
+	struct ixgb_hw *hw = &adapter->hw;
+	u32 *reg = (u32 *) regs_buff;
+	u32 *reg_start = reg;
+	u8 i;
+
+	regs->version =
+	    (adapter->hw.device_id << 16) | adapter->hw.subsystem_id;
+
+	/* General Registers */
+	*reg++ = IXGB_READ_REG(hw, CTRL0);	/*   0 */
+	*reg++ = IXGB_READ_REG(hw, CTRL1);	/*   1 */
+	*reg++ = IXGB_READ_REG(hw, STATUS);	/*   2 */
+	*reg++ = IXGB_READ_REG(hw, EECD);	/*   3 */
+	*reg++ = IXGB_READ_REG(hw, MFS);	/*   4 */
+
+	/* Interrupt */
+	*reg++ = IXGB_READ_REG(hw, ICR);	/*   5 */
+	*reg++ = IXGB_READ_REG(hw, ICS);	/*   6 */
+	*reg++ = IXGB_READ_REG(hw, IMS);	/*   7 */
+	*reg++ = IXGB_READ_REG(hw, IMC);	/*   8 */
+
+	/* Receive */
+	*reg++ = IXGB_READ_REG(hw, RCTL);	/*   9 */
+	*reg++ = IXGB_READ_REG(hw, FCRTL);	/*  10 */
+	*reg++ = IXGB_READ_REG(hw, FCRTH);	/*  11 */
+	*reg++ = IXGB_READ_REG(hw, RDBAL);	/*  12 */
+	*reg++ = IXGB_READ_REG(hw, RDBAH);	/*  13 */
+	*reg++ = IXGB_READ_REG(hw, RDLEN);	/*  14 */
+	*reg++ = IXGB_READ_REG(hw, RDH);	/*  15 */
+	*reg++ = IXGB_READ_REG(hw, RDT);	/*  16 */
+	*reg++ = IXGB_READ_REG(hw, RDTR);	/*  17 */
+	*reg++ = IXGB_READ_REG(hw, RXDCTL);	/*  18 */
+	*reg++ = IXGB_READ_REG(hw, RAIDC);	/*  19 */
+	*reg++ = IXGB_READ_REG(hw, RXCSUM);	/*  20 */
+
+	for (i = 0; i < IXGB_RAR_ENTRIES; i++) {
+		*reg++ = IXGB_READ_REG_ARRAY(hw, RAL, (i << 1));	/*21,...,51 */
+		*reg++ = IXGB_READ_REG_ARRAY(hw, RAH, (i << 1));	/*22,...,52 */
+	}
+
+	/* Transmit */
+	*reg++ = IXGB_READ_REG(hw, TCTL);	/*  53 */
+	*reg++ = IXGB_READ_REG(hw, TDBAL);	/*  54 */
+	*reg++ = IXGB_READ_REG(hw, TDBAH);	/*  55 */
+	*reg++ = IXGB_READ_REG(hw, TDLEN);	/*  56 */
+	*reg++ = IXGB_READ_REG(hw, TDH);	/*  57 */
+	*reg++ = IXGB_READ_REG(hw, TDT);	/*  58 */
+	*reg++ = IXGB_READ_REG(hw, TIDV);	/*  59 */
+	*reg++ = IXGB_READ_REG(hw, TXDCTL);	/*  60 */
+	*reg++ = IXGB_READ_REG(hw, TSPMT);	/*  61 */
+	*reg++ = IXGB_READ_REG(hw, PAP);	/*  62 */
+
+	/* Physical */
+	*reg++ = IXGB_READ_REG(hw, PCSC1);	/*  63 */
+	*reg++ = IXGB_READ_REG(hw, PCSC2);	/*  64 */
+	*reg++ = IXGB_READ_REG(hw, PCSS1);	/*  65 */
+	*reg++ = IXGB_READ_REG(hw, PCSS2);	/*  66 */
+	*reg++ = IXGB_READ_REG(hw, XPCSS);	/*  67 */
+	*reg++ = IXGB_READ_REG(hw, UCCR);	/*  68 */
+	*reg++ = IXGB_READ_REG(hw, XPCSTC);	/*  69 */
+	*reg++ = IXGB_READ_REG(hw, MACA);	/*  70 */
+	*reg++ = IXGB_READ_REG(hw, APAE);	/*  71 */
+	*reg++ = IXGB_READ_REG(hw, ARD);	/*  72 */
+	*reg++ = IXGB_READ_REG(hw, AIS);	/*  73 */
+	*reg++ = IXGB_READ_REG(hw, MSCA);	/*  74 */
+	*reg++ = IXGB_READ_REG(hw, MSRWD);	/*  75 */
+
+#if 0
+	/* Wake-up */
+	reg[IXGB_WUFC] = IXGB_READ_REG(hw, WUFC);
+	reg[IXGB_WUS] = IXGB_READ_REG(hw, WUS);
+	reg[IXGB_FFLT] = IXGB_READ_REG(hw, FFLT);
+	reg[IXGB_FFMT] = IXGB_READ_REG(hw, FFMT);
+	reg[IXGB_FTVT] = IXGB_READ_REG(hw, FTVT);
+#endif
+
+	/* Statistics */
+	*reg++ = IXGB_GET_STAT(adapter, tprl);	/*  76 */
+	*reg++ = IXGB_GET_STAT(adapter, tprh);	/*  77 */
+	*reg++ = IXGB_GET_STAT(adapter, gprcl);	/*  78 */
+	*reg++ = IXGB_GET_STAT(adapter, gprch);	/*  79 */
+	*reg++ = IXGB_GET_STAT(adapter, bprcl);	/*  80 */
+	*reg++ = IXGB_GET_STAT(adapter, bprch);	/*  81 */
+	*reg++ = IXGB_GET_STAT(adapter, mprcl);	/*  82 */
+	*reg++ = IXGB_GET_STAT(adapter, mprch);	/*  83 */
+	*reg++ = IXGB_GET_STAT(adapter, uprcl);	/*  84 */
+	*reg++ = IXGB_GET_STAT(adapter, uprch);	/*  85 */
+	*reg++ = IXGB_GET_STAT(adapter, vprcl);	/*  86 */
+	*reg++ = IXGB_GET_STAT(adapter, vprch);	/*  87 */
+	*reg++ = IXGB_GET_STAT(adapter, jprcl);	/*  88 */
+	*reg++ = IXGB_GET_STAT(adapter, jprch);	/*  89 */
+	*reg++ = IXGB_GET_STAT(adapter, gorcl);	/*  90 */
+	*reg++ = IXGB_GET_STAT(adapter, gorch);	/*  91 */
+	*reg++ = IXGB_GET_STAT(adapter, torl);	/*  92 */
+	*reg++ = IXGB_GET_STAT(adapter, torh);	/*  93 */
+	*reg++ = IXGB_GET_STAT(adapter, rnbc);	/*  94 */
+	*reg++ = IXGB_GET_STAT(adapter, ruc);	/*  95 */
+	*reg++ = IXGB_GET_STAT(adapter, roc);	/*  96 */
+	*reg++ = IXGB_GET_STAT(adapter, rlec);	/*  97 */
+	*reg++ = IXGB_GET_STAT(adapter, crcerrs);	/*  98 */
+	*reg++ = IXGB_GET_STAT(adapter, icbc);	/*  99 */
+	*reg++ = IXGB_GET_STAT(adapter, ecbc);	/* 100 */
+	*reg++ = IXGB_GET_STAT(adapter, mpc);	/* 101 */
+	*reg++ = IXGB_GET_STAT(adapter, tptl);	/* 102 */
+	*reg++ = IXGB_GET_STAT(adapter, tpth);	/* 103 */
+	*reg++ = IXGB_GET_STAT(adapter, gptcl);	/* 104 */
+	*reg++ = IXGB_GET_STAT(adapter, gptch);	/* 105 */
+	*reg++ = IXGB_GET_STAT(adapter, bptcl);	/* 106 */
+	*reg++ = IXGB_GET_STAT(adapter, bptch);	/* 107 */
+	*reg++ = IXGB_GET_STAT(adapter, mptcl);	/* 108 */
+	*reg++ = IXGB_GET_STAT(adapter, mptch);	/* 109 */
+	*reg++ = IXGB_GET_STAT(adapter, uptcl);	/* 110 */
+	*reg++ = IXGB_GET_STAT(adapter, uptch);	/* 111 */
+	*reg++ = IXGB_GET_STAT(adapter, vptcl);	/* 112 */
+	*reg++ = IXGB_GET_STAT(adapter, vptch);	/* 113 */
+	*reg++ = IXGB_GET_STAT(adapter, jptcl);	/* 114 */
+	*reg++ = IXGB_GET_STAT(adapter, jptch);	/* 115 */
+	*reg++ = IXGB_GET_STAT(adapter, gotcl);	/* 116 */
+	*reg++ = IXGB_GET_STAT(adapter, gotch);	/* 117 */
+	*reg++ = IXGB_GET_STAT(adapter, totl);	/* 118 */
+	*reg++ = IXGB_GET_STAT(adapter, toth);	/* 119 */
+	*reg++ = IXGB_GET_STAT(adapter, dc);	/* 120 */
+	*reg++ = IXGB_GET_STAT(adapter, plt64c);	/* 121 */
+	*reg++ = IXGB_GET_STAT(adapter, tsctc);	/* 122 */
+	*reg++ = IXGB_GET_STAT(adapter, tsctfc);	/* 123 */
+	*reg++ = IXGB_GET_STAT(adapter, ibic);	/* 124 */
+	*reg++ = IXGB_GET_STAT(adapter, rfc);	/* 125 */
+	*reg++ = IXGB_GET_STAT(adapter, lfc);	/* 126 */
+	*reg++ = IXGB_GET_STAT(adapter, pfrc);	/* 127 */
+	*reg++ = IXGB_GET_STAT(adapter, pftc);	/* 128 */
+	*reg++ = IXGB_GET_STAT(adapter, mcfrc);	/* 129 */
+	*reg++ = IXGB_GET_STAT(adapter, mcftc);	/* 130 */
+	*reg++ = IXGB_GET_STAT(adapter, xonrxc);	/* 131 */
+	*reg++ = IXGB_GET_STAT(adapter, xontxc);	/* 132 */
+	*reg++ = IXGB_GET_STAT(adapter, xoffrxc);	/* 133 */
+	*reg++ = IXGB_GET_STAT(adapter, xofftxc);	/* 134 */
+	*reg++ = IXGB_GET_STAT(adapter, rjc);	/* 135 */
+
+#if 0
+#endif
+	regs->len = (reg - reg_start) * sizeof (u32);
+}
+#endif				/* ETHTOOL_GREGS */
+
+static int
+ixgb_ethtool_geeprom(struct ixgb_adapter *adapter,
+		     struct ethtool_eeprom *eeprom, u16 * eeprom_buff)
+{
+	struct ixgb_hw *hw = &adapter->hw;
+	int i, max_len, first_word, last_word;
+	IXGB_DBG("ixgb_ethtool_geeprom\n");
+
+	if (eeprom->len == 0)
+		return -EINVAL;
+
+	eeprom->magic = hw->vendor_id | (hw->device_id << 16);
+
+	max_len = ixgb_eeprom_size(hw);
+
+	/* use our function to read the eeprom and update our cache */
+	ixgb_get_eeprom_data(hw);
+
+	if (eeprom->offset > eeprom->offset + eeprom->len)
+		return -EINVAL;
+
+	if ((eeprom->offset + eeprom->len) > max_len)
+		eeprom->len = (max_len - eeprom->offset);
+
+	first_word = eeprom->offset >> 1;
+	last_word = (eeprom->offset + eeprom->len - 1) >> 1;
+
+	for (i = 0; i <= (last_word - first_word); i++) {
+		eeprom_buff[i] = hw->eeprom[first_word + i];
+	}
+
+	return 0;
+}
+static int
+ixgb_ethtool_seeprom(struct ixgb_adapter *adapter,
+		     struct ethtool_eeprom *eeprom, void *user_data)
+{
+	struct ixgb_hw *hw = &adapter->hw;
+	u16 eeprom_buff[256];
+	int i, max_len, first_word, last_word;
+	void *ptr;
+
+	if (eeprom->magic != (hw->vendor_id | (hw->device_id << 16)))
+		return -EFAULT;
+
+	if (eeprom->len == 0)
+		return -EINVAL;
+
+	max_len = ixgb_eeprom_size(hw);
+
+	if (eeprom->offset > eeprom->offset + eeprom->len)
+		return -EINVAL;
+
+	if ((eeprom->offset + eeprom->len) > max_len)
+		eeprom->len = (max_len - eeprom->offset);
+
+	first_word = eeprom->offset >> 1;
+	last_word = (eeprom->offset + eeprom->len - 1) >> 1;
+	ptr = (void *) eeprom_buff;
+
+	if (eeprom->offset & 1) {
+		/* need read/modify/write of first changed EEPROM word */
+		/* only the second byte of the word is being modified */
+		eeprom_buff[0] = ixgb_read_eeprom(hw, first_word);
+		ptr++;
+	}
+	if ((eeprom->offset + eeprom->len) & 1) {
+		/* need read/modify/write of last changed EEPROM word */
+		/* only the first byte of the word is being modified */
+		eeprom_buff[last_word - first_word]
+		    = ixgb_read_eeprom(hw, last_word);
+	}
+	if (copy_from_user(ptr, user_data, eeprom->len))
+		return -EFAULT;
+
+	for (i = 0; i <= (last_word - first_word); i++)
+		ixgb_write_eeprom(hw, first_word + i, eeprom_buff[i]);
+
+	/* Update the checksum over the first part of the EEPROM if needed */
+	if (first_word <= EEPROM_CHECKSUM_REG)
+		ixgb_update_eeprom_checksum(hw);
+
+	return 0;
+}
+
+#ifdef  ETHTOOL_PHYS_ID
+
+/* toggle LED 4 times per second = 2 "blinks" per second */
+#define IXGB_ID_INTERVAL    (HZ/4)
+
+/* bit defines for adapter->led_status */
+#define IXGB_LED_ON     0
+
+static void
+ixgb_led_blink_callback(unsigned long data)
+{
+	struct ixgb_adapter *adapter = (struct ixgb_adapter *) data;
+
+	if (test_and_change_bit(IXGB_LED_ON, &adapter->led_status))
+		ixgb_led_off(&adapter->hw);
+	else
+		ixgb_led_on(&adapter->hw);
+
+	mod_timer(&adapter->blink_timer, jiffies + IXGB_ID_INTERVAL);
+}
+
+static int
+ixgb_ethtool_led_blink(struct ixgb_adapter *adapter, struct ethtool_value *id)
+{
+	if (!adapter->blink_timer.function) {
+		init_timer(&adapter->blink_timer);
+		adapter->blink_timer.function = ixgb_led_blink_callback;
+		adapter->blink_timer.data = (unsigned long) adapter;
+	}
+
+	mod_timer(&adapter->blink_timer, jiffies);
+
+	set_current_state(TASK_INTERRUPTIBLE);
+	if (id->data)
+		schedule_timeout(id->data * HZ);
+	else
+		schedule_timeout(MAX_SCHEDULE_TIMEOUT);
+
+	del_timer_sync(&adapter->blink_timer);
+	ixgb_led_off(&adapter->hw);
+	clear_bit(IXGB_LED_ON, &adapter->led_status);
+
+	return 0;
+}
+#endif				/* ETHTOOL_PHYS_ID */
+
+int
+ixgb_ethtool_ioctl(struct net_device *netdev, struct ifreq *ifr)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+	void *addr = ifr->ifr_data;
+	u32 cmd;
+
+	if (get_user(cmd, (u32 *) addr))
+		return -EFAULT;
+
+	switch (cmd) {
+#if 0
+	case ETHTOOL_PROMISCUOUS:{
+			struct ethtool_pmode pmode;
+
+			if (copy_from_user(&pmode, addr, sizeof (pmode)))
+				return -EFAULT;
+
+			ixgb_ethtool_promiscuous(adapter, &pmode);
+
+			if (copy_to_user(addr, &pmode, sizeof (pmode)))
+				return -EFAULT;
+
+			return 0;
+		}
+	case ETHTOOL_DOWN_UP:
+		ixgb_down(netdev->priv);
+		ixgb_up(netdev->priv);
+		return 0;
+#endif
+	case ETHTOOL_GSET:{
+			struct ethtool_cmd ecmd = { ETHTOOL_GSET };
+
+			ixgb_ethtool_gset(adapter, &ecmd);
+			if (copy_to_user(addr, &ecmd, sizeof (ecmd)))
+				return -EFAULT;
+			return 0;
+		}
+	case ETHTOOL_SSET:{
+			struct ethtool_cmd ecmd;
+
+			if (!capable(CAP_NET_ADMIN))
+				return -EPERM;
+			if (copy_from_user(&ecmd, addr, sizeof (ecmd)))
+				return -EFAULT;
+			return ixgb_ethtool_sset(adapter, &ecmd);
+		}
+	case ETHTOOL_GDRVINFO:
+		{
+			struct ethtool_drvinfo drvinfo = { ETHTOOL_GDRVINFO };
+
+			ixgb_ethtool_gdrvinfo(adapter, &drvinfo);
+			if (copy_to_user(addr, &drvinfo, sizeof (drvinfo)))
+				return -EFAULT;
+			return 0;
+		}
+#if defined(ETHTOOL_GREGS) && defined(ETHTOOL_GEEPROM)
+	case ETHTOOL_GREGS:{
+			struct ethtool_regs regs = { ETHTOOL_GREGS };
+			u8 regs_buff[IXGB_REG_DUMP_LEN];
+
+			ixgb_ethtool_gregs(adapter, &regs, regs_buff);
+
+			if (copy_to_user(addr, &regs, sizeof (regs)))
+				return -EFAULT;
+
+			addr += offsetof(struct ethtool_regs, data);
+
+			if (copy_to_user(addr, regs_buff, regs.len))
+				return -EFAULT;
+			return 0;
+		}
+#endif				/* ETHTOOL_GREGS */
+	case ETHTOOL_NWAY_RST:{
+			IXGB_DBG("ETHTOOL_NWAY_RST\n");
+			if (!capable(CAP_NET_ADMIN))
+				return -EPERM;
+
+			ixgb_down(adapter);
+			ixgb_up(adapter);
+
+			return 0;
+		}
+#ifdef  ETHTOOL_PHYS_ID
+	case ETHTOOL_PHYS_ID:{
+			struct ethtool_value id;
+
+			IXGB_DBG("ETHTOOL_PHYS_ID\n");
+			if (copy_from_user(&id, addr, sizeof (id)))
+				return -EFAULT;
+			return ixgb_ethtool_led_blink(adapter, &id);
+		}
+#endif				/* ETHTOOL_PHYS_ID */
+	case ETHTOOL_GLINK:{
+			struct ethtool_value link = { ETHTOOL_GLINK };
+
+			IXGB_DBG("ETHTOOL_GLINK\n");
+			link.data = netif_carrier_ok(netdev);
+			if (copy_to_user(addr, &link, sizeof (link)))
+				return -EFAULT;
+			return 0;
+		}
+
+	case ETHTOOL_GEEPROM:{
+			struct ethtool_eeprom eeprom = { ETHTOOL_GEEPROM };
+			u16 eeprom_buff[IXGB_EEPROM_SIZE];
+			void *ptr;
+			int err;
+
+			IXGB_DBG("ETHTOOL_GEEPROM\n");
+			if (copy_from_user(&eeprom, addr, sizeof (eeprom)))
+				return -EFAULT;
+
+			if ((err =
+			     ixgb_ethtool_geeprom(adapter, &eeprom,
+						  eeprom_buff)) < 0)
+				return err;
+
+			if (copy_to_user(addr, &eeprom, sizeof (eeprom)))
+				return -EFAULT;
+
+			addr += offsetof(struct ethtool_eeprom, data);
+
+			ptr = ((void *) eeprom_buff) + (eeprom.offset & 1);
+			if (copy_to_user(addr, ptr, eeprom.len))
+				return -EFAULT;
+			return 0;
+		}
+	case ETHTOOL_SEEPROM:{
+			struct ethtool_eeprom eeprom;
+
+			IXGB_DBG("ETHTOOL_SEEPROM\n");
+			if (!capable(CAP_NET_ADMIN))
+				return -EPERM;
+
+			if (copy_from_user(&eeprom, addr, sizeof (eeprom)))
+				return -EFAULT;
+
+			addr += offsetof(struct ethtool_eeprom, data);
+			return ixgb_ethtool_seeprom(adapter, &eeprom, addr);
+		}
+	default:
+		return -EOPNOTSUPP;
+	}
+}
diff -Nru a/drivers/net/ixgb/ixgb_hw.c b/drivers/net/ixgb/ixgb_hw.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/net/ixgb/ixgb_hw.c	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,1055 @@
+/*******************************************************************************
+
+  
+  Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
+  
+  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; either version 2 of the License, or (at your option) 
+  any later version.
+  
+  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.
+  
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59 
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+  
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+  
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+*******************************************************************************/
+
+/* ixgb_hw.c
+ * Shared functions for accessing and configuring the adapter
+ */
+
+#include "ixgb_hw.h"
+#include "ixgb_ids.h"
+
+/*  Local function prototypes */
+
+static u32 ixgb_hash_mc_addr(struct ixgb_hw *hw, u8 * mc_addr);
+
+static void ixgb_mta_set(struct ixgb_hw *hw, u32 hash_value);
+
+static void ixgb_get_bus_info(struct ixgb_hw *hw);
+
+boolean_t mac_addr_valid(u8 * mac_addr);
+
+static boolean_t ixgb_link_reset(struct ixgb_hw *hw);
+
+static void ixgb_optics_reset(struct ixgb_hw *hw);
+
+u32 ixgb_mac_reset(struct ixgb_hw *hw);
+
+u32
+ixgb_mac_reset(struct ixgb_hw *hw)
+{
+	u32 ctrl_reg;
+
+	/* Setup up hardware to known state with RESET.  */
+	ctrl_reg = IXGB_CTRL0_RST | IXGB_CTRL0_SDP3_DIR |	/* All pins are Output=1 */
+	    IXGB_CTRL0_SDP2_DIR | IXGB_CTRL0_SDP1_DIR | IXGB_CTRL0_SDP0_DIR | IXGB_CTRL0_SDP3 |	/* Initial value 1101   */
+	    IXGB_CTRL0_SDP2 | IXGB_CTRL0_SDP0;
+#ifdef HP_ZX1
+	outl(IXGB_CTRL0, hw->io_base);
+	outl(ctrl_reg, hw->io_base + 4);
+#else
+	IXGB_WRITE_REG(hw, CTRL0, ctrl_reg);
+#endif
+
+	/* Delay a few ms just to allow the reset to complete */
+	msec_delay(IXGB_DELAY_AFTER_RESET);
+	ctrl_reg = IXGB_READ_REG(hw, CTRL0);
+#if DBG
+	/* Make sure the self-clearing global reset bit did self clear */
+	ASSERT(!(ctrl_reg & IXGB_CTRL0_RST));
+#endif
+
+	ixgb_optics_reset(hw);
+	return ctrl_reg;
+}
+
+/******************************************************************************
+ * Reset the transmit and receive units; mask and clear all interrupts.
+ *
+ * hw - Struct containing variables accessed by shared code
+ *****************************************************************************/
+boolean_t
+ixgb_adapter_stop(struct ixgb_hw * hw)
+{
+	u32 ctrl_reg;
+	u32 icr_reg;
+
+	DEBUGFUNC("ixgb_adapter_stop");
+
+	/* If we are stopped or resetting exit gracefully and wait to be
+	 * started again before accessing the hardware.
+	 */
+	if (hw->adapter_stopped) {
+		DEBUGOUT("Exiting because the adapter is already stopped!!!\n");
+		return FALSE;
+	}
+
+	/* Set the Adapter Stopped flag so other driver functions stop
+	 * touching the Hardware.
+	 */
+	hw->adapter_stopped = TRUE;
+
+	/* Clear interrupt mask to stop board from generating interrupts */
+	DEBUGOUT("Masking off all interrupts\n");
+	IXGB_WRITE_REG(hw, IMC, 0xFFFFFFFF);
+
+	/* Disable the Transmit and Receive units.  Then delay to allow
+	 * any pending transactions to complete before we hit the MAC with
+	 * the global reset.
+	 */
+	IXGB_WRITE_REG(hw, RCTL, IXGB_READ_REG(hw, RCTL) & ~IXGB_RCTL_RXEN);
+	IXGB_WRITE_REG(hw, TCTL, IXGB_READ_REG(hw, TCTL) & ~IXGB_TCTL_TXEN);
+	msec_delay(IXGB_DELAY_BEFORE_RESET);
+
+	/* Issue a global reset to the MAC.  This will reset the chip's
+	 * transmit, receive, DMA, and link units.  It will not effect
+	 * the current PCI configuration.  The global reset bit is self-
+	 * clearing, and should clear within a microsecond.
+	 */
+	DEBUGOUT("Issuing a global reset to MAC\n");
+
+	ctrl_reg = ixgb_mac_reset(hw);
+
+	/* Clear interrupt mask to stop board from generating interrupts */
+	DEBUGOUT("Masking off all interrupts\n");
+	IXGB_WRITE_REG(hw, IMC, 0xffffffff);
+
+	/* Clear any pending interrupt events. */
+	icr_reg = IXGB_READ_REG(hw, ICR);
+
+	return (ctrl_reg & IXGB_CTRL0_RST);
+}
+
+/******************************************************************************
+ * Performs basic configuration of the adapter.
+ *
+ * hw - Struct containing variables accessed by shared code
+ * 
+ * Resets the controller.  
+ * Reads and validates the EEPROM.
+ * Initializes the receive address registers.
+ * Initializes the multicast table.
+ * Clears all on-chip counters. 
+ * Calls routine to setup flow control settings. 
+ * Leaves the transmit and receive units disabled and uninitialized.
+ * 
+ * Returns:
+ *      TRUE if successful, 
+ *      FALSE if unrecoverable problems were encountered.
+ *****************************************************************************/
+boolean_t
+ixgb_init_hw(struct ixgb_hw * hw)
+{
+	u32 i;
+	u32 ctrl_reg;
+	boolean_t status;
+
+	DEBUGFUNC("ixgb_init_hw");
+
+	/* Issue a global reset to the MAC.  This will reset the chip's
+	 * transmit, receive, DMA, and link units.  It will not effect
+	 * the current PCI configuration.  The global reset bit is self-
+	 * clearing, and should clear within a microsecond.
+	 */
+	DEBUGOUT("Issuing a global reset to MAC\n");
+
+	ctrl_reg = ixgb_mac_reset(hw);
+
+	DEBUGOUT("Issuing an EE reset to MAC\n");
+#ifdef HP_ZX1
+	outl(IXGB_CTRL1, hw->io_base);
+	outl(IXGB_CTRL1_EE_RST, hw->io_base + 4);
+#else
+	IXGB_WRITE_REG(hw, CTRL1, IXGB_CTRL1_EE_RST);
+#endif
+
+	/* Delay a few ms just to allow the reset to complete */
+	msec_delay(IXGB_DELAY_AFTER_EE_RESET);
+
+	if (ixgb_get_eeprom_data(hw) == FALSE) {
+		return (FALSE);
+	}
+
+	/* Setup the receive addresses. 
+	 * Receive Address Registers (RARs 0 - 15).
+	 */
+	ixgb_init_rx_addrs(hw);
+
+	/* 
+	 * Check that a valid MAC address has been set.
+	 * If it is not valid, we fail hardware init.
+	 */
+	if (!mac_addr_valid(hw->curr_mac_addr)) {
+		DEBUGOUT("MAC address invalid after ixgb_init_rx_addrs\n");
+		return (FALSE);
+	}
+
+	/* tell the routines in this file they can access hardware again */
+	hw->adapter_stopped = FALSE;
+
+	/* Fill in the bus_info structure */
+	ixgb_get_bus_info(hw);
+
+	/* Zero out the Multicast HASH table */
+	DEBUGOUT("Zeroing the MTA\n");
+	for (i = 0; i < IXGB_MC_TBL_SIZE; i++)
+		IXGB_WRITE_REG_ARRAY(hw, MTA, i, 0);
+
+	/* Zero out the VLAN Filter Table Array */
+	ixgb_clear_vfta(hw);
+
+	/* Zero all of the hardware counters */
+	ixgb_clear_hw_cntrs(hw);
+
+	/* Call a subroutine to setup flow control. */
+	status = ixgb_setup_fc(hw);
+
+	/* check-for-link in case lane deskew is locked */
+	ixgb_check_for_link(hw);
+
+	return (status);
+}
+
+/******************************************************************************
+ * Initializes receive address filters.
+ *
+ * hw - Struct containing variables accessed by shared code 
+ *
+ * Places the MAC address in receive address register 0 and clears the rest
+ * of the receive addresss registers. Clears the multicast table. Assumes
+ * the receiver is in reset when the routine is called.
+ *****************************************************************************/
+void
+ixgb_init_rx_addrs(struct ixgb_hw *hw)
+{
+	u32 i;
+
+	DEBUGFUNC("ixgb_init_rx_addrs");
+
+	/* 
+	 * If the current mac address is valid, assume it is a software override
+	 * to the permanent address.
+	 * Otherwise, use the permanent address from the eeprom.
+	 */
+	if (!mac_addr_valid(hw->curr_mac_addr)) {
+
+		/* Get the MAC address from the eeprom for later reference */
+		ixgb_get_ee_mac_addr(hw, hw->curr_mac_addr);
+
+		DEBUGOUT3(" Keeping Permanent MAC Addr =%.2X %.2X %.2X ",
+			  hw->curr_mac_addr[0],
+			  hw->curr_mac_addr[1], hw->curr_mac_addr[2]);
+		DEBUGOUT3("%.2X %.2X %.2X\n",
+			  hw->curr_mac_addr[3],
+			  hw->curr_mac_addr[4], hw->curr_mac_addr[5]);
+	} else {
+
+		/* Setup the receive address. */
+		DEBUGOUT("Overriding MAC Address in RAR[0]\n");
+		DEBUGOUT3(" New MAC Addr =%.2X %.2X %.2X ",
+			  hw->curr_mac_addr[0],
+			  hw->curr_mac_addr[1], hw->curr_mac_addr[2]);
+		DEBUGOUT3("%.2X %.2X %.2X\n",
+			  hw->curr_mac_addr[3],
+			  hw->curr_mac_addr[4], hw->curr_mac_addr[5]);
+
+		ixgb_rar_set(hw, hw->curr_mac_addr, 0);
+	}
+
+	/* Zero out the other 15 receive addresses. */
+	DEBUGOUT("Clearing RAR[1-15]\n");
+	for (i = 1; i < IXGB_RAR_ENTRIES; i++) {
+		IXGB_WRITE_REG_ARRAY(hw, RA, (i << 1), 0);
+		IXGB_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0);
+	}
+
+	return;
+}
+
+/******************************************************************************
+ * Updates the MAC's list of multicast addresses.
+ *
+ * hw - Struct containing variables accessed by shared code
+ * mc_addr_list - the list of new multicast addresses
+ * mc_addr_count - number of addresses
+ * pad - number of bytes between addresses in the list
+ *
+ * The given list replaces any existing list. Clears the last 15 receive
+ * address registers and the multicast table. Uses receive address registers
+ * for the first 15 multicast addresses, and hashes the rest into the 
+ * multicast table.
+ *****************************************************************************/
+void
+ixgb_mc_addr_list_update(struct ixgb_hw *hw,
+			 u8 * mc_addr_list,
+			 u32 mc_addr_count, u32 pad)
+{
+	u32 hash_value;
+	u32 i;
+	u32 rar_used_count = 1;	/* RAR[0] is used for our MAC address */
+
+	DEBUGFUNC("ixgb_mc_addr_list_update");
+
+	/* Set the new number of MC addresses that we are being requested to use. */
+	hw->num_mc_addrs = mc_addr_count;
+
+	/* Clear RAR[1-15] */
+	DEBUGOUT(" Clearing RAR[1-15]\n");
+	for (i = rar_used_count; i < IXGB_RAR_ENTRIES; i++) {
+		IXGB_WRITE_REG_ARRAY(hw, RA, (i << 1), 0);
+		IXGB_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0);
+	}
+
+	/* Clear the MTA */
+	DEBUGOUT(" Clearing MTA\n");
+	for (i = 0; i < IXGB_MC_TBL_SIZE; i++) {
+		IXGB_WRITE_REG_ARRAY(hw, MTA, i, 0);
+	}
+
+	/* Add the new addresses */
+	for (i = 0; i < mc_addr_count; i++) {
+		DEBUGOUT(" Adding the multicast addresses:\n");
+		DEBUGOUT7(" MC Addr #%d =%.2X %.2X %.2X %.2X %.2X %.2X\n", i,
+			  mc_addr_list[i * (IXGB_ETH_LENGTH_OF_ADDRESS + pad)],
+			  mc_addr_list[i * (IXGB_ETH_LENGTH_OF_ADDRESS + pad) +
+				       1],
+			  mc_addr_list[i * (IXGB_ETH_LENGTH_OF_ADDRESS + pad) +
+				       2],
+			  mc_addr_list[i * (IXGB_ETH_LENGTH_OF_ADDRESS + pad) +
+				       3],
+			  mc_addr_list[i * (IXGB_ETH_LENGTH_OF_ADDRESS + pad) +
+				       4],
+			  mc_addr_list[i * (IXGB_ETH_LENGTH_OF_ADDRESS + pad) +
+				       5]);
+
+		/* Place this multicast address in the RAR if there is room, *
+		 * else put it in the MTA            
+		 */
+		if (rar_used_count < IXGB_RAR_ENTRIES) {
+			ixgb_rar_set(hw,
+				     mc_addr_list +
+				     (i * (IXGB_ETH_LENGTH_OF_ADDRESS + pad)),
+				     rar_used_count);
+			DEBUGOUT1("Added a multicast address to RAR[%d]\n", i);
+			rar_used_count++;
+		} else {
+			hash_value = ixgb_hash_mc_addr(hw,
+						       mc_addr_list +
+						       (i *
+							(IXGB_ETH_LENGTH_OF_ADDRESS
+							 + pad)));
+
+			DEBUGOUT1(" Hash value = 0x%03X\n", hash_value);
+
+			ixgb_mta_set(hw, hash_value);
+		}
+	}
+
+	DEBUGOUT("MC Update Complete\n");
+	return;
+}
+
+/******************************************************************************
+ * Hashes an address to determine its location in the multicast table
+ *
+ * hw - Struct containing variables accessed by shared code
+ * mc_addr - the multicast address to hash 
+ *
+ * Returns:
+ *      The hash value
+ *****************************************************************************/
+static u32
+ixgb_hash_mc_addr(struct ixgb_hw *hw, u8 * mc_addr)
+{
+	u32 hash_value = 0;
+
+	DEBUGFUNC("ixgb_hash_mc_addr");
+
+	/* The portion of the address that is used for the hash table is
+	 * determined by the mc_filter_type setting.  
+	 */
+	switch (hw->mc_filter_type) {
+		/* [0] [1] [2] [3] [4] [5]
+		 * 01  AA  00  12  34  56
+		 * LSB                 MSB - According to H/W docs */
+	case 0:
+		/* [47:36] i.e. 0x563 for above example address */
+		hash_value =
+		    ((mc_addr[4] >> 4) | (((u16) mc_addr[5]) << 4));
+		break;
+	case 1:		/* [46:35] i.e. 0xAC6 for above example address */
+		hash_value =
+		    ((mc_addr[4] >> 3) | (((u16) mc_addr[5]) << 5));
+		break;
+	case 2:		/* [45:34] i.e. 0x5D8 for above example address */
+		hash_value =
+		    ((mc_addr[4] >> 2) | (((u16) mc_addr[5]) << 6));
+		break;
+	case 3:		/* [43:32] i.e. 0x634 for above example address */
+		hash_value = ((mc_addr[4]) | (((u16) mc_addr[5]) << 8));
+		break;
+	default:
+		/* Invalid mc_filter_type, what should we do? */
+		DEBUGOUT("MC filter type param set incorrectly\n");
+		ASSERT(0);
+		break;
+	}
+
+	hash_value &= 0xFFF;
+	return (hash_value);
+}
+
+/******************************************************************************
+ * Sets the bit in the multicast table corresponding to the hash value.
+ *
+ * hw - Struct containing variables accessed by shared code
+ * hash_value - Multicast address hash value
+ *****************************************************************************/
+static void
+ixgb_mta_set(struct ixgb_hw *hw, u32 hash_value)
+{
+	u32 hash_bit, hash_reg;
+	u32 mta_reg;
+
+	/* The MTA is a register array of 128 32-bit registers.  
+	 * It is treated like an array of 4096 bits.  We want to set 
+	 * bit BitArray[hash_value]. So we figure out what register
+	 * the bit is in, read it, OR in the new bit, then write
+	 * back the new value.  The register is determined by the 
+	 * upper 7 bits of the hash value and the bit within that 
+	 * register are determined by the lower 5 bits of the value.
+	 */
+	hash_reg = (hash_value >> 5) & 0x7F;
+	hash_bit = hash_value & 0x1F;
+
+	mta_reg = IXGB_READ_REG_ARRAY(hw, MTA, hash_reg);
+
+	mta_reg |= (1 << hash_bit);
+
+	IXGB_WRITE_REG_ARRAY(hw, MTA, hash_reg, mta_reg);
+
+	return;
+}
+
+/******************************************************************************
+ * Puts an ethernet address into a receive address register.
+ *
+ * hw - Struct containing variables accessed by shared code
+ * addr - Address to put into receive address register
+ * index - Receive address register to write
+ *****************************************************************************/
+void
+ixgb_rar_set(struct ixgb_hw *hw, u8 * addr, u32 index)
+{
+	u32 rar_low, rar_high;
+
+	DEBUGFUNC("ixgb_rar_set");
+
+	/* HW expects these in little endian so we reverse the byte order
+	 * from network order (big endian) to little endian              
+	 */
+	rar_low = ((u32) addr[0] |
+		   ((u32) addr[1] << 8) |
+		   ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
+
+	rar_high = ((u32) addr[4] |
+		    ((u32) addr[5] << 8) | IXGB_RAH_AV);
+
+	IXGB_WRITE_REG_ARRAY(hw, RA, (index << 1), rar_low);
+	IXGB_WRITE_REG_ARRAY(hw, RA, ((index << 1) + 1), rar_high);
+	return;
+}
+
+/******************************************************************************
+ * Writes a value to the specified offset in the VLAN filter table.
+ *
+ * hw - Struct containing variables accessed by shared code
+ * offset - Offset in VLAN filer table to write
+ * value - Value to write into VLAN filter table
+ *****************************************************************************/
+void
+ixgb_write_vfta(struct ixgb_hw *hw, u32 offset, u32 value)
+{
+	IXGB_WRITE_REG_ARRAY(hw, VFTA, offset, value);
+	return;
+}
+
+/******************************************************************************
+ * Clears the VLAN filer table
+ *
+ * hw - Struct containing variables accessed by shared code
+ *****************************************************************************/
+void
+ixgb_clear_vfta(struct ixgb_hw *hw)
+{
+	u32 offset;
+
+	for (offset = 0; offset < IXGB_VLAN_FILTER_TBL_SIZE; offset++)
+		IXGB_WRITE_REG_ARRAY(hw, VFTA, offset, 0);
+	return;
+}
+
+/******************************************************************************
+ * Configures the flow control settings based on SW configuration.
+ *
+ * hw - Struct containing variables accessed by shared code
+ *****************************************************************************/
+
+boolean_t
+ixgb_setup_fc(struct ixgb_hw * hw)
+{
+	u32 ctrl_reg;
+	u32 pap_reg = 0;	/* by default, assume no pause time */
+	boolean_t status = TRUE;
+
+	DEBUGFUNC("ixgb_setup_fc");
+
+	/* Get the current control reg 0 settings */
+	ctrl_reg = IXGB_READ_REG(hw, CTRL0);
+
+	/* Clear the Receive Pause Enable and Transmit Pause Enable bits */
+	ctrl_reg &= ~(IXGB_CTRL0_RPE | IXGB_CTRL0_TPE);
+
+	/* The possible values of the "flow_control" parameter are:
+	 *      0:  Flow control is completely disabled
+	 *      1:  Rx flow control is enabled (we can receive pause frames
+	 *          but not send pause frames).
+	 *      2:  Tx flow control is enabled (we can send pause frames
+	 *          but we do not support receiving pause frames).
+	 *      3:  Both Rx and TX flow control (symmetric) are enabled.
+	 *  other:  Invalid.
+	 */
+	switch (hw->fc.type) {
+	case ixgb_fc_none:	/* 0 */
+		break;
+	case ixgb_fc_rx_pause:	/* 1 */
+		/* RX Flow control is enabled, and TX Flow control is
+		 * disabled.
+		 */
+		ctrl_reg |= (IXGB_CTRL0_RPE);
+		break;
+	case ixgb_fc_tx_pause:	/* 2 */
+		/* TX Flow control is enabled, and RX Flow control is
+		 * disabled, by a software over-ride.
+		 */
+		ctrl_reg |= (IXGB_CTRL0_TPE);
+		pap_reg = hw->fc.pause_time;
+		break;
+	case ixgb_fc_full:	/* 3 */
+		/* Flow control (both RX and TX) is enabled by a software
+		 * over-ride.
+		 */
+		ctrl_reg |= (IXGB_CTRL0_RPE | IXGB_CTRL0_TPE);
+		pap_reg = hw->fc.pause_time;
+		break;
+	default:
+		/* We should never get here.  The value should be 0-3. */
+		DEBUGOUT("Flow control param set incorrectly\n");
+		ASSERT(0);
+		break;
+	}
+
+	/* Write the new settings */
+	IXGB_WRITE_REG(hw, CTRL0, ctrl_reg);
+
+	if (pap_reg != 0) {
+		IXGB_WRITE_REG(hw, PAP, pap_reg);
+	}
+
+	/* Set the flow control receive threshold registers.  Normally,
+	 * these registers will be set to a default threshold that may be
+	 * adjusted later by the driver's runtime code.  However, if the
+	 * ability to transmit pause frames in not enabled, then these
+	 * registers will be set to 0. 
+	 */
+	if (!(hw->fc.type & ixgb_fc_tx_pause)) {
+		IXGB_WRITE_REG(hw, FCRTL, 0);
+		IXGB_WRITE_REG(hw, FCRTH, 0);
+	} else {
+		/* We need to set up the Receive Threshold high and low water
+		 * marks as well as (optionally) enabling the transmission of XON frames.
+		 */
+		if (hw->fc.send_xon) {
+			IXGB_WRITE_REG(hw, FCRTL,
+				       (hw->fc.low_water | IXGB_FCRTL_XONE));
+		} else {
+			IXGB_WRITE_REG(hw, FCRTL, hw->fc.low_water);
+		}
+		IXGB_WRITE_REG(hw, FCRTH, hw->fc.high_water);
+	}
+	return (status);
+}
+
+/******************************************************************************
+ * Reads a word from a device over the Management Data Interface (MDI) bus.
+ * This interface is used to manage Physical layer devices.
+ *
+ * hw          - Struct containing variables accessed by hw code
+ * reg_address - Offset of device register being read.
+ * phy_address - Address of device on MDI.
+ *
+ * Returns:  Data word (16 bits) from MDI device.
+ *
+ * This routine uses the new protocol MDI Single Command and Address Operation.
+ * This requires that first an address cycle command is sent, followed by a
+ * read command.
+ *****************************************************************************/
+u16
+ixgb_read_phy_reg(struct ixgb_hw * hw,
+		  u32 reg_address,
+		  u32 phy_address, u32 device_type)
+{
+	u32 i;
+	u32 data;
+	u32 command = 0;
+
+	ASSERT(reg_address <= IXGB_MAX_PHY_REG_ADDRESS);
+	ASSERT(phy_address <= IXGB_MAX_PHY_ADDRESS);
+	ASSERT(device_type <= IXGB_MAX_PHY_DEV_TYPE);
+
+	/* Setup and write the address cycle command */
+	command = ((reg_address << IXGB_MSCA_NP_ADDR_SHIFT) |
+		   (device_type << IXGB_MSCA_DEV_TYPE_SHIFT) |
+		   (phy_address << IXGB_MSCA_PHY_ADDR_SHIFT) |
+		   (IXGB_MSCA_ADDR_CYCLE | IXGB_MSCA_MDI_COMMAND));
+
+	IXGB_WRITE_REG(hw, MSCA, command);
+
+    /**************************************************************
+    ** Check every 10 usec to see if the address cycle completed
+    ** The COMMAND bit will clear when the operation is complete.
+    ** This may take as long as 64 usecs (we'll wait 100 usecs max)
+    ** from the CPU Write to the Ready bit assertion.
+    **************************************************************/
+
+	for (i = 0; i < 10; i++) {
+		udelay(10);
+
+		command = IXGB_READ_REG(hw, MSCA);
+
+		if ((command & IXGB_MSCA_MDI_COMMAND) == 0)
+			break;
+	}
+
+	ASSERT((command & IXGB_MSCA_MDI_COMMAND) == 0);
+
+	/* Address cycle complete, setup and write the read command */
+	command = ((reg_address << IXGB_MSCA_NP_ADDR_SHIFT) |
+		   (device_type << IXGB_MSCA_DEV_TYPE_SHIFT) |
+		   (phy_address << IXGB_MSCA_PHY_ADDR_SHIFT) |
+		   (IXGB_MSCA_READ | IXGB_MSCA_MDI_COMMAND));
+
+	IXGB_WRITE_REG(hw, MSCA, command);
+
+    /**************************************************************
+    ** Check every 10 usec to see if the read command completed
+    ** The COMMAND bit will clear when the operation is complete.
+    ** The read may take as long as 64 usecs (we'll wait 100 usecs max)
+    ** from the CPU Write to the Ready bit assertion.
+    **************************************************************/
+
+	for (i = 0; i < 10; i++) {
+		udelay(10);
+
+		command = IXGB_READ_REG(hw, MSCA);
+
+		if ((command & IXGB_MSCA_MDI_COMMAND) == 0)
+			break;
+	}
+
+	ASSERT((command & IXGB_MSCA_MDI_COMMAND) == 0);
+
+	/* Operation is complete, get the data from the MDIO Read/Write Data
+	 * register and return. 
+	 */
+	data = IXGB_READ_REG(hw, MSRWD);
+	data >>= IXGB_MSRWD_READ_DATA_SHIFT;
+	return ((u16) data);
+}
+
+/******************************************************************************
+ * Writes a word to a device over the Management Data Interface (MDI) bus.
+ * This interface is used to manage Physical layer devices.
+ *
+ * hw          - Struct containing variables accessed by hw code
+ * reg_address - Offset of device register being read.
+ * phy_address - Address of device on MDI.
+ * device_type - Also known as the Device ID or DID.
+ * data        - 16-bit value to be written
+ *
+ * Returns:  void.
+ *
+ * This routine uses the new protocol MDI Single Command and Address Operation.
+ * This requires that first an address cycle command is sent, followed by a
+ * write command.
+ *****************************************************************************/
+void
+ixgb_write_phy_reg(struct ixgb_hw *hw,
+		   u32 reg_address,
+		   u32 phy_address, u32 device_type, u16 data)
+{
+	u32 i;
+	u32 command = 0;
+
+	ASSERT(reg_address <= IXGB_MAX_PHY_REG_ADDRESS);
+	ASSERT(phy_address <= IXGB_MAX_PHY_ADDRESS);
+	ASSERT(device_type <= IXGB_MAX_PHY_DEV_TYPE);
+
+	/* Put the data in the MDIO Read/Write Data register */
+	IXGB_WRITE_REG(hw, MSRWD, (u32) data);
+
+	/* Setup and write the address cycle command */
+	command = ((reg_address << IXGB_MSCA_NP_ADDR_SHIFT) |
+		   (device_type << IXGB_MSCA_DEV_TYPE_SHIFT) |
+		   (phy_address << IXGB_MSCA_PHY_ADDR_SHIFT) |
+		   (IXGB_MSCA_ADDR_CYCLE | IXGB_MSCA_MDI_COMMAND));
+
+	IXGB_WRITE_REG(hw, MSCA, command);
+
+    /**************************************************************
+    ** Check every 10 usec to see if the address cycle completed
+    ** The COMMAND bit will clear when the operation is complete.
+    ** This may take as long as 64 usecs (we'll wait 100 usecs max)
+    ** from the CPU Write to the Ready bit assertion.
+    **************************************************************/
+
+	for (i = 0; i < 10; i++) {
+		udelay(10);
+
+		command = IXGB_READ_REG(hw, MSCA);
+
+		if ((command & IXGB_MSCA_MDI_COMMAND) == 0)
+			break;
+	}
+
+	ASSERT((command & IXGB_MSCA_MDI_COMMAND) == 0);
+
+	/* Address cycle complete, setup and write the write command */
+	command = ((reg_address << IXGB_MSCA_NP_ADDR_SHIFT) |
+		   (device_type << IXGB_MSCA_DEV_TYPE_SHIFT) |
+		   (phy_address << IXGB_MSCA_PHY_ADDR_SHIFT) |
+		   (IXGB_MSCA_WRITE | IXGB_MSCA_MDI_COMMAND));
+
+	IXGB_WRITE_REG(hw, MSCA, command);
+
+    /**************************************************************
+    ** Check every 10 usec to see if the read command completed
+    ** The COMMAND bit will clear when the operation is complete.
+    ** The write may take as long as 64 usecs (we'll wait 100 usecs max)
+    ** from the CPU Write to the Ready bit assertion.
+    **************************************************************/
+
+	for (i = 0; i < 10; i++) {
+		udelay(10);
+
+		command = IXGB_READ_REG(hw, MSCA);
+
+		if ((command & IXGB_MSCA_MDI_COMMAND) == 0)
+			break;
+	}
+
+	ASSERT((command & IXGB_MSCA_MDI_COMMAND) == 0);
+
+	/* Operation is complete, return. */
+}
+
+/******************************************************************************
+ * Checks to see if the link status of the hardware has changed.
+ *
+ * hw - Struct containing variables accessed by hw code
+ *
+ * Called by any function that needs to check the link status of the adapter.
+ *****************************************************************************/
+void
+ixgb_check_for_link(struct ixgb_hw *hw)
+{
+	u32 status_reg;
+	u32 xpcss_reg;
+
+	DEBUGFUNC("ixgb_check_for_link");
+
+	xpcss_reg = IXGB_READ_REG(hw, XPCSS);
+	status_reg = IXGB_READ_REG(hw, STATUS);
+
+	if ((xpcss_reg & IXGB_XPCSS_ALIGN_STATUS) &&
+	    (status_reg & IXGB_STATUS_LU)) {
+		hw->link_up = TRUE;
+	} else if (!(xpcss_reg & IXGB_XPCSS_ALIGN_STATUS) &&
+		   (status_reg & IXGB_STATUS_LU)) {
+		DEBUGOUT("XPCSS Not Aligned while Status:LU is set.\n");
+		hw->link_up = ixgb_link_reset(hw);
+	} else {
+		hw->link_up = ixgb_link_reset(hw);
+	}
+
+	/*  Anything else for 10 Gig?? */
+}
+
+boolean_t
+ixgb_check_for_bad_link(struct ixgb_hw *hw)
+{
+	u32 newLFC, newRFC;
+	boolean_t bad_link_returncode = FALSE;
+
+	/* check for a bad reset that may have occured
+	 * the indication is that the RFC / LFC registers may be incrementing
+	 * continually. Do a full adapter reset to recover
+	 */
+	newLFC = IXGB_READ_REG(hw, LFC);
+	newRFC = IXGB_READ_REG(hw, RFC);
+	if ((hw->lastLFC + 250 < newLFC) || (hw->lastRFC + 250 < newRFC)) {
+		DEBUGOUT("BAD LINK! too many LFC/RFC since last check\n");
+		bad_link_returncode = TRUE;
+	}
+	hw->lastLFC = newLFC;
+	hw->lastRFC = newRFC;
+	return bad_link_returncode;
+}
+
+/******************************************************************************
+ * Clears all hardware statistics counters. 
+ *
+ * hw - Struct containing variables accessed by shared code
+ *****************************************************************************/
+void
+ixgb_clear_hw_cntrs(struct ixgb_hw *hw)
+{
+	volatile u32 temp_reg;
+
+	DEBUGFUNC("ixgb_clear_hw_cntrs");
+
+	/* if we are stopped or resetting exit gracefully */
+	if (hw->adapter_stopped) {
+		DEBUGOUT("Exiting because the adapter is stopped!!!\n");
+		return;
+	}
+
+	temp_reg = IXGB_READ_REG(hw, TPRL);
+	temp_reg = IXGB_READ_REG(hw, TPRH);
+	temp_reg = IXGB_READ_REG(hw, GPRCL);
+	temp_reg = IXGB_READ_REG(hw, GPRCH);
+	temp_reg = IXGB_READ_REG(hw, BPRCL);
+	temp_reg = IXGB_READ_REG(hw, BPRCH);
+	temp_reg = IXGB_READ_REG(hw, MPRCL);
+	temp_reg = IXGB_READ_REG(hw, MPRCH);
+	temp_reg = IXGB_READ_REG(hw, UPRCL);
+	temp_reg = IXGB_READ_REG(hw, UPRCH);
+	temp_reg = IXGB_READ_REG(hw, VPRCL);
+	temp_reg = IXGB_READ_REG(hw, VPRCH);
+	temp_reg = IXGB_READ_REG(hw, JPRCL);
+	temp_reg = IXGB_READ_REG(hw, JPRCH);
+	temp_reg = IXGB_READ_REG(hw, GORCL);
+	temp_reg = IXGB_READ_REG(hw, GORCH);
+	temp_reg = IXGB_READ_REG(hw, TORL);
+	temp_reg = IXGB_READ_REG(hw, TORH);
+	temp_reg = IXGB_READ_REG(hw, RNBC);
+	temp_reg = IXGB_READ_REG(hw, RUC);
+	temp_reg = IXGB_READ_REG(hw, ROC);
+	temp_reg = IXGB_READ_REG(hw, RLEC);
+	temp_reg = IXGB_READ_REG(hw, CRCERRS);
+	temp_reg = IXGB_READ_REG(hw, ICBC);
+	temp_reg = IXGB_READ_REG(hw, ECBC);
+	temp_reg = IXGB_READ_REG(hw, MPC);
+	temp_reg = IXGB_READ_REG(hw, TPTL);
+	temp_reg = IXGB_READ_REG(hw, TPTH);
+	temp_reg = IXGB_READ_REG(hw, GPTCL);
+	temp_reg = IXGB_READ_REG(hw, GPTCH);
+	temp_reg = IXGB_READ_REG(hw, BPTCL);
+	temp_reg = IXGB_READ_REG(hw, BPTCH);
+	temp_reg = IXGB_READ_REG(hw, MPTCL);
+	temp_reg = IXGB_READ_REG(hw, MPTCH);
+	temp_reg = IXGB_READ_REG(hw, UPTCL);
+	temp_reg = IXGB_READ_REG(hw, UPTCH);
+	temp_reg = IXGB_READ_REG(hw, VPTCL);
+	temp_reg = IXGB_READ_REG(hw, VPTCH);
+	temp_reg = IXGB_READ_REG(hw, JPTCL);
+	temp_reg = IXGB_READ_REG(hw, JPTCH);
+	temp_reg = IXGB_READ_REG(hw, GOTCL);
+	temp_reg = IXGB_READ_REG(hw, GOTCH);
+	temp_reg = IXGB_READ_REG(hw, TOTL);
+	temp_reg = IXGB_READ_REG(hw, TOTH);
+	temp_reg = IXGB_READ_REG(hw, DC);
+	temp_reg = IXGB_READ_REG(hw, PLT64C);
+	temp_reg = IXGB_READ_REG(hw, TSCTC);
+	temp_reg = IXGB_READ_REG(hw, TSCTFC);
+	temp_reg = IXGB_READ_REG(hw, IBIC);
+	temp_reg = IXGB_READ_REG(hw, RFC);
+	temp_reg = IXGB_READ_REG(hw, LFC);
+	temp_reg = IXGB_READ_REG(hw, PFRC);
+	temp_reg = IXGB_READ_REG(hw, PFTC);
+	temp_reg = IXGB_READ_REG(hw, MCFRC);
+	temp_reg = IXGB_READ_REG(hw, MCFTC);
+	temp_reg = IXGB_READ_REG(hw, XONRXC);
+	temp_reg = IXGB_READ_REG(hw, XONTXC);
+	temp_reg = IXGB_READ_REG(hw, XOFFRXC);
+	temp_reg = IXGB_READ_REG(hw, XOFFTXC);
+	temp_reg = IXGB_READ_REG(hw, RJC);
+	return;
+}
+
+/******************************************************************************
+ * Turns on the software controllable LED
+ *
+ * hw - Struct containing variables accessed by shared code
+ *****************************************************************************/
+void
+ixgb_led_on(struct ixgb_hw *hw)
+{
+	u32 ctrl0_reg = IXGB_READ_REG(hw, CTRL0);
+
+	/* To turn on the LED, clear software-definable pin 0 (SDP0). */
+	ctrl0_reg &= ~IXGB_CTRL0_SDP0;
+	IXGB_WRITE_REG(hw, CTRL0, ctrl0_reg);
+	return;
+}
+
+/******************************************************************************
+ * Turns off the software controllable LED
+ *
+ * hw - Struct containing variables accessed by shared code
+ *****************************************************************************/
+void
+ixgb_led_off(struct ixgb_hw *hw)
+{
+	u32 ctrl0_reg = IXGB_READ_REG(hw, CTRL0);
+
+	/* To turn off the LED, set software-definable pin 0 (SDP0). */
+	ctrl0_reg |= IXGB_CTRL0_SDP0;
+	IXGB_WRITE_REG(hw, CTRL0, ctrl0_reg);
+	return;
+}
+
+/******************************************************************************
+ * Gets the current PCI bus type, speed, and width of the hardware
+ *
+ * hw - Struct containing variables accessed by shared code
+ *****************************************************************************/
+static void
+ixgb_get_bus_info(struct ixgb_hw *hw)
+{
+	u32 status_reg;
+
+	status_reg = IXGB_READ_REG(hw, STATUS);
+
+	hw->bus.type = (status_reg & IXGB_STATUS_PCIX_MODE) ?
+	    ixgb_bus_type_pcix : ixgb_bus_type_pci;
+
+	if (hw->bus.type == ixgb_bus_type_pci) {
+		hw->bus.speed = (status_reg & IXGB_STATUS_PCI_SPD) ?
+		    ixgb_bus_speed_66 : ixgb_bus_speed_33;
+	} else {
+		switch (status_reg & IXGB_STATUS_PCIX_SPD_MASK) {
+		case IXGB_STATUS_PCIX_SPD_66:
+			hw->bus.speed = ixgb_bus_speed_66;
+			break;
+		case IXGB_STATUS_PCIX_SPD_100:
+			hw->bus.speed = ixgb_bus_speed_100;
+			break;
+		case IXGB_STATUS_PCIX_SPD_133:
+			hw->bus.speed = ixgb_bus_speed_133;
+			break;
+		default:
+			hw->bus.speed = ixgb_bus_speed_reserved;
+			break;
+		}
+	}
+
+	hw->bus.width = (status_reg & IXGB_STATUS_BUS64) ?
+	    ixgb_bus_width_64 : ixgb_bus_width_32;
+
+	return;
+}
+
+/******************************************************************************
+ * Tests a MAC address to ensure it is a valid Individual Address
+ *
+ * mac_addr - pointer to MAC address. 
+ *
+ *****************************************************************************/
+boolean_t
+mac_addr_valid(u8 * mac_addr)
+{
+	boolean_t is_valid = TRUE;
+	DEBUGFUNC("mac_addr_valid");
+
+	/* Make sure it is not a multicast address */
+	if (IS_MULTICAST(mac_addr)) {
+		DEBUGOUT("MAC address is multicast\n");
+		is_valid = FALSE;
+	}
+	/* Not a broadcast address */
+	else if (IS_BROADCAST(mac_addr)) {
+		DEBUGOUT("MAC address is broadcast\n");
+		is_valid = FALSE;
+	}
+	/* Reject the zero address */
+	else if (mac_addr[0] == 0 &&
+		 mac_addr[1] == 0 &&
+		 mac_addr[2] == 0 &&
+		 mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0) {
+		DEBUGOUT("MAC address is all zeros\n");
+		is_valid = FALSE;
+	}
+	return (is_valid);
+}
+
+/******************************************************************************
+ * Resets the 10GbE link.  Waits the settle time and returns the state of 
+ * the link.
+ *
+ * hw - Struct containing variables accessed by shared code
+ *****************************************************************************/
+boolean_t
+ixgb_link_reset(struct ixgb_hw * hw)
+{
+	boolean_t link_status = FALSE;
+	u8 wait_retries = MAX_RESET_ITERATIONS;
+	u8 lrst_retries = MAX_RESET_ITERATIONS;
+
+	do {
+		IXGB_WRITE_REG(hw, CTRL0,
+			       IXGB_READ_REG(hw, CTRL0) | IXGB_CTRL0_LRST);
+
+		do {
+			udelay(IXGB_DELAY_USECS_AFTER_LINK_RESET);
+			link_status =
+			    ((IXGB_READ_REG(hw, STATUS) & IXGB_STATUS_LU)
+			     && (IXGB_READ_REG(hw, XPCSS) &
+				 IXGB_XPCSS_ALIGN_STATUS)) ? TRUE : FALSE;
+		} while (!link_status && --wait_retries);
+	} while (!link_status && --lrst_retries);
+
+	return link_status;
+}
+
+/******************************************************************************
+ * Resets the 10GbE optics module.
+ *
+ * hw - Struct containing variables accessed by shared code
+ *****************************************************************************/
+void
+ixgb_optics_reset(struct ixgb_hw *hw)
+{
+	u16 mdio_reg;
+
+	ixgb_write_phy_reg(hw,
+			   TXN17401_PMA_PMD_CR1,
+			   IXGB_PHY_ADDRESS,
+			   TXN17401_PMA_PMD_DID, TXN17401_PMA_PMD_CR1_RESET);
+	mdio_reg = ixgb_read_phy_reg(hw,
+				     TXN17401_PMA_PMD_CR1,
+				     IXGB_PHY_ADDRESS, TXN17401_PMA_PMD_DID);
+}
diff -Nru a/drivers/net/ixgb/ixgb_hw.h b/drivers/net/ixgb/ixgb_hw.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/net/ixgb/ixgb_hw.h	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,625 @@
+/*******************************************************************************
+
+  
+  Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
+  
+  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; either version 2 of the License, or (at your option) 
+  any later version.
+  
+  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.
+  
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59 
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+  
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+  
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+*******************************************************************************/
+
+#ifndef _IXGB_HW_H_
+#define _IXGB_HW_H_
+
+#include "ixgb_osdep.h"
+
+/* Enums */
+typedef enum {
+	ixgb_mac_unknown = 0,
+	ixgb_82597,
+	ixgb_num_macs
+} ixgb_mac_type;
+
+/* Media Types */
+typedef enum {
+	ixgb_media_type_unknown = 0,
+	ixgb_media_type_fiber = 1,
+	ixgb_num_media_types
+} ixgb_media_type;
+
+/* Flow Control Settings */
+typedef enum {
+	ixgb_fc_none = 0,
+	ixgb_fc_rx_pause = 1,
+	ixgb_fc_tx_pause = 2,
+	ixgb_fc_full = 3,
+	ixgb_fc_default = 0xFF
+} ixgb_fc_type;
+
+/* PCI bus types */
+typedef enum {
+	ixgb_bus_type_unknown = 0,
+	ixgb_bus_type_pci,
+	ixgb_bus_type_pcix
+} ixgb_bus_type;
+
+/* PCI bus speeds */
+typedef enum {
+	ixgb_bus_speed_unknown = 0,
+	ixgb_bus_speed_33,
+	ixgb_bus_speed_66,
+	ixgb_bus_speed_100,
+	ixgb_bus_speed_133,
+	ixgb_bus_speed_reserved
+} ixgb_bus_speed;
+
+/* PCI bus widths */
+typedef enum {
+	ixgb_bus_width_unknown = 0,
+	ixgb_bus_width_32,
+	ixgb_bus_width_64
+} ixgb_bus_width;
+
+#define IXGB_ETH_LENGTH_OF_ADDRESS   6
+
+#define IXGB_EEPROM_SIZE    64	/* Size in words */
+
+#define SPEED_10000  10000
+#define FULL_DUPLEX  2
+
+#define IXGB_DELAY_BEFORE_RESET        10	/* allow 10ms after idling rx/tx units      */
+#define IXGB_DELAY_AFTER_RESET          1	/* allow 1ms after the reset                */
+#define IXGB_DELAY_AFTER_EE_RESET      10	/* allow 10ms after the EEPROM reset        */
+
+#define IXGB_DELAY_USECS_AFTER_LINK_RESET    13	/* allow 13 microseconds after the reset    */
+					   /* NOTE: this is MICROSECONDS               */
+#define MAX_RESET_ITERATIONS            8	/* number of iterations to get things right */
+
+/* General Registers */
+#define IXGB_CTRL0   0x00000	/* Device Control Register 0 - RW */
+#define IXGB_CTRL1   0x00008	/* Device Control Register 1 - RW */
+#define IXGB_STATUS  0x00010	/* Device Status Register - RO */
+#define IXGB_EECD    0x00018	/* EEPROM/Flash Control/Data Register - RW */
+#define IXGB_MFS     0x00020	/* Maximum Frame Size - RW */
+
+/* Interrupt */
+#define IXGB_ICR     0x00080	/* Interrupt Cause Read - R/clr */
+#define IXGB_ICS     0x00088	/* Interrupt Cause Set - RW */
+#define IXGB_IMS     0x00090	/* Interrupt Mask Set/Read - RW */
+#define IXGB_IMC     0x00098	/* Interrupt Mask Clear - WO */
+
+/* Receive */
+#define IXGB_RCTL    0x00100	/* RX Control - RW */
+#define IXGB_FCRTL   0x00108	/* Flow Control Receive Threshold Low - RW */
+#define IXGB_FCRTH   0x00110	/* Flow Control Receive Threshold High - RW */
+#define IXGB_RDBAL   0x00118	/* RX Descriptor Base Low - RW */
+#define IXGB_RDBAH   0x0011C	/* RX Descriptor Base High - RW */
+#define IXGB_RDLEN   0x00120	/* RX Descriptor Length - RW */
+#define IXGB_RDH     0x00128	/* RX Descriptor Head - RW */
+#define IXGB_RDT     0x00130	/* RX Descriptor Tail - RW */
+#define IXGB_RDTR    0x00138	/* RX Delay Timer Ring - RW */
+#define IXGB_RXDCTL  0x00140	/* Receive Descriptor Control - RW */
+#define IXGB_RAIDC   0x00148	/* Receive Adaptive Interrupt Delay Control - RW */
+#define IXGB_RXCSUM  0x00158	/* Receive Checksum Control - RW */
+#define IXGB_RA      0x00180	/* Receive Address Array Base - RW */
+#define IXGB_RAL     0x00180	/* Receive Address Low [0:15] - RW */
+#define IXGB_RAH     0x00184	/* Receive Address High [0:15] - RW */
+#define IXGB_MTA     0x00200	/* Multicast Table Array [0:127] - RW */
+#define IXGB_VFTA    0x00400	/* VLAN Filter Table Array [0:127] - RW */
+#define IXGB_REQ_RX_DESCRIPTOR_MULTIPLE 8
+
+/* Transmit */
+#define IXGB_TCTL    0x00600	/* TX Control - RW */
+#define IXGB_TDBAL   0x00608	/* TX Descriptor Base Low - RW */
+#define IXGB_TDBAH   0x0060C	/* TX Descriptor Base High - RW */
+#define IXGB_TDLEN   0x00610	/* TX Descriptor Length - RW */
+#define IXGB_TDH     0x00618	/* TX Descriptor Head - RW */
+#define IXGB_TDT     0x00620	/* TX Descriptor Tail - RW */
+#define IXGB_TIDV    0x00628	/* TX Interrupt Delay Value - RW */
+#define IXGB_TXDCTL  0x00630	/* Transmit Descriptor Control - RW */
+#define IXGB_TSPMT   0x00638	/* TCP Segmentation PAD & Min Threshold - RW */
+#define IXGB_PAP     0x00640	/* Pause and Pace - RW */
+#define IXGB_REQ_TX_DESCRIPTOR_MULTIPLE 8
+
+/* Physical */
+#define IXGB_PCSC1   0x00700	/* PCS Control 1 - RW */
+#define IXGB_PCSC2   0x00708	/* PCS Control 2 - RW */
+#define IXGB_PCSS1   0x00710	/* PCS Status 1 - RO */
+#define IXGB_PCSS2   0x00718	/* PCS Status 2 - RO */
+#define IXGB_XPCSS   0x00720	/* 10GBASE-X PCS Status (or XGXS Lane Status) - RO */
+#define IXGB_UCCR    0x00728	/* Unilink Circuit Control Register */
+#define IXGB_XPCSTC  0x00730	/* 10GBASE-X PCS Test Control */
+#define IXGB_MACA    0x00738	/* MDI Autoscan Command and Address - RW */
+#define IXGB_APAE    0x00740	/* Autoscan PHY Address Enable - RW */
+#define IXGB_ARD     0x00748	/* Autoscan Read Data - RO */
+#define IXGB_AIS     0x00750	/* Autoscan Interrupt Status - RO */
+#define IXGB_MSCA    0x00758	/* MDI Single Command and Address - RW */
+#define IXGB_MSRWD   0x00760	/* MDI Single Read and Write Data - RW, RO */
+
+/* Wake-up */
+#define IXGB_WUFC    0x00808	/* Wake Up Filter Control - RW */
+#define IXGB_WUS     0x00810	/* Wake Up Status - RO */
+#define IXGB_FFLT    0x01000	/* Flexible Filter Length Table - RW */
+#define IXGB_FFMT    0x01020	/* Flexible Filter Mask Table - RW */
+#define IXGB_FTVT    0x01420	/* Flexible Filter Value Table - RW */
+
+/* Statistics */
+#define IXGB_TPRL    0x02000	/* Total Packets Received (Low) */
+#define IXGB_TPRH    0x02004	/* Total Packets Received (High) */
+#define IXGB_GPRCL   0x02008	/* Good Packets Received Count (Low) */
+#define IXGB_GPRCH   0x0200C	/* Good Packets Received Count (High) */
+#define IXGB_BPRCL   0x02010	/* Broadcast Packets Received Count (Low) */
+#define IXGB_BPRCH   0x02014	/* Broadcast Packets Received Count (High) */
+#define IXGB_MPRCL   0x02018	/* Multicast Packets Received Count (Low) */
+#define IXGB_MPRCH   0x0201C	/* Multicast Packets Received Count (High) */
+#define IXGB_UPRCL   0x02020	/* Unicast Packets Received Count (Low) */
+#define IXGB_UPRCH   0x02024	/* Unicast Packets Received Count (High) */
+#define IXGB_VPRCL   0x02028	/* VLAN Packets Received Count (Low) */
+#define IXGB_VPRCH   0x0202C	/* VLAN Packets Received Count (High) */
+#define IXGB_JPRCL   0x02030	/* Jumbo Packets Received Count (Low) */
+#define IXGB_JPRCH   0x02034	/* Jumbo Packets Received Count (High) */
+#define IXGB_GORCL   0x02038	/* Good Octets Received Count (Low) */
+#define IXGB_GORCH   0x0203C	/* Good Octets Received Count (High) */
+#define IXGB_TORL    0x02040	/* Total Octets Received (Low) */
+#define IXGB_TORH    0x02044	/* Total Octets Received (High) */
+#define IXGB_RNBC    0x02048	/* Receive No Buffers Count */
+#define IXGB_RUC     0x02050	/* Receive Undersize Count */
+#define IXGB_ROC     0x02058	/* Receive Oversize Count */
+#define IXGB_RLEC    0x02060	/* Receive Length Error Count */
+#define IXGB_CRCERRS 0x02068	/* CRC Error Count */
+#define IXGB_ICBC    0x02070	/* Illegal control byte in mid-packet Count */
+#define IXGB_ECBC    0x02078	/* Error Control byte in mid-packet Count */
+#define IXGB_MPC     0x02080	/* Missed Packets Count */
+#define IXGB_TPTL    0x02100	/* Total Packets Transmitted (Low) */
+#define IXGB_TPTH    0x02104	/* Total Packets Transmitted (High) */
+#define IXGB_GPTCL   0x02108	/* Good Packets Transmitted Count (Low) */
+#define IXGB_GPTCH   0x0210C	/* Good Packets Transmitted Count (High) */
+#define IXGB_BPTCL   0x02110	/* Broadcast Packets Transmitted Count (Low) */
+#define IXGB_BPTCH   0x02114	/* Broadcast Packets Transmitted Count (High) */
+#define IXGB_MPTCL   0x02118	/* Multicast Packets Transmitted Count (Low) */
+#define IXGB_MPTCH   0x0211C	/* Multicast Packets Transmitted Count (High) */
+#define IXGB_UPTCL   0x02120	/* Unicast Packets Transmitted Count (Low) */
+#define IXGB_UPTCH   0x02124	/* Unicast Packets Transmitted Count (High) */
+#define IXGB_VPTCL   0x02128	/* VLAN Packets Transmitted Count (Low) */
+#define IXGB_VPTCH   0x0212C	/* VLAN Packets Transmitted Count (High) */
+#define IXGB_JPTCL   0x02130	/* Jumbo Packets Transmitted Count (Low) */
+#define IXGB_JPTCH   0x02134	/* Jumbo Packets Transmitted Count (High) */
+#define IXGB_GOTCL   0x02138	/* Good Octets Transmitted Count (Low) */
+#define IXGB_GOTCH   0x0213C	/* Good Octets Transmitted Count (High) */
+#define IXGB_TOTL    0x02140	/* Total Octets Transmitted Count (Low) */
+#define IXGB_TOTH    0x02144	/* Total Octets Transmitted Count (High) */
+#define IXGB_DC      0x02148	/* Defer Count */
+#define IXGB_PLT64C  0x02150	/* Packet Transmitted was less than 64 bytes Count */
+#define IXGB_TSCTC   0x02170	/* TCP Segmentation Context Transmitted Count */
+#define IXGB_TSCTFC  0x02178	/* TCP Segmentation Context Tx Fail Count */
+#define IXGB_IBIC    0x02180	/* Illegal byte during Idle stream count */
+#define IXGB_RFC     0x02188	/* Remote Fault Count */
+#define IXGB_LFC     0x02190	/* Local Fault Count */
+#define IXGB_PFRC    0x02198	/* Pause Frame Receive Count */
+#define IXGB_PFTC    0x021A0	/* Pause Frame Transmit Count */
+#define IXGB_MCFRC   0x021A8	/* MAC Control Frames (non-Pause) Received Count */
+#define IXGB_MCFTC   0x021B0	/* MAC Control Frames (non-Pause) Transmitted Count */
+#define IXGB_XONRXC  0x021B8	/* XON Received Count */
+#define IXGB_XONTXC  0x021C0	/* XON Transmitted Count */
+#define IXGB_XOFFRXC 0x021C8	/* XOFF Received Count */
+#define IXGB_XOFFTXC 0x021D0	/* XOFF Transmitted Count */
+#define IXGB_RJC     0x021D8	/* Receive Jabber Count */
+
+/* CTRL0 Bit Masks */
+#define IXGB_CTRL0_LRST     0x00000008
+#define IXGB_CTRL0_JFE      0x00000010
+#define IXGB_CTRL0_SDP0     0x00040000
+#define IXGB_CTRL0_SDP1     0x00080000
+#define IXGB_CTRL0_SDP2     0x00100000
+#define IXGB_CTRL0_SDP3     0x00200000
+#define IXGB_CTRL0_SDP0_DIR 0x00400000
+#define IXGB_CTRL0_SDP1_DIR 0x00800000
+#define IXGB_CTRL0_SDP2_DIR 0x01000000
+#define IXGB_CTRL0_SDP3_DIR 0x02000000
+#define IXGB_CTRL0_RST      0x04000000
+#define IXGB_CTRL0_RPE      0x08000000
+#define IXGB_CTRL0_TPE      0x10000000
+#define IXGB_CTRL0_VME      0x40000000
+
+/* CTRL1 Bit Masks */
+
+#define IXGB_CTRL1_EE_RST      0x00002000
+
+/* STATUS Bit Masks */
+#define IXGB_STATUS_LU            0x00000002
+
+#define IXGB_STATUS_TXOFF         0x00000010
+
+#define IXGB_STATUS_PCI_SPD       0x00000800
+#define IXGB_STATUS_BUS64         0x00001000
+#define IXGB_STATUS_PCIX_MODE     0x00002000
+#define IXGB_STATUS_PCIX_SPD_MASK 0x0000C000
+#define IXGB_STATUS_PCIX_SPD_66   0x00000000
+#define IXGB_STATUS_PCIX_SPD_100  0x00004000
+#define IXGB_STATUS_PCIX_SPD_133  0x00008000
+
+/* EECD Bit Masks */
+#define IXGB_EECD_SK       0x00000001
+#define IXGB_EECD_CS       0x00000002
+#define IXGB_EECD_DI       0x00000004
+#define IXGB_EECD_DO       0x00000008
+
+/* MFS */
+#define IXGB_MFS_SHIFT 16
+
+/* Interrupt Register Bit Masks (used for ICR, ICS, IMS, and IMC) */
+#define IXGB_INT_TXDW     0x00000001
+#define IXGB_INT_LSC      0x00000004
+#define IXGB_INT_RXSEQ    0x00000008
+#define IXGB_INT_RXDMT0   0x00000010
+#define IXGB_INT_RXO      0x00000040
+#define IXGB_INT_RXT0     0x00000080
+
+/* RCTL Bit Masks */
+#define IXGB_RCTL_RXEN        0x00000002
+#define IXGB_RCTL_UPE         0x00000008
+#define IXGB_RCTL_MPE         0x00000010
+#define IXGB_RCTL_RDMTS_1_2   0x00000000
+#define IXGB_RCTL_MO_SHIFT    12
+#define IXGB_RCTL_BAM         0x00008000
+#define IXGB_RCTL_BSIZE_2048  0x00000000
+#define IXGB_RCTL_BSIZE_4096  0x00010000
+#define IXGB_RCTL_BSIZE_8192  0x00020000
+#define IXGB_RCTL_BSIZE_16384 0x00030000
+#define IXGB_RCTL_VFE         0x00040000
+#define IXGB_RCTL_CFIEN       0x00080000
+#define IXGB_RCTL_CFI         0x00100000
+#define IXGB_RCTL_CFF         0x00800000
+#define IXGB_RCTL_SECRC       0x04000000
+
+/* FCRTL Bit Masks */
+#define IXGB_FCRTL_XONE       0x80000000
+
+/* RXDCTL Bit Masks */
+#define IXGB_RXDCTL_PTHRESH_SHIFT 0
+#define IXGB_RXDCTL_HTHRESH_SHIFT 9
+#define IXGB_RXDCTL_WTHRESH_SHIFT 18
+
+/* RAIDC Bit Masks */
+#define IXGB_RAIDC_DELAY_SHIFT   11
+#define IXGB_RAIDC_POLL_SHIFT    20
+#define IXGB_RAIDC_RXT_GATE      0x40000000
+#define IXGB_RAIDC_EN            0x80000000
+
+/* RXCSUM Bit Masks */
+#define IXGB_RXCSUM_TUOFL 0x00000200
+
+/* RAH Bit Masks */
+#define IXGB_RAH_AV        0x80000000
+
+/* TCTL Bit Masks */
+#define IXGB_TCTL_TCE  0x00000001
+#define IXGB_TCTL_TXEN 0x00000002
+#define IXGB_TCTL_TPDE 0x00000004
+
+/* TXDCTL Bit Masks */
+#define IXGB_TXDCTL_HTHRESH_SHIFT 8
+
+/* TSPMT Bit Masks */
+
+/* PAP Bit Masks */
+
+/* PCSC1 Bit Masks */
+
+/* PCSC2 Bit Masks */
+
+/* PCSS1 Bit Masks */
+
+/* PCSS2 Bit Masks */
+
+/* XPCSS Bit Masks */
+#define IXGB_XPCSS_ALIGN_STATUS 0x00001000
+
+/* XPCSTC Bit Masks */
+
+/* MSCA bit Masks */
+/* New Protocol Address */
+#define IXGB_MSCA_NP_ADDR_SHIFT     0
+/* Either Device Type or Register Address,depending on ST_CODE */
+#define IXGB_MSCA_DEV_TYPE_SHIFT    16
+#define IXGB_MSCA_PHY_ADDR_SHIFT    21
+#define IXGB_MSCA_ADDR_CYCLE        0x00000000
+#define IXGB_MSCA_WRITE             0x04000000
+#define IXGB_MSCA_READ              0x08000000
+/* Initiate command, self-clearing when command completes */
+#define IXGB_MSCA_MDI_COMMAND       0x40000000
+/*MDI In Progress Enable. */
+
+/* MSRWD bit masks */
+#define IXGB_MSRWD_READ_DATA_SHIFT  16
+
+/* Definitions for the TXN17401 devices on the MDIO bus. */
+#define IXGB_PHY_ADDRESS             0x0	/* Single PHY, multiple "Devices" */
+
+/* Five bit Device IDs */
+#define TXN17401_PMA_PMD_DID    0x01
+#define TXN17401_PCS_DID        0x03
+#define TXN17401_XGXS_DID       0x04
+
+/* PMA/PMD registers and bit definitions. */
+/* Note: This is a very limited set of definitions,      */
+/* only implemented features are defined.                */
+#define TXN17401_PMA_PMD_CR1        0x0000
+
+#define TXN17401_PMA_PMD_CR1_RESET  0x8000
+
+struct ixgb_rx_desc {
+	uint64_t buff_addr;
+	u16 length;
+	u16 reserved;
+	u8 status;
+	u8 errors;
+	u16 special;
+};
+
+#define IXGB_RX_DESC_STATUS_DD    0x01
+#define IXGB_RX_DESC_STATUS_EOP   0x02
+#define IXGB_RX_DESC_STATUS_IXSM  0x04
+#define IXGB_RX_DESC_STATUS_VP    0x08
+#define IXGB_RX_DESC_STATUS_TCPCS 0x20
+
+#define IXGB_RX_DESC_ERRORS_CE   0x01
+#define IXGB_RX_DESC_ERRORS_SE   0x02
+#define IXGB_RX_DESC_ERRORS_P    0x08
+#define IXGB_RX_DESC_ERRORS_TCPE 0x20
+#define IXGB_RX_DESC_ERRORS_RXE  0x80
+
+#define IXGB_RX_DESC_SPECIAL_VLAN_MASK  0x0FFF	/* VLAN ID is in lower 12 bits */
+
+struct ixgb_tx_desc {
+	uint64_t buff_addr;
+	u32 cmd_type_len;
+	u8 status;
+	u8 popts;
+	u16 vlan;
+};
+
+#define IXGB_TX_DESC_CMD_EOP        0x01000000
+#define IXGB_TX_DESC_CMD_TSE        0x04000000
+#define IXGB_TX_DESC_CMD_RS         0x08000000
+#define IXGB_TX_DESC_CMD_VLE        0x40000000
+#define IXGB_TX_DESC_CMD_IDE        0x80000000
+
+#define IXGB_TX_DESC_TYPE           0x00100000
+
+#define IXGB_TX_DESC_STATUS_DD  0x01
+
+#define IXGB_TX_DESC_POPTS_IXSM 0x01
+#define IXGB_TX_DESC_POPTS_TXSM 0x02
+
+struct ixgb_context_desc {
+	u8 ipcss;
+	u8 ipcso;
+	u16 ipcse;
+	u8 tucss;
+	u8 tucso;
+	u16 tucse;
+	u32 cmd_type_len;
+	u8 status;
+	u8 hdr_len;
+	u16 mss;
+};
+
+#define IXGB_CONTEXT_DESC_CMD_TCP 0x01000000
+#define IXGB_CONTEXT_DESC_CMD_IP  0x02000000
+#define IXGB_CONTEXT_DESC_CMD_TSE 0x04000000
+#define IXGB_CONTEXT_DESC_CMD_RS  0x08000000
+#define IXGB_CONTEXT_DESC_CMD_IDE 0x80000000
+
+#define IXGB_CONTEXT_DESC_TYPE 0x00000000
+
+/* Filters */
+#define IXGB_RAR_ENTRIES          16	/* Number of entries in Rx Address array */
+#define IXGB_MC_TBL_SIZE          128	/* Multicast Filter Table (4096 bits) */
+#define IXGB_VLAN_FILTER_TBL_SIZE 128	/* VLAN Filter Table (4096 bits) */
+
+#define ENET_HEADER_SIZE            14
+#define ENET_FCS_LENGTH             4
+#define IXGB_MAX_NUM_MULTICAST_ADDRESSES    128
+#define IXGB_MIN_ENET_FRAME_SIZE_WITHOUT_FCS    60
+#define IXGB_MAX_ENET_FRAME_SIZE_WITHOUT_FCS    1514
+#define IXGB_MAX_JUMBO_FRAME_SIZE       0x3F00
+
+/* Phy Addresses */
+
+/*
+ * This is a little-endian specific check.
+ */
+#define IS_MULTICAST(Address) \
+    (boolean_t)(((u8 *)(Address))[0] & ((u8)0x01))
+
+/*
+ * Check whether an address is broadcast.
+ */
+#define IS_BROADCAST(Address)               \
+    ((((u8 *)(Address))[0] == ((u8)0xff)) && (((u8 *)(Address))[1] == ((u8)0xff)))
+
+/* Flow control parameters */
+struct ixgb_fc {
+	u32 high_water;	/* Flow Control High-water          */
+	u32 low_water;	/* Flow Control Low-water           */
+	u16 pause_time;	/* Flow Control Pause timer         */
+	boolean_t send_xon;	/* Flow control send XON            */
+	ixgb_fc_type type;	/* Type of flow control             */
+};
+
+/* The historical defaults for the flow control values are given below. */
+
+/* Phy definitions */
+#define IXGB_MAX_PHY_REG_ADDRESS    0xFFFF
+#define IXGB_MAX_PHY_ADDRESS        31
+#define IXGB_MAX_PHY_DEV_TYPE       31
+
+/* Bus parameters */
+struct ixgb_bus {
+	ixgb_bus_speed speed;
+	ixgb_bus_width width;
+	ixgb_bus_type type;
+};
+
+struct ixgb_hw {
+	u8 *hw_addr;	/* Base Address of the hardware     */
+	void *back;		/* Pointer to OS-dependent struct   */
+	struct ixgb_fc fc;	/* Flow control parameters          */
+	struct ixgb_bus bus;	/* Bus parameters                   */
+	u32 phy_id;	/* Phy Identifier                   */
+	u32 phy_addr;	/* XGMII address of Phy             */
+	ixgb_mac_type mac_type;	/* Identifier for MAC controller    */
+	u32 max_frame_size;	/* Maximum frame size supported     */
+	u32 mc_filter_type;	/* Multicast filter hash type       */
+	u32 num_mc_addrs;	/* Number of current Multicast addrs */
+	u8 curr_mac_addr[IXGB_ETH_LENGTH_OF_ADDRESS];	/* Individual address currently programmed in MAC */
+	u32 num_tx_desc;	/* Number of Transmit descriptors   */
+	u32 num_rx_desc;	/* Number of Receive descriptors    */
+	u32 rx_buffer_size;	/* Size of Receive buffer           */
+	boolean_t link_up;	/* TRUE if link is valid            */
+	boolean_t adapter_stopped;	/* State of adapter                 */
+	u16 device_id;	/* device id from PCI configuration space */
+	u16 vendor_id;	/* vendor id from PCI configuration space */
+	u16 subsystem_vendor_id;	/* subsystem vendor id from PCI configuration space */
+	u16 subsystem_id;	/* subsystem id from PCI configuration space */
+	u16 eeprom[IXGB_EEPROM_SIZE];	/* EEPROM contents read at init time  */
+	uint64_t io_base;	/* Our I/O mapped location */
+	u32 lastLFC;
+	u32 lastRFC;
+};
+
+struct ixgb_hw_stats {
+	uint64_t tprl;
+	uint64_t tprh;
+	uint64_t gprcl;
+	uint64_t gprch;
+	uint64_t bprcl;
+	uint64_t bprch;
+	uint64_t mprcl;
+	uint64_t mprch;
+	uint64_t uprcl;
+	uint64_t uprch;
+	uint64_t vprcl;
+	uint64_t vprch;
+	uint64_t jprcl;
+	uint64_t jprch;
+	uint64_t gorcl;
+	uint64_t gorch;
+	uint64_t torl;
+	uint64_t torh;
+	uint64_t rnbc;
+	uint64_t ruc;
+	uint64_t roc;
+	uint64_t rlec;
+	uint64_t crcerrs;
+	uint64_t icbc;
+	uint64_t ecbc;
+	uint64_t mpc;
+	uint64_t tptl;
+	uint64_t tpth;
+	uint64_t gptcl;
+	uint64_t gptch;
+	uint64_t bptcl;
+	uint64_t bptch;
+	uint64_t mptcl;
+	uint64_t mptch;
+	uint64_t uptcl;
+	uint64_t uptch;
+	uint64_t vptcl;
+	uint64_t vptch;
+	uint64_t jptcl;
+	uint64_t jptch;
+	uint64_t gotcl;
+	uint64_t gotch;
+	uint64_t totl;
+	uint64_t toth;
+	uint64_t dc;
+	uint64_t plt64c;
+	uint64_t tsctc;
+	uint64_t tsctfc;
+	uint64_t ibic;
+	uint64_t rfc;
+	uint64_t lfc;
+	uint64_t pfrc;
+	uint64_t pftc;
+	uint64_t mcfrc;
+	uint64_t mcftc;
+	uint64_t xonrxc;
+	uint64_t xontxc;
+	uint64_t xoffrxc;
+	uint64_t xofftxc;
+	uint64_t rjc;
+};
+
+/* Function Prototypes */
+extern boolean_t ixgb_adapter_stop(struct ixgb_hw *hw);
+extern boolean_t ixgb_init_hw(struct ixgb_hw *hw);
+extern boolean_t ixgb_adapter_start(struct ixgb_hw *hw);
+extern void ixgb_init_rx_addrs(struct ixgb_hw *hw);
+extern void ixgb_check_for_link(struct ixgb_hw *hw);
+extern boolean_t ixgb_check_for_bad_link(struct ixgb_hw *hw);
+extern boolean_t ixgb_setup_fc(struct ixgb_hw *hw);
+extern void ixgb_clear_hw_cntrs(struct ixgb_hw *hw);
+extern boolean_t mac_addr_valid(u8 * mac_addr);
+
+extern u16 ixgb_read_phy_reg(struct ixgb_hw *hw,
+				  u32 reg_addr,
+				  u32 phy_addr, u32 device_type);
+
+extern void ixgb_write_phy_reg(struct ixgb_hw *hw,
+			       u32 reg_addr,
+			       u32 phy_addr,
+			       u32 device_type, u16 data);
+
+extern void ixgb_rar_set(struct ixgb_hw *hw, u8 * addr, u32 index);
+
+/* Filters (multicast, vlan, receive) */
+extern void ixgb_mc_addr_list_update(struct ixgb_hw *hw,
+				     u8 * mc_addr_list,
+				     u32 mc_addr_count, u32 pad);
+
+/* Vfta functions */
+extern void ixgb_write_vfta(struct ixgb_hw *hw,
+			    u32 offset, u32 value);
+
+extern void ixgb_clear_vfta(struct ixgb_hw *hw);
+
+/* Access functions to eeprom data */
+void ixgb_get_ee_mac_addr(struct ixgb_hw *hw, u8 * mac_addr);
+u16 ixgb_get_ee_compatibility(struct ixgb_hw *hw);
+u32 ixgb_get_ee_pba_number(struct ixgb_hw *hw);
+u16 ixgb_get_ee_init_ctrl_reg_1(struct ixgb_hw *hw);
+u16 ixgb_get_ee_init_ctrl_reg_2(struct ixgb_hw *hw);
+u16 ixgb_get_ee_subsystem_id(struct ixgb_hw *hw);
+u16 ixgb_get_ee_subvendor_id(struct ixgb_hw *hw);
+u16 ixgb_get_ee_device_id(struct ixgb_hw *hw);
+u16 ixgb_get_ee_vendor_id(struct ixgb_hw *hw);
+u16 ixgb_get_ee_swdpins_reg(struct ixgb_hw *hw);
+u8 ixgb_get_ee_d3_power(struct ixgb_hw *hw);
+u8 ixgb_get_ee_d0_power(struct ixgb_hw *hw);
+boolean_t ixgb_get_eeprom_data(struct ixgb_hw *hw);
+
+/* Everything else */
+void ixgb_led_on(struct ixgb_hw *hw);
+void ixgb_led_off(struct ixgb_hw *hw);
+void ixgb_write_pci_cfg(struct ixgb_hw *hw, u32 reg, u16 * value);
+
+#endif				/* _IXGB_HW_H_ */
diff -Nru a/drivers/net/ixgb/ixgb_ids.h b/drivers/net/ixgb/ixgb_ids.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/net/ixgb/ixgb_ids.h	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,44 @@
+/*******************************************************************************
+
+  
+  Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
+  
+  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; either version 2 of the License, or (at your option) 
+  any later version.
+  
+  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.
+  
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59 
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+  
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+  
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+*******************************************************************************/
+
+#ifndef _IXGB_IDS_H_
+#define _IXGB_IDS_H_
+
+/**********************************************************************
+** The Device and Vendor IDs for 10 Gigabit MACs
+**********************************************************************/
+
+#define INTEL_VENDOR_ID         0x8086
+#define INTEL_SUBVENDOR_ID      0x8086
+
+#define IXGB_DEVICE_ID_82597EX 	0x1048
+#define IXGB_SUBDEVICE_ID_A11F  0xA11F	/* Adapter-OEM-1310nm-Fiber */
+#define IXGB_SUBDEVICE_ID_A01F	0xA01F	/* Adapter-Retail-1310nm-Fiber */
+
+#endif				/* #ifndef _IXGB_IDS_H_ */
+
+/* End of File */
diff -Nru a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/net/ixgb/ixgb_main.c	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,2350 @@
+/*******************************************************************************
+
+  
+  Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
+  
+  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; either version 2 of the License, or (at your option) 
+  any later version.
+  
+  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.
+  
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59 
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+  
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+  
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+*******************************************************************************/
+
+#define __IXGB_MAIN__
+
+#include "ixgb.h"
+
+char ixgb_driver_name[] = "ixgb";
+char ixgb_driver_string[] = "Intel(R) PRO/10GbE Network Driver";
+char ixgb_driver_version[] = "1.0.47-k1jg";
+char ixgb_copyright[] = "Copyright (c) 2001-2003 Intel Corporation.";
+
+/* ixgb_pci_tbl - PCI Device ID Table
+ *
+ * For selecting devices to load on private driver_data field (last one) 
+ * stores an index into ixgb_strings.
+ * Wildcard entries (PCI_ANY_ID) should come last
+ * Last entry must be all 0s
+ *
+ * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
+ *   Class, Class Mask, String Index }
+ */
+static struct pci_device_id ixgb_pci_tbl[] __devinitdata = {
+	/* Intel(R) PRO/10GbE Network Connection */
+	{INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX,
+	 INTEL_SUBVENDOR_ID, IXGB_SUBDEVICE_ID_A11F, 0, 0, 0},
+	{INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX,
+	 INTEL_SUBVENDOR_ID, IXGB_SUBDEVICE_ID_A01F, 0, 0, 0},
+	/* Generic */
+	{INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+
+	/* required last entry */
+	{0,}
+};
+
+MODULE_DEVICE_TABLE(pci, ixgb_pci_tbl);
+
+static char *ixgb_strings[] = {
+	"Intel(R) PRO/10GbE Network Connection"
+};
+
+/* Local Function Prototypes */
+
+int ixgb_up(struct ixgb_adapter *adapter);
+void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog);
+void ixgb_reset(struct ixgb_adapter *adapter);
+
+static int ixgb_init_module(void);
+static void ixgb_exit_module(void);
+static int ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
+static void ixgb_remove(struct pci_dev *pdev);
+static void ixgb_sw_init(struct ixgb_adapter *adapter);
+static int ixgb_open(struct net_device *netdev);
+static int ixgb_close(struct net_device *netdev);
+static int ixgb_setup_tx_resources(struct ixgb_adapter *adapter);
+static int ixgb_setup_rx_resources(struct ixgb_adapter *adapter);
+static void ixgb_configure_tx(struct ixgb_adapter *adapter);
+static void ixgb_configure_rx(struct ixgb_adapter *adapter);
+static void ixgb_setup_rctl(struct ixgb_adapter *adapter);
+static void ixgb_clean_tx_ring(struct ixgb_adapter *adapter);
+static void ixgb_clean_rx_ring(struct ixgb_adapter *adapter);
+static void ixgb_free_tx_resources(struct ixgb_adapter *adapter);
+static void ixgb_free_rx_resources(struct ixgb_adapter *adapter);
+static void ixgb_set_multi(struct net_device *netdev);
+static void ixgb_watchdog(unsigned long data);
+static inline boolean_t ixgb_tso(struct ixgb_adapter *adapter,
+				 struct sk_buff *skb);
+static int ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
+static void ixgb_tx_timeout(struct net_device *netdev);
+static void ixgb_tx_timeout_task(struct net_device *netdev);
+static void ixgb_vlan_rx_register(struct net_device *netdev,
+				  struct vlan_group *grp);
+static void ixgb_vlan_rx_add_vid(struct net_device *netdev, u16 vid);
+static void ixgb_vlan_rx_kill_vid(struct net_device *netdev, u16 vid);
+static void ixgb_restore_vlan(struct ixgb_adapter *adapter);
+static struct net_device_stats *ixgb_get_stats(struct net_device *netdev);
+static int ixgb_change_mtu(struct net_device *netdev, int new_mtu);
+static int ixgb_set_mac(struct net_device *netdev, void *p);
+static void ixgb_update_stats(struct ixgb_adapter *adapter);
+static inline void ixgb_irq_disable(struct ixgb_adapter *adapter);
+static inline void ixgb_irq_enable(struct ixgb_adapter *adapter);
+static irqreturn_t ixgb_intr(int irq, void *data, struct pt_regs *regs);
+static void ixgb_clean_tx_irq(struct ixgb_adapter *adapter);
+#ifdef CONFIG_IXGB_NAPI
+static int ixgb_poll(struct net_device *netdev, int *budget);
+#else
+static void ixgb_clean_rx_irq(struct ixgb_adapter *adapter);
+#endif
+static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter);
+static int ixgb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
+static inline void ixgb_rx_checksum(struct ixgb_adapter *adapter,
+				    struct ixgb_rx_desc *rx_desc,
+				    struct sk_buff *skb);
+static int ixgb_notify_reboot(struct notifier_block *, unsigned long event,
+			      void *ptr);
+static int ixgb_suspend(struct pci_dev *pdev, u32 state);
+
+struct notifier_block ixgb_notifier_reboot = {
+	.notifier_call	= ixgb_notify_reboot,
+	.next		= NULL,
+	.priority	= 0
+};
+
+/* Exported from other modules */
+
+extern void ixgb_check_options(struct ixgb_adapter *adapter);
+extern int ixgb_ethtool_ioctl(struct net_device *netdev, struct ifreq *ifr);
+
+static struct pci_driver ixgb_driver = {
+	.name		= ixgb_driver_name,
+	.id_table	= ixgb_pci_tbl,
+	.probe		= ixgb_probe,
+	.remove		= __devexit_p(ixgb_remove),
+	/* Power Managment Hooks */
+	.suspend	= NULL,
+	.resume		= NULL
+};
+
+MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
+MODULE_DESCRIPTION("Intel(R) PRO/10GbE Network Driver");
+MODULE_LICENSE("GPL");
+
+/* some defines for controlling descriptor fetches in h/w */
+#define RXDCTL_PTHRESH_DEFAULT 128	/* chip considers prefech below this */
+#define RXDCTL_HTHRESH_DEFAULT 16	/* chip will only prefetch if tail is 
+					   pushed this many descriptors from head */
+#define RXDCTL_WTHRESH_DEFAULT 16	/* chip writes back at this many or RXT0 */
+
+/**
+ * ixgb_init_module - Driver Registration Routine.
+ *
+ * ixgb_init_module is the first routine called when the driver is
+ * loaded. All it does is register with the PCI subsystem.
+ **/
+
+static int __init
+ixgb_init_module(void)
+{
+	int ret;
+	IXGB_DBG("ixgb_init_module\n");
+
+	printk(KERN_INFO "%s - version %s\n", ixgb_driver_string,
+	       ixgb_driver_version);
+	printk(KERN_INFO "%s\n", ixgb_copyright);
+#ifdef CONFIG_IXGB_NAPI
+	printk(KERN_INFO "NAPI Enabled\n");
+#endif
+	ret = pci_module_init(&ixgb_driver);
+	if (ret >= 0) {
+		register_reboot_notifier(&ixgb_notifier_reboot);
+	}
+	return ret;
+}
+
+module_init(ixgb_init_module);
+
+/**
+ * ixgb_exit_module - Driver Exit Cleanup Routine.
+ *
+ * ixgb_exit_module is called just before the driver is removed
+ * from memory.
+ **/
+
+static void __exit
+ixgb_exit_module(void)
+{
+
+	IXGB_DBG("ixgb_exit_module\n");
+	unregister_reboot_notifier(&ixgb_notifier_reboot);
+	pci_unregister_driver(&ixgb_driver);
+}
+
+module_exit(ixgb_exit_module);
+
+/**
+ * ixgb_up - Driver ifconfig UP routine.
+ *
+ * ixgb_up is called to initialize and bring online an interface.
+ * @param adapter board private structure
+ **/
+
+int
+ixgb_up(struct ixgb_adapter *adapter)
+{
+	struct net_device *netdev = adapter->netdev;
+
+	IXGB_DBG("ixgb_up\n");
+
+	if (request_irq(netdev->irq, &ixgb_intr, SA_SHIRQ | SA_SAMPLE_RANDOM,
+			netdev->name, netdev)) {
+		IXGB_DBG("%s: request_irq failed\n", netdev->name);
+		return -1;
+	}
+	/* disable interrupts and get the hardware into a known state */
+	IXGB_WRITE_REG(&adapter->hw, IMC, 0xffffffff);
+
+	/* hardware was reset in probe/down, we need to reload some things */
+	ixgb_set_multi(netdev);
+	ixgb_restore_vlan(adapter);
+
+	ixgb_configure_tx(adapter);
+	ixgb_setup_rctl(adapter);
+	ixgb_configure_rx(adapter);
+	ixgb_alloc_rx_buffers(adapter);
+
+	mod_timer(&adapter->watchdog_timer, jiffies);
+	ixgb_irq_enable(adapter);
+
+	IXGB_DBG("ixgb_up: RAH_0 is <%x>\n", IXGB_READ_REG(&adapter->hw, RAH));
+	IXGB_DBG("ixgb_up: RDBAL is <%x>\n",
+		 IXGB_READ_REG(&adapter->hw, RDBAL));
+	return 0;
+}
+
+/**
+ * ixgb_down - Driver ifconfig DOWN routine.
+ *
+ * ixgb_down is called to uninitialize and take offline an interface.
+ * @param adapter board private structure
+ * @param kill_watchdog
+ **/
+void
+ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog)
+{
+	struct net_device *netdev = adapter->netdev;
+
+	IXGB_DBG("ixgb_down\n");
+
+	ixgb_irq_disable(adapter);
+	free_irq(netdev->irq, netdev);
+	if (kill_watchdog)
+		del_timer_sync(&adapter->watchdog_timer);
+	adapter->link_speed = 0;
+	adapter->link_duplex = 0;
+	netif_carrier_off(netdev);
+	netif_stop_queue(netdev);
+
+	ixgb_reset(adapter);
+
+	ixgb_clean_tx_ring(adapter);
+	ixgb_clean_rx_ring(adapter);
+}
+
+/**
+ * ixgb_reset - hardware reset.
+ *
+ * ixgb_reset is called to initialize hardware to a known state.
+ * @param adapter board private structure
+ **/
+void
+ixgb_reset(struct ixgb_adapter *adapter)
+{
+	IXGB_DBG("ixgb_reset\n");
+
+	ixgb_adapter_stop(&adapter->hw);
+	if (!ixgb_init_hw(&adapter->hw))
+		IXGB_DBG("ixgb_init_hw failed.\n");
+}
+
+/**
+ * ixgb_probe - Device Initialization Routine.
+ * @param pdev PCI device information struct
+ * @param ent entry in ixgb_pci_table
+ *
+ * Returns 0 on success, negative on failure
+ **/
+
+static int __devinit
+ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+	struct net_device *netdev = NULL;
+	struct ixgb_adapter *adapter;
+	static int cards_found = 0;
+	unsigned long mmio_start;
+	int mmio_len;
+	int pci_using_dac;
+	int i;
+
+	IXGB_DBG("ixgb_probe\n");
+
+	if ((i = pci_enable_device(pdev))) {
+		IXGB_ERR("pci_enable_device failed\n");
+		return i;
+	}
+
+	if (!(i = pci_set_dma_mask(pdev, PCI_DMA_64BIT))) {
+		pci_using_dac = 1;
+	} else {
+		if ((i = pci_set_dma_mask(pdev, PCI_DMA_32BIT))) {
+			IXGB_ERR("No usable DMA configuration, aborting\n");
+			return i;
+		}
+		pci_using_dac = 0;
+	}
+
+	if ((i = pci_request_regions(pdev, ixgb_driver_name))) {
+		IXGB_ERR("Failed to reserve PCI I/O and Memory resources.\n");
+		return i;
+	}
+
+	pci_set_master(pdev);
+
+	/* alloc_etherdev clears the memory for us */
+	netdev = alloc_etherdev(sizeof (struct ixgb_adapter));
+	if (!netdev) {
+		IXGB_ERR("Unable to allocate net_device struct\n");
+		goto err_alloc_etherdev;
+	}
+
+	SET_MODULE_OWNER(netdev);
+
+	pci_set_drvdata(pdev, netdev);
+	adapter = netdev->priv;
+	adapter->netdev = netdev;
+	adapter->pdev = pdev;
+	adapter->hw.back = adapter;
+
+	mmio_start = pci_resource_start(pdev, BAR_0);
+	mmio_len = pci_resource_len(pdev, BAR_0);
+
+	adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
+	if (!adapter->hw.hw_addr)
+		goto err_ioremap;
+
+	for (i = BAR_1; i <= BAR_5; i++) {
+		if (pci_resource_len(pdev, i) == 0)
+			continue;
+		if (pci_resource_flags(pdev, i) & IORESOURCE_IO) {
+			adapter->hw.io_base = pci_resource_start(pdev, i);
+			break;
+		}
+	}
+	IXGB_DBG("mmio_start<%lx> hw_addr<%p>\n", mmio_start,
+		 adapter->hw.hw_addr);
+
+	netdev->open = &ixgb_open;
+	netdev->stop = &ixgb_close;
+	netdev->hard_start_xmit = &ixgb_xmit_frame;
+	netdev->get_stats = &ixgb_get_stats;
+	netdev->set_multicast_list = &ixgb_set_multi;
+	netdev->set_mac_address = &ixgb_set_mac;
+	netdev->change_mtu = &ixgb_change_mtu;
+	netdev->do_ioctl = &ixgb_ioctl;
+	netdev->tx_timeout = &ixgb_tx_timeout;
+	netdev->watchdog_timeo = HZ;
+#ifdef CONFIG_IXGB_NAPI
+	netdev->poll = &ixgb_poll;
+	netdev->weight = 64;
+#endif
+	netdev->vlan_rx_register = ixgb_vlan_rx_register;
+	netdev->vlan_rx_add_vid = ixgb_vlan_rx_add_vid;
+	netdev->vlan_rx_kill_vid = ixgb_vlan_rx_kill_vid;
+
+	netdev->irq = pdev->irq;
+	netdev->mem_start = mmio_start;
+	netdev->mem_end = mmio_start + mmio_len;
+	netdev->base_addr = adapter->hw.io_base;
+
+	adapter->bd_number = cards_found;
+	adapter->id_string = ixgb_strings[ent->driver_data];
+	adapter->link_speed = 0;
+	adapter->link_duplex = 0;
+
+	/* setup the private structure */
+	ixgb_sw_init(adapter);
+
+	netdev->features = NETIF_F_SG |
+	    NETIF_F_HW_CSUM |
+	    NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER;
+#ifdef NETIF_F_TSO
+	netdev->features |= NETIF_F_TSO;
+#endif
+
+	if (pci_using_dac)
+		netdev->features |= NETIF_F_HIGHDMA;
+
+	/* make sure the EEPROM is good */
+
+	if (!ixgb_validate_eeprom_checksum(&adapter->hw)) {
+		IXGB_DBG("Invalid EEPROM checksum.\n");
+		goto err_eeprom;
+	}
+
+	ixgb_get_ee_mac_addr(&adapter->hw, netdev->dev_addr);
+
+	if (!is_valid_ether_addr(netdev->dev_addr)) {
+		IXGB_DBG("Invalid MAC address in EEPROM.\n");
+		goto err_eeprom;
+	}
+
+	adapter->max_data_per_txd = IXGB_MAX_JUMBO_FRAME_SIZE;
+	adapter->part_num = ixgb_get_ee_pba_number(&adapter->hw);
+
+	init_timer(&adapter->watchdog_timer);
+	adapter->watchdog_timer.function = &ixgb_watchdog;
+	adapter->watchdog_timer.data = (unsigned long) adapter;
+
+	INIT_WORK(&adapter->tx_timeout_task,
+		  (void (*)(void *)) ixgb_tx_timeout_task, netdev);
+
+	register_netdev(netdev);
+	memcpy(adapter->ifname, netdev->name, IFNAMSIZ);
+	adapter->ifname[IFNAMSIZ - 1] = 0;
+
+	/* we're going to reset, so assume we have no link for now */
+
+	netif_carrier_off(netdev);
+	netif_stop_queue(netdev);
+
+	printk(KERN_INFO "%s: %s\n", netdev->name, adapter->id_string);
+	ixgb_check_options(adapter);
+
+	/* reset the hardware with the new settings */
+	ixgb_reset(adapter);
+
+	cards_found++;
+	return 0;
+
+      err_eeprom:
+	iounmap(adapter->hw.hw_addr);
+      err_ioremap:
+	pci_release_regions(pdev);
+	kfree(netdev);
+      err_alloc_etherdev:
+	return -ENOMEM;
+}
+
+/**
+ * ixgb_remove - Device Removal Routine.
+ * @param pdev PCI device information struct
+ *
+ * ixgb_remove is called by the PCI subsystem to alert the driver
+ * that it should release a PCI device.  The could be caused by a
+ * Hot-Plug event, or because the driver is going to be removed from
+ * memory.
+ **/
+
+static void __devexit
+ixgb_remove(struct pci_dev *pdev)
+{
+	struct net_device *netdev = pci_get_drvdata(pdev);
+	struct ixgb_adapter *adapter = netdev->priv;
+
+	IXGB_DBG("ixgb_remove\n");
+
+	unregister_netdev(netdev);
+
+#ifdef ETHTOOL_IDENTIFY
+	ixgb_identify_stop(adapter);
+#endif
+
+	iounmap((void *) adapter->hw.hw_addr);
+	pci_release_regions(pdev);
+
+	kfree(netdev);
+}
+
+/**
+ * ixgb_sw_init - Initialize general software structures (struct ixgb_adapter).
+ * @param adapter board private structure to initialize
+ *
+ * ixgb_sw_init initializes the adapter private data structure.
+ * Fields are initialized based on PCI device information and
+ * OS network device settings (MTU size).
+ **/
+
+static void __devinit
+ixgb_sw_init(struct ixgb_adapter *adapter)
+{
+	struct ixgb_hw *hw = &adapter->hw;
+	struct net_device *netdev = adapter->netdev;
+	struct pci_dev *pdev = adapter->pdev;
+
+	IXGB_DBG("ixgb_sw_init\n");
+
+	/* PCI config space info */
+
+	/* FIXME: do not store, instead directly use struct pci_dev
+	 * where needed
+	 */
+	hw->vendor_id = pdev->vendor;
+	hw->device_id = pdev->device;
+	hw->subsystem_vendor_id = pdev->subsystem_vendor;
+	hw->subsystem_id = pdev->subsystem_device;
+
+	adapter->rx_buffer_len = IXGB_RXBUFFER_2048;
+
+	hw->max_frame_size = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
+
+	if (hw->device_id == IXGB_DEVICE_ID_82597EX)
+		hw->mac_type = ixgb_82597;
+	else {
+		/* should never have loaded on this device */
+		printk(KERN_ERR "ixgb: unsupported device id\n");
+	}
+
+	/* enable flow control to be programmed */
+	hw->fc.send_xon = 1;
+
+	atomic_set(&adapter->irq_sem, 1);
+}
+
+/**
+ * ixgb_open - Called when a network interface is made active.
+ * @param netdev network interface device structure
+ *
+ * Returns 0 on success, negative value on failure
+ *
+ * The open entry point is called when a network interface is made
+ * active by the system (IFF_UP).  At this point all resources needed
+ * for transmit and receive operations are allocated, the interrupt
+ * handler is registered with the OS, the watchdog timer is started,
+ * and the stack is notified that the interface is ready.
+ **/
+
+static int
+ixgb_open(struct net_device *netdev)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+
+	IXGB_DBG("ixgb_open\n");
+
+	/* allocate transmit descriptors */
+
+	if (ixgb_setup_tx_resources(adapter)) {
+		IXGB_DBG("ixgb_open: failed ixgb_setup_tx_resources.\n");
+		goto err_setup_tx;
+	}
+
+	/* allocate receive descriptors and buffers */
+
+	if (ixgb_setup_rx_resources(adapter)) {
+		IXGB_DBG("ixgb_open: failed ixgb_setup_rx_resources.\n");
+		goto err_setup_rx;
+	}
+	if (ixgb_up(adapter))
+		goto err_up;
+
+	return 0;
+
+      err_up:
+	ixgb_free_rx_resources(adapter);
+      err_setup_rx:
+	ixgb_free_tx_resources(adapter);
+      err_setup_tx:
+	ixgb_reset(adapter);
+	return -EBUSY;
+}
+
+/**
+ * ixgb_close - Disables a network interface.
+ * @param netdev network interface device structure
+ *
+ * Returns 0, this is not allowed to fail
+ *
+ * The close entry point is called when an interface is de-activated
+ * by the OS.  The hardware is still under the drivers control, but
+ * needs to be disabled.  A global MAC reset is issued to stop the
+ * hardware, and all transmit and receive resources are freed.
+ **/
+
+static int
+ixgb_close(struct net_device *netdev)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+
+	IXGB_DBG("ixgb_close\n");
+
+	ixgb_down(adapter, TRUE);
+
+	ixgb_free_tx_resources(adapter);
+	ixgb_free_rx_resources(adapter);
+
+	return 0;
+}
+
+/**
+ * ixgb_setup_tx_resources - allocate Tx resources (Descriptors).
+ * @param adapter board private structure
+ *
+ * Return 0 on success, negative on failure
+ **/
+
+static int
+ixgb_setup_tx_resources(struct ixgb_adapter *adapter)
+{
+	struct pci_dev *pdev = adapter->pdev;
+	struct ixgb_desc_ring *txdr = &adapter->tx_ring;
+	int size;
+
+	IXGB_DBG("ixgb_setup_tx_resources\n");
+
+	size = sizeof (struct ixgb_buffer) * txdr->count;
+	txdr->buffer_info = kmalloc(size, GFP_KERNEL);
+	if (!txdr->buffer_info) {
+		return -ENOMEM;
+	}
+	memset(txdr->buffer_info, 0, size);
+
+	/* round up to nearest 4K */
+	txdr->size = txdr->count * sizeof (struct ixgb_tx_desc);
+	IXGB_ROUNDUP(txdr->size, 4096);
+
+	txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
+	if (!txdr->desc) {
+		kfree(txdr->buffer_info);
+		return -ENOMEM;
+	}
+	memset(txdr->desc, 0, txdr->size);
+
+	IXGB_DBG("txdr->desc <%p>\n", txdr->desc);
+	IXGB_DBG("txdr->next_to_use = <%p>\n", &txdr->next_to_use);
+	IXGB_DBG("txdr->next_to_clean = <%p>\n", &txdr->next_to_clean);
+
+	txdr->next_to_use = 0;
+	txdr->next_to_clean = 0;
+
+	return 0;
+}
+
+/**
+ * ixgb_configure_tx - Configure 82597 Transmit Unit after Reset.
+ * @adapter board private structure
+ *
+ * Configure the Tx unit of the MAC after a reset.
+ **/
+
+static void
+ixgb_configure_tx(struct ixgb_adapter *adapter)
+{
+	u32 tctl;
+	u32 tdlen = adapter->tx_ring.count * sizeof (struct ixgb_tx_desc);
+	uint64_t tdba = adapter->tx_ring.dma;
+	struct ixgb_hw *hw = &adapter->hw;
+
+	IXGB_DBG("ixgb_configure_tx\n");
+
+	/* Setup the Base and Length of the Tx Descriptor Ring 
+	 * tx_ring.dma can be either a 32 or 64 bit value 
+	 */
+
+	IXGB_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
+	IXGB_WRITE_REG(hw, TDBAH, (tdba >> 32));
+
+	IXGB_WRITE_REG(hw, TDLEN, tdlen);
+
+	/* Setup the HW Tx Head and Tail descriptor pointers */
+
+	IXGB_WRITE_REG(hw, TDH, 0);
+	IXGB_WRITE_REG(hw, TDT, 0);
+
+	/* don't set up txdctl, it induces performance problems if
+	 * configured incorrectly
+	 txdctl  = TXDCTL_PTHRESH_DEFAULT; // prefetch txds below this threshold
+	 txdctl |= (TXDCTL_HTHRESH_DEFAULT // only prefetch if there are this many ready
+	 << IXGB_TXDCTL_HTHRESH_SHIFT);
+	 IXGB_WRITE_REG (hw, TXDCTL, txdctl);
+	 */
+
+	/* Set the Tx Interrupt Delay register */
+
+	IXGB_WRITE_REG(hw, TIDV, adapter->tx_int_delay);
+
+	/* Program the Transmit Control Register */
+
+	tctl = IXGB_TCTL_TCE | IXGB_TCTL_TXEN | IXGB_TCTL_TPDE;
+	IXGB_WRITE_REG(hw, TCTL, tctl);
+
+	/* Setup Transmit Descriptor Settings for this adapter */
+	adapter->tx_cmd_type =
+	    IXGB_TX_DESC_TYPE | IXGB_TX_DESC_CMD_RS
+	    | (adapter->tx_int_delay_enable ? IXGB_TX_DESC_CMD_IDE : 0);
+}
+
+/**
+ * ixgb_setup_rx_resources - allocate Rx resources (Descriptors).
+ * @param adapter board private structure
+ * 
+ * Returns 0 on success, negative on failure
+ **/
+
+static int
+ixgb_setup_rx_resources(struct ixgb_adapter *adapter)
+{
+	struct pci_dev *pdev = adapter->pdev;
+	struct ixgb_desc_ring *rxdr = &adapter->rx_ring;
+	int size;
+
+	IXGB_DBG("ixgb_setup_rx_resources.\n");
+
+	size = sizeof (struct ixgb_buffer) * rxdr->count;
+	rxdr->buffer_info = kmalloc(size, GFP_KERNEL);
+	if (!rxdr->buffer_info) {
+		return -ENOMEM;
+	}
+	memset(rxdr->buffer_info, 0, size);
+
+	/* Round up to nearest 4K */
+	rxdr->size = rxdr->count * sizeof (struct ixgb_rx_desc);
+	IXGB_ROUNDUP(rxdr->size, 4096);
+
+	rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
+
+	if (!rxdr->desc) {
+		IXGB_DBG("pci_alloc_consistent failed.\n");
+		kfree(rxdr->buffer_info);
+		return -ENOMEM;
+	}
+	memset(rxdr->desc, 0, rxdr->size);
+
+	IXGB_DBG("rxdr->desc <%p>\n", rxdr->desc);
+	IXGB_DBG("rxdr->next_to_use = <%p>\n", &rxdr->next_to_use);
+	IXGB_DBG("rxdr->next_to_clean = <%p>\n", &rxdr->next_to_clean);
+
+	rxdr->next_to_use = 0;
+	rxdr->next_to_clean = 0;
+
+	return 0;
+}
+
+/**
+ * ixgb_setup_rctl - configure the receive control register.
+ * @param adapter Board private structure
+ **/
+
+static void
+ixgb_setup_rctl(struct ixgb_adapter *adapter)
+{
+	u32 rctl;
+
+	rctl = IXGB_READ_REG(&adapter->hw, RCTL);
+
+	IXGB_DBG("ixgb_setup_rctl\n");
+
+	rctl &= ~(3 << IXGB_RCTL_MO_SHIFT);
+
+	rctl |=
+	    IXGB_RCTL_BAM | IXGB_RCTL_RDMTS_1_2 |
+	    IXGB_RCTL_RXEN | IXGB_RCTL_CFF |
+	    (adapter->hw.mc_filter_type << IXGB_RCTL_MO_SHIFT);
+
+	rctl |= IXGB_RCTL_SECRC;
+
+	switch (adapter->rx_buffer_len) {
+	case IXGB_RXBUFFER_2048:
+	default:
+		rctl |= IXGB_RCTL_BSIZE_2048;
+		break;
+	case IXGB_RXBUFFER_4096:
+		rctl |= IXGB_RCTL_BSIZE_4096;
+		break;
+	case IXGB_RXBUFFER_8192:
+		rctl |= IXGB_RCTL_BSIZE_8192;
+		break;
+	case IXGB_RXBUFFER_16384:
+		rctl |= IXGB_RCTL_BSIZE_16384;
+		break;
+	}
+	IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
+}
+
+/**
+ * ixgb_configure_rx - Configure 82597 Receive Unit after Reset.
+ * @param adapter board private structure
+ *
+ * Configure the Rx unit of the MAC after a reset.
+ **/
+
+static void
+ixgb_configure_rx(struct ixgb_adapter *adapter)
+{
+	uint64_t rdba = adapter->rx_ring.dma;
+	u32 rdlen = adapter->rx_ring.count * sizeof (struct ixgb_rx_desc);
+	struct ixgb_hw *hw = &adapter->hw;
+	u32 rctl;
+	u32 rxcsum;
+
+	IXGB_DBG("ixgb_configure_rx\n");
+
+	/* make sure receives are disabled while setting up the descriptors */
+	rctl = IXGB_READ_REG(hw, RCTL);
+	IXGB_WRITE_REG(hw, RCTL, rctl & ~IXGB_RCTL_RXEN);
+
+	/* set the Receive Delay Timer Register */
+	IXGB_WRITE_REG(hw, RDTR, adapter->rx_int_delay);
+
+	/* Setup the Base and Length of the Rx Descriptor Ring */
+	IXGB_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL));
+	IXGB_WRITE_REG(hw, RDBAH, (rdba >> 32));
+
+	IXGB_WRITE_REG(hw, RDLEN, rdlen);
+
+	/* Setup the HW Rx Head and Tail Descriptor Pointers */
+	IXGB_WRITE_REG(hw, RDH, 0);
+	IXGB_WRITE_REG(hw, RDT, 0);
+
+	{
+		u32 rxdctl;
+		/* burst 16 or burst when RXT0 */
+		rxdctl = RXDCTL_WTHRESH_DEFAULT << IXGB_RXDCTL_WTHRESH_SHIFT
+		    | RXDCTL_HTHRESH_DEFAULT << IXGB_RXDCTL_HTHRESH_SHIFT
+		    | RXDCTL_PTHRESH_DEFAULT << IXGB_RXDCTL_PTHRESH_SHIFT;
+		IXGB_WRITE_REG(hw, RXDCTL, rxdctl);
+	}
+
+	if (adapter->raidc) {
+		u32 raidc;
+		u8 poll_threshold;
+
+		/* Poll every rx_int_delay period, if RBD exists
+		 * Receive Backlog Detection is set to <threshold> 
+		 * Rx Descriptors
+		 * max is 0x3F == set to poll when 504 RxDesc left 
+		 * min is 0 */
+
+		/* polling times are 1 == 0.8192us
+		   2 == 1.6384us
+		   3 == 3.2768us etc
+		   ...
+		   511 == 418 us
+		 */
+#define IXGB_RAIDC_POLL_DEFAULT 122	/* set to poll every ~100 us under load 
+					   also known as 10000 interrupts / sec */
+
+		/* divide this by 2^3 (8) to get a register size count */
+		poll_threshold = ((adapter->rx_ring.count - 1) >> 3);
+		/* poll at half of that size */
+		poll_threshold >>= 1;
+		/* make sure its not bigger than our max */
+		poll_threshold &= 0x3F;
+
+		raidc = IXGB_RAIDC_EN |	/* turn on raidc style moderation */
+		    IXGB_RAIDC_RXT_GATE |	/* don't interrupt with rxt0 while
+						   in RBD mode (polling) */
+		    (IXGB_RAIDC_POLL_DEFAULT << IXGB_RAIDC_POLL_SHIFT) |
+		    /* this sets the regular "min interrupt delay" */
+		    (adapter->rx_int_delay << IXGB_RAIDC_DELAY_SHIFT) |
+		    poll_threshold;
+
+		IXGB_WRITE_REG(hw, RAIDC, raidc);
+	}
+
+	/* Enable Receive Checksum Offload for TCP and UDP */
+	if (adapter->rx_csum == TRUE) {
+		rxcsum = IXGB_READ_REG(hw, RXCSUM);
+		rxcsum |= IXGB_RXCSUM_TUOFL;
+		IXGB_WRITE_REG(hw, RXCSUM, rxcsum);
+	}
+
+	/* Enable Receives */
+
+	IXGB_WRITE_REG(hw, RCTL, rctl);
+}
+
+/**
+ * ixgb_free_tx_resources - Free Tx Resources.
+ * @param adapter board private structure
+ *
+ * Free all transmit software resources
+ **/
+
+static void
+ixgb_free_tx_resources(struct ixgb_adapter *adapter)
+{
+	struct pci_dev *pdev = adapter->pdev;
+
+	IXGB_DBG("ixgb_free_tx_resources\n");
+
+	ixgb_clean_tx_ring(adapter);
+
+	kfree(adapter->tx_ring.buffer_info);
+	adapter->tx_ring.buffer_info = NULL;
+
+	pci_free_consistent(pdev, adapter->tx_ring.size, adapter->tx_ring.desc,
+			    adapter->tx_ring.dma);
+
+	adapter->tx_ring.desc = NULL;
+}
+
+/**
+ * ixgb_clean_tx_ring - Free Tx Buffers.
+ * @param adapter board private structure
+ **/
+
+static void
+ixgb_clean_tx_ring(struct ixgb_adapter *adapter)
+{
+	struct pci_dev *pdev = adapter->pdev;
+	unsigned long size;
+	int i;
+
+	IXGB_DBG("ixgb_clean_tx_ring\n");
+
+	/* Free all the Tx ring sk_buffs */
+
+	for (i = 0; i < adapter->tx_ring.count; i++) {
+		if (adapter->tx_ring.buffer_info[i].skb) {
+
+			pci_unmap_page(pdev,
+				       adapter->tx_ring.buffer_info[i].dma,
+				       adapter->tx_ring.buffer_info[i].length,
+				       PCI_DMA_TODEVICE);
+
+			dev_kfree_skb(adapter->tx_ring.buffer_info[i].skb);
+
+			adapter->tx_ring.buffer_info[i].skb = NULL;
+		}
+	}
+
+	size = sizeof (struct ixgb_buffer) * adapter->tx_ring.count;
+	memset(adapter->tx_ring.buffer_info, 0, size);
+
+	/* Zero out the descriptor ring */
+
+	memset(adapter->tx_ring.desc, 0, adapter->tx_ring.size);
+
+	adapter->tx_ring.next_to_use = 0;
+	adapter->tx_ring.next_to_clean = 0;
+
+	IXGB_WRITE_REG(&adapter->hw, TDH, 0);
+	IXGB_WRITE_REG(&adapter->hw, TDT, 0);
+}
+
+/**
+ * ixgb_free_rx_resources - Free Rx Resources.
+ * @param adapter board private structure
+ *
+ * Free all receive software resources
+ **/
+
+static void
+ixgb_free_rx_resources(struct ixgb_adapter *adapter)
+{
+	struct pci_dev *pdev = adapter->pdev;
+
+	IXGB_DBG("ixgb_free_rx_resources\n");
+
+	ixgb_clean_rx_ring(adapter);
+
+	kfree(adapter->rx_ring.buffer_info);
+	adapter->rx_ring.buffer_info = NULL;
+
+	pci_free_consistent(pdev, adapter->rx_ring.size,
+			    adapter->rx_ring.desc, adapter->rx_ring.dma);
+
+	adapter->rx_ring.desc = NULL;
+}
+
+/**
+ * ixgb_clean_rx_ring - Free Rx Buffers.
+ * @param adapter board private structure
+ **/
+
+static void
+ixgb_clean_rx_ring(struct ixgb_adapter *adapter)
+{
+	struct pci_dev *pdev = adapter->pdev;
+	unsigned long size;
+	int i;
+
+	IXGB_DBG("ixgb_free_rx_ring\n");
+
+	/* Free all the Rx ring sk_buffs */
+
+	for (i = 0; i < adapter->rx_ring.count; i++) {
+		if (adapter->rx_ring.buffer_info[i].skb) {
+
+			pci_unmap_single(pdev,
+					 adapter->rx_ring.buffer_info[i].dma,
+					 adapter->rx_ring.buffer_info[i].length,
+					 PCI_DMA_FROMDEVICE);
+
+			dev_kfree_skb(adapter->rx_ring.buffer_info[i].skb);
+
+			adapter->rx_ring.buffer_info[i].skb = NULL;
+		}
+	}
+
+	size = sizeof (struct ixgb_buffer) * adapter->rx_ring.count;
+	memset(adapter->rx_ring.buffer_info, 0, size);
+
+	/* Zero out the descriptor ring */
+
+	memset(adapter->rx_ring.desc, 0, adapter->rx_ring.size);
+
+	adapter->rx_ring.next_to_clean = 0;
+	adapter->rx_ring.next_to_use = 0;
+
+	IXGB_WRITE_REG(&adapter->hw, RDH, 0);
+	IXGB_WRITE_REG(&adapter->hw, RDT, 0);
+}
+
+/**
+ * ixgb_set_multi - Multicast and Promiscuous mode set.
+ * @param netdev network interface device structure
+ *
+ * The set_multi entry point is called whenever the multicast address
+ * list or the network interface flags are updated.  This routine is
+ * resposible for configuring the hardware for proper multicast,
+ * promiscuous mode, and all-multi behavior.
+ **/
+
+void
+ixgb_set_multi(struct net_device *netdev)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+	struct ixgb_hw *hw = &adapter->hw;
+	u32 rctl;
+	int i;
+	struct dev_mc_list *mc_ptr;
+
+	IXGB_DBG("ixgb_set_multi <%x>\n", netdev->flags);
+
+	/* Check for Promiscuous and All Multicast modes */
+
+	rctl = IXGB_READ_REG(&adapter->hw, RCTL);
+
+	if (netdev->flags & IFF_PROMISC) {
+		rctl |= (IXGB_RCTL_UPE | IXGB_RCTL_MPE);
+	} else if (netdev->flags & IFF_ALLMULTI) {
+		rctl |= IXGB_RCTL_MPE;
+		rctl &= ~IXGB_RCTL_UPE;
+	} else {
+		rctl &= ~(IXGB_RCTL_UPE | IXGB_RCTL_MPE);
+	}
+
+	if (netdev->mc_count > IXGB_MAX_NUM_MULTICAST_ADDRESSES) {
+		rctl |= IXGB_RCTL_MPE;
+		IXGB_WRITE_REG(hw, RCTL, rctl);
+	} else {
+		u8 mta[netdev->mc_count * IXGB_ETH_LENGTH_OF_ADDRESS];
+
+		IXGB_WRITE_REG(hw, RCTL, rctl);
+
+		for (i = 0, mc_ptr = netdev->mc_list; mc_ptr;
+		     i++, mc_ptr = mc_ptr->next)
+			memcpy(&mta[i * IXGB_ETH_LENGTH_OF_ADDRESS],
+			       mc_ptr->dmi_addr, IXGB_ETH_LENGTH_OF_ADDRESS);
+
+		ixgb_mc_addr_list_update(hw, mta, netdev->mc_count, 0);
+	}
+}
+
+/**
+ * ixgb_watchdog - Timer Call-back.
+ * @param data pointer to adapter cast into an unsigned long
+ **/
+
+void
+ixgb_watchdog(unsigned long data)
+{
+	struct ixgb_adapter *adapter = (struct ixgb_adapter *) data;
+	struct net_device *netdev = adapter->netdev;
+
+	ixgb_check_for_link(&adapter->hw);
+
+	if (ixgb_check_for_bad_link(&adapter->hw)) {
+		/* force the reset path */
+		netif_stop_queue(netdev);
+	}
+
+	if (adapter->hw.link_up) {
+		if (!netif_carrier_ok(netdev)) {
+			printk(KERN_INFO "ixgb: %s NIC Link is Up %d Mbps %s\n",
+			       netdev->name, 10000, "Full Duplex");
+			adapter->link_speed = 10000;
+			adapter->link_duplex = FULL_DUPLEX;
+			netif_carrier_on(netdev);
+			netif_wake_queue(netdev);
+		}
+	} else {
+		if (netif_carrier_ok(netdev)) {
+			printk(KERN_INFO "ixgb: %s NIC Link is Down\n",
+			       netdev->name);
+			adapter->link_speed = 0;
+			adapter->link_duplex = 0;
+			netif_carrier_off(netdev);
+			netif_stop_queue(netdev);
+
+			ixgb_down(adapter, FALSE);
+			ixgb_up(adapter);
+		}
+	}
+
+	ixgb_update_stats(adapter);
+
+	/* Early detection of hung controller */
+	{
+		struct ixgb_desc_ring *txdr = &adapter->tx_ring;
+		int i = txdr->next_to_clean;
+
+		if (txdr->buffer_info[i].dma &&
+		    time_after(jiffies, txdr->buffer_info[i].time_stamp + HZ) &&
+		    !(IXGB_READ_REG(&adapter->hw, STATUS) & IXGB_STATUS_TXOFF))
+		{
+			IXGB_DBG
+			    ("ixgb: %s Hung controller? Watchdog stopping queue\n",
+			     netdev->name);
+			netif_stop_queue(netdev);
+		}
+	}
+
+	/* generate an interrupt to force clean up of any stragglers */
+	IXGB_WRITE_REG(&adapter->hw, ICS, IXGB_INT_TXDW);
+
+	/* Reset the timer */
+	mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
+}
+
+#define IXGB_TX_FLAGS_CSUM	0x00000001
+#define IXGB_TX_FLAGS_VLAN	0x00000002
+#define IXGB_TX_FLAGS_TSO	0x00000004
+
+/** Transmit Segmentation offload setup.
+ * ixgb_tso - (Large Send) setup where the initial descriptor is prepared
+ * @param adapter adapter specific information
+ * @param skb the skb we are trying to set up for segmentation
+ **/
+
+static inline boolean_t
+ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
+{
+#ifdef NETIF_F_TSO
+	struct ixgb_context_desc *context_desc;
+	int i;
+	u8 ipcss, ipcso, tucss, tucso, hdr_len;
+	u16 ipcse, tucse, mss;
+
+	if (likely(skb_shinfo(skb)->tso_size)) {
+		hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
+		mss = skb_shinfo(skb)->tso_size;
+		skb->nh.iph->tot_len = 0;
+		skb->nh.iph->check = 0;
+		skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr,
+						      skb->nh.iph->daddr,
+						      0, IPPROTO_TCP, 0);
+		ipcss = skb->nh.raw - skb->data;
+		ipcso = (void *) &(skb->nh.iph->check) - (void *) skb->data;
+		ipcse = skb->h.raw - skb->data - 1;
+		tucss = skb->h.raw - skb->data;
+		tucso = (void *) &(skb->h.th->check) - (void *) skb->data;
+		tucse = 0;
+
+		i = adapter->tx_ring.next_to_use;
+		context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i);
+
+		context_desc->ipcss = ipcss;
+		context_desc->ipcso = ipcso;
+		context_desc->ipcse = cpu_to_le16(ipcse);
+		context_desc->tucss = tucss;
+		context_desc->tucso = tucso;
+		context_desc->tucse = cpu_to_le16(tucse);
+		context_desc->mss = cpu_to_le16(mss);
+		context_desc->hdr_len = hdr_len;
+		context_desc->status = 0;
+		context_desc->cmd_type_len = cpu_to_le32(IXGB_CONTEXT_DESC_TYPE
+							 |
+							 IXGB_CONTEXT_DESC_CMD_TSE
+							 |
+							 IXGB_CONTEXT_DESC_CMD_IP
+							 |
+							 IXGB_CONTEXT_DESC_CMD_TCP
+							 |
+							 IXGB_CONTEXT_DESC_CMD_RS
+							 |
+							 IXGB_CONTEXT_DESC_CMD_IDE
+							 | (skb->len -
+							    (hdr_len)));
+
+		i = (i + 1) % adapter->tx_ring.count;
+		adapter->tx_ring.next_to_use = i;
+
+		return TRUE;
+	}
+#endif
+	return FALSE;
+}
+
+/**
+ * ixgb_tx_csum - prepare context descriptor for checksum offload.
+ *
+ * ixgb_tx_csum is called to prepare for checksumming a packet in hw.
+ * @param adapter board private structure
+ * @param skb structure containing data to send
+ **/
+static inline boolean_t
+ixgb_tx_csum(struct ixgb_adapter *adapter, struct sk_buff *skb)
+{
+	struct ixgb_context_desc *context_desc;
+	int i;
+	u8 css, cso;
+
+	if (likely(skb->ip_summed == CHECKSUM_HW)) {
+		css = skb->h.raw - skb->data;
+		cso = (skb->h.raw + skb->csum) - skb->data;
+		i = adapter->tx_ring.next_to_use;
+		context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i);
+
+		context_desc->tucss = css;
+		context_desc->tucso = cso;
+		context_desc->tucse = 0;
+		/* zero out any previously existing data in one instruction */
+		*(u32 *) & (context_desc->ipcss) = 0;
+		context_desc->status = 0;
+		context_desc->hdr_len = 0;
+		context_desc->mss = 0;
+		context_desc->cmd_type_len =
+		    cpu_to_le32(IXGB_CONTEXT_DESC_TYPE
+				| IXGB_TX_DESC_CMD_RS | IXGB_TX_DESC_CMD_IDE);
+
+		i = (i + 1) % adapter->tx_ring.count;
+		adapter->tx_ring.next_to_use = i;
+
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+/**
+ * ixgb_tx_map - private function for mapping send data to hardware addresses.
+ *
+ * @param adapter board private structure
+ * @param skb structure containing data to send
+ **/
+
+static inline int
+ixgb_tx_map(struct ixgb_adapter *adapter, struct sk_buff *skb)
+{
+	struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
+	int len, offset, count, size, i;
+
+	int f;
+	len = skb->len - skb->data_len;
+
+	i = (tx_ring->next_to_use + tx_ring->count - 1) % tx_ring->count;
+	count = 0;
+
+	offset = 0;
+
+	while (len) {
+		i = (i + 1) % tx_ring->count;
+		size = min(len, adapter->max_data_per_txd);
+		tx_ring->buffer_info[i].length = size;
+		tx_ring->buffer_info[i].dma =
+		    pci_map_single(adapter->pdev, skb->data + offset, size,
+				   PCI_DMA_TODEVICE);
+
+		tx_ring->buffer_info[i].time_stamp = jiffies;
+
+		len -= size;
+		offset += size;
+		count++;
+	}
+
+	for (f = 0; f < skb_shinfo(skb)->nr_frags; f++) {
+		struct skb_frag_struct *frag;
+
+		frag = &skb_shinfo(skb)->frags[f];
+		len = frag->size;
+		offset = 0;
+
+		while (len) {
+			i = (i + 1) % tx_ring->count;
+			size = min(len, adapter->max_data_per_txd);
+			tx_ring->buffer_info[i].length = size;
+			tx_ring->buffer_info[i].dma =
+			    pci_map_page(adapter->pdev, frag->page,
+					 frag->page_offset + offset, size,
+					 PCI_DMA_TODEVICE);
+
+			tx_ring->buffer_info[i].time_stamp = jiffies;
+			len -= size;
+			offset += size;
+			count++;
+		}
+	}
+	tx_ring->buffer_info[i].skb = skb;
+
+	return count;
+}
+
+/**
+ * ixgb_tx_queue - private function to start transmit on hardware.
+ *
+ * @param adapter board private structure
+ * @param count number of tx_descriptors to initialize (consume)
+ * @param vlan_id the vlan tag to insert (if necessary)
+ * @param tx_flags special handling for this transmit, if any
+ **/
+
+static inline void
+ixgb_tx_queue(struct ixgb_adapter *adapter, int count, int vlan_id,
+	      int tx_flags)
+{
+	struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
+	struct ixgb_tx_desc *tx_desc = NULL;
+	u32 cmd_type_len = adapter->tx_cmd_type;
+	u8 status = 0;
+	u8 popts = 0;
+	int i;
+
+	if (tx_flags & IXGB_TX_FLAGS_TSO) {
+		cmd_type_len |= IXGB_TX_DESC_CMD_TSE;
+		popts |= (IXGB_TX_DESC_POPTS_IXSM | IXGB_TX_DESC_POPTS_TXSM);
+	}
+
+	if (tx_flags & IXGB_TX_FLAGS_CSUM)
+		popts |= IXGB_TX_DESC_POPTS_TXSM;
+
+	if (tx_flags & IXGB_TX_FLAGS_VLAN) {
+		cmd_type_len |= IXGB_TX_DESC_CMD_VLE;
+	}
+
+	i = tx_ring->next_to_use;
+
+	while (count--) {
+		tx_desc = IXGB_TX_DESC(*tx_ring, i);
+		tx_desc->buff_addr = cpu_to_le64(tx_ring->buffer_info[i].dma);
+		tx_desc->cmd_type_len =
+		    cpu_to_le32(cmd_type_len | tx_ring->buffer_info[i].length);
+		tx_desc->status = status;
+		tx_desc->popts = popts;
+		tx_desc->vlan = cpu_to_le16(vlan_id);
+
+		i = (i + 1) % tx_ring->count;
+	}
+
+	tx_desc->cmd_type_len |= cpu_to_le32(IXGB_TX_DESC_CMD_EOP);
+
+	/* Force memory writes to complete before letting h/w
+	 * know there are new descriptors to fetch.  (Only
+	 * applicable for weak-ordered memory model archs,
+	 * such as IA-64). */
+	wmb();
+
+	tx_ring->next_to_use = i;
+	IXGB_WRITE_REG(&adapter->hw, TDT, i);
+}
+
+#define TXD_USE_COUNT(S, X) (((S) / (X)) + (((S) % (X)) ? 1 : 0))
+
+/**
+ * ixgb_xmit_frame - hard_start_xmit linked function, transmit entry point.
+ *
+ * ixgb_xmit_frame is called to send an skb on the wire.
+ * @param skb contains data to send
+ * @param netdev network interface device structure 
+ **/
+
+static int
+ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+	int vlan_id = 0;
+	int tx_flags = 0, count;
+	int f;
+
+	count =
+	    TXD_USE_COUNT(skb->len - skb->data_len, adapter->max_data_per_txd);
+
+	if (count == 0) {
+		dev_kfree_skb_any(skb);
+		return 0;
+	}
+
+	for (f = 0; f < skb_shinfo(skb)->nr_frags; f++)
+		count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size,
+				       adapter->max_data_per_txd);
+#ifdef NETIF_F_TSO
+	if ((skb_shinfo(skb)->tso_size) || (skb->ip_summed == CHECKSUM_HW))
+		count++;
+#else
+	if (skb->ip_summed == CHECKSUM_HW)
+		count++;
+#endif
+
+	if (unlikely(IXGB_DESC_UNUSED(&adapter->tx_ring) < count)) {
+		netif_stop_queue(netdev);
+		return 1;
+	}
+
+	if (adapter->vlgrp && vlan_tx_tag_present(skb)) {
+		tx_flags |= IXGB_TX_FLAGS_VLAN;
+		vlan_id = vlan_tx_tag_get(skb);
+	}
+
+	if (ixgb_tso(adapter, skb))
+		tx_flags |= IXGB_TX_FLAGS_TSO;
+	else if (ixgb_tx_csum(adapter, skb))
+		tx_flags |= IXGB_TX_FLAGS_CSUM;
+
+	count = ixgb_tx_map(adapter, skb);
+	ixgb_tx_queue(adapter, count, vlan_id, tx_flags);
+	netdev->trans_start = jiffies;
+
+	return 0;
+}
+
+/**
+ * ixgb_tx_timeout - Respond to a Tx Hang by resetting the adapter.
+ * @param netdev network interface device structure
+ **/
+
+static void
+ixgb_tx_timeout(struct net_device *netdev)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+
+	IXGB_DBG("ixgb_tx_timeout\n");
+
+	/* Do the reset outside of interrupt context */
+	schedule_work(&adapter->tx_timeout_task);
+}
+
+/**
+ * ixgb_tx_timeout_task - worker function to reset hardware and dump queues.
+ * This function is pointed to by adapter->tx_timeout_task
+ *
+ * @param netdev network interface device structure 
+ **/
+
+static void
+ixgb_tx_timeout_task(struct net_device *netdev)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+
+	IXGB_DBG("ixgb_tx_timeout_task\n");
+
+	netif_device_detach(netdev);
+	ixgb_down(adapter, TRUE);
+	ixgb_up(adapter);
+	netif_device_attach(netdev);
+}
+
+/**
+ * ixgb_get_stats - Get System Network Statistics.
+ * @param netdev network interface device structure
+ *
+ * Returns the address of the device statistics structure.
+ * The statistics are actually updated from the timer callback.
+ **/
+
+static struct net_device_stats *
+ixgb_get_stats(struct net_device *netdev)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+
+	return &adapter->net_stats;
+}
+
+/**
+ * ixgb_change_mtu - Change the Maximum Transfer Unit.
+ * @param netdev network interface device structure
+ * @param new_mtu new value for maximum frame size
+ *
+ * Returns 0 on success, negative on failure
+ **/
+
+static int
+ixgb_change_mtu(struct net_device *netdev, int new_mtu)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+	u32 old_mtu = adapter->rx_buffer_len;
+	int max_frame = new_mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
+
+	IXGB_DBG("ixgb_change_mtu\n");
+
+	if ((max_frame < IXGB_MIN_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH)
+	    || (max_frame > IXGB_MAX_JUMBO_FRAME_SIZE + ENET_FCS_LENGTH)) {
+		IXGB_ERR("Invalid MTU setting\n");
+		return -EINVAL;
+	}
+
+	if ((max_frame <=
+	     IXGB_MAX_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH)
+	    || (max_frame <= IXGB_RXBUFFER_2048)) {
+		adapter->rx_buffer_len = IXGB_RXBUFFER_2048;
+
+	} else if (max_frame <= IXGB_RXBUFFER_4096) {
+		adapter->rx_buffer_len = IXGB_RXBUFFER_4096;
+
+	} else if (max_frame <= IXGB_RXBUFFER_8192) {
+		adapter->rx_buffer_len = IXGB_RXBUFFER_8192;
+
+	} else {
+		adapter->rx_buffer_len = IXGB_RXBUFFER_16384;
+	}
+
+	if (old_mtu != adapter->rx_buffer_len && netif_running(netdev)) {
+
+		ixgb_down(adapter, TRUE);
+		ixgb_up(adapter);
+	}
+
+	if (adapter->hw.max_frame_size != max_frame) {
+		struct ixgb_hw *hw = &adapter->hw;
+
+		adapter->hw.max_frame_size = max_frame;
+
+		IXGB_WRITE_REG(hw, MFS, hw->max_frame_size << IXGB_MFS_SHIFT);
+
+		if (hw->max_frame_size >
+		    IXGB_MAX_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH) {
+			u32 ctrl0 = IXGB_READ_REG(hw, CTRL0);
+
+			if (!(ctrl0 & IXGB_CTRL0_JFE)) {
+				ctrl0 |= IXGB_CTRL0_JFE;
+				IXGB_WRITE_REG(hw, CTRL0, ctrl0);
+			}
+		}
+
+		printk(KERN_ERR "%s: ixgb_change_mtu MFS is set to <%x>\n",
+		       adapter->netdev->name,
+		       (IXGB_READ_REG(hw, MFS) >> IXGB_MFS_SHIFT));
+	}
+
+	netdev->mtu = new_mtu;
+
+	return 0;
+}
+
+/**
+ * ixgb_set_mac - Change the Ethernet Address of the NIC.
+ * @param netdev network interface device structure
+ * @param p pointer to an address structure
+ * 
+ * Returns 0 on success, negative on failure
+ **/
+
+static int
+ixgb_set_mac(struct net_device *netdev, void *p)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+	struct sockaddr *addr = (struct sockaddr *) p;
+
+	IXGB_DBG("ixgb_set_mac\n");
+
+	memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
+
+	ixgb_rar_set(&adapter->hw, addr->sa_data, 0);
+
+	return 0;
+}
+
+/**
+ * ixgb_update_stats - Update the board statistics counters.
+ * @param adapter board private structure
+ **/
+
+static void
+ixgb_update_stats(struct ixgb_adapter *adapter)
+{
+	adapter->stats.tprl += IXGB_READ_REG(&adapter->hw, TPRL);
+	adapter->stats.tprh += IXGB_READ_REG(&adapter->hw, TPRH);
+	adapter->stats.gprcl += IXGB_READ_REG(&adapter->hw, GPRCL);
+	adapter->stats.gprch += IXGB_READ_REG(&adapter->hw, GPRCH);
+	adapter->stats.bprcl += IXGB_READ_REG(&adapter->hw, BPRCL);
+	adapter->stats.bprch += IXGB_READ_REG(&adapter->hw, BPRCH);
+	adapter->stats.mprcl += IXGB_READ_REG(&adapter->hw, MPRCL);
+	adapter->stats.mprch += IXGB_READ_REG(&adapter->hw, MPRCH);
+	adapter->stats.uprcl += IXGB_READ_REG(&adapter->hw, UPRCL);
+	adapter->stats.uprch += IXGB_READ_REG(&adapter->hw, UPRCH);
+	adapter->stats.vprcl += IXGB_READ_REG(&adapter->hw, VPRCL);
+	adapter->stats.vprch += IXGB_READ_REG(&adapter->hw, VPRCH);
+	adapter->stats.jprcl += IXGB_READ_REG(&adapter->hw, JPRCL);
+	adapter->stats.jprch += IXGB_READ_REG(&adapter->hw, JPRCH);
+	adapter->stats.gorcl += IXGB_READ_REG(&adapter->hw, GORCL);
+	adapter->stats.gorch += IXGB_READ_REG(&adapter->hw, GORCH);
+	adapter->stats.torl += IXGB_READ_REG(&adapter->hw, TORL);
+	adapter->stats.torh += IXGB_READ_REG(&adapter->hw, TORH);
+	adapter->stats.rnbc += IXGB_READ_REG(&adapter->hw, RNBC);
+	adapter->stats.ruc += IXGB_READ_REG(&adapter->hw, RUC);
+	adapter->stats.roc += IXGB_READ_REG(&adapter->hw, ROC);
+	adapter->stats.rlec += IXGB_READ_REG(&adapter->hw, RLEC);
+	adapter->stats.crcerrs += IXGB_READ_REG(&adapter->hw, CRCERRS);
+	adapter->stats.icbc += IXGB_READ_REG(&adapter->hw, ICBC);
+	adapter->stats.ecbc += IXGB_READ_REG(&adapter->hw, ECBC);
+	adapter->stats.mpc += IXGB_READ_REG(&adapter->hw, MPC);
+	adapter->stats.tptl += IXGB_READ_REG(&adapter->hw, TPTL);
+	adapter->stats.tpth += IXGB_READ_REG(&adapter->hw, TPTH);
+	adapter->stats.gptcl += IXGB_READ_REG(&adapter->hw, GPTCL);
+	adapter->stats.gptch += IXGB_READ_REG(&adapter->hw, GPTCH);
+	adapter->stats.bptcl += IXGB_READ_REG(&adapter->hw, BPTCL);
+	adapter->stats.bptch += IXGB_READ_REG(&adapter->hw, BPTCH);
+	adapter->stats.mptcl += IXGB_READ_REG(&adapter->hw, MPTCL);
+	adapter->stats.mptch += IXGB_READ_REG(&adapter->hw, MPTCH);
+	adapter->stats.uptcl += IXGB_READ_REG(&adapter->hw, UPTCL);
+	adapter->stats.uptch += IXGB_READ_REG(&adapter->hw, UPTCH);
+	adapter->stats.vptcl += IXGB_READ_REG(&adapter->hw, VPTCL);
+	adapter->stats.vptch += IXGB_READ_REG(&adapter->hw, VPTCH);
+	adapter->stats.jptcl += IXGB_READ_REG(&adapter->hw, JPTCL);
+	adapter->stats.jptch += IXGB_READ_REG(&adapter->hw, JPTCH);
+	adapter->stats.gotcl += IXGB_READ_REG(&adapter->hw, GOTCL);
+	adapter->stats.gotch += IXGB_READ_REG(&adapter->hw, GOTCH);
+	adapter->stats.totl += IXGB_READ_REG(&adapter->hw, TOTL);
+	adapter->stats.toth += IXGB_READ_REG(&adapter->hw, TOTH);
+	adapter->stats.dc += IXGB_READ_REG(&adapter->hw, DC);
+	adapter->stats.plt64c += IXGB_READ_REG(&adapter->hw, PLT64C);
+	adapter->stats.tsctc += IXGB_READ_REG(&adapter->hw, TSCTC);
+	adapter->stats.tsctfc += IXGB_READ_REG(&adapter->hw, TSCTFC);
+	adapter->stats.ibic += IXGB_READ_REG(&adapter->hw, IBIC);
+	adapter->stats.rfc += IXGB_READ_REG(&adapter->hw, RFC);
+	adapter->stats.lfc += IXGB_READ_REG(&adapter->hw, LFC);
+	adapter->stats.pfrc += IXGB_READ_REG(&adapter->hw, PFRC);
+	adapter->stats.pftc += IXGB_READ_REG(&adapter->hw, PFTC);
+	adapter->stats.mcfrc += IXGB_READ_REG(&adapter->hw, MCFRC);
+	adapter->stats.mcftc += IXGB_READ_REG(&adapter->hw, MCFTC);
+	adapter->stats.xonrxc += IXGB_READ_REG(&adapter->hw, XONRXC);
+	adapter->stats.xontxc += IXGB_READ_REG(&adapter->hw, XONTXC);
+	adapter->stats.xoffrxc += IXGB_READ_REG(&adapter->hw, XOFFRXC);
+	adapter->stats.xofftxc += IXGB_READ_REG(&adapter->hw, XOFFTXC);
+	adapter->stats.rjc += IXGB_READ_REG(&adapter->hw, RJC);
+
+	/* Fill out the OS statistics structure */
+
+	adapter->net_stats.rx_packets = adapter->stats.gprcl;
+	adapter->net_stats.tx_packets = adapter->stats.gptcl;
+	adapter->net_stats.rx_bytes = adapter->stats.gorcl;
+	adapter->net_stats.tx_bytes = adapter->stats.gotcl;
+	adapter->net_stats.multicast = adapter->stats.mprcl;
+	adapter->net_stats.collisions = 0;
+
+	/* ignore RLEC as it reports errors for padded (<64bytes) frames
+	 * with a length in the type/len field */
+	adapter->net_stats.rx_errors =
+	    /* adapter->stats.rnbc + */ adapter->stats.crcerrs +
+	    adapter->stats.ruc +
+	    adapter->stats.roc /*+ adapter->stats.rlec */  +
+	    adapter->stats.icbc +
+	    adapter->stats.ecbc + adapter->stats.mpc;
+
+	adapter->net_stats.rx_dropped = adapter->stats.mpc;
+
+	/* see above
+	 * adapter->net_stats.rx_length_errors = adapter->stats.rlec;
+	 */
+
+	adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
+	adapter->net_stats.rx_fifo_errors = adapter->stats.mpc;
+	adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
+	adapter->net_stats.rx_over_errors = adapter->stats.mpc;
+
+	adapter->net_stats.tx_errors = 0;
+	adapter->net_stats.rx_frame_errors = 0;
+	adapter->net_stats.tx_aborted_errors = 0;
+	adapter->net_stats.tx_carrier_errors = 0;
+	adapter->net_stats.tx_fifo_errors = 0;
+	adapter->net_stats.tx_heartbeat_errors = 0;
+	adapter->net_stats.tx_window_errors = 0;
+}
+
+/**
+ * ixgb_irq_disable - Mask off interrupt generation on the NIC
+ * @param adapter board private structure
+ **/
+
+static inline void
+ixgb_irq_disable(struct ixgb_adapter *adapter)
+{
+	IXGB_DBG("ixgb_irq_disable\n");
+
+	atomic_inc(&adapter->irq_sem);
+	IXGB_WRITE_REG(&adapter->hw, IMC, ~0);
+	synchronize_irq(adapter->netdev->irq);
+}
+
+/**
+ * ixgb_irq_enable - Enable default interrupt generation settings.
+ * @param adapter board private structure
+ **/
+
+static inline void
+ixgb_irq_enable(struct ixgb_adapter *adapter)
+{
+	IXGB_DBG("ixgb_irq_enable\n");
+
+	if (atomic_dec_and_test(&adapter->irq_sem)) {
+		IXGB_WRITE_REG(&adapter->hw, IMS,
+			       IXGB_INT_RXT0 | IXGB_INT_RXDMT0 | IXGB_INT_TXDW |
+			       IXGB_INT_RXO | IXGB_INT_LSC);
+	}
+}
+
+#define IXGB_MAX_INTR 10
+/**
+ * ixgb_intr - Interrupt Handler.
+ * @param irq interrupt number
+ * @param data pointer to a network interface device structure
+ * @param regs CPU registers structure
+ **/
+
+static irqreturn_t
+ixgb_intr(int irq, void *data, struct pt_regs *regs)
+{
+	struct net_device *netdev = (struct net_device *) data;
+	struct ixgb_adapter *adapter = netdev->priv;
+#ifdef CONFIG_IXGB_NAPI
+	if (netif_rx_schedule_prep(netdev)) {
+		ixgb_irq_disable(adapter);
+		__netif_rx_schedule(netdev);
+	}
+
+	return IRQ_HANDLED; /* FIXME: check for shared interrupts */
+#else
+	struct ixgb_hw *hw = &adapter->hw;
+	u32 icr;
+	uint i = IXGB_MAX_INTR;
+	boolean_t rxdmt0 = FALSE;
+	int handled = 0;
+
+	while (i && (icr = IXGB_READ_REG(hw, ICR))) {
+		handled = 1;
+
+		if (icr & IXGB_INT_RXDMT0)
+			rxdmt0 = TRUE;
+
+		if (unlikely(icr & (IXGB_INT_RXSEQ | IXGB_INT_LSC))) {
+			mod_timer(&adapter->watchdog_timer, jiffies);
+		}
+
+		/* adapter->generate_int = 0; */
+		ixgb_clean_rx_irq(adapter);
+		ixgb_clean_tx_irq(adapter);
+
+		i--;
+	}
+
+	/* if RAIDC:EN == 1 and ICR:RXDMT0 == 1, we need to
+	 * set IMS:RXDMT0 to 1 to restart the RBD timer (POLL)
+	 */
+	if (rxdmt0 && adapter->raidc) {
+		/* ready the timer by writing the clear reg */
+		IXGB_WRITE_REG(hw, IMC, IXGB_INT_RXDMT0);
+		/* now restart it, h/w will decide if its necessary */
+		IXGB_WRITE_REG(hw, IMS, IXGB_INT_RXDMT0);
+	}
+
+	return IRQ_RETVAL(handled);
+#endif				// NAPI else
+}
+
+#ifdef CONFIG_IXGB_NAPI
+static int
+ixgb_process_intr(struct net_device *netdev)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+	u32 icr;
+	int i = IXGB_MAX_INTR;
+	int hasReceived = 0;
+
+	while (i && (icr = IXGB_READ_REG(&adapter->hw, ICR))) {
+		if (icr & IXGB_INT_RXT0)
+			hasReceived = 1;
+
+		if (!(icr & ~(IXGB_INT_RXT0)))
+			break;
+
+		if (icr & (IXGB_INT_RXSEQ | IXGB_INT_LSC)) {
+			mod_timer(&adapter->watchdog_timer, jiffies);
+		}
+
+		ixgb_clean_tx_irq(adapter);
+		i--;
+	}
+
+	return hasReceived;
+}
+
+#endif
+/**
+ * ixgb_clean_tx_irq - Reclaim resources after transmit completes.
+ * @param adapter board private structure
+ **/
+
+static void
+ixgb_clean_tx_irq(struct ixgb_adapter *adapter)
+{
+	struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
+	struct net_device *netdev = adapter->netdev;
+	struct pci_dev *pdev = adapter->pdev;
+	int i = adapter->tx_ring.next_to_clean;
+	struct ixgb_tx_desc *tx_desc = IXGB_TX_DESC(*tx_ring, i);
+	while ((tx_desc->status & IXGB_TX_DESC_STATUS_DD)) {
+		if (tx_desc->popts
+		    & (IXGB_TX_DESC_POPTS_TXSM | IXGB_TX_DESC_POPTS_IXSM))
+			adapter->hw_csum_tx_good++;
+
+		if (tx_ring->buffer_info[i].dma) {
+			pci_unmap_page(pdev, tx_ring->buffer_info[i].dma,
+				       tx_ring->buffer_info[i].length,
+				       PCI_DMA_TODEVICE);
+			tx_ring->buffer_info[i].dma = 0;
+		}
+
+		if (tx_ring->buffer_info[i].skb) {
+			dev_kfree_skb_any(tx_ring->buffer_info[i].skb);
+			tx_ring->buffer_info[i].skb = NULL;
+		}
+
+		*(u32 *) & (tx_desc->status) = 0;
+
+		i = (i + 1) % tx_ring->count;
+		tx_desc = IXGB_TX_DESC(*tx_ring, i);
+	}
+
+	tx_ring->next_to_clean = i;
+
+	if (netif_queue_stopped(netdev) && netif_carrier_ok(netdev) &&
+	    (IXGB_DESC_UNUSED(tx_ring) > IXGB_TX_QUEUE_WAKE)) {
+
+		netif_wake_queue(netdev);
+	}
+}
+
+#ifdef CONFIG_IXGB_NAPI
+static int
+ixgb_poll(struct net_device *netdev, int *budget)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+	struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
+	struct pci_dev *pdev = adapter->pdev;
+	struct ixgb_rx_desc *rx_desc;
+	struct sk_buff *skb;
+	u32 length;
+	int i;
+	int received = 0;
+	int rx_work_limit = *budget;
+
+	if (rx_work_limit > netdev->quota)
+		rx_work_limit = netdev->quota;
+
+	ixgb_process_intr(netdev);
+
+	i = rx_ring->next_to_clean;
+	rx_desc = IXGB_RX_DESC(*rx_ring, i);
+
+	while ((rx_desc->status & IXGB_RX_DESC_STATUS_DD)) {
+		if (--rx_work_limit < 0)
+			goto not_done;
+
+		pci_unmap_single(pdev,
+				 rx_ring->buffer_info[i].dma,
+				 rx_ring->buffer_info[i].length,
+				 PCI_DMA_FROMDEVICE);
+
+		skb = rx_ring->buffer_info[i].skb;
+		length = le16_to_cpu(rx_desc->length);
+
+		if (!(rx_desc->status & IXGB_RX_DESC_STATUS_EOP)) {
+
+			/* All receives must fit into a single buffer */
+
+			IXGB_DBG("Receive packet consumed multiple buffers\n");
+
+			dev_kfree_skb_irq(skb);
+			rx_desc->status = 0;
+			rx_ring->buffer_info[i].skb = NULL;
+
+			i = (i + 1) % rx_ring->count;
+
+			rx_desc = IXGB_RX_DESC(*rx_ring, i);
+			continue;
+		}
+
+		if (rx_desc->
+		    errors & (IXGB_RX_DESC_ERRORS_CE | IXGB_RX_DESC_ERRORS_SE |
+			      IXGB_RX_DESC_ERRORS_P | IXGB_RX_DESC_ERRORS_RXE))
+		{
+
+			IXGB_DBG("Receive Errors Reported by Hardware-%x.\n",
+				 rx_desc->errors);
+
+			dev_kfree_skb_irq(skb);
+			rx_desc->status = 0;
+			rx_ring->buffer_info[i].skb = NULL;
+			i = (i + 1) % rx_ring->count;
+			rx_desc = IXGB_RX_DESC(*rx_ring, i);
+			continue;
+		}
+
+		/* Good Receive */
+		skb_put(skb, length);
+
+		/* Receive Checksum Offload */
+		ixgb_rx_checksum(adapter, rx_desc, skb);
+
+		skb->protocol = eth_type_trans(skb, netdev);
+		if (adapter->vlgrp
+		    && (rx_desc->status & IXGB_RX_DESC_STATUS_VP)) {
+			vlan_hwaccel_rx(skb, adapter->vlgrp,
+					(rx_desc->
+					 special &
+					 IXGB_RX_DESC_SPECIAL_VLAN_MASK));
+		} else {
+			netif_receive_skb(skb);
+		}
+		netdev->last_rx = jiffies;
+
+		rx_desc->status = 0;
+		rx_ring->buffer_info[i].skb = NULL;
+
+		i = (i + 1) % rx_ring->count;
+
+		rx_desc = IXGB_RX_DESC(*rx_ring, i);
+		received++;
+	}
+
+	if (!received)
+		received = 1;
+
+	ixgb_alloc_rx_buffers(adapter);
+
+	rx_ring->next_to_clean = i;
+	netdev->quota -= received;
+	*budget -= received;
+
+	netif_rx_complete(netdev);
+
+	/* NOTE: RAIDC will be automatically restarted by this enable */
+	ixgb_irq_enable(adapter);
+	return 0;
+
+      not_done:
+
+	ixgb_alloc_rx_buffers(adapter);
+
+	rx_ring->next_to_clean = i;
+	netdev->quota -= received;
+	*budget -= received;
+
+	return 1;
+}
+#else
+/**
+ * ixgb_clean_rx_irq - Send received data up the network stack.
+ * @param adapter board private structure
+ **/
+
+static void
+ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
+{
+	struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
+	struct net_device *netdev = adapter->netdev;
+	struct pci_dev *pdev = adapter->pdev;
+	struct ixgb_rx_desc *rx_desc;
+	struct sk_buff *skb;
+	u32 length;
+	int i;
+
+	i = rx_ring->next_to_clean;
+	rx_desc = IXGB_RX_DESC(*rx_ring, i);
+
+	while ((rx_desc->status & IXGB_RX_DESC_STATUS_DD)) {
+		pci_unmap_single(pdev, rx_ring->buffer_info[i].dma,
+				 rx_ring->buffer_info[i].length,
+				 PCI_DMA_FROMDEVICE);
+
+		skb = rx_ring->buffer_info[i].skb;
+		length = le16_to_cpu(rx_desc->length);
+
+		if (unlikely(!(rx_desc->status & IXGB_RX_DESC_STATUS_EOP))) {
+
+			/* All receives must fit into a single buffer */
+
+			IXGB_DBG("Receive packet consumed multiple buffers "
+				 "length<%x>\n", length);
+
+			dev_kfree_skb_irq(skb);
+			rx_desc->status = 0;
+			rx_ring->buffer_info[i].skb = NULL;
+			i = (i + 1) % rx_ring->count;
+			rx_desc = IXGB_RX_DESC(*rx_ring, i);
+			continue;
+		}
+
+		if (unlikely(rx_desc->errors
+			     & (IXGB_RX_DESC_ERRORS_CE | IXGB_RX_DESC_ERRORS_SE
+				| IXGB_RX_DESC_ERRORS_P |
+				IXGB_RX_DESC_ERRORS_RXE))) {
+
+			IXGB_DBG("Receive Errors Reported by Hardware-%x.\n",
+				 rx_desc->errors);
+
+			dev_kfree_skb_irq(skb);
+			rx_desc->status = 0;
+			rx_ring->buffer_info[i].skb = NULL;
+			i = (i + 1) % rx_ring->count;
+			rx_desc = IXGB_RX_DESC(*rx_ring, i);
+			continue;
+		}
+
+		/* Good Receive */
+		skb_put(skb, length);
+
+		/* Receive Checksum Offload */
+		ixgb_rx_checksum(adapter, rx_desc, skb);
+
+		skb->protocol = eth_type_trans(skb, netdev);
+		if (adapter->vlgrp
+		    && (rx_desc->status & IXGB_RX_DESC_STATUS_VP)) {
+			vlan_hwaccel_rx(skb, adapter->vlgrp,
+					(rx_desc->
+					 special &
+					 IXGB_RX_DESC_SPECIAL_VLAN_MASK));
+		} else {
+			netif_rx(skb);
+		}
+
+		netdev->last_rx = jiffies;
+
+		rx_desc->status = 0;
+
+		rx_ring->buffer_info[i].skb = NULL;
+		i = (i + 1) % rx_ring->count;
+
+		rx_desc = IXGB_RX_DESC(*rx_ring, i);
+	}			/* while */
+
+	rx_ring->next_to_clean = i;
+
+	ixgb_alloc_rx_buffers(adapter);
+}
+#endif
+
+/**
+ * ixgb_alloc_rx_buffers - Replace used receive buffers.
+ * @param adapter address of board private structure
+ **/
+
+static void
+ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter)
+{
+	struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
+	struct net_device *netdev = adapter->netdev;
+	struct pci_dev *pdev = adapter->pdev;
+	struct ixgb_rx_desc *rx_desc;
+	struct sk_buff *skb;
+	int reserve_len;
+	int i;
+	int num_group_tail_writes;
+	long cleancount;
+
+	reserve_len = 2;
+
+	i = rx_ring->next_to_use;
+	cleancount = IXGB_DESC_UNUSED(rx_ring);
+
+	/* lessen this to 4 if we're
+	 * in the midst of raidc and rbd is occuring
+	 * because we don't want to delay returning buffers when low
+	 */
+	num_group_tail_writes = adapter->raidc ? 4 : IXGB_RX_BUFFER_WRITE;
+
+	/* leave one descriptor unused */
+	while (--cleancount > 0) {
+		rx_desc = IXGB_RX_DESC(*rx_ring, i);
+
+		/* allocate a new one */
+		skb = dev_alloc_skb(adapter->rx_buffer_len + reserve_len);
+
+		if (unlikely(!skb)) {
+			/* better luck next time around */
+			IXGB_DBG("Could not allocate SKB\n");
+			break;
+		}
+		/* Make buffer alignment 2 beyond a 16 byte boundary
+		 * this will result in a 16 byte aligned IP header after
+		 * the 14 byte MAC header is removed
+		 */
+		skb_reserve(skb, reserve_len);
+
+		skb->dev = netdev;
+
+		rx_ring->buffer_info[i].skb = skb;
+		rx_ring->buffer_info[i].length = adapter->rx_buffer_len;
+		rx_ring->buffer_info[i].dma =
+		    pci_map_single(pdev, skb->data, adapter->rx_buffer_len,
+				   PCI_DMA_FROMDEVICE);
+
+		rx_desc->buff_addr = cpu_to_le64(rx_ring->buffer_info[i].dma);
+
+		if (!(i % num_group_tail_writes)) {
+			/* Force memory writes to complete before letting h/w
+			 * know there are new descriptors to fetch.  (Only
+			 * applicable for weak-ordered memory model archs,
+			 * such as IA-64). */
+			wmb();
+			/* move tail */
+			IXGB_WRITE_REG(&adapter->hw, RDT, i);
+		}
+		i = (i + 1) % rx_ring->count;
+	}
+
+	rx_ring->next_to_use = i;
+}
+
+/**
+ * ixgb_ioctl - perform a command - e.g: ethtool:get_driver_info.
+ * @param netdev network interface device structure
+ * @param ifr data to be used/filled in by the ioctl command
+ * @param cmd ioctl command to execute
+ **/
+
+int
+ixgb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
+{
+
+	switch (cmd) {
+	case SIOCETHTOOL:
+		return ixgb_ethtool_ioctl(netdev, ifr);
+
+	default:
+		return -EOPNOTSUPP;
+	}
+
+	return 0;
+}
+
+/**
+ * ixgb_vlan_rx_register - enables or disables vlan tagging/stripping.
+ * 
+ * @param netdev network interface device structure
+ * @param grp indicates to enable or disable tagging/stripping
+ **/
+
+static void
+ixgb_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+	u32 ctrl, rctl;
+
+	ixgb_irq_disable(adapter);
+	adapter->vlgrp = grp;
+
+	if (grp) {
+		/* enable VLAN tag insert/strip */
+		ctrl = IXGB_READ_REG(&adapter->hw, CTRL0);
+		ctrl |= IXGB_CTRL0_VME;
+		IXGB_WRITE_REG(&adapter->hw, CTRL0, ctrl);
+
+		/* enable VLAN receive filtering */
+		rctl = IXGB_READ_REG(&adapter->hw, RCTL);
+		rctl |= IXGB_RCTL_VFE;
+		rctl &= ~IXGB_RCTL_CFIEN;
+		IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
+	} else {
+		/* disable VLAN tag insert/strip */
+		ctrl = IXGB_READ_REG(&adapter->hw, CTRL0);
+		ctrl &= ~IXGB_CTRL0_VME;
+		IXGB_WRITE_REG(&adapter->hw, CTRL0, ctrl);
+
+		/* disable VLAN filtering */
+		rctl = IXGB_READ_REG(&adapter->hw, RCTL);
+		rctl &= ~IXGB_RCTL_VFE;
+		IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
+	}
+
+	ixgb_irq_enable(adapter);
+}
+
+/**
+ * ixgb_vlan_rx_add_vid - adds a vlan id to be tagged/stripped in packet data.
+ * @param netdev network interface device structure
+ * @param vid the vlan to be added
+ **/
+
+static void
+ixgb_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+	u32 vfta, index;
+
+	/* add VID to filter table */
+
+	index = (vid >> 5) & 0x7F;
+	vfta = IXGB_READ_REG_ARRAY(&adapter->hw, VFTA, index);
+	vfta |= (1 << (vid & 0x1F));
+	ixgb_write_vfta(&adapter->hw, index, vfta);
+}
+
+/**
+ * ixgb_vlan_rx_kill_vid - removes a vlan id from tag/strip tables.
+ * @param netdev network interface device structure
+ * @param vid the vlan to be deleted
+ **/
+
+static void
+ixgb_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+	u32 vfta, index;
+
+	ixgb_irq_disable(adapter);
+
+	if (adapter->vlgrp)
+		adapter->vlgrp->vlan_devices[vid] = NULL;
+
+	ixgb_irq_enable(adapter);
+
+	/* remove VID from filter table */
+
+	index = (vid >> 5) & 0x7F;
+	vfta = IXGB_READ_REG_ARRAY(&adapter->hw, VFTA, index);
+	vfta &= ~(1 << (vid & 0x1F));
+	ixgb_write_vfta(&adapter->hw, index, vfta);
+}
+
+/**
+ * ixgb_restore_vlan - restores vlan settings after adapter reset.
+ * @param adapter the address of the board private structure
+ **/
+static void
+ixgb_restore_vlan(struct ixgb_adapter *adapter)
+{
+	ixgb_vlan_rx_register(adapter->netdev, adapter->vlgrp);
+
+	if (adapter->vlgrp) {
+		u16 vid;
+		for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
+			if (!adapter->vlgrp->vlan_devices[vid])
+				continue;
+			ixgb_vlan_rx_add_vid(adapter->netdev, vid);
+		}
+	}
+}
+
+/**
+ * ixgb_rx_checksum - Receive Checksum Offload for 82597.
+ * @param adapter board private structure
+ * @param rx_desc receive descriptor
+ * @param skb socket buffer with received data
+ **/
+
+static inline void
+ixgb_rx_checksum(struct ixgb_adapter *adapter,
+		 struct ixgb_rx_desc *rx_desc, struct sk_buff *skb)
+{
+	/* Ignore Checksum bit is set OR 
+	 * TCP Checksum has not been calculated 
+	 */
+	if ((rx_desc->status & IXGB_RX_DESC_STATUS_IXSM) ||
+	    (!(rx_desc->status & IXGB_RX_DESC_STATUS_TCPCS))) {
+		skb->ip_summed = CHECKSUM_NONE;
+		return;
+	}
+
+	/* At this point we know the hardware did the TCP checksum 
+	 * now look at the TCP checksum error bit
+	 */
+	if (rx_desc->errors & IXGB_RX_DESC_ERRORS_TCPE) {
+		/* let the stack verify checksum errors */
+		skb->ip_summed = CHECKSUM_NONE;
+		adapter->hw_csum_rx_error++;
+	} else {
+		/* TCP checksum is good */
+		skb->ip_summed = CHECKSUM_UNNECESSARY;
+		adapter->hw_csum_rx_good++;
+	}
+}
+
+/**
+ * ixgb_write_pci_cfg - write PCI configuration space.
+ * @param hw board specific data structure
+ * @param reg PCI configuration space register to write to
+ * @param value Value to be written to reg
+ **/
+
+void
+ixgb_write_pci_cfg(struct ixgb_hw *hw, u32 reg, u16 * value)
+{
+	struct ixgb_adapter *adapter = (struct ixgb_adapter *) hw->back;
+
+	pci_write_config_word(adapter->pdev, reg, *value);
+}
+
+/**
+ * ixgb_notify_reboot - handles OS notification of reboot event.
+ * @param nb notifier block, unused
+ * @param event Event being passed to driver to act upon
+ * @param p A pointer to our net device
+ **/
+static int
+ixgb_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
+{
+	struct pci_dev *pdev = NULL;
+
+	switch (event) {
+	case SYS_DOWN:
+	case SYS_HALT:
+	case SYS_POWER_OFF:
+		pci_for_each_dev(pdev) {
+			if (pci_dev_driver(pdev) == &ixgb_driver)
+				ixgb_suspend(pdev, 3);
+		}
+	}
+	return NOTIFY_DONE;
+}
+
+/**
+ * ixgb_suspend - driver suspend function called from notify.
+ * @param pdev pci driver structure used for passing to
+ * @param state power state to enter 
+ **/
+static int
+ixgb_suspend(struct pci_dev *pdev, u32 state)
+{
+	struct net_device *netdev = pci_get_drvdata(pdev);
+	struct ixgb_adapter *adapter = netdev->priv;
+
+	netif_device_detach(netdev);
+
+	if (netif_running(netdev))
+		ixgb_down(adapter, TRUE);
+
+	pci_save_state(pdev, adapter->pci_state);
+
+	state = (state > 0) ? 3 : 0;
+	pci_set_power_state(pdev, state);
+	msec_delay(200);
+
+	return 0;
+}
+
+/* ixgb_main.c */
diff -Nru a/drivers/net/ixgb/ixgb_osdep.h b/drivers/net/ixgb/ixgb_osdep.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/net/ixgb/ixgb_osdep.h	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,84 @@
+/*******************************************************************************
+
+  
+  Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
+  
+  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; either version 2 of the License, or (at your option) 
+  any later version.
+  
+  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.
+  
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59 
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+  
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+  
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+*******************************************************************************/
+
+/* glue for the OS independant part of ixgb 
+ * includes register access macros
+ */
+
+#ifndef IXGB_OSDEP_H
+#define IXGB_OSDEP_H
+
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+#include <linux/interrupt.h>
+#include <linux/sched.h>
+
+/* FIXME: eliminate me */
+#define msec_delay(x)	do { if(in_interrupt()) { \
+	                	mdelay(x); \
+			} else { \
+				set_current_state(TASK_UNINTERRUPTIBLE); \
+				schedule_timeout((x * HZ)/1000); \
+			} } while(0)
+
+typedef enum {
+	FALSE = 0,
+	TRUE = 1
+} boolean_t;
+
+#define MSGOUT(S, A, B)	printk(KERN_DEBUG S "\n", A, B)
+
+#if DBG
+#define ASSERT(x)	if(!(x)) BUG()
+#define DEBUGOUT(S)		printk(KERN_ERR S "\n")
+#define DEBUGOUT1(S, A...)	printk(KERN_ERR S "\n", A)
+#else
+#define ASSERT(x)
+#define DEBUGOUT(S)
+#define DEBUGOUT1(S, A...)
+#endif
+
+#define DEBUGOUT2 DEBUGOUT1
+#define DEBUGOUT3 DEBUGOUT1
+#define DEBUGOUT7 DEBUGOUT1
+#define DEBUGFUNC(F)        DEBUGOUT(F)
+
+#define IXGB_WRITE_REG(a, reg, value) ( \
+    writel((value), ((a)->hw_addr + IXGB_##reg)))
+
+#define IXGB_READ_REG(a, reg) ( \
+    readl((a)->hw_addr + IXGB_##reg))
+
+#define IXGB_WRITE_REG_ARRAY(a, reg, offset, value) ( \
+    writel((value), ((a)->hw_addr + IXGB_##reg + ((offset) << 2))))
+
+#define IXGB_READ_REG_ARRAY(a, reg, offset) ( \
+    readl((a)->hw_addr + IXGB_##reg + ((offset) << 2)))
+
+#endif				/* IXGB_OSDEP_H */
diff -Nru a/drivers/net/ixgb/ixgb_param.c b/drivers/net/ixgb/ixgb_param.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/net/ixgb/ixgb_param.c	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,502 @@
+/*******************************************************************************
+
+  
+  Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
+  
+  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; either version 2 of the License, or (at your option) 
+  any later version.
+  
+  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.
+  
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59 
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+  
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+  
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+*******************************************************************************/
+
+#include "ixgb.h"
+
+/* This is the only thing that needs to be changed to adjust the
+ * maximum number of ports that the driver can manage.
+ */
+
+#define IXGB_MAX_NIC			 8
+
+#define OPTION_UNSET			-1
+#define OPTION_DISABLED			 0
+#define OPTION_ENABLED			 1
+
+/* Module Parameters are always initialized to -1, so that the driver
+ * can tell the difference between no user specified value or the
+ * user asking for the default value.
+ * The true default values are loaded in when ixgb_check_options is called.
+ *
+ * This is a GCC extension to ANSI C.
+ * See the item "Labeled Elements in Initializers" in the section
+ * "Extensions to the C Language Family" of the GCC documentation.
+ */
+
+#define IXGB_PARAM_INIT { [0 ... IXGB_MAX_NIC] = OPTION_UNSET }
+
+/* All parameters are treated the same, as an integer array of values.
+ * This macro just reduces the need to repeat the same declaration code
+ * over and over (plus this helps to avoid typo bugs).
+ */
+
+#define IXGB_PARAM(X, S) \
+static const int __devinitdata X[IXGB_MAX_NIC + 1] = IXGB_PARAM_INIT; \
+MODULE_PARM(X, "1-" __MODULE_STRING(IXGB_MAX_NIC) "i"); \
+MODULE_PARM_DESC(X, S);
+
+/* Transmit Descriptor Count
+ *
+ * Valid Range: 64-4096
+ *
+ * Default Value: 256
+ */
+
+IXGB_PARAM(TxDescriptors, "Number of transmit descriptors");
+
+/* Receive Descriptor Count
+ *
+ * Valid Range: 64-4096
+ *
+ * Default Value: 1024
+ */
+
+IXGB_PARAM(RxDescriptors, "Number of receive descriptors");
+
+/* User Specified Flow Control Override
+ *
+ * Valid Range: 0-3
+ *  - 0 - No Flow Control
+ *  - 1 - Rx only, respond to PAUSE frames but do not generate them
+ *  - 2 - Tx only, generate PAUSE frames but ignore them on receive
+ *  - 3 - Full Flow Control Support
+ *
+ * Default Value: Read flow control settings from the EEPROM
+ */
+
+IXGB_PARAM(FlowControl, "Flow Control setting");
+
+/* XsumRX - Receive Checksum Offload Enable/Disable
+ *
+ * Valid Range: 0, 1
+ *  - 0 - disables all checksum offload
+ *  - 1 - enables receive IP/TCP/UDP checksum offload
+ *        on 82597 based NICs
+ *
+ * Default Value: 1
+ */
+
+IXGB_PARAM(XsumRX, "Disable or enable Receive Checksum offload");
+
+/* XsumTX - Transmit Checksum Offload Enable/Disable
+ *
+ * Valid Range: 0, 1
+ *  - 0 - disables all checksum offload
+ *  - 1 - enables transmmit IP/TCP/UDP checksum offload
+ *        on 82597 based NICs
+ *
+ * Default Value: 1
+ */
+
+IXGB_PARAM(XsumTX, "Disable or enable Transmit Checksum offload");
+
+/* Receive Interrupt Delay in units of 0.8192 microseconds
+ *
+ * Valid Range: 0-65535
+ *
+ * Default Value: 72
+ */
+
+IXGB_PARAM(RxIntDelay, "Receive Interrupt Delay");
+
+/* Receive Interrupt Moderation enable (uses RxIntDelay too)
+ *
+ * Valid Range: 0,1
+ *
+ * Default Value: 1
+ */
+
+IXGB_PARAM(RAIDC, "Disable or enable Receive Interrupt Moderation");
+
+/* Receive Flow control high threshold (when we send a pause frame)
+ * (FCRTH)
+ *
+ * Valid Range: 1,536 - 262,136 (0x600 - 0x3FFF8, 8 byte granularity)
+ *
+ * Default Value: 196,608 (0x30000)
+ */
+
+IXGB_PARAM(RxFCHighThresh, "Receive Flow Control High Threshold");
+
+/* Receive Flow control low threshold (when we send a resume frame)
+ * (FCRTL)
+ *
+ * Valid Range: 64 - 262,136 (0x40 - 0x3FFF8, 8 byte granularity)
+ *              must be less than high threshold by at least 8 bytes
+ *
+ * Default Value:  163,840 (0x28000)
+ */
+
+IXGB_PARAM(RxFCLowThresh, "Receive Flow Control Low Threshold");
+
+/* Flow control request timeout (how long to pause the link partner's tx)
+ * (PAP 15:0)
+ *
+ * Valid Range: 1 - 65535 
+ *
+ * Default Value:  256 (0x100)
+ */
+
+IXGB_PARAM(FCReqTimeout, "Flow Control Request Timeout");
+
+/* Transmit Interrupt Delay in units of 0.8192 microseconds
+ *
+ * Valid Range: 0-65535
+ *
+ * Default Value: 32
+ */
+
+IXGB_PARAM(TxIntDelay, "Transmit Interrupt Delay");
+
+/* Interrupt Delay Enable
+ *
+ * Valid Range: 0, 1
+ *
+ *  - 0 - disables transmit interrupt delay
+ *  - 1 - enables transmmit interrupt delay
+ *
+ * Default Value: 1
+ */
+
+IXGB_PARAM(IntDelayEnable, "Transmit Interrupt Delay Enable");
+
+#define DEFAULT_TXD			    256
+#define MAX_TXD				   4096
+#define MIN_TXD				     64
+#define DEFAULT_RXD			   1024
+#define MAX_RXD				   4096
+#define MIN_RXD				     64
+#define DEFAULT_TIDV			     32
+#define MAX_TIDV		         0xFFFF
+#define MIN_TIDV			      0
+#define DEFAULT_RDTR			     72
+#define MAX_RDTR			 0xFFFF
+#define MIN_RDTR			      0
+#define XSUMRX_DEFAULT		 OPTION_ENABLED
+#define FLOW_CONTROL_FULL	   ixgb_fc_full
+#define FLOW_CONTROL_DEFAULT  FLOW_CONTROL_FULL
+#define DEFAULT_FCRTL	    		0x28000
+#define DEFAULT_FCRTH			0x30000
+#define MIN_FCRTL			      0
+#define MAX_FCRTL			0x3FFE8
+#define MIN_FCRTH			      8
+#define MAX_FCRTH			0x3FFF0
+#define DEFAULT_FCPAUSE		 	  0x100
+#define MIN_FCPAUSE			      1
+#define MAX_FCPAUSE			 0xffff
+
+struct ixgb_option {
+	enum { enable_option, range_option, list_option } type;
+	char *name;
+	char *err;
+	int def;
+	union {
+		struct {	/* range option information */
+			int min;
+			int max;
+		} r;
+		struct {	/* list option information */
+			int nr;
+			struct ixgb_opt_list {
+				int i;
+				char *str;
+			} *p;
+		} l;
+	} arg;
+};
+
+static int __devinit
+ixgb_validate_option(int *value, struct ixgb_option *opt)
+{
+	if (*value == OPTION_UNSET) {
+		*value = opt->def;
+		return 0;
+	}
+
+	switch (opt->type) {
+	case enable_option:
+		switch (*value) {
+		case OPTION_ENABLED:
+			printk(KERN_INFO "%s Enabled\n", opt->name);
+			return 0;
+		case OPTION_DISABLED:
+			printk(KERN_INFO "%s Disabled\n", opt->name);
+			return 0;
+		}
+		break;
+	case range_option:
+		if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
+			printk(KERN_INFO "%s set to %i\n", opt->name, *value);
+			return 0;
+		}
+		break;
+	case list_option:
+		{
+			int i;
+			struct ixgb_opt_list *ent;
+
+			for (i = 0; i < opt->arg.l.nr; i++) {
+				ent = &opt->arg.l.p[i];
+				if (*value == ent->i) {
+					if (ent->str[0] != '\0')
+						printk(KERN_INFO "%s",
+						       ent->str);
+					return 0;
+				}
+			}
+		}
+		break;
+	default:
+		BUG();
+	}
+
+	printk(KERN_INFO "Invalid %s specified (%i) %s\n", opt->name, *value,
+	       opt->err);
+	*value = opt->def;
+	return -1;
+}
+
+#define LIST_LEN(l) (sizeof(l) / sizeof(l[0]))
+
+/**
+ * ixgb_check_options - Range Checking for Command Line Parameters
+ * @adapter: board private structure
+ *
+ * This routine checks all command line paramters for valid user
+ * input.  If an invalid value is given, or if no user specified
+ * value exists, a default value is used.  The final value is stored
+ * in a variable in the adapter structure.
+ **/
+
+void __devinit
+ixgb_check_options(struct ixgb_adapter *adapter)
+{
+	int board = adapter->bd_number;
+
+	IXGB_DBG("ixgb_check_options\n");
+
+	if (board >= IXGB_MAX_NIC) {
+		printk(KERN_NOTICE "Warning: no configuration for board #%i\n",
+		       board);
+		printk(KERN_NOTICE "Using defaults for all values\n");
+		board = IXGB_MAX_NIC;
+	}
+
+	{			/* Transmit Descriptor Count */
+		struct ixgb_option opt = {
+			.type = range_option,
+			.name = "Transmit Descriptors",
+			.err = "using default of " __MODULE_STRING(DEFAULT_TXD),
+			.def = DEFAULT_TXD,
+			.arg = {.r = {.min = MIN_TXD,.max = MAX_TXD}}
+		};
+		struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
+
+		tx_ring->count = TxDescriptors[board];
+		ixgb_validate_option(&tx_ring->count, &opt);
+		IXGB_ROUNDUP(tx_ring->count, IXGB_REQ_TX_DESCRIPTOR_MULTIPLE);
+	}
+
+	{			/* Receive Descriptor Count */
+		struct ixgb_option opt = {
+			.type = range_option,
+			.name = "Receive Descriptors",
+			.err = "using default of " __MODULE_STRING(DEFAULT_RXD),
+			.def = DEFAULT_RXD,
+			.arg = {.r = {.min = MIN_RXD,.max = MAX_RXD}}
+		};
+		struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
+
+		rx_ring->count = RxDescriptors[board];
+		ixgb_validate_option(&rx_ring->count, &opt);
+		IXGB_ROUNDUP(rx_ring->count, IXGB_REQ_RX_DESCRIPTOR_MULTIPLE);
+	}
+
+	{			/* Receive Checksum Offload Enable */
+		struct ixgb_option opt = {
+			.type = enable_option,
+			.name = "Receive Checksum Offload",
+			.err = "defaulting to Enabled",
+			.def = OPTION_ENABLED,
+		};
+		int rx_csum = XsumRX[board];
+
+		ixgb_validate_option(&rx_csum, &opt);
+		adapter->rx_csum = rx_csum;
+	}
+
+	{			/* Transmit Checksum Offload Enable */
+		struct ixgb_option opt = {
+			.type = enable_option,
+			.name = "Transmit Checksum Offload",
+			.err = "defaulting to Enabled",
+			.def = OPTION_ENABLED,
+		};
+		int tx_csum = XsumTX[board];
+
+		ixgb_validate_option(&tx_csum, &opt);
+		adapter->tx_csum = tx_csum;
+	}
+
+	{			/* Flow Control */
+		struct ixgb_opt_list fc_list[] = {
+			{ixgb_fc_none, "Flow Control Disabled\n"},
+			{ixgb_fc_rx_pause, "Flow Control Receive Only\n"},
+			{ixgb_fc_tx_pause, "Flow Control Transmit Only\n"},
+			{ixgb_fc_full, "Flow Control Enabled\n"},
+			{ixgb_fc_default, "Flow Control Hardware Default\n"}
+		};
+
+		struct ixgb_option opt = {
+			.type = list_option,
+			.name = "Flow Control",
+			.err = "reading default settings from EEPROM",
+			.def = ixgb_fc_full,
+			.arg = {.l = {.nr = LIST_LEN(fc_list),.p = fc_list}}
+		};
+
+		int fc = FlowControl[board];
+
+		ixgb_validate_option(&fc, &opt);
+		adapter->hw.fc.type = fc;
+	}
+	{			/* Receive Flow Control High Threshold */
+		struct ixgb_option fcrth = {
+			.type = range_option,
+			.name = "Rx Flow Control High Threshold",
+			.err =
+			    "using default of " __MODULE_STRING(DEFAULT_FCRTH),
+			.def = DEFAULT_FCRTH,
+			.arg = {.r = {.min = MIN_FCRTH,.max = MAX_FCRTH}}
+		};
+
+		adapter->hw.fc.high_water = RxFCHighThresh[board];
+		ixgb_validate_option(&adapter->hw.fc.high_water, &fcrth);
+		if (!(adapter->hw.fc.type & ixgb_fc_rx_pause))
+			printk(KERN_INFO
+			       "Ignoring RxFCHighThresh when no RxFC\n");
+	}
+	{			/* Receive Flow Control Low Threshold */
+		struct ixgb_option fcrtl = {
+			.type = range_option,
+			.name = "Rx Flow Control Low Threshold",
+			.err =
+			    "using default of " __MODULE_STRING(DEFAULT_FCRTL),
+			.def = DEFAULT_FCRTL,
+			.arg = {.r = {.min = MIN_FCRTL,.max = MAX_FCRTL}}
+		};
+
+		adapter->hw.fc.low_water = RxFCLowThresh[board];
+		ixgb_validate_option(&adapter->hw.fc.low_water, &fcrtl);
+		if (!(adapter->hw.fc.type & ixgb_fc_rx_pause))
+			printk(KERN_INFO
+			       "Ignoring RxFCLowThresh when no RxFC\n");
+	}
+	{			/* Flow Control Pause Time Request */
+		struct ixgb_option fcpap = {
+			.type = range_option,
+			.name = "Flow Control Pause Time Request",
+			.err =
+			    "using default of "
+			    __MODULE_STRING(DEFAULT_FCPAUSE),
+			.def = DEFAULT_FCPAUSE,
+			.arg = {.r = {.min = MIN_FCPAUSE,.max = MAX_FCPAUSE}}
+		};
+
+		int pause_time = FCReqTimeout[board];
+
+		ixgb_validate_option(&pause_time, &fcpap);
+		if (!(adapter->hw.fc.type & ixgb_fc_rx_pause))
+			printk(KERN_INFO
+			       "Ignoring FCReqTimeout when no RxFC\n");
+		adapter->hw.fc.pause_time = pause_time;
+	}
+	/* high low and spacing check for rx flow control thresholds */
+	if (adapter->hw.fc.type & ixgb_fc_rx_pause) {
+		/* high must be greater than low */
+		if (adapter->hw.fc.high_water < (adapter->hw.fc.low_water + 8)) {
+			/* set defaults */
+			printk(KERN_INFO
+			       "RxFCHighThresh must be >= (RxFCLowThresh + 8), "
+			       "Using Defaults\n");
+			adapter->hw.fc.high_water = DEFAULT_FCRTH;
+			adapter->hw.fc.low_water = DEFAULT_FCRTL;
+		}
+	}
+	{			/* Receive Interrupt Delay */
+		struct ixgb_option opt = {
+			.type = range_option,
+			.name = "Receive Interrupt Delay",
+			.err =
+			    "using default of " __MODULE_STRING(DEFAULT_RDTR),
+			.def = DEFAULT_RDTR,
+			.arg = {.r = {.min = MIN_RDTR,.max = MAX_RDTR}}
+		};
+
+		adapter->rx_int_delay = RxIntDelay[board];
+		ixgb_validate_option(&adapter->rx_int_delay, &opt);
+	}
+	{			/* Receive Interrupt Moderation */
+		struct ixgb_option opt = {
+			.type = enable_option,
+			.name = "Advanced Receive Interrupt Moderation",
+			.err = "defaulting to Enabled",
+			.def = OPTION_ENABLED,
+		};
+		int raidc = RAIDC[board];
+
+		ixgb_validate_option(&raidc, &opt);
+		adapter->raidc = raidc;
+	}
+
+	{			/* Transmit Interrupt Delay */
+		struct ixgb_option opt = {
+			.type = range_option,
+			.name = "Transmit Interrupt Delay",
+			.err =
+			    "using default of " __MODULE_STRING(DEFAULT_TIDV),
+			.def = DEFAULT_TIDV,
+			.arg = {.r = {.min = MIN_TIDV,.max = MAX_TIDV}}
+		};
+
+		adapter->tx_int_delay = TxIntDelay[board];
+		ixgb_validate_option(&adapter->tx_int_delay, &opt);
+	}
+
+	{			/* Transmit Interrupt Delay Enable */
+		struct ixgb_option opt = {
+			.type = enable_option,
+			.name = "Tx Interrupt Delay Enable",
+			.err = "defaulting to Enabled",
+			.def = OPTION_ENABLED,
+		};
+		int ide = IntDelayEnable[board];
+
+		ixgb_validate_option(&ide, &opt);
+		adapter->tx_int_delay_enable = ide;
+	}
+}
diff -Nru a/drivers/net/lance.c b/drivers/net/lance.c
--- a/drivers/net/lance.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/net/lance.c	Wed Apr 30 22:28:04 2003
@@ -278,7 +278,7 @@
 static void lance_init_ring(struct net_device *dev, int mode);
 static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static int lance_rx(struct net_device *dev);
-static void lance_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t lance_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static int lance_close(struct net_device *dev);
 static struct net_device_stats *lance_get_stats(struct net_device *dev);
 static void set_multicast_list(struct net_device *dev);
@@ -945,7 +945,7 @@
 }
 
 /* The LANCE interrupt handler. */
-static void
+static irqreturn_t
 lance_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
 	struct net_device *dev = dev_id;
@@ -955,7 +955,7 @@
 
 	if (dev == NULL) {
 		printk ("lance_interrupt(): irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	ioaddr = dev->base_addr;
@@ -1066,6 +1066,7 @@
 			   inw(dev->base_addr + LANCE_DATA));
 
 	spin_unlock (&lp->devlock);
+	return IRQ_HANDLED;
 }
 
 static int
diff -Nru a/drivers/net/lasi_82596.c b/drivers/net/lasi_82596.c
--- a/drivers/net/lasi_82596.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/net/lasi_82596.c	Wed Apr 30 22:28:05 2003
@@ -405,7 +405,7 @@
 
 static int i596_open(struct net_device *dev);
 static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static void i596_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t i596_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static int i596_close(struct net_device *dev);
 static struct net_device_stats *i596_get_stats(struct net_device *dev);
 static void i596_add_cmd(struct net_device *dev, struct i596_cmd *cmd);
@@ -1244,7 +1244,7 @@
 }
 
 
-static void i596_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t i596_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
 	struct i596_private *lp;
@@ -1252,7 +1252,7 @@
 
 	if (dev == NULL) {
 		printk("i596_interrupt(): irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	lp = (struct i596_private *) dev->priv;
@@ -1270,7 +1270,7 @@
 	if (!ack_cmd) {
 		DEB(DEB_ERRORS, printk("%s: interrupt with no events\n", dev->name));
 		spin_unlock (&lp->lock);
-		return;
+		return IRQ_NONE;
 	}
 
 	if ((status & 0x8000) || (status & 0x2000)) {
@@ -1396,7 +1396,7 @@
 	DEB(DEB_INTS,printk("%s: exiting interrupt.\n", dev->name));
 
 	spin_unlock (&lp->lock);
-	return;
+	return IRQ_HANDLED;
 }
 
 static int i596_close(struct net_device *dev)
diff -Nru a/drivers/net/lp486e.c b/drivers/net/lp486e.c
--- a/drivers/net/lp486e.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/net/lp486e.c	Wed Apr 30 22:28:06 2003
@@ -377,7 +377,7 @@
 
 static int i596_open(struct net_device *dev);
 static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static void i596_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t i596_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static int i596_close(struct net_device *dev);
 static struct net_device_stats *i596_get_stats(struct net_device *dev);
 static void i596_add_cmd(struct net_device *dev, struct i596_cmd *cmd);
@@ -1160,7 +1160,7 @@
 	spin_unlock_irqrestore(&lp->cmd_lock, flags);
 }
 
-static void
+static irqreturn_t
 i596_interrupt (int irq, void *dev_instance, struct pt_regs *regs) {
 	struct net_device *dev = (struct net_device *) dev_instance;
 	struct i596_private *lp;
@@ -1229,7 +1229,7 @@
 	CA();
 
  out:
-	return;
+	return IRQ_HANDLED;
 }
 
 static int i596_close(struct net_device *dev) {
diff -Nru a/drivers/net/mac89x0.c b/drivers/net/mac89x0.c
--- a/drivers/net/mac89x0.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/net/mac89x0.c	Wed Apr 30 22:28:09 2003
@@ -129,7 +129,7 @@
 #endif
 static int net_open(struct net_device *dev);
 static int	net_send_packet(struct sk_buff *skb, struct net_device *dev);
-static void net_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t net_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void set_multicast_list(struct net_device *dev);
 static void net_rx(struct net_device *dev);
 static int net_close(struct net_device *dev);
@@ -424,7 +424,7 @@
 
 /* The typical workload of the driver:
    Handle the network interface interrupts. */
-static void net_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t net_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
 	struct net_device *dev = dev_id;
 	struct net_local *lp;
@@ -432,7 +432,7 @@
 
 	if (dev == NULL) {
 		printk ("net_interrupt(): irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 	if (dev->interrupt)
 		printk("%s: Re-entering the interrupt handler.\n", dev->name);
@@ -491,7 +491,7 @@
 		}
 	}
 	dev->interrupt = 0;
-	return;
+	return IRQ_HANDLED;
 }
 
 /* We have a good packet(s), get it/them out of the buffers. */
diff -Nru a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
--- a/drivers/net/myri_sbus.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/net/myri_sbus.c	Wed Apr 30 22:28:04 2003
@@ -533,7 +533,7 @@
 	}
 }
 
-static void myri_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t myri_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev		= (struct net_device *) dev_id;
 	struct myri_eth *mp		= (struct myri_eth *) dev->priv;
@@ -567,6 +567,8 @@
 	DIRQ(("\n"));
 
 	spin_unlock_irqrestore(&mp->irq_lock, flags);
+
+	return IRQ_HANDLED;
 }
 
 static int myri_open(struct net_device *dev)
diff -Nru a/drivers/net/natsemi.c b/drivers/net/natsemi.c
--- a/drivers/net/natsemi.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/net/natsemi.c	Wed Apr 30 22:28:04 2003
@@ -696,7 +696,7 @@
 static void reinit_ring(struct net_device *dev);
 static void init_registers(struct net_device *dev);
 static int start_tx(struct sk_buff *skb, struct net_device *dev);
-static void intr_handler(int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *regs);
 static void netdev_error(struct net_device *dev, int intr_status);
 static void netdev_rx(struct net_device *dev);
 static void netdev_tx_done(struct net_device *dev);
@@ -1680,15 +1680,16 @@
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
-static void intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
+static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
 {
 	struct net_device *dev = dev_instance;
 	struct netdev_private *np = dev->priv;
 	long ioaddr = dev->base_addr;
 	int boguscnt = max_interrupt_work;
+	unsigned int handled = 0;
 
 	if (np->hands_off)
-		return;
+		return IRQ_NONE;
 	do {
 		/* Reading automatically acknowledges all int sources. */
 		u32 intr_status = readl(ioaddr + IntrStatus);
@@ -1701,6 +1702,7 @@
 
 		if (intr_status == 0)
 			break;
+		handled = 1;
 
 		if (intr_status &
 		   (IntrRxDone | IntrRxIntr | RxStatusFIFOOver |
@@ -1731,6 +1733,8 @@
 
 	if (netif_msg_intr(np))
 		printk(KERN_DEBUG "%s: exiting interrupt.\n", dev->name);
+
+	return IRQ_RETVAL(handled);
 }
 
 /* This routine is logically part of the interrupt handler, but separated
diff -Nru a/drivers/net/ni5010.c b/drivers/net/ni5010.c
--- a/drivers/net/ni5010.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/net/ni5010.c	Wed Apr 30 22:28:08 2003
@@ -104,7 +104,7 @@
 static int	ni5010_probe1(struct net_device *dev, int ioaddr);
 static int	ni5010_open(struct net_device *dev);
 static int	ni5010_send_packet(struct sk_buff *skb, struct net_device *dev);
-static void	ni5010_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t ni5010_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void	ni5010_rx(struct net_device *dev);
 static void	ni5010_timeout(struct net_device *dev);
 static int	ni5010_close(struct net_device *dev);
@@ -451,7 +451,7 @@
  * The typical workload of the driver:
  * Handle the network interface interrupts. 
  */
-static void  ni5010_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t ni5010_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
 	struct ni5010_local *lp;
@@ -479,7 +479,7 @@
 
 	if (!xmit_was_error) 
 		reset_receiver(dev); 
-	return;
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/net/ni52.c b/drivers/net/ni52.c
--- a/drivers/net/ni52.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/net/ni52.c	Wed Apr 30 22:28:11 2003
@@ -193,7 +193,7 @@
 #define NI52_ADDR2 0x01
 
 static int     ni52_probe1(struct net_device *dev,int ioaddr);
-static void    ni52_interrupt(int irq,void *dev_id,struct pt_regs *reg_ptr);
+static irqreturn_t ni52_interrupt(int irq,void *dev_id,struct pt_regs *reg_ptr);
 static int     ni52_open(struct net_device *dev);
 static int     ni52_close(struct net_device *dev);
 static int     ni52_send_packet(struct sk_buff *,struct net_device *);
@@ -821,7 +821,7 @@
  * Interrupt Handler ...
  */
 
-static void ni52_interrupt(int irq,void *dev_id,struct pt_regs *reg_ptr)
+static irqreturn_t ni52_interrupt(int irq,void *dev_id,struct pt_regs *reg_ptr)
 {
 	struct net_device *dev = dev_id;
 	unsigned short stat;
@@ -830,7 +830,7 @@
 
 	if (!dev) {
 		printk ("ni5210-interrupt: irq %d for unknown device.\n",irq);
-		return;
+		return IRQ_NONE;
 	}
 	p = (struct priv *) dev->priv;
 
@@ -889,6 +889,7 @@
 
 	if(debuglevel > 1)
 		printk("i");
+	return IRQ_HANDLED;
 }
 
 /*******************************************************
diff -Nru a/drivers/net/ni65.c b/drivers/net/ni65.c
--- a/drivers/net/ni65.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/net/ni65.c	Wed Apr 30 22:28:06 2003
@@ -248,7 +248,7 @@
 };
 
 static int  ni65_probe1(struct net_device *dev,int);
-static void ni65_interrupt(int irq, void * dev_id, struct pt_regs *regs);
+static irqreturn_t ni65_interrupt(int irq, void * dev_id, struct pt_regs *regs);
 static void ni65_recv_intr(struct net_device *dev,int);
 static void ni65_xmit_intr(struct net_device *dev,int);
 static int  ni65_open(struct net_device *dev);
@@ -307,7 +307,6 @@
 	if(ni65_lance_reinit(dev))
 	{
 		netif_start_queue(dev);
-		MOD_INC_USE_COUNT;
 		return 0;
 	}
 	else
@@ -341,7 +340,6 @@
 	}
 #endif
 	free_irq(dev->irq,dev);
-	MOD_DEC_USE_COUNT;
 	return 0;
 }
 
@@ -512,7 +510,7 @@
 	}
 
 	dev->base_addr = ioaddr;
-
+	SET_MODULE_OWNER(dev);
 	dev->open		= ni65_open;
 	dev->stop		= ni65_close;
 	dev->hard_start_xmit	= ni65_send_packet;
@@ -839,7 +837,7 @@
 /*
  * interrupt handler
  */
-static void ni65_interrupt(int irq, void * dev_id, struct pt_regs * regs)
+static irqreturn_t ni65_interrupt(int irq, void * dev_id, struct pt_regs * regs)
 {
 	int csr0 = 0;
 	struct net_device *dev = dev_id;
@@ -940,7 +938,7 @@
 	else
 		writedatareg(CSR0_INEA);
 
-	return;
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/net/ns83820.c b/drivers/net/ns83820.c
--- a/drivers/net/ns83820.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/net/ns83820.c	Wed Apr 30 22:28:18 2003
@@ -549,7 +549,7 @@
 static inline int rx_refill(struct ns83820 *dev, int gfp)
 {
 	unsigned i;
-	long flags = 0;
+	unsigned long flags = 0;
 
 	if (unlikely(nr_rx_empty(dev) <= 2))
 		return 0;
@@ -763,7 +763,7 @@
 static void ns83820_cleanup_rx(struct ns83820 *dev)
 {
 	unsigned i;
-	long flags;
+	unsigned long flags;
 
 	dprintk("ns83820_cleanup_rx(%p)\n", dev);
 
@@ -820,7 +820,7 @@
 	struct rx_info *info = &dev->rx_info;
 	unsigned next_rx;
 	u32 cmdsts, *desc;
-	long flags;
+	unsigned long flags;
 	int nr = 0;
 
 	dprintk("rx_irq(%p)\n", dev);
@@ -1234,7 +1234,7 @@
 }
 
 static void ns83820_do_isr(struct ns83820 *dev, u32 isr);
-static void ns83820_irq(int foo, void *data, struct pt_regs *regs)
+static irqreturn_t ns83820_irq(int foo, void *data, struct pt_regs *regs)
 {
 	struct ns83820 *dev = data;
 	u32 isr;
@@ -1245,6 +1245,7 @@
 	isr = readl(dev->base + ISR);
 	dprintk("irq: %08x\n", isr);
 	ns83820_do_isr(dev, isr);
+	return IRQ_HANDLED;
 }
 
 static void ns83820_do_isr(struct ns83820 *dev, u32 isr)
@@ -1396,7 +1397,7 @@
 {
 	struct ns83820 *dev = (struct ns83820 *)_dev;
         u32 tx_done_idx, *desc;
-	long flags;
+	unsigned long flags;
 
 	local_irq_save(flags);
 
diff -Nru a/drivers/net/pci-skeleton.c b/drivers/net/pci-skeleton.c
--- a/drivers/net/pci-skeleton.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/pci-skeleton.c	Wed Apr 30 22:28:03 2003
@@ -505,7 +505,7 @@
 static void netdrv_init_ring (struct net_device *dev);
 static int netdrv_start_xmit (struct sk_buff *skb,
 			       struct net_device *dev);
-static void netdrv_interrupt (int irq, void *dev_instance,
+static irqreturn_t netdrv_interrupt (int irq, void *dev_instance,
 			       struct pt_regs *regs);
 static int netdrv_close (struct net_device *dev);
 static int netdrv_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
@@ -1665,7 +1665,7 @@
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
-static void netdrv_interrupt (int irq, void *dev_instance,
+static irqreturn_t netdrv_interrupt (int irq, void *dev_instance,
 			       struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *) dev_instance;
@@ -1673,6 +1673,7 @@
 	int boguscnt = max_interrupt_work;
 	void *ioaddr = tp->mmio_addr;
 	int status = 0, link_changed = 0; /* avoid bogus "uninit" warning */
+	int handled = 0;
 
 	spin_lock (&tp->lock);
 
@@ -1683,6 +1684,7 @@
 		if (status == 0xFFFF)
 			break;
 
+		handled = 1;
 		/* Acknowledge all of the current interrupt sources ASAP */
 		NETDRV_W16_F (IntrStatus, status);
 
@@ -1724,6 +1726,7 @@
 
 	DPRINTK ("%s: exiting interrupt, intr_status=%#4.4x.\n",
 		 dev->name, NETDRV_R16 (IntrStatus));
+	return IRQ_RETVAL(handled);
 }
 
 
diff -Nru a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
--- a/drivers/net/pcmcia/3c574_cs.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/net/pcmcia/3c574_cs.c	Wed Apr 30 22:28:06 2003
@@ -247,7 +247,7 @@
 static void media_check(unsigned long arg);
 static int el3_open(struct net_device *dev);
 static int el3_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static void el3_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t el3_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void update_stats(struct net_device *dev);
 static struct net_device_stats *el3_get_stats(struct net_device *dev);
 static int el3_rx(struct net_device *dev, int worklimit);
@@ -273,16 +273,6 @@
 	}
 }
 
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-#if CS_RELEASE_CODE < 0x2911
-	CardServices(ReportError, dev_info, (void *)func, (void *)ret);
-#else
-	error_info_t err = { func, ret };
-	CardServices(ReportError, handle, &err);
-#endif
-}
-
 /*
 	tc574_attach() creates an "instance" of the driver, allocating
 	local data structures for one device.  The device is registered
@@ -940,24 +930,23 @@
 		outw(SetTxThreshold + (1536>>2), ioaddr + EL3_CMD);
 	}
 
-	dev_kfree_skb (skb);
 	pop_tx_status(dev);
-
-	spin_unlock(&lp->window_lock);
-	
+	spin_unlock_irqrestore(&lp->window_lock, flags);
+	dev_kfree_skb(skb);
 	return 0;
 }
 
 /* The EL3 interrupt handler. */
-static void el3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t el3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct el3_private *lp = dev_id;
 	struct net_device *dev = &lp->dev;
 	ioaddr_t ioaddr, status;
 	int work_budget = max_interrupt_work;
+	int handled = 0;
 
 	if (!netif_device_present(dev))
-		return;
+		return IRQ_NONE;
 	ioaddr = dev->base_addr;
 
 	DEBUG(3, "%s: interrupt, status %4.4x.\n",
@@ -973,6 +962,8 @@
 			break;
 		}
 
+		handled = 1;
+
 		if (status & RxComplete)
 			work_budget = el3_rx(dev, work_budget);
 
@@ -1031,7 +1022,7 @@
 		  dev->name, inw(ioaddr + EL3_STATUS));
 		  
 	spin_unlock(&lp->window_lock);
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 /*
@@ -1338,37 +1329,26 @@
 	return 0;
 }
 
-static int __init init_3c574_cs(void)
-{
-	servinfo_t serv;
+static struct pcmcia_driver tc574_driver = {
+	.owner		= THIS_MODULE,
+	.drv		= {
+		.name	= "3c574_cs",
+	},
+	.attach		= tc574_attach,
+	.detach		= tc574_detach,
+};
 
-	DEBUG(0, "%s\n", version);
-	CardServices(GetCardServicesInfo, &serv);
-	if (serv.Revision != CS_RELEASE_CODE) {
-		printk(KERN_NOTICE "3c574_cs: Card Services release "
-			   "does not match!\n");
-		return -1;
-	}
-	register_pccard_driver(&dev_info, &tc574_attach, &tc574_detach);
-	return 0;
+static int __init init_tc574(void)
+{
+	return pcmcia_register_driver(&tc574_driver);
 }
 
-static void __exit exit_3c574_cs(void)
+static void __exit exit_tc574(void)
 {
-	DEBUG(0, "3c574_cs: unloading\n");
-	unregister_pccard_driver(&dev_info);
+	pcmcia_unregister_driver(&tc574_driver);
 	while (dev_list != NULL)
 		tc574_detach(dev_list);
 }
 
-module_init(init_3c574_cs);
-module_exit(exit_3c574_cs);
-
-/*
- * Local variables:
- *  compile-command: "make 3c574_cs.o"
- *  c-indent-level: 4
- *  c-basic-offset: 4
- *  tab-width: 4
- * End:
- */
+module_init(init_tc574);
+module_exit(exit_tc574);
diff -Nru a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
--- a/drivers/net/pcmcia/3c589_cs.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/net/pcmcia/3c589_cs.c	Wed Apr 30 22:28:17 2003
@@ -193,14 +193,6 @@
     }
 }
 
-/*====================================================================*/
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
 /*======================================================================
 
     tc589_attach() creates an "instance" of the driver, allocating
@@ -249,6 +241,7 @@
     link->conf.Present = PRESENT_OPTION;
     
     /* The EL3-specific entries in the device structure. */
+    SET_MODULE_OWNER(dev);
     dev->hard_start_xmit = &el3_start_xmit;
     dev->set_config = &el3_config;
     dev->get_stats = &el3_get_stats;
@@ -740,7 +733,6 @@
 	return -ENODEV;
 
     link->open++;
-    MOD_INC_USE_COUNT;
     netif_start_queue(dev);
     
     tc589_reset(dev);
@@ -1148,33 +1140,29 @@
     if (link->state & DEV_STALE_CONFIG)
 	mod_timer(&link->release, jiffies + HZ/20);
     
-    MOD_DEC_USE_COUNT;
-    
     return 0;
 }
 
-/*====================================================================*/
+static struct pcmcia_driver tc589_driver = {
+	.owner		= THIS_MODULE,
+	.drv		= {
+		.name	= "3c589_cs",
+	},
+	.attach		= tc589_attach,
+	.detach		= tc589_detach,
+};
 
-static int __init init_3c589_cs(void)
+static int __init init_tc589(void)
 {
-    servinfo_t serv;
-    DEBUG(0, "%s\n", version);
-    CardServices(GetCardServicesInfo, &serv);
-    if (serv.Revision != CS_RELEASE_CODE) {
-	printk(KERN_ERR "3c589_cs: Card Services release does not match!\n");
-	return -1;
-    }
-    register_pccard_driver(&dev_info, &tc589_attach, &tc589_detach);
-    return 0;
+	return pcmcia_register_driver(&tc589_driver);
 }
 
-static void __exit exit_3c589_cs(void)
+static void __exit exit_tc589(void)
 {
-    DEBUG(0, "3c589_cs: unloading\n");
-    unregister_pccard_driver(&dev_info);
-    while (dev_list != NULL)
-	tc589_detach(dev_list);
+	pcmcia_unregister_driver(&tc589_driver);
+	while (dev_list != NULL)
+		tc589_detach(dev_list);
 }
 
-module_init(init_3c589_cs);
-module_exit(exit_3c589_cs);
+module_init(init_tc589);
+module_exit(exit_tc589);
diff -Nru a/drivers/net/pcmcia/Kconfig b/drivers/net/pcmcia/Kconfig
--- a/drivers/net/pcmcia/Kconfig	Wed Apr 30 22:28:14 2003
+++ b/drivers/net/pcmcia/Kconfig	Wed Apr 30 22:28:14 2003
@@ -17,7 +17,7 @@
 	  To use your PC-cards, you will need supporting software from David
 	  Hinds' pcmcia-cs package (see the file <file:Documentation/Changes>
 	  for location).  You also want to check out the PCMCIA-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>.
+	  available from <http://www.tldp.org/docs.html#howto>.
 
 	  If unsure, say N.
 
diff -Nru a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
--- a/drivers/net/pcmcia/axnet_cs.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/net/pcmcia/axnet_cs.c	Wed Apr 30 22:28:10 2003
@@ -98,7 +98,7 @@
 static int axnet_open(struct net_device *dev);
 static int axnet_close(struct net_device *dev);
 static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
-static void ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs);
 static void ei_watchdog(u_long arg);
 static void axnet_reset_8390(struct net_device *dev);
 
@@ -122,7 +122,7 @@
 static void AX88190_init(struct net_device *dev, int startp);
 static int ax_open(struct net_device *dev);
 static int ax_close(struct net_device *dev);
-static void ax_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t ax_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 /*====================================================================*/
 
@@ -157,14 +157,6 @@
     }
 }
 
-/*====================================================================*/
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
 /*======================================================================
 
     We never need to do anything when a axnet device is "initialized"
@@ -687,7 +679,6 @@
 	return -ENODEV;
 
     link->open++;
-    MOD_INC_USE_COUNT;
 
     request_irq(dev->irq, ei_irq_wrapper, SA_SHIRQ, dev_info, dev);
 
@@ -719,8 +710,6 @@
     if (link->state & DEV_STALE_CONFIG)
 	mod_timer(&link->release, jiffies + HZ/20);
 
-    MOD_DEC_USE_COUNT;
-
     return 0;
 } /* axnet_close */
 
@@ -757,11 +746,11 @@
 
 /*====================================================================*/
 
-static void ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs)
 {
     axnet_dev_t *info = dev_id;
     info->stale = 0;
-    ax_interrupt(irq, dev_id, regs);
+    return ax_interrupt(irq, dev_id, regs);
 }
 
 static void ei_watchdog(u_long arg)
@@ -933,28 +922,25 @@
     outsw(nic_base + AXNET_DATAPORT, buf, count>>1);
 }
 
-/*====================================================================*/
+static struct pcmcia_driver axnet_cs_driver = {
+	.owner		= THIS_MODULE,
+	.drv		= {
+		.name	= "axnet_cs",
+	},
+	.attach		= axnet_attach,
+	.detach		= axnet_detach,
+};
 
 static int __init init_axnet_cs(void)
 {
-    servinfo_t serv;
-    DEBUG(0, "%s\n", version);
-    CardServices(GetCardServicesInfo, &serv);
-    if (serv.Revision != CS_RELEASE_CODE) {
-	printk(KERN_NOTICE "axnet_cs: Card Services release "
-	       "does not match!\n");
-	return -EINVAL;
-    }
-    register_pccard_driver(&dev_info, &axnet_attach, &axnet_detach);
-    return 0;
+	return pcmcia_register_driver(&axnet_cs_driver);
 }
 
 static void __exit exit_axnet_cs(void)
 {
-    DEBUG(0, "axnet_cs: unloading\n");
-    unregister_pccard_driver(&dev_info);
-    while (dev_list != NULL)
-	axnet_detach(dev_list);
+	pcmcia_unregister_driver(&axnet_cs_driver);
+	while (dev_list != NULL)
+		axnet_detach(dev_list);
 }
 
 module_init(init_axnet_cs);
@@ -1345,17 +1331,18 @@
  * needed.
  */
 
-static void ax_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t ax_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
 	struct net_device *dev = dev_id;
 	long e8390_base;
 	int interrupts, nr_serviced = 0, i;
 	struct ei_device *ei_local;
-    
+    	int handled = 0;
+
 	if (dev == NULL) 
 	{
 		printk ("net_interrupt(): irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
     
 	e8390_base = dev->base_addr;
@@ -1378,7 +1365,7 @@
 			   inb_p(e8390_base + EN0_IMR));
 #endif
 		spin_unlock(&ei_local->page_lock);
-		return;
+		return IRQ_NONE;
 	}
     
 	if (ei_debug > 3)
@@ -1399,6 +1386,8 @@
 			interrupts = 0;
 			break;
 		}
+		handled = 1;
+
 		/* AX88190 bug fix. */
 		outb_p(interrupts, e8390_base + EN0_ISR);
 		for (i = 0; i < 10; i++) {
@@ -1430,6 +1419,7 @@
     
 	if (interrupts && ei_debug) 
 	{
+		handled = 1;
 		if (nr_serviced >= MAX_SERVICE) 
 		{
 			/* 0xFF is valid for a card removal */
@@ -1448,7 +1438,7 @@
 	outb_p(ENISR_ALL, e8390_base + EN0_IMR);
 
 	spin_unlock(&ei_local->page_lock);
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 /**
@@ -1842,6 +1832,8 @@
 	if (ei_debug > 1)
 		printk(version_8390);
     
+	SET_MODULE_OWNER(dev);
+
 	if (dev->priv == NULL) 
 	{
 		struct ei_device *ei_local;
diff -Nru a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
--- a/drivers/net/pcmcia/com20020_cs.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/net/pcmcia/com20020_cs.c	Wed Apr 30 22:28:09 2003
@@ -163,14 +163,6 @@
     }
 }
 
-/*====================================================================*/
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
 /*======================================================================
 
     com20020_attach() creates an "instance" of the driver, allocating
@@ -567,29 +559,26 @@
 } /* com20020_event */
 
 
-/*====================================================================*/
+
+static struct pcmcia_driver com20020_cs_driver = {
+	.owner		= THIS_MODULE,
+	.drv		= {
+		.name	= "com20020_cs",
+	},
+	.attach		= com20020_attach,
+	.detach		= com20020_detach,
+};
 
 static int __init init_com20020_cs(void)
 {
-    servinfo_t serv;
-
-    DEBUG(0, "%s\n", VERSION);
-    CardServices(GetCardServicesInfo, &serv);
-    if (serv.Revision != CS_RELEASE_CODE) {
-	printk(KERN_NOTICE "com20020_cs: Card Services release "
-	       "does not match!\n");
-        return -1;
-    }
-    register_pccard_driver(&dev_info, &com20020_attach, &com20020_detach);
-    return 0;
+	return pcmcia_register_driver(&com20020_cs_driver);
 }
 
 static void __exit exit_com20020_cs(void)
 {
-    DEBUG(0, "com20020_cs: unloading\n");
-    unregister_pccard_driver(&dev_info);
-    while (dev_list != NULL)
-        com20020_detach(dev_list);
+	pcmcia_unregister_driver(&com20020_cs_driver);
+	while (dev_list != NULL)
+		com20020_detach(dev_list);
 }
 
 module_init(init_com20020_cs);
diff -Nru a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
--- a/drivers/net/pcmcia/fmvj18x_cs.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/net/pcmcia/fmvj18x_cs.c	Wed Apr 30 22:28:12 2003
@@ -261,16 +261,6 @@
     }
 }
 
-/*====================================================================*/
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
-/*====================================================================*/
-
 static dev_link_t *fmvj18x_attach(void)
 {
     local_info_t *lp;
@@ -314,6 +304,7 @@
     link->conf.IntType = INT_MEMORY_AND_IO;
 
     /* The FMVJ18x specific entries in the device structure. */
+    SET_MODULE_OWNER(dev);
     dev->hard_start_xmit = &fjn_start_xmit;
     dev->set_config = &fjn_config;
     dev->get_stats = &fjn_get_stats;
@@ -828,28 +819,25 @@
     return 0;
 } /* fmvj18x_event */
 
-/*====================================================================*/
+static struct pcmcia_driver fmvj18x_cs_driver = {
+	.owner		= THIS_MODULE,
+	.drv		= {
+		.name	= "fmvj18x_cs",
+	},
+	.attach		= fmvj18x_attach,
+	.detach		= fmvj18x_detach,
+};
 
 static int __init init_fmvj18x_cs(void)
 {
-    servinfo_t serv;
-    DEBUG(0, "%s\n", version);
-    CardServices(GetCardServicesInfo, &serv);
-    if (serv.Revision != CS_RELEASE_CODE) {
-	printk(KERN_NOTICE "fmvj18x: Card Services release "
-	       "does not match!\n");
-	return -EINVAL;
-    }
-    register_pccard_driver(&dev_info, &fmvj18x_attach, &fmvj18x_detach);
-    return 0;
+	return pcmcia_register_driver(&fmvj18x_cs_driver);
 }
 
 static void __exit exit_fmvj18x_cs(void)
 {
-    DEBUG(0, "fmvj18x_cs: unloading\n");
-    unregister_pccard_driver(&dev_info);
-    while (dev_list != NULL)
-	fmvj18x_detach(dev_list);
+	pcmcia_unregister_driver(&fmvj18x_cs_driver);
+	while (dev_list != NULL)
+		fmvj18x_detach(dev_list);
 }
 
 module_init(init_fmvj18x_cs);
@@ -1287,8 +1275,6 @@
     lp->open_time = jiffies;
     netif_start_queue(dev);
     
-    MOD_INC_USE_COUNT;
-
     return 0;
 } /* fjn_open */
 
@@ -1323,7 +1309,6 @@
     link->open--;
     if (link->state & DEV_STALE_CONFIG)
 	mod_timer(&link->release, jiffies + HZ/20);
-    MOD_DEC_USE_COUNT;
 
     return 0;
 } /* fjn_close */
@@ -1369,9 +1354,11 @@
 	
 	memset(mc_filter, 0, sizeof(mc_filter));
 	for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count;
-	     i++, mclist = mclist->next)
-	    set_bit(ether_crc_le(ETH_ALEN, mclist->dmi_addr) & 0x3f,
-		    mc_filter);
+	     i++, mclist = mclist->next) {
+	    unsigned int bit =
+	    	ether_crc_le(ETH_ALEN, mclist->dmi_addr) & 0x3f;
+	    mc_filter[bit >> 3] |= (1 << bit);
+	}
     }
     
     save_flags(flags);
diff -Nru a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
--- a/drivers/net/pcmcia/ibmtr_cs.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/net/pcmcia/ibmtr_cs.c	Wed Apr 30 22:28:10 2003
@@ -157,14 +157,6 @@
     }
 }
 
-/*====================================================================*/
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
 static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
 {
 	u32 ethcmd;
@@ -585,28 +577,25 @@
     return;
 }
 
-/*====================================================================*/
+static struct pcmcia_driver ibmtr_cs_driver = {
+	.owner		= THIS_MODULE,
+	.drv		= {
+		.name	= "ibmtr_cs",
+	},
+	.attach		= ibmtr_attach,
+	.detach		= ibmtr_detach,
+};
 
 static int __init init_ibmtr_cs(void)
 {
-    servinfo_t serv;
-    DEBUG(0, "%s", version);
-    CardServices(GetCardServicesInfo, &serv);
-    if (serv.Revision != CS_RELEASE_CODE) {
-        printk(KERN_NOTICE "ibmtr_cs: Card Services release "
-	       "does not match!\n");
-        return -1;
-    }
-    register_pccard_driver(&dev_info, &ibmtr_attach, &ibmtr_detach);
-    return 0;
+	return pcmcia_register_driver(&ibmtr_cs_driver);
 }
 
 static void __exit exit_ibmtr_cs(void)
 {
-    DEBUG(0, "ibmtr_cs: unloading\n");
-    unregister_pccard_driver(&dev_info);
-    while (dev_list != NULL)
-        ibmtr_detach(dev_list);
+	pcmcia_unregister_driver(&ibmtr_cs_driver);
+	while (dev_list != NULL)
+		ibmtr_detach(dev_list);
 }
 
 module_init(init_ibmtr_cs);
diff -Nru a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
--- a/drivers/net/pcmcia/nmclan_cs.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/net/pcmcia/nmclan_cs.c	Wed Apr 30 22:28:04 2003
@@ -457,17 +457,6 @@
 }
 
 /* ----------------------------------------------------------------------------
-cs_error
-	Report a Card Services related error.
----------------------------------------------------------------------------- */
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
-/* ----------------------------------------------------------------------------
 nmclan_attach
 	Creates an "instance" of the driver, allocating local data
 	structures for one device.  The device is registered with Card
@@ -515,6 +504,7 @@
 
     lp->tx_free_frames=AM2150_MAX_TX_FRAMES;
 
+    SET_MODULE_OWNER(dev);
     dev->hard_start_xmit = &mace_start_xmit;
     dev->set_config = &mace_config;
     dev->get_stats = &mace_get_stats;
@@ -974,7 +964,6 @@
     return -ENODEV;
 
   link->open++;
-  MOD_INC_USE_COUNT;
 
   MACEBANK(0);
 
@@ -1004,8 +993,6 @@
   if (link->state & DEV_STALE_CONFIG)
     mod_timer(&link->release, jiffies + HZ/20);
 
-  MOD_DEC_USE_COUNT;
-
   return 0;
 } /* mace_close */
 
@@ -1743,33 +1730,25 @@
 
 } /* set_multicast_list */
 
-/* ----------------------------------------------------------------------------
-init_nmclan_cs
----------------------------------------------------------------------------- */
+static struct pcmcia_driver nmclan_cs_driver = {
+	.owner		= THIS_MODULE,
+	.drv		= {
+		.name	= "nmclan_cs",
+	},
+	.attach		= nmclan_attach,
+	.detach		= nmclan_detach,
+};
 
 static int __init init_nmclan_cs(void)
 {
-  servinfo_t serv;
-  DEBUG(0, "%s\n", version);
-  CardServices(GetCardServicesInfo, &serv);
-  if (serv.Revision != CS_RELEASE_CODE) {
-    printk(KERN_NOTICE "nmclan_cs: Card Services release does not match!\n");
-    return -1;
-  }
-  register_pccard_driver(&dev_info, &nmclan_attach, &nmclan_detach);
-  return 0;
+	return pcmcia_register_driver(&nmclan_cs_driver);
 }
 
-/* ----------------------------------------------------------------------------
-exit_nmclan_cs
----------------------------------------------------------------------------- */
-
 static void __exit exit_nmclan_cs(void)
 {
-    DEBUG(0, "nmclan_cs: unloading\n");
-    unregister_pccard_driver(&dev_info);
-    while (dev_list != NULL)
-	nmclan_detach(dev_list);
+	pcmcia_unregister_driver(&nmclan_cs_driver);
+	while (dev_list != NULL)
+		nmclan_detach(dev_list);
 }
 
 module_init(init_nmclan_cs);
diff -Nru a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
--- a/drivers/net/pcmcia/pcnet_cs.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/net/pcmcia/pcnet_cs.c	Wed Apr 30 22:28:15 2003
@@ -117,7 +117,7 @@
 static int pcnet_close(struct net_device *dev);
 static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static int do_ioctl_light(struct net_device *dev, struct ifreq *rq, int cmd);
-static void ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs);
 static void ei_watchdog(u_long arg);
 static void pcnet_reset_8390(struct net_device *dev);
 static int set_config(struct net_device *dev, struct ifmap *map);
@@ -255,14 +255,6 @@
     }
 }
 
-/*====================================================================*/
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
 /*======================================================================
 
     We never need to do anything when a pcnet device is "initialized"
@@ -315,6 +307,7 @@
     link->conf.IntType = INT_MEMORY_AND_IO;
 
     ethdev_init(dev);
+    SET_MODULE_OWNER(dev);
     dev->init = &pcnet_init;
     dev->open = &pcnet_open;
     dev->stop = &pcnet_close;
@@ -1030,7 +1023,6 @@
 	return -ENODEV;
 
     link->open++;
-    MOD_INC_USE_COUNT;
 
     set_misc_reg(dev);
     request_irq(dev->irq, ei_irq_wrapper, SA_SHIRQ, dev_info, dev);
@@ -1064,8 +1056,6 @@
     if (link->state & DEV_STALE_CONFIG)
 	mod_timer(&link->release, jiffies + HZ/20);
 
-    MOD_DEC_USE_COUNT;
-
     return 0;
 } /* pcnet_close */
 
@@ -1121,11 +1111,13 @@
 
 /*====================================================================*/
 
-static void ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs)
 {
     pcnet_dev_t *info = dev_id;
     info->stale = 0;
     ei_interrupt(irq, dev_id, regs);
+    /* FIXME! Was it really ours? */
+    return IRQ_HANDLED;
 }
 
 static void ei_watchdog(u_long arg)
diff -Nru a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
--- a/drivers/net/pcmcia/smc91c92_cs.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/net/pcmcia/smc91c92_cs.c	Wed Apr 30 22:28:12 2003
@@ -324,14 +324,6 @@
     }
 }
 
-/*====================================================================*/
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
 /*======================================================================
 
   smc91c92_attach() creates an "instance" of the driver, allocating
@@ -376,6 +368,7 @@
     link->conf.IntType = INT_MEMORY_AND_IO;
 
     /* The SMC91c92-specific entries in the device structure. */
+    SET_MODULE_OWNER(dev);
     dev->hard_start_xmit = &smc_start_xmit;
     dev->get_stats = &smc_get_stats;
     dev->set_config = &s9k_config;
@@ -1301,7 +1294,6 @@
 	return -ENODEV;
     }
     link->open++;
-    MOD_INC_USE_COUNT;
 
     netif_start_queue(dev);
     smc->saved_skb = 0;
@@ -1347,8 +1339,6 @@
     if (link->state & DEV_STALE_CONFIG)
 	mod_timer(&link->release, jiffies + HZ/20);
 
-    MOD_DEC_USE_COUNT;
-
     return 0;
 } /* smc_close */
 
@@ -2267,29 +2257,25 @@
     return rc;
 }
 
-
-/*====================================================================*/
+static struct pcmcia_driver smc91c92_cs_driver = {
+	.owner		= THIS_MODULE,
+	.drv		= {
+		.name	= "smc91c92_cs",
+	},
+	.attach		= smc91c92_attach,
+	.detach		= smc91c92_detach,
+};
 
 static int __init init_smc91c92_cs(void)
 {
-    servinfo_t serv;
-    DEBUG(0, "%s\n", version);
-    CardServices(GetCardServicesInfo, &serv);
-    if (serv.Revision != CS_RELEASE_CODE) {
-	printk(KERN_ERR
-	       "smc91c92_cs: Card Services release does not match!\n");
-	return -EINVAL;
-    }
-    register_pccard_driver(&dev_info, &smc91c92_attach, &smc91c92_detach);
-    return 0;
+	return pcmcia_register_driver(&smc91c92_cs_driver);
 }
 
 static void __exit exit_smc91c92_cs(void)
 {
-    DEBUG(0, "smc91c92_cs: unloading\n");
-    unregister_pccard_driver(&dev_info);
-    while (dev_list != NULL)
-	smc91c92_detach(dev_list);
+	pcmcia_unregister_driver(&smc91c92_cs_driver);
+	while (dev_list != NULL)
+		smc91c92_detach(dev_list);
 }
 
 module_init(init_smc91c92_cs);
diff -Nru a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
--- a/drivers/net/pcmcia/xirc2ps_cs.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/net/pcmcia/xirc2ps_cs.c	Wed Apr 30 22:28:08 2003
@@ -403,13 +403,6 @@
     }
 }
 
-static void
-cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
 static int
 get_tuple_data(int fn, client_handle_t handle, tuple_t *tuple)
 {
@@ -646,6 +639,7 @@
     link->irq.Instance = dev;
 
     /* Fill in card specific entries */
+    SET_MODULE_OWNER(dev);
     dev->hard_start_xmit = &do_start_xmit;
     dev->set_config = &do_config;
     dev->get_stats = &do_get_stats;
@@ -1714,7 +1708,6 @@
 
     /* okay */
     link->open++;
-    MOD_INC_USE_COUNT;
 
     netif_start_queue(dev);
     do_reset(dev,1);
@@ -2066,40 +2059,35 @@
     if (link->state & DEV_STALE_CONFIG)
 	mod_timer(&link->release, jiffies + HZ/20);
 
-    MOD_DEC_USE_COUNT;
-
     return 0;
 }
 
+static struct pcmcia_driver xirc2ps_cs_driver = {
+	.owner		= THIS_MODULE,
+	.drv		= {
+		.name	= "xirc2ps_cs",
+	},
+	.attach		= xirc2ps_attach,
+	.detach		= xirc2ps_detach,
+};
+
 static int __init
 init_xirc2ps_cs(void)
 {
-    servinfo_t serv;
-
-    printk(KERN_INFO "%s\n", version);
-    if (lockup_hack)
-	printk(KINF_XIRC "lockup hack is enabled\n");
-    CardServices(GetCardServicesInfo, &serv);
-    if (serv.Revision != CS_RELEASE_CODE) {
-	printk(KNOT_XIRC "Card Services release does not match!\n");
-	return -1;
-    }
-    DEBUG(0, "pc_debug=%d\n", pc_debug);
-    register_pccard_driver(&dev_info, &xirc2ps_attach, &xirc2ps_detach);
-    return 0;
+	return pcmcia_register_driver(&xirc2ps_cs_driver);
 }
 
 static void __exit
 exit_xirc2ps_cs(void)
 {
-    DEBUG(0, "unloading\n");
-    unregister_pccard_driver(&dev_info);
-    while (dev_list) {
-	if (dev_list->state & DEV_CONFIG)
-	    xirc2ps_release((u_long)dev_list);
-	if (dev_list)	/* xirc2ps_release() might already have detached... */
-	    xirc2ps_detach(dev_list);
-    }
+	pcmcia_unregister_driver(&xirc2ps_cs_driver);
+
+	while (dev_list) {
+		if (dev_list->state & DEV_CONFIG)
+			xirc2ps_release((u_long)dev_list);
+		if (dev_list)	/* xirc2ps_release() might already have detached... */
+			xirc2ps_detach(dev_list);
+	}
 }
 
 module_init(init_xirc2ps_cs);
diff -Nru a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
--- a/drivers/net/pcnet32.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/net/pcnet32.c	Wed Apr 30 22:28:06 2003
@@ -331,7 +331,7 @@
 static int  pcnet32_start_xmit(struct sk_buff *, struct net_device *);
 static int  pcnet32_rx(struct net_device *);
 static void pcnet32_tx_timeout (struct net_device *dev);
-static void pcnet32_interrupt(int, void *, struct pt_regs *);
+static irqreturn_t pcnet32_interrupt(int, void *, struct pt_regs *);
 static int  pcnet32_close(struct net_device *);
 static struct net_device_stats *pcnet32_get_stats(struct net_device *);
 static void pcnet32_set_multicast_list(struct net_device *);
@@ -717,6 +717,7 @@
 
     spin_lock_init(&lp->lock);
     
+    SET_MODULE_OWNER(dev);
     dev->priv = lp;
     lp->name = chipname;
     lp->shared_irq = shared;
@@ -945,8 +946,6 @@
 	       lp->a.read_csr(ioaddr, 0));
 
 
-    MOD_INC_USE_COUNT;
-    
     return 0;	/* Always succeed */
 }
 
@@ -1148,7 +1147,7 @@
 }
 
 /* The PCNET32 interrupt handler. */
-static void
+static irqreturn_t
 pcnet32_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
     struct net_device *dev = dev_id;
@@ -1161,7 +1160,7 @@
     if (!dev) {
 	printk (KERN_DEBUG "%s(): irq %d for unknown device\n",
 		__FUNCTION__, irq);
-	return;
+	return IRQ_NONE;
     }
 
     ioaddr = dev->base_addr;
@@ -1293,6 +1292,8 @@
 	       dev->name, lp->a.read_csr (ioaddr, 0));
 
     spin_unlock(&lp->lock);
+
+    return IRQ_HANDLED;
 }
 
 static int
@@ -1440,8 +1441,6 @@
         lp->tx_dma_addr[i] = 0;
     }
     
-    MOD_DEC_USE_COUNT;
-
     return 0;
 }
 
diff -Nru a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c
--- a/drivers/net/ppp_async.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/net/ppp_async.c	Wed Apr 30 22:28:13 2003
@@ -332,8 +332,8 @@
 	spin_unlock_bh(&ap->recv_lock);
 	ap_put(ap);
 	if (test_and_clear_bit(TTY_THROTTLED, &tty->flags)
-	    && tty->driver.unthrottle)
-		tty->driver.unthrottle(tty);
+	    && tty->driver->unthrottle)
+		tty->driver->unthrottle(tty);
 }
 
 static void
@@ -662,7 +662,7 @@
 		if (!tty_stuffed && ap->optr < ap->olim) {
 			avail = ap->olim - ap->optr;
 			set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
-			sent = tty->driver.write(tty, 0, ap->optr, avail);
+			sent = tty->driver->write(tty, 0, ap->optr, avail);
 			if (sent < 0)
 				goto flush;	/* error, e.g. loss of CD */
 			ap->optr += sent;
diff -Nru a/drivers/net/ppp_synctty.c b/drivers/net/ppp_synctty.c
--- a/drivers/net/ppp_synctty.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/net/ppp_synctty.c	Wed Apr 30 22:28:08 2003
@@ -385,8 +385,8 @@
 	spin_unlock_bh(&ap->recv_lock);
 	sp_put(ap);
 	if (test_and_clear_bit(TTY_THROTTLED, &tty->flags)
-	    && tty->driver.unthrottle)
-		tty->driver.unthrottle(tty);
+	    && tty->driver->unthrottle)
+		tty->driver->unthrottle(tty);
 }
 
 static void
@@ -610,7 +610,7 @@
 			tty_stuffed = 0;
 		if (!tty_stuffed && ap->tpkt != 0) {
 			set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
-			sent = tty->driver.write(tty, 0, ap->tpkt->data, ap->tpkt->len);
+			sent = tty->driver->write(tty, 0, ap->tpkt->data, ap->tpkt->len);
 			if (sent < 0)
 				goto flush;	/* error, e.g. loss of CD */
 			if (sent < ap->tpkt->len) {
diff -Nru a/drivers/net/pppoe.c b/drivers/net/pppoe.c
--- a/drivers/net/pppoe.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/net/pppoe.c	Wed Apr 30 22:28:11 2003
@@ -471,16 +471,15 @@
 
 /***********************************************************************
  *
- * Really kill the socket. (Called from sock_put if refcnt == 0.)
+ * Really kill the socket. (Called from pppox_sk_free if refcnt == 0.)
  *
  **********************************************************************/
-void pppoe_sock_destruct(struct sock *sk)
+static void pppoe_sk_free(struct sock *sk)
 {
 	struct pppox_opt *po = pppox_sk(sk);
 
 	if (po)
 		kfree(po);
-	MOD_DEC_USE_COUNT;
 }
 
 
@@ -495,26 +494,16 @@
 	struct sock *sk;
 	struct pppox_opt *po;
 
-	MOD_INC_USE_COUNT;
-
-	sk = sk_alloc(PF_PPPOX, GFP_KERNEL, 1, NULL);
+	sk = pppox_sk_alloc(sock, PX_PROTO_OE, GFP_KERNEL, 1, NULL);
 	if (!sk)
-		goto decmod;
-
-	sock_init_data(sock, sk);
+		goto out;
 
 	sock->state = SS_UNCONNECTED;
 	sock->ops   = &pppoe_ops;
 
-	sk->protocol = PX_PROTO_OE;
-	sk->family = PF_PPPOX;
-
 	sk->backlog_rcv = pppoe_rcv_core;
-	sk->next = NULL;
-	sk->pprev = NULL;
 	sk->state = PPPOX_NONE;
 	sk->type = SOCK_STREAM;
-	sk->destruct = pppoe_sock_destruct;
 
 	po = pppox_sk(sk) = kmalloc(sizeof(*po), GFP_KERNEL);
 	if (!po)
@@ -522,10 +511,8 @@
 	memset(po, 0, sizeof(*po));
 	po->sk = sk;
 	error = 0;
-	sock->sk = sk;
 out:	return error;
 frees:	sk_free(sk);
-decmod:	MOD_DEC_USE_COUNT;
 	goto out;
 }
 
@@ -1075,16 +1062,16 @@
 };
 #endif /* CONFIG_PROC_FS */
 
+/* ->release and ->ioctl are set at pppox_create */
+
 struct proto_ops pppoe_ops = {
     .family		= AF_PPPOX,
-    .release		= pppoe_release,
     .bind		= sock_no_bind,
     .connect		= pppoe_connect,
     .socketpair		= sock_no_socketpair,
     .accept		= sock_no_accept,
     .getname		= pppoe_getname,
     .poll		= datagram_poll,
-    .ioctl		= pppoe_ioctl,
     .listen		= sock_no_listen,
     .shutdown		= sock_no_shutdown,
     .setsockopt		= sock_no_setsockopt,
@@ -1096,7 +1083,10 @@
 
 struct pppox_proto pppoe_proto = {
     .create	= pppoe_create,
-    .ioctl	= pppoe_ioctl
+    .ioctl	= pppoe_ioctl,
+    .release	= pppoe_release,
+    .sk_free	= pppoe_sk_free,
+    .owner	= THIS_MODULE,
 };
 
 
diff -Nru a/drivers/net/pppox.c b/drivers/net/pppox.c
--- a/drivers/net/pppox.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/net/pppox.c	Wed Apr 30 22:28:16 2003
@@ -36,22 +36,22 @@
 
 #include <asm/uaccess.h>
 
-static struct pppox_proto *proto[PX_MAX_PROTO+1];
+static struct pppox_proto *pppox_protos[PX_MAX_PROTO + 1];
 
 int register_pppox_proto(int proto_num, struct pppox_proto *pp)
 {
 	if (proto_num < 0 || proto_num > PX_MAX_PROTO)
 		return -EINVAL;
-	if (proto[proto_num])
+	if (pppox_protos[proto_num])
 		return -EALREADY;
-	proto[proto_num] = pp;
+	pppox_protos[proto_num] = pp;
 	return 0;
 }
 
 void unregister_pppox_proto(int proto_num)
 {
 	if (proto_num >= 0 && proto_num <= PX_MAX_PROTO)
-		proto[proto_num] = NULL;
+		pppox_protos[proto_num] = NULL;
 }
 
 void pppox_unbind_sock(struct sock *sk)
@@ -64,71 +64,112 @@
 	}
 }
 
+static int pppox_release(struct socket *sock)
+{
+	struct sock *sk = sock->sk;
+	int rc = pppox_protos[sk->protocol]->release(sock);
+
+	module_put(pppox_protos[sk->protocol]->owner);
+	return rc;
+}
+
+static void pppox_sk_free(struct sock *sk)
+{
+	pppox_protos[sk->protocol]->sk_free(sk);
+	module_put(pppox_protos[sk->protocol]->owner);
+}
+
+struct sock *pppox_sk_alloc(struct socket *sock, int protocol, int priority,
+			    int zero_it, kmem_cache_t *slab)
+{
+	struct sock *sk = NULL;
+
+	if (!try_module_get(pppox_protos[protocol]->owner))
+		goto out;
+
+	sk = sk_alloc(PF_PPPOX, priority, zero_it, slab);
+	if (sk) {
+		sock_init_data(sock, sk);
+		sk->family   = PF_PPPOX;
+		sk->protocol = protocol;
+		sk->destruct = pppox_sk_free;
+	} else
+		module_put(pppox_protos[protocol]->owner);
+out:
+	return sk;
+}
+
 EXPORT_SYMBOL(register_pppox_proto);
 EXPORT_SYMBOL(unregister_pppox_proto);
 EXPORT_SYMBOL(pppox_unbind_sock);
+EXPORT_SYMBOL(pppox_sk_alloc);
 
 static int pppox_ioctl(struct socket* sock, unsigned int cmd, 
 		       unsigned long arg)
 {
 	struct sock *sk = sock->sk;
 	struct pppox_opt *po = pppox_sk(sk);
-	int err = 0;
+	int rc = 0;
 
 	lock_sock(sk);
 
 	switch (cmd) {
-	case PPPIOCGCHAN:{
+	case PPPIOCGCHAN: {
 		int index;
-		err = -ENOTCONN;
+		rc = -ENOTCONN;
 		if (!(sk->state & PPPOX_CONNECTED))
 			break;
 
-		err = -EINVAL;
+		rc = -EINVAL;
 		index = ppp_channel_index(&po->chan);
 		if (put_user(index , (int *) arg))
 			break;
 
-		err = 0;
+		rc = 0;
 		sk->state |= PPPOX_BOUND;
 		break;
 	}
 	default:
-		if (proto[sk->protocol]->ioctl)
-			err = (*proto[sk->protocol]->ioctl)(sock, cmd, arg);
+		if (pppox_protos[sk->protocol]->ioctl)
+			rc = pppox_protos[sk->protocol]->ioctl(sock, cmd, arg);
 
 		break;
 	};
 
 	release_sock(sk);
-	return err;
+	return rc;
 }
 
 
 static int pppox_create(struct socket *sock, int protocol)
 {
-	int err = 0;
+	int rc = -EPROTOTYPE;
 
 	if (protocol < 0 || protocol > PX_MAX_PROTO)
-		return -EPROTOTYPE;
-
-	if (proto[protocol] == NULL)
-		return -EPROTONOSUPPORT;
+		goto out;
 
-	err = (*proto[protocol]->create)(sock);
+	rc = -EPROTONOSUPPORT;
+	if (!pppox_protos[protocol] ||
+	    !try_module_get(pppox_protos[protocol]->owner))
+		goto out;
 
-	if (err == 0) {
+	rc = pppox_protos[protocol]->create(sock);
+	if (!rc) {
 		/* We get to set the ioctl handler. */
+		/* And the release handler, for module refcounting */
 		/* For everything else, pppox is just a shell. */
 		sock->ops->ioctl = pppox_ioctl;
-	}
-
-	return err;
+		sock->ops->release = pppox_release;
+	} else
+		module_put(pppox_protos[protocol]->owner);
+out:
+	return rc;
 }
 
 static struct net_proto_family pppox_proto_family = {
 	.family	= PF_PPPOX,
 	.create	= pppox_create,
+	.owner	= THIS_MODULE,
 };
 
 static int __init pppox_init(void)
diff -Nru a/drivers/net/r8169.c b/drivers/net/r8169.c
--- a/drivers/net/r8169.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/net/r8169.c	Wed Apr 30 22:28:09 2003
@@ -295,7 +295,7 @@
 
 static int rtl8169_open(struct net_device *dev);
 static int rtl8169_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static void rtl8169_interrupt(int irq, void *dev_instance,
+static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance,
 			      struct pt_regs *regs);
 static void rtl8169_init_ring(struct net_device *dev);
 static void rtl8169_hw_start(struct net_device *dev);
@@ -958,7 +958,7 @@
 }
 
 /* The interrupt handler does all of the Rx thread work and cleans up after the Tx thread. */
-static void
+static irqreturn_t
 rtl8169_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *) dev_instance;
@@ -966,6 +966,7 @@
 	int boguscnt = max_interrupt_work;
 	void *ioaddr = tp->mmio_addr;
 	int status = 0;
+	int handled = 0;
 
 	do {
 		status = RTL_R16(IntrStatus);
@@ -974,6 +975,7 @@
 		if (status == 0xFFFF)
 			break;
 
+		handled = 1;
 /*
 		if (status & RxUnderrun)
 			link_changed = RTL_R16 (CSCR) & CSCR_LinkChangeBit;
@@ -1006,6 +1008,7 @@
 		/* Clear all interrupt sources. */
 		RTL_W16(IntrStatus, 0xffff);
 	}
+	return IRQ_RETVAL(handled);
 }
 
 static int
diff -Nru a/drivers/net/rclanmtl.c b/drivers/net/rclanmtl.c
--- a/drivers/net/rclanmtl.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/net/rclanmtl.c	Wed Apr 30 22:28:11 2003
@@ -301,13 +301,13 @@
 	PPAB pPab;
 	U32 pciBaseAddr = dev->base_addr;
 	PDPA pDpa = dev->priv;
-	PU8 p_msgbuf = pDpa->PLanApiPA;
-	PU8 p_phymsgbuf = (PU8) virt_to_bus ((void *) p_msgbuf);
+	PU8 p_msgbuf = pDpa->msgbuf;
+	PU8 p_phymsgbuf = (PU8) pDpa->msgbuf_dma;
 
 	dprintk
-	    ("InitI2O: Adapter:0x%04ux ATU:0x%08ulx msgbuf:0x%08ulx phymsgbuf:0x%08ulx\n"
+	    ("InitI2O: Adapter:0x%04ux ATU:0x%08ulx msgbuf:%p phymsgbuf:0x%08ulx\n"
 	     "TransmitCallbackFunction:0x%08ulx  ReceiveCallbackFunction:0x%08ulx\n",
-	     pDpa->id, pciBaseAddr, (u32) p_msgbuf, (u32) p_phymsgbuf,
+	     pDpa->id, pciBaseAddr, p_msgbuf, (u32) p_phymsgbuf,
 	     (u32) TransmitCallbackFunction, (u32) ReceiveCallbackFunction);
 
 	/* Check if this interface already initialized - if so, shut it down */
@@ -445,7 +445,7 @@
 		return RC_RTN_FREE_Q_EMPTY;
 	}
 
-	/* calc virual address of msg - virual already mapped to physical */
+	/* calc virtual address of msg - virtual already mapped to physical */
 	pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
 
 	size = FillI2OMsgSGLFromTCB (pMsg + 4, pTransCtrlBlock);
@@ -502,7 +502,7 @@
 		dprintk ("RCPostRecvBuffers(): Inbound Free Q empty!\n");
 		return RC_RTN_FREE_Q_EMPTY;
 	}
-	/* calc virual address of msg - virual already mapped to physical */
+	/* calc virtual address of msg - virtual already mapped to physical */
 	pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
 
 	size = FillI2OMsgSGLFromTCB (pMsg + 4, pTransCtrlBlock);
@@ -538,7 +538,7 @@
 ** Process I2O outbound message queue until empty.
 ** =========================================================================
 */
-void
+irqreturn_t
 RCProcI2OMsgQ (struct net_device *dev)
 {
 	U32 phyAddrMsg;
@@ -549,7 +549,7 @@
 	unsigned char debug_msg[20];
 
 	if (pPab == NULL)
-		return;
+		return IRQ_NONE;
 
 	phyAddrMsg = pPab->p_atu->OutQueue;
 
@@ -642,6 +642,8 @@
 		/* any more msgs? */
 		phyAddrMsg = pPab->p_atu->OutQueue;
 	}
+
+	return IRQ_HANDLED;
 }
 
 /*
@@ -677,7 +679,7 @@
 		return RC_RTN_FREE_Q_EMPTY;
 	}
 
-	/* calc virual address of msg - virual already mapped to physical */
+	/* calc virtual address of msg - virtual already mapped to physical */
 	pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
 
 /*dprintk("Get82558Stats - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", pMsg, msgOffset);*/
@@ -751,7 +753,7 @@
 		return RC_RTN_FREE_Q_EMPTY;
 	}
 
-	/* calc virual address of msg - virual already mapped to physical */
+	/* calc virtual address of msg - virtual already mapped to physical */
 	pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
 /*dprintk("Get82558LinkStatus - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", pMsg, msgOffset);*/
 /*dprintk("Get82558LinkStatus - pMsg = 0x%08X, InQ msgOffset = 0x%08X\n", pMsg, msgOffset);*/
@@ -1452,7 +1454,7 @@
 	pMsg[7] = 0;
 	pMsg[8] = 1;		/*  return 1 byte */
 
-	/* virual pointer to return buffer - clear first two dwords */
+	/* virtual pointer to return buffer - clear first two dwords */
 	p32 = (volatile PU32) pPab->pLinOutMsgBlock;
 	p32[0] = 0;
 	p32[1] = 0;
@@ -1693,7 +1695,7 @@
 		return RC_RTN_FREE_Q_EMPTY;
 	}
 
-	/* calc virual address of msg - virual already mapped to physical */
+	/* calc virtual address of msg - virtual already mapped to physical */
 	pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
 
 	dprintk
@@ -1711,7 +1713,7 @@
 	/* phys address to return status - area right after PAB */
 	pMsg[7] = pPab->outMsgBlockPhyAddr;
 
-	/* virual pointer to return buffer - clear first two dwords */
+	/* virtual pointer to return buffer - clear first two dwords */
 	p32 = (PU32) pPab->pLinOutMsgBlock;
 	p32[0] = 0;
 
@@ -1779,7 +1781,7 @@
 		return RC_RTN_FREE_Q_EMPTY;
 	}
 
-	/* calc virual address of msg - virual already mapped to physical */
+	/* calc virtual address of msg - virtual already mapped to physical */
 	pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
 
 	pMsg[0] = NINE_WORD_MSG_SIZE | SGL_OFFSET_0;
@@ -1793,7 +1795,7 @@
 	pMsg[7] = 0;
 	pMsg[8] = 88;		/*  return 88 bytes */
 
-	/* virual pointer to return buffer - clear first two dwords */
+	/* virtual pointer to return buffer - clear first two dwords */
 	p32 = (volatile PU32) pPab->pLinOutMsgBlock;
 	p32[0] = 0;
 	p32[1] = 0;
@@ -1862,7 +1864,7 @@
 		return RC_RTN_FREE_Q_EMPTY;
 	}
 
-	/* calc virual address of msg - virual already mapped to physical */
+	/* calc virtual address of msg - virtual already mapped to physical */
 	pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
 
 	dprintk
@@ -1885,7 +1887,7 @@
 ** =========================================================================
 ** FillI2OMsgFromTCB()
 **
-** inputs   pMsgU32 - virual pointer (mapped to physical) of message frame
+** inputs   pMsgU32 - virtual pointer (mapped to physical) of message frame
 **          pXmitCntrlBlock - pointer to caller buffer control block.
 **
 ** fills in LAN SGL after Transaction Control Word or Bucket Count.
diff -Nru a/drivers/net/rclanmtl.h b/drivers/net/rclanmtl.h
--- a/drivers/net/rclanmtl.h	Wed Apr 30 22:28:09 2003
+++ b/drivers/net/rclanmtl.h	Wed Apr 30 22:28:09 2003
@@ -182,6 +182,7 @@
 	U32 pci_addr;		/* the pci address of the adapter */
 	U32 pci_addr_len;
 
+	struct pci_dev *pci_dev;
 	struct timer_list timer;	/*  timer */
 	struct net_device_stats stats;	/* the statistics structure */
 	unsigned long numOutRcvBuffers;	/* number of outstanding receive buffers */
@@ -189,7 +190,7 @@
 	unsigned char reboot;
 	unsigned char nexus;
 	PU8 msgbuf;		/* Pointer to Lan Api Private Area */
-	PU8 PLanApiPA;		/* Pointer to Lan Api Private Area (aligned) */
+	dma_addr_t msgbuf_dma;
 	PPAB pPab;		/* Pointer to the PCI Adapter Block */
 } *PDPA;
 
@@ -421,7 +422,7 @@
     ** callback functions, TransmitCallbackFunction or ReceiveCallbackFunction,
     ** if a TX or RX transaction has completed.
   */
-void RCProcI2OMsgQ (struct net_device *dev);
+irqreturn_t RCProcI2OMsgQ (struct net_device *dev);
 
  /*
     ** Disable and Enable I2O interrupts.  I2O interrupts are enabled at Init time
diff -Nru a/drivers/net/rcpci45.c b/drivers/net/rcpci45.c
--- a/drivers/net/rcpci45.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/net/rcpci45.c	Wed Apr 30 22:28:15 2003
@@ -29,6 +29,8 @@
 **  along with this program; if not, write to the Free Software
 **  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 **
+**  Francois Romieu, Apr 2003: Converted to pci DMA mapping API.
+**
 **  Pete Popov, Oct 2001: Fixed a few bugs to make the driver functional
 **  again. Note that this card is not supported or manufactured by 
 **  RedCreek anymore.
@@ -47,8 +49,6 @@
 **
 ***************************************************************************/
 
-#error Please convert me to Documentation/DMA-mapping.txt
-
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
@@ -66,7 +66,7 @@
 #include <asm/uaccess.h>
 
 static char version[] __initdata =
-    "RedCreek Communications PCI linux driver version 2.20\n";
+    "RedCreek Communications PCI linux driver version 2.21\n";
 
 #define RC_LINUX_MODULE
 #include "rclanmtl.h"
@@ -95,13 +95,19 @@
  */
 #define MSG_BUF_SIZE  16384
 
+/* 2003/04/20: I don't know about the hardware ability but the driver won't
+ * play safe with 64 bit addressing and DAC without NETIF_F_HIGHDMA doesn't
+ * really make sense anyway. Let's play safe - romieu.
+ */
+#define RCPCI45_DMA_MASK	((u64) 0xffffffff)
+
 static U32 DriverControlWord;
 
 static void rc_timer (unsigned long);
 
 static int RCopen (struct net_device *);
 static int RC_xmit_packet (struct sk_buff *, struct net_device *);
-static void RCinterrupt (int, void *, struct pt_regs *);
+static irqreturn_t RCinterrupt (int, void *, struct pt_regs *);
 static int RCclose (struct net_device *dev);
 static struct net_device_stats *RCget_stats (struct net_device *);
 static int RCioctl (struct net_device *, struct ifreq *, int);
@@ -136,8 +142,8 @@
 	free_irq (dev->irq, dev);
 	iounmap ((void *) dev->base_addr);
 	pci_release_regions (pdev);
-	if (pDpa->msgbuf)
-		kfree (pDpa->msgbuf);
+	pci_free_consistent (pdev, MSG_BUF_SIZE, pDpa->msgbuf,
+			     pDpa->msgbuf_dma);
 	if (pDpa->pPab)
 		kfree (pDpa->pPab);
 	kfree (dev);
@@ -172,6 +178,7 @@
 		error = -ENOMEM;
 		goto err_out;
 	}
+	SET_MODULE_OWNER(dev);
 
 	error = pci_enable_device (pdev);
 	if (error) {
@@ -180,7 +187,6 @@
 			card_idx);
 		goto err_out;
 	}
-	error = -ENOMEM;
 	pci_start = pci_resource_start (pdev, 0);
 	pci_len = pci_resource_len (pdev, 0);
 	printk("pci_start %lx pci_len %lx\n", pci_start, pci_len);
@@ -189,6 +195,7 @@
 
 	pDpa = dev->priv;
 	pDpa->id = card_idx;
+	pDpa->pci_dev = pdev;
 	pDpa->pci_addr = pci_start;
 
 	if (!pci_start || !(pci_resource_flags (pdev, 0) & IORESOURCE_MEM)) {
@@ -200,24 +207,21 @@
 
 	/*
 	 * pDpa->msgbuf is where the card will dma the I2O 
-	 * messages. Thus, we need contiguous physical pages of
-	 * memory.
-	 */
-	pDpa->msgbuf = kmalloc (MSG_BUF_SIZE, GFP_DMA | GFP_KERNEL);
+	 * messages. Thus, we need contiguous physical pages of memory.
+	 * 2003/04/20:  pci_alloc_consistent() provides well over the needed
+	 * alignment on a 256 bytes boundary for the LAN API private area.
+	 * Thus it isn't needed anymore to align it by hand.
+         */
+	pDpa->msgbuf = pci_alloc_consistent (pdev, MSG_BUF_SIZE,
+					     &pDpa->msgbuf_dma);
 	if (!pDpa->msgbuf) {
 		printk (KERN_ERR "(rcpci45 driver:) \
 			Could not allocate %d byte memory for the \
 				private msgbuf!\n", MSG_BUF_SIZE);
+		error = -ENOMEM;
 		goto err_out_free_dev;
 	}
 
-	/*
-	 * Save the starting address of the LAN API private area.  We'll
-	 * pass that to RCInitI2OMsgLayer().
-	 *
-	 */
-	pDpa->PLanApiPA = (void *) (((long) pDpa->msgbuf + 0xff) & ~0xff);
-
 	/* The adapter is accessible through memory-access read/write, not
 	 * I/O read/write.  Thus, we need to map it to some virtual address
 	 * area in order to access the registers as normal memory.
@@ -226,12 +230,20 @@
 	if (error)
 		goto err_out_free_msgbuf;
 
+	error = pci_set_dma_mask (pdev, RCPCI45_DMA_MASK);
+	if (error) {
+		printk (KERN_ERR
+			"(rcpci45 driver:) pci_set_dma_mask failed!\n");
+		goto err_out_free_region;
+	}
+
 	vaddr = (ulong *) ioremap (pci_start, pci_len);
 	if (!vaddr) {
 		printk (KERN_ERR
 			"(rcpci45 driver:) \
 			Unable to remap address range from %lu to %lu\n",
 			pci_start, pci_start + pci_len);
+		error = -EIO;
 		goto err_out_free_region;
 	}
 
@@ -249,13 +261,14 @@
 err_out_free_region:
 	pci_release_regions (pdev);
 err_out_free_msgbuf:
-	kfree (pDpa->msgbuf);
+	pci_free_consistent (pdev, MSG_BUF_SIZE, pDpa->msgbuf,
+			     pDpa->msgbuf_dma);
 err_out_free_dev:
 	unregister_netdev (dev);
 	kfree (dev);
 err_out:
 	card_idx--;
-	return -ENODEV;
+	return error;
 }
 
 static struct pci_driver rcpci45_driver = {
@@ -283,7 +296,6 @@
 	int requested = 0;
 	int error;
 
-	MOD_INC_USE_COUNT;
 	if (pDpa->nexus) {
 		/* This is not the first time RCopen is called.  Thus,
 		 * the interface was previously opened and later closed
@@ -365,7 +377,6 @@
 err_out_free_irq:
 	free_irq (dev->irq, dev);
 err_out:
-	MOD_DEC_USE_COUNT;
 	return error;
 }
 
@@ -402,7 +413,8 @@
 	ptcb->b.context = (U32) skb;
 	ptcb->b.scount = 1;
 	ptcb->b.size = skb->len;
-	ptcb->b.addr = virt_to_bus ((void *) skb->data);
+	ptcb->b.addr = pci_map_single(pDpa->pci_dev, skb->data, skb->len,
+				      PCI_DMA_TODEVICE);
 
 	if ((status = RCI2OSendPacket (dev, (U32) NULL, (PRCTCB) ptcb))
 	    != RC_RTN_NO_ERROR) {
@@ -451,6 +463,8 @@
 	while (PcktCount--) {
 		skb = (struct sk_buff *) (BufferContext[0]);
 		BufferContext++;
+		pci_unmap_single(pDpa->pci_dev, BufferContext[1], skb->len,
+				 PCI_DMA_TODEVICE);
 		dev_kfree_skb_irq (skb);
 	}
 	netif_wake_queue (dev);
@@ -621,7 +635,7 @@
  * RCProcI2OMsgQ(), which in turn process the message and
  * calls one of our callback functions.
  */
-static void
+static irqreturn_t
 RCinterrupt (int irq, void *dev_id, struct pt_regs *regs)
 {
 
@@ -634,7 +648,7 @@
 		printk (KERN_DEBUG "%s: shutdown, service irq\n",
 				dev->name);
 
-	RCProcI2OMsgQ (dev);
+	return RCProcI2OMsgQ (dev);
 }
 
 #define REBOOT_REINIT_RETRY_LIMIT 4
@@ -706,6 +720,7 @@
 			RCDisableI2OInterrupts (dev);
 			dev->flags &= ~IFF_UP;
 			MOD_DEC_USE_COUNT;
+			/* FIXME: kill MOD_DEC_USE_COUNT, use dev_put */
 		} else {
 			printk (KERN_INFO "%s: rescheduling timer...\n",
 					dev->name);
@@ -731,7 +746,6 @@
 		printk (KERN_INFO "%s skipping reset -- adapter already in reboot mode\n", dev->name);
 		dev->flags &= ~IFF_UP;
 		pDpa->shutdown = 1;
-		MOD_DEC_USE_COUNT;
 		return 0;
 	}
 
@@ -749,7 +763,6 @@
 			   (PFNCALLBACK) RCreset_callback);
 
 	dev->flags &= ~IFF_UP;
-	MOD_DEC_USE_COUNT;
 	return 0;
 }
 
@@ -984,8 +997,9 @@
 	PU32 p;
 	psingleB pB;
 	struct sk_buff *skb;
+	PDPA pDpa = dev->priv;
 	RC_RETURN status;
-	U32 res;
+	U32 res = 0;
 
 	if (!numBuffers)
 		return 0;
@@ -1001,7 +1015,7 @@
 	if (!p) {
 		printk (KERN_WARNING "%s unable to allocate TCB\n",
 				dev->name);
-		return 0;
+		goto out;
 	}
 
 	p[0] = 0;		/* Buffer Count */
@@ -1013,18 +1027,14 @@
 			printk (KERN_WARNING 
 					"%s: unable to allocate enough skbs!\n",
 					dev->name);
-			if (*p != 0) {	/* did we allocate any buffers */
-				break;
-			} else {
-				kfree (p);	/* Free the TCB */
-				return 0;
-			}
+			goto err_out_unmap;
 		}
 		skb_reserve (skb, 2);	/* Align IP on 16 byte boundaries */
 		pB->context = (U32) skb;
 		pB->scount = 1;	/* segment count */
 		pB->size = MAX_ETHER_SIZE;
-		pB->addr = virt_to_bus ((void *) skb->data);
+		pB->addr = pci_map_single(pDpa->pci_dev, skb->data, 
+					  MAX_ETHER_SIZE, PCI_DMA_FROMDEVICE);
 		p[0]++;
 		pB++;
 	}
@@ -1032,16 +1042,21 @@
 	if ((status = RCPostRecvBuffers (dev, (PRCTCB) p)) != RC_RTN_NO_ERROR) {
 		printk (KERN_WARNING "%s: Post buffer failed, error 0x%x\n",
 				dev->name, status);
-		/* point to the first buffer */
-		pB = (psingleB) ((U32) p + sizeof (U32));
-		while (p[0]) {
-			skb = (struct sk_buff *) pB->context;
-			dev_kfree_skb (skb);
-			p[0]--;
-			pB++;
-		}
+		goto err_out_unmap;
 	}
+out_free:
 	res = p[0];
 	kfree (p);
+out:
 	return (res);		/* return the number of posted buffers */
+
+err_out_unmap:
+	for (; p[0] > 0; p[0]--) {
+		--pB;
+		skb = (struct sk_buff *) pB->context;
+		pci_unmap_single(pDpa->pci_dev, pB->addr, MAX_ETHER_SIZE,
+				 PCI_DMA_FROMDEVICE);
+		dev_kfree_skb (skb);
+	}
+	goto out_free;
 }
diff -Nru a/drivers/net/rrunner.c b/drivers/net/rrunner.c
--- a/drivers/net/rrunner.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/net/rrunner.c	Wed Apr 30 22:28:06 2003
@@ -1045,7 +1045,7 @@
 }
 
 
-static void rr_interrupt(int irq, void *dev_id, struct pt_regs *ptregs)
+static irqreturn_t rr_interrupt(int irq, void *dev_id, struct pt_regs *ptregs)
 {
 	struct rr_private *rrpriv;
 	struct rr_regs *regs;
@@ -1056,7 +1056,7 @@
 	regs = rrpriv->regs;
 
 	if (!(readl(&regs->HostCtrl) & RR_INT))
-		return;
+		return IRQ_NONE;
 
 	spin_lock(&rrpriv->lock);
 
@@ -1127,6 +1127,7 @@
 	wmb();
 
 	spin_unlock(&rrpriv->lock);
+	return IRQ_HANDLED;
 }
 
 static void rr_timer(unsigned long data)
diff -Nru a/drivers/net/rrunner.h b/drivers/net/rrunner.h
--- a/drivers/net/rrunner.h	Wed Apr 30 22:28:11 2003
+++ b/drivers/net/rrunner.h	Wed Apr 30 22:28:11 2003
@@ -1,7 +1,8 @@
 #ifndef _RRUNNER_H_
 #define _RRUNNER_H_
 
-#include<linux/config.h>
+#include <linux/config.h>
+#include <linux/interrupt.h>
 
 #if ((BITS_PER_LONG != 32) && (BITS_PER_LONG != 64))
 #error "BITS_PER_LONG not defined or not valid"
@@ -830,7 +831,7 @@
  */
 static int rr_init(struct net_device *dev);
 static int rr_init1(struct net_device *dev);
-static void rr_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t rr_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 static int rr_open(struct net_device *dev);
 static int rr_start_xmit(struct sk_buff *skb, struct net_device *dev);
diff -Nru a/drivers/net/saa9730.c b/drivers/net/saa9730.c
--- a/drivers/net/saa9730.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/net/saa9730.c	Wed Apr 30 22:28:10 2003
@@ -745,7 +745,7 @@
 	return 0;
 }
 
-static void lan_saa9730_interrupt(const int irq, void *dev_id,
+static irqreturn_t lan_saa9730_interrupt(const int irq, void *dev_id,
 				  struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *) dev_id;
@@ -773,7 +773,7 @@
 	/* Enable the EVM LAN interrupt. */
 	evm_saa9730_unblock_lan_int(lp);
 
-	return;
+	return IRQ_HANDLED;
 }
 
 static int lan_saa9730_open_fail(struct net_device *dev)
diff -Nru a/drivers/net/sb1000.c b/drivers/net/sb1000.c
--- a/drivers/net/sb1000.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/net/sb1000.c	Wed Apr 30 22:28:04 2003
@@ -84,7 +84,7 @@
 static int sb1000_open(struct net_device *dev);
 static int sb1000_dev_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd);
 static int sb1000_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static void sb1000_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t sb1000_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static struct net_device_stats *sb1000_stats(struct net_device *dev);
 static int sb1000_close(struct net_device *dev);
 
@@ -1112,7 +1112,7 @@
 }
 
 /* SB1000 interrupt handler. */
-static void sb1000_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sb1000_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	char *name;
 	unsigned char st;
@@ -1127,7 +1127,7 @@
 	if (dev == NULL) {
 		printk(KERN_ERR "sb1000_interrupt(): irq %d for unknown device.\n",
 			irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	ioaddr[0] = dev->base_addr;
@@ -1138,7 +1138,7 @@
 	/* is it a good interrupt? */
 	st = inb(ioaddr[1] + 6);
 	if (!(st & 0x08 && st & 0x20)) {
-		return;
+		return IRQ_NONE;
 	}
 
 	if (sb1000_debug > 3)
@@ -1169,7 +1169,7 @@
 		lp->rx_error_count = 0;
 	}
 
-	return;
+	return IRQ_HANDLED;
 }
 
 static struct net_device_stats *sb1000_stats(struct net_device *dev)
diff -Nru a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
--- a/drivers/net/sb1250-mac.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/net/sb1250-mac.c	Wed Apr 30 22:28:17 2003
@@ -281,7 +281,7 @@
 static void sbmac_promiscuous_mode(struct sbmac_softc *sc,int onoff);
 /*static void sbmac_init_and_start(struct sbmac_softc *sc);*/
 static uint64_t sbmac_addr2reg(unsigned char *ptr);
-static void sbmac_intr(int irq,void *dev_instance,struct pt_regs *rgs);
+static irqreturn_t sbmac_intr(int irq,void *dev_instance,struct pt_regs *rgs);
 static int sbmac_start_tx(struct sk_buff *skb, struct net_device *dev);
 static void sbmac_setmulti(struct sbmac_softc *sc);
 static int sbmac_init(struct net_device *dev);
@@ -1891,7 +1891,8 @@
 	struct net_device *dev = (struct net_device *) dev_instance;
 	struct sbmac_softc *sc = (struct sbmac_softc *) (dev->priv);
 	uint64_t isr;
-	
+	int handled = 0;
+
 	for (;;) {
 		
 		/*
@@ -1900,8 +1901,9 @@
 		
 		isr = SBMAC_READCSR(sc->sbm_isr);
 		
-		if (isr == 0) break;
-		
+		if (isr == 0)
+			break;
+		handled = 1;
 		/*
 		 * Transmits on channel 0
 		 */
@@ -1918,7 +1920,7 @@
 			sbdma_rx_process(sc,&(sc->sbm_rxdma));
 		}
 	}
-	
+	return IRQ_RETVAL(handled);
 }
 
 
diff -Nru a/drivers/net/sgiseeq.c b/drivers/net/sgiseeq.c
--- a/drivers/net/sgiseeq.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/net/sgiseeq.c	Wed Apr 30 22:28:17 2003
@@ -416,7 +416,7 @@
 	}
 }
 
-static void sgiseeq_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sgiseeq_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *) dev_id;
 	struct sgiseeq_private *sp = (struct sgiseeq_private *) dev->priv;
@@ -436,6 +436,7 @@
 	if ((TX_BUFFS_AVAIL(sp) > 0) && netif_queue_stopped(dev)) {
 		netif_wake_queue(dev);
 	}
+	return IRQ_HANDLED;
 }
 
 static int sgiseeq_open(struct net_device *dev)
diff -Nru a/drivers/net/sis900.c b/drivers/net/sis900.c
--- a/drivers/net/sis900.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/net/sis900.c	Wed Apr 30 22:28:08 2003
@@ -195,11 +195,11 @@
 static int sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev);
 static int sis900_rx(struct net_device *net_dev);
 static void sis900_finish_xmit (struct net_device *net_dev);
-static void sis900_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t sis900_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
 static int sis900_close(struct net_device *net_dev);
 static int mii_ioctl(struct net_device *net_dev, struct ifreq *rq, int cmd);
 static struct net_device_stats *sis900_get_stats(struct net_device *net_dev);
-static u16 sis900_compute_hashtable_index(u8 *addr, u8 revision);
+static u16 sis900_mcast_bitnr(u8 *addr, u8 revision);
 static void set_rx_mode(struct net_device *net_dev);
 static void sis900_reset(struct net_device *net_dev);
 static void sis630_set_eq(struct net_device *net_dev, u8 revision);
@@ -1534,13 +1534,14 @@
  *	and cleans up after the Tx thread
  */
 
-static void sis900_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
+static irqreturn_t sis900_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
 {
 	struct net_device *net_dev = dev_instance;
 	struct sis900_private *sis_priv = net_dev->priv;
 	int boguscnt = max_interrupt_work;
 	long ioaddr = net_dev->base_addr;
 	u32 status;
+	unsigned int handled = 0;
 
 	spin_lock (&sis_priv->lock);
 
@@ -1550,6 +1551,7 @@
 		if ((status & (HIBERR|TxURN|TxERR|TxIDLE|RxORN|RxERR|RxOK)) == 0)
 			/* nothing intresting happened */
 			break;
+		handled = 1;
 
 		/* why dow't we break after Tx/Rx case ?? keyword: full-duplex */
 		if (status & (RxORN | RxERR | RxOK))
@@ -1580,7 +1582,7 @@
 		       net_dev->name, inl(ioaddr + isr));
 	
 	spin_unlock (&sis_priv->lock);
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 /**
@@ -2031,7 +2033,7 @@
 }
 
 /**
- *	sis900_compute_hashtable_index: - compute hashtable index 
+ *	sis900_mcast_bitnr: - compute hashtable index 
  *	@addr: multicast address
  *	@revision: revision id of chip
  *
@@ -2041,7 +2043,7 @@
  *   	multicast hash table. 
  */
 
-static u16 sis900_compute_hashtable_index(u8 *addr, u8 revision)
+static inline u16 sis900_mcast_bitnr(u8 *addr, u8 revision)
 {
 
 	u32 crc = ether_crc(6, addr);
@@ -2095,9 +2097,11 @@
 		struct dev_mc_list *mclist;
 		rx_mode = RFAAB;
 		for (i = 0, mclist = net_dev->mc_list; mclist && i < net_dev->mc_count;
-		     i++, mclist = mclist->next)
-			set_bit(sis900_compute_hashtable_index(mclist->dmi_addr, revision),
-				mc_filter);
+		     i++, mclist = mclist->next) {
+			unsigned int bit_nr =
+				sis900_mcast_bitnr(mclist->dmi_addr, revision);
+			mc_filter[bit_nr >> 4] |= (1 << bit_nr);
+		}
 	}
 
 	/* update Multicast Hash Table in Receive Filter */
diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/net/sk98lin/skge.c	Wed Apr 30 22:28:05 2003
@@ -322,8 +322,8 @@
 static void	SetupRing(SK_AC*, void*, uintptr_t, RXD**, RXD**, RXD**,
 			int*, SK_BOOL);
 
-static void	SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs);
-static void	SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs);
+static irqreturn_t SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs);
+static irqreturn_t SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs);
 static int	SkGeOpen(struct net_device *dev);
 static int	SkGeClose(struct net_device *dev);
 static int	SkGeXmit(struct sk_buff *skb, struct net_device *dev);
@@ -470,6 +470,7 @@
 		pNet->Up = 0;
 		dev->irq = pdev->irq;
 
+		SET_MODULE_OWNER(dev);
 		dev->open =		&SkGeOpen;
 		dev->stop =		&SkGeClose;
 		dev->hard_start_xmit =	&SkGeXmit;
@@ -1236,7 +1237,7 @@
  * Returns: N/A
  *
  */
-static void SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs)
+static irqreturn_t SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs)
 {
 struct net_device *dev = (struct net_device *)dev_id;
 
@@ -1252,7 +1253,7 @@
 	 */
 	SK_IN32(pAC->IoBase, B0_SP_ISRC, &IntSrc);
 	if (IntSrc == 0) {
-		return;
+		return IRQ_NONE;
 	}
 
 	while (((IntSrc & IRQ_MASK) & ~SPECIAL_IRQS) != 0) {
@@ -1380,7 +1381,7 @@
 	/* IRQ is processed - Enable IRQs again*/
 	SK_OUT32(pAC->IoBase, B0_IMSK, IRQ_MASK);
 
-	return;
+	return IRQ_HANDLED;
 } /* SkGeIsr */
 
 
@@ -1397,7 +1398,7 @@
  * Returns: N/A
  *
  */
-static void SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs)
+static irqreturn_t SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs)
 {
 struct net_device *dev = (struct net_device *)dev_id;
 DEV_NET		*pNet;
@@ -1412,7 +1413,7 @@
 	 */
 	SK_IN32(pAC->IoBase, B0_SP_ISRC, &IntSrc);
 	if (IntSrc == 0) {
-		return;
+		return IRQ_NONE;
 	}
 
 	while (((IntSrc & IRQ_MASK) & ~SPECIAL_IRQS) != 0) {
@@ -1498,7 +1499,7 @@
 	/* IRQ is processed - Enable IRQs again*/
 	SK_OUT32(pAC->IoBase, B0_IMSK, IRQ_MASK);
 
-	return;
+	return IRQ_HANDLED;
 } /* SkGeIsrOnePort */
 
 
@@ -1604,8 +1605,6 @@
 	pAC->MaxPorts++;
 	pNet->Up = 1;
 
-	MOD_INC_USE_COUNT;
-
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
 		("SkGeOpen suceeded\n"));
 
@@ -1705,7 +1704,6 @@
 
 	pAC->MaxPorts--;
 	pNet->Up = 0;
-	MOD_DEC_USE_COUNT;
 	
 	return (0);
 } /* SkGeClose */
diff -Nru a/drivers/net/sk_g16.c b/drivers/net/sk_g16.c
--- a/drivers/net/sk_g16.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/net/sk_g16.c	Wed Apr 30 22:28:20 2003
@@ -478,7 +478,7 @@
 static void  SK_timeout(struct net_device *dev);
 static int   SK_open(struct net_device *dev);
 static int   SK_send_packet(struct sk_buff *skb, struct net_device *dev);
-static void  SK_interrupt(int irq, void *dev_id, struct pt_regs * regs);
+static irqreturn_t SK_interrupt(int irq, void *dev_id, struct pt_regs * regs);
 static void  SK_rxintr(struct net_device *dev);
 static void  SK_txintr(struct net_device *dev);
 static int   SK_close(struct net_device *dev);
@@ -1337,7 +1337,7 @@
  *     YY/MM/DD  uid  Description
 -*/
 
-static void SK_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t SK_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
     int csr0;
     struct net_device *dev = dev_id;
@@ -1386,6 +1386,7 @@
     SK_write_reg(CSR0, CSR0_INEA); /* Enable Interrupts */
 
     spin_unlock (&SK_lock);
+    return IRQ_HANDLED;
 } /* End of SK_interrupt() */ 
 
 
diff -Nru a/drivers/net/sk_mca.c b/drivers/net/sk_mca.c
--- a/drivers/net/sk_mca.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/net/sk_mca.c	Wed Apr 30 22:28:11 2003
@@ -754,7 +754,7 @@
 
 /* general interrupt entry */
 
-static void irq_handler(int irq, void *device, struct pt_regs *regs)
+static irqreturn_t irq_handler(int irq, void *device, struct pt_regs *regs)
 {
 	struct SKMCA_NETDEV *dev = (struct SKMCA_NETDEV *) device;
 	u16 csr0val;
@@ -766,7 +766,7 @@
 	/* in case we're not meant... */
 
 	if ((csr0val & CSR0_INTR) == 0)
-		return;
+		return IRQ_NONE;
 
 #if (LINUX_VERSION_CODE >= 0x02032a)
 #if 0
@@ -805,6 +805,7 @@
 #else
 	dev->interrupt = 0;
 #endif
+	return IRQ_HANDLED;
 }
 
 /* ------------------------------------------------------------------------
diff -Nru a/drivers/net/skfp/skfddi.c b/drivers/net/skfp/skfddi.c
--- a/drivers/net/skfp/skfddi.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/net/skfp/skfddi.c	Wed Apr 30 22:28:04 2003
@@ -118,7 +118,7 @@
 static int skfp_driver_init(struct net_device *dev);
 static int skfp_open(struct net_device *dev);
 static int skfp_close(struct net_device *dev);
-static void skfp_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t skfp_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static struct net_device_stats *skfp_ctl_get_stats(struct net_device *dev);
 static void skfp_ctl_set_multicast_list(struct net_device *dev);
 static void skfp_ctl_set_multicast_list_wo_lock(struct net_device *dev);
@@ -896,7 +896,7 @@
  *   Interrupts are disabled, then reenabled at the adapter.
  */
 
-void skfp_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t skfp_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *) dev_id;
 	struct s_smc *smc;	/* private board structure pointer */
@@ -905,7 +905,7 @@
 
 	if (dev == NULL) {
 		printk("%s: irq %d for unknown device\n", dev->name, irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	smc = (struct s_smc *) dev->priv;
@@ -913,12 +913,12 @@
 	// IRQs enabled or disabled ?
 	if (inpd(ADDR(B0_IMSK)) == 0) {
 		// IRQs are disabled: must be shared interrupt
-		return;
+		return IRQ_NONE;
 	}
 	// Note: At this point, IRQs are enabled.
 	if ((inpd(ISR_A) & smc->hw.is_imask) == 0) {	// IRQ?
 		// Adapter did not issue an IRQ: must be shared interrupt
-		return;
+		return IRQ_NONE;
 	}
 	CLI_FBI();		// Disable IRQs from our adapter.
 	spin_lock(&bp->DriverLock);
@@ -933,7 +933,7 @@
 	spin_unlock(&bp->DriverLock);
 	STI_FBI();		// Enable IRQs from our adapter.
 
-	return;
+	return IRQ_HANDLED;
 }				// skfp_interrupt
 
 
diff -Nru a/drivers/net/slip.c b/drivers/net/slip.c
--- a/drivers/net/slip.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/net/slip.c	Wed Apr 30 22:28:20 2003
@@ -428,7 +428,7 @@
 	 *       14 Oct 1994  Dmitry Gorodchanin.
 	 */
 	sl->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
-	actual = sl->tty->driver.write(sl->tty, 0, sl->xbuff, count);
+	actual = sl->tty->driver->write(sl->tty, 0, sl->xbuff, count);
 #ifdef SL_CHECK_TRANSMIT
 	sl->dev->trans_start = jiffies;
 #endif
@@ -462,7 +462,7 @@
 		return;
 	}
 
-	actual = tty->driver.write(tty, 0, sl->xhead, sl->xleft);
+	actual = tty->driver->write(tty, 0, sl->xhead, sl->xleft);
 	sl->xleft -= actual;
 	sl->xhead += actual;
 }
@@ -488,7 +488,7 @@
 			goto out;
 		}
 		printk(KERN_WARNING "%s: transmit timed out, %s?\n", dev->name,
-		       (sl->tty->driver.chars_in_buffer(sl->tty) || sl->xleft) ?
+		       (sl->tty->driver->chars_in_buffer(sl->tty) || sl->xleft) ?
 		       "bad line quality" : "driver error");
 		sl->xleft = 0;
 		sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
@@ -722,7 +722,7 @@
 
 /* Find a free SLIP channel, and link in this `tty' line. */
 static struct slip *
-sl_alloc(kdev_t line)
+sl_alloc(dev_t line)
 {
 	struct slip *sl;
 	slip_ctrl_t *slp = NULL;
@@ -739,7 +739,7 @@
 			break;
 
 		if (slp->ctrl.leased) {
-			if (!kdev_same(slp->ctrl.line, line))
+			if (slp->ctrl.line != line)
 				continue;
 			if (slp->ctrl.tty)
 				return NULL;
@@ -753,7 +753,7 @@
 			continue;
 
 		if (current->pid == slp->ctrl.pid) {
-			if (kdev_same(slp->ctrl.line, line) && score < 3) {
+			if (slp->ctrl.line == line && score < 3) {
 				sel = i;
 				score = 3;
 				continue;
@@ -764,7 +764,7 @@
 			}
 			continue;
 		}
-		if (kdev_same(slp->ctrl.line, line) && score < 1) {
+		if (slp->ctrl.line == line && score < 1) {
 			sel = i;
 			score = 1;
 			continue;
@@ -861,8 +861,8 @@
 	tty->disc_data = sl;
 	sl->line = tty->device;
 	sl->pid = current->pid;
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 
@@ -941,7 +941,7 @@
 	tty->disc_data = 0;
 	sl->tty = NULL;
 	if (!sl->leased)
-		sl->line = NODEV;
+		sl->line = 0;
 
 	/* VSV = very important to remove timers */
 #ifdef CONFIG_SLIP_SMART
@@ -1456,7 +1456,7 @@
 			if (!netif_queue_stopped(sl->dev))
 			{
 				/* if device busy no outfill */
-				sl->tty->driver.write(sl->tty, 0, &s, 1);
+				sl->tty->driver->write(sl->tty, 0, &s, 1);
 			}
 		}
 		else
diff -Nru a/drivers/net/slip.h b/drivers/net/slip.h
--- a/drivers/net/slip.h	Wed Apr 30 22:28:10 2003
+++ b/drivers/net/slip.h	Wed Apr 30 22:28:10 2003
@@ -100,7 +100,7 @@
 
   unsigned char		mode;		/* SLIP mode			*/
   unsigned char		leased;
-  kdev_t		line;
+  dev_t			line;
   pid_t			pid;
 #define SL_MODE_SLIP	0
 #define SL_MODE_CSLIP	1
diff -Nru a/drivers/net/smc9194.c b/drivers/net/smc9194.c
--- a/drivers/net/smc9194.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/net/smc9194.c	Wed Apr 30 22:28:14 2003
@@ -234,7 +234,7 @@
 /*
  . Handles the actual interrupt
 */
-static void smc_interrupt(int irq, void *, struct pt_regs *regs);
+static irqreturn_t smc_interrupt(int irq, void *, struct pt_regs *regs);
 /*
  . This is a separate procedure to handle the receipt of a packet, to
  . leave the interrupt code looking slightly cleaner
@@ -1133,7 +1133,7 @@
  .
  ---------------------------------------------------------------------*/
 
-static void smc_interrupt(int irq, void * dev_id,  struct pt_regs * regs)
+static irqreturn_t smc_interrupt(int irq, void * dev_id,  struct pt_regs * regs)
 {
 	struct net_device *dev 	= dev_id;
 	int ioaddr 		= dev->base_addr;
@@ -1146,7 +1146,7 @@
 	/* state registers */
 	word	saved_bank;
 	word	saved_pointer;
-
+	int handled = 0;
 
 
 	PRINTK3((CARDNAME": SMC interrupt started \n"));
@@ -1171,6 +1171,8 @@
 		if (!status )
 			break;
 
+		handled = 1;
+
 		PRINTK3((KERN_WARNING CARDNAME
 			": Handling interrupt status %x \n", status ));
 
@@ -1242,7 +1244,7 @@
 	SMC_SELECT_BANK( saved_bank );
 
 	PRINTK3((CARDNAME ": Interrupt done\n"));
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 /*-------------------------------------------------------------
diff -Nru a/drivers/net/sonic.c b/drivers/net/sonic.c
--- a/drivers/net/sonic.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/net/sonic.c	Wed Apr 30 22:28:18 2003
@@ -170,7 +170,7 @@
  * The typical workload of the driver:
  * Handle the network interface interrupts.
  */
-static void sonic_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sonic_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *) dev_id;
 	unsigned int base_addr = dev->base_addr;
@@ -179,7 +179,7 @@
 
 	if (dev == NULL) {
 		printk("sonic_interrupt: irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	lp = (struct sonic_local *) dev->priv;
@@ -286,6 +286,7 @@
 	 * clear interrupt bits and return
 	 */
 	SONIC_WRITE(SONIC_ISR, status);
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/net/sonic.h b/drivers/net/sonic.h
--- a/drivers/net/sonic.h	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/sonic.h	Wed Apr 30 22:28:03 2003
@@ -469,7 +469,7 @@
 
 static int sonic_open(struct net_device *dev);
 static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev);
-static void sonic_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t sonic_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void sonic_rx(struct net_device *dev);
 static int sonic_close(struct net_device *dev);
 static struct net_device_stats *sonic_get_stats(struct net_device *dev);
diff -Nru a/drivers/net/starfire.c b/drivers/net/starfire.c
--- a/drivers/net/starfire.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/net/starfire.c	Wed Apr 30 22:28:06 2003
@@ -789,7 +789,7 @@
 static void	tx_timeout(struct net_device *dev);
 static void	init_ring(struct net_device *dev);
 static int	start_tx(struct sk_buff *skb, struct net_device *dev);
-static void	intr_handler(int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *regs);
 static void	netdev_error(struct net_device *dev, int intr_status);
 static int	__netdev_rx(struct net_device *dev, int *quota);
 static void	refill_rx_ring(struct net_device *dev);
@@ -1491,7 +1491,7 @@
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
-static void intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
+static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
 {
 	struct net_device *dev = dev_instance;
 	struct netdev_private *np;
@@ -1499,6 +1499,7 @@
 	int boguscnt = max_interrupt_work;
 	int consumer;
 	int tx_status;
+	int handled = 0;
 
 	ioaddr = dev->base_addr;
 	np = dev->priv;
@@ -1513,6 +1514,8 @@
 		if (intr_status == 0 || intr_status == (u32) -1)
 			break;
 
+		handled = 1;
+
 		if (intr_status & (IntrRxDone | IntrRxEmpty))
 			netdev_rx(dev, ioaddr);
 
@@ -1591,6 +1594,7 @@
 	if (debug > 4)
 		printk(KERN_DEBUG "%s: exiting interrupt, status=%#8.8x.\n",
 		       dev->name, (int) readl(ioaddr + IntrStatus));
+	return IRQ_RETVAL(handled);
 }
 
 
diff -Nru a/drivers/net/sun3_82586.c b/drivers/net/sun3_82586.c
--- a/drivers/net/sun3_82586.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/net/sun3_82586.c	Wed Apr 30 22:28:10 2003
@@ -119,7 +119,7 @@
      DELAY_16(); DELAY_16(); } }
 
 static int     sun3_82586_probe1(struct net_device *dev,int ioaddr);
-static void    sun3_82586_interrupt(int irq,void *dev_id,struct pt_regs *reg_ptr);
+static irqreturn_t sun3_82586_interrupt(int irq,void *dev_id,struct pt_regs *reg_ptr);
 static int     sun3_82586_open(struct net_device *dev);
 static int     sun3_82586_close(struct net_device *dev);
 static int     sun3_82586_send_packet(struct sk_buff *,struct net_device *);
@@ -665,7 +665,7 @@
  * Interrupt Handler ...
  */
 
-static void sun3_82586_interrupt(int irq,void *dev_id,struct pt_regs *reg_ptr)
+static irqreturn_t sun3_82586_interrupt(int irq,void *dev_id,struct pt_regs *reg_ptr)
 {
 	struct net_device *dev = dev_id;
 	unsigned short stat;
@@ -674,7 +674,7 @@
 
 	if (!dev) {
 		printk ("sun3_82586-interrupt: irq %d for unknown device.\n",irq);
-		return;
+		return IRQ_NONE;
 	}
 	p = (struct priv *) dev->priv;
 
@@ -733,6 +733,7 @@
 
 	if(debuglevel > 1)
 		printk("i");
+	return IRQ_HANDLED;
 }
 
 /*******************************************************
diff -Nru a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
--- a/drivers/net/sunbmac.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/net/sunbmac.c	Wed Apr 30 22:28:10 2003
@@ -874,7 +874,7 @@
 		printk(KERN_NOTICE "%s: Memory squeeze, deferring packet.\n", bp->dev->name);
 }
 
-static void bigmac_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t bigmac_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct bigmac *bp = (struct bigmac *) dev_id;
 	u32 qec_status, bmac_status;
@@ -895,6 +895,8 @@
 
 	if (bmac_status & CREG_STAT_RXIRQ)
 		bigmac_rx(bp);
+
+	return IRQ_HANDLED;
 }
 
 static int bigmac_open(struct net_device *dev)
diff -Nru a/drivers/net/sundance.c b/drivers/net/sundance.c
--- a/drivers/net/sundance.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/net/sundance.c	Wed Apr 30 22:28:11 2003
@@ -71,19 +71,29 @@
 
 	Versin LK1.06b (D-Link):
 	- New tx scheme, adaptive tx_coalesce
+	
+	Version LK1.07 (D-Link):
+	- Fix tx bugs in big-endian machines
+	- Remove unused max_interrupt_work module parameter, the new 
+	  NAPI-like rx scheme doesn't need it.
+	- Remove redundancy get_stats() in intr_handler(), those 
+	  I/O access could affect performance in ARM-based system
+	- Add Linux software VLAN support
+	
+	Version LK1.08 (D-Link):
+	- Fix bug of custom mac address 
+	(StationAddr register only accept word write) 
 
 */
 
 #define DRV_NAME	"sundance"
-#define DRV_VERSION	"1.01+LK1.06b"
-#define DRV_RELDATE	"6-Nov-2002"
+#define DRV_VERSION	"1.01+LK1.08a"
+#define DRV_RELDATE	"23-Apr-2003"
 
 
 /* The user-configurable values.
    These may be modified when a driver module is loaded.*/
 static int debug = 1;			/* 1 normal messages, 0 quiet .. 7 verbose. */
-/* Maximum events (Rx packets, etc.) to handle at each interrupt. */
-static int max_interrupt_work = 0;
 /* Maximum number of multicast addresses to filter (vs. rx-all-multicast).
    Typical is a 64 element hash table based on the Ethernet CRC.  */
 static int multicast_filter_limit = 32;
@@ -129,8 +139,7 @@
 /* Operational parameters that usually are not changed. */
 /* Time in jiffies before concluding the transmitter is hung. */
 #define TX_TIMEOUT  (4*HZ)
-
-#define PKT_BUF_SZ		1536			/* Size of each temporary Rx buffer.*/
+#define PKT_BUF_SZ		1536	/* Size of each temporary Rx buffer.*/
 
 #ifndef __KERNEL__
 #define __KERNEL__
@@ -181,12 +190,10 @@
 MODULE_DESCRIPTION("Sundance Alta Ethernet driver");
 MODULE_LICENSE("GPL");
 
-MODULE_PARM(max_interrupt_work, "i");
 MODULE_PARM(debug, "i");
 MODULE_PARM(rx_copybreak, "i");
 MODULE_PARM(media, "1-" __MODULE_STRING(MAX_UNITS) "s");
 MODULE_PARM(flowctrl, "i");
-MODULE_PARM_DESC(max_interrupt_work, "Sundance Alta maximum events handled per interrupt");
 MODULE_PARM_DESC(debug, "Sundance Alta debug level (0-5)");
 MODULE_PARM_DESC(rx_copybreak, "Sundance Alta copy breakpoint for copy-only-tiny-frames");
 MODULE_PARM_DESC(flowctrl, "Sundance Alta flow control [0|1]");
@@ -495,13 +502,14 @@
 static void init_ring(struct net_device *dev);
 static int  start_tx(struct sk_buff *skb, struct net_device *dev);
 static int reset_tx (struct net_device *dev);
-static void intr_handler(int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *regs);
 static void rx_poll(unsigned long data);
 static void tx_poll(unsigned long data);
 static void refill_rx (struct net_device *dev);
 static void netdev_error(struct net_device *dev, int intr_status);
 static void netdev_error(struct net_device *dev, int intr_status);
 static void set_rx_mode(struct net_device *dev);
+static int __set_mac_addr(struct net_device *dev);
 static struct net_device_stats *get_stats(struct net_device *dev);
 static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static int  netdev_close(struct net_device *dev);
@@ -847,17 +855,18 @@
 	if (netif_msg_ifup(np))
 		printk(KERN_DEBUG "%s: netdev_open() irq %d.\n",
 			   dev->name, dev->irq);
-
 	init_ring(dev);
 
 	writel(np->rx_ring_dma, ioaddr + RxListPtr);
 	/* The Tx list pointer is written as packets are queued. */
 
-	for (i = 0; i < 6; i++)
-		writeb(dev->dev_addr[i], ioaddr + StationAddr + i);
-
 	/* Initialize other registers. */
+	__set_mac_addr(dev);
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
+	writew(dev->mtu + 18, ioaddr + MaxFrameSize);
+#else
 	writew(dev->mtu + 14, ioaddr + MaxFrameSize);
+#endif
 	if (dev->mtu > 2047)
 		writel(readl(ioaddr + ASICCtrl) | 0x0C, ioaddr + ASICCtrl);
 
@@ -879,7 +888,7 @@
 		writeb(0x01, ioaddr + DebugCtrl1);
 	netif_start_queue(dev);
 
-	writew(StatsEnable | RxEnable | TxEnable, ioaddr + MACCtrl1);
+	writew (StatsEnable | RxEnable | TxEnable, ioaddr + MACCtrl1);
 
 	if (netif_msg_ifup(np))
 		printk(KERN_DEBUG "%s: Done netdev_open(), status: Rx %x Tx %x "
@@ -951,7 +960,7 @@
 {
 	struct netdev_private *np = dev->priv;
 	long ioaddr = dev->base_addr;
-	long flag;
+	unsigned long flag;
 	
 	netif_stop_queue(dev);
 	tasklet_disable(&np->tx_tasklet);
@@ -966,11 +975,11 @@
 		for (i=0; i<TX_RING_SIZE; i++) {
 			printk(KERN_DEBUG "%02x %08x %08x %08x(%02x) %08x %08x\n", i,
 				np->tx_ring_dma + i*sizeof(*np->tx_ring),	
-				np->tx_ring[i].next_desc,
-				np->tx_ring[i].status,
-				(np->tx_ring[i].status >> 2) & 0xff,
-				np->tx_ring[i].frag[0].addr, 
-				np->tx_ring[i].frag[0].length);
+				le32_to_cpu(np->tx_ring[i].next_desc),
+				le32_to_cpu(np->tx_ring[i].status),
+				(le32_to_cpu(np->tx_ring[i].status) >> 2) & 0xff,
+				le32_to_cpu(np->tx_ring[i].frag[0].addr), 
+				le32_to_cpu(np->tx_ring[i].frag[0].length));
 		}
 		printk(KERN_DEBUG "TxListPtr=%08x netif_queue_stopped=%d\n", 
 			readl(dev->base_addr + TxListPtr), 
@@ -1152,15 +1161,15 @@
 
 /* The interrupt handler cleans up after the Tx thread, 
    and schedule a Rx thread work */
-static void intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
+static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
 {
 	struct net_device *dev = (struct net_device *)dev_instance;
 	struct netdev_private *np;
 	long ioaddr;
-	int boguscnt = max_interrupt_work;
 	int hw_frame_id;
 	int tx_cnt;
 	int tx_status;
+	int handled = 0;
 
 	ioaddr = dev->base_addr;
 	np = dev->priv;
@@ -1176,6 +1185,8 @@
 		if (!(intr_status & DEFAULT_INTR))
 			break;
 
+		handled = 1;
+
 		if (intr_status & (IntrRxDMADone)) {
 			writew(DEFAULT_INTR & ~(IntrRxDone|IntrRxDMADone),
 					ioaddr + IntrEnable);
@@ -1226,11 +1237,14 @@
 				int entry = np->dirty_tx % TX_RING_SIZE;
 				struct sk_buff *skb;
 				int sw_frame_id;
-				sw_frame_id = (np->tx_ring[entry].status >> 2) & 0xff;
-					if (sw_frame_id == hw_frame_id &&
-						!(np->tx_ring[entry].status & 0x00010000))
+				sw_frame_id = (le32_to_cpu(
+					np->tx_ring[entry].status) >> 2) & 0xff;
+				if (sw_frame_id == hw_frame_id &&
+					!(le32_to_cpu(np->tx_ring[entry].status)
+					& 0x00010000))
 						break;
-					if (sw_frame_id == (hw_frame_id + 1) % TX_RING_SIZE)
+				if (sw_frame_id == (hw_frame_id + 1) % 
+					TX_RING_SIZE)
 						break;
 				skb = np->tx_skbuff[entry];
 				/* Free the original skb. */
@@ -1248,7 +1262,8 @@
 			for (; np->cur_tx - np->dirty_tx > 0; np->dirty_tx++) {
 				int entry = np->dirty_tx % TX_RING_SIZE;
 				struct sk_buff *skb;
-				if (!(np->tx_ring[entry].status & 0x00010000))
+				if (!(le32_to_cpu(np->tx_ring[entry].status) 
+							& 0x00010000))
 					break;
 				skb = np->tx_skbuff[entry];
 				/* Free the original skb. */
@@ -1271,20 +1286,12 @@
 		/* Abnormal error summary/uncommon events handlers. */
 		if (intr_status & (IntrPCIErr | LinkChange | StatsMax))
 			netdev_error(dev, intr_status);
-		if (--boguscnt < 0) {
-			get_stats(dev);
-			if (netif_msg_hw(np))
-				printk(KERN_WARNING "%s: Too much work at interrupt, "
-				   "status=0x%4.4x / 0x%4.4x.\n",
-				   dev->name, intr_status, readw(ioaddr + IntrClear));
-			break;
-		}
-	} while (1);
+	} while (0);
 	if (netif_msg_intr(np))
 		printk(KERN_DEBUG "%s: exiting interrupt, status=%#4.4x.\n",
 			   dev->name, readw(ioaddr + IntrStatus));
 	writel(5000, ioaddr + DownCounter);
-
+	return IRQ_RETVAL(handled);
 }
 
 static void rx_poll(unsigned long data)
@@ -1463,8 +1470,8 @@
 
 static struct net_device_stats *get_stats(struct net_device *dev)
 {
-	long ioaddr = dev->base_addr;
 	struct netdev_private *np = dev->priv;
+	long ioaddr = dev->base_addr;
 	int i;
 
 	/* We should lock this segment of code for SMP eventually, although
@@ -1477,7 +1484,7 @@
 	np->stats.collisions += readb(ioaddr + StatsLateColl);
 	np->stats.collisions += readb(ioaddr + StatsMultiColl);
 	np->stats.collisions += readb(ioaddr + StatsOneColl);
-	readb(ioaddr + StatsCarrierError);
+	np->stats.tx_carrier_errors += readb(ioaddr + StatsCarrierError);
 	readb(ioaddr + StatsTxDefer);
 	for (i = StatsTxDefer; i <= StatsMcastRx; i++)
 		readb(ioaddr + i);
@@ -1529,6 +1536,20 @@
 	writeb(rx_mode, ioaddr + RxMode);
 }
 
+static int __set_mac_addr(struct net_device *dev)
+{
+	u16 addr16;
+
+	addr16 = (dev->dev_addr[0] | (dev->dev_addr[1] << 8));
+	writew(addr16, dev->base_addr + StationAddr);
+	addr16 = (dev->dev_addr[2] | (dev->dev_addr[3] << 8));
+	writew(addr16, dev->base_addr + StationAddr+2);
+	addr16 = (dev->dev_addr[4] | (dev->dev_addr[5] << 8));
+	writew(addr16, dev->base_addr + StationAddr+4);
+	return 0;
+}
+	
+
 static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
 {
 	struct netdev_private *np = dev->priv;
@@ -1615,6 +1636,7 @@
 	struct mii_ioctl_data *data = (struct mii_ioctl_data *) & rq->ifr_data;
 	int rc;
 	int i;
+	long ioaddr = dev->base_addr;
 
 	if (!netif_running(dev))
 		return -EINVAL;
@@ -1632,11 +1654,12 @@
 		for (i=0; i<TX_RING_SIZE; i++) {
 			printk(KERN_DEBUG "%02x %08x %08x %08x(%02x) %08x %08x\n", i,
 				np->tx_ring_dma + i*sizeof(*np->tx_ring),	
-				np->tx_ring[i].next_desc,
-				np->tx_ring[i].status,
-				(np->tx_ring[i].status >> 2) & 0xff,
-				np->tx_ring[i].frag[0].addr, 
-				np->tx_ring[i].frag[0].length);
+				le32_to_cpu(np->tx_ring[i].next_desc),
+				le32_to_cpu(np->tx_ring[i].status),
+				(le32_to_cpu(np->tx_ring[i].status) >> 2) 
+					& 0xff,
+				le32_to_cpu(np->tx_ring[i].frag[0].addr), 
+				le32_to_cpu(np->tx_ring[i].frag[0].length));
 		}
 		printk(KERN_DEBUG "TxListPtr=%08x netif_queue_stopped=%d\n", 
 			readl(dev->base_addr + TxListPtr), 
@@ -1646,6 +1669,7 @@
 			np->dirty_tx, np->dirty_tx % TX_RING_SIZE);
 		printk(KERN_DEBUG "cur_rx=%d dirty_rx=%d\n", np->cur_rx, np->dirty_rx);
 		printk(KERN_DEBUG "cur_task=%d\n", np->cur_task);
+		printk(KERN_DEBUG "TxStatus=%04x\n", readw(ioaddr + TxStatus));
 			return 0;
 	}
 				
diff -Nru a/drivers/net/sungem.c b/drivers/net/sungem.c
--- a/drivers/net/sungem.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/net/sungem.c	Wed Apr 30 22:28:18 2003
@@ -773,7 +773,7 @@
 		       gp->dev->name);
 }
 
-static void gem_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t gem_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
 	struct gem *gp = dev->priv;
@@ -792,6 +792,8 @@
 
 out:
 	spin_unlock(&gp->lock);
+
+	return IRQ_HANDLED;
 }
 
 static void gem_tx_timeout(struct net_device *dev)
diff -Nru a/drivers/net/sunhme.c b/drivers/net/sunhme.c
--- a/drivers/net/sunhme.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/net/sunhme.c	Wed Apr 30 22:28:07 2003
@@ -2101,7 +2101,7 @@
 	RXD((">"));
 }
 
-static void happy_meal_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t happy_meal_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *) dev_id;
 	struct happy_meal *hp  = dev->priv;
@@ -2135,10 +2135,12 @@
 	HMD(("done\n"));
 out:
 	spin_unlock(&hp->happy_lock);
+
+	return IRQ_HANDLED;
 }
 
 #ifdef CONFIG_SBUS
-static void quattro_sbus_interrupt(int irq, void *cookie, struct pt_regs *ptregs)
+static irqreturn_t quattro_sbus_interrupt(int irq, void *cookie, struct pt_regs *ptregs)
 {
 	struct quattro *qp = (struct quattro *) cookie;
 	int i;
@@ -2183,6 +2185,8 @@
 		spin_unlock(&hp->happy_lock);
 	}
 	HMD(("done\n"));
+
+	return IRQ_HANDLED;
 }
 #endif
 
diff -Nru a/drivers/net/sunlance.c b/drivers/net/sunlance.c
--- a/drivers/net/sunlance.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/net/sunlance.c	Wed Apr 30 22:28:07 2003
@@ -812,7 +812,7 @@
 	spin_unlock(&lp->lock);
 }
 
-static void lance_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t lance_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *)dev_id;
 	struct lance_private *lp = (struct lance_private *)dev->priv;
@@ -871,6 +871,8 @@
 	}
 
 	sbus_writew(LE_C0_INEA, lp->lregs + RDP);
+
+	return IRQ_HANDLED;
 }
 
 /* Build a fake network packet and send it to ourselves. */
@@ -1415,7 +1417,7 @@
 				       "'tpe-link-test?'\n", dev->name);
 				printk(KERN_NOTICE "%s: warning: mail any problems "
 				       "to ecd@skynet.be\n", dev->name);
-				set_auxio(AUXIO_LINK_TEST, 0);
+				auxio_set_lte(AUXIO_LTE_ON);
 			}
 no_link_test:
 			lp->auto_select = 1;
diff -Nru a/drivers/net/sunqe.c b/drivers/net/sunqe.c
--- a/drivers/net/sunqe.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/net/sunqe.c	Wed Apr 30 22:28:07 2003
@@ -456,7 +456,7 @@
  * so we just run through each qe and check to see who is signaling
  * and thus needs to be serviced.
  */
-static void qec_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t qec_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct sunqec *qecp = (struct sunqec *) dev_id;
 	u32 qec_status;
@@ -495,6 +495,8 @@
 		qec_status >>= 4;
 		channel++;
 	}
+
+	return IRQ_HANDLED;
 }
 
 static int qe_open(struct net_device *dev)
diff -Nru a/drivers/net/tc35815.c b/drivers/net/tc35815.c
--- a/drivers/net/tc35815.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/tc35815.c	Wed Apr 30 22:28:03 2003
@@ -451,7 +451,7 @@
 static int	tc35815_open(struct net_device *dev);
 static int	tc35815_send_packet(struct sk_buff *skb, struct net_device *dev);
 static void     tc35815_tx_timeout(struct net_device *dev);
-static void	tc35815_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t tc35815_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void	tc35815_rx(struct net_device *dev);
 static void	tc35815_txdone(struct net_device *dev);
 static int	tc35815_close(struct net_device *dev);
@@ -1036,16 +1036,17 @@
  * The typical workload of the driver:
  *   Handle the network interface interrupts.
  */
-static void tc35815_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t tc35815_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
 	struct net_device *dev = dev_id;
 	struct tc35815_regs *tr;
 	struct tc35815_local *lp;
 	int status, boguscount = 0;
+	int handled = 0;
 
 	if (dev == NULL) {
 		printk(KERN_WARNING "%s: irq %d for unknown device.\n", cardname, irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	tr = (struct tc35815_regs*)dev->base_addr;
@@ -1055,6 +1056,7 @@
 		status = tc_readl(&tr->Int_Src);
 		if (status == 0)
 			break;
+		handled = 1;
 		tc_writel(status, &tr->Int_Src);	/* write to clear */
 
 		/* Fatal errors... */
@@ -1097,7 +1099,7 @@
 		}
 	} while (++boguscount < 20) ;
 
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 /* We have a good packet(s), get it/them out of the buffers. */
diff -Nru a/drivers/net/tg3.c b/drivers/net/tg3.c
--- a/drivers/net/tg3.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/net/tg3.c	Wed Apr 30 22:28:10 2003
@@ -2148,12 +2148,13 @@
 	return work_exists;
 }
 
-static void tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
 	struct tg3 *tp = dev->priv;
 	struct tg3_hw_status *sblk = tp->hw_status;
 	unsigned long flags;
+	unsigned int handled = 1;
 
 	spin_lock_irqsave(&tp->lock, flags);
 
@@ -2184,9 +2185,13 @@
 			     	0x00000000);
 			tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);
 		}
+	} else {	/* shared interrupt */
+		handled = 0;
 	}
 
 	spin_unlock_irqrestore(&tp->lock, flags);
+
+	return IRQ_RETVAL(handled);
 }
 
 static void tg3_init_rings(struct tg3 *);
@@ -3100,6 +3105,7 @@
 	err |= tg3_stop_block(tp, SNDDATAI_MODE, SNDDATAI_MODE_ENABLE);
 	err |= tg3_stop_block(tp, RDMAC_MODE, RDMAC_MODE_ENABLE);
 	err |= tg3_stop_block(tp, SNDDATAC_MODE, SNDDATAC_MODE_ENABLE);
+	err |= tg3_stop_block(tp, DMAC_MODE, DMAC_MODE_ENABLE);
 	err |= tg3_stop_block(tp, SNDBDC_MODE, SNDBDC_MODE_ENABLE);
 	if (err)
 		goto out;
diff -Nru a/drivers/net/tlan.c b/drivers/net/tlan.c
--- a/drivers/net/tlan.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/net/tlan.c	Wed Apr 30 22:28:05 2003
@@ -288,7 +288,7 @@
 static int      TLan_Init( struct net_device * );
 static int	TLan_Open( struct net_device *dev );
 static int	TLan_StartTx( struct sk_buff *, struct net_device *);
-static void	TLan_HandleInterrupt( int, void *, struct pt_regs *);
+static irqreturn_t TLan_HandleInterrupt( int, void *, struct pt_regs *);
 static int	TLan_Close( struct net_device *);
 static struct	net_device_stats *TLan_GetStats( struct net_device *);
 static void	TLan_SetMulticastList( struct net_device *);
@@ -1106,7 +1106,7 @@
 	 *
 	 **************************************************************/
 
-static void TLan_HandleInterrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t TLan_HandleInterrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	u32		ack;
 	struct net_device	*dev;
@@ -1134,6 +1134,7 @@
 
 	spin_unlock(&priv->lock);
 
+	return IRQ_HANDLED;
 } /* TLan_HandleInterrupts */
 
 
diff -Nru a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
--- a/drivers/net/tokenring/3c359.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/net/tokenring/3c359.c	Wed Apr 30 22:28:19 2003
@@ -131,7 +131,7 @@
 static void xl_dn_comp(struct net_device *dev); 
 static int xl_close(struct net_device *dev);
 static void xl_set_rx_mode(struct net_device *dev);
-static void xl_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t xl_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static struct net_device_stats * xl_get_stats(struct net_device *dev);
 static int xl_set_mac_address(struct net_device *dev, void *addr) ; 
 static void xl_arb_cmd(struct net_device *dev);
@@ -1027,7 +1027,7 @@
 	return  ; 
 }
 
-static void xl_interrupt(int irq, void *dev_id, struct pt_regs *regs) 
+static irqreturn_t xl_interrupt(int irq, void *dev_id, struct pt_regs *regs) 
 {
 	struct net_device *dev = (struct net_device *)dev_id;
  	struct xl_private *xl_priv =(struct xl_private *)dev->priv;
@@ -1036,13 +1036,13 @@
 
 	if (!dev) { 
 		printk(KERN_WARNING "Device structure dead, aaahhhh !\n") ;
-		return ; 
+		return IRQ_NONE; 
 	}
 
 	intstatus = readw(xl_mmio + MMIO_INTSTATUS) ;  
 
 	if (!(intstatus & 1)) /* We didn't generate the interrupt */
-		return ; 
+		return IRQ_NONE;
 
 	spin_lock(&xl_priv->xl_lock) ; 
 
@@ -1074,7 +1074,7 @@
 				xl_reset(dev) ; 
 				writel(ACK_INTERRUPT | LATCH_ACK, xl_mmio + MMIO_COMMAND) ; 
 				spin_unlock(&xl_priv->xl_lock) ; 
-				return ; 
+				return IRQ_HANDLED;
 			} /* Host Error */
 
 			if (intstatus & SRBRINT ) {  /* Srbc interrupt */
@@ -1134,7 +1134,7 @@
 				xl_reset(dev) ; 
 				writel(ACK_INTERRUPT | LATCH_ACK, xl_mmio + MMIO_COMMAND) ; 
 				spin_unlock(&xl_priv->xl_lock) ; 
-				return ; 
+				return IRQ_HANDLED;
 			}
 		} else { 
 			printk(KERN_WARNING "%s: Received Unknown interrupt : %04x \n", dev->name, intstatus) ;
@@ -1147,7 +1147,8 @@
 	writel( SETINDENABLE | INT_MASK, xl_mmio + MMIO_COMMAND) ; 
 	writel( SETINTENABLE | INT_MASK, xl_mmio + MMIO_COMMAND) ; 
 
-	spin_unlock(&xl_priv->xl_lock) ; 
+	spin_unlock(&xl_priv->xl_lock) ;
+	return IRQ_HANDLED;
 }	
 
 /*
diff -Nru a/drivers/net/tokenring/Kconfig b/drivers/net/tokenring/Kconfig
--- a/drivers/net/tokenring/Kconfig	Wed Apr 30 22:28:06 2003
+++ b/drivers/net/tokenring/Kconfig	Wed Apr 30 22:28:06 2003
@@ -16,7 +16,7 @@
 	  connected to such a Token Ring network and want to use your Token
 	  Ring card under Linux, say Y here and to the driver for your
 	  particular card below and read the Token-Ring mini-HOWTO, available
-	  from <http://www.linuxdoc.org/docs.html#howto>. Most people can
+	  from <http://www.tldp.org/docs.html#howto>. Most people can
 	  say N here.
 
 config IBMTR
@@ -25,7 +25,7 @@
 	---help---
 	  This is support for all IBM Token Ring cards that don't use DMA. If
 	  you have such a beast, say Y and read the Token-Ring mini-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>.
+	  available from <http://www.tldp.org/docs.html#howto>.
 
 	  Warning: this driver will almost definitely fail if more than one
 	  active Token Ring card is present.
@@ -44,7 +44,7 @@
 	  Wake On Lan, and PCI 100/16/4 adapters.
 
 	  If you have such an adapter, say Y and read the Token-Ring
-	  mini-HOWTO, available from <http://www.linuxdoc.org/docs.html#howto>.
+	  mini-HOWTO, available from <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -62,7 +62,7 @@
 	  This is support for IBM Lanstreamer PCI Token Ring Cards.
 
 	  If you have such an adapter, say Y and read the Token-Ring
-	  mini-HOWTO, available from <http://www.linuxdoc.org/docs.html#howto>.
+	  mini-HOWTO, available from <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a modules ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -78,7 +78,7 @@
 	  should use the tms380 driver instead.
 
 	  If you have such an adapter, say Y and read the Token-Ring
-	  mini-HOWTO, available from <http://www.linuxdoc.org/docs.html#howto>.
+	  mini-HOWTO, available from <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -104,7 +104,7 @@
 
 	  If you have such an adapter and would like to use it, say Y and
 	  read the Token-Ring mini-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  Also read the file <file:Documentation/networking/tms380tr.txt> or
 	  check <http://www.auk.cx/tms380tr/>.
@@ -194,7 +194,7 @@
 
 	  If you have such an adapter and would like to use it, say Y or M and
 	  read the Token-Ring mini-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto> and the file
+	  <http://www.tldp.org/docs.html#howto> and the file
 	  <file:Documentation/networking/smctr.txt>.
 
 	  This driver is also available as a module ( = code which can be
diff -Nru a/drivers/net/tokenring/ibmtr.c b/drivers/net/tokenring/ibmtr.c
--- a/drivers/net/tokenring/ibmtr.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/net/tokenring/ibmtr.c	Wed Apr 30 22:28:11 2003
@@ -198,7 +198,7 @@
 static void 	tok_set_multicast_list(struct net_device *dev);
 static int 	tok_send_packet(struct sk_buff *skb, struct net_device *dev);
 static int 	tok_close(struct net_device *dev);
-void 		tok_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+irqreturn_t tok_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void 	initial_tok_int(struct net_device *dev);
 static void 	tr_tx(struct net_device *dev);
 static void 	tr_rx(struct net_device *dev);
@@ -246,7 +246,8 @@
 	void *chanid;
 	int found_turbo=0;
 	unsigned char *tchanid, ctemp;
-	int i,j;
+	int i, j;
+	unsigned long jif;
 	void *ram_mapped ;   
 
 	if (turbo_searched == 1) return;
@@ -276,7 +277,7 @@
 			writeb(0x00, ram_mapped+0x1E01+i);
 		}
 		writeb(0x00, ram_mapped+0x1E01);
-		for(i=jiffies+TR_BUSY_INTERVAL; time_before_eq(jiffies,i););
+		for(jif=jiffies+TR_BUSY_INTERVAL; time_before_eq(jiffies,jif););
 		intf_tbl=ntohs(readw(ram_mapped+ACA_OFFSET+ACA_RW+WRBR_EVEN));
 		if (intf_tbl) {
 #if IBMTR_DEBUG_MESSAGES
@@ -291,7 +292,7 @@
 			turbo_io[index]=ntohs(readw(ram_mapped+intf_tbl+4));
 			turbo_irq[index]=readb(ram_mapped+intf_tbl+3);
 			outb(0, turbo_io[index] + ADAPTRESET);
-			for(i=jiffies+TR_RST_TIME;time_before_eq(jiffies,i););
+			for(jif=jiffies+TR_RST_TIME;time_before_eq(jiffies,jif););
 			outb(0, turbo_io[index] + ADAPTRESETREL);
 			index++;
 			continue;
@@ -1165,7 +1166,7 @@
 
 /******************************************************************************/
 
-void tok_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t tok_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	unsigned char status;
 	/*  unsigned char status_even ; */
@@ -1181,7 +1182,7 @@
 #endif
 	ti = (struct tok_info *) dev->priv;
 	if (ti->sram_virt & 1)
-		return;         /* PCMCIA card extraction flag */
+		return IRQ_NONE;         /* PCMCIA card extraction flag */
 	spin_lock(&(ti->lock));
 #ifdef ENABLE_PAGING
 	save_srpr = readb(ti->mmio + ACA_OFFSET + ACA_RW + SRPR_EVEN);
@@ -1201,7 +1202,7 @@
                 writeb(save_srpr, ti->mmio + ACA_OFFSET + ACA_RW + SRPR_EVEN);
 #endif
                 spin_unlock(&(ti->lock));
-                return;
+                return IRQ_HANDLED;
         }
 	/*  Begin interrupt handler HERE inline to avoid the extra
 	    levels of logic and call depth for the original solution. */
@@ -1240,7 +1241,7 @@
 		outb(0, dev->base_addr + ADAPTRESET);
 		ibmtr_reset_timer(&(ti->tr_timer), dev);/*BMS try to reopen*/
 		spin_unlock(&(ti->lock));
-		return;
+		return IRQ_HANDLED;
 	}
 	if (readb(ti->mmio + ACA_OFFSET + ACA_RW + ISRP_EVEN)
 		& (TCR_INT | ERR_INT | ACCESS_INT)) {
@@ -1255,7 +1256,7 @@
                 writeb(save_srpr, ti->mmio + ACA_OFFSET + ACA_RW + SRPR_EVEN);
 #endif
                 spin_unlock(&(ti->lock));
-                return;
+                return IRQ_HANDLED;
         }
 	if (status & SRB_RESP_INT) {	/* SRB response */
 		SET_PAGE(ti->srb_page);
@@ -1486,6 +1487,7 @@
 #endif
 	writeb(INT_ENABLE, ti->mmio + ACA_OFFSET + ACA_SET + ISRP_EVEN);
 	spin_unlock(&(ti->lock));
+	return IRQ_HANDLED;
 }				/*tok_interrupt */
 
 /*****************************************************************************/
diff -Nru a/drivers/net/tokenring/madgemc.c b/drivers/net/tokenring/madgemc.c
--- a/drivers/net/tokenring/madgemc.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/net/tokenring/madgemc.c	Wed Apr 30 22:28:17 2003
@@ -77,7 +77,7 @@
 static void madgemc_setsifsel(struct net_device *dev, int val);
 static void madgemc_setint(struct net_device *dev, int val);
 
-static void madgemc_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t madgemc_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 /*
  * These work around paging, however they don't guarentee you're on the
@@ -457,14 +457,14 @@
  * exhausted all contiguous interrupts.
  *
  */
-static void madgemc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t madgemc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	int pending,reg1;
 	struct net_device *dev;
 
 	if (!dev_id) {
 		printk("madgemc_interrupt: was not passed a dev_id!\n");
-		return;
+		return IRQ_NONE;
 	}
 
 	dev = (struct net_device *)dev_id;
@@ -472,7 +472,7 @@
 	/* Make sure its really us. -- the Madge way */
 	pending = inb(dev->base_addr + MC_CONTROL_REG0);
 	if (!(pending & MC_CONTROL_REG0_SINTR))
-		return; /* not our interrupt */
+		return IRQ_NONE; /* not our interrupt */
 
 	/*
 	 * Since we're level-triggered, we may miss the rising edge
@@ -496,10 +496,10 @@
 			pending = SIFREADW(SIFSTS); /* restart - the SIF way */
 
 		} else
-			return; 
+			return IRQ_HANDLED; 
 	} while (1);
 
-	return; /* not reachable */
+	return IRQ_HANDLED; /* not reachable */
 }
 
 /*
diff -Nru a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c
--- a/drivers/net/tokenring/olympic.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/net/tokenring/olympic.c	Wed Apr 30 22:28:14 2003
@@ -185,7 +185,7 @@
 static int olympic_close(struct net_device *dev);
 static void olympic_set_rx_mode(struct net_device *dev);
 static void olympic_freemem(struct net_device *dev) ;  
-static void olympic_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t olympic_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static struct net_device_stats * olympic_get_stats(struct net_device *dev);
 static int olympic_set_mac_address(struct net_device *dev, void *addr) ; 
 static void olympic_arb_cmd(struct net_device *dev);
@@ -910,7 +910,7 @@
 	return ; 
 }
  
-static void olympic_interrupt(int irq, void *dev_id, struct pt_regs *regs) 
+static irqreturn_t olympic_interrupt(int irq, void *dev_id, struct pt_regs *regs) 
 {
 	struct net_device *dev= (struct net_device *)dev_id;
 	struct olympic_private *olympic_priv=(struct olympic_private *)dev->priv;
@@ -925,7 +925,7 @@
 	 */ 
 	sisr=readl(olympic_mmio+SISR) ; 
 	if (!(sisr & SISR_MI)) /* Interrupt isn't for us */ 
-		return ;
+		return IRQ_NONE;
 	sisr=readl(olympic_mmio+SISR_RR) ;  /* Read & Reset sisr */ 
 
 	spin_lock(&olympic_priv->olympic_lock);
@@ -937,7 +937,7 @@
 		free_irq(dev->irq, dev) ;
 		dev->stop = NULL ;  
 		spin_unlock(&olympic_priv->olympic_lock) ; 
-		return ;
+		return IRQ_NONE;
 	} 
 		
 	if (sisr & (SISR_SRB_REPLY | SISR_TX1_EOF | SISR_RX_STATUS | SISR_ADAPTER_CHECK |  
@@ -954,7 +954,7 @@
 			free_irq(dev->irq, dev) ;
 			dev->stop = NULL ;  
 			spin_unlock(&olympic_priv->olympic_lock) ; 
-			return ;
+			return IRQ_HANDLED;
 		} /* SISR_ERR */
 
 		if(sisr & SISR_SRB_REPLY) {
@@ -999,7 +999,7 @@
 			free_irq(dev->irq, dev) ;
 			dev->stop = NULL ;  
 			spin_unlock(&olympic_priv->olympic_lock) ; 
-			return ; 
+			return IRQ_HANDLED; 
 		} /* SISR_ADAPTER_CHECK */
 	
 		if (sisr & SISR_ASB_FREE) {
@@ -1032,6 +1032,7 @@
 	writel(SISR_MI,olympic_mmio+SISR_MASK_SUM);
 	
 	spin_unlock(&olympic_priv->olympic_lock) ; 
+	return IRQ_HANDLED;
 }	
 
 static int olympic_xmit(struct sk_buff *skb, struct net_device *dev) 
diff -Nru a/drivers/net/tokenring/smctr.c b/drivers/net/tokenring/smctr.c
--- a/drivers/net/tokenring/smctr.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/net/tokenring/smctr.c	Wed Apr 30 22:28:09 2003
@@ -151,7 +151,7 @@
 static int smctr_init_tx_bdbs(struct net_device *dev);
 static int smctr_init_tx_fcbs(struct net_device *dev);
 static int smctr_internal_self_test(struct net_device *dev);
-static void smctr_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t smctr_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static int smctr_issue_enable_int_cmd(struct net_device *dev,
         __u16 interrupt_enable_mask);
 static int smctr_issue_int_ack(struct net_device *dev, __u16 iack_code,
@@ -2002,7 +2002,7 @@
 /*
  * The typical workload of the driver: Handle the network interface interrupts.
  */
-static void smctr_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t smctr_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
         struct net_device *dev = dev_id;
         struct net_local *tp;
@@ -2015,7 +2015,7 @@
         if(dev == NULL)
         {
                 printk(KERN_CRIT "%s: irq %d for unknown device.\n", dev->name, irq);
-                return;
+                return IRQ_NONE;
         }
 
         ioaddr = dev->base_addr;
@@ -2023,7 +2023,7 @@
         
 
         if(tp->status == NOT_INITIALIZED)
-                return;
+                return IRQ_NONE;
 
         spin_lock(&tp->lock);
         
@@ -2047,7 +2047,7 @@
                 {
                         smctr_disable_16bit(dev);
 		        spin_unlock(&tp->lock);
-                        return;
+                        return IRQ_HANDLED;
                 }
 
                 err = HARDWARE_FAILED;
@@ -2486,7 +2486,7 @@
         smctr_enable_bic_int(dev);
         spin_unlock(&tp->lock);
 
-        return;
+        return IRQ_HANDLED;
 }
 
 static int smctr_issue_enable_int_cmd(struct net_device *dev,
diff -Nru a/drivers/net/tokenring/tms380tr.c b/drivers/net/tokenring/tms380tr.c
--- a/drivers/net/tokenring/tms380tr.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/net/tokenring/tms380tr.c	Wed Apr 30 22:28:10 2003
@@ -152,7 +152,6 @@
 static void 	tms380tr_init_ipb(struct net_local *tp);
 static void 	tms380tr_init_net_local(struct net_device *dev);
 static void 	tms380tr_init_opb(struct net_device *dev);
-void	 	tms380tr_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 /* "M" */
 /* "O" */
 int		tms380tr_open(struct net_device *dev);
@@ -780,15 +779,16 @@
 /*
  * The typical workload of the driver: Handle the network interface interrupts.
  */
-void tms380tr_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t tms380tr_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
 	struct net_local *tp;
 	unsigned short irq_type;
+	int handled = 0;
 
 	if(dev == NULL) {
 		printk(KERN_INFO "%s: irq %d for unknown device.\n", dev->name, irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	tp = (struct net_local *)dev->priv;
@@ -796,6 +796,7 @@
 	irq_type = SIFREADW(SIFSTS);
 
 	while(irq_type & STS_SYSTEM_IRQ) {
+		handled = 1;
 		irq_type &= STS_IRQ_MASK;
 
 		if(!tms380tr_chk_ssb(tp, irq_type)) {
@@ -870,7 +871,7 @@
 		irq_type = SIFREADW(SIFSTS);
 	}
 
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 /*
diff -Nru a/drivers/net/tokenring/tms380tr.h b/drivers/net/tokenring/tms380tr.h
--- a/drivers/net/tokenring/tms380tr.h	Wed Apr 30 22:28:15 2003
+++ b/drivers/net/tokenring/tms380tr.h	Wed Apr 30 22:28:15 2003
@@ -11,10 +11,12 @@
 
 #ifdef __KERNEL__
 
+#include <linux/interrupt.h>
+
 /* module prototypes */
 int tms380tr_open(struct net_device *dev);
 int tms380tr_close(struct net_device *dev);
-void tms380tr_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+irqreturn_t tms380tr_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 int tmsdev_init(struct net_device *dev, unsigned long dmalimit,
 		struct pci_dev *pdev);
 void tmsdev_term(struct net_device *dev);
diff -Nru a/drivers/net/tulip/Kconfig b/drivers/net/tulip/Kconfig
--- a/drivers/net/tulip/Kconfig	Wed Apr 30 22:28:14 2003
+++ b/drivers/net/tulip/Kconfig	Wed Apr 30 22:28:14 2003
@@ -21,7 +21,7 @@
 	  (smc9332dst), you can also try the driver for "Generic DECchip"
 	  cards, above.  However, most people with a network card of this type
 	  will say Y here.) Do read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  More specific
+	  <http://www.tldp.org/docs.html#howto>.  More specific
 	  information is contained in
 	  <file:Documentation/DocBook/tulip-user.tmpl>.
 
@@ -42,7 +42,7 @@
 	  (smc9332dst), you can also try the driver for "Generic DECchip"
 	  cards, above.  However, most people with a network card of this type
 	  will say Y here.) Do read the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  More specific
+	  <http://www.tldp.org/docs.html#howto>.  More specific
 	  information is contained in 
 	  <file:Documentation/networking/tulip.txt>.
 
@@ -80,7 +80,7 @@
 	  These include the DE425, DE434, DE435, DE450 and DE500 models.  If
 	  you have a network card of this type, say Y and read the
 	  Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. More specific
+	  <http://www.tldp.org/docs.html#howto>. More specific
 	  information is contained in
 	  <file:Documentation/networking/de4x5.txt>.
 
diff -Nru a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
--- a/drivers/net/tulip/de2104x.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/net/tulip/de2104x.c	Wed Apr 30 22:28:15 2003
@@ -492,7 +492,7 @@
 	de->rx_tail = rx_tail;
 }
 
-static void de_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
+static irqreturn_t de_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_instance;
 	struct de_private *de = dev->priv;
@@ -500,7 +500,7 @@
 
 	status = dr32(MacStatus);
 	if ((!(status & (IntrOK|IntrErr))) || (status == 0xFFFF))
-		return;
+		return IRQ_NONE;
 
 	if (netif_msg_intr(de))
 		printk(KERN_DEBUG "%s: intr, status %08x mode %08x desc %u/%u/%u\n",
@@ -532,6 +532,8 @@
 		printk(KERN_ERR "%s: PCI bus error, status=%08x, PCI status=%04x\n",
 		       dev->name, status, pci_status);
 	}
+
+	return IRQ_HANDLED;
 }
 
 static void de_tx (struct de_private *de)
diff -Nru a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
--- a/drivers/net/tulip/de4x5.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/tulip/de4x5.c	Wed Apr 30 22:28:03 2003
@@ -909,7 +909,7 @@
 */
 static int     de4x5_open(struct net_device *dev);
 static int     de4x5_queue_pkt(struct sk_buff *skb, struct net_device *dev);
-static void    de4x5_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t de4x5_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static int     de4x5_close(struct net_device *dev);
 static struct  net_device_stats *de4x5_get_stats(struct net_device *dev);
 static void    de4x5_local_stats(struct net_device *dev, char *buf, int pkt_len);
@@ -1349,6 +1349,7 @@
     }
     
     /* The DE4X5-specific entries in the device structure. */
+    SET_MODULE_OWNER(dev);
     dev->open = &de4x5_open;
     dev->hard_start_xmit = &de4x5_queue_pkt;
     dev->stop = &de4x5_close;
@@ -1433,8 +1434,6 @@
 	printk("\tsigr: 0x%08x\n", inl(DE4X5_SIGR));
     }
     
-    MOD_INC_USE_COUNT;
-    
     return status;
 }
 
@@ -1617,17 +1616,18 @@
 ** is high and descriptor status bits cannot be set before the associated
 ** interrupt is asserted and this routine entered.
 */
-static void
+static irqreturn_t
 de4x5_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
     struct net_device *dev = (struct net_device *)dev_id;
     struct de4x5_private *lp;
     s32 imr, omr, sts, limit;
     u_long iobase;
+    unsigned int handled = 0;
     
     if (dev == NULL) {
 	printk ("de4x5_interrupt(): irq %d for unknown device.\n", irq);
-	return;
+	return IRQ_NONE;
     }
     lp = (struct de4x5_private *)dev->priv;
     spin_lock(&lp->lock);
@@ -1645,6 +1645,7 @@
 	outl(sts, DE4X5_STS);            /* Reset the board interrupts */
 	    
 	if (!(sts & lp->irq_mask)) break;/* All done */
+	handled = 1;
 	    
 	if (sts & (STS_RI | STS_RU))     /* Rx interrupt (packet[s] arrived) */
 	  de4x5_rx(dev);
@@ -1665,7 +1666,7 @@
 	    printk("%s: Fatal bus error occurred, sts=%#8x, device stopped.\n",
 		   dev->name, sts);
 	    spin_unlock(&lp->lock);
-	    return;
+	    return IRQ_HANDLED;
 	}
     }
 
@@ -1681,7 +1682,7 @@
     ENABLE_IRQs;
     spin_unlock(&lp->lock);
     
-    return;
+    return IRQ_RETVAL(handled);
 }
 
 static int
@@ -1923,8 +1924,6 @@
     /* Free any socket buffers */
     de4x5_free_rx_buffs(dev);
     de4x5_free_tx_buffs(dev);
-    
-    MOD_DEC_USE_COUNT;
     
     /* Put the adapter to sleep to save power */
     yawn(dev, SLEEP);
diff -Nru a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
--- a/drivers/net/tulip/dmfe.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/net/tulip/dmfe.c	Wed Apr 30 22:28:16 2003
@@ -298,7 +298,7 @@
 static void dmfe_set_filter_mode(struct DEVICE *);
 static int dmfe_do_ioctl(struct DEVICE *, struct ifreq *, int);
 static u16 read_srom_word(long ,int);
-static void dmfe_interrupt(int , void *, struct pt_regs *);
+static irqreturn_t dmfe_interrupt(int , void *, struct pt_regs *);
 static void dmfe_descriptor_init(struct dmfe_board_info *, unsigned long);
 static void allocate_rx_buffer(struct dmfe_board_info *);
 static void update_cr6(u32, unsigned long);
@@ -668,13 +668,13 @@
 	if ( db->tx_queue_cnt < TX_FREE_DESC_CNT )
 		netif_wake_queue(dev);
 
-	/* free this SKB */
-	dev_kfree_skb(skb);
-
 	/* Restore CR7 to enable interrupt */
 	spin_unlock_irqrestore(&db->lock, flags);
 	outl(db->cr7_data, dev->base_addr + DCR7);
 
+	/* free this SKB */
+	dev_kfree_skb(skb);
+
 	return 0;
 }
 
@@ -726,7 +726,7 @@
  *	receive the packet to upper layer, free the transmitted packet
  */
 
-static void dmfe_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t dmfe_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct DEVICE *dev = dev_id;
 	struct dmfe_board_info *db = (struct dmfe_board_info *) dev->priv;
@@ -737,7 +737,7 @@
 
 	if (!dev) {
 		DMFE_DBUG(1, "dmfe_interrupt() without DEVICE arg", 0);
-		return;
+		return IRQ_NONE;
 	}
 
 	spin_lock_irqsave(&db->lock, flags);
@@ -747,7 +747,7 @@
 	outl(db->cr5_data, ioaddr + DCR5);
 	if ( !(db->cr5_data & 0xc1) ) {
 		spin_unlock_irqrestore(&db->lock, flags);
-		return;
+		return IRQ_HANDLED;
 	}
 
 	/* Disable all interrupt in CR7 to solve the interrupt edge problem */
@@ -760,7 +760,7 @@
 		db->reset_fatal++;
 		db->wait_reset = 1;	/* Need to RESET */
 		spin_unlock_irqrestore(&db->lock, flags);
-		return;
+		return IRQ_HANDLED;
 	}
 
 	 /* Received the coming packet */
@@ -786,6 +786,7 @@
 	outl(db->cr7_data, ioaddr + DCR7);
 
 	spin_unlock_irqrestore(&db->lock, flags);
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/net/tulip/interrupt.c b/drivers/net/tulip/interrupt.c
--- a/drivers/net/tulip/interrupt.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/net/tulip/interrupt.c	Wed Apr 30 22:28:06 2003
@@ -291,7 +291,7 @@
 #endif
 }
 
-static inline void phy_interrupt (struct net_device *dev)
+static inline unsigned int phy_interrupt (struct net_device *dev)
 {
 #ifdef __hppa__
 	int csr12 = inl(dev->base_addr + CSR12) & 0xff;
@@ -307,13 +307,17 @@
 		spin_unlock(&tp->lock);
 		/* clear irq ack bit */
 		outl(csr12 & ~0x02, dev->base_addr + CSR12);
+
+		return 1;
 	}
 #endif
+
+	return 0;
 }
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
-void tulip_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
+irqreturn_t tulip_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *)dev_instance;
 	struct tulip_private *tp = (struct tulip_private *)dev->priv;
@@ -328,15 +332,16 @@
 	int maxtx = TX_RING_SIZE;
 	int maxoi = TX_RING_SIZE;
 	unsigned int work_count = tulip_max_interrupt_work;
+	unsigned int handled = 0;
 
 	/* Let's see whether the interrupt really is for us */
 	csr5 = inl(ioaddr + CSR5);
 
-        if (tp->flags & HAS_PHY_IRQ)
-	        phy_interrupt (dev);
+        if (tp->flags & HAS_PHY_IRQ) 
+	        handled = phy_interrupt (dev);
     
 	if ((csr5 & (NormalIntr|AbnormalIntr)) == 0)
-		return;
+		return IRQ_RETVAL(handled);
 
 	tp->nir++;
 
@@ -578,4 +583,5 @@
 		printk(KERN_DEBUG "%s: exiting interrupt, csr5=%#4.4x.\n",
 			   dev->name, inl(ioaddr + CSR5));
 
+	return IRQ_HANDLED;
 }
diff -Nru a/drivers/net/tulip/tulip.h b/drivers/net/tulip/tulip.h
--- a/drivers/net/tulip/tulip.h	Wed Apr 30 22:28:17 2003
+++ b/drivers/net/tulip/tulip.h	Wed Apr 30 22:28:17 2003
@@ -423,7 +423,7 @@
 /* interrupt.c */
 extern unsigned int tulip_max_interrupt_work;
 extern int tulip_rx_copybreak;
-void tulip_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
+irqreturn_t tulip_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
 int tulip_refill_rx(struct net_device *dev);
 
 /* media.c */
diff -Nru a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
--- a/drivers/net/tulip/winbond-840.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/net/tulip/winbond-840.c	Wed Apr 30 22:28:05 2003
@@ -385,7 +385,7 @@
 static int alloc_ringdesc(struct net_device *dev);
 static void free_ringdesc(struct netdev_private *np);
 static int  start_tx(struct sk_buff *skb, struct net_device *dev);
-static void intr_handler(int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *regs);
 static void netdev_error(struct net_device *dev, int intr_status);
 static int  netdev_rx(struct net_device *dev);
 static u32 __set_rx_mode(struct net_device *dev);
@@ -1165,15 +1165,16 @@
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
-static void intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
+static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
 {
 	struct net_device *dev = (struct net_device *)dev_instance;
 	struct netdev_private *np = dev->priv;
 	long ioaddr = dev->base_addr;
 	int work_limit = max_interrupt_work;
+	int handled = 0;
 
 	if (!netif_device_present(dev))
-		return;
+		return IRQ_NONE;
 	do {
 		u32 intr_status = readl(ioaddr + IntrStatus);
 
@@ -1187,6 +1188,8 @@
 		if ((intr_status & (NormalIntr|AbnormalIntr)) == 0)
 			break;
 
+		handled = 1;
+
 		if (intr_status & (IntrRxDone | RxNoBuf))
 			netdev_rx(dev);
 		if (intr_status & RxNoBuf)
@@ -1222,6 +1225,7 @@
 	if (debug > 3)
 		printk(KERN_DEBUG "%s: exiting interrupt, status=%#4.4x.\n",
 			   dev->name, (int)readl(ioaddr + IntrStatus));
+	return IRQ_RETVAL(handled);
 }
 
 /* This routine is logically part of the interrupt handler, but separated
diff -Nru a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c
--- a/drivers/net/tulip/xircom_cb.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/net/tulip/xircom_cb.c	Wed Apr 30 22:28:15 2003
@@ -111,7 +111,7 @@
 /* Function prototypes */
 static int xircom_probe(struct pci_dev *pdev, const struct pci_device_id *id);
 static void xircom_remove(struct pci_dev *pdev);
-static void xircom_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t xircom_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
 static int xircom_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static int xircom_open(struct net_device *dev);
 static int xircom_close(struct net_device *dev);
@@ -344,7 +344,7 @@
 	leave("xircom_remove");
 } 
 
-static void xircom_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
+static irqreturn_t xircom_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
 {
 	struct net_device *dev = (struct net_device *) dev_instance;
 	struct xircom_private *card = (struct xircom_private *) dev->priv;
@@ -388,6 +388,7 @@
 	
 	spin_unlock(&card->lock);
 	leave("xircom_interrupt");
+	return IRQ_HANDLED;
 }
 
 static int xircom_start_xmit(struct sk_buff *skb, struct net_device *dev)
diff -Nru a/drivers/net/tulip/xircom_tulip_cb.c b/drivers/net/tulip/xircom_tulip_cb.c
--- a/drivers/net/tulip/xircom_tulip_cb.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/net/tulip/xircom_tulip_cb.c	Wed Apr 30 22:28:05 2003
@@ -340,7 +340,7 @@
 static void xircom_init_ring(struct net_device *dev);
 static int xircom_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static int xircom_rx(struct net_device *dev);
-static void xircom_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t xircom_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
 static int xircom_close(struct net_device *dev);
 static struct net_device_stats *xircom_get_stats(struct net_device *dev);
 static int xircom_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
@@ -355,7 +355,7 @@
 	const int strict_bits =
 		TxThresh10 | TxStoreForw | TxThreshMask | EnableTxRx | FullDuplexBit;
     int csr5, csr5_22_20, csr5_19_17, currcsr6, attempts = 200;
-    long flags;
+    unsigned long flags;
     save_flags(flags);
     cli();
 	/* mask out the reserved bits that always read 0 on the Xircom cards */
@@ -1054,12 +1054,13 @@
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
-static void xircom_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
+static irqreturn_t xircom_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_instance;
 	struct xircom_private *tp = dev->priv;
 	long ioaddr = dev->base_addr;
 	int csr5, work_budget = max_interrupt_work;
+	int handled = 0;
 
 	spin_lock (&tp->lock);
 
@@ -1078,6 +1079,8 @@
 		if ((csr5 & (NormalIntr|AbnormalIntr)) == 0)
 			break;
 
+		handled = 1;
+
 		if (csr5 & (RxIntr | RxNoBuf))
 			work_budget -= xircom_rx(dev);
 
@@ -1185,6 +1188,7 @@
 			   dev->name, inl(ioaddr + CSR5));
 
 	spin_unlock (&tp->lock);
+	return IRQ_RETVAL(handled);
 }
 
 
@@ -1461,7 +1465,7 @@
 	struct xircom_private *tp = dev->priv;
 	u16 *data = (u16 *)&rq->ifr_data;
 	int phy = tp->phys[0] & 0x1f;
-	long flags;
+	unsigned long flags;
 
 	switch(cmd) {
 	case SIOCETHTOOL:
diff -Nru a/drivers/net/typhoon.c b/drivers/net/typhoon.c
--- a/drivers/net/typhoon.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/net/typhoon.c	Wed Apr 30 22:28:11 2003
@@ -1790,7 +1790,7 @@
 	return (done ? 0 : 1);
 }
 
-static void
+static irqreturn_t
 typhoon_interrupt(int irq, void *dev_instance, struct pt_regs *rgs)
 {
 	struct net_device *dev = (struct net_device *) dev_instance;
@@ -1799,7 +1799,7 @@
 
 	intr_status = readl(ioaddr + TYPHOON_REG_INTR_STATUS);
 	if(!intr_status)
-		return;
+		return IRQ_NONE;
 
 	writel(intr_status, ioaddr + TYPHOON_REG_INTR_STATUS);
 
@@ -1811,6 +1811,7 @@
 		printk(KERN_ERR "%s: Error, poll already scheduled\n",
                        dev->name);
 	}
+	return IRQ_HANDLED;
 }
 
 static void
@@ -2134,7 +2135,7 @@
 	return 0;
 }
 
-#if CONFIG_PM
+#ifdef CONFIG_PM
 static int
 typhoon_resume(struct pci_dev *pdev)
 {
@@ -2482,7 +2483,7 @@
 	.id_table	= typhoon_pci_tbl,
 	.probe		= typhoon_init_one,
 	.remove		= __devexit_p(typhoon_remove_one),
-#if CONFIG_PM
+#ifdef CONFIG_PM
 	.suspend	= typhoon_suspend,
 	.resume		= typhoon_resume,
 	.enable_wake	= typhoon_enable_wake,
diff -Nru a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
--- a/drivers/net/via-rhine.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/net/via-rhine.c	Wed Apr 30 22:28:18 2003
@@ -530,7 +530,7 @@
 static void via_rhine_timer(unsigned long data);
 static void via_rhine_tx_timeout(struct net_device *dev);
 static int  via_rhine_start_tx(struct sk_buff *skb, struct net_device *dev);
-static void via_rhine_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t via_rhine_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
 static void via_rhine_tx(struct net_device *dev);
 static void via_rhine_rx(struct net_device *dev);
 static void via_rhine_error(struct net_device *dev, int intr_status);
@@ -1330,16 +1330,19 @@
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
-static void via_rhine_interrupt(int irq, void *dev_instance, struct pt_regs *rgs)
+static irqreturn_t via_rhine_interrupt(int irq, void *dev_instance, struct pt_regs *rgs)
 {
 	struct net_device *dev = dev_instance;
 	long ioaddr;
 	u32 intr_status;
 	int boguscnt = max_interrupt_work;
+	int handled = 0;
 
 	ioaddr = dev->base_addr;
 	
 	while ((intr_status = get_intr_status(dev))) {
+		handled = 1;
+
 		/* Acknowledge all of the current interrupt sources ASAP. */
 		if (intr_status & IntrTxDescRace)
 			writeb(0x08, ioaddr + IntrStatus2);
@@ -1385,6 +1388,7 @@
 	if (debug > 3)
 		printk(KERN_DEBUG "%s: exiting interrupt, status=%8.8x.\n",
 			   dev->name, readw(ioaddr + IntrStatus));
+	return IRQ_RETVAL(handled);
 }
 
 /* This routine is logically part of the interrupt handler, but isolated
@@ -1690,6 +1694,8 @@
 		/* Unconditionally log net taps. */
 		printk(KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name);
 		rx_mode = 0x1C;
+		writel(0xffffffff, ioaddr + MulticastFilter0);
+		writel(0xffffffff, ioaddr + MulticastFilter1);
 	} else if ((dev->mc_count > multicast_filter_limit)
 			   ||  (dev->flags & IFF_ALLMULTI)) {
 		/* Too many to match, or accept all multicasts. */
diff -Nru a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
--- a/drivers/net/wan/Kconfig	Wed Apr 30 22:28:06 2003
+++ b/drivers/net/wan/Kconfig	Wed Apr 30 22:28:06 2003
@@ -255,8 +255,8 @@
 
  	  If you want to compile the driver as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
-	  say M here and read Documentation/modules.txt.  The module
-	  will be called hdlc.o.
+	  say M here and read <file:Documentation/modules.txt>.  The module
+	  will be called hdlc.
 
 	  If unsure, say N here.
 
@@ -363,7 +363,7 @@
 	  If you want to compile the driver as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
 	  say M here and read <file:Documentation/modules.txt>.  The module
-	  will be called n2.o.
+	  will be called n2.
 
 	  If unsure, say N here.
 
@@ -378,7 +378,7 @@
 	  If you want to compile the driver as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
 	  say M here and read <file:Documentation/modules.txt>.  The module
-	  will be called c101.o.
+	  will be called c101.
 
 	  If unsure, say N here.
 
diff -Nru a/drivers/net/wan/c101.c b/drivers/net/wan/c101.c
--- a/drivers/net/wan/c101.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/net/wan/c101.c	Wed Apr 30 22:28:14 2003
@@ -155,15 +155,11 @@
 {
 	hdlc_device *hdlc = dev_to_hdlc(dev);
 	port_t *port = hdlc_to_port(hdlc);
+	int result;
 
-	if (!try_module_get(THIS_MODULE))
-		return -EFAULT;	/* rmmod in progress */
-
-	int result = hdlc_open(hdlc);
-	if (result) {
+	result = hdlc_open(hdlc);
+	if (result)
 		return result;
-		module_put(THIS_MODULE);
-	}
 
 	writeb(1, port->win0base + C101_DTR);
 	sca_out(0, MSCI1_OFFSET + CTL, port); /* RTS uses ch#2 output */
@@ -182,7 +178,6 @@
 	writeb(0, port->win0base + C101_DTR);
 	sca_out(CTL_NORTS, MSCI1_OFFSET + CTL, port);
 	hdlc_close(hdlc);
-	module_put(THIS_MODULE);
 	return 0;
 }
 
@@ -318,6 +313,7 @@
 	dev = hdlc_to_dev(&card->hdlc);
 
 	spin_lock_init(&card->lock);
+	SET_MODULE_OWNER(dev);
 	dev->irq = irq;
 	dev->mem_start = winbase;
 	dev->mem_end = winbase + C101_MAPPED_RAM_SIZE - 1;
diff -Nru a/drivers/net/wan/comx-hw-comx.c b/drivers/net/wan/comx-hw-comx.c
--- a/drivers/net/wan/comx-hw-comx.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/net/wan/comx-hw-comx.c	Wed Apr 30 22:28:04 2003
@@ -96,7 +96,7 @@
 extern struct comx_hardware comx_hw;
 extern struct comx_hardware cmx_hw;
 
-static void COMX_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t COMX_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 static void COMX_board_on(struct net_device *dev)
 {
@@ -335,7 +335,7 @@
 
 
 
-static void COMX_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t COMX_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
 	struct comx_channel *ch = dev->priv;
@@ -348,7 +348,7 @@
 
 	if (dev == NULL) {
 		printk(KERN_ERR "COMX_interrupt: irq %d for unknown device\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	jiffs = jiffies;
@@ -445,6 +445,7 @@
 	}
 
 	ch->HW_release_board(dev, interrupted);
+	return IRQ_HANDLED;
 }
 
 static int COMX_open(struct net_device *dev)
diff -Nru a/drivers/net/wan/comx-hw-mixcom.c b/drivers/net/wan/comx-hw-mixcom.c
--- a/drivers/net/wan/comx-hw-mixcom.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/net/wan/comx-hw-mixcom.c	Wed Apr 30 22:28:18 2003
@@ -412,7 +412,7 @@
 }
 
 
-static void MIXCOM_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t MIXCOM_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	unsigned long flags;
 	struct net_device *dev = (struct net_device *)dev_id;
@@ -422,7 +422,7 @@
 
 	if (dev==NULL) {
 		printk(KERN_ERR "comx_interrupt: irq %d for unknown device\n",irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	ch = dev->priv; 
@@ -480,7 +480,7 @@
 	}
 
 	restore_flags(flags);
-	return;
+	return IRQ_HANDLED;
 }
 
 static int MIXCOM_open(struct net_device *dev)
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	Wed Apr 30 22:28:06 2003
+++ b/drivers/net/wan/comx-hw-munich.c	Wed Apr 30 22:28:06 2003
@@ -1029,7 +1029,7 @@
  * Called by the Linux kernel.
  * BEWARE! The interrupts are enabled on the call!
  */
-static void MUNICH_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t MUNICH_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
     struct sk_buff *skb;
     int length;
@@ -1386,7 +1386,7 @@
 	board->stat_pri_races_missed++;
     if (race_stat & STAT_PTI)
 	board->stat_pti_races_missed++;
-    return;
+    return IRQ_HANDLED;
 }
 
 /* 
diff -Nru a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
--- a/drivers/net/wan/cosa.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/wan/cosa.c	Wed Apr 30 22:28:03 2003
@@ -343,7 +343,7 @@
 static void put_driver_status_nolock(struct cosa_data *cosa);
 
 /* Interrupt handling */
-static void cosa_interrupt(int irq, void *cosa, struct pt_regs *regs);
+static irqreturn_t cosa_interrupt(int irq, void *cosa, struct pt_regs *regs);
 
 /* I/O ops debugging */
 #ifdef DEBUG_IO
@@ -1983,7 +1983,7 @@
 	spin_unlock_irqrestore(&cosa->lock, flags);
 }
 
-static void cosa_interrupt(int irq, void *cosa_, struct pt_regs *regs)
+static irqreturn_t cosa_interrupt(int irq, void *cosa_, struct pt_regs *regs)
 {
 	unsigned status;
 	int count = 0;
@@ -2023,6 +2023,7 @@
 	else
 		printk(KERN_INFO "%s: returning from IRQ\n", cosa->name);
 #endif
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/net/wan/cycx_main.c b/drivers/net/wan/cycx_main.c
--- a/drivers/net/wan/cycx_main.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/net/wan/cycx_main.c	Wed Apr 30 22:28:09 2003
@@ -75,7 +75,7 @@
 static int ioctl (wan_device_t *wandev, unsigned cmd, unsigned long arg);
 
 /* Miscellaneous functions */
-static void cycx_isr (int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t cycx_isr (int irq, void *dev_id, struct pt_regs *regs);
 
 /* Global Data
  * Note: All data must be explicitly initialized!!!
@@ -316,7 +316,7 @@
  * o acknowledge Cyclom 2X hardware interrupt.
  * o call protocol-specific interrupt service routine, if any.
  */
-static void cycx_isr (int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t cycx_isr (int irq, void *dev_id, struct pt_regs *regs)
 {
 	cycx_t *card = (cycx_t *)dev_id;
 
@@ -331,7 +331,8 @@
 
 	if (card->isr)
 		card->isr(card);
-out:	return;
+	return IRQ_HANDLED;
+out:	return IRQ_NONE;
 }
 
 /*
diff -Nru a/drivers/net/wan/cycx_x25.c b/drivers/net/wan/cycx_x25.c
--- a/drivers/net/wan/cycx_x25.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/net/wan/cycx_x25.c	Wed Apr 30 22:28:05 2003
@@ -1347,7 +1347,7 @@
 {
 	x25_channel_t *chan = dev->priv;
 	cycx_t *card = chan->card;
-	long flags;
+	unsigned long flags;
 	char *string_state = NULL;
 
 	spin_lock_irqsave(&card->lock, flags);
diff -Nru a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
--- a/drivers/net/wan/dscc4.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/net/wan/dscc4.c	Wed Apr 30 22:28:06 2003
@@ -337,7 +337,7 @@
 static void dscc4_release_ring(struct dscc4_dev_priv *);
 static void dscc4_timer(unsigned long);
 static void dscc4_tx_timeout(struct net_device *);
-static void dscc4_irq(int irq, void *dev_id, struct pt_regs *ptregs);
+static irqreturn_t dscc4_irq(int irq, void *dev_id, struct pt_regs *ptregs);
 static int dscc4_hdlc_attach(hdlc_device *, unsigned short, unsigned short);
 static int dscc4_set_iface(struct dscc4_dev_priv *, struct net_device *);
 static inline int dscc4_set_quartz(struct dscc4_dev_priv *, int);
@@ -1315,14 +1315,14 @@
 	return ret;
 }
 
-static void dscc4_irq(int irq, void *token, struct pt_regs *ptregs)
+static irqreturn_t dscc4_irq(int irq, void *token, struct pt_regs *ptregs)
 {
 	struct dscc4_dev_priv *root = token;
 	struct dscc4_pci_priv *priv;
 	struct net_device *dev;
 	u32 ioaddr, state;
 	unsigned long flags;
-	int i;
+	int i, handled = 1;
 
 	priv = root->pci_priv;
 	dev = hdlc_to_dev(&root->hdlc);
@@ -1332,8 +1332,10 @@
 	ioaddr = dev->base_addr;
 
 	state = readl(ioaddr + GSTAR);
-	if (!state)
+	if (!state) {
+		handled = 0;
 		goto out;
+	}
 	writel(state, ioaddr + GSTAR);
 
 	if (state & Arf) {
@@ -1366,6 +1368,7 @@
 	}
 out:
 	spin_unlock_irqrestore(&priv->lock, flags);
+	return IRQ_RETVAL(handled);
 }
 
 static inline void dscc4_tx_irq(struct dscc4_pci_priv *ppriv,
diff -Nru a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
--- a/drivers/net/wan/farsync.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/net/wan/farsync.c	Wed Apr 30 22:28:12 2003
@@ -614,7 +614,7 @@
 
 /*      Control signal change interrupt event
  */
-static void
+static irqreturn_t
 fst_intr_ctlchg ( struct fst_card_info *card, struct fst_port_info *port )
 {
         int signals;
@@ -637,6 +637,7 @@
                         netif_carrier_off ( port_to_dev ( port ));
                 }
         }
+	return IRQ_HANDLED;
 }
 
 
@@ -772,7 +773,7 @@
  *      The interrupt service routine
  *      Dev_id is our fst_card_info pointer
  */
-static void
+static irqreturn_t
 fst_intr ( int irq, void *dev_id, struct pt_regs *regs )
 {
         struct fst_card_info *card;
@@ -785,7 +786,7 @@
         if (( card = dev_id ) == NULL )
         {
                 dbg ( DBG_INTR,"intr: spurious %d\n", irq );
-                return;
+                return IRQ_NONE;
         }
 
         dbg ( DBG_INTR,"intr: %d %p\n", irq, card );
@@ -882,6 +883,7 @@
         }
 
         spin_unlock ( &card->card_lock );
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/net/wan/hd6457x.c b/drivers/net/wan/hd6457x.c
--- a/drivers/net/wan/hd6457x.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/net/wan/hd6457x.c	Wed Apr 30 22:28:05 2003
@@ -408,17 +408,19 @@
 
 
 
-static void sca_intr(int irq, void* dev_id, struct pt_regs *regs)
+static irqreturn_t sca_intr(int irq, void* dev_id, struct pt_regs *regs)
 {
 	card_t *card = dev_id;
 	int i;
 	u8 stat;
+	int handled = 0;
 
 #ifndef ALL_PAGES_ALWAYS_MAPPED
 	u8 page = sca_get_page(card);
 #endif
 
 	while((stat = sca_intr_status(card)) != 0) {
+		handled = 1;
 		for (i = 0; i < 2; i++) {
 			port_t *port = get_port(card, i);
 			if (port) {
@@ -437,6 +439,7 @@
 #ifndef ALL_PAGES_ALWAYS_MAPPED
 	openwin(card, page);		/* Restore original page */
 #endif
+	return IRQ_RETVAL(handled);
 }
 
 
diff -Nru a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c
--- a/drivers/net/wan/n2.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/net/wan/n2.c	Wed Apr 30 22:28:05 2003
@@ -216,16 +216,11 @@
 	port_t *port = hdlc_to_port(hdlc);
 	int io = port->card->io;
 	u8 mcr = inb(io + N2_MCR) | (port->phy_node ? TX422_PORT1:TX422_PORT0);
+	int result;
 
-
-	if (!try_module_get(THIS_MODULE))
-		return -EFAULT;	/* rmmod in progress */
-
-	int result = hdlc_open(hdlc);
-	if (result) {
+	result = hdlc_open(hdlc);
+	if (result)
 		return result;
-		module_put(THIS_MODULE);
-	}
 
 	mcr &= port->phy_node ? ~DTR_PORT1 : ~DTR_PORT0; /* set DTR ON */
 	outb(mcr, io + N2_MCR);
@@ -250,7 +245,6 @@
 	mcr |= port->phy_node ? DTR_PORT1 : DTR_PORT0; /* set DTR OFF */
 	outb(mcr, io + N2_MCR);
 	hdlc_close(hdlc);
-	module_put(THIS_MODULE);
 	return 0;
 }
 
@@ -450,6 +444,7 @@
 			port->log_node = 1;
 
 		spin_lock_init(&port->lock);
+		SET_MODULE_OWNER(dev);
 		dev->irq = irq;
 		dev->mem_start = winbase;
 		dev->mem_end = winbase + USE_WINDOWSIZE-1;
diff -Nru a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
--- a/drivers/net/wan/pc300_drv.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/net/wan/pc300_drv.c	Wed Apr 30 22:28:17 2003
@@ -285,7 +285,7 @@
 static void rx_dma_buf_init(pc300_t *, int);
 static void tx_dma_buf_check(pc300_t *, int);
 static void rx_dma_buf_check(pc300_t *, int);
-static void cpc_intr(int, void *, struct pt_regs *);
+static irqreturn_t cpc_intr(int, void *, struct pt_regs *);
 static struct net_device_stats *cpc_get_stats(struct net_device *);
 static int clock_rate_calc(uclong, uclong, int *);
 static uclong detect_ram(pc300_t *);
@@ -2366,7 +2366,7 @@
 	}
 }
 
-static void cpc_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t cpc_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	pc300_t *card;
 	volatile ucchar plx_status;
@@ -2375,14 +2375,14 @@
 #ifdef PC300_DEBUG_INTR
 		printk("cpc_intr: spurious intr %d\n", irq);
 #endif
-		return;		/* spurious intr */
+		return IRQ_NONE;		/* spurious intr */
 	}
 
 	if (card->hw.rambase == 0) {
 #ifdef PC300_DEBUG_INTR
 		printk("cpc_intr: spurious intr2 %d\n", irq);
 #endif
-		return;		/* spurious intr */
+		return IRQ_NONE;		/* spurious intr */
 	}
 
 	switch (card->hw.type) {
@@ -2403,6 +2403,7 @@
 			}
 			break;
 	}
+	return IRQ_HANDLED;
 }
 
 void cpc_sca_status(pc300_t * card, int ch)
diff -Nru a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c
--- a/drivers/net/wan/pc300_tty.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/net/wan/pc300_tty.c	Wed Apr 30 22:28:08 2003
@@ -318,18 +318,18 @@
 		return -ENODEV;
 	} 
 
-	port = minor(tty->device) - tty->driver.minor_start; 
+	port = tty->index;
 
 	if ((port < 0) || (port >= CPC_TTY_NPORTS)){ 
-		CPC_TTY_DBG("pc300_tty: open invalid minor %i\n",MINOR(tty->device));
+		CPC_TTY_DBG("pc300_tty: open invalid port %d\n", port);
 		return -ENODEV;
 	} 
 
 	cpc_tty = &cpc_tty_area[port];
 	
 	if (cpc_tty->state == CPC_TTY_ST_IDLE){
-		CPC_TTY_DBG("%s: open - invalid interface, minor=%i\n",
-					cpc_tty->name, MINOR(tty->device));
+		CPC_TTY_DBG("%s: open - invalid interface, port=%d\n",
+					cpc_tty->name, tty->index);
 		return -ENODEV;
 	}
 
diff -Nru a/drivers/net/wan/sbni.c b/drivers/net/wan/sbni.c
--- a/drivers/net/wan/sbni.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/net/wan/sbni.c	Wed Apr 30 22:28:07 2003
@@ -119,7 +119,7 @@
 static struct net_device_stats  *sbni_get_stats( struct net_device * );
 static void  set_multicast_list( struct net_device * );
 
-static void  sbni_interrupt( int, void *, struct pt_regs * );
+static irqreturn_t sbni_interrupt( int, void *, struct pt_regs * );
 static void  handle_channel( struct net_device * );
 static int   recv_frame( struct net_device * );
 static void  send_frame( struct net_device * );
@@ -469,7 +469,7 @@
  * this board to be "master".
  */ 
 
-static void
+static irqreturn_t
 sbni_interrupt( int  irq,  void  *dev_id,  struct pt_regs  *regs )
 {
 	struct net_device	  *dev = (struct net_device *) dev_id;
@@ -494,6 +494,7 @@
 	if( nl->second )
 		spin_unlock( &((struct net_local *)nl->second->priv)->lock );
 	spin_unlock( &nl->lock );
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/net/wan/sdla.c b/drivers/net/wan/sdla.c
--- a/drivers/net/wan/sdla.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/net/wan/sdla.c	Wed Apr 30 22:28:20 2003
@@ -856,7 +856,7 @@
 	restore_flags(flags);
 }
 
-static void sdla_isr(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t sdla_isr(int irq, void *dev_id, struct pt_regs * regs)
 {
 	struct net_device     *dev;
 	struct frad_local *flp;
@@ -867,7 +867,7 @@
 	if (dev == NULL)
 	{
 		printk(KERN_WARNING "sdla_isr(): irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	flp = dev->priv;
@@ -875,7 +875,7 @@
 	if (!flp->initialized)
 	{
 		printk(KERN_WARNING "%s: irq %d for uninitialized device.\n", dev->name, irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	byte = sdla_byte(dev, flp->type == SDLA_S508 ? SDLA_508_IRQ_INTERFACE : SDLA_502_IRQ_INTERFACE);
@@ -910,6 +910,7 @@
 	/* this clears the byte, informing the Z80 we're done */
 	byte = 0;
 	sdla_write(dev, flp->type == SDLA_S508 ? SDLA_508_IRQ_INTERFACE : SDLA_502_IRQ_INTERFACE, &byte, sizeof(byte));
+	return IRQ_HANDLED;
 }
 
 static void sdla_poll(unsigned long device)
diff -Nru a/drivers/net/wan/sdla_chdlc.c b/drivers/net/wan/sdla_chdlc.c
--- a/drivers/net/wan/sdla_chdlc.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/net/wan/sdla_chdlc.c	Wed Apr 30 22:28:09 2003
@@ -3698,7 +3698,7 @@
 	
 	if (!tty->driver_data){
 		int port;
-		port = minor(tty->device) - tty->driver.minor_start;
+		port = tty->index;
 		if ((port < 0) || (port >= NR_PORTS)) 
 			return -ENODEV;
 		
diff -Nru a/drivers/net/wan/sdlamain.c b/drivers/net/wan/sdlamain.c
--- a/drivers/net/wan/sdlamain.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/net/wan/sdlamain.c	Wed Apr 30 22:28:13 2003
@@ -193,7 +193,7 @@
 static int ioctl_exec	(sdla_t* card, sdla_exec_t* u_exec, int);
 
 /* Miscellaneous functions */
-STATIC void sdla_isr	(int irq, void* dev_id, struct pt_regs *regs);
+STATIC irqreturn_t sdla_isr	(int irq, void* dev_id, struct pt_regs *regs);
 static void release_hw  (sdla_t *card);
 static void run_wanpipe_tq (unsigned long);
 
@@ -1034,9 +1034,10 @@
  * o acknowledge SDLA hardware interrupt.
  * o call protocol-specific interrupt service routine, if any.
  */
-STATIC void sdla_isr (int irq, void* dev_id, struct pt_regs *regs)
+STATIC irqreturn_t sdla_isr (int irq, void* dev_id, struct pt_regs *regs)
 {
 #define	card	((sdla_t*)dev_id)
+	int handled = 0;
 
 	if(card->hw.type == SDLA_S514) {	/* handle interrrupt on S514 */
                 u32 int_status;
@@ -1051,7 +1052,7 @@
 			/* check if the interrupt is for this device */
  			if(!((unsigned char)int_status &
 				(IRQ_CPU_A | IRQ_CPU_B)))
-                	        return;
+                	        return IRQ_HANDLED;
 
 			/* if the IRQ is for both CPUs on the same adapter, */
 			/* then alter the interrupt status so as to handle */
@@ -1083,7 +1084,7 @@
 			/* exit if the interrupt is for another CPU on the */
 			/* same IRQ */
 			if(!card_found_for_IRQ)
-				return;
+				return IRQ_HANDLED;
 
        	 		if (!card || 
 			   (card->wandev.state == WAN_UNCONFIGURED && !card->configured)){
@@ -1093,7 +1094,7 @@
 					printk(KERN_INFO
 						"IRQ for unconfigured adapter\n");
 					S514_intack(&card->hw, int_status);
-					return;
+					return IRQ_HANDLED;
        			}
 
 	        	if (card->in_isr) {
@@ -1101,7 +1102,7 @@
 					"%s: interrupt re-entrancy on IRQ %d\n",
                        			card->devname, card->wandev.irq);
 				S514_intack(&card->hw, int_status);
- 				return;
+ 				return IRQ_HANDLED;
        			}
 
 			spin_lock(&card->wandev.lock);
@@ -1121,20 +1122,20 @@
 			/* handle a maximum of two interrupts (one for each */
 			/* CPU on the adapter) before returning */  
 			if((++ IRQ_count) == 2)
-				return;
+				return IRQ_HANDLED;
 		}
 	}
 
 	else {			/* handle interrupt on S508 adapter */
 
 		if (!card || ((card->wandev.state == WAN_UNCONFIGURED) && !card->configured))
-			return;
+			return IRQ_HANDLED;
 
 		if (card->in_isr) {
 			printk(KERN_INFO
 				"%s: interrupt re-entrancy on IRQ %d!\n",
 				card->devname, card->wandev.irq);
-			return;
+			return IRQ_HANDLED;
 		}
 
 		spin_lock(&card->wandev.lock);
@@ -1152,7 +1153,7 @@
 		spin_unlock(&card->wandev.lock);
 
 	}
-                
+        return IRQ_HANDLED;
 #undef	card
 }
 
diff -Nru a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
--- a/drivers/net/wan/x25_asy.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/net/wan/x25_asy.c	Wed Apr 30 22:28:05 2003
@@ -288,7 +288,7 @@
 	 *       14 Oct 1994  Dmitry Gorodchanin.
 	 */
 	sl->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
-	actual = sl->tty->driver.write(sl->tty, 0, sl->xbuff, count);
+	actual = sl->tty->driver->write(sl->tty, 0, sl->xbuff, count);
 	sl->xleft = count - actual;
 	sl->xhead = sl->xbuff + actual;
 	/* VSV */
@@ -318,7 +318,7 @@
 		return;
 	}
 
-	actual = tty->driver.write(tty, 0, sl->xhead, sl->xleft);
+	actual = tty->driver->write(tty, 0, sl->xhead, sl->xleft);
 	sl->xleft -= actual;
 	sl->xhead += actual;
 }
@@ -330,7 +330,7 @@
 	 *      14 Oct 1994 Dmitry Gorodchanin.
 	 */
 	printk(KERN_WARNING "%s: transmit timed out, %s?\n", dev->name,
-	       (sl->tty->driver.chars_in_buffer(sl->tty) || sl->xleft) ?
+	       (sl->tty->driver->chars_in_buffer(sl->tty) || sl->xleft) ?
 	       "bad line quality" : "driver error");
 	sl->xleft = 0;
 	sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
@@ -620,8 +620,8 @@
 
 	sl->tty = tty;
 	tty->disc_data = sl;
-	if (tty->driver.flush_buffer)  {
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)  {
+		tty->driver->flush_buffer(tty);
 	}
 	if (tty->ldisc.flush_buffer)  {
 		tty->ldisc.flush_buffer(tty);
diff -Nru a/drivers/net/wan/z85230.c b/drivers/net/wan/z85230.c
--- a/drivers/net/wan/z85230.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/wan/z85230.c	Wed Apr 30 22:28:03 2003
@@ -718,7 +718,7 @@
  *	channel). c->lock for both channels points to dev->lock
  */
 
-void z8530_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t z8530_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct z8530_dev *dev=dev_id;
 	u8 intr;
@@ -729,7 +729,7 @@
 	if(locker)
 	{
 		printk(KERN_ERR "IRQ re-enter\n");
-		return;
+		return IRQ_NONE;
 	}
 	locker=1;
 
@@ -775,6 +775,7 @@
 		printk(KERN_ERR "%s: interrupt jammed - abort(0x%X)!\n", dev->name, intr);
 	/* Ok all done */
 	locker=0;
+	return IRQ_HANDLED;
 }
 
 EXPORT_SYMBOL(z8530_interrupt);
diff -Nru a/drivers/net/wan/z85230.h b/drivers/net/wan/z85230.h
--- a/drivers/net/wan/z85230.h	Wed Apr 30 22:28:13 2003
+++ b/drivers/net/wan/z85230.h	Wed Apr 30 22:28:13 2003
@@ -9,6 +9,7 @@
 #define _Z8530_H
 
 #include <linux/tty.h>
+#include <linux/interrupt.h>
 
 /* Conversion routines to/from brg time constants from/to bits
  * per second.
@@ -399,7 +400,7 @@
 extern u8 z8530_dead_port[];
 extern u8 z8530_hdlc_kilostream_85230[];
 extern u8 z8530_hdlc_kilostream[];
-extern void z8530_interrupt(int, void *, struct pt_regs *);
+extern irqreturn_t z8530_interrupt(int, void *, struct pt_regs *);
 extern void z8530_describe(struct z8530_dev *, char *mapping, unsigned long io);
 extern int z8530_init(struct z8530_dev *);
 extern int z8530_shutdown(struct z8530_dev *);
diff -Nru a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
--- a/drivers/net/wireless/Kconfig	Wed Apr 30 22:28:06 2003
+++ b/drivers/net/wireless/Kconfig	Wed Apr 30 22:28:06 2003
@@ -88,7 +88,7 @@
 
 	  If you want to use an ISA WaveLAN card under Linux, say Y and read
 	  the Ethernet-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. Some more specific
+	  <http://www.tldp.org/docs.html#howto>. Some more specific
 	  information is contained in
 	  <file:Documentation/networking/wavelan.txt> and in the source code
 	  <file:drivers/net/wavelan.p.h>.
@@ -240,7 +240,7 @@
 	  To use your PC-cards, you will need supporting software from David
 	  Hinds' pcmcia-cs package (see the file <file:Documentation/Changes>
 	  for location).  You also want to check out the PCMCIA-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>.
+	  available from <http://www.tldp.org/docs.html#howto>.
 
 	  You will also very likely also need the Wireless Tools in order to
 	  configure your card and that /etc/pcmcia/wireless.opts works:
@@ -266,7 +266,7 @@
 	  To use your PC-cards, you will need supporting software from David
 	  Hinds' pcmcia-cs package (see the file <file:Documentation/Changes>
 	  for location).  You also want to check out the PCMCIA-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>.
+	  available from <http://www.tldp.org/docs.html#howto>.
 
 # yes, this works even when no drivers are selected
 config NET_WIRELESS
diff -Nru a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
--- a/drivers/net/wireless/airo.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/net/wireless/airo.c	Wed Apr 30 22:28:04 2003
@@ -947,7 +947,7 @@
 static int transmit_802_3_packet(struct airo_info*, int len, char *pPacket);
 static int transmit_802_11_packet(struct airo_info*, int len, char *pPacket);
 
-static void airo_interrupt( int irq, void* dev_id, struct pt_regs
+static irqreturn_t airo_interrupt( int irq, void* dev_id, struct pt_regs
 			    *regs);
 static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 #ifdef WIRELESS_EXT
@@ -1837,20 +1837,23 @@
 	}
 }
 
-static void airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs) {
+static irqreturn_t airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs) {
 	struct net_device *dev = (struct net_device *)dev_id;
 	u16 status;
 	u16 fid;
 	struct airo_info *apriv = dev->priv;
 	u16 savedInterrupts = 0;
+	int handled = 0;
 
 	if (!netif_device_present(dev))
-		return;
+		return IRQ_NONE;
 
 	for (;;) {
 		status = IN4500( apriv, EVSTAT );
 		if ( !(status & STATUS_INTS) || status == 0xffff ) break;
 
+		handled = 1;
+
 		if ( status & EV_AWAKE ) {
 			OUT4500( apriv, EVACK, EV_AWAKE );
 			OUT4500( apriv, EVACK, EV_AWAKE );
@@ -2133,7 +2136,7 @@
 		OUT4500( apriv, EVINTEN, savedInterrupts );
 
 	/* done.. */
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 /*
@@ -2494,7 +2497,7 @@
 	u16 next;
 	int words;
 	int i;
-	long flags;
+	unsigned long flags;
 
 	spin_lock_irqsave(&ai->aux_lock, flags);
 	page = IN4500(ai, SWS0+whichbap);
@@ -3155,7 +3158,7 @@
 	readStatsRid(apriv, &stats, rid);
 
         j = 0;
-	for(i=0; (int)statsLabels[i]!=-1 &&
+	for(i=0; statsLabels[i]!=(char *)-1 &&
 		    i*4<stats.len; i++){
 		if (!statsLabels[i]) continue;
 		if (j+strlen(statsLabels[i])+16>4096) {
diff -Nru a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
--- a/drivers/net/wireless/airo_cs.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/net/wireless/airo_cs.c	Wed Apr 30 22:28:15 2003
@@ -161,14 +161,6 @@
 	struct net_device *eth_dev;
 } local_info_t;
 
-/*====================================================================*/
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-	error_info_t err = { func, ret };
-	CardServices(ReportError, handle, &err);
-}
-
 /*======================================================================
   
   This bit of code is used to avoid unregistering network devices
diff -Nru a/drivers/net/wireless/arlan.c b/drivers/net/wireless/arlan.c
--- a/drivers/net/wireless/arlan.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/net/wireless/arlan.c	Wed Apr 30 22:28:11 2003
@@ -113,7 +113,7 @@
 static  int 	arlan_probe_here(struct net_device *dev, int ioaddr);
 static  int 	arlan_open(struct net_device *dev);
 static  int 	arlan_tx(struct sk_buff *skb, struct net_device *dev);
-static  void 	arlan_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static  irqreturn_t arlan_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static  int 	arlan_close(struct net_device *dev);
 static  struct net_device_stats *
 		arlan_statistics		(struct net_device *dev);
@@ -1840,7 +1840,7 @@
 	return;
 }
 
-static void arlan_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t arlan_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
 	struct arlan_private *priv = (struct arlan_private *) dev->priv;
@@ -1859,7 +1859,7 @@
 	priv->irq_test_done = 1;
 
 	ARLAN_DEBUG_EXIT("arlan_interrupt");
-	return;
+	return IRQ_HANDLED;
 
 }
 
diff -Nru a/drivers/net/wireless/arlan.h b/drivers/net/wireless/arlan.h
--- a/drivers/net/wireless/arlan.h	Wed Apr 30 22:28:10 2003
+++ b/drivers/net/wireless/arlan.h	Wed Apr 30 22:28:10 2003
@@ -376,7 +376,7 @@
       volatile int txNew;
       volatile int txOffset;
       volatile char ReTransmitRequested;
-      volatile long long tx_done_delayed;
+      volatile unsigned long tx_done_delayed;
       volatile long long registrationLastSeen;
       volatile char under_command;
       volatile char under_toggle;
diff -Nru a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
--- a/drivers/net/wireless/netwave_cs.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/net/wireless/netwave_cs.c	Wed Apr 30 22:28:18 2003
@@ -353,14 +353,6 @@
     return readw(staddr);
 }
 
-/**************************************************************************/
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
 /* 
  * Wait until the WOC (Write Operation Complete) bit in the 
  * ASR (Adapter Status Register) is asserted. 
@@ -495,6 +487,7 @@
     spin_lock_init(&priv->spinlock);
 
     /* Netwave specific entries in the device structure */
+    SET_MODULE_OWNER(dev);
     dev->hard_start_xmit = &netwave_start_xmit;
     dev->set_config = &netwave_config;
     dev->get_stats  = &netwave_get_stats;
@@ -1727,7 +1720,6 @@
 	return -ENODEV;
 
     link->open++;
-    MOD_INC_USE_COUNT;
 
     netif_start_queue(dev);
     netwave_reset(dev);
@@ -1746,7 +1738,6 @@
     if (link->state & DEV_STALE_CONFIG)
 	mod_timer(&link->release, jiffies + HZ/20);
 	
-    MOD_DEC_USE_COUNT;
     return 0;
 }
 
diff -Nru a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
--- a/drivers/net/wireless/orinoco.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/net/wireless/orinoco.c	Wed Apr 30 22:28:20 2003
@@ -1337,7 +1337,7 @@
 /*
  * Interrupt handler
  */
-void orinoco_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t orinoco_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct orinoco_private *priv = (struct orinoco_private *) dev_id;
 	hermes_t *hw = &priv->hw;
@@ -1353,7 +1353,7 @@
 
 	if (orinoco_lock(priv, &flags) != 0) {
 		/* If hw is unavailable */
-		return;
+		return IRQ_NONE;
 	}
 
 	evstat = hermes_read_regn(hw, EVSTAT);
@@ -1403,6 +1403,8 @@
 	};
 
 	orinoco_unlock(priv, &flags);
+
+	return IRQ_HANDLED;
 }
 
 static void __orinoco_ev_tick(struct orinoco_private *priv, hermes_t *hw)
diff -Nru a/drivers/net/wireless/orinoco.h b/drivers/net/wireless/orinoco.h
--- a/drivers/net/wireless/orinoco.h	Wed Apr 30 22:28:07 2003
+++ b/drivers/net/wireless/orinoco.h	Wed Apr 30 22:28:07 2003
@@ -114,7 +114,7 @@
 
 extern int orinoco_proc_dev_init(struct net_device *dev);
 extern void orinoco_proc_dev_cleanup(struct net_device *dev);
-extern void orinoco_interrupt(int irq, void * dev_id, struct pt_regs *regs);
+extern irqreturn_t orinoco_interrupt(int irq, void * dev_id, struct pt_regs *regs);
 
 /********************************************************************/
 /* Locking and synchronization functions                            */
diff -Nru a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
--- a/drivers/net/wireless/orinoco_cs.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/net/wireless/orinoco_cs.c	Wed Apr 30 22:28:16 2003
@@ -35,7 +35,6 @@
 #include <pcmcia/cistpl.h>
 #include <pcmcia/cisreg.h>
 #include <pcmcia/ds.h>
-#include <pcmcia/bus_ops.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -144,14 +143,6 @@
 /********************************************************************/
 /* PCMCIA stuff     						    */
 /********************************************************************/
-
-static void
-cs_error(client_handle_t handle, int func, int ret)
-{
-	error_info_t err = { func, ret };
-	CardServices(ReportError, handle, &err);
-}
-
 
 /* Remove zombie instances (card removed, detach pending) */
 static void
diff -Nru a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
--- a/drivers/net/wireless/ray_cs.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/net/wireless/ray_cs.c	Wed Apr 30 22:28:08 2003
@@ -314,12 +314,6 @@
 
 static char rcsid[] = "Raylink/WebGear wireless LAN - Corey <Thomas corey@world.std.com>";
 
-/*===========================================================================*/
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    pcmcia_report_error(handle, &err);
-}
 /*======================================================================
 
     This bit of code is used to avoid unregistering network devices
@@ -423,6 +417,7 @@
     dev->set_multicast_list = &set_multicast_list;
 
     DEBUG(2,"ray_cs ray_attach calling ether_setup.)\n");
+    SET_MODULE_OWNER(dev);
     ether_setup(dev);
     dev->init = &ray_dev_init;
     dev->open = &ray_open;
@@ -1724,14 +1719,11 @@
     dev_link_t *link;
     ray_dev_t *local = (ray_dev_t *)dev->priv;
     
-    MOD_INC_USE_COUNT;
-
     DEBUG(1, "ray_open('%s')\n", dev->name);
 
     for (link = dev_list; link; link = link->next)
         if (link->priv == dev) break;
     if (!DEV_OK(link)) {
-        MOD_DEC_USE_COUNT;
         return -ENODEV;
     }
 
@@ -1780,8 +1772,6 @@
      * and set local->card_status to CARD_AWAITING_PARAM, so that while the
      * card is closed we can chage its configuration.
      * Probably also need a COR reset to get sane state - Jean II */
-
-    MOD_DEC_USE_COUNT;
 
     return 0;
 } /* end ray_dev_close */
diff -Nru a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c
--- a/drivers/net/wireless/strip.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/net/wireless/strip.c	Wed Apr 30 22:28:13 2003
@@ -801,7 +801,7 @@
 	struct termios old_termios = *(tty->termios);
 	tty->termios->c_cflag &= ~CBAUD;	/* Clear the old baud setting */
 	tty->termios->c_cflag |= baudcode;	/* Set the new baud setting */
-	tty->driver.set_termios(tty, &old_termios);
+	tty->driver->set_termios(tty, &old_termios);
 }
 
 /*
@@ -1048,8 +1048,10 @@
 		if (table->num_nodes)
 			ptr += sprintf(ptr, "\n %s\n", title);
 		for (i = 0; i < table->num_nodes; i++) {
+			MetricomNode node;
+
 			spin_lock_irqsave(&strip_lock, flags);
-			MetricomNode node = table->node[i];
+			node = table->node[i];
 			spin_unlock_irqrestore(&strip_lock, flags);
 			ptr += sprintf(ptr, "  %s\n", node.c);
 		}
@@ -1266,7 +1268,7 @@
 			set_baud(tty, strip_info->user_baud);
 	}
 
-	tty->driver.write(tty, 0, s.string, s.length);
+	tty->driver->write(tty, 0, s.string, s.length);
 #ifdef EXT_COUNTERS
 	strip_info->tx_ebytes += s.length;
 #endif
@@ -1288,7 +1290,7 @@
 
 	if (strip_info->tx_left > 0) {
 		int num_written =
-		    tty->driver.write(tty, 0, strip_info->tx_head,
+		    tty->driver->write(tty, 0, strip_info->tx_head,
 				      strip_info->tx_left);
 		strip_info->tx_left -= num_written;
 		strip_info->tx_head += num_written;
@@ -2688,8 +2690,8 @@
 
 	strip_info->tty = tty;
 	tty->disc_data = strip_info;
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 
diff -Nru a/drivers/net/wireless/wavelan.c b/drivers/net/wireless/wavelan.c
--- a/drivers/net/wireless/wavelan.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/net/wireless/wavelan.c	Wed Apr 30 22:28:16 2003
@@ -3858,7 +3858,7 @@
  * This function is the interrupt handler for the WaveLAN card. This
  * routine will be called whenever: 
  */
-static void wavelan_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t wavelan_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	device *dev;
 	unsigned long ioaddr;
@@ -3934,7 +3934,7 @@
 		       dev->name, hasr);
 #endif
 		spin_unlock (&lp->spinlock);
-		return;
+		return IRQ_NONE;
 	}
 
 	/* Read interrupt data. */
@@ -4004,6 +4004,7 @@
 #ifdef DEBUG_INTERRUPT_TRACE
 	printk(KERN_DEBUG "%s: <-wavelan_interrupt()\n", dev->name);
 #endif
+	return IRQ_HANDLED;
 }
 
 /*------------------------------------------------------------------*/
diff -Nru a/drivers/net/wireless/wavelan.p.h b/drivers/net/wireless/wavelan.p.h
--- a/drivers/net/wireless/wavelan.p.h	Wed Apr 30 22:28:13 2003
+++ b/drivers/net/wireless/wavelan.p.h	Wed Apr 30 22:28:13 2003
@@ -650,7 +650,7 @@
 	wv_check_ioaddr(u_long,		/* ioaddr */
 			u_char *);	/* mac address (read) */
 /* ---------------------- INTERRUPT HANDLING ---------------------- */
-static void
+static irqreturn_t
 	wavelan_interrupt(int,		/* interrupt handler */
 			  void *,
 			  struct pt_regs *);
diff -Nru a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
--- a/drivers/net/wireless/wavelan_cs.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/net/wireless/wavelan_cs.c	Wed Apr 30 22:28:10 2003
@@ -65,16 +65,6 @@
  * (wavelan modem or i82593)
  */
 
-/*------------------------------------------------------------------*/
-/*
- * Wrapper for reporting error to cardservices
- */
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
 #ifdef STRUCT_CHECK
 /*------------------------------------------------------------------*/
 /*
@@ -5020,7 +5010,6 @@
 
   /* Mark the device as used */
   link->open++;
-  MOD_INC_USE_COUNT;
 
 #ifdef WAVELAN_ROAMING
   if(do_roaming)
@@ -5065,7 +5054,6 @@
 #endif	/* WAVELAN_ROAMING */
 
   link->open--;
-  MOD_DEC_USE_COUNT;
 
   /* If the card is still present */
   if(netif_running(dev))
@@ -5186,6 +5174,7 @@
   ether_setup(dev);
 
   /* wavelan NET3 callbacks */
+  SET_MODULE_OWNER(dev);
   dev->open = &wavelan_open;
   dev->stop = &wavelan_close;
   dev->hard_start_xmit = &wavelan_packet_xmit;
diff -Nru a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c
--- a/drivers/net/yellowfin.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/net/yellowfin.c	Wed Apr 30 22:28:08 2003
@@ -406,7 +406,7 @@
 static void yellowfin_tx_timeout(struct net_device *dev);
 static void yellowfin_init_ring(struct net_device *dev);
 static int yellowfin_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static void yellowfin_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t yellowfin_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
 static int yellowfin_rx(struct net_device *dev);
 static void yellowfin_error(struct net_device *dev, int intr_status);
 static int yellowfin_close(struct net_device *dev);
@@ -942,17 +942,18 @@
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
-static void yellowfin_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
+static irqreturn_t yellowfin_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_instance;
 	struct yellowfin_private *yp;
 	long ioaddr;
 	int boguscnt = max_interrupt_work;
+	unsigned int handled = 0;
 
 #ifndef final_version			/* Can never occur. */
 	if (dev == NULL) {
 		printk (KERN_ERR "yellowfin_interrupt(): irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 #endif
 
@@ -970,6 +971,7 @@
 
 		if (intr_status == 0)
 			break;
+		handled = 1;
 
 		if (intr_status & (IntrRxDone | IntrEarlyRx)) {
 			yellowfin_rx(dev);
@@ -1091,7 +1093,7 @@
 			   dev->name, inw(ioaddr + IntrStatus));
 
 	spin_unlock (&yp->lock);
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 /* This routine is logically part of the interrupt handler, but separated
@@ -1371,18 +1373,20 @@
 		memset(hash_table, 0, sizeof(hash_table));
 		for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count;
 			 i++, mclist = mclist->next) {
+			unsigned int bit;
+
 			/* Due to a bug in the early chip versions, multiple filter
 			   slots must be set for each address. */
 			if (yp->drv_flags & HasMulticastBug) {
-				set_bit((ether_crc_le(3, mclist->dmi_addr) >> 3) & 0x3f,
-						hash_table);
-				set_bit((ether_crc_le(4, mclist->dmi_addr) >> 3) & 0x3f,
-						hash_table);
-				set_bit((ether_crc_le(5, mclist->dmi_addr) >> 3) & 0x3f,
-						hash_table);
+				bit = (ether_crc_le(3, mclist->dmi_addr) >> 3) & 0x3f;
+				hash_table[bit >> 4] |= (1 << bit);
+				bit = (ether_crc_le(4, mclist->dmi_addr) >> 3) & 0x3f;
+				hash_table[bit >> 4] |= (1 << bit);
+				bit = (ether_crc_le(5, mclist->dmi_addr) >> 3) & 0x3f;
+				hash_table[bit >> 4] |= (1 << bit);
 			}
-			set_bit((ether_crc_le(6, mclist->dmi_addr) >> 3) & 0x3f,
-					hash_table);
+			bit = (ether_crc_le(6, mclist->dmi_addr) >> 3) & 0x3f;
+			hash_table[bit >> 4] |= (1 << bit);
 		}
 		/* Copy the hash table to the chip. */
 		for (i = 0; i < 4; i++)
diff -Nru a/drivers/net/znet.c b/drivers/net/znet.c
--- a/drivers/net/znet.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/net/znet.c	Wed Apr 30 22:28:03 2003
@@ -159,7 +159,7 @@
 
 static int	znet_open(struct net_device *dev);
 static int	znet_send_packet(struct sk_buff *skb, struct net_device *dev);
-static void	znet_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t znet_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void	znet_rx(struct net_device *dev);
 static int	znet_close(struct net_device *dev);
 static struct net_device_stats *net_get_stats(struct net_device *dev);
@@ -604,16 +604,17 @@
 }
 
 /* The ZNET interrupt handler. */
-static void	znet_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t znet_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
 	struct net_device *dev = dev_id;
 	struct znet_private *znet = dev->priv;
 	int ioaddr;
 	int boguscnt = 20;
+	int handled = 0;
 
 	if (dev == NULL) {
 		printk(KERN_WARNING "znet_interrupt(): IRQ %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	spin_lock (&znet->lock);
@@ -637,6 +638,8 @@
 		if ((status & SR0_INTERRUPT) == 0)
 			break;
 
+		handled = 1;
+
 		if ((status & SR0_EVENT_MASK) == SR0_TRANSMIT_DONE ||
 		    (status & SR0_EVENT_MASK) == SR0_RETRANSMIT_DONE ||
 		    (status & SR0_EVENT_MASK) == SR0_TRANSMIT_NO_CRC_DONE) {
@@ -682,7 +685,7 @@
 
 	spin_unlock (&znet->lock);
 	
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 static void znet_rx(struct net_device *dev)
diff -Nru a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c
--- a/drivers/parport/parport_cs.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/parport/parport_cs.c	Wed Apr 30 22:28:19 2003
@@ -103,14 +103,6 @@
 static dev_info_t dev_info = "parport_cs";
 static dev_link_t *dev_list = NULL;
 
-/*====================================================================*/
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
 /*======================================================================
 
     parport_attach() creates an "instance" of the driver, allocating
diff -Nru a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
--- a/drivers/parport/parport_pc.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/parport/parport_pc.c	Wed Apr 30 22:28:18 2003
@@ -262,9 +262,11 @@
  * of these are in parport_pc.h.
  */
 
-static void parport_pc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t parport_pc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	parport_generic_irq(irq, (struct parport *) dev_id, regs);
+	/* FIXME! Was it really ours? */
+	return IRQ_HANDLED;
 }
 
 void parport_pc_write_data(struct parport *p, unsigned char d)
diff -Nru a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
--- a/drivers/parport/parport_serial.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/parport/parport_serial.c	Wed Apr 30 22:28:16 2003
@@ -26,6 +26,7 @@
 #include <linux/serial.h>
 #include <linux/serialP.h>
 #include <linux/list.h>
+#include <linux/8250_pci.h>
 
 #include <asm/serial.h>
 
@@ -150,12 +151,12 @@
 
 static int __devinit siig10x_init_fn(struct pci_dev *dev, struct pci_board_no_ids *board, int enable)
 {
-	return pci_siig10x_fn(dev, NULL, enable);
+	return pci_siig10x_fn(dev, enable);
 }
 
 static int __devinit siig20x_init_fn(struct pci_dev *dev, struct pci_board_no_ids *board, int enable)
 {
-	return pci_siig20x_fn(dev, NULL, enable);
+	return pci_siig20x_fn(dev, enable);
 }
 
 static struct pci_board_no_ids pci_boards[] __devinitdata = {
diff -Nru a/drivers/pci/Makefile b/drivers/pci/Makefile
--- a/drivers/pci/Makefile	Wed Apr 30 22:28:17 2003
+++ b/drivers/pci/Makefile	Wed Apr 30 22:28:17 2003
@@ -20,6 +20,7 @@
 obj-$(CONFIG_PARISC) += setup-bus.o
 obj-$(CONFIG_SUPERH) += setup-bus.o setup-irq.o
 obj-$(CONFIG_PPC32) += setup-irq.o
+obj-$(CONFIG_PPC64) += setup-bus.o
 obj-$(CONFIG_DDB5476) += setup-bus.o
 obj-$(CONFIG_SGI_IP27) += setup-irq.o
 obj-$(CONFIG_X86_VISWS) += setup-irq.o
diff -Nru a/drivers/pci/bus.c b/drivers/pci/bus.c
--- a/drivers/pci/bus.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/pci/bus.c	Wed Apr 30 22:28:18 2003
@@ -75,7 +75,8 @@
  * Add newly discovered PCI devices (which are on the bus->devices
  * list) to the global PCI device list, add the sysfs and procfs
  * entries.  Where a bridge is found, add the discovered bus to
- * the parents list of child buses, and recurse.
+ * the parents list of child buses, and recurse (breadth-first
+ * to be compatible with 2.4)
  *
  * Call hotplug for each new devices.
  */
@@ -97,6 +98,12 @@
 		pci_proc_attach_device(dev);
 #endif
 		pci_create_sysfs_dev_files(dev);
+
+	}
+
+	list_for_each_entry(dev, &bus->devices, bus_list) {
+
+		BUG_ON(list_empty(&dev->global_list));
 
 		/*
 		 * If there is an unattached subordinate bus, attach
diff -Nru a/drivers/pci/pci.ids b/drivers/pci/pci.ids
--- a/drivers/pci/pci.ids	Wed Apr 30 22:28:09 2003
+++ b/drivers/pci/pci.ids	Wed Apr 30 22:28:09 2003
@@ -6207,6 +6207,9 @@
 	103e  82801BD PRO/100 VM (MOB) Ethernet Controller
 	1040  536EP Data Fax Modem
 		16be 1040  V.9X DSP Data Fax Modem
+	1048  82597EX 10GbE Ethernet Controller
+		8086 a01f  PRO/10GbE LR Server Adapter
+		8086 a11f  PRO/10GbE LR Server Adapter
 	1059  82551QM Ethernet Controller
 	1130  82815 815 Chipset Host Bridge and Memory Controller Hub
 		1025 1016  Travelmate 612 TX
diff -Nru a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
--- a/drivers/pcmcia/Kconfig	Wed Apr 30 22:28:14 2003
+++ b/drivers/pcmcia/Kconfig	Wed Apr 30 22:28:14 2003
@@ -21,7 +21,7 @@
 	  To use your PC-cards, you will need supporting software from David
 	  Hinds' pcmcia-cs package (see the file <file:Documentation/Changes>
 	  for location).  Please also read the PCMCIA-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
diff -Nru a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c
--- a/drivers/pcmcia/cardbus.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/pcmcia/cardbus.c	Wed Apr 30 22:28:06 2003
@@ -123,7 +123,7 @@
     
 =====================================================================*/
 
-void cb_release_cis_mem(socket_info_t * s)
+static void cb_release_cis_mem(socket_info_t * s)
 {
 	if (s->cb_cis_virt) {
 		DEBUG(1, "cs: cb_release_cis_mem()\n");
@@ -269,6 +269,8 @@
 void cb_free(socket_info_t * s)
 {
 	struct pci_dev *bridge = s->cap.cb_dev;
+
+	cb_release_cis_mem(s);
 
 	if (bridge)
 		pci_remove_behind_bridge(bridge);
diff -Nru a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
--- a/drivers/pcmcia/cistpl.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/pcmcia/cistpl.c	Wed Apr 30 22:28:07 2003
@@ -269,8 +269,8 @@
 static void read_cis_cache(socket_info_t *s, int attr, u_int addr,
 			   u_int len, void *ptr)
 {
-    int i, ret;
-    char *caddr;
+    struct cis_cache_entry *cis;
+    int ret;
 
     if (s->fake_cis) {
 	if (s->fake_cis_len > addr+len)
@@ -279,32 +279,55 @@
 	    memset(ptr, 0xff, len);
 	return;
     }
-    caddr = s->cis_cache;
-    for (i = 0; i < s->cis_used; i++) {
-	if ((s->cis_table[i].addr == addr) &&
-	    (s->cis_table[i].len == len) &&
-	    (s->cis_table[i].attr == attr)) break;
-	caddr += s->cis_table[i].len;
-    }
-    if (i < s->cis_used) {
-	memcpy(ptr, caddr, len);
-	return;
+
+    list_for_each_entry(cis, &s->cis_cache, node) {
+	if (cis->addr == addr && cis->len == len && cis->attr == attr) {
+	    memcpy(ptr, cis->cache, len);
+	    return;
+	}
     }
+
 #ifdef CONFIG_CARDBUS
     if (s->state & SOCKET_CARDBUS)
 	ret = read_cb_mem(s, attr, addr, len, ptr);
     else
 #endif
 	ret = read_cis_mem(s, attr, addr, len, ptr);
-    /* Copy data into the cache, if there is room */
-    if ((ret == 0) && (i < MAX_CIS_TABLE) &&
-	(caddr+len < s->cis_cache+MAX_CIS_DATA)) {
-	s->cis_table[i].addr = addr;
-	s->cis_table[i].len = len;
-	s->cis_table[i].attr = attr;
-	s->cis_used++;
-	memcpy(caddr, ptr, len);
-    }	    
+
+    /* Copy data into the cache */
+    cis = kmalloc(sizeof(struct cis_cache_entry) + len, GFP_KERNEL);
+    if (cis) {
+	cis->addr = addr;
+	cis->len = len;
+	cis->attr = attr;
+	memcpy(cis->cache, ptr, len);
+	list_add(&cis->node, &s->cis_cache);
+    }
+}
+
+static void
+remove_cis_cache(socket_info_t *s, int attr, u_int addr, u_int len)
+{
+	struct cis_cache_entry *cis;
+
+	list_for_each_entry(cis, &s->cis_cache, node)
+		if (cis->addr == addr && cis->len == len && cis->attr == attr) {
+			list_del(&cis->node);
+			kfree(cis);
+			break;
+		}
+}
+
+void destroy_cis_cache(socket_info_t *s)
+{
+	struct list_head *l, *n;
+
+	list_for_each_safe(l, n, &s->cis_cache) {
+		struct cis_cache_entry *cis = list_entry(l, struct cis_cache_entry, node);
+
+		list_del(&cis->node);
+		kfree(cis);
+	}
 }
 
 /*======================================================================
@@ -316,24 +339,25 @@
 
 int verify_cis_cache(socket_info_t *s)
 {
-    char buf[256], *caddr;
-    int i;
-    
-    caddr = s->cis_cache;
-    for (i = 0; i < s->cis_used; i++) {
+	struct cis_cache_entry *cis;
+	char buf[256];
+
+	list_for_each_entry(cis, &s->cis_cache, node) {
+		int len = cis->len;
+
+		if (len > 256)
+			len = 256;
 #ifdef CONFIG_CARDBUS
-	if (s->state & SOCKET_CARDBUS)
-	    read_cb_mem(s, s->cis_table[i].attr, s->cis_table[i].addr,
-			s->cis_table[i].len, buf);
-	else
+		if (s->state & SOCKET_CARDBUS)
+			read_cb_mem(s, cis->attr, cis->addr, len, buf);
+		else
 #endif
-	    read_cis_mem(s, s->cis_table[i].attr, s->cis_table[i].addr,
-			 s->cis_table[i].len, buf);
-	if (memcmp(buf, caddr, s->cis_table[i].len) != 0)
-	    break;
-	caddr += s->cis_table[i].len;
-    }
-    return (i < s->cis_used);
+			read_cis_mem(s, cis->attr, cis->addr, len, buf);
+
+		if (memcmp(buf, cis->cache, len) != 0)
+			return -1;
+	}
+	return 0;
 }
 
 /*======================================================================
@@ -449,14 +473,16 @@
 	if ((link[0] == CISTPL_LINKTARGET) && (link[1] >= 3) &&
 	    (strncmp(link+2, "CIS", 3) == 0))
 	    return ofs;
+	remove_cis_cache(s, SPACE(tuple->Flags), ofs, 5);
 	/* Then, we try the wrong spot... */
 	ofs = ofs >> 1;
     }
     read_cis_cache(s, SPACE(tuple->Flags), ofs, 5, link);
-    if ((link[0] != CISTPL_LINKTARGET) || (link[1] < 3) ||
-	(strncmp(link+2, "CIS", 3) != 0))
-	return -1;
-    return ofs;
+    if ((link[0] == CISTPL_LINKTARGET) && (link[1] >= 3) &&
+	(strncmp(link+2, "CIS", 3) == 0))
+	return ofs;
+    remove_cis_cache(s, SPACE(tuple->Flags), ofs, 5);
+    return -1;
 }
 
 int pcmcia_get_next_tuple(client_handle_t handle, tuple_t *tuple)
diff -Nru a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
--- a/drivers/pcmcia/cs.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/pcmcia/cs.c	Wed Apr 30 22:28:06 2003
@@ -313,9 +313,9 @@
 /**
  * pcmcia_register_socket - add a new pcmcia socket device
  */
-int pcmcia_register_socket(struct device *dev)
+int pcmcia_register_socket(struct class_device *class_dev)
 {
-	struct pcmcia_socket_class_data *cls_d = to_class_data(dev);
+	struct pcmcia_socket_class_data *cls_d = class_get_devdata(class_dev);
 	socket_info_t *s_info;
 	unsigned int i, j;
 
@@ -342,6 +342,7 @@
 		s->cis_mem.flags = 0;
 		s->cis_mem.speed = cis_speed;
 		s->erase_busy.next = s->erase_busy.prev = &s->erase_busy;
+		INIT_LIST_HEAD(&s->cis_cache);
 		spin_lock_init(&s->lock);
     
 		/* TBD: remove usage of socket_table, use class_for_each_dev instead */
@@ -374,9 +375,9 @@
 /**
  * pcmcia_unregister_socket - remove a pcmcia socket device
  */
-void pcmcia_unregister_socket(struct device *dev)
+void pcmcia_unregister_socket(struct class_device *class_dev)
 {
-	struct pcmcia_socket_class_data *cls_d = to_class_data(dev);
+	struct pcmcia_socket_class_data *cls_d = class_get_devdata(class_dev);
 	unsigned int i;
 	int j, socket = -1;
 	client_t *client;
@@ -469,7 +470,7 @@
     init_socket(s);
     s->irq.AssignedIRQ = s->irq.Config = 0;
     s->lock_count = 0;
-    s->cis_used = 0;
+    destroy_cis_cache(s);
     if (s->fake_cis) {
 	kfree(s->fake_cis);
 	s->fake_cis = NULL;
@@ -484,7 +485,6 @@
     set_socket(s, &s->socket);
     /* */
 #ifdef CONFIG_CARDBUS
-    cb_release_cis_mem(s);
     cb_free(s);
 #endif
     s->functions = 0;
@@ -751,9 +751,8 @@
 }
 
 
-int pcmcia_socket_dev_suspend(struct device * dev, u32 state, u32 level)
+int pcmcia_socket_dev_suspend(struct pcmcia_socket_class_data *cls_d, u32 state, u32 level)
 {
-	struct pcmcia_socket_class_data *cls_d = to_class_data(dev);
 	socket_info_t *s;
 	int i;
 
@@ -771,9 +770,8 @@
 }
 EXPORT_SYMBOL(pcmcia_socket_dev_suspend);
 
-int pcmcia_socket_dev_resume(struct device * dev, u32 level)
+int pcmcia_socket_dev_resume(struct pcmcia_socket_class_data *cls_d, u32 level)
 {
-	struct pcmcia_socket_class_data *cls_d = to_class_data(dev);
 	socket_info_t *s;
 	int i;
 
@@ -2423,20 +2421,25 @@
 EXPORT_SYMBOL(pcmcia_suspend_socket);
 EXPORT_SYMBOL(pcmcia_resume_socket);
 
-struct device_class pcmcia_socket_class = {
+struct class pcmcia_socket_class = {
 	.name = "pcmcia_socket",
-	.add_device = &pcmcia_register_socket,
-	.remove_device = &pcmcia_unregister_socket,
 };
 EXPORT_SYMBOL(pcmcia_socket_class);
 
+static struct class_interface pcmcia_socket = {
+	.class = &pcmcia_socket_class,
+	.add = &pcmcia_register_socket,
+	.remove = &pcmcia_unregister_socket,
+};
+
 
 static int __init init_pcmcia_cs(void)
 {
     printk(KERN_INFO "%s\n", release);
     printk(KERN_INFO "  %s\n", options);
     DEBUG(0, "%s\n", version);
-    devclass_register(&pcmcia_socket_class);
+    class_register(&pcmcia_socket_class);
+    class_interface_register(&pcmcia_socket);
 #ifdef CONFIG_PROC_FS
     proc_pccard = proc_mkdir("pccard", proc_bus);
 #endif
@@ -2453,7 +2456,8 @@
     }
 #endif
     release_resource_db();
-    devclass_unregister(&pcmcia_socket_class);
+    class_interface_unregister(&pcmcia_socket);
+    class_unregister(&pcmcia_socket_class);
 }
 
 subsys_initcall(init_pcmcia_cs);
diff -Nru a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h
--- a/drivers/pcmcia/cs_internal.h	Wed Apr 30 22:28:03 2003
+++ b/drivers/pcmcia/cs_internal.h	Wed Apr 30 22:28:03 2003
@@ -114,9 +114,13 @@
 /* Maximum number of memory windows per socket */
 #define MAX_WIN 4
 
-/* The size of the CIS cache */
-#define MAX_CIS_TABLE	64
-#define MAX_CIS_DATA	512
+struct cis_cache_entry {
+	struct list_head	node;
+	unsigned int		addr;
+	unsigned int		len;
+	unsigned int		attr;
+	unsigned char		cache[0];
+};
 
 typedef struct socket_info_t {
     spinlock_t			lock;
@@ -145,13 +149,7 @@
     window_t			win[MAX_WIN];
     region_t			*c_region, *a_region;
     erase_busy_t		erase_busy;
-    int				cis_used;
-    struct {
-	u_int			addr;
-	u_short			len;
-	u_short			attr;
-    }				cis_table[MAX_CIS_TABLE];
-    char			cis_cache[MAX_CIS_DATA];
+    struct list_head		cis_cache;
     u_int			fake_cis_len;
     char			*fake_cis;
 #ifdef CONFIG_PROC_FS
@@ -198,7 +196,6 @@
 int cb_alloc(socket_info_t *s);
 void cb_free(socket_info_t *s);
 int read_cb_mem(socket_info_t *s, int space, u_int addr, u_int len, void *ptr);
-void cb_release_cis_mem(socket_info_t *s);
 
 /* In cistpl.c */
 int read_cis_mem(socket_info_t *s, int attr,
@@ -206,6 +203,7 @@
 void write_cis_mem(socket_info_t *s, int attr,
 		   u_int addr, u_int len, void *ptr);
 void release_cis_mem(socket_info_t *s);
+void destroy_cis_cache(socket_info_t *s);
 int verify_cis_cache(socket_info_t *s);
 void preload_cis_cache(socket_info_t *s);
 int get_first_tuple(client_handle_t handle, tuple_t *tuple);
diff -Nru a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
--- a/drivers/pcmcia/ds.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/pcmcia/ds.c	Wed Apr 30 22:28:14 2003
@@ -130,11 +130,12 @@
 
 /*====================================================================*/
 
-static void cs_error(client_handle_t handle, int func, int ret)
+void cs_error(client_handle_t handle, int func, int ret)
 {
-    error_info_t err = { func, ret };
-    pcmcia_report_error(handle, &err);
+	error_info_t err = { func, ret };
+	pcmcia_report_error(handle, &err);
 }
+EXPORT_SYMBOL(cs_error);
 
 /*======================================================================*/
 
@@ -957,9 +958,9 @@
 }
 
 
-static int __devinit pcmcia_bus_add_socket_dev(struct device *dev)
+static int pcmcia_bus_add_socket_dev(struct class_device *class_dev)
 {
-	struct pcmcia_socket_class_data *cls_d = dev->class_data;
+	struct pcmcia_socket_class_data *cls_d = class_get_devdata(class_dev);
 	unsigned int i;
 	unsigned int ret = 0;
 
@@ -968,45 +969,42 @@
 
 	down_write(&bus_socket_list_rwsem);
         for (i = 0; i < cls_d->nsock; i++)
-		ret += pcmcia_bus_add_socket(dev, i);
+		ret += pcmcia_bus_add_socket(class_dev->dev, i);
 	up_write(&bus_socket_list_rwsem);
 
 	return ret;
 }
 
-static int __devexit pcmcia_bus_remove_socket_dev(struct device *dev)
+static void pcmcia_bus_remove_socket_dev(struct class_device *class_dev)
 {
-	struct pcmcia_socket_class_data *cls_d = dev->class_data;
+	struct pcmcia_socket_class_data *cls_d = class_get_devdata(class_dev);
 	struct list_head *list_loop;
 	struct list_head *tmp_storage;
 
 	if (!cls_d)
-		return -ENODEV;
+		return;
 
 	flush_scheduled_work();
 
 	down_write(&bus_socket_list_rwsem);
 	list_for_each_safe(list_loop, tmp_storage, &bus_socket_list) {
 		struct pcmcia_bus_socket *bus_sock = container_of(list_loop, struct pcmcia_bus_socket, socket_list);
-		if (bus_sock->socket_dev == dev) {
+		if (bus_sock->socket_dev == class_dev->dev) {
 			pcmcia_deregister_client(bus_sock->handle);
 			list_del(&bus_sock->socket_list);
 			kfree(bus_sock);
 		}
 	}
 	up_write(&bus_socket_list_rwsem);
-	return 0;
+	return;
 }
 
 
 /* the pcmcia_bus_interface is used to handle pcmcia socket devices */
-static struct device_interface pcmcia_bus_interface = {
-	.name = "pcmcia-bus",
-	.devclass = &pcmcia_socket_class,
-	.add_device = &pcmcia_bus_add_socket_dev,
-	.remove_device = __devexit_p(&pcmcia_bus_remove_socket_dev),
-	.kset = { .subsys = &pcmcia_socket_class.subsys, },
-	.devnum = 0,
+static struct class_interface pcmcia_bus_interface = {
+	.class = &pcmcia_socket_class,
+	.add = &pcmcia_bus_add_socket_dev,
+	.remove = &pcmcia_bus_remove_socket_dev,
 };
 
 
@@ -1021,7 +1019,7 @@
 	int i;
 
 	bus_register(&pcmcia_bus_type);
-	interface_register(&pcmcia_bus_interface);
+	class_interface_register(&pcmcia_bus_interface);
 
 	/* Set up character device for user mode clients */
 	i = register_chrdev(0, "pcmcia", &ds_fops);
@@ -1044,7 +1042,7 @@
 
 static void __exit exit_pcmcia_bus(void)
 {
-	interface_unregister(&pcmcia_bus_interface);
+	class_interface_unregister(&pcmcia_bus_interface);
 
 #ifdef CONFIG_PROC_FS
 	if (proc_pccard)
diff -Nru a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c
--- a/drivers/pcmcia/i82092.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/pcmcia/i82092.c	Wed Apr 30 22:28:20 2003
@@ -44,12 +44,14 @@
 
 static int i82092aa_socket_suspend (struct pci_dev *dev, u32 state)
 {
-	return pcmcia_socket_dev_suspend(&dev->dev, state, 0);
+	struct pcmcia_socket_class_data *cls_d = pci_get_drvdata(dev);
+	return pcmcia_socket_dev_suspend(cls_d, state, 0);
 }
 
 static int i82092aa_socket_resume (struct pci_dev *dev)
 {
-	return pcmcia_socket_dev_resume(&dev->dev, RESUME_RESTORE_STATE);
+	struct pcmcia_socket_class_data *cls_d = pci_get_drvdata(dev);
+	return pcmcia_socket_dev_resume(cls_d, RESUME_RESTORE_STATE);
 }
 
 static struct pci_driver i82092aa_pci_drv = {
@@ -59,9 +61,6 @@
 	.remove         = __devexit_p(i82092aa_pci_remove),
 	.suspend        = i82092aa_socket_suspend,
 	.resume         = i82092aa_socket_resume,
-	.driver		= {
-		.devclass = &pcmcia_socket_class,
-	},
 };
 
 
@@ -176,7 +175,12 @@
 	memset(cls_d, 0, sizeof(*cls_d));
 	cls_d->nsock = socket_count;
 	cls_d->ops = &i82092aa_operations;
-	dev->dev.class_data = cls_d;
+	pci_set_drvdata(dev, &cls_d);
+	cls_d->class_dev.class = &pcmcia_socket_class;
+	cls_d->class_dev.dev = &dev->dev;
+	strncpy(cls_d->class_dev.class_id, dev->dev.name, BUS_ID_SIZE);
+	class_set_devdata(&cls_d->class_dev, cls_d);
+	class_device_register(&cls_d->class_dev);
 
 	leave("i82092aa_pci_probe");
 	return 0;
@@ -192,11 +196,16 @@
 
 static void __devexit i82092aa_pci_remove(struct pci_dev *dev)
 {
+	struct pcmcia_socket_class_data *cls_d = pci_get_drvdata(dev);
+
 	enter("i82092aa_pci_remove");
 	
 	free_irq(dev->irq, i82092aa_interrupt);
-	if (dev->dev.class_data)
-		kfree(dev->dev.class_data);
+
+	if (cls_d) {
+		class_device_unregister(&cls_d->class_dev);
+		kfree(cls_d);
+	}
 
 	leave("i82092aa_pci_remove");
 }
@@ -219,6 +228,7 @@
 	return val;
 }
 
+#if 0
 static unsigned short indirect_read16(int socket, unsigned short reg)
 {
 	unsigned short int port;
@@ -235,6 +245,7 @@
 	spin_unlock_irqrestore(&port_lock,flags);
 	return tmp;
 }
+#endif
 
 static void indirect_write(int socket, unsigned short reg, unsigned char value)
 {
@@ -334,11 +345,12 @@
 static DECLARE_WORK(i82092aa_task, i82092aa_bh, NULL);
         
 
-static void i82092aa_interrupt(int irq, void *dev, struct pt_regs *regs)
+static irqreturn_t i82092aa_interrupt(int irq, void *dev, struct pt_regs *regs)
 {
 	int i;
 	int loopcount = 0;
-	
+	int handled = 0;
+
 	unsigned int events, active=0;
 	
 /*	enter("i82092aa_interrupt");*/
@@ -362,6 +374,7 @@
 			if ((csc==0) ||  /* no events on this socket */
 			   (sockets[i].handler==NULL)) /* no way to handle events */
 			   	continue;
+			handled = 1;
 			events = 0;
 			 
 			if (csc & I365_CSC_DETECT) {
@@ -390,7 +403,7 @@
 			break;				
 		
 	}
-	
+	return IRQ_RETVAL(handled);
 /*	leave("i82092aa_interrupt");*/
 }
 
diff -Nru a/drivers/pcmcia/i82092aa.h b/drivers/pcmcia/i82092aa.h
--- a/drivers/pcmcia/i82092aa.h	Wed Apr 30 22:28:04 2003
+++ b/drivers/pcmcia/i82092aa.h	Wed Apr 30 22:28:04 2003
@@ -1,6 +1,8 @@
 #ifndef _INCLUDE_GUARD_i82092aa_H_
 #define _INCLUDE_GUARD_i82092aa_H_
 
+#include <linux/interrupt.h>
+
 /* $Id: i82092aa.h,v 1.1.1.1 2001/09/19 14:53:15 dwmw2 Exp $ */
 
 /* Debuging defines */
@@ -21,7 +23,7 @@
 static int  i82092aa_pci_probe(struct pci_dev *dev, const struct pci_device_id *id);
 static void i82092aa_pci_remove(struct pci_dev *dev);
 static int card_present(int socketno);
-static void i82092aa_interrupt(int irq, void *dev, struct pt_regs *regs);
+static irqreturn_t i82092aa_interrupt(int irq, void *dev, struct pt_regs *regs);
 
 
 
diff -Nru a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c
--- a/drivers/pcmcia/i82365.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/pcmcia/i82365.c	Wed Apr 30 22:28:16 2003
@@ -78,7 +78,7 @@
 #define DEBUG(n, args...) do { } while (0)
 #endif
 
-static void i365_count_irq(int, void *, struct pt_regs *);
+static irqreturn_t i365_count_irq(int, void *, struct pt_regs *);
 static inline int _check_irq(int irq, int flags)
 {
     if (request_irq(irq, i365_count_irq, flags, "x", i365_count_irq) != 0)
@@ -535,11 +535,12 @@
 static volatile u_int irq_hits;
 static u_short irq_sock;
 
-static void i365_count_irq(int irq, void *dev, struct pt_regs *regs)
+static irqreturn_t i365_count_irq(int irq, void *dev, struct pt_regs *regs)
 {
     i365_get(irq_sock, I365_CSC);
     irq_hits++;
     DEBUG(2, "-> hit on irq %d\n", irq);
+    return IRQ_HANDLED;
 }
 
 static u_int __init test_irq(u_short sock, int irq)
@@ -627,11 +628,6 @@
     return ns/cycle_time;
 }
 
-static int to_ns(int cycles)
-{
-    return cycle_time*cycles;
-}
-
 /*====================================================================*/
 
 #ifdef CONFIG_ISA
@@ -939,7 +935,7 @@
 
 static unsigned long last_detect_jiffies;
 
-static void pcic_interrupt(int irq, void *dev,
+static irqreturn_t pcic_interrupt(int irq, void *dev,
 				    struct pt_regs *regs)
 {
     int i, j, csc;
@@ -947,7 +943,8 @@
 #ifdef CONFIG_ISA
     u_long flags = 0;
 #endif
-    
+    int handled = 0;
+
     DEBUG(4, "i82365: pcic_interrupt(%d)\n", irq);
 
     for (j = 0; j < 20; j++) {
@@ -956,6 +953,7 @@
 	    if ((socket[i].cs_irq != irq) &&
 		(socket[i].cap.pci_irq != irq))
 		continue;
+	    handled = 1;
 	    ISA_LOCK(i, flags);
 	    csc = i365_get(i, I365_CSC);
 	    if ((csc == 0) || (!socket[i].handler) ||
@@ -1002,6 +1000,7 @@
 	printk(KERN_NOTICE "i82365: infinite loop in interrupt handler\n");
 
     DEBUG(4, "i82365: interrupt done\n");
+    return IRQ_RETVAL(handled);
 } /* pcic_interrupt */
 
 static void pcic_interrupt_wrapper(u_long data)
@@ -1510,9 +1509,8 @@
 static struct device_driver i82365_driver = {
 	.name = "i82365",
 	.bus = &platform_bus_type,
-	.devclass = &pcmcia_socket_class,
-	.suspend = pcmcia_socket_dev_suspend,
-	.resume = pcmcia_socket_dev_resume,
+/*	.suspend = pcmcia_socket_dev_suspend,	FIXME?	*/
+/*	.resume = pcmcia_socket_dev_resume,	FIXME?	*/
 };
 
 static struct platform_device i82365_device = {
@@ -1523,6 +1521,10 @@
 	},
 };
 
+static struct class_device i82365_class_data = {
+	.class = &pcmcia_socket_class,
+};
+
 static int __init init_i82365(void)
 {
     servinfo_t serv;
@@ -1556,9 +1558,12 @@
 #endif
     
     i82365_data.nsock = sockets;
-    i82365_device.dev.class_data = &i82365_data;
+    i82365_class_data.dev = &i82365_device.dev;
+    i82365_class_data.class_data = &i82365_data;
+    strncpy(i82365_class_data.class_id, "i82365", BUS_ID_SIZE);
     
     platform_device_register(&i82365_device);
+    class_device_register(&i82365_class_data);
 
     /* Finally, schedule a polling interrupt */
     if (poll_interval != 0) {
@@ -1579,6 +1584,7 @@
 #ifdef CONFIG_PROC_FS
     for (i = 0; i < sockets; i++) pcic_proc_remove(i);
 #endif
+    class_device_unregister(&i82365_class_data);
     platform_device_unregister(&i82365_device);
     if (poll_interval != 0)
 	del_timer_sync(&poll_timer);
diff -Nru a/drivers/pcmcia/pci_socket.c b/drivers/pcmcia/pci_socket.c
--- a/drivers/pcmcia/pci_socket.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/pcmcia/pci_socket.c	Wed Apr 30 22:28:19 2003
@@ -153,7 +153,10 @@
 	socket->cls_d.nsock = 1; /* yenta is 1, no other low-level driver uses
 			     this yet */
 	socket->cls_d.ops = &pci_socket_operations;
-	dev->dev.class_data = &socket->cls_d;
+	socket->cls_d.class_dev.class = &pcmcia_socket_class;
+	socket->cls_d.class_dev.dev = &dev->dev;
+	strncpy(socket->cls_d.class_dev.class_id, dev->dev.bus_id, BUS_ID_SIZE);
+	class_set_devdata(&socket->cls_d.class_dev, &socket->cls_d);
 
 	/* prepare pci_socket_t */
 	socket->dev = dev;
@@ -161,10 +164,11 @@
 	pci_set_drvdata(dev, socket);
 	spin_lock_init(&socket->event_lock);
 	err = socket->op->open(socket);
-	if(err)
-	{
+	if (err) {
 		socket->dev = NULL;
 		pci_set_drvdata(dev, NULL);
+	} else {
+		class_device_register(&socket->cls_d.class_dev);
 	}
 	return err;
 }
@@ -194,17 +198,20 @@
 	/* note: we are already unregistered from the cs core */
 	if (socket->op && socket->op->close)
 		socket->op->close(socket);
+	class_device_unregister(&socket->cls_d.class_dev);
 	pci_set_drvdata(dev, NULL);
 }
 
 static int cardbus_suspend (struct pci_dev *dev, u32 state)
 {
-	return pcmcia_socket_dev_suspend(&dev->dev, state, 0);
+	pci_socket_t *socket = pci_get_drvdata(dev);
+	return pcmcia_socket_dev_suspend(&socket->cls_d, state, 0);
 }
 
 static int cardbus_resume (struct pci_dev *dev)
 {
-	return pcmcia_socket_dev_resume(&dev->dev, RESUME_RESTORE_STATE);
+	pci_socket_t *socket = pci_get_drvdata(dev);
+	return pcmcia_socket_dev_resume(&socket->cls_d, RESUME_RESTORE_STATE);
 }
 
 
@@ -227,9 +234,6 @@
 	.remove		= __devexit_p(cardbus_remove),
 	.suspend	= cardbus_suspend,
 	.resume		= cardbus_resume,
-	.driver		= {
-		.devclass = &pcmcia_socket_class,
-	},
 };
 
 static int __init pci_socket_init(void)
diff -Nru a/drivers/pcmcia/rsrc_mgr.c b/drivers/pcmcia/rsrc_mgr.c
--- a/drivers/pcmcia/rsrc_mgr.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/pcmcia/rsrc_mgr.c	Wed Apr 30 22:28:11 2003
@@ -351,7 +351,7 @@
     ret = pcmcia_validate_cis(s->clients, &info1);
     /* invalidate mapping and CIS cache */
     iounmap(s->cis_virt);
-    s->cis_used = 0;
+    destroy_cis_cache(s);
     if ((ret != 0) || (info1.Chains == 0))
 	return 0;
     s->cis_mem.sys_start = base+s->cap.map_size;
@@ -359,7 +359,7 @@
     s->cis_virt = ioremap(base+s->cap.map_size, s->cap.map_size);
     ret = pcmcia_validate_cis(s->clients, &info2);
     iounmap(s->cis_virt);
-    s->cis_used = 0;
+    destroy_cis_cache(s);
     return ((ret == 0) && (info1.Chains == info2.Chains));
 }
 
@@ -499,14 +499,16 @@
 
 void validate_mem(socket_info_t *s)
 {
-    resource_map_t *m;
+    resource_map_t *m, *n;
     static int done = 0;
     
     if (probe_mem && done++ == 0) {
 	down(&rsrc_sem);
-	for (m = mem_db.next; m != &mem_db; m = m->next)
+	for (m = mem_db.next; m != &mem_db; m = n) {
+	    n = m->next;
 	    if (do_mem_probe(m->base, m->num, s))
 		break;
+	}
 	up(&rsrc_sem);
     }
 }
@@ -599,7 +601,7 @@
 
 #ifdef CONFIG_PCMCIA_PROBE
 
-static void fake_irq(int i, void *d, struct pt_regs *r) { }
+static irqreturn_t fake_irq(int i, void *d, struct pt_regs *r) { return IRQ_NONE; }
 static inline int check_irq(int irq)
 {
     if (request_irq(irq, fake_irq, 0, "bogus", NULL) != 0)
@@ -743,9 +745,6 @@
 	if (ret == CS_SUCCESS) {
 	    for (i = 0; i < sockets; i++) {
 		release_cis_mem(socket_table[i]);
-#ifdef CONFIG_CARDBUS
-		cb_release_cis_mem(socket_table[i]);
-#endif
 	    }
 	}
 	break;
diff -Nru a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c
--- a/drivers/pcmcia/sa1111_generic.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/pcmcia/sa1111_generic.c	Wed Apr 30 22:28:06 2003
@@ -176,7 +176,6 @@
 	.drv = {
 		.name		= "sa1111-pcmcia",
 		.bus		= &sa1111_bus_type,
-		.devclass	= &pcmcia_socket_class,
 		.probe		= pcmcia_probe,
 		.remove		= __devexit_p(pcmcia_remove),
 		.suspend 	= pcmcia_socket_dev_suspend,
diff -Nru a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c
--- a/drivers/pcmcia/tcic.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/pcmcia/tcic.c	Wed Apr 30 22:28:10 2003
@@ -111,7 +111,7 @@
 
 /*====================================================================*/
 
-static void tcic_interrupt(int irq, void *dev, struct pt_regs *regs);
+static irqreturn_t tcic_interrupt(int irq, void *dev, struct pt_regs *regs);
 static void tcic_timer(u_long data);
 static struct pccard_operations tcic_operations;
 
@@ -229,9 +229,10 @@
 
 static volatile u_int irq_hits;
 
-static void __init tcic_irq_count(int irq, void *dev, struct pt_regs *regs)
+static irqreturn_t __init tcic_irq_count(int irq, void *dev, struct pt_regs *regs)
 {
     irq_hits++;
+    return IRQ_HANDLED;
 }
 
 static u_int __init try_irq(int irq)
@@ -378,9 +379,8 @@
 static struct device_driver tcic_driver = {
 	.name = "tcic-pcmcia",
 	.bus = &platform_bus_type,
-	.devclass = &pcmcia_socket_class,
-	.suspend = pcmcia_socket_dev_suspend,
-	.resume = pcmcia_socket_dev_resume,
+/*	.suspend = pcmcia_socket_dev_suspend,	FIXME?	*/
+/*	.resume = pcmcia_socket_dev_resume,	FIXME?	*/
 };
 
 static struct platform_device tcic_device = {
@@ -391,6 +391,10 @@
 	},
 };
 
+static struct class_device tcic_class_data = {
+	.class = &pcmcia_socket_class,
+};
+
 static int __init init_tcic(void)
 {
     int i, sock;
@@ -521,9 +525,12 @@
     tcic_interrupt(0, NULL, NULL);
 
     tcic_data.nsock = sockets;
-    tcic_device.dev.class_data = &tcic_data;
-
+    tcic_class_data.dev = &tcic_device.dev;
+    tcic_class_data.class_data = &tcic_data;
+    strncpy(tcic_class_data.class_id, "tcic-pcmcia", BUS_ID_SIZE);
+    
     platform_device_register(&tcic_device);
+    class_device_register(&tcic_class_data);
 
     return 0;
     
@@ -539,6 +546,7 @@
 	free_irq(cs_irq, tcic_interrupt);
     }
     release_region(tcic_base, 16);
+    class_device_unregister(&tcic_class_data);
     platform_device_unregister(&tcic_device);
     driver_unregister(&tcic_driver);
 } /* exit_tcic */
@@ -565,7 +573,7 @@
 
 static DECLARE_WORK(tcic_task, tcic_bh, NULL);
 
-static void tcic_interrupt(int irq, void *dev, struct pt_regs *regs)
+static irqreturn_t tcic_interrupt(int irq, void *dev, struct pt_regs *regs)
 {
     int i, quick = 0;
     u_char latch, sstat;
@@ -575,7 +583,7 @@
 
     if (active) {
 	printk(KERN_NOTICE "tcic: reentered interrupt handler!\n");
-	return;
+	return IRQ_NONE;
     } else
 	active = 1;
 
@@ -620,7 +628,7 @@
     active = 0;
     
     DEBUG(2, "tcic: interrupt done\n");
-    
+    return IRQ_HANDLED;
 } /* tcic_interrupt */
 
 static void tcic_timer(u_long data)
diff -Nru a/drivers/pcmcia/yenta.c b/drivers/pcmcia/yenta.c
--- a/drivers/pcmcia/yenta.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/pcmcia/yenta.c	Wed Apr 30 22:28:11 2003
@@ -429,7 +429,7 @@
 		socket->handler(socket->info, events);
 }
 
-static void yenta_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t yenta_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	unsigned int events;
 	pci_socket_t *socket = (pci_socket_t *) dev_id;
@@ -440,7 +440,9 @@
 		socket->events |= events;
 		spin_unlock(&socket->event_lock);
 		schedule_work(&socket->tq_task);
+		return IRQ_HANDLED;
 	}
+	return IRQ_NONE;
 }
 
 static void yenta_interrupt_wrapper(unsigned long data)
diff -Nru a/drivers/pnp/resource.c b/drivers/pnp/resource.c
--- a/drivers/pnp/resource.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/pnp/resource.c	Wed Apr 30 22:28:10 2003
@@ -420,8 +420,9 @@
 	return NULL;
 }
 
-static void pnp_test_handler(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t pnp_test_handler(int irq, void *dev_id, struct pt_regs *regs)
 {
+	return IRQ_NONE;
 }
 
 int pnp_check_irq(struct pnp_dev * dev, int idx)
diff -Nru a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
--- a/drivers/s390/block/dasd.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/s390/block/dasd.c	Wed Apr 30 22:28:08 2003
@@ -10,8 +10,6 @@
  * $Revision: 1.94 $
  */
 
-#define LOCAL_END_REQUEST /* Don't generate end_request in blk.h */
-
 #include <linux/config.h>
 #include <linux/kmod.h>
 #include <linux/init.h>
@@ -141,38 +139,15 @@
 static inline int
 dasd_state_new_to_known(struct dasd_device *device)
 {
-	umode_t devfs_perm;
-	kdev_t kdev;
-	char buf[20];
-
-	kdev = dasd_get_kdev(device);
-	if (kdev_none(kdev))
-		return -ENODEV;
-
 	/*
 	 * As long as the device is not in state DASD_STATE_NEW we want to 
 	 * keep the reference count > 0.
 	 */
 	dasd_get_device(device);
 
-#ifdef CONFIG_DEVFS_FS
-	/* Add a proc directory and the dasd device entry to devfs. */
  	sprintf(device->gdp->devfs_name, "dasd/%04x",
 		_ccw_device_get_device_number(device->cdev));
-#endif
 
-	if (device->ro_flag)
-		devfs_perm = S_IFBLK | S_IRUSR;
-	else
-		devfs_perm = S_IFBLK | S_IRUSR | S_IWUSR;
-
-	snprintf(buf, sizeof(buf), "dasd/%04x/device",
-		 _ccw_device_get_device_number(device->cdev));
-	device->devfs_entry = devfs_register(NULL, buf, 0,
-					     major(kdev),
-					     minor(kdev) << DASD_PARTN_BITS,
-					     devfs_perm,
-					     &dasd_device_operations, NULL);
 	device->state = DASD_STATE_KNOWN;
 	return 0;
 }
@@ -183,10 +158,6 @@
 static inline void
 dasd_state_known_to_new(struct dasd_device * device)
 {
-	/* Remove device entry and devfs directory. */
-	devfs_unregister(device->devfs_entry);
-	devfs_unregister(device->gdp->de);
-
 	/* Forget the discipline information. */
 	device->discipline = NULL;
 	device->state = DASD_STATE_NEW;
@@ -1721,50 +1692,51 @@
 static int
 dasd_open(struct inode *inp, struct file *filp)
 {
-	struct dasd_device *device;
+	struct gendisk *disk = inp->i_bdev->bd_disk;
+	struct dasd_device *device = disk->private_data;
 	int rc;
+
+	if (!try_module_get(device->discipline->owner))
+		return -EINVAL;
 	
 	if (dasd_probeonly) {
 		MESSAGE(KERN_INFO,
-			"No access to device (%d:%d) due to probeonly mode",
-			major(inp->i_rdev), minor(inp->i_rdev));
-		return -EPERM;
+			"No access to device %s due to probeonly mode",
+			disk->disk_name);
+		rc = -EPERM;
+		goto out;
 	}
 
-	device = inp->i_bdev->bd_disk->private_data;
+	rc = -ENODEV;
 	if (device->state < DASD_STATE_BASIC) {
 		DBF_DEV_EVENT(DBF_ERR, device, " %s",
 			      " Cannot open unrecognized device");
-		return -ENODEV;
+		rc = -ENODEV;
+		goto out;
 	}
-	rc = 0;
 
-	if (atomic_inc_return(&device->open_count) == 1) {
-		if (!try_module_get(device->discipline->owner)) {
-			/* Discipline is currently unloaded! */
-			atomic_dec(&device->open_count);
-			rc = -ENODEV;
-		}
-	}
+	atomic_inc(&device->open_count);
+	return 0;
+
+out:
+	module_put(device->discipline->owner);
 	return rc;
 }
 
 static int
 dasd_release(struct inode *inp, struct file *filp)
 {
-	struct dasd_device *device;
-
-	device = inp->i_bdev->bd_disk->private_data;
+	struct gendisk *disk = inp->i_bdev->bd_disk;
+	struct dasd_device *device = isk->private_data;
 
 	if (device->state < DASD_STATE_ACCEPT) {
 		DBF_DEV_EVENT(DBF_ERR, device, " %s",
 			      " Cannot release unrecognized device");
 		return -EINVAL;
 	}
-	if (atomic_dec_return(&device->open_count) == 0) {
-		invalidate_buffers(inp->i_rdev);
-		module_put(device->discipline->owner);
-	}
+
+	atomic_dec(&device->open_count);
+	module_put(device->discipline->owner);
 	return 0;
 }
 
@@ -2084,13 +2056,9 @@
 
 	DBF_EVENT(DBF_EMERG, "%s", "debug area created");
 
-#ifdef CONFIG_DEVFS_FS
-	if (!devfs_mk_dir("dasd")) {
-		DBF_EVENT(DBF_ALERT, "%s", "no devfs");
-		rc = -ENOSYS;
+	rc = devfs_mk_dir("dasd");
+	if (rc)
 		goto failed;
-	}
-#endif
 	rc = dasd_devmap_init();
 	if (rc)
 		goto failed;
diff -Nru a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
--- a/drivers/s390/block/dasd_devmap.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/s390/block/dasd_devmap.c	Wed Apr 30 22:28:09 2003
@@ -406,27 +406,6 @@
 }
 
 /*
- * Return kdev for a dasd device.
- */
-kdev_t
-dasd_get_kdev(struct dasd_device *device)
-{
-	struct dasd_devmap *devmap;
-	int major, minor;
-	int devno;
-
-	devno = _ccw_device_get_device_number(device->cdev);
-	devmap = dasd_devmap_from_devno(devno);
-	if (devmap == NULL)
-		return NODEV;
-	major = dasd_gendisk_index_major(devmap->devindex);
-	if (major < 0)
-		return NODEV;
-	minor = devmap->devindex % DASD_PER_MAJOR;
-	return mk_kdev(major, minor);
-}
-
-/*
  * Create a dasd device structure for cdev.
  */
 struct dasd_device *
diff -Nru a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
--- a/drivers/s390/block/dasd_int.h	Wed Apr 30 22:28:13 2003
+++ b/drivers/s390/block/dasd_int.h	Wed Apr 30 22:28:13 2003
@@ -264,7 +264,6 @@
 struct dasd_device {
 	/* Block device stuff. */
 	struct gendisk *gdp;
-	devfs_handle_t devfs_entry;
 	request_queue_t *request_queue;
 	spinlock_t request_queue_lock;
 	unsigned long blocks;		/* size of volume in blocks */
@@ -471,7 +470,6 @@
 struct dasd_device *dasd_create_device(struct ccw_device *);
 void dasd_delete_device(struct dasd_device *);
 
-kdev_t dasd_get_kdev(struct dasd_device *);
 struct dasd_device *dasd_device_from_devindex(int);
 
 int dasd_parse(void);
diff -Nru a/drivers/s390/block/xpram.c b/drivers/s390/block/xpram.c
--- a/drivers/s390/block/xpram.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/s390/block/xpram.c	Wed Apr 30 22:28:14 2003
@@ -449,7 +449,6 @@
 	offset = 0;
 	for (i = 0; i < xpram_devs; i++) {
 		struct gendisk *disk = xpram_disks[i];
-		char name[16];
 
 		xpram_devices[i].size = xpram_sizes[i] / 4;
 		xpram_devices[i].offset = offset;
@@ -460,13 +459,9 @@
 		disk->private_data = &xpram_devices[i];
 		disk->queue = &xpram_queue;
 		sprintf(disk->disk_name, "slram%d", i);
+		sprintf(disk->disk_name, "slram/%d", i);
 		set_capacity(disk, xpram_sizes[i] << 1);
 		add_disk(disk);
-		sprintf(name, "slram/%d", i);
-		devfs_register(NULL, name, DEVFS_FL_DEFAULT,
-			       disk->major, disk->first_minor,
-			       S_IFBLK | S_IRUSR | S_IWUSR,
-			       disk->fops, NULL);
 	}
 
 	return 0;
@@ -485,7 +480,6 @@
 	for (i = 0; i < xpram_devs; i++) {
 		del_gendisk(xpram_disks[i]);
 		put_disk(xpram_disks[i]);
-		devfs_remove("slram/%d", i);
 	}
 	unregister_blkdev(XPRAM_MAJOR, XPRAM_NAME);
 	devfs_remove("slram");
diff -Nru a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
--- a/drivers/s390/char/con3215.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/s390/char/con3215.c	Wed Apr 30 22:28:12 2003
@@ -840,10 +840,10 @@
 	}
 }
 
-static kdev_t
-con3215_device(struct console *c)
+static struct tty_driver *con3215_device(struct console *c, int *index)
 {
-	return mk_kdev(TTY_MAJOR, c->index + 64 );
+	*index = c->index;
+	return &tty3215_driver;
 }
 
 /*
@@ -957,7 +957,7 @@
 	struct raw3215_info *raw;
 	int retval, line;
 
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if ((line < 0) || (line >= NR_3215))
 		return -ENODEV;
 
@@ -1182,7 +1182,6 @@
 	tty3215_driver.owner = THIS_MODULE;
 	tty3215_driver.driver_name = "tty3215";
 	tty3215_driver.name = "ttyS";
-	tty3215_driver.name_base = 0;
 	tty3215_driver.major = TTY_MAJOR;
 	tty3215_driver.minor_start = 64;
 	tty3215_driver.num = NR_3215;
diff -Nru a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
--- a/drivers/s390/char/sclp_tty.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/s390/char/sclp_tty.c	Wed Apr 30 22:28:05 2003
@@ -761,7 +761,6 @@
 	sclp_tty_driver.owner = THIS_MODULE;
 	sclp_tty_driver.driver_name = "sclp_line";
 	sclp_tty_driver.name = "ttyS";
-	sclp_tty_driver.name_base = 0;
 	sclp_tty_driver.major = TTY_MAJOR;
 	sclp_tty_driver.minor_start = 64;
 	sclp_tty_driver.num = 1;
diff -Nru a/drivers/s390/char/tape.h b/drivers/s390/char/tape.h
--- a/drivers/s390/char/tape.h	Wed Apr 30 22:28:12 2003
+++ b/drivers/s390/char/tape.h	Wed Apr 30 22:28:12 2003
@@ -23,6 +23,8 @@
 #include <asm/debug.h>
 #include <asm/idals.h>
 
+struct gendisk;
+
 /*
  * macros s390 debug feature (dbf)
  */
@@ -173,6 +175,7 @@
 	struct tasklet_struct tasklet;
 	/* Current position on the tape. */
 	long block_position;
+	struct gendisk *disk;
 };
 #endif
 
diff -Nru a/drivers/s390/char/tape_block.c b/drivers/s390/char/tape_block.c
--- a/drivers/s390/char/tape_block.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/s390/char/tape_block.c	Wed Apr 30 22:28:14 2003
@@ -208,38 +208,65 @@
 int
 tapeblock_setup_device(struct tape_device * device)
 {
-	request_queue_t *blk_queue;
+	struct tape_blk_data *d = &device->blk_data;
+	request_queue_t *q = &d->request_queue;
+	struct gendisk *disk = alloc_disk(1);
 	int rc;
 
-	/* Setup request queue and initialize gendisk for this device. */
-	tasklet_init(&device->blk_data.tasklet, tapeblock_tasklet,
-		     (unsigned long) device);
-	spin_lock_init(&device->blk_data.request_queue_lock);
-	blk_queue = &device->blk_data.request_queue;
-	rc = blk_init_queue(blk_queue, tapeblock_request_fn,
-			    &device->blk_data.request_queue_lock);
-
-	elevator_exit(blk_queue);
-	rc = elevator_init(blk_queue, &elevator_noop);
-	if (rc) {
-		blk_cleanup_queue(blk_queue);
-		return rc;
-	}
+	if (!disk)
+		return -ENOMEM;
+
+	tasklet_init(&d->tasklet, tapeblock_tasklet, (unsigned long)device);
+
+	spin_lock_init(&d->request_queue_lock);
+	rc = blk_init_queue(q, tapeblock_request_fn, &d->request_queue_lock);
+	if (rc)
+		goto put_disk;
+
+	elevator_exit(q);
+	rc = elevator_init(q, &elevator_noop);
+	if (rc)
+		goto cleanup_queue;
+
 	/* FIXME: We should be able to sense the sectore size */
-	blk_queue_hardsect_size(blk_queue, TAPEBLOCK_HSEC_SIZE);
-	blk_queue_max_sectors(blk_queue, TAPEBLOCK_MAX_SEC);
-	blk_queue_max_phys_segments(blk_queue, -1L);
-	blk_queue_max_hw_segments(blk_queue, -1L);
-	blk_queue_max_segment_size(blk_queue, -1L);
-	blk_queue_segment_boundary(blk_queue, -1L);
+	blk_queue_hardsect_size(q, TAPEBLOCK_HSEC_SIZE);
+	blk_queue_max_sectors(q, TAPEBLOCK_MAX_SEC);
+	blk_queue_max_phys_segments(q, -1L);
+	blk_queue_max_hw_segments(q, -1L);
+	blk_queue_max_segment_size(q, -1L);
+	blk_queue_segment_boundary(q, -1L);
+
+	disk->major = tapeblock_major;
+	disk->first_minor = i;
+	disk->fops = &tapeblock_fops;
+	disk->private_data = device;
+	disk->queue = q;
+	set_capacity(disk, size);
+
+	sprintf(disk->disk_name, "tBLK%d", i);
+	sprintf(disk->disk_name, "tBLK/%d", i);
+
+	add_disk(disk);
+	d->disk = disk;
 	return 0;
+
+ cleanup_queue:
+	blk_cleanup_queue(q);
+ put_disk:
+	put_disk(disk);
+	return rc;
 }
 
 void
 tapeblock_cleanup_device(struct tape_device *device)
 {
-	blk_cleanup_queue(&device->blk_data.request_queue);
-	tasklet_kill(&device->blk_data.tasklet);
+	struct tape_blk_data *d = &device->blk_data;
+
+	del_gendisk(d->disk);
+	put_disk(d->disk);
+	blk_cleanup_queue(&d->request_queue);
+
+	tasklet_kill(&d->tasklet);
 }
 
 /*
@@ -272,55 +299,47 @@
 /*
  * Block frontend tape device open function.
  */
-int
-tapeblock_open(struct inode *inode, struct file *filp) {
-	struct tape_device *device;
-	int minor, rc;
-
-	MOD_INC_USE_COUNT;
-	if (major(filp->f_dentry->d_inode->i_rdev) != tapeblock_major)
-		return -ENODEV;
-	minor = minor(filp->f_dentry->d_inode->i_rdev);
-	device = tape_get_device(minor >> TAPE_MINORS_PER_DEV);
-	if (IS_ERR(device)) {
-		MOD_DEC_USE_COUNT;
-		return PTR_ERR(device);
-	}
-	DBF_EVENT(6, "TBLOCK:open:  %x\n", device->first_minor);
+static int
+tapeblock_open(struct inode *inode, struct file *filp)
+{
+	struct gendisk *disk = inp->i_bdev->bd_disk;
+	struct tape_device *device = disk->private_data;
+	int rc;
+
 	rc = tape_open(device);
-	if (rc == 0) {
-		rc = tape_assign(device);
-		if (rc == 0) {
-			device->blk_data.block_position = -1;
-			rc = tapeblock_mediumdetect(device);
-			if (rc == 0) {
-				filp->private_data = device;
-				return 0;
-			}
-			tape_unassign(device);
-		}
-		tape_release(device);
-	}
+	if (rc)
+		goto put_device;
+	rc = tape_assign(device);
+	if (rc)
+		goto release;
+	device->blk_data.block_position = -1;
+	rc = tapeblock_mediumdetect(device);
+	if (rc)
+		goto unassign;
+	return 0;
+
+ unassign:
+	tape_unassign(device);
+ release:
+	tape_release(device);
+ put_device:
 	tape_put_device(device);
-	MOD_DEC_USE_COUNT;
 	return rc;
 }
 
 /*
  * Block frontend tape device release function.
  */
-int
-tapeblock_release(struct inode *inode, struct file *filp) {
-	struct tape_device *device;
-
-	/* Remove all buffers at device close. */
-	/* FIXME: can we do that a tape unload ? */
-	invalidate_buffers(inode->i_rdev);
-	device = (struct tape_device *) filp->private_data;
+static int
+tapeblock_release(struct inode *inode, struct file *filp)
+{
+	struct gendisk *disk = inp->i_bdev->bd_disk;
+	struct tape_device *device = disk->private_data;
+
 	tape_release(device);
 	tape_unassign(device);
 	tape_put_device(device);
-	MOD_DEC_USE_COUNT;
+
 	return 0;
 }
 
diff -Nru a/drivers/s390/char/tuball.c b/drivers/s390/char/tuball.c
--- a/drivers/s390/char/tuball.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/s390/char/tuball.c	Wed Apr 30 22:28:15 2003
@@ -82,7 +82,7 @@
  * Can't have this driver a module & support console at the same time
  */
 #ifdef CONFIG_TN3270_CONSOLE
-static kdev_t tub3270_con_device(struct console *);
+static struct tty_driver *tub3270_con_device(struct console *, int *);
 static void tub3270_con_unblank(void);
 static void tub3270_con_write(struct console *, const char *,
 	unsigned int);
@@ -144,10 +144,11 @@
 
 #endif
 
-static kdev_t
-tub3270_con_device(struct console *conp)
+static struct tty_driver *tub3270_con_device(struct console *conp, int *index)
 {
-	return tub_mkdev(IBM_TTY3270_MAJOR, conp->index + 1);
+	*index = conp->index + 1;
+	extern struct tty_driver tty3270_driver;
+	return &tty3270_driver;
 }
 
 static void
diff -Nru a/drivers/s390/char/tubfs.c b/drivers/s390/char/tubfs.c
--- a/drivers/s390/char/tubfs.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/s390/char/tubfs.c	Wed Apr 30 22:28:11 2003
@@ -34,10 +34,6 @@
 };
 
 #ifdef CONFIG_DEVFS_FS
-static devfs_handle_t fs3270_devfs_dir;
-static devfs_handle_t fs3270_devfs_tub;
-extern struct file_operations tty_fops;
-
 void fs3270_devfs_register(tub_t *tubp)
 {
 	char name[16];
@@ -48,7 +44,7 @@
 		       S_IFCHR | S_IRUSR | S_IWUSR, &fs3270_fops, NULL);
 	sprintf(name, "tty%.4x", tubp->devno);
 	tty_register_devfs_name(&tty3270_driver, 0, tubp->minor,
-				fs3270_devfs_dir, name);
+				NULL, name);
 }
 
 void fs3270_devfs_unregister(tub_t *tubp)
@@ -72,13 +68,11 @@
 			IBM_FS3270_MAJOR, rc);
 		return -1;
 	}
-#ifdef CONFIG_DEVFS_FS
-	fs3270_devfs_dir = devfs_mk_dir("3270");
-	fs3270_devfs_tub = devfs_register(NULL, "3270/tub", 0,
+	devfs_mk_dir("3270");
+	devfs_register(NULL, "3270/tub", 0,
 			       IBM_FS3270_MAJOR, 0,
 			       S_IFCHR | S_IRUGO | S_IWUGO, 
 			       &fs3270_fops, NULL);
-#endif
 	fs3270_major = IBM_FS3270_MAJOR;
 	return 0;
 }
@@ -90,10 +84,8 @@
 fs3270_fini(void)
 {
 	if (fs3270_major != -1) {
-#ifdef CONFIG_DEVFS_FS
-		devfs_unregister(fs3270_devfs_tub);
-		devfs_unregister(fs3270_devfs_dir);
-#endif
+		devfs_remove("3270");
+		devfs_remove("3270/tub");
 		unregister_chrdev(fs3270_major, "fs3270");
 		fs3270_major = -1;
 	}
diff -Nru a/drivers/s390/char/tubio.h b/drivers/s390/char/tubio.h
--- a/drivers/s390/char/tubio.h	Wed Apr 30 22:28:09 2003
+++ b/drivers/s390/char/tubio.h	Wed Apr 30 22:28:09 2003
@@ -338,7 +338,6 @@
 extern enum tubwhat tty3270_proc_what;
 extern struct tty_driver tty3270_driver;
 #ifdef CONFIG_DEVFS_FS
-extern devfs_handle_t fs3270_devfs_dir;
 extern void fs3270_devfs_register(tub_t *);
 extern void fs3270_devfs_unregister(tub_t *);
 #endif
@@ -384,17 +383,9 @@
 {
 	unsigned int minor = minor(ip->i_rdev);
 	tub_t *tubp = NULL;
-	if (minor == 0 && current->tty != NULL) {
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
-#ifdef CONFIG_TN3270_CONSOLE
-		if (tub3270_con_tubp != NULL &&
-		    current->tty->device == S390_CONSOLE_DEV)
-			minor = tub3270_con_tubp->minor;
-		else
-#endif
-#endif
-		if (tub_major(current->tty->device) == IBM_TTY3270_MAJOR)
-			minor = tub_minor(current->tty->device);
+	if (minor == 0 && current->tty) {
+		if (current->tty->driver == &tty3270_driver)
+			minor = current->tty->index;
 	}
 	if (minor <= tubnummins && minor > 0)
 		tubp = (*tubminors)[minor];
@@ -406,18 +397,11 @@
  */
 extern inline tub_t *TTY2TUB(struct tty_struct *tty)
 {
-	unsigned int minor = minor(tty->device);
+	unsigned index = tty->index;
 	tub_t *tubp = NULL;
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
-#ifdef CONFIG_TN3270_CONSOLE
-	if (tty->device == S390_CONSOLE_DEV)
-		tubp = tub3270_con_tubp;
-	else
-#endif
-#endif
-	if (minor <= tubnummins && minor > 0)
-		tubp = (*tubminors)[minor];
+	if (index <= tubnummins && index > 0)
+		tubp = (*tubminors)[index];
 	return tubp;
 }
 
diff -Nru a/drivers/s390/char/tubtty.c b/drivers/s390/char/tubtty.c
--- a/drivers/s390/char/tubtty.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/s390/char/tubtty.c	Wed Apr 30 22:28:15 2003
@@ -539,16 +539,8 @@
 	 */
 	tubp = NULL;
 	tty = current->tty;
-	if (tty) {
-		if (tub_major(tty->device) == IBM_TTY3270_MAJOR)
-			tubp = (*tubminors)[tub_minor(tty->device)];
-#ifdef CONFIG_TN3270_CONSOLE
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
-		if (CONSOLE_IS_3270 && tty->device == S390_CONSOLE_DEV)
-			tubp = tub3270_con_tubp;
-#endif /* LINUX_VERSION_CODE */
-#endif /* CONFIG_TN3270_CONSOLE */
-	}
+	if (tty && tty->driver == &tty3270_driver)
+		tubp = (*tubminors)[tty->index];
 	if (tubp) {
 		if ((rc = tty3270_aid_set(tubp, mybuf, mycount + 1)))
 			return rc > 0? count: rc;
diff -Nru a/drivers/s390/net/ctctty.c b/drivers/s390/net/ctctty.c
--- a/drivers/s390/net/ctctty.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/s390/net/ctctty.c	Wed Apr 30 22:28:10 2003
@@ -332,17 +332,17 @@
  ************************************************************/
 
 static inline int
-ctc_tty_paranoia_check(ctc_tty_info * info, kdev_t device, const char *routine)
+ctc_tty_paranoia_check(ctc_tty_info * info, char *name, const char *routine)
 {
 #ifdef MODEM_PARANOIA_CHECK
 	if (!info) {
-		printk(KERN_WARNING "ctc_tty: null info_struct for (%d, %d) in %s\n",
-		       major(device), minor(device), routine);
+		printk(KERN_WARNING "ctc_tty: null info_struct for %s in %s\n",
+		       name, routine);
 		return 1;
 	}
 	if (info->magic != CTC_ASYNC_MAGIC) {
-		printk(KERN_WARNING "ctc_tty: bad magic for info struct (%d, %d) in %s\n",
-		       major(device), minor(device), routine);
+		printk(KERN_WARNING "ctc_tty: bad magic for info struct %s in %s\n",
+		       name, routine);
 		return 1;
 	}
 #endif
@@ -502,7 +502,7 @@
 
 	if (ctc_tty_shuttingdown)
 		return 0;
-	if (ctc_tty_paranoia_check(info, tty->device, "ctc_tty_write"))
+	if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_write"))
 		return 0;
 	if (!tty)
 		return 0;
@@ -551,7 +551,7 @@
 {
 	ctc_tty_info *info = (ctc_tty_info *) tty->driver_data;
 
-	if (ctc_tty_paranoia_check(info, tty->device, "ctc_tty_write_room"))
+	if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_write_room"))
 		return 0;
 	return CTC_TTY_XMIT_SIZE;
 }
@@ -561,7 +561,7 @@
 {
 	ctc_tty_info *info = (ctc_tty_info *) tty->driver_data;
 
-	if (ctc_tty_paranoia_check(info, tty->device, "ctc_tty_chars_in_buffer"))
+	if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_chars_in_buffer"))
 		return 0;
 	return 0;
 }
@@ -576,7 +576,7 @@
 		return;
 	spin_lock_irqsave(&ctc_tty_lock, flags);
 	info = (ctc_tty_info *) tty->driver_data;
-	if (ctc_tty_paranoia_check(info, tty->device, "ctc_tty_flush_buffer")) {
+	if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_flush_buffer")) {
 		spin_unlock_irqrestore(&ctc_tty_lock, flags);
 		return;
 	}
@@ -596,7 +596,7 @@
 
 	if (ctc_tty_shuttingdown)
 		return;
-	if (ctc_tty_paranoia_check(info, tty->device, "ctc_tty_flush_chars"))
+	if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_flush_chars"))
 		return;
 	if (tty->stopped || tty->hw_stopped || (!skb_queue_len(&info->tx_queue)))
 		return;
@@ -616,7 +616,7 @@
 {
 	ctc_tty_info *info = (ctc_tty_info *) tty->driver_data;
 
-	if (ctc_tty_paranoia_check(info, tty->device, "ctc_tty_throttle"))
+	if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_throttle"))
 		return;
 	info->mcr &= ~UART_MCR_RTS;
 	if (I_IXOFF(tty))
@@ -629,7 +629,7 @@
 {
 	ctc_tty_info *info = (ctc_tty_info *) tty->driver_data;
 
-	if (ctc_tty_paranoia_check(info, tty->device, "ctc_tty_unthrottle"))
+	if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_unthrottle"))
 		return;
 	info->mcr |= UART_MCR_RTS;
 	if (I_IXOFF(tty))
@@ -744,7 +744,7 @@
 	int error;
 	int retval;
 
-	if (ctc_tty_paranoia_check(info, tty->device, "ctc_tty_ioctl"))
+	if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_ioctl"))
 		return -ENODEV;
 	if (tty->flags & (1 << TTY_IO_ERROR))
 		return -EIO;
@@ -973,17 +973,17 @@
 	int retval,
 	 line;
 
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if (line < 0 || line > CTC_TTY_MAX_DEVICES)
 		return -ENODEV;
 	info = &driver->info[line];
-	if (ctc_tty_paranoia_check(info, tty->device, "ctc_tty_open"))
+	if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_open"))
 		return -ENODEV;
 	if (!info->netdev)
 		return -ENODEV;
 #ifdef CTC_DEBUG_MODEM_OPEN
-	printk(KERN_DEBUG "ctc_tty_open %s%d, count = %d\n", tty->driver.name,
-	       info->line, info->count);
+	printk(KERN_DEBUG "ctc_tty_open %s, count = %d\n", tty->name,
+	       info->count);
 #endif
 	spin_lock_irqsave(&ctc_tty_lock, saveflags);
 	info->count++;
@@ -1012,7 +1012,7 @@
 		ctc_tty_change_speed(info);
 	}
 #ifdef CTC_DEBUG_MODEM_OPEN
-	printk(KERN_DEBUG "ctc_tty_open %s%d successful...\n", CTC_TTY_NAME, info->line);
+	printk(KERN_DEBUG "ctc_tty_open %s successful...\n", tty->name);
 #endif
 	return 0;
 }
@@ -1024,7 +1024,7 @@
 	ulong flags;
 	ulong timeout;
 
-	if (!info || ctc_tty_paranoia_check(info, tty->device, "ctc_tty_close"))
+	if (!info || ctc_tty_paranoia_check(info, tty->name, "ctc_tty_close"))
 		return;
 	spin_lock_irqsave(&ctc_tty_lock, flags);
 	if (tty_hung_up_p(filp)) {
@@ -1091,8 +1091,8 @@
 		}
 	}
 	ctc_tty_shutdown(info);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	info->tty = 0;
@@ -1119,7 +1119,7 @@
 	ctc_tty_info *info = (ctc_tty_info *)tty->driver_data;
 	unsigned long saveflags;
 
-	if (ctc_tty_paranoia_check(info, tty->device, "ctc_tty_hangup"))
+	if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_hangup"))
 		return;
 	ctc_tty_shutdown(info);
 	info->count = 0;
diff -Nru a/drivers/sbus/char/aurora.c b/drivers/sbus/char/aurora.c
--- a/drivers/sbus/char/aurora.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/sbus/char/aurora.c	Wed Apr 30 22:28:05 2003
@@ -107,7 +107,7 @@
 DECLARE_TASK_QUEUE(tq_aurora);
 
 static inline int aurora_paranoia_check(struct Aurora_port const * port,
-				    kdev_t device, const char *routine)
+				    char *name, const char *routine)
 {
 #ifdef AURORA_PARANOIA_CHECK
 	static const char *badmagic =
@@ -116,11 +116,11 @@
 		KERN_DEBUG "aurora: Warning: null aurora port for device %s in %s\n";
 
 	if (!port) {
-		printk(badinfo, cdevname(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (port->magic != AURORA_MAGIC) {
-		printk(badmagic, cdevname(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -265,7 +265,7 @@
 return 0;
 }
 
-static void aurora_interrupt(int irq, void * dev_id, struct pt_regs * regs);
+static irqreturn_t aurora_interrupt(int irq, void * dev_id, struct pt_regs * regs);
 
 /* Main probing routine, also sets irq. */
 static int aurora_probe(void)
@@ -701,7 +701,7 @@
 }
 
 /* The main interrupt processing routine */
-static void aurora_interrupt(int irq, void * dev_id, struct pt_regs * regs)
+static irqreturn_t aurora_interrupt(int irq, void * dev_id, struct pt_regs * regs)
 {
 	unsigned char status;
 	unsigned char ack,chip/*,chip_id*/;
@@ -719,7 +719,7 @@
 /* old	bp = IRQ_to_board[irq&0x0f];*/
 	
 	if (!bp || !(bp->flags & AURORA_BOARD_ACTIVE))
-		return;
+		return IRQ_NONE;
 
 /*	The while() below takes care of this.
 	status = sbus_readb(&bp->r[0]->r[CD180_SRSR]);
@@ -727,7 +727,7 @@
 	printk("mumu: %02x\n", status);
 #endif
 	if (!(status&SRSR_ANYINT))
-		return; * Nobody has anything to say, so exit *
+		return IRQ_NONE; * Nobody has anything to say, so exit *
 */
 	while ((loop++ < 48) &&
 	       (status = sbus_readb(&bp->r[0]->r[CD180_SRSR]) & SRSR_ANYINT)){
@@ -875,6 +875,8 @@
 		}
 	}
 #endif
+
+	return IRQ_HANDLED;
 }
 
 #ifdef AURORA_INT_DEBUG
@@ -1419,7 +1421,7 @@
 	printk("aurora_open: start\n");
 #endif
 	
-	board = AURORA_BOARD(minor(tty->device));
+	board = AURORA_BOARD(tty->index);
 	if (board > AURORA_NBOARD ||
 	    !(aurora_board[board].flags & AURORA_BOARD_PRESENT)) {
 #ifdef AURORA_DEBUG
@@ -1430,8 +1432,8 @@
 	}
 	
 	bp = &aurora_board[board];
-	port = aurora_port + board * AURORA_NPORT * AURORA_NCD180 + AURORA_PORT(minor(tty->device));
-	if (aurora_paranoia_check(port, tty->device, "aurora_open")) {
+	port = aurora_port + board * AURORA_NPORT * AURORA_NCD180 + AURORA_PORT(tty->index);
+	if ((aurora_paranoia_check(port, tty->name, "aurora_open")) {
 #ifdef AURORA_DEBUG
 		printk("aurora_open: error paranoia check\n");
 #endif
@@ -1483,7 +1485,7 @@
 	printk("aurora_close: start\n");
 #endif
 	
-	if (!port || aurora_paranoia_check(port, tty->device, "close"))
+	if (!port || (aurora_paranoia_check(port, tty->name, "close"))
 		return;
 	
 	chip = AURORA_CD180(port_No(port));
@@ -1562,8 +1564,8 @@
 	printk("aurora_close: shutdown_port\n");
 #endif
 	aurora_shutdown_port(bp, port);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -1597,7 +1599,7 @@
 #ifdef AURORA_DEBUG
 	printk("aurora_write: start %d\n",count);
 #endif
-	if (aurora_paranoia_check(port, tty->device, "aurora_write"))
+	if ((aurora_paranoia_check(port, tty->name, "aurora_write"))
 		return 0;
 		
 	chip = AURORA_CD180(port_No(port));
@@ -1679,7 +1681,7 @@
 #ifdef AURORA_DEBUG
 	printk("aurora_put_char: start %c\n",ch);
 #endif
-	if (aurora_paranoia_check(port, tty->device, "aurora_put_char"))
+	if ((aurora_paranoia_check(port, tty->name, "aurora_put_char"))
 		return;
 
 	if (!tty || !port->xmit_buf)
@@ -1710,7 +1712,7 @@
 /*#ifdef AURORA_DEBUG
 	printk("aurora_flush_chars: start\n");
 #endif*/
-	if (aurora_paranoia_check(port, tty->device, "aurora_flush_chars"))
+	if ((aurora_paranoia_check(port, tty->name, "aurora_flush_chars"))
 		return;
 		
 	chip = AURORA_CD180(port_No(port));
@@ -1740,7 +1742,7 @@
 #ifdef AURORA_DEBUG
 	printk("aurora_write_room: start\n");
 #endif
-	if (aurora_paranoia_check(port, tty->device, "aurora_write_room"))
+	if ((aurora_paranoia_check(port, tty->name, "aurora_write_room"))
 		return 0;
 
 	ret = SERIAL_XMIT_SIZE - port->xmit_cnt - 1;
@@ -1756,7 +1758,7 @@
 {
 	struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
 				
-	if (aurora_paranoia_check(port, tty->device, "aurora_chars_in_buffer"))
+	if ((aurora_paranoia_check(port, tty->name, "aurora_chars_in_buffer"))
 		return 0;
 	
 	return port->xmit_cnt;
@@ -1770,7 +1772,7 @@
 #ifdef AURORA_DEBUG
 	printk("aurora_flush_buffer: start\n");
 #endif
-	if (aurora_paranoia_check(port, tty->device, "aurora_flush_buffer"))
+	if ((aurora_paranoia_check(port, tty->name, "aurora_flush_buffer"))
 		return;
 
 	save_flags(flags); cli();
@@ -1999,7 +2001,7 @@
 #ifdef AURORA_DEBUG
 	printk("aurora_ioctl: start\n");
 #endif
-	if (aurora_paranoia_check(port, tty->device, "aurora_ioctl"))
+	if ((aurora_paranoia_check(port, tty->name, "aurora_ioctl"))
 		return -ENODEV;
 	
 	switch (cmd) {
@@ -2060,7 +2062,7 @@
 #ifdef AURORA_DEBUG
 	printk("aurora_throttle: start\n");
 #endif
-	if (aurora_paranoia_check(port, tty->device, "aurora_throttle"))
+	if ((aurora_paranoia_check(port, tty->name, "aurora_throttle"))
 		return;
 	
 	bp = port_Board(port);
@@ -2092,7 +2094,7 @@
 #ifdef AURORA_DEBUG
 	printk("aurora_unthrottle: start\n");
 #endif
-	if (aurora_paranoia_check(port, tty->device, "aurora_unthrottle"))
+	if ((aurora_paranoia_check(port, tty->name, "aurora_unthrottle"))
 		return;
 	
 	bp = port_Board(port);
@@ -2127,7 +2129,7 @@
 #ifdef AURORA_DEBUG
 	printk("aurora_stop: start\n");
 #endif
-	if (aurora_paranoia_check(port, tty->device, "aurora_stop"))
+	if ((aurora_paranoia_check(port, tty->name, "aurora_stop"))
 		return;
 	
 	bp = port_Board(port);
@@ -2157,7 +2159,7 @@
 #ifdef AURORA_DEBUG
 	printk("aurora_start: start\n");
 #endif
-	if (aurora_paranoia_check(port, tty->device, "aurora_start"))
+	if ((aurora_paranoia_check(port, tty->name, "aurora_start"))
 		return;
 	
 	bp = port_Board(port);
@@ -2213,7 +2215,7 @@
 #ifdef AURORA_DEBUG
 	printk("aurora_hangup: start\n");
 #endif
-	if (aurora_paranoia_check(port, tty->device, "aurora_hangup"))
+	if ((aurora_paranoia_check(port, tty->name, "aurora_hangup"))
 		return;
 	
 	bp = port_Board(port);
@@ -2237,7 +2239,7 @@
 #ifdef AURORA_DEBUG
 	printk("aurora_set_termios: start\n");
 #endif
-	if (aurora_paranoia_check(port, tty->device, "aurora_set_termios"))
+	if ((aurora_paranoia_check(port, tty->name, "aurora_set_termios"))
 		return;
 	
 	if (tty->termios->c_cflag == old_termios->c_cflag &&
diff -Nru a/drivers/sbus/char/bbc_i2c.c b/drivers/sbus/char/bbc_i2c.c
--- a/drivers/sbus/char/bbc_i2c.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/sbus/char/bbc_i2c.c	Wed Apr 30 22:28:15 2003
@@ -331,7 +331,7 @@
 EXPORT_SYMBOL(bbc_i2c_write_buf);
 EXPORT_SYMBOL(bbc_i2c_read_buf);
 
-static void bbc_i2c_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t bbc_i2c_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct bbc_i2c_bus *bp = dev_id;
 
@@ -341,6 +341,8 @@
 	if (bp->waiting &&
 	    !(readb(bp->i2c_control_regs + 0x0) & I2C_PCF_PIN))
 		wake_up(&bp->wq);
+
+	return IRQ_HANDLED;
 }
 
 static void __init reset_one_i2c(struct bbc_i2c_bus *bp)
diff -Nru a/drivers/sbus/char/cpwatchdog.c b/drivers/sbus/char/cpwatchdog.c
--- a/drivers/sbus/char/cpwatchdog.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/sbus/char/cpwatchdog.c	Wed Apr 30 22:28:17 2003
@@ -201,7 +201,7 @@
 #ifdef WD_DEBUG
 static void wd_dumpregs(void);
 #endif
-static void wd_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t wd_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static void wd_toggleintr(struct wd_timer* pTimer, int enable);
 static void wd_pingtimer(struct wd_timer* pTimer);
 static void wd_starttimer(struct wd_timer* pTimer);
@@ -325,13 +325,11 @@
 		wd_dev.initialized = 1;
 	}
 
-	MOD_INC_USE_COUNT;
 	return(0);
 }
 
 static int wd_release(struct inode *inode, struct file *file)
 {
-	MOD_DEC_USE_COUNT;
 	return 0;
 }
 
@@ -444,7 +442,7 @@
 #endif /* ifdef WD_DEBUG */
 }
 
-static void wd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t wd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	/* Only WD0 will interrupt-- others are NMI and we won't
 	 * see them here....
@@ -456,7 +454,7 @@
 		wd_dev.watchdog[WD0_ID].runstatus |=  WD_STAT_SVCD;
 	}
 	spin_unlock_irq(&wd_dev.lock);
-	return;
+	return IRQ_HANDLED;
 }
 
 static struct file_operations wd_fops = {
diff -Nru a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c
--- a/drivers/sbus/char/envctrl.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/sbus/char/envctrl.c	Wed Apr 30 22:28:05 2003
@@ -707,7 +707,6 @@
 envctrl_open(struct inode *inode, struct file *file)
 {
 	file->private_data = 0;
-	MOD_INC_USE_COUNT;
 	return 0;
 }
 
@@ -717,7 +716,6 @@
 static int
 envctrl_release(struct inode *inode, struct file *file)
 {
-	MOD_DEC_USE_COUNT;
 	return 0;
 }
 
diff -Nru a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c
--- a/drivers/sbus/char/openprom.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/sbus/char/openprom.c	Wed Apr 30 22:28:13 2003
@@ -40,6 +40,7 @@
 #include <linux/string.h>
 #include <linux/miscdevice.h>
 #include <linux/init.h>
+#include <linux/fs.h>
 #include <asm/oplib.h>
 #include <asm/system.h>
 #include <asm/uaccess.h>
diff -Nru a/drivers/sbus/char/uctrl.c b/drivers/sbus/char/uctrl.c
--- a/drivers/sbus/char/uctrl.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/sbus/char/uctrl.c	Wed Apr 30 22:28:19 2003
@@ -217,10 +217,11 @@
 	return 0;
 }
 
-void uctrl_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t uctrl_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct uctrl_driver *driver = (struct uctrl_driver *)dev_id;
 	printk("in uctrl_interrupt\n");
+	return IRQ_HANDLED;
 }
 
 static struct file_operations uctrl_fops = {
diff -Nru a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
--- a/drivers/scsi/3w-xxxx.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/scsi/3w-xxxx.c	Wed Apr 30 22:28:17 2003
@@ -213,7 +213,6 @@
 static int tw_chrdev_release(struct inode *inode, struct file *file);
 static int tw_copy_info(TW_Info *info, char *fmt, ...);
 static void tw_copy_mem_info(TW_Info *info, char *data, int len);
-static void tw_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
 static int tw_halt(struct notifier_block *nb, ulong event, void *buf);
 static int tw_map_scsi_sg_data(struct pci_dev *pdev, Scsi_Cmnd *cmd);
 static u32 tw_map_scsi_single_data(struct pci_dev *pdev, Scsi_Cmnd *cmd);
@@ -226,10 +225,10 @@
 
 /* File operations struct for character device */
 static struct file_operations tw_fops = {
-	owner: THIS_MODULE,
-	ioctl: tw_chrdev_ioctl,
-	open: tw_chrdev_open,
-	release: tw_chrdev_release
+	.owner		= THIS_MODULE,
+	.ioctl		= tw_chrdev_ioctl,
+	.open		= tw_chrdev_open,
+	.release	= tw_chrdev_release
 };
 
 /* Globals */
@@ -1471,7 +1470,8 @@
 } /* End tw_initialize_units() */
 
 /* This function is the interrupt service routine */
-static void tw_interrupt(int irq, void *dev_instance, struct pt_regs *regs) 
+static irqreturn_t tw_interrupt(int irq, void *dev_instance,
+					struct pt_regs *regs) 
 {
 	int request_id;
 	u32 status_reg_addr, status_reg_value;
@@ -1481,12 +1481,13 @@
 	int error = 0, retval = 0;
 	unsigned long flags = 0;
 	TW_Command *command_packet;
+	int handled = 0;
 
 	dprintk(KERN_WARNING "3w-xxxx: tw_interrupt()\n");
 
 	/* See if we are already running on another processor */
 	if (test_and_set_bit(TW_IN_INTR, &tw_dev->flags))
-		return;
+		return IRQ_NONE;
 
 	/* Get the host lock for io completions */
 	spin_lock_irqsave(tw_dev->host->host_lock, flags);
@@ -1494,6 +1495,7 @@
 	/* See if the interrupt matches this instance */
 	if (tw_dev->tw_pci_dev->irq == irq) {
 
+		handled = 1;
 		/* Make sure io isn't queueing */
 		spin_lock(&tw_dev->tw_lock);
 
@@ -1683,6 +1685,7 @@
 
 	spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
 	clear_bit(TW_IN_INTR, &tw_dev->flags);
+	return IRQ_RETVAL(handled);
 } /* End tw_interrupt() */
 
 /* This function handles ioctls from userspace to the driver */
diff -Nru a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
--- a/drivers/scsi/53c700.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/scsi/53c700.c	Wed Apr 30 22:28:05 2003
@@ -133,6 +133,7 @@
 #include <linux/blk.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/interrupt.h>
 
 #include "scsi.h"
 #include "hosts.h"
@@ -1432,7 +1433,7 @@
 	return 1;
 }
 
-void
+irqreturn_t
 NCR_700_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct Scsi_Host *host = (struct Scsi_Host *)dev_id;
@@ -1442,6 +1443,7 @@
 	__u32 resume_offset = 0;
 	__u8 pun = 0xff, lun = 0xff;
 	unsigned long flags;
+	int handled = 0;
 
 	/* Use the host lock to serialise acess to the 53c700
 	 * hardware.  Note: In future, we may need to take the queue
@@ -1457,6 +1459,7 @@
 		Scsi_Cmnd *SCp = hostdata->cmd;
 		enum NCR_700_Host_State state;
 
+		handled = 1;
 		state = hostdata->state;
 		SCp = hostdata->cmd;
 
@@ -1697,6 +1700,7 @@
 	}
  out_unlock:
 	spin_unlock_irqrestore(host->host_lock, flags);
+	return IRQ_RETVAL(handled);
 }
 
 /* FIXME: Need to put some proc information in and plumb it
diff -Nru a/drivers/scsi/53c700.h b/drivers/scsi/53c700.h
--- a/drivers/scsi/53c700.h	Wed Apr 30 22:28:04 2003
+++ b/drivers/scsi/53c700.h	Wed Apr 30 22:28:04 2003
@@ -8,6 +8,8 @@
 #ifndef _53C700_H
 #define _53C700_H
 
+#include <linux/interrupt.h>
+
 #include <asm/io.h>
 
 /* Turn on for general debugging---too verbose for normal use */
@@ -52,7 +54,7 @@
 /* These are the externally used routines */
 struct Scsi_Host *NCR_700_detect(Scsi_Host_Template *, struct NCR_700_Host_Parameters *);
 int NCR_700_release(struct Scsi_Host *host);
-void NCR_700_intr(int, void *, struct pt_regs *);
+irqreturn_t NCR_700_intr(int, void *, struct pt_regs *);
 
 
 enum NCR_700_Host_State {
diff -Nru a/drivers/scsi/53c7xx.c b/drivers/scsi/53c7xx.c
--- a/drivers/scsi/53c7xx.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/scsi/53c7xx.c	Wed Apr 30 22:28:20 2003
@@ -6056,7 +6056,7 @@
 	(struct NCR53c7x0_hostdata *) host->hostdata[0];
     struct NCR53c7x0_cmd *cmd, *tmp;
     shutdown (host);
-    if (host->irq != IRQ_NONE)
+    if (host->irq != SCSI_IRQ_NONE)
 	{
 	    int irq_count;
 	    struct Scsi_Host *tmp;
diff -Nru a/drivers/scsi/53c7xx.h b/drivers/scsi/53c7xx.h
--- a/drivers/scsi/53c7xx.h	Wed Apr 30 22:28:03 2003
+++ b/drivers/scsi/53c7xx.h	Wed Apr 30 22:28:03 2003
@@ -1450,7 +1450,7 @@
 
 };
 
-#define IRQ_NONE	255
+#define SCSI_IRQ_NONE	255
 #define DMA_NONE	255
 #define IRQ_AUTO	254
 #define DMA_AUTO	254
diff -Nru a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
--- a/drivers/scsi/BusLogic.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/scsi/BusLogic.c	Wed Apr 30 22:28:17 2003
@@ -3339,7 +3339,7 @@
   Adapters.
 */
 
-static void BusLogic_InterruptHandler(int IRQ_Channel,
+static irqreturn_t BusLogic_InterruptHandler(int IRQ_Channel,
 				      void *DeviceIdentifier,
 				      Registers_T *InterruptRegisters)
 {
@@ -3420,6 +3420,7 @@
     Release exclusive access to Host Adapter.
   */
   BusLogic_ReleaseHostAdapterLockIH(HostAdapter, &ProcessorFlags);
+  return IRQ_HANDLED;
 }
 
 
@@ -4261,7 +4262,7 @@
       PartitionTable_T *FirstPartitionEntry = (PartitionTable_T *) buf;
       PartitionTable_T *PartitionEntry = FirstPartitionEntry;
       int SavedCylinders = DiskParameters->Cylinders, PartitionNumber;
-      unsigned char PartitionEntryEndHead, PartitionEntryEndSector;
+      unsigned char PartitionEntryEndHead=0, PartitionEntryEndSector=0;
       for (PartitionNumber = 0; PartitionNumber < 4; PartitionNumber++)
 	{
 	  PartitionEntryEndHead = PartitionEntry->end_head;
diff -Nru a/drivers/scsi/BusLogic.h b/drivers/scsi/BusLogic.h
--- a/drivers/scsi/BusLogic.h	Wed Apr 30 22:28:09 2003
+++ b/drivers/scsi/BusLogic.h	Wed Apr 30 22:28:09 2003
@@ -1763,7 +1763,7 @@
 */
 
 static void BusLogic_QueueCompletedCCB(BusLogic_CCB_T *);
-static void BusLogic_InterruptHandler(int, void *, Registers_T *);
+static irqreturn_t BusLogic_InterruptHandler(int, void *, Registers_T *);
 static int BusLogic_ResetHostAdapter(BusLogic_HostAdapter_T *,
 				     SCSI_Command_T *, unsigned int);
 static void BusLogic_Message(BusLogic_MessageLevel_T, char *,
diff -Nru a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
--- a/drivers/scsi/Kconfig	Wed Apr 30 22:28:16 2003
+++ b/drivers/scsi/Kconfig	Wed Apr 30 22:28:16 2003
@@ -8,7 +8,7 @@
 	  If you want to use a SCSI hard disk or the SCSI or parallel port
 	  version of the IOMEGA ZIP drive under Linux, say Y and read the
 	  SCSI-HOWTO, the Disk-HOWTO and the Multi-Disk-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. This is NOT for SCSI
+	  <http://www.tldp.org/docs.html#howto>. This is NOT for SCSI
 	  CD-ROMs.
 
 	  This driver is also available as a module ( = code which can be
@@ -26,7 +26,7 @@
 	---help---
 	  If you want to use a SCSI tape drive under Linux, say Y and read the
 	  SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, and
+	  <http://www.tldp.org/docs.html#howto>, and
 	  <file:Documentation/scsi/st.txt> in the kernel source.  This is NOT for
 	  SCSI CD-ROMs.
 
@@ -48,7 +48,7 @@
 	  tape drives (ADR-x0) that supports the standard SCSI-2 commands for
 	  tapes (QIC-157) and can be driven by the standard driver st.
 	  For more information, you may have a look at the SCSI-HOWTO
-	  <http://www.linuxdoc.org/docs.html#howto>  and
+	  <http://www.tldp.org/docs.html#howto>  and
 	  <file:Documentation/scsi/osst.txt>  in the kernel source.
 	  More info on the OnStream driver may be found on
 	  <http://linux1.onstream.nl/test/>
@@ -67,7 +67,7 @@
 	---help---
 	  If you want to use a SCSI CD-ROM under Linux, say Y and read the
 	  SCSI-HOWTO and the CD-ROM-HOWTO at
-	  <http://www.linuxdoc.org/docs.html#howto>. Also make sure to say Y
+	  <http://www.tldp.org/docs.html#howto>. Also make sure to say Y
 	  or M to "ISO 9660 CD-ROM file system support" later.
 
 	  This driver is also available as a module ( = code which can be
@@ -238,7 +238,7 @@
 	  must be manually specified in this case.
 
 	  It is explained in section 3.3 of the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. You might also want to
+	  <http://www.tldp.org/docs.html#howto>. You might also want to
 	  read the file <file:Documentation/scsi/aha152x.txt>.
 
 	  This driver is also available as a module ( = code which can be
@@ -252,7 +252,7 @@
 	---help---
 	  This is support for a SCSI host adapter.  It is explained in section
 	  3.4 of the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  Note that Trantor was
+	  <http://www.tldp.org/docs.html#howto>.  Note that Trantor was
 	  purchased by Adaptec, and some former Trantor products are being
 	  sold under the Adaptec name.  If it doesn't work out of the box, you
 	  may have to change some settings in <file:drivers/scsi/aha1542.h>.
@@ -268,7 +268,7 @@
 	---help---
 	  This is support for a SCSI host adapter.  It is explained in section
 	  3.5 of the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  If it doesn't work out
+	  <http://www.tldp.org/docs.html#howto>.  If it doesn't work out
 	  of the box, you may have to change some settings in
 	  <file:drivers/scsi/aha1740.h>.
 
@@ -316,7 +316,7 @@
 	  configuration options. You should read
 	  <file:Documentation/scsi/aic7xxx_old.txt> at a minimum before
 	  contacting the maintainer with any questions.  The SCSI-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>, can also
+	  available from <http://www.tldp.org/docs.html#howto>, can also
 	  be of great help.
 
 	  If you want to compile this driver as a module ( = code which can be
@@ -377,7 +377,7 @@
 	  This is support for the AM53/79C974 SCSI host adapters.  Please read
 	  <file:Documentation/scsi/AM53C974.txt> for details.  Also, the
 	  SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, is for you.
+	  <http://www.tldp.org/docs.html#howto>, is for you.
 
 	  Note that there is another driver for AM53C974 based adapters:
 	  "Tekram DC390(T) and Am53/79C974 (PCscsi) SCSI support", above.  You
@@ -406,7 +406,7 @@
 	---help---
 	  This is support for BusLogic MultiMaster and FlashPoint SCSI Host
 	  Adapters. Consult the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, and the files
+	  <http://www.tldp.org/docs.html#howto>, and the files
 	  <file:Documentation/scsi/BusLogic.txt> and
 	  <file:Documentation/scsi/FlashPoint.txt> for more information. If this
 	  driver does not work correctly without modification, please contact
@@ -451,7 +451,7 @@
 	help
 	  This is support for DTC 3180/3280 SCSI Host Adapters.  Please read
 	  the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, and the file
+	  <http://www.tldp.org/docs.html#howto>, and the file
 	  <file:Documentation/scsi/dtc3x80.txt>.
 
 	  This driver is also available as a module ( = code which can be
@@ -470,7 +470,7 @@
 
 	  You want to read the start of <file:drivers/scsi/eata.c> and the
 	  SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to compile this as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
@@ -518,7 +518,7 @@
 	  host adapters could also use this driver but are discouraged from
 	  doing so, since this driver only supports hard disks and lacks
 	  numerous features.  You might want to have a look at the SCSI-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>.
+	  available from <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to compile this as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
@@ -534,7 +534,7 @@
 	  other adapters based on the Future Domain chipsets (Quantum
 	  ISA-200S, ISA-250MG; Adaptec AHA-2920A; and at least one IBM board).
 	  It is explained in section 3.7 of the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  NOTE: Newer Adaptec AHA-2920C boards use the Adaptec AIC-7850 chip
 	  and should use the aic7xxx driver ("Adaptec AIC7xxx chipset SCSI
@@ -589,7 +589,7 @@
 	  generic 5380 support.
 
 	  It is explained in section 3.8 of the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  If it doesn't work out
+	  <http://www.tldp.org/docs.html#howto>.  If it doesn't work out
 	  of the box, you may have to change some settings in
 	  <file:drivers/scsi/g_NCR5380.h>.
 
@@ -605,7 +605,7 @@
 	  This is a driver for the old NCR 53c80 series of SCSI controllers
 	  on boards using memory mapped I/O. 
 	  It is explained in section 3.8 of the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  If it doesn't work out
+	  <http://www.tldp.org/docs.html#howto>.  If it doesn't work out
 	  of the box, you may have to change some settings in
 	  <file:drivers/scsi/g_NCR5380.h>.
 
@@ -719,7 +719,7 @@
 	help
 	  This is support for the Initio 91XXU(W) SCSI host adapter.  Please
 	  read the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to compile this as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
@@ -732,7 +732,7 @@
 	help
 	  This is support for the Initio INI-A100U2W SCSI host adapter.
 	  Please read the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to compile this as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
@@ -758,7 +758,7 @@
 	  For more information about this driver and how to use it you should
 	  read the file <file:Documentation/scsi/ppa.txt>.  You should also read
 	  the SCSI-HOWTO, which is available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  If you use this driver,
+	  <http://www.tldp.org/docs.html#howto>.  If you use this driver,
 	  you will still be able to use the parallel port for other tasks,
 	  such as a printer; it is safe to compile both drivers into the
 	  kernel.
@@ -787,7 +787,7 @@
 	  For more information about this driver and how to use it you should
 	  read the file <file:Documentation/scsi/ppa.txt>.  You should also read
 	  the SCSI-HOWTO, which is available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  If you use this driver,
+	  <http://www.tldp.org/docs.html#howto>.  If you use this driver,
 	  you will still be able to use the parallel port for other tasks,
 	  such as a printer; it is safe to compile both drivers into the
 	  kernel.
@@ -833,7 +833,7 @@
 	  This is support for the NCR53c406a SCSI host adapter.  For user
 	  configurable parameters, check out <file:drivers/scsi/NCR53c406a.c>
 	  in the kernel source.  Also read the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to compile this driver as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
@@ -883,7 +883,7 @@
 	  This is a driver for the 53c7 and 8xx NCR family of SCSI
 	  controllers, not to be confused with the NCR 5380 controllers.  It
 	  is explained in section 3.8 of the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  If it doesn't work out
+	  <http://www.tldp.org/docs.html#howto>.  If it doesn't work out
 	  of the box, you may have to change some settings in
 	  <file:drivers/scsi/53c7,8xx.h>.  Please read
 	  <file:Documentation/scsi/ncr53c7xx.txt> for the available boot time
@@ -1220,7 +1220,7 @@
 	---help---
 	  This is support for a SCSI host adapter.  It is explained in section
 	  3.10 of the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  If it doesn't work out
+	  <http://www.tldp.org/docs.html#howto>.  If it doesn't work out
 	  of the box, you may have to change some settings in
 	  <file:drivers/scsi/pas16.h>.
 
@@ -1235,7 +1235,7 @@
 	help
 	  This is support for the PCI2000I EIDE interface card which acts as a
 	  SCSI host adapter.  Please read the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module called pci2000 ( = code
 	  which can be inserted in and removed from the running kernel
@@ -1248,7 +1248,7 @@
 	help
 	  This is support for the PCI2220i EIDE interface card which acts as a
 	  SCSI host adapter.  Please read the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module called pci2220i ( = code
 	  which can be inserted in and removed from the running kernel
@@ -1261,7 +1261,7 @@
 	help
 	  This is support for the PSI240i EIDE interface card which acts as a
 	  SCSI host adapter.  Please read the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module called psi240i ( = code
 	  which can be inserted in and removed from the running kernel
@@ -1283,7 +1283,7 @@
 	  Information about this driver is contained in
 	  <file:Documentation/scsi/qlogicfas.txt>.  You should also read the
 	  SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -1303,7 +1303,7 @@
 
 	  Please read the file <file:Documentation/scsi/qlogicisp.txt>.  You
 	  should also read the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This driver is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -1346,7 +1346,7 @@
 	---help---
 	  These are 8-bit SCSI controllers; the ST-01 is also supported by
 	  this driver.  It is explained in section 3.9 of the SCSI-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>.  If it
+	  available from <http://www.tldp.org/docs.html#howto>.  If it
 	  doesn't work out of the box, you may have to change some settings in
 	  <file:drivers/scsi/seagate.h>.
 
@@ -1390,6 +1390,23 @@
 	  read <file:Documentation/modules.txt>. The module will be called
 	  sym53c416.
 
+config SCSI_DC395x
+	tristate "Tekram DC395(U/UW/F) and DC315(U) SCSI support (EXPERIMENTAL)"
+	depends on EXPERIMENTAL && PCI && SCSI
+	---help---
+	  This driver supports PCI SCSI host adapters based on the ASIC
+	  TRM-S1040 chip, e.g Tekram DC395(U/UW/F) and DC315(U) variants.
+
+	  This driver works, but is still in experimental status. So better
+	  have a bootable disk and a backup in case of emergency.
+
+	  Documentation can be found in <file:Documentation/scsi/dc395x.txt>.
+
+	  If you want to compile this driver as a module ( = code which can be
+	  inserted in and removed from the running kernel whenever you want),
+	  say M here and read <file:Documentation/modules.txt>.  The module
+	  will be called dc395x.
+
 config SCSI_DC390T
 	tristate "Tekram DC390(T) and Am53/79C974 SCSI support"
 	depends on PCI && SCSI
@@ -1433,7 +1450,7 @@
 	---help---
 	  This is support for a SCSI host adapter. It is explained in section
 	  3.11 of the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  If it doesn't work out
+	  <http://www.tldp.org/docs.html#howto>.  If it doesn't work out
 	  of the box, you may have to change some settings in
 	  <file:drivers/scsi/t128.h>.  Note that Trantor was purchased by
 	  Adaptec, and some former Trantor products are being sold under the
@@ -1453,7 +1470,7 @@
 	  information about this hardware.  If the driver doesn't work out of
 	  the box, you may have to change some settings in
 	  <file: drivers/scsi/u14-34f.c>.  Read the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  Note that there is also
+	  <http://www.tldp.org/docs.html#howto>.  Note that there is also
 	  another driver for the same hardware: "UltraStor SCSI support",
 	  below.  You should say Y to both only if you want 24F support as
 	  well.
@@ -1502,7 +1519,7 @@
 	  This is support for the UltraStor 14F, 24F and 34F SCSI-2 host
 	  adapter family.  This driver is explained in section 3.12 of the
 	  SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  If it doesn't work out
+	  <http://www.tldp.org/docs.html#howto>.  If it doesn't work out
 	  of the box, you may have to change some settings in
 	  <file:drivers/scsi/ultrastor.h>.
 
@@ -1520,7 +1537,7 @@
 	help
 	  This is support for the Workbit NinjaSCSI-32Bi/UDE PCI/Cardbus
 	  SCSI host adapter. Please read the SCSI-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to compile this as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want),
diff -Nru a/drivers/scsi/Makefile b/drivers/scsi/Makefile
--- a/drivers/scsi/Makefile	Wed Apr 30 22:28:15 2003
+++ b/drivers/scsi/Makefile	Wed Apr 30 22:28:15 2003
@@ -88,6 +88,7 @@
 obj-$(CONFIG_SCSI_MCA_53C9X)	+= NCR53C9x.o	mca_53c9x.o
 obj-$(CONFIG_SCSI_IBMMCA)	+= ibmmca.o
 obj-$(CONFIG_SCSI_EATA)		+= eata.o
+obj-$(CONFIG_SCSI_DC395x)	+= dc395x.o
 obj-$(CONFIG_SCSI_DC390T)	+= tmscsim.o
 obj-$(CONFIG_SCSI_AM53C974)	+= AM53C974.o
 obj-$(CONFIG_SCSI_MEGARAID)	+= megaraid.o
diff -Nru a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
--- a/drivers/scsi/NCR5380.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/scsi/NCR5380.c	Wed Apr 30 22:28:06 2003
@@ -677,9 +677,11 @@
  *	used by the IRQ probe code.
  */
  
-static void __init probe_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t __init probe_intr(int irq, void *dev_id,
+					struct pt_regs *regs)
 {
 	probe_irq = irq;
+	return IRQ_HANDLED;
 }
 
 /**
@@ -706,7 +708,7 @@
 			trying_irqs |= mask;
 
 	timeout = jiffies + (250 * HZ / 1000);
-	probe_irq = IRQ_NONE;
+	probe_irq = SCSI_IRQ_NONE;
 
 	/*
 	 * A interrupt is triggered whenever BSY = false, SEL = true
@@ -723,7 +725,7 @@
 	NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask);
 	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA | ICR_ASSERT_SEL);
 
-	while (probe_irq == IRQ_NONE && time_before(jiffies, timeout))
+	while (probe_irq == SCSI_IRQ_NONE && time_before(jiffies, timeout))
 	{
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(1);
@@ -892,7 +894,7 @@
 
 	SPRINTF("\nBase Addr: 0x%05lX    ", (long) instance->base);
 	SPRINTF("io_port: %04x      ", (int) instance->io_port);
-	if (instance->irq == IRQ_NONE)
+	if (instance->irq == SCSI_IRQ_NONE)
 		SPRINTF("IRQ: None.\n");
 	else
 		SPRINTF("IRQ: %d.\n", instance->irq);
@@ -1191,7 +1193,7 @@
 	Scsi_Cmnd *tmp, *prev;
 	struct Scsi_Host *instance;
 	int done;
-	unsigned long flags;
+	unsigned long flags = 0;
 	
 	/*
 	 * We run (with interrupts disabled) until we're sure that none of 
@@ -1207,7 +1209,7 @@
 
 	instance = hostdata->host;
 
-	if(instance->irq != IRQ_NONE)
+	if(instance->irq != SCSI_IRQ_NONE)
 		spin_lock_irqsave(instance->host_lock, flags);
 
 	do {
@@ -1308,7 +1310,7 @@
 			break;
 	} while (!done);
 	
-	if(instance->irq != IRQ_NONE)
+	if(instance->irq != SCSI_IRQ_NONE)
 		spin_unlock_irqrestore(instance->host_lock, flags);
 }
 
@@ -1327,13 +1329,14 @@
  *	Locks: takes the needed instance locks
  */
 
-static void NCR5380_intr(int irq, void *dev_id, struct pt_regs *regs) 
+static irqreturn_t NCR5380_intr(int irq, void *dev_id, struct pt_regs *regs) 
 {
 	NCR5380_local_declare();
 	struct Scsi_Host *instance;
 	int done;
 	unsigned char basr;
 	struct NCR5380_hostdata *hostdata;
+	int handled = 0;
 
 	dprintk(NDEBUG_INTR, ("scsi : NCR5380 irq %d triggered\n", irq));
 
@@ -1345,6 +1348,7 @@
 		{
 			instance = hostdata->host;
 			if (instance->irq == irq) {
+				handled = 1;
 				spin_lock_irq(instance->host_lock);
 				/* Look for pending interrupts */
 				NCR5380_setup(instance);
@@ -1402,6 +1406,7 @@
 			}	/* if (instance->irq == irq) */
 		}
 	} while (!done);
+	return IRQ_RETVAL(handled);
 }
 
 #endif 
@@ -1481,7 +1486,7 @@
 	NCR5380_setup(instance);
 
 	if (hostdata->selecting) {
-		if(instance->irq != IRQ_NONE)
+		if(instance->irq != SCSI_IRQ_NONE)
 			spin_unlock_irq(instance->host_lock);
 		goto part2;	/* RvC: sorry prof. Dijkstra, but it keeps the
 				   rest of the code nearly the same */
@@ -1506,14 +1511,14 @@
 	NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask);
 	NCR5380_write(MODE_REG, MR_ARBITRATE);
 
-	if(instance->irq != IRQ_NONE)
+	if(instance->irq != SCSI_IRQ_NONE)
 		spin_unlock_irq(instance->host_lock);
 
 	/* We can be relaxed here, interrupts are on, we are
 	   in workqueue context, the birds are singing in the trees */
 
 	err = NCR5380_poll_politely(instance, INITIATOR_COMMAND_REG, ICR_ARBITRATION_PROGRESS, ICR_ARBITRATION_PROGRESS, 5*HZ);
-	if(instance->irq != IRQ_NONE)
+	if(instance->irq != SCSI_IRQ_NONE)
 		spin_lock_irq(instance->host_lock);
 
 	if (err < 0) {
@@ -1649,7 +1654,7 @@
 					   waiting period */
 	if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) == (SR_SEL | SR_IO)) {
 		NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-		if(instance->irq != IRQ_NONE)
+		if(instance->irq != SCSI_IRQ_NONE)
 			spin_lock_irq(instance->host_lock);
 		NCR5380_reselect(instance);
 		printk("scsi%d : reselection after won arbitration?\n", instance->host_no);
@@ -1676,7 +1681,7 @@
 			NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
 			return -1;
 		}
-		if(instance->irq != IRQ_NONE)
+		if(instance->irq != SCSI_IRQ_NONE)
 			spin_lock_irq(instance->host_lock);
 		cmd->result = DID_BAD_TARGET << 16;
 		collect_stats(hostdata, cmd);
@@ -1714,9 +1719,9 @@
 	}
 
 	dprintk(NDEBUG_SELECTION, ("scsi%d : target %d selected, going into MESSAGE OUT phase.\n", instance->host_no, cmd->device->id));
-	tmp[0] = IDENTIFY(((instance->irq == IRQ_NONE) ? 0 : 1), cmd->device->lun);
+	tmp[0] = IDENTIFY(((instance->irq == SCSI_IRQ_NONE) ? 0 : 1), cmd->device->lun);
 
-	if(instance->irq != IRQ_NONE)
+	if(instance->irq != SCSI_IRQ_NONE)
 		spin_lock_irq(instance->host_lock);
 		
 	len = 1;
@@ -1738,7 +1743,7 @@
 
 	/* Selection failed */
 failed:
-	if(instance->irq != IRQ_NONE)
+	if(instance->irq != SCSI_IRQ_NONE)
 		spin_lock_irq(instance->host_lock);
 	return -1;
 
diff -Nru a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h
--- a/drivers/scsi/NCR5380.h	Wed Apr 30 22:28:10 2003
+++ b/drivers/scsi/NCR5380.h	Wed Apr 30 22:28:10 2003
@@ -28,6 +28,8 @@
 #ifndef NCR5380_H
 #define NCR5380_H
 
+#include <linux/interrupt.h>
+
 #define NCR5380_PUBLIC_RELEASE 7
 #define NCR53C400_PUBLIC_RELEASE 2
 
@@ -233,7 +235,7 @@
  * Scsi_Host structure
  */
 
-#define IRQ_NONE	255
+#define SCSI_IRQ_NONE	255
 #define DMA_NONE	255
 #define IRQ_AUTO	254
 #define DMA_AUTO	254
@@ -295,7 +297,7 @@
 static int NCR5380_init(struct Scsi_Host *instance, int flags);
 static void NCR5380_information_transfer(struct Scsi_Host *instance);
 #ifndef DONT_USE_INTR
-static void NCR5380_intr(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t NCR5380_intr(int irq, void *dev_id, struct pt_regs *regs);
 #endif
 static void NCR5380_main(void *ptr);
 static void NCR5380_print_options(struct Scsi_Host *instance);
diff -Nru a/drivers/scsi/NCR53C9x.c b/drivers/scsi/NCR53C9x.c
--- a/drivers/scsi/NCR53C9x.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/scsi/NCR53C9x.c	Wed Apr 30 22:28:05 2003
@@ -30,6 +30,7 @@
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/blk.h>
+#include <linux/interrupt.h>
 #include <linux/proc_fs.h>
 #include <linux/stat.h>
 #include <linux/init.h>
@@ -96,7 +97,7 @@
 struct NCR_ESP *espchain = 0;
 int nesps = 0, esps_in_use = 0, esps_running = 0;
 
-void esp_intr(int irq, void *dev_id, struct pt_regs *pregs);
+irqreturn_t esp_intr(int irq, void *dev_id, struct pt_regs *pregs);
 
 /* Debugging routines */
 struct esp_cmdstrings {
@@ -3559,7 +3560,7 @@
 }
 
 #ifndef CONFIG_SMP
-void esp_intr(int irq, void *dev_id, struct pt_regs *pregs)
+irqreturn_t esp_intr(int irq, void *dev_id, struct pt_regs *pregs)
 {
 	struct NCR_ESP *esp;
 	unsigned long flags;
@@ -3592,10 +3593,11 @@
 	if(again)
 		goto repeat;
 	spin_unlock_irqrestore(dev->host_lock, flags);
+	return IRQ_HANDLED;
 }
 #else
 /* For SMP we only service one ESP on the list list at our IRQ level! */
-void esp_intr(int irq, void *dev_id, struct pt_regs *pregs)
+irqreturn_t esp_intr(int irq, void *dev_id, struct pt_regs *pregs)
 {
 	struct NCR_ESP *esp;
 	unsigned long flags;
@@ -3620,6 +3622,7 @@
 	}
 out:
 	spin_unlock_irqrestore(dev->host_lock, flags);
+	return IRQ_HANDLED;
 }
 #endif
 
diff -Nru a/drivers/scsi/NCR53C9x.h b/drivers/scsi/NCR53C9x.h
--- a/drivers/scsi/NCR53C9x.h	Wed Apr 30 22:28:07 2003
+++ b/drivers/scsi/NCR53C9x.h	Wed Apr 30 22:28:07 2003
@@ -14,6 +14,7 @@
 #define NCR53C9X_H
 
 #include <linux/config.h>
+#include <linux/interrupt.h>
 
 /* djweis for mac driver */
 #if defined(CONFIG_MAC)
@@ -657,7 +658,7 @@
 extern void esp_deallocate(struct NCR_ESP *);
 extern void esp_release(void);
 extern void esp_initialize(struct NCR_ESP *);
-extern void esp_intr(int, void *, struct pt_regs *);
+extern irqreturn_t esp_intr(int, void *, struct pt_regs *);
 extern const char *esp_info(struct Scsi_Host *);
 extern int esp_queue(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
 extern int esp_command(Scsi_Cmnd *);
diff -Nru a/drivers/scsi/NCR53c406a.c b/drivers/scsi/NCR53c406a.c
--- a/drivers/scsi/NCR53c406a.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/scsi/NCR53c406a.c	Wed Apr 30 22:28:09 2003
@@ -169,7 +169,7 @@
 
 /* Static function prototypes */
 static void NCR53c406a_intr(int, void *, struct pt_regs *);
-static void do_NCR53c406a_intr(int, void *, struct pt_regs *);
+static irqreturn_t do_NCR53c406a_intr(int, void *, struct pt_regs *);
 static void internal_done(Scsi_Cmnd *);
 static void wait_intr(void);
 static void chip_init(void);
@@ -658,7 +658,7 @@
 
 static void wait_intr(void)
 {
-	int i = jiffies + WATCHDOG;
+	unsigned long i = jiffies + WATCHDOG;
 
 	while (time_after(i, jiffies) && !(inb(STAT_REG) & 0xe0)) {	/* wait for a pseudo-interrupt */
 		cpu_relax();
@@ -773,7 +773,8 @@
 	return 0;
 }
 
-static void do_NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs)
+static irqreturn_t do_NCR53c406a_intr(int unused, void *dev_id,
+					struct pt_regs *regs)
 {
 	unsigned long flags;
 	struct Scsi_Host *dev = dev_id;
@@ -781,6 +782,7 @@
 	spin_lock_irqsave(dev->host_lock, flags);
 	NCR53c406a_intr(0, dev_id, regs);
 	spin_unlock_irqrestore(dev->host_lock, flags);
+	return IRQ_HANDLED;
 }
 
 static void NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs)
@@ -970,7 +972,7 @@
 static int irq_probe(void)
 {
 	int irqs, irq;
-	int i;
+	unsigned long i;
 
 	inb(INT_REG);		/* clear the interrupt register */
 	irqs = probe_irq_on();
diff -Nru a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
--- a/drivers/scsi/aacraid/linit.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/scsi/aacraid/linit.c	Wed Apr 30 22:28:08 2003
@@ -48,6 +48,7 @@
 #include <linux/spinlock.h>
 #include <linux/slab.h>
 #include <linux/completion.h>
+#include <linux/interrupt.h>
 #include <asm/semaphore.h>
 #include <linux/blk.h>
 #include "scsi.h"
diff -Nru a/drivers/scsi/aacraid/rx.c b/drivers/scsi/aacraid/rx.c
--- a/drivers/scsi/aacraid/rx.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/scsi/aacraid/rx.c	Wed Apr 30 22:28:20 2003
@@ -39,13 +39,14 @@
 #include <linux/blk.h>
 #include <linux/delay.h>
 #include <linux/completion.h>
+#include <linux/interrupt.h>
 #include <asm/semaphore.h>
 #include "scsi.h"
 #include "hosts.h"
 
 #include "aacraid.h"
 
-static void aac_rx_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t aac_rx_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct aac_dev *dev = dev_id;
 	unsigned long bellbits;
@@ -81,7 +82,9 @@
 			rx_writel(dev, MUnit.ODR, DoorBellAdapterNormCmdNotFull);
 			rx_writel(dev, MUnit.ODR, DoorBellAdapterNormRespNotFull);
 		}
+		return IRQ_HANDLED;
 	}
+	return IRQ_NONE;
 }
 
 /**
diff -Nru a/drivers/scsi/aacraid/sa.c b/drivers/scsi/aacraid/sa.c
--- a/drivers/scsi/aacraid/sa.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/scsi/aacraid/sa.c	Wed Apr 30 22:28:10 2003
@@ -39,13 +39,14 @@
 #include <linux/blk.h>
 #include <linux/delay.h>
 #include <linux/completion.h>
+#include <linux/interrupt.h>
 #include <asm/semaphore.h>
 #include "scsi.h"
 #include "hosts.h"
 
 #include "aacraid.h"
 
-static void aac_sa_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t aac_sa_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct aac_dev *dev = dev_id;
 	unsigned short intstat, mask;
@@ -75,7 +76,9 @@
 		} else if (intstat & DOORBELL_4) {	// dev -> Host Normal Response Not Full
 			sa_writew(dev, DoorbellClrReg_p, DOORBELL_4);
 		}
+		return IRQ_HANDLED;
 	}
+	return IRQ_NONE;
 }
 
 /**
diff -Nru a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
--- a/drivers/scsi/advansys.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/scsi/advansys.c	Wed Apr 30 22:28:07 2003
@@ -4208,7 +4208,7 @@
  * advansys.h contains function prototypes for functions global to Linux.
  */
 
-STATIC void       advansys_interrupt(int, void *, struct pt_regs *);
+STATIC irqreturn_t advansys_interrupt(int, void *, struct pt_regs *);
 STATIC int	  advansys_slave_configure(Scsi_Device *);
 STATIC void       asc_scsi_done_list(Scsi_Cmnd *, int from_isr);
 STATIC int        asc_execute_scsi_cmnd(Scsi_Cmnd *);
@@ -4395,32 +4395,6 @@
     curbuf += cnt;
 
     /*
-     * Display target driver information for each device attached
-     * to the board.
-     */
-    list_for_each_entry (scd, &shp->my_devices, siblings)
-    {
-        if (scd->host == shp) {
-            cp = boardp->prtbuf;
-            /*
-             * Note: If proc_print_scsidevice() writes more than
-             * ASC_PRTBUF_SIZE bytes, it will overrun 'prtbuf'.
-             */
-            proc_print_scsidevice(scd, cp, &cplen, 0);
-            ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
-            cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
-            totcnt += cnt;
-            leftlen -= cnt;
-            if (leftlen == 0) {
-                ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
-                return totcnt;
-            }
-            advoffset += cplen;
-            curbuf += cnt;
-        }
-    }
-
-    /*
      * Display EEPROM configuration for the board.
      */
     cp = boardp->prtbuf;
@@ -6246,7 +6220,7 @@
  * to the AdvanSys driver which is for a device sharing an interrupt with
  * an AdvanSys adapter.
  */
-STATIC void
+STATIC irqreturn_t
 advansys_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
     ulong           flags;
@@ -6336,7 +6310,7 @@
     asc_scsi_done_list(done_scp, 1);
 
     ASC_DBG(1, "advansys_interrupt: end\n");
-    return;
+    return IRQ_HANDLED;
 }
 
 /*
@@ -8370,7 +8344,6 @@
     int                    totlen;
     int                    len;
     int                    chip_scsi_id;
-    int                    i;
 
     boardp = ASC_BOARDP(shp);
 
diff -Nru a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
--- a/drivers/scsi/aha152x.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/scsi/aha152x.c	Wed Apr 30 22:28:04 2003
@@ -646,7 +646,7 @@
 };
 
 /* setup & interrupt */
-static void intr(int irq, void *dev_id, struct pt_regs *);
+static irqreturn_t intr(int irq, void *dev_id, struct pt_regs *);
 static void reset_ports(struct Scsi_Host *shpnt);
 static void aha152x_error(struct Scsi_Host *shpnt, char *msg);
 static void done(struct Scsi_Host *shpnt, int error);
@@ -936,18 +936,19 @@
 	return 0;
 }
 
-static void swintr(int irqno, void *dev_id, struct pt_regs *regs)
+static irqreturn_t swintr(int irqno, void *dev_id, struct pt_regs *regs)
 {
 	struct Scsi_Host *shpnt = lookup_irq(irqno);
 
 	if (!shpnt) {
         	printk(KERN_ERR "aha152x%d: catched software interrupt %d for unknown controller.\n", HOSTNO, irqno);
-		return;
+		return IRQ_NONE;
 	}
 
 	HOSTDATA(shpnt)->swint++;
 
 	SETPORT(DMACNTRL0, INTEN);
+	return IRQ_HANDLED;
 }
 
 #ifdef __ISAPNP__
@@ -1379,8 +1380,6 @@
  */ 
 static int setup_expected_interrupts(struct Scsi_Host *shpnt)
 {
-	ASSERT_LOCK(&QLOCK,1);
-
 	if(CURRENT_SC) {
 		CURRENT_SC->SCp.phase |= 1 << 16;
 	
@@ -1873,13 +1872,13 @@
  *
  */
 
-static void intr(int irqno, void *dev_id, struct pt_regs *regs)
+static irqreturn_t intr(int irqno, void *dev_id, struct pt_regs *regs)
 {
 	struct Scsi_Host *shpnt = lookup_irq(irqno);
 
 	if (!shpnt) {
 		printk(KERN_ERR "aha152x: catched interrupt %d for unknown controller.\n", irqno);
-		return;
+		return IRQ_NONE;
 	}
 
 	/* no more interrupts from the controller, while we're busy.
@@ -1899,6 +1898,7 @@
 	HOSTDATA(shpnt)->service++;
 	INIT_WORK(&aha152x_tq, (void *) run, NULL);
 	schedule_work(&aha152x_tq);
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
--- a/drivers/scsi/aha1542.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/scsi/aha1542.c	Wed Apr 30 22:28:09 2003
@@ -176,7 +176,8 @@
 static void setup_mailboxes(int base_io, struct Scsi_Host *shpnt);
 static int aha1542_restart(struct Scsi_Host *shost);
 static void aha1542_intr_handle(struct Scsi_Host *shost, void *dev_id, struct pt_regs *regs);
-static void do_aha1542_intr_handle(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t do_aha1542_intr_handle(int irq, void *dev_id,
+					struct pt_regs *regs);
 
 #define aha1542_intr_reset(base)  outb(IRST, CONTROL(base))
 
@@ -416,7 +417,8 @@
 }
 
 /* A quick wrapper for do_aha1542_intr_handle to grab the spin lock */
-static void do_aha1542_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t do_aha1542_intr_handle(int irq, void *dev_id,
+					struct pt_regs *regs)
 {
 	unsigned long flags;
 	struct Scsi_Host *shost;
@@ -428,6 +430,7 @@
 	spin_lock_irqsave(shost->host_lock, flags);
 	aha1542_intr_handle(shost, dev_id, regs);
 	spin_unlock_irqrestore(shost->host_lock, flags);
+	return IRQ_HANDLED;
 }
 
 /* A "high" level interrupt handler */
diff -Nru a/drivers/scsi/aha1740.c b/drivers/scsi/aha1740.c
--- a/drivers/scsi/aha1740.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/scsi/aha1740.c	Wed Apr 30 22:28:06 2003
@@ -220,7 +220,8 @@
 }
 
 /* A "high" level interrupt handler */
-static void aha1740_intr_handle(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t aha1740_intr_handle(int irq, void *dev_id,
+					struct pt_regs *regs)
 {
     struct Scsi_Host *host = aha_host[irq - 9];
     void (*my_done)(Scsi_Cmnd *);
@@ -230,6 +231,7 @@
     Scsi_Cmnd *SCtmp;
     unsigned int base;
     unsigned long flags;
+    int handled = 0;
 
     if (!host)
 	panic("aha1740.c: Irq from unknown host!\n");
@@ -239,6 +241,7 @@
 
     while(inb(G2STAT(base)) & G2STAT_INTPEND)
     {
+	handled = 1;
 	DEB(printk("aha1740_intr top of loop.\n"));
 	adapstat = inb(G2INTST(base));
 	ecbptr = (struct ecb *) isa_bus_to_virt(inl(MBOXIN0(base)));
@@ -309,6 +312,7 @@
     }
 
     spin_unlock_irqrestore(host->host_lock, flags);
+    return IRQ_RETVAL(handled);
 }
 
 static int aha1740_queuecommand(Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *))
diff -Nru a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c	Wed Apr 30 22:28:04 2003
@@ -3863,7 +3863,7 @@
 /*
  * SCSI controller interrupt handler.
  */
-void
+irqreturn_t
 ahc_linux_isr(int irq, void *dev_id, struct pt_regs * regs)
 {
 	struct	ahc_softc *ahc;
@@ -3883,6 +3883,8 @@
 			ahc_schedule_completeq(ahc, acmd);
 	}
 	ahc_unlock(ahc, &flags);
+	/* FIXME! Was it really ours? */
+	return IRQ_HANDLED;
 }
 
 void
diff -Nru a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.h	Wed Apr 30 22:28:07 2003
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h	Wed Apr 30 22:28:07 2003
@@ -1224,7 +1224,7 @@
 int	ahc_platform_abort_scbs(struct ahc_softc *ahc, int target,
 				char channel, int lun, u_int tag,
 				role_t role, uint32_t status);
-void	ahc_linux_isr(int irq, void *dev_id, struct pt_regs * regs);
+irqreturn_t ahc_linux_isr(int irq, void *dev_id, struct pt_regs * regs);
 void	ahc_platform_flushwork(struct ahc_softc *ahc);
 int	ahc_softc_comp(struct ahc_softc *, struct ahc_softc *);
 void	ahc_done(struct ahc_softc*, struct scb*);
diff -Nru a/drivers/scsi/aic7xxx_old/aic7xxx.h b/drivers/scsi/aic7xxx_old/aic7xxx.h
--- a/drivers/scsi/aic7xxx_old/aic7xxx.h	Wed Apr 30 22:28:03 2003
+++ b/drivers/scsi/aic7xxx_old/aic7xxx.h	Wed Apr 30 22:28:03 2003
@@ -30,26 +30,26 @@
  * to do with card config are filled in after the card is detected.
  */
 #define AIC7XXX	{						\
-	proc_info: aic7xxx_proc_info,				\
-	detect: aic7xxx_detect,					\
-	release: aic7xxx_release,				\
-	info: aic7xxx_info,					\
-	queuecommand: aic7xxx_queue,				\
-	slave_alloc: aic7xxx_slave_alloc,			\
-	slave_configure: aic7xxx_slave_configure,		\
-	slave_destroy: aic7xxx_slave_destroy,			\
-	bios_param: aic7xxx_biosparam,				\
-	eh_abort_handler: aic7xxx_abort,			\
-	eh_device_reset_handler: aic7xxx_bus_device_reset,	\
-	eh_host_reset_handler: aic7xxx_reset,			\
-	can_queue: 255,		/* max simultaneous cmds      */\
-	this_id: -1,		/* scsi id of host adapter    */\
-	sg_tablesize: 0,	/* max scatter-gather cmds    */\
-	max_sectors: 2048,	/* max physical sectors in 1 cmd */\
-	cmd_per_lun: 3,		/* cmds per lun (linked cmds) */\
-	present: 0,		/* number of 7xxx's present   */\
-	unchecked_isa_dma: 0,	/* no memory DMA restrictions */\
-	use_clustering: ENABLE_CLUSTERING,			\
+	.proc_info		= aic7xxx_proc_info,		\
+	.detect			= aic7xxx_detect,		\
+	.release		= aic7xxx_release,		\
+	.info			= aic7xxx_info,			\
+	.queuecommand		= aic7xxx_queue,		\
+	.slave_alloc		= aic7xxx_slave_alloc,		\
+	.slave_configure	= aic7xxx_slave_configure,	\
+	.slave_destroy		= aic7xxx_slave_destroy,	\
+	.bios_param		= aic7xxx_biosparam,		\
+	.eh_abort_handler	= aic7xxx_abort,		\
+	.eh_device_reset_handler	= aic7xxx_bus_device_reset,	\
+	.eh_host_reset_handler	= aic7xxx_reset,			\
+	.can_queue		= 255,	/* max simultaneous cmds      */\
+	.this_id		= -1,	/* scsi id of host adapter    */\
+	.sg_tablesize		= 0,	/* max scatter-gather cmds    */\
+	.max_sectors		= 2048,	/* max physical sectors in 1 cmd */\
+	.cmd_per_lun		= 3,	/* cmds per lun (linked cmds) */\
+	.present		= 0,	/* number of 7xxx's present   */\
+	.unchecked_isa_dma	= 0,	/* no memory DMA restrictions */\
+	.use_clustering		= ENABLE_CLUSTERING,			\
 }
 
 extern int aic7xxx_queue(Scsi_Cmnd *, void (*)(Scsi_Cmnd *));
diff -Nru a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
--- a/drivers/scsi/aic7xxx_old.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/scsi/aic7xxx_old.c	Wed Apr 30 22:28:08 2003
@@ -6484,7 +6484,7 @@
  *   above.  Please, children, do not try this at home, and if you ever see
  *   anything like it, please inform the Gross Hack Police immediately
  *-F*************************************************************************/
-static void
+static irqreturn_t
 do_aic7xxx_isr(int irq, void *dev_id, struct pt_regs *regs)
 {
   unsigned long cpu_flags;
@@ -6492,7 +6492,7 @@
   
   p = (struct aic7xxx_host *)dev_id;
   if(!p)
-    return;
+    return IRQ_NONE;
   spin_lock_irqsave(p->host->host_lock, cpu_flags);
   p->flags |= AHC_IN_ISR;
   do
@@ -6503,6 +6503,8 @@
   aic7xxx_run_waiting_queues(p);
   p->flags &= ~AHC_IN_ISR;
   spin_unlock_irqrestore(p->host->host_lock, cpu_flags);
+
+  return IRQ_HANDLED;
 }
 
 /*+F*************************************************************************
diff -Nru a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c
--- a/drivers/scsi/atp870u.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/scsi/atp870u.c	Wed Apr 30 22:28:08 2003
@@ -86,7 +86,8 @@
 
 static void send_s870(struct Scsi_Host *);
 
-static void atp870u_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t atp870u_intr_handle(int irq, void *dev_id,
+					struct pt_regs *regs)
 {
 	unsigned long flags;
 	unsigned short int tmpcip, id;
@@ -108,7 +109,7 @@
 		j = inb(tmport);
 		if ((j & 0x80) == 0) {
 			dev->in_int = 0;
-			return;
+			return IRQ_NONE;
 		}
 
 		tmpcip = dev->pciport;
@@ -175,13 +176,13 @@
 			 *      Done
 			 */
 			dev->in_int = 0;
-			return;
+			goto out;
 		}
 
 		if (i == 0x40) {
 			dev->last_cmd |= 0x40;
 			dev->in_int = 0;
-			return;
+			goto out;
 		}
 
 		if (i == 0x21) {
@@ -202,7 +203,7 @@
 			tmport += 0x08;
 			outb(0x08, tmport);
 			dev->in_int = 0;
-			return;
+			goto out;
 		}
 		if ((i == 0x80) || (i == 0x8f)) {
 			lun = 0;
@@ -228,7 +229,7 @@
 					tmport += 0x04;
 					outb(0x08, tmport);
 					dev->in_int = 0;
-					return;
+					goto out;
 				} else {
 					outb(0x46, tmport);
 					dev->id[target_id].dirctu = 0x00;
@@ -239,7 +240,7 @@
 					tmport += 0x03;
 					outb(0x08, tmport);
 					dev->in_int = 0;
-					return;
+					goto out;
 				}
 			}
 			if (dev->last_cmd != 0xff) {
@@ -313,7 +314,7 @@
 				tmport = workportu + 0x18;
 				outb(0x08, tmport);
 				dev->in_int = 0;
-				return;
+				goto out;
 			}
 			prd = dev->id[target_id].prd_posu;
 			while (adrcntu != 0) {
@@ -352,12 +353,12 @@
 				outb(0x08, tmport);
 				outb(0x01, tmpcip);
 				dev->in_int = 0;
-				return;
+				goto out;
 			}
 			outb(0x08, tmport);
 			outb(0x09, tmpcip);
 			dev->in_int = 0;
-			return;
+			goto out;
 		}
 
 		/*
@@ -417,7 +418,7 @@
 				send_s870(host);
 			}
 			dev->in_int = 0;
-			return;
+			goto out;
 		}
 		if ((dev->last_cmd & 0xf0) != 0x40) {
 			dev->last_cmd = 0xff;
@@ -440,7 +441,7 @@
 			outb(0x08, tmport);
 			outb(0x09, tmpcip);
 			dev->in_int = 0;
-			return;
+			goto out;
 		}
 		if (i == 0x08) {
 			tmpcip = tmpcip + 4;
@@ -458,7 +459,7 @@
 			outb(0x08, tmport);
 			outb(0x01, tmpcip);
 			dev->in_int = 0;
-			return;
+			goto out;
 		}
 		tmport -= 0x07;
 		if (i == 0x0a) {
@@ -474,14 +475,15 @@
 		tmport += 0x03;
 		outb(0x08, tmport);
 		dev->in_int = 0;
-		return;
+		goto out;
 	} else {
 //              tmport = workportu + 0x17;
 //              inb(tmport);
 //              dev->working = 0;
 		dev->in_int = 0;
-		return;
 	}
+out:
+	return IRQ_HANDLED;
 }
 
 static int atp870u_queuecommand(Scsi_Cmnd * req_p, void (*done) (Scsi_Cmnd *))
diff -Nru a/drivers/scsi/cpqfcTSinit.c b/drivers/scsi/cpqfcTSinit.c
--- a/drivers/scsi/cpqfcTSinit.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/scsi/cpqfcTSinit.c	Wed Apr 30 22:28:04 2003
@@ -1716,7 +1716,7 @@
 
 
 
-void cpqfcTS_intr_handler( int irq, 
+irqreturn_t cpqfcTS_intr_handler( int irq, 
 		void *dev_id, 
 		struct pt_regs *regs)
 {
@@ -1726,7 +1726,8 @@
   CPQFCHBA *cpqfcHBA = (CPQFCHBA *)HostAdapter->hostdata;
   int MoreMessages = 1; // assume we have something to do
   UCHAR IntPending;
-  
+  int handled = 0;
+
   ENTER("intr_handler");
   spin_lock_irqsave( HostAdapter->host_lock, flags);
   // is this our INT?
@@ -1737,7 +1738,7 @@
 #define INFINITE_IMQ_BREAK 10000
   if( IntPending )
   {
-    
+    handled = 1;
     // mask our HBA interrupts until we handle it...
     writeb( 0, cpqfcHBA->fcChip.Registers.INTEN.address);
 
@@ -1791,6 +1792,7 @@
   }
   spin_unlock_irqrestore( HostAdapter->host_lock, flags);
   LEAVE("intr_handler");
+  return IRQ_RETVAL(handled);
 }
 
 
diff -Nru a/drivers/scsi/cpqfcTSstructs.h b/drivers/scsi/cpqfcTSstructs.h
--- a/drivers/scsi/cpqfcTSstructs.h	Wed Apr 30 22:28:08 2003
+++ b/drivers/scsi/cpqfcTSstructs.h	Wed Apr 30 22:28:08 2003
@@ -21,6 +21,7 @@
 #define CPQFCTSSTRUCTS_H
 
 #include <linux/timer.h>  // timer declaration in our host data
+#include <linux/interrupt.h>
 #include <asm/atomic.h>
 #include "cpqfcTSioctl.h"
 
@@ -861,7 +862,7 @@
                   
 
 // Linux interrupt handler
-void cpqfcTS_intr_handler( int irq,void *dev_id,struct pt_regs *regs);
+irqreturn_t cpqfcTS_intr_handler( int irq,void *dev_id,struct pt_regs *regs);
 void cpqfcTSheartbeat( unsigned long ptr );
 
 
diff -Nru a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/scsi/dc395x.c	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,6351 @@
+/*
+ * dc395x.c
+ *
+ * Device Driver for Tekram DC395(U/UW/F), DC315(U)
+ * PCI SCSI Bus Master Host Adapter
+ * (SCSI chip set used Tekram ASIC TRM-S1040)
+ *
+ * Authors:
+ *  C.L. Huang <ching@tekram.com.tw>
+ *  Erich Chen <erich@tekram.com.tw>
+ *  (C) Copyright 1995-1999 Tekram Technology Co., Ltd.
+ *
+ *  Kurt Garloff <garloff@suse.de>
+ *  (C) 1999-2000 Kurt Garloff
+ *
+ *  Oliver Neukum <oliver@neukum.name>
+ *  Ali Akcaagac <aliakc@web.de>
+ *  Jamie Lenehan <lenehan@twibble.org>
+ *  (C) 2003
+ *
+ * License: GNU GPL
+ *
+ *************************************************************************
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************
+ */
+
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/ctype.h>
+#include <linux/blk.h>
+#include "scsi.h"
+#include "hosts.h"
+#include "dc395x.h"
+#include <scsi/scsicam.h>	/* needed for scsicam_bios_param */
+#include <linux/interrupt.h>
+#include <linux/init.h>
+#include <linux/spinlock.h>
+
+/* Debugging */
+/*#define DC395x_DEBUG_KG */
+/*#define DC395x_DEBUG0*/
+/*#define DC395x_DEBUG1*/
+/*#define DC395x_DEBUGDCB*/
+#define DC395x_DEBUGTRACE
+/*#define DC395x_DEBUGTRACEALL*/
+/*#define DC395x_DEBUGPARSE*/
+/*#define DC395x_SGPARANOIA*/
+/*#define DC395x_DEBUGFIFO*/
+/*#define DC395x_DEBUGRECURSION*/
+/*#define DC395x_DEBUGPIO*/
+/*#define DC395x_DEBUGMALLOC*/
+
+/* DISable features */
+/*#define DC395x_NO_DISCONNECT*/
+/*#define DC395x_NO_TAGQ*/
+/*#define DC395x_NO_SYNC*/
+/*#define DC395x_NO_WIDE*/
+
+#ifdef DC395x_DEBUG0
+# define DEBUG0(x) x
+#else
+# define DEBUG0(x)
+#endif
+
+#ifdef DC395x_DEBUG1
+# define DEBUG1(x) x
+#else
+# define DEBUG1(x)
+#endif
+
+#ifdef DC395x_DEBUGDCB
+# define DCBDEBUG(x) x
+#else
+# define DCBDEBUG(x)
+#endif
+
+#ifdef DC395x_DEBUGPARSE
+# define PARSEDEBUG(x) x
+#else
+# define PARSEDEBUG(x)
+#endif
+
+#ifdef DC395x_DEBUGRECURSION
+# define DEBUGRECURSION(x) x
+#else
+# define DEBUGRECURSION(x)
+#endif
+
+#ifdef DC395x_DEBUGPIO
+# define DEBUGPIO(x) x
+#else
+# define DEBUGPIO(x)
+#endif
+
+/* Here comes the joker of all debugging facilities! */
+#ifdef DC395x_DEBUGTRACEALL
+# ifndef DC395x_DEBUGTRACE
+#  define DC395x_DEBUGTRACE
+# endif
+# define TRACEOUTALL(x...) printk ( x)
+#else
+# define TRACEOUTALL(x...) do {} while (0)
+#endif
+#ifdef DC395x_DEBUGTRACE
+# define DEBUGTRACEBUFSZ 512
+char DC395x_tracebuf[64];
+char DC395x_traceoverflow[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+# define TRACEPRINTF(x...) \
+do { int ln = sprintf (DC395x_tracebuf, x); \
+     if (pSRB->debugpos + ln >= DEBUGTRACEBUFSZ) \
+     { pSRB->debugtrace[pSRB->debugpos] = 0; pSRB->debugpos = DEBUGTRACEBUFSZ/5; pSRB->debugtrace[pSRB->debugpos++] = '>'; }; \
+     sprintf (pSRB->debugtrace + pSRB->debugpos, "%s", DC395x_tracebuf); \
+     pSRB->debugpos += ln - 1; \
+   } while (0)
+# define TRACEOUT(x...) printk ( x)
+#else
+# define TRACEPRINTF(x...) do {} while (0)
+# define TRACEOUT(x...) do {} while (0)
+#endif
+
+
+#ifdef DC395x_DEBUGMALLOC
+inline void *dc395x_kmalloc(size_t sz, int fl)
+{
+	void *ptr = kmalloc(sz, fl);
+	printk(KERN_DEBUG DC395X_NAME ": Alloc %i bytes @ %p w/ fl %08x\n",
+	       sz, ptr, fl);
+	return ptr;
+}
+inline void dc395x_kfree(const void *adr)
+{
+	printk(KERN_DEBUG DC395X_NAME ": Free mem @ %p\n", adr);
+	kfree(adr);
+}
+
+# define KMALLOC(sz,fl) dc395x_kmalloc(sz,fl)
+# define KFREE(adr) dc395x_kfree(adr)
+#else
+# define KMALLOC(sz,fl) kmalloc(sz,fl)
+# define KFREE(adr) kfree(adr)
+#endif
+
+
+#ifndef PCI_VENDOR_ID_TEKRAM
+#define PCI_VENDOR_ID_TEKRAM                    0x1DE1	/* Vendor ID    */
+#endif
+#ifndef PCI_DEVICE_ID_TEKRAM_TRMS1040
+#define PCI_DEVICE_ID_TEKRAM_TRMS1040           0x0391	/* Device ID    */
+#endif
+
+static struct pci_device_id dc395x_pci_tbl[] __devinitdata = {
+	{
+		.vendor		= PCI_VENDOR_ID_TEKRAM,
+		.device		= PCI_DEVICE_ID_TEKRAM_TRMS1040,
+		.subvendor	= PCI_ANY_ID,
+		.subdevice	= PCI_ANY_ID,
+	 },
+	{}			/* Terminating entry */
+};
+MODULE_DEVICE_TABLE(pci, dc395x_pci_tbl);
+
+
+#define DC395x_LOCK_IO(dev)   spin_lock_irqsave(((struct Scsi_Host *)dev)->host_lock, flags)
+#define DC395x_UNLOCK_IO(dev) spin_unlock_irqrestore(((struct Scsi_Host *)dev)->host_lock, flags)
+
+#define DC395x_ACB_INITLOCK(pACB)               spin_lock_init(&pACB->smp_lock)
+#define DC395x_ACB_LOCK(pACB,acb_flags)	        if (!pACB->lock_level_count[cpuid]) { spin_lock_irqsave(&pACB->smp_lock,acb_flags); pACB->lock_level_count[cpuid]++; } else { pACB->lock_level_count[cpuid]++; }
+#define DC395x_ACB_UNLOCK(pACB,acb_flags)       if (--pACB->lock_level_count[cpuid] == 0) { spin_unlock_irqrestore(&pACB->smp_lock,acb_flags); }
+
+#define DC395x_SMP_IO_LOCK(dev,irq_flags)       spin_lock_irqsave(((struct Scsi_Host*)dev)->host_lock,irq_flags)
+#define DC395x_SMP_IO_UNLOCK(dev,irq_flags)     spin_unlock_irqrestore(((struct Scsi_Host*)dev)->host_lock,irq_flags)
+#define DC395x_SCSI_DONE_ACB_LOCK	        spin_lock(&(pACB->smp_lock))
+#define DC395x_SCSI_DONE_ACB_UNLOCK	        spin_unlock(&(pACB->smp_lock))
+
+
+#define DC395x_read8(address)                   (u8)(inb(pACB->IOPortBase + (address)))
+#define DC395x_read8_(address, base)            (u8)(inb((USHORT)(base) + (address)))
+#define DC395x_read16(address)                  (u16)(inw(pACB->IOPortBase + (address)))
+#define DC395x_read32(address)                  (u32)(inl(pACB->IOPortBase + (address)))
+#define DC395x_write8(address,value)            outb((value), pACB->IOPortBase + (address))
+#define DC395x_write8_(address,value,base)      outb((value), (USHORT)(base) + (address))
+#define DC395x_write16(address,value)           outw((value), pACB->IOPortBase + (address))
+#define DC395x_write32(address,value)           outl((value), pACB->IOPortBase + (address))
+
+
+#define BUS_ADDR(sg)		sg_dma_address(&(sg))
+#define CPU_ADDR(sg)		(page_address((sg).page)+(sg).offset)
+#define PAGE_ADDRESS(sg)	page_address((sg)->page)
+#define SET_DIR(dir,pcmd)	dir = scsi_to_pci_dma_dir((pcmd)->sc_data_direction)
+
+/* cmd->result */
+#define RES_TARGET		0x000000FF	/* Target State */
+#define RES_TARGET_LNX  STATUS_MASK	/* Only official ... */
+#define RES_ENDMSG		0x0000FF00	/* End Message */
+#define RES_DID			0x00FF0000	/* DID_ codes */
+#define RES_DRV			0xFF000000	/* DRIVER_ codes */
+
+#define MK_RES(drv,did,msg,tgt) ((int)(drv)<<24 | (int)(did)<<16 | (int)(msg)<<8 | (int)(tgt))
+#define MK_RES_LNX(drv,did,msg,tgt) ((int)(drv)<<24 | (int)(did)<<16 | (int)(msg)<<8 | (int)(tgt)<<1)
+
+#define SET_RES_TARGET(who,tgt) { who &= ~RES_TARGET; who |= (int)(tgt); }
+#define SET_RES_TARGET_LNX(who,tgt) { who &= ~RES_TARGET_LNX; who |= (int)(tgt) << 1; }
+#define SET_RES_MSG(who,msg) { who &= ~RES_ENDMSG; who |= (int)(msg) << 8; }
+#define SET_RES_DID(who,did) { who &= ~RES_DID; who |= (int)(did) << 16; }
+#define SET_RES_DRV(who,drv) { who &= ~RES_DRV; who |= (int)(drv) << 24; }
+
+/*
+**************************************************************************
+*/
+#define NO_IRQ 255
+#define TAG_NONE 255
+
+struct SGentry {
+	u32 address;		/* bus! address */
+	u32 length;
+};
+
+
+/*-----------------------------------------------------------------------
+  SCSI Request Block
+  -----------------------------------------------------------------------*/
+struct ScsiReqBlk {
+	struct ScsiReqBlk *pNextSRB;
+	struct DeviceCtlBlk *pSRBDCB;
+
+	/* HW scatter list (up to 64 entries) */
+	struct SGentry *SegmentX;
+	Scsi_Cmnd *pcmd;
+
+	/* Offset 0x20/0x10 */
+	unsigned char *virt_addr;	/* set by DC395x_update_SGlist */
+
+	u32 SRBTotalXferLength;
+	u32 Xferred;		/* Backup for the already xferred len */
+
+	u32 SRBSGBusAddr;	/* bus address of DC395x scatterlist */
+
+	u16 SRBState;
+	u8 SRBSGCount;
+	u8 SRBSGIndex;
+
+	/* Offset 0x38/0x24 */
+	u8 MsgInBuf[6];
+	u8 MsgOutBuf[6];
+
+	u8 AdaptStatus;
+	u8 TargetStatus;
+	u8 MsgCnt;
+	u8 EndMessage;
+
+	/* Offset 0x48/0x34 */
+	u8 *pMsgPtr;
+
+	u8 TagNumber;
+	u8 SRBStatus;
+	u8 RetryCnt;
+	u8 SRBFlag;
+
+	u8 ScsiPhase;
+	u8 padding;
+	u16 debugpos;
+	/* Offset 0x58/0x40 */
+#ifdef DC395x_DEBUGTRACE
+	char *debugtrace;
+	/* Offset 0x60/0x44 */
+#endif
+};
+
+
+/*-----------------------------------------------------------------------
+  Device Control Block
+  -----------------------------------------------------------------------*/
+struct DeviceCtlBlk {
+	struct DeviceCtlBlk *pNextDCB;
+	struct AdapterCtlBlk *pDCBACB;
+
+	struct ScsiReqBlk *pGoingSRB;
+	struct ScsiReqBlk *pGoingLast;
+
+/* 0x10: */
+	struct ScsiReqBlk *pWaitingSRB;
+	struct ScsiReqBlk *pWaitLast;
+
+	struct ScsiReqBlk *pActiveSRB;
+	u32 TagMask;
+
+/* 0x20: */
+	u16 MaxCommand;
+	u8 AdaptIndex;		/* UnitInfo struc start        */
+	u8 UnitIndex;		/* nth Unit on this card       */
+
+	u16 GoingSRBCnt;
+	u16 WaitSRBCnt;
+	u8 TargetID;		/* SCSI Target ID  (SCSI Only) */
+	u8 TargetLUN;		/* SCSI Log.  Unit (SCSI Only) */
+	u8 IdentifyMsg;
+	u8 DevMode;
+
+/* 0x2c: */
+/*    u8	AdpMode;*/
+	u8 Inquiry7;		/* To store Inquiry flags */
+	u8 SyncMode;		/* 0:async mode */
+	u8 MinNegoPeriod;	/* for nego. */
+	u8 SyncPeriod;		/* for reg.  */
+
+	u8 SyncOffset;		/* for reg. and nego.(low nibble) */
+	u8 UnitCtrlFlag;
+	u8 DCBFlag;
+	u8 DevType;
+	u8 init_TCQ_flag;
+
+	unsigned long last_derated;	/* last time, when features were turned off in abort */
+/* 0x38: */
+	/* u8       Reserved2[3];    for dword alignment */
+};
+
+/*-----------------------------------------------------------------------
+  Adapter Control Block
+  -----------------------------------------------------------------------*/
+struct AdapterCtlBlk {
+	struct Scsi_Host *pScsiHost;
+	struct AdapterCtlBlk *pNextACB;
+
+	u16 IOPortBase;
+	u16 Revxx1;
+
+	struct DeviceCtlBlk *pLinkDCB;
+	struct DeviceCtlBlk *pLastDCB;
+	struct DeviceCtlBlk *pDCBRunRobin;
+
+	struct DeviceCtlBlk *pActiveDCB;
+
+	struct ScsiReqBlk *pFreeSRB;
+	struct ScsiReqBlk *pTmpSRB;
+	struct timer_list Waiting_Timer;
+	struct timer_list SelTO_Timer;
+
+	u16 SRBCount;
+	u16 AdapterIndex;	/* nth Adapter this driver */
+
+	u32 QueryCnt;
+	Scsi_Cmnd *pQueryHead;
+	Scsi_Cmnd *pQueryTail;
+
+	u8 msgin123[4];
+
+	u8 status;
+	u8 DCBCnt;
+	u8 sel_timeout;
+	u8 dummy;
+
+	u8 IRQLevel;
+	u8 TagMaxNum;
+	u8 ACBFlag;
+	u8 Gmode2;
+
+	u8 Config;
+	u8 LUNchk;
+	u8 scan_devices;
+	u8 HostID_Bit;
+
+	u8 DCBmap[DC395x_MAX_SCSI_ID];
+	struct DeviceCtlBlk *children[DC395x_MAX_SCSI_ID][32];
+
+	u32 Cmds;
+	u32 SelLost;
+	u32 SelConn;
+	u32 CmdInQ;
+	u32 CmdOutOfSRB;
+
+	/*struct DeviceCtlBlk       DCB_array[DC395x_MAX_DCB]; *//*  +74h, Len=3E8  */
+	struct pci_dev *pdev;
+
+	u8 MsgLen;
+	u8 DeviceCnt;
+
+	struct ScsiReqBlk SRB_array[DC395x_MAX_SRB_CNT];
+	struct ScsiReqBlk TmpSRB;
+};
+
+
+/*
+ * The SEEPROM structure for TRM_S1040 
+ */
+struct NVRamTarget {
+	u8 NvmTarCfg0;		/* Target configuration byte 0  */
+	u8 NvmTarPeriod;	/* Target period                */
+	u8 NvmTarCfg2;		/* Target configuration byte 2  */
+	u8 NvmTarCfg3;		/* Target configuration byte 3  */
+};
+
+
+struct NvRamType {
+	u8 NvramSubVendorID[2];	/* 0,1  Sub Vendor ID   */
+	u8 NvramSubSysID[2];	/* 2,3  Sub System ID   */
+	u8 NvramSubClass;	/* 4    Sub Class       */
+	u8 NvramVendorID[2];	/* 5,6  Vendor ID       */
+	u8 NvramDeviceID[2];	/* 7,8  Device ID       */
+	u8 NvramReserved;	/* 9    Reserved        */
+	struct NVRamTarget NvramTarget[DC395x_MAX_SCSI_ID];
+						/** 10,11,12,13
+						 ** 14,15,16,17
+						 ** ....
+						 ** ....
+						 ** 70,71,72,73
+						 */
+	u8 NvramScsiId;		/* 74 Host Adapter SCSI ID      */
+	u8 NvramChannelCfg;	/* 75 Channel configuration     */
+	u8 NvramDelayTime;	/* 76 Power on delay time       */
+	u8 NvramMaxTag;		/* 77 Maximum tags              */
+	u8 NvramReserved0;	/* 78  */
+	u8 NvramBootTarget;	/* 79  */
+	u8 NvramBootLun;	/* 80  */
+	u8 NvramReserved1;	/* 81  */
+	u16 Reserved[22];	/* 82,..125 */
+	u16 NvramCheckSum;	/* 126,127 */
+};
+
+/*------------------------------------------------------------------------------*/
+
+void DC395x_DataOutPhase0(struct AdapterCtlBlk *pACB,
+			  struct ScsiReqBlk *pSRB, u16 * pscsi_status);
+void DC395x_DataInPhase0(struct AdapterCtlBlk *pACB,
+			 struct ScsiReqBlk *pSRB, u16 * pscsi_status);
+static void DC395x_CommandPhase0(struct AdapterCtlBlk *pACB,
+				 struct ScsiReqBlk *pSRB,
+				 u16 * pscsi_status);
+static void DC395x_StatusPhase0(struct AdapterCtlBlk *pACB,
+				struct ScsiReqBlk *pSRB,
+				u16 * pscsi_status);
+static void DC395x_MsgOutPhase0(struct AdapterCtlBlk *pACB,
+				struct ScsiReqBlk *pSRB,
+				u16 * pscsi_status);
+void DC395x_MsgInPhase0(struct AdapterCtlBlk *pACB,
+			struct ScsiReqBlk *pSRB, u16 * pscsi_status);
+static void DC395x_DataOutPhase1(struct AdapterCtlBlk *pACB,
+				 struct ScsiReqBlk *pSRB,
+				 u16 * pscsi_status);
+static void DC395x_DataInPhase1(struct AdapterCtlBlk *pACB,
+				struct ScsiReqBlk *pSRB,
+				u16 * pscsi_status);
+static void DC395x_CommandPhase1(struct AdapterCtlBlk *pACB,
+				 struct ScsiReqBlk *pSRB,
+				 u16 * pscsi_status);
+static void DC395x_StatusPhase1(struct AdapterCtlBlk *pACB,
+				struct ScsiReqBlk *pSRB,
+				u16 * pscsi_status);
+static void DC395x_MsgOutPhase1(struct AdapterCtlBlk *pACB,
+				struct ScsiReqBlk *pSRB,
+				u16 * pscsi_status);
+static void DC395x_MsgInPhase1(struct AdapterCtlBlk *pACB,
+			       struct ScsiReqBlk *pSRB,
+			       u16 * pscsi_status);
+static void DC395x_Nop0(struct AdapterCtlBlk *pACB,
+			struct ScsiReqBlk *pSRB, u16 * pscsi_status);
+static void DC395x_Nop1(struct AdapterCtlBlk *pACB,
+			struct ScsiReqBlk *pSRB, u16 * pscsi_status);
+static void DC395x_basic_config(struct AdapterCtlBlk *pACB);
+static void DC395x_cleanup_after_transfer(struct AdapterCtlBlk *pACB,
+					  struct ScsiReqBlk *pSRB);
+static void DC395x_ResetSCSIBus(struct AdapterCtlBlk *pACB);
+void DC395x_DataIO_transfer(struct AdapterCtlBlk *pACB,
+			    struct ScsiReqBlk *pSRB, u16 ioDir);
+void DC395x_Disconnect(struct AdapterCtlBlk *pACB);
+void DC395x_Reselect(struct AdapterCtlBlk *pACB);
+u8 DC395x_StartSCSI(struct AdapterCtlBlk *pACB, struct DeviceCtlBlk *pDCB,
+		    struct ScsiReqBlk *pSRB);
+static void DC395x_BuildSRB(Scsi_Cmnd * pcmd, struct DeviceCtlBlk *pDCB,
+			    struct ScsiReqBlk *pSRB);
+void DC395x_DoingSRB_Done(struct AdapterCtlBlk *pACB, u8 did_code,
+			  Scsi_Cmnd * pcmd, u8 force);
+static void DC395x_ScsiRstDetect(struct AdapterCtlBlk *pACB);
+static void DC395x_pci_unmap(struct AdapterCtlBlk *pACB,
+			     struct ScsiReqBlk *pSRB);
+static void DC395x_pci_unmap_sense(struct AdapterCtlBlk *pACB,
+				   struct ScsiReqBlk *pSRB);
+static inline void DC395x_EnableMsgOut_Abort(struct AdapterCtlBlk *pACB,
+					     struct ScsiReqBlk *pSRB);
+void DC395x_SRBdone(struct AdapterCtlBlk *pACB, struct DeviceCtlBlk *pDCB,
+		    struct ScsiReqBlk *pSRB);
+static void DC395x_RequestSense(struct AdapterCtlBlk *pACB,
+				struct DeviceCtlBlk *pDCB,
+				struct ScsiReqBlk *pSRB);
+static inline void DC395x_SetXferRate(struct AdapterCtlBlk *pACB,
+				      struct DeviceCtlBlk *pDCB);
+void DC395x_initDCB(struct AdapterCtlBlk *pACB,
+		    struct DeviceCtlBlk **ppDCB, u8 target, u8 lun);
+int DC395x_shutdown(struct Scsi_Host *host);
+static void DC395x_remove_dev(struct AdapterCtlBlk *pACB,
+			      struct DeviceCtlBlk *pDCB);
+
+
+static struct AdapterCtlBlk *DC395x_pACB_start = NULL;
+static struct AdapterCtlBlk *DC395x_pACB_current = NULL;
+static u16 DC395x_adapterCnt = 0;
+static u16 DC395x_CurrSyncOffset = 0;
+
+DEBUGRECURSION(static char in_driver = 0;
+    )
+static char DC395x_monitor_next_IRQ = 0;
+
+/* 
+ * DC395x_stateV = (void *)DC395x_SCSI_phase0[phase]
+ */
+static void *DC395x_SCSI_phase0[] = {
+	DC395x_DataOutPhase0,	/* phase:0 */
+	DC395x_DataInPhase0,	/* phase:1 */
+	DC395x_CommandPhase0,	/* phase:2 */
+	DC395x_StatusPhase0,	/* phase:3 */
+	DC395x_Nop0,		/* phase:4 PH_BUS_FREE .. initial phase */
+	DC395x_Nop0,		/* phase:5 PH_BUS_FREE .. initial phase */
+	DC395x_MsgOutPhase0,	/* phase:6 */
+	DC395x_MsgInPhase0,	/* phase:7 */
+};
+
+/*
+ * DC395x_stateV = (void *)DC395x_SCSI_phase1[phase]
+ */
+static void *DC395x_SCSI_phase1[] = {
+	DC395x_DataOutPhase1,	/* phase:0 */
+	DC395x_DataInPhase1,	/* phase:1 */
+	DC395x_CommandPhase1,	/* phase:2 */
+	DC395x_StatusPhase1,	/* phase:3 */
+	DC395x_Nop1,		/* phase:4 PH_BUS_FREE .. initial phase */
+	DC395x_Nop1,		/* phase:5 PH_BUS_FREE .. initial phase */
+	DC395x_MsgOutPhase1,	/* phase:6 */
+	DC395x_MsgInPhase1,	/* phase:7 */
+};
+
+struct NvRamType dc395x_trm_eepromBuf[DC395x_MAX_ADAPTER_NUM];
+/*
+ *Fast20:	000	 50ns, 20.0 MHz
+ *		001	 75ns, 13.3 MHz
+ *		010	100ns, 10.0 MHz
+ *		011	125ns,  8.0 MHz
+ *		100	150ns,  6.6 MHz
+ *		101	175ns,  5.7 MHz
+ *		110	200ns,  5.0 MHz
+ *		111	250ns,  4.0 MHz
+ *
+ *Fast40(LVDS):	000	 25ns, 40.0 MHz
+ *		001	 50ns, 20.0 MHz
+ *		010	 75ns, 13.3 MHz
+ *		011	100ns, 10.0 MHz
+ *		100	125ns,  8.0 MHz
+ *		101	150ns,  6.6 MHz
+ *		110	175ns,  5.7 MHz
+ *		111	200ns,  5.0 MHz
+ */
+/*static u8	dc395x_clock_period[] = {12,19,25,31,37,44,50,62};*/
+
+/* real period:48ns,76ns,100ns,124ns,148ns,176ns,200ns,248ns */
+static u8 dc395x_clock_period[] = { 12, 18, 25, 31, 37, 43, 50, 62 };
+static u16 dc395x_clock_speed[] = { 200, 133, 100, 80, 67, 58, 50, 40 };
+/* real period:48ns,72ns,100ns,124ns,148ns,172ns,200ns,248ns */
+
+/*
+ * Override defaults on cmdline:
+ * dc395x_trm = AdaptID, MaxSpeed (Index), DevMode (Bitmapped), AdaptMode (Bitmapped), Tags (log2-1), DelayReset
+ */
+int dc395x_trm[] = { -2, -2, -2, -2, -2, -2 };
+
+#if defined(MODULE)
+MODULE_PARM(dc395x_trm, "1-6i");
+MODULE_PARM_DESC(dc395x_trm,
+		 "Host SCSI ID, Speed (0=20MHz), Device Flags, Adapter Flags, Max Tags (log2(tags)-1), DelayReset (s)");
+#endif
+
+MODULE_AUTHOR("C.L. Huang / Erich Chen / Kurt Garloff");
+MODULE_DESCRIPTION
+    ("SCSI host adapter driver for Tekram TRM-S1040 based adapters: Tekram DC395 and DC315 series");
+MODULE_SUPPORTED_DEVICE("sd,sr,sg,st");
+
+MODULE_LICENSE("GPL");
+
+/* Delaying after a reset */
+static char __initdata DC395x_interpd[] = { 1, 3, 5, 10, 16, 30, 60, 120 };
+
+/* Convert EEprom value to seconds */
+static void __init DC395x_interpret_delay(struct NvRamType *eeprom)
+{
+	/*printk (DC395X_NAME ": Debug: Delay: %i\n", eeprom->NvramDelayTime); */
+	eeprom->NvramDelayTime = DC395x_interpd[eeprom->NvramDelayTime];
+}
+
+/* seconds to EEProm value */
+static int __init DC395x_uninterpret_delay(int delay)
+{
+	u8 idx = 0;
+	while (idx < 7 && DC395x_interpd[idx] < delay)
+		idx++;
+	return idx;
+}
+
+
+/* Handle "-1" case */
+static void __init DC395x_check_for_safe_settings(void)
+{
+	if (dc395x_trm[0] == -1 || dc395x_trm[0] > 15) {	/* modules-2.0.0 passes -1 as string */
+		dc395x_trm[0] = 7;
+		dc395x_trm[1] = 4;
+		dc395x_trm[2] = 0x09;
+		dc395x_trm[3] = 0x0f;
+		dc395x_trm[4] = 2;
+		dc395x_trm[5] = 10;
+		printk(KERN_INFO DC395X_NAME ": Using safe settings.\n");
+	}
+}
+
+/* Defaults, to be overriden by (a) BIOS and (b) Cmnd line (kernel/module) args */
+int __initdata dc395x_def[] = { 7, 1 /* 13.3MHz */ ,
+	NTC_DO_PARITY_CHK | NTC_DO_DISCONNECT | NTC_DO_SYNC_NEGO |
+	    NTC_DO_WIDE_NEGO | NTC_DO_TAG_QUEUEING | NTC_DO_SEND_START,
+	NAC_GT2DRIVES | NAC_GREATER_1G | NAC_POWERON_SCSI_RESET
+	    /* | NAC_ACTIVE_NEG */
+#ifdef CONFIG_SCSI_MULTI_LUN
+	    | NAC_SCANLUN
+#endif
+	    , 3 /* 16 Tags per LUN */ , 1	/* s delay after Reset */
+};
+
+/* Copy defaults over set values where missing */
+static void __init DC395x_fill_with_defaults(void)
+{
+	int i;
+	PARSEDEBUG(printk
+		   (KERN_INFO DC395X_NAME
+		    ": setup %08x %08x %08x %08x %08x %08x\n",
+		    dc395x_trm[0], dc395x_trm[1], dc395x_trm[2],
+		    dc395x_trm[3], dc395x_trm[4], dc395x_trm[5]);
+	    )
+	    for (i = 0; i < 6; i++) {
+		if (dc395x_trm[i] < 0 || dc395x_trm[i] > 255)
+			dc395x_trm[i] = dc395x_def[i];
+	}
+	/* Sanity checks */
+	if (dc395x_trm[0] > 15)
+		dc395x_trm[0] = 7;
+	if (dc395x_trm[1] > 7)
+		dc395x_trm[1] = 4;
+	if (dc395x_trm[4] > 5)
+		dc395x_trm[4] = 4;
+	if (dc395x_trm[5] > 180)
+		dc395x_trm[5] = 180;
+}
+
+
+/* Read the parameters from the command line */
+#if !defined(MODULE)
+static int DC395x_trm_setup(char *str)
+{
+	int i;
+	int im;
+	int ints[8];
+	(void) get_options(str, ARRAY_SIZE(ints), ints);
+	im = ints[0];
+	if (im > 6) {
+		printk(KERN_NOTICE DC395X_NAME ": ignore extra params!\n");
+		im = 6;
+	}
+	for (i = 0; i < im; i++)
+		dc395x_trm[i] = ints[i + 1];
+
+	return 1;
+}
+
+__setup(DC395X_NAME "=", DC395x_trm_setup);
+
+#endif				/* !MODULE */
+
+/* Overrride BIOS values with the set ones */
+static void __init DC395x_EEprom_Override(struct NvRamType *eeprom)
+{
+	u8 id;
+
+	/* Adapter Settings */
+	if (dc395x_trm[0] != -2)
+		eeprom->NvramScsiId = (u8) dc395x_trm[0];	/* Adapter ID */
+	if (dc395x_trm[3] != -2)
+		eeprom->NvramChannelCfg = (u8) dc395x_trm[3];
+	if (dc395x_trm[5] != -2)
+		eeprom->NvramDelayTime = DC395x_uninterpret_delay(dc395x_trm[5]);	/* Reset delay */
+	if (dc395x_trm[4] != -2)
+		eeprom->NvramMaxTag = (u8) dc395x_trm[4];	/* Tagged Cmds */
+
+	/* Device Settings */
+	for (id = 0; id < DC395x_MAX_SCSI_ID; id++) {
+		if (dc395x_trm[2] != -2)
+			eeprom->NvramTarget[id].NvmTarCfg0 = (u8) dc395x_trm[2];	/* Cfg0 */
+		if (dc395x_trm[1] != -2)
+			eeprom->NvramTarget[id].NvmTarPeriod = (u8) dc395x_trm[1];	/* Speed */
+	}
+}
+
+
+/*
+ * Queueing philosphy:
+ * There are a couple of lists:
+ * - Query: Contains the Scsi Commands not yet turned into SRBs (per ACB)
+ *   (Note: For new EH, it is unecessary!)
+ * - Waiting: Contains a list of SRBs not yet sent (per DCB)
+ * - Free: List of free SRB slots
+ * 
+ * If there are no waiting commands for the DCB, the new one is sent to the bus
+ * otherwise the oldest one is taken from the Waiting list and the new one is 
+ * queued to the Waiting List
+ * 
+ * Lists are managed using two pointers and eventually a counter
+ */
+
+/* Nomen est omen ... */
+static inline void
+DC395x_freetag(struct DeviceCtlBlk *pDCB, struct ScsiReqBlk *pSRB)
+{
+	if (pSRB->TagNumber < 255) {
+		pDCB->TagMask &= ~(1 << pSRB->TagNumber);	/* free tag mask */
+		pSRB->TagNumber = 255;
+	}
+}
+
+
+/* Find cmd in SRB list */
+inline static struct ScsiReqBlk *DC395x_find_cmd(Scsi_Cmnd * pcmd,
+						 struct ScsiReqBlk *start)
+{
+	struct ScsiReqBlk *psrb = start;
+	if (!start)
+		return 0;
+	do {
+		if (psrb->pcmd == pcmd)
+			return psrb;
+		psrb = psrb->pNextSRB;
+	} while (psrb && psrb != start);
+	return 0;
+}
+
+
+/* Append to Query List */
+static void
+DC395x_Query_append(Scsi_Cmnd * cmd, struct AdapterCtlBlk *pACB)
+{
+	DEBUG0(printk(DC395X_NAME ": Append cmd %li to Query\n", cmd->pid);
+	    )
+
+	    cmd->host_scribble = NULL;
+
+	if (!pACB->QueryCnt)
+		pACB->pQueryHead = cmd;
+	else
+		pACB->pQueryTail->host_scribble = (void *) cmd;
+
+	pACB->pQueryTail = cmd;
+	pACB->QueryCnt++;
+	pACB->CmdOutOfSRB++;
+}
+
+
+/* Return next cmd from Query list */
+static Scsi_Cmnd *DC395x_Query_get(struct AdapterCtlBlk *pACB)
+{
+	Scsi_Cmnd *pcmd;
+
+	pcmd = pACB->pQueryHead;
+	if (!pcmd)
+		return pcmd;
+	DEBUG0(printk(DC395X_NAME ": Get cmd %li from Query\n", pcmd->pid);
+	    )
+	    pACB->pQueryHead = (void *) pcmd->host_scribble;
+	pcmd->host_scribble = NULL;
+	if (!pACB->pQueryHead)
+		pACB->pQueryTail = NULL;
+	pACB->QueryCnt--;
+	return pcmd;
+}
+
+
+/* Return next free SRB */
+static __inline__ struct ScsiReqBlk *DC395x_Free_get(struct AdapterCtlBlk
+						     *pACB)
+{
+	struct ScsiReqBlk *pSRB;
+
+	/*DC395x_Free_integrity (pACB); */
+	pSRB = pACB->pFreeSRB;
+	if (!pSRB)
+		printk(DC395X_NAME ": Out of Free SRBs :-(\n");
+	if (pSRB) {
+		pACB->pFreeSRB = pSRB->pNextSRB;
+		pSRB->pNextSRB = NULL;
+	}
+
+	return pSRB;
+}
+
+
+/* Insert SRB oin top of free list */
+static __inline__ void
+DC395x_Free_insert(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB)
+{
+	DEBUG0(printk(DC395X_NAME ": Free SRB %p\n", pSRB);
+	    )
+	    pSRB->pNextSRB = pACB->pFreeSRB;
+	pACB->pFreeSRB = pSRB;
+}
+
+
+/* Inserts a SRB to the top of the Waiting list */
+static __inline__ void
+DC395x_Waiting_insert(struct DeviceCtlBlk *pDCB, struct ScsiReqBlk *pSRB)
+{
+	DEBUG0(printk
+	       (DC395X_NAME ": Insert pSRB %p cmd %li to Waiting\n", pSRB,
+		pSRB->pcmd->pid);
+	    )
+	    pSRB->pNextSRB = pDCB->pWaitingSRB;
+	if (!pDCB->pWaitingSRB)
+		pDCB->pWaitLast = pSRB;
+	pDCB->pWaitingSRB = pSRB;
+	pDCB->WaitSRBCnt++;
+}
+
+
+/* Queue SRB to waiting list */
+static __inline__ void
+DC395x_Waiting_append(struct DeviceCtlBlk *pDCB, struct ScsiReqBlk *pSRB)
+{
+	DEBUG0(printk
+	       (DC395X_NAME ": Append pSRB %p cmd %li to Waiting\n", pSRB,
+		pSRB->pcmd->pid);
+	    )
+	    if (pDCB->pWaitingSRB)
+		pDCB->pWaitLast->pNextSRB = pSRB;
+	else
+		pDCB->pWaitingSRB = pSRB;
+
+	pDCB->pWaitLast = pSRB;
+	/* No next one in waiting list */
+	pSRB->pNextSRB = NULL;
+	pDCB->WaitSRBCnt++;
+	/*pDCB->pDCBACB->CmdInQ++; */
+}
+
+
+static __inline__ void
+DC395x_Going_append(struct DeviceCtlBlk *pDCB, struct ScsiReqBlk *pSRB)
+{
+	DEBUG0(printk(DC395X_NAME ": Append SRB %p to Going\n", pSRB);
+	    )
+	    /* Append to the list of Going commands */
+	    if (pDCB->pGoingSRB)
+		pDCB->pGoingLast->pNextSRB = pSRB;
+	else
+		pDCB->pGoingSRB = pSRB;
+
+	pDCB->pGoingLast = pSRB;
+	/* No next one in sent list */
+	pSRB->pNextSRB = NULL;
+	pDCB->GoingSRBCnt++;
+}
+
+
+/* Find predecessor SRB */
+inline static struct ScsiReqBlk *DC395x_find_SRBpre(struct ScsiReqBlk
+						    *pSRB,
+						    struct ScsiReqBlk
+						    *start)
+{
+	struct ScsiReqBlk *srb = start;
+	if (!start)
+		return 0;
+	do {
+		if (srb->pNextSRB == pSRB)
+			return srb;
+		srb = srb->pNextSRB;
+	} while (srb && srb != start);
+	return 0;
+}
+
+
+/* Remove SRB from SRB queue */
+inline static struct ScsiReqBlk *DC395x_rmv_SRB(struct ScsiReqBlk *pSRB,
+						struct ScsiReqBlk *pre)
+{
+	if (pre->pNextSRB != pSRB)
+		pre = DC395x_find_SRBpre(pSRB, pre);
+	if (!pre) {
+		printk(DC395X_NAME
+		       ": Internal ERROR: SRB to rmv not found in Q!\n");
+		return 0;
+	}
+	pre->pNextSRB = pSRB->pNextSRB;
+	/*pSRB->pNextSRB = 0; */
+	return pre;
+}
+
+
+/* Remove SRB from Going queue */
+static void
+DC395x_Going_remove(struct DeviceCtlBlk *pDCB, struct ScsiReqBlk *pSRB,
+		    struct ScsiReqBlk *hint)
+{
+	struct ScsiReqBlk *pre = 0;
+	DEBUG0(printk(DC395X_NAME ": Remove SRB %p from Going\n", pSRB);
+	    )
+	    if (!pSRB)
+		printk(DC395X_NAME ": Going_remove %p!\n", pSRB);
+	if (pSRB == pDCB->pGoingSRB)
+		pDCB->pGoingSRB = pSRB->pNextSRB;
+	else if (hint && hint->pNextSRB == pSRB)
+		pre = DC395x_rmv_SRB(pSRB, hint);
+	else
+		pre = DC395x_rmv_SRB(pSRB, pDCB->pGoingSRB);
+	if (pSRB == pDCB->pGoingLast)
+		pDCB->pGoingLast = pre;
+	pDCB->GoingSRBCnt--;
+}
+
+
+/* Remove SRB from Waiting queue */
+static void
+DC395x_Waiting_remove(struct DeviceCtlBlk *pDCB, struct ScsiReqBlk *pSRB,
+		      struct ScsiReqBlk *hint)
+{
+	struct ScsiReqBlk *pre = 0;
+	DEBUG0(printk(DC395X_NAME ": Remove SRB %p from Waiting\n", pSRB);
+	    )
+	    if (!pSRB)
+		printk(DC395X_NAME ": Waiting_remove %p!\n", pSRB);
+	if (pSRB == pDCB->pWaitingSRB)
+		pDCB->pWaitingSRB = pSRB->pNextSRB;
+	else if (hint && hint->pNextSRB == pSRB)
+		pre = DC395x_rmv_SRB(pSRB, hint);
+	else
+		pre = DC395x_rmv_SRB(pSRB, pDCB->pWaitingSRB);
+	if (pSRB == pDCB->pWaitLast)
+		pDCB->pWaitLast = pre;
+	pDCB->WaitSRBCnt--;
+}
+
+
+/* Moves SRB from Going list to the top of Waiting list */
+static void
+DC395x_Going_to_Waiting(struct DeviceCtlBlk *pDCB, struct ScsiReqBlk *pSRB)
+{
+	DEBUG0(printk
+	       (KERN_INFO DC395X_NAME
+		": Going_to_Waiting (SRB %p) pid = %li\n", pSRB,
+		pSRB->pcmd->pid);
+	    )
+	    /* Remove SRB from Going */
+	    DC395x_Going_remove(pDCB, pSRB, 0);
+	TRACEPRINTF("GtW *");
+	/* Insert on top of Waiting */
+	DC395x_Waiting_insert(pDCB, pSRB);
+	/* Tag Mask must be freed elsewhere ! (KG, 99/06/18) */
+}
+
+
+/* Moves first SRB from Waiting list to Going list */
+static __inline__ void
+DC395x_Waiting_to_Going(struct DeviceCtlBlk *pDCB, struct ScsiReqBlk *pSRB)
+{
+	/* Remove from waiting list */
+	DEBUG0(printk
+	       (DC395X_NAME ": Remove SRB %p from head of Waiting\n",
+		pSRB);
+	    )
+	    DC395x_Waiting_remove(pDCB, pSRB, 0);
+	TRACEPRINTF("WtG *");
+	DC395x_Going_append(pDCB, pSRB);
+}
+
+
+void DC395x_waiting_timed_out(unsigned long ptr);
+/* Sets the timer to wake us up */
+static void
+DC395x_waiting_timer(struct AdapterCtlBlk *pACB, unsigned long to)
+{
+	if (timer_pending(&pACB->Waiting_Timer))
+		return;
+	init_timer(&pACB->Waiting_Timer);
+	pACB->Waiting_Timer.function = DC395x_waiting_timed_out;
+	pACB->Waiting_Timer.data = (unsigned long) pACB;
+	if (time_before
+	    (jiffies + to, pACB->pScsiHost->last_reset - HZ / 2))
+		pACB->Waiting_Timer.expires =
+		    pACB->pScsiHost->last_reset - HZ / 2 + 1;
+	else
+		pACB->Waiting_Timer.expires = jiffies + to + 1;
+	add_timer(&pACB->Waiting_Timer);
+}
+
+
+/* Send the next command from the waiting list to the bus */
+void DC395x_Waiting_process(struct AdapterCtlBlk *pACB)
+{
+	struct DeviceCtlBlk *ptr;
+	struct DeviceCtlBlk *ptr1;
+	struct ScsiReqBlk *pSRB;
+
+	if ((pACB->pActiveDCB)
+	    || (pACB->ACBFlag & (RESET_DETECT + RESET_DONE + RESET_DEV)))
+		return;
+	if (timer_pending(&pACB->Waiting_Timer))
+		del_timer(&pACB->Waiting_Timer);
+	ptr = pACB->pDCBRunRobin;
+	if (!ptr) {		/* This can happen! */
+		ptr = pACB->pLinkDCB;
+		pACB->pDCBRunRobin = ptr;
+	}
+	ptr1 = ptr;
+	if (!ptr1)
+		return;
+	do {
+		/* Make sure, the next another device gets scheduled ... */
+		pACB->pDCBRunRobin = ptr1->pNextDCB;
+		if (!(pSRB = ptr1->pWaitingSRB)
+		    || (ptr1->MaxCommand <= ptr1->GoingSRBCnt))
+			ptr1 = ptr1->pNextDCB;
+		else {
+			/* Try to send to the bus */
+			if (!DC395x_StartSCSI(pACB, ptr1, pSRB))
+				DC395x_Waiting_to_Going(ptr1, pSRB);
+			else
+				DC395x_waiting_timer(pACB, HZ / 50);
+			break;
+		}
+	} while (ptr1 != ptr);
+	return;
+}
+
+
+/* Wake up waiting queue */
+void DC395x_waiting_timed_out(unsigned long ptr)
+{
+	unsigned long flags;
+	struct AdapterCtlBlk *pACB = (struct AdapterCtlBlk *) ptr;
+#ifdef DC395x_DEBUG_KG
+	printk(DC395X_NAME ": Debug: Waiting queue woken up by timer.\n");
+#endif
+	DC395x_LOCK_IO(pACB->pScsiHost);
+	DC395x_Waiting_process(pACB);
+	DC395x_UNLOCK_IO(pACB->pScsiHost);
+}
+
+
+/* Get the DCB for a given ID/LUN combination */
+static inline struct DeviceCtlBlk *DC395x_findDCB(struct AdapterCtlBlk
+						  *pACB, u8 id, u8 lun)
+{
+	return pACB->children[id][lun];
+}
+
+
+/***********************************************************************
+ * Function: static void DC395x_SendSRB (struct AdapterCtlBlk* pACB, struct ScsiReqBlk* pSRB)
+ *
+ * Purpose: Send SCSI Request Block (pSRB) to adapter (pACB)
+ *
+ *            DC395x_queue_command
+ *            DC395x_Waiting_process
+ *
+ ***********************************************************************/
+static void
+DC395x_SendSRB(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB)
+{
+	struct DeviceCtlBlk *pDCB;
+
+	pDCB = pSRB->pSRBDCB;
+	if ((pDCB->MaxCommand <= pDCB->GoingSRBCnt) || (pACB->pActiveDCB)
+	    || (pACB->ACBFlag & (RESET_DETECT + RESET_DONE + RESET_DEV))) {
+		DC395x_Waiting_append(pDCB, pSRB);
+		DC395x_Waiting_process(pACB);
+		return;
+	}
+#if 0
+	if (pDCB->pWaitingSRB) {
+		DC395x_Waiting_append(pDCB, pSRB);
+		/*      pSRB = GetWaitingSRB(pDCB); *//* non-existent */
+		pSRB = pDCB->pWaitingSRB;
+		/* Remove from waiting list */
+		pDCB->pWaitingSRB = pSRB->pNextSRB;
+		pSRB->pNextSRB = NULL;
+		if (!pDCB->pWaitingSRB)
+			pDCB->pWaitLast = NULL;
+	}
+#endif
+
+	if (!DC395x_StartSCSI(pACB, pDCB, pSRB))
+		DC395x_Going_append(pDCB, pSRB);
+	else {
+		DC395x_Waiting_insert(pDCB, pSRB);
+		DC395x_waiting_timer(pACB, HZ / 50);
+	}
+}
+
+
+/*
+ *********************************************************************
+ *
+ * Function: static void DC395x_BuildSRB (Scsi_Cmd *pcmd, struct DeviceCtlBlk* pDCB, struct ScsiReqBlk* pSRB)
+ *
+ *  Purpose: Prepare SRB for being sent to Device DCB w/ command *pcmd
+ *
+ *********************************************************************
+ */
+static void
+DC395x_BuildSRB(Scsi_Cmnd * pcmd, struct DeviceCtlBlk *pDCB,
+		struct ScsiReqBlk *pSRB)
+{
+	int i, max;
+	struct SGentry *sgp;
+	struct scatterlist *sl;
+	u32 request_size;
+	int dir;
+
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME ": DC395x_BuildSRB..............\n ");
+#endif
+	/*memset (pSRB, 0, sizeof (struct ScsiReqBlk)); */
+	pSRB->pSRBDCB = pDCB;
+	pSRB->pcmd = pcmd;
+	/* Find out about direction */
+	dir = scsi_to_pci_dma_dir(pcmd->sc_data_direction);
+
+	if (pcmd->use_sg && dir != PCI_DMA_NONE) {
+		unsigned int len = 0;
+		/* TODO: In case usg_sg and the no of segments differ, things
+		 * will probably go wrong. */
+		max = pSRB->SRBSGCount =
+		    pci_map_sg(pDCB->pDCBACB->pdev,
+			       (struct scatterlist *) pcmd->request_buffer,
+			       pcmd->use_sg, dir);
+		sgp = pSRB->SegmentX;
+		request_size = pcmd->request_bufflen;
+#ifdef DC395x_SGPARANOIA
+		printk(KERN_INFO DC395X_NAME
+		       ": BuildSRB: Bufflen = %d, buffer = %p, use_sg = %d\n",
+		       pcmd->request_bufflen, pcmd->request_buffer,
+		       pcmd->use_sg);
+		printk(KERN_INFO DC395X_NAME
+		       ": Mapped %i Segments to %i\n", pcmd->use_sg,
+		       pSRB->SRBSGCount);
+#endif
+		sl = (struct scatterlist *) pcmd->request_buffer;
+
+		pSRB->virt_addr = page_address(sl->page);
+		for (i = 0; i < max; i++) {
+			u32 busaddr = (u32) sg_dma_address(&sl[i]);
+			u32 seglen = (u32) sl[i].length;
+			sgp[i].address = busaddr;
+			sgp[i].length = seglen;
+			len += seglen;
+#ifdef DC395x_SGPARANOIA
+			printk(KERN_INFO DC395X_NAME
+			       ": Setting up sgp %d, address = 0x%08x, length = %d, tot len = %d\n",
+			       i, busaddr, seglen, len);
+#endif
+		}
+		sgp += max - 1;
+		/* Fixup for last buffer too big as it is allocated on even page boundaries */
+		if (len > request_size) {
+#if defined(DC395x_DEBUG_KG) || defined (DC395x_SGPARANOIA)
+			printk(KERN_INFO DC395X_NAME
+			       ": Fixup SG total length: %d->%d, last seg %d->%d\n",
+			       len, request_size, sgp->length,
+			       sgp->length - (len - request_size));
+#endif
+			sgp->length -= (len - request_size);
+			len = request_size;
+		}
+		/* WIDE padding */
+		if (pDCB->SyncPeriod & WIDE_SYNC && len % 2) {
+			len++;
+			sgp->length++;
+		}
+		pSRB->SRBTotalXferLength = len;	/*? */
+		/* Hopefully this does not cross a page boundary ... */
+		pSRB->SRBSGBusAddr =
+		    pci_map_single(pDCB->pDCBACB->pdev, pSRB->SegmentX,
+				   sizeof(struct SGentry) *
+				   DC395x_MAX_SG_LISTENTRY,
+				   PCI_DMA_TODEVICE);
+#ifdef DC395x_SGPARANOIA
+		printk(DC395X_NAME
+		       ": Map SG descriptor list %p (%05x) to %08x\n",
+		       pSRB->SegmentX,
+		       sizeof(struct SGentry) * DC395x_MAX_SG_LISTENTRY,
+		       pSRB->SRBSGBusAddr);
+#endif
+	} else {
+		if (pcmd->request_buffer && dir != PCI_DMA_NONE) {
+			u32 len = pcmd->request_bufflen;	/* Actual request size */
+			pSRB->SRBSGCount = 1;
+			pSRB->SegmentX[0].address =
+			    pci_map_single(pDCB->pDCBACB->pdev,
+					   pcmd->request_buffer, len, dir);
+			/* WIDE padding */
+			if (pDCB->SyncPeriod & WIDE_SYNC && len % 2)
+				len++;
+			pSRB->SegmentX[0].length = len;
+			pSRB->SRBTotalXferLength = len;
+			pSRB->virt_addr = pcmd->request_buffer;
+			pSRB->SRBSGBusAddr = 0;
+#ifdef DC395x_SGPARANOIA
+			printk(KERN_INFO DC395X_NAME
+			       ": BuildSRB: len = %d, buffer = %p, use_sg = %d, map %08x\n",
+			       len, pcmd->request_buffer, pcmd->use_sg,
+			       pSRB->SegmentX[0].address);
+#endif
+		} else {
+			pSRB->SRBSGCount = 0;
+			pSRB->SRBTotalXferLength = 0;
+			pSRB->SRBSGBusAddr = 0;
+			pSRB->virt_addr = 0;
+#ifdef DC395x_SGPARANOIA
+			printk(KERN_INFO DC395X_NAME
+			       ": BuildSRB: buflen = %d, buffer = %p, use_sg = %d, NOMAP %08x\n",
+			       pcmd->bufflen, pcmd->request_buffer,
+			       pcmd->use_sg, pSRB->SegmentX[0].address);
+#endif
+		}
+	}
+
+	pSRB->SRBSGIndex = 0;
+	pSRB->AdaptStatus = 0;
+	pSRB->TargetStatus = 0;
+	pSRB->MsgCnt = 0;
+	pSRB->SRBStatus = 0;
+	pSRB->SRBFlag = 0;
+	pSRB->SRBState = 0;
+	pSRB->RetryCnt = 0;
+
+#if DC395x_SGPARANOIA
+	if ((unsigned long) pSRB->debugtrace & (DEBUGTRACEBUFSZ - 1)) {
+		printk(DC395X_NAME
+		       ": SRB %i (%p): debugtrace %p corrupt!\n",
+		       (pSRB -
+			pDCB->pDCBACB->SRB_array) /
+		       sizeof(struct ScsiReqBlk), pSRB, pSRB->debugtrace);
+	}
+#endif
+#ifdef DC395x_TRACEDEBUG
+	pSRB->debugpos = 0;
+	pSRB->debugtrace = 0;
+#endif
+	TRACEPRINTF("pid %li(%li):%02x %02x..(%i-%i) *", pcmd->pid,
+		    jiffies, pcmd->cmnd[0], pcmd->cmnd[1],
+		    pcmd->device->id, pcmd->device->lun);
+	pSRB->TagNumber = TAG_NONE;
+
+	pSRB->ScsiPhase = PH_BUS_FREE;	/* initial phase */
+	pSRB->EndMessage = 0;
+	return;
+}
+
+
+/* Put cmnd from Query to Waiting list and send next Waiting cmnd */
+static void DC395x_Query_to_Waiting(struct AdapterCtlBlk *pACB)
+{
+	Scsi_Cmnd *pcmd;
+	struct ScsiReqBlk *pSRB;
+	struct DeviceCtlBlk *pDCB;
+
+	if (pACB->ACBFlag & (RESET_DETECT + RESET_DONE + RESET_DEV))
+		return;
+
+	while (pACB->QueryCnt) {
+		pSRB = DC395x_Free_get(pACB);
+		if (!pSRB)
+			return;
+		pcmd = DC395x_Query_get(pACB);
+		if (!pcmd) {
+			DC395x_Free_insert(pACB, pSRB);
+			return;
+		}		/* should not happen */
+		pDCB =
+		    DC395x_findDCB(pACB, pcmd->device->id,
+				   pcmd->device->lun);
+		if (!pDCB) {
+			DC395x_Free_insert(pACB, pSRB);
+			printk(KERN_ERR DC395X_NAME
+			       ": Command in queue to non-existing device!\n");
+			pcmd->result =
+			    MK_RES(DRIVER_ERROR, DID_ERROR, 0, 0);
+			/*DC395x_UNLOCK_ACB_NI; */
+			pcmd->done(pcmd);
+			/*DC395x_LOCK_ACB_NI; */
+		}
+		DC395x_BuildSRB(pcmd, pDCB, pSRB);
+		DC395x_Waiting_append(pDCB, pSRB);
+	}
+}
+
+
+/***********************************************************************
+ * Function : static int DC395x_queue_command (Scsi_Cmnd *cmd,
+ *					       void (*done)(Scsi_Cmnd *))
+ *
+ * Purpose : enqueues a SCSI command
+ *
+ * Inputs : cmd - SCSI command, done - callback function called on 
+ *	    completion, with a pointer to the command descriptor.
+ *
+ * Returns : (depending on kernel version)
+ * 2.0.x: always return 0
+ * 2.1.x: old model: (use_new_eh_code == 0): like 2.0.x
+ *	  new model: return 0 if successful
+ *	  	     return 1 if command cannot be queued (queue full)
+ *		     command will be inserted in midlevel queue then ...
+ *
+ ***********************************************************************/
+static int
+DC395x_queue_command(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
+{
+	struct DeviceCtlBlk *pDCB;
+	struct ScsiReqBlk *pSRB;
+	struct AdapterCtlBlk *pACB =
+	    (struct AdapterCtlBlk *) cmd->device->host->hostdata;
+
+
+	DEBUG0(			/*  if(pACB->scan_devices) */
+		      printk(KERN_INFO DC395X_NAME
+			     ": Queue Cmd=%02x,Tgt=%d,LUN=%d (pid=%li)\n",
+			     cmd->cmnd[0], cmd->device->id,
+			     cmd->device->lun, cmd->pid);
+	    )
+
+	    DEBUGRECURSION(if (in_driver++ > NORM_REC_LVL)
+			   printk(DC395X_NAME
+				  ": %i queue_command () recursion? (pid=%li)\n",
+				  in_driver, cmd->pid);)
+
+		/* Assume BAD_TARGET; will be cleared later */
+		cmd->result = DID_BAD_TARGET << 16;
+
+	if ((cmd->device->id >= pACB->pScsiHost->max_id)
+	    || (cmd->device->lun >= pACB->pScsiHost->max_lun)
+	    || (cmd->device->lun >31)) {
+		/*      printk (KERN_INFO DC395X_NAME "Ignore target %d lun %d\n",
+		   cmd->device->id, cmd->device->lun); */
+		DEBUGRECURSION(in_driver--;
+		    )
+		    /*return 1; */
+		    done(cmd);
+		return 0;
+	}
+
+	if (!(pACB->DCBmap[cmd->device->id] & (1 << cmd->device->lun))) {
+		printk(KERN_INFO DC395X_NAME
+		       ": Ignore target %02x lun %02x\n", cmd->device->id,
+		       cmd->device->lun);
+		/*return 1; */
+		DEBUGRECURSION(in_driver--;
+		    )
+		    done(cmd);
+		return 0;
+	} else {
+		pDCB =
+		    DC395x_findDCB(pACB, cmd->device->id,
+				   cmd->device->lun);
+		if (!pDCB) {	/* should never happen */
+			printk(KERN_ERR DC395X_NAME
+			       ": no DCB failed, target %02x lun %02x\n",
+			       cmd->device->id, cmd->device->lun);
+			printk(DC395X_NAME
+			       ": No DCB in queuecommand (2)!\n");
+			DEBUGRECURSION(in_driver--;
+			    )
+			    return 1;
+		}
+	}
+
+	pACB->Cmds++;
+	cmd->scsi_done = done;
+	cmd->result = 0;
+
+	DC395x_Query_to_Waiting(pACB);
+
+	if (pACB->QueryCnt) {
+		/* Unsent commands ? */
+		DEBUG0(printk(DC395X_NAME ": QueryCnt != 0\n");
+		    )
+		    DC395x_Query_append(cmd, pACB);
+		DC395x_Waiting_process(pACB);
+	} else {
+		if (pDCB->pWaitingSRB) {
+			pSRB = DC395x_Free_get(pACB);
+			DEBUG0(if (!pSRB)
+			       printk(DC395X_NAME
+				      ": No free SRB but Waiting\n");
+			       else
+			       printk(DC395X_NAME
+				      ": Free SRB w/ Waiting\n");)
+				if (!pSRB) {
+					DC395x_Query_append(cmd, pACB);
+				} else {
+					DC395x_BuildSRB(cmd, pDCB, pSRB);
+					DC395x_Waiting_append(pDCB, pSRB);
+				}
+			DC395x_Waiting_process(pACB);
+		} else {
+			pSRB = DC395x_Free_get(pACB);
+			DEBUG0(if (!pSRB)
+			       printk(DC395X_NAME
+				      ": No free SRB w/o Waiting\n");
+			       else
+			       printk(DC395X_NAME
+				      ": Free SRB w/o Waiting\n");)
+				if (!pSRB) {
+					DC395x_Query_append(cmd, pACB);
+					DC395x_Waiting_process(pACB);
+				} else {
+					DC395x_BuildSRB(cmd, pDCB, pSRB);
+					DC395x_SendSRB(pACB, pSRB);
+				}
+		}
+	}
+
+	/*DC395x_ACB_LOCK(pACB,acb_flags); */
+	DEBUG1(printk
+	       (KERN_DEBUG " ... command (pid %li) queued successfully.\n",
+		cmd->pid);
+	    )
+	    DEBUGRECURSION(in_driver--;
+	    )
+	    return 0;
+}
+
+
+/***********************************************************************
+ * Function static int DC395x_slave_alloc()
+ *
+ * Purpose: Allocate DCB
+ ***********************************************************************/
+static int DC395x_slave_alloc(struct scsi_device *sdp)
+{
+	struct AdapterCtlBlk *pACB;
+	struct DeviceCtlBlk *dummy;
+
+	pACB = (struct AdapterCtlBlk *) sdp->host->hostdata;
+
+	DC395x_initDCB(pACB, &dummy, sdp->id, sdp->lun);
+
+	return dummy ? 0 : -ENOMEM;
+}
+
+
+static void DC395x_slave_destroy(struct scsi_device *sdp)
+{
+	struct AdapterCtlBlk *ACB;
+	struct DeviceCtlBlk *DCB;
+
+	ACB = (struct AdapterCtlBlk *) sdp->host->hostdata;
+	DCB = DC395x_findDCB(ACB, sdp->id, sdp->lun);
+
+	DC395x_remove_dev(ACB, DCB);
+}
+
+
+/***********************************************************************
+ * Function : static void DC395_updateDCB()
+ *
+ * Purpose :  Set the configuration dependent DCB parameters
+ ***********************************************************************/
+void
+DC395x_updateDCB(struct AdapterCtlBlk *pACB, struct DeviceCtlBlk *pDCB)
+{
+	/* Prevent disconnection of narrow devices if this_id > 7 */
+	if (!(pDCB->DevMode & NTC_DO_WIDE_NEGO)
+	    && pACB->pScsiHost->this_id > 7)
+		pDCB->DevMode &= ~NTC_DO_DISCONNECT;
+
+	/* TagQ w/o DisCn is impossible */
+	if (!(pDCB->DevMode & NTC_DO_DISCONNECT))
+		pDCB->DevMode &= ~NTC_DO_TAG_QUEUEING;
+	pDCB->IdentifyMsg =
+	    IDENTIFY((pDCB->DevMode & NTC_DO_DISCONNECT), pDCB->TargetLUN);
+
+	pDCB->SyncMode &=
+	    EN_TAG_QUEUEING | SYNC_NEGO_DONE | WIDE_NEGO_DONE
+	    /*| EN_ATN_STOP */ ;
+	if (pDCB->DevMode & NTC_DO_TAG_QUEUEING) {
+		if (pDCB->SyncMode & EN_TAG_QUEUEING)
+			pDCB->MaxCommand = pACB->TagMaxNum;
+	} else {
+		pDCB->SyncMode &= ~EN_TAG_QUEUEING;
+		pDCB->MaxCommand = 1;
+	}
+
+	if (pDCB->DevMode & NTC_DO_SYNC_NEGO)
+		pDCB->SyncMode |= SYNC_NEGO_ENABLE;
+	else {
+		pDCB->SyncMode &= ~(SYNC_NEGO_DONE | SYNC_NEGO_ENABLE);
+		pDCB->SyncOffset &= ~0x0f;
+	}
+
+	if (pDCB->DevMode & NTC_DO_WIDE_NEGO
+	    && pACB->Config & HCC_WIDE_CARD)
+		pDCB->SyncMode |= WIDE_NEGO_ENABLE;
+	else {
+		pDCB->SyncMode &= ~(WIDE_NEGO_DONE | WIDE_NEGO_ENABLE);
+		pDCB->SyncPeriod &= ~WIDE_SYNC;
+	}
+	/*if (! (pDCB->DevMode & EN_DISCONNECT_)) pDCB->SyncMode &= ~EN_ATN_STOP; */
+}
+
+
+/*
+ *********************************************************************
+ *
+ * Function   : DC395x_bios_param
+ * Description: Return the disk geometry for the given SCSI device.
+ *********************************************************************
+ */
+static int
+DC395x_bios_param(struct scsi_device *sdev, struct block_device *bdev,
+		  sector_t capacity, int *info)
+{
+#ifdef CONFIG_SCSI_DC395x_TRMS1040_TRADMAP
+	int heads, sectors, cylinders;
+	struct AdapterCtlBlk *pACB;
+	int size = capacity;
+
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME
+	       ":DC395x_bios_param..............\n ");
+#endif
+	pACB = (struct AdapterCtlBlk *) sdev->host->hostdata;
+	heads = 64;
+	sectors = 32;
+	cylinders = size / (heads * sectors);
+
+	if ((pACB->Gmode2 & NAC_GREATER_1G) && (cylinders > 1024)) {
+		heads = 255;
+		sectors = 63;
+		cylinders = size / (heads * sectors);
+	}
+	geom[0] = heads;
+	geom[1] = sectors;
+	geom[2] = cylinders;
+	return 0;
+#else
+	return scsicam_bios_param(bdev, capacity, info);
+#endif
+}
+
+
+/*
+ * DC395x register dump
+ */
+void
+DC395x_dumpinfo(struct AdapterCtlBlk *pACB, struct DeviceCtlBlk *pDCB,
+		struct ScsiReqBlk *pSRB)
+{
+	u16 pstat;
+	struct pci_dev *pdev = pACB->pdev;
+	pci_read_config_word(pdev, PCI_STATUS, &pstat);
+	if (!pDCB)
+		pDCB = pACB->pActiveDCB;
+	if (!pSRB && pDCB)
+		pSRB = pDCB->pActiveSRB;
+	if (pSRB) {
+		if (!(pSRB->pcmd))
+			printk(DC395X_NAME
+			       ": dump: SRB %p: cmd %p OOOPS!\n", pSRB,
+			       pSRB->pcmd);
+		else
+			printk(DC395X_NAME
+			       ": dump: SRB %p: cmd %p pid %li: %02x (%02i-%i)\n",
+			       pSRB, pSRB->pcmd, pSRB->pcmd->pid,
+			       pSRB->pcmd->cmnd[0], pSRB->pcmd->device->id,
+			       pSRB->pcmd->device->lun);
+		printk("              SGList %p Cnt %i Idx %i Len %i\n",
+		       pSRB->SegmentX, pSRB->SRBSGCount, pSRB->SRBSGIndex,
+		       pSRB->SRBTotalXferLength);
+		printk
+		    ("              State %04x Status %02x Phase %02x (%sconn.)\n",
+		     pSRB->SRBState, pSRB->SRBStatus, pSRB->ScsiPhase,
+		     (pACB->pActiveDCB) ? "" : "not");
+		TRACEOUT("        %s\n", pSRB->debugtrace);
+	}
+	printk(DC395X_NAME ": dump: SCSI block\n");
+	printk
+	    ("              Status %04x FIFOCnt %02x Signals %02x IRQStat %02x\n",
+	     DC395x_read16(TRM_S1040_SCSI_STATUS),
+	     DC395x_read8(TRM_S1040_SCSI_FIFOCNT),
+	     DC395x_read8(TRM_S1040_SCSI_SIGNAL),
+	     DC395x_read8(TRM_S1040_SCSI_INTSTATUS));
+	printk
+	    ("              Sync %02x Target %02x RSelID %02x SCSICtr %08x\n",
+	     DC395x_read8(TRM_S1040_SCSI_SYNC),
+	     DC395x_read8(TRM_S1040_SCSI_TARGETID),
+	     DC395x_read8(TRM_S1040_SCSI_IDMSG),
+	     DC395x_read32(TRM_S1040_SCSI_COUNTER));
+	printk
+	    ("              IRQEn %02x Config %04x Cfg2 %02x Cmd %02x SelTO %02x\n",
+	     DC395x_read8(TRM_S1040_SCSI_INTEN),
+	     DC395x_read16(TRM_S1040_SCSI_CONFIG0),
+	     DC395x_read8(TRM_S1040_SCSI_CONFIG2),
+	     DC395x_read8(TRM_S1040_SCSI_COMMAND),
+	     DC395x_read8(TRM_S1040_SCSI_TIMEOUT));
+	printk(DC395X_NAME ": dump: DMA block\n");
+	printk
+	    ("              Cmd %04x FIFOCnt %02x FStat %02x IRQStat %02x IRQEn %02x Cfg %04x\n",
+	     DC395x_read16(TRM_S1040_DMA_COMMAND),
+	     DC395x_read8(TRM_S1040_DMA_FIFOCNT),
+	     DC395x_read8(TRM_S1040_DMA_FIFOSTAT),
+	     DC395x_read8(TRM_S1040_DMA_STATUS),
+	     DC395x_read8(TRM_S1040_DMA_INTEN),
+	     DC395x_read16(TRM_S1040_DMA_CONFIG));
+	printk("              TCtr %08x CTCtr %08x Addr %08x%08x\n",
+	       DC395x_read32(TRM_S1040_DMA_XCNT),
+	       DC395x_read32(TRM_S1040_DMA_CXCNT),
+	       DC395x_read32(TRM_S1040_DMA_XHIGHADDR),
+	       DC395x_read32(TRM_S1040_DMA_XLOWADDR));
+	printk(DC395X_NAME
+	       ": dump: Misc: GCtrl %02x GStat %02x GTmr %02x\n",
+	       DC395x_read8(TRM_S1040_GEN_CONTROL),
+	       DC395x_read8(TRM_S1040_GEN_STATUS),
+	       DC395x_read8(TRM_S1040_GEN_TIMER));
+	printk(DC395X_NAME ": dump: PCI Status %04x\n", pstat);
+
+
+}
+
+
+static inline void DC395x_clrfifo(struct AdapterCtlBlk *pACB, char *txt)
+{
+#ifdef DC395x_DEBUGFIFO
+	u8 lines = DC395x_read8(TRM_S1040_SCSI_SIGNAL);
+	u8 fifocnt = DC395x_read8(TRM_S1040_SCSI_FIFOCNT);
+	if (!(fifocnt & 0x40))
+		printk(DC395X_NAME
+		       ": Clr FIFO (%i bytes) on phase %02x in %s\n",
+		       fifocnt & 0x3f, lines, txt);
+#endif
+	if (pACB->pActiveDCB && pACB->pActiveDCB->pActiveSRB) {
+		struct ScsiReqBlk *pSRB = pACB->pActiveDCB->pActiveSRB;
+		TRACEPRINTF("#*");
+	}
+	DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_CLRFIFO);
+}
+
+
+/*
+ ********************************************************************
+ *
+ *		DC395x_reset      DC395x_ScsiRstDetect
+ *
+ ********************************************************************
+ */
+static void DC395x_ResetDevParam(struct AdapterCtlBlk *pACB)
+{
+	struct DeviceCtlBlk *pDCB;
+	struct DeviceCtlBlk *pDCBTemp;
+	struct NvRamType *eeprom;
+	u8 PeriodIndex;
+	u16 index;
+
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME
+	       ": DC395x_ResetDevParam..............\n ");
+#endif
+	pDCB = pACB->pLinkDCB;
+	if (pDCB == NULL)
+		return;
+
+	pDCBTemp = pDCB;
+	do {
+		pDCB->SyncMode &= ~(SYNC_NEGO_DONE + WIDE_NEGO_DONE);
+		pDCB->SyncPeriod = 0;
+		pDCB->SyncOffset = 0;
+		index = pACB->AdapterIndex;
+		eeprom = &dc395x_trm_eepromBuf[index];
+
+		pDCB->DevMode =
+		    eeprom->NvramTarget[pDCB->TargetID].NvmTarCfg0;
+		/*pDCB->AdpMode = eeprom->NvramChannelCfg; */
+		PeriodIndex =
+		    eeprom->NvramTarget[pDCB->TargetID].
+		    NvmTarPeriod & 0x07;
+		pDCB->MinNegoPeriod = dc395x_clock_period[PeriodIndex];
+		if (!(pDCB->DevMode & NTC_DO_WIDE_NEGO)
+		    || !(pACB->Config & HCC_WIDE_CARD))
+			pDCB->SyncMode &= ~WIDE_NEGO_ENABLE;
+
+		pDCB = pDCB->pNextDCB;
+	}
+	while (pDCBTemp != pDCB && pDCB != NULL);
+}
+
+
+/*
+ *********************************************************************
+ * Function : int DC395x_eh_bus_reset(Scsi_Cmnd *cmd)
+ * Purpose  : perform a hard reset on the SCSI bus
+ * Inputs   : cmd - some command for this host (for fetching hooks)
+ * Returns  : SUCCESS (0x2002) on success, else FAILED (0x2003).
+ *********************************************************************
+ */
+static int DC395x_eh_bus_reset(Scsi_Cmnd * cmd)
+{
+	struct AdapterCtlBlk *pACB;
+	/*u32         acb_flags=0; */
+
+	printk(KERN_INFO DC395X_NAME ": reset requested!\n");
+	pACB = (struct AdapterCtlBlk *) cmd->device->host->hostdata;
+	/* mid level guarantees no recursion */
+	/*DC395x_ACB_LOCK(pACB,acb_flags); */
+
+	if (timer_pending(&pACB->Waiting_Timer))
+		del_timer(&pACB->Waiting_Timer);
+
+	/*
+	 * disable interrupt    
+	 */
+	DC395x_write8(TRM_S1040_DMA_INTEN, 0x00);
+	DC395x_write8(TRM_S1040_SCSI_INTEN, 0x00);
+	DC395x_write8(TRM_S1040_SCSI_CONTROL, DO_RSTMODULE);
+	DC395x_write8(TRM_S1040_DMA_CONTROL, DMARESETMODULE);
+
+	DC395x_ResetSCSIBus(pACB);
+	udelay(500);
+
+	/* We may be in serious trouble. Wait some seconds */
+	pACB->pScsiHost->last_reset =
+	    jiffies + 3 * HZ / 2 +
+	    HZ * dc395x_trm_eepromBuf[pACB->AdapterIndex].NvramDelayTime;
+
+	/*
+	 * re-enable interrupt      
+	 */
+	/* Clear SCSI FIFO          */
+	DC395x_write8(TRM_S1040_DMA_CONTROL, CLRXFIFO);
+	DC395x_clrfifo(pACB, "reset");
+	/* Delete pending IRQ */
+	DC395x_read8(TRM_S1040_SCSI_INTSTATUS);
+	DC395x_basic_config(pACB);
+
+	DC395x_ResetDevParam(pACB);
+	DC395x_DoingSRB_Done(pACB, DID_RESET, cmd, 0);
+
+	pACB->pActiveDCB = NULL;
+
+	pACB->ACBFlag = 0;	/* RESET_DETECT, RESET_DONE ,RESET_DEV */
+	DC395x_Waiting_process(pACB);
+
+	/*DC395x_ACB_LOCK(pACB,acb_flags); */
+	return SUCCESS;
+}
+
+
+/*
+ *********************************************************************
+ * Function : int DC395x_eh_abort(Scsi_Cmnd *cmd)
+ * Purpose  : abort an errant SCSI command
+ * Inputs   : cmd - command to be aborted
+ * Returns  : SUCCESS (0x2002) on success, else FAILED (0x2003).
+ *********************************************************************
+ */
+static int DC395x_eh_abort(Scsi_Cmnd * cmd)
+{
+	/*
+	 * Look into our command queues: If it has not been sent already,
+	 * we remove it and return success. Otherwise fail.
+	 * First check the Query Queues, then the Waiting ones
+	 */
+	struct AdapterCtlBlk *pACB =
+	    (struct AdapterCtlBlk *) cmd->device->host->hostdata;
+	struct DeviceCtlBlk *pDCB;
+	struct ScsiReqBlk *pSRB;
+	int cnt = pACB->QueryCnt;
+	Scsi_Cmnd *pcmd;
+	Scsi_Cmnd *last = 0;
+	printk(DC395X_NAME ": DC395x_eh_abort: cmd %p (pid %li, %02i-%i) ",
+	       cmd, cmd->pid, cmd->device->id, cmd->device->lun);
+	for (pcmd = pACB->pQueryHead; cnt--;
+	     last = pcmd, pcmd = (Scsi_Cmnd *) pcmd->host_scribble) {
+		if (pcmd == cmd) {
+			/* unqueue */
+			if (last) {
+				last->host_scribble = pcmd->host_scribble;
+				if (!pcmd->host_scribble)
+					pACB->pQueryTail = last;
+			} else {
+				pACB->pQueryHead =
+				    (Scsi_Cmnd *) pcmd->host_scribble;
+				if (!pcmd->host_scribble)
+					pACB->pQueryTail = 0;
+			}
+			printk("found in Query queue :-)\n");
+			pACB->QueryCnt--;
+			cmd->result = DID_ABORT << 16;
+			return SUCCESS;
+		}
+	}
+	pDCB = DC395x_findDCB(pACB, cmd->device->id, cmd->device->lun);
+	if (!pDCB) {
+		printk("no DCB !\n");
+		return FAILED;
+	}
+
+	pSRB = DC395x_find_cmd(cmd, pDCB->pWaitingSRB);
+	if (pSRB) {
+		DC395x_Waiting_remove(pDCB, pSRB, 0);
+		DC395x_pci_unmap_sense(pACB, pSRB);
+		DC395x_pci_unmap(pACB, pSRB);
+		DC395x_freetag(pDCB, pSRB);
+		DC395x_Free_insert(pACB, pSRB);
+		printk("found in waiting queue :-)\n");
+		cmd->result = DID_ABORT << 16;
+		return SUCCESS;
+	}
+	pSRB = DC395x_find_cmd(cmd, pDCB->pGoingSRB);
+	if (pSRB)
+		printk("found in going queue :-(\n");
+	else
+		printk("not found!\n");
+	return FAILED;
+}
+
+
+/*
+ * TODO (new EH):
+ * int (*eh_device_reset_handler)(Scsi_Cmnd *);
+ * int (*eh_host_reset_handler)(Scsi_Cmnd *);
+ * 
+ * remove Query Queue
+ * investigate whether/which commands need to be ffed back to mid-layer
+ * in _eh_reset()
+ */
+
+
+/* SDTR */
+static void
+DC395x_Build_SDTR(struct AdapterCtlBlk *pACB, struct DeviceCtlBlk *pDCB,
+		  struct ScsiReqBlk *pSRB)
+{
+	u8 *ptr = pSRB->MsgOutBuf + pSRB->MsgCnt;
+	if (pSRB->MsgCnt > 1) {
+		printk(DC395X_NAME
+		       ": Build_SDTR: MsgOutBuf BUSY (%i: %02x %02x)\n",
+		       pSRB->MsgCnt, pSRB->MsgOutBuf[0],
+		       pSRB->MsgOutBuf[1]);
+		return;
+	}
+	if (!(pDCB->DevMode & NTC_DO_SYNC_NEGO)) {
+		pDCB->SyncOffset = 0;
+		pDCB->MinNegoPeriod = 200 >> 2;
+	} else if (pDCB->SyncOffset == 0)
+		pDCB->SyncOffset = SYNC_NEGO_OFFSET;
+
+	*ptr++ = MSG_EXTENDED;	/* (01h) */
+	*ptr++ = 3;		/* length */
+	*ptr++ = EXTENDED_SDTR;	/* (01h) */
+	*ptr++ = pDCB->MinNegoPeriod;	/* Transfer period (in 4ns) */
+	*ptr++ = pDCB->SyncOffset;	/* Transfer period (max. REQ/ACK dist) */
+	pSRB->MsgCnt += 5;
+	pSRB->SRBState |= SRB_DO_SYNC_NEGO;
+	TRACEPRINTF("S *");
+}
+
+
+/* SDTR */
+static void
+DC395x_Build_WDTR(struct AdapterCtlBlk *pACB, struct DeviceCtlBlk *pDCB,
+		  struct ScsiReqBlk *pSRB)
+{
+	u8 wide =
+	    ((pDCB->DevMode & NTC_DO_WIDE_NEGO) & (pACB->
+						   Config & HCC_WIDE_CARD))
+	    ? 1 : 0;
+	u8 *ptr = pSRB->MsgOutBuf + pSRB->MsgCnt;
+	if (pSRB->MsgCnt > 1) {
+		printk(DC395X_NAME
+		       ": Build_WDTR: MsgOutBuf BUSY (%i: %02x %02x)\n",
+		       pSRB->MsgCnt, pSRB->MsgOutBuf[0],
+		       pSRB->MsgOutBuf[1]);
+		return;
+	}
+	*ptr++ = MSG_EXTENDED;	/* (01h) */
+	*ptr++ = 2;		/* length */
+	*ptr++ = EXTENDED_WDTR;	/* (03h) */
+	*ptr++ = wide;
+	pSRB->MsgCnt += 4;
+	pSRB->SRBState |= SRB_DO_WIDE_NEGO;
+	TRACEPRINTF("W *");
+}
+
+
+#if 0
+/* Timer to work around chip flaw: When selecting and the bus is 
+ * busy, we sometimes miss a Selection timeout IRQ */
+void DC395x_selection_timeout_missed(unsigned long ptr);
+/* Sets the timer to wake us up */
+static void DC395x_selto_timer(struct AdapterCtlBlk *pACB)
+{
+	if (timer_pending(&pACB->SelTO_Timer))
+		return;
+	init_timer(&pACB->SelTO_Timer);
+	pACB->SelTO_Timer.function = DC395x_selection_timeout_missed;
+	pACB->SelTO_Timer.data = (unsigned long) pACB;
+	if (time_before
+	    (jiffies + HZ, pACB->pScsiHost->last_reset + HZ / 2))
+		pACB->SelTO_Timer.expires =
+		    pACB->pScsiHost->last_reset + HZ / 2 + 1;
+	else
+		pACB->SelTO_Timer.expires = jiffies + HZ + 1;
+	add_timer(&pACB->SelTO_Timer);
+}
+
+
+void DC395x_selection_timeout_missed(unsigned long ptr)
+{
+	unsigned long flags;
+	struct AdapterCtlBlk *pACB = (struct AdapterCtlBlk *) ptr;
+	struct ScsiReqBlk *pSRB;
+	printk(DC395X_NAME ": Debug: Chip forgot to produce SelTO IRQ!\n");
+	if (!pACB->pActiveDCB || !pACB->pActiveDCB->pActiveSRB) {
+		printk(DC395X_NAME ": ... but no cmd pending? Oops!\n");
+		return;
+	}
+	DC395x_LOCK_IO(pACB->pScsiHost);
+	pSRB = pACB->pActiveDCB->pActiveSRB;
+	TRACEPRINTF("N/TO *");
+	DC395x_Disconnect(pACB);
+	DC395x_UNLOCK_IO(pACB->pScsiHost);
+}
+#endif
+
+
+/*
+ * scsiio
+ *		DC395x_DoWaitingSRB    DC395x_SRBdone 
+ *		DC395x_SendSRB         DC395x_RequestSense
+ */
+u8
+DC395x_StartSCSI(struct AdapterCtlBlk * pACB, struct DeviceCtlBlk * pDCB,
+		 struct ScsiReqBlk * pSRB)
+{
+	u16 s_stat2, return_code;
+	u8 s_stat, scsicommand, i, identify_message;
+	u8 *ptr;
+
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME
+	       ": DC395x_StartSCSI..............\n ");
+#endif
+	pSRB->TagNumber = TAG_NONE;	/* pACB->TagMaxNum: had error read in eeprom */
+
+	s_stat = DC395x_read8(TRM_S1040_SCSI_SIGNAL);
+	s_stat2 = 0;
+	s_stat2 = DC395x_read16(TRM_S1040_SCSI_STATUS);
+	TRACEPRINTF("Start %02x *", s_stat);
+#if 1
+	if (s_stat & 0x20 /* s_stat2 & 0x02000 */ ) {
+#ifdef DC395x_DEBUG_KG
+		printk(DC395X_NAME
+		       ": Debug: StartSCSI: pid %li(%02i-%i): BUSY %02x %04x\n",
+		       pSRB->pcmd->pid, pDCB->TargetID, pDCB->TargetLUN,
+		       s_stat, s_stat2);
+#endif
+		/*
+		 * Try anyway?
+		 *
+		 * We could, BUT: Sometimes the TRM_S1040 misses to produce a Selection
+		 * Timeout, a Disconnect or a Reselction IRQ, so we would be screwed!
+		 * (This is likely to be a bug in the hardware. Obviously, most people
+		 *  only have one initiator per SCSI bus.)
+		 * Instead let this fail and have the timer make sure the command is 
+		 * tried again after a short time
+		 */
+		TRACEPRINTF("^*");
+		/*DC395x_selto_timer (pACB); */
+		/*DC395x_monitor_next_IRQ = 1; */
+		return 1;
+	}
+#endif
+	if (pACB->pActiveDCB) {
+		printk(DC395X_NAME
+		       ": We try to start a SCSI command (%li)!\n",
+		       pSRB->pcmd->pid);
+		printk(DC395X_NAME
+		       ": While another one (%li) is active!!\n",
+		       (pACB->pActiveDCB->pActiveSRB ? pACB->pActiveDCB->
+			pActiveSRB->pcmd->pid : 0));
+		TRACEOUT(" %s\n", pSRB->debugtrace);
+		if (pACB->pActiveDCB->pActiveSRB)
+			TRACEOUT(" %s\n",
+				 pACB->pActiveDCB->pActiveSRB->debugtrace);
+		return 1;
+	}
+	if (DC395x_read16(TRM_S1040_SCSI_STATUS) & SCSIINTERRUPT) {
+#ifdef DC395x_DEBUG_KG
+		printk(DC395X_NAME
+		       ": Debug: StartSCSI failed (busy) for pid %li(%02i-%i)\n",
+		       pSRB->pcmd->pid, pDCB->TargetID, pDCB->TargetLUN);
+#endif
+		TRACEPRINTF("°*");
+		return 1;
+	}
+	/* Allow starting of SCSI commands half a second before we allow the mid-level
+	 * to queue them again after a reset */
+	if (time_before(jiffies, pACB->pScsiHost->last_reset - HZ / 2)) {
+#ifdef DC395x_DEBUG_KG
+		printk(DC395X_NAME
+		       ": We were just reset and don't accept commands yet!\n");
+#endif
+		return 1;
+	}
+
+	/* Flush FIFO */
+	DC395x_clrfifo(pACB, "Start");
+	DC395x_write8(TRM_S1040_SCSI_HOSTID, pACB->pScsiHost->this_id);
+	DC395x_write8(TRM_S1040_SCSI_TARGETID, pDCB->TargetID);
+	DC395x_write8(TRM_S1040_SCSI_SYNC, pDCB->SyncPeriod);
+	DC395x_write8(TRM_S1040_SCSI_OFFSET, pDCB->SyncOffset);
+	pSRB->ScsiPhase = PH_BUS_FREE;	/* initial phase */
+
+	identify_message = pDCB->IdentifyMsg;
+	/*DC395x_TRM_write8(TRM_S1040_SCSI_IDMSG, identify_message); */
+	/* Don't allow disconnection for AUTO_REQSENSE: Cont.All.Cond.! */
+	if (pSRB->SRBFlag & AUTO_REQSENSE)
+		identify_message &= 0xBF;
+
+	if (((pSRB->pcmd->cmnd[0] == INQUIRY)
+	     || (pSRB->pcmd->cmnd[0] == REQUEST_SENSE)
+	     || (pSRB->SRBFlag & AUTO_REQSENSE))
+	    && (((pDCB->SyncMode & WIDE_NEGO_ENABLE)
+		 && !(pDCB->SyncMode & WIDE_NEGO_DONE))
+		|| ((pDCB->SyncMode & SYNC_NEGO_ENABLE)
+		    && !(pDCB->SyncMode & SYNC_NEGO_DONE)))
+	    && (pDCB->TargetLUN == 0)) {
+		pSRB->MsgOutBuf[0] = identify_message;
+		pSRB->MsgCnt = 1;
+		scsicommand = SCMD_SEL_ATNSTOP;
+		pSRB->SRBState = SRB_MSGOUT;
+#ifndef SYNC_FIRST
+		if (pDCB->SyncMode & WIDE_NEGO_ENABLE
+		    && pDCB->Inquiry7 & SCSI_INQ_WBUS16) {
+			DC395x_Build_WDTR(pACB, pDCB, pSRB);
+			goto no_cmd;
+		}
+#endif
+		if (pDCB->SyncMode & SYNC_NEGO_ENABLE
+		    && pDCB->Inquiry7 & SCSI_INQ_SYNC) {
+			DC395x_Build_SDTR(pACB, pDCB, pSRB);
+			goto no_cmd;
+		}
+		if (pDCB->SyncMode & WIDE_NEGO_ENABLE
+		    && pDCB->Inquiry7 & SCSI_INQ_WBUS16) {
+			DC395x_Build_WDTR(pACB, pDCB, pSRB);
+			goto no_cmd;
+		}
+		pSRB->MsgCnt = 0;
+	}
+	/* 
+	 ** Send identify message   
+	 */
+	DC395x_write8(TRM_S1040_SCSI_FIFO, identify_message);
+
+	scsicommand = SCMD_SEL_ATN;
+	pSRB->SRBState = SRB_START_;
+#ifndef DC395x_NO_TAGQ
+	if ((pDCB->SyncMode & EN_TAG_QUEUEING)
+	    && (identify_message & 0xC0)) {
+		/* Send Tag message */
+		u32 tag_mask = 1;
+		u8 tag_number = 0;
+		while (tag_mask & pDCB->TagMask
+		       && tag_number <= pDCB->MaxCommand) {
+			tag_mask = tag_mask << 1;
+			tag_number++;
+		}
+		if (tag_number >= pDCB->MaxCommand) {
+			printk(KERN_WARNING DC395X_NAME
+			       ": Start_SCSI: Out of tags for pid %li (%i-%i)\n",
+			       pSRB->pcmd->pid, pSRB->pcmd->device->id,
+			       pSRB->pcmd->device->lun);
+			pSRB->SRBState = SRB_READY;
+			DC395x_write16(TRM_S1040_SCSI_CONTROL,
+				       DO_HWRESELECT);
+			return 1;
+		}
+		/* 
+		 ** Send Tag id
+		 */
+		DC395x_write8(TRM_S1040_SCSI_FIFO, MSG_SIMPLE_QTAG);
+		DC395x_write8(TRM_S1040_SCSI_FIFO, tag_number);
+		pDCB->TagMask |= tag_mask;
+		pSRB->TagNumber = tag_number;
+		TRACEPRINTF("Tag %i *", tag_number);
+
+		scsicommand = SCMD_SEL_ATN3;
+		pSRB->SRBState = SRB_START_;
+	}
+#endif
+/*polling:*/
+	/*
+	 *          Send CDB ..command block .........                     
+	 */
+#ifdef DC395x_DEBUG_KG
+	printk(KERN_INFO DC395X_NAME
+	       ": StartSCSI (pid %li) %02x (%i-%i): Tag %i\n",
+	       pSRB->pcmd->pid, pSRB->pcmd->cmnd[0],
+	       pSRB->pcmd->device->id, pSRB->pcmd->device->lun,
+	       pSRB->TagNumber);
+#endif
+	if (pSRB->SRBFlag & AUTO_REQSENSE) {
+		DC395x_write8(TRM_S1040_SCSI_FIFO, REQUEST_SENSE);
+		DC395x_write8(TRM_S1040_SCSI_FIFO, (pDCB->TargetLUN << 5));
+		DC395x_write8(TRM_S1040_SCSI_FIFO, 0);
+		DC395x_write8(TRM_S1040_SCSI_FIFO, 0);
+		DC395x_write8(TRM_S1040_SCSI_FIFO,
+			      sizeof(pSRB->pcmd->sense_buffer));
+		DC395x_write8(TRM_S1040_SCSI_FIFO, 0);
+	} else {
+		ptr = (u8 *) pSRB->pcmd->cmnd;
+		for (i = 0; i < pSRB->pcmd->cmd_len; i++)
+			DC395x_write8(TRM_S1040_SCSI_FIFO, *ptr++);
+	}
+      no_cmd:
+	DC395x_write16(TRM_S1040_SCSI_CONTROL,
+		       DO_HWRESELECT | DO_DATALATCH);
+	if (DC395x_read16(TRM_S1040_SCSI_STATUS) & SCSIINTERRUPT) {
+		/* 
+		 * If DC395x_StartSCSI return 1:
+		 * we caught an interrupt (must be reset or reselection ... )
+		 * : Let's process it first!
+		 */
+		DEBUG0(printk
+		       (DC395X_NAME
+			": Debug: StartSCSI failed (busy) for pid %li(%02i-%i)!\n",
+			pSRB->pcmd->pid, pDCB->TargetID, pDCB->TargetLUN);
+		    )
+		    /*DC395x_clrfifo (pACB, "Start2"); */
+		    /*DC395x_write16 (TRM_S1040_SCSI_CONTROL, DO_HWRESELECT | DO_DATALATCH); */
+		    pSRB->SRBState = SRB_READY;
+		DC395x_freetag(pDCB, pSRB);
+		pSRB->MsgCnt = 0;
+		return_code = 1;
+		/* This IRQ should NOT get lost, as we did not acknowledge it */
+	} else {
+		/* 
+		 * If DC395x_StartSCSI returns 0:
+		 * we know that the SCSI processor is free
+		 */
+		pSRB->ScsiPhase = PH_BUS_FREE;	/* initial phase */
+		pDCB->pActiveSRB = pSRB;
+		pACB->pActiveDCB = pDCB;
+		return_code = 0;
+		/* it's important for atn stop */
+		DC395x_write16(TRM_S1040_SCSI_CONTROL,
+			       DO_DATALATCH | DO_HWRESELECT);
+		/*
+		 ** SCSI command
+		 */
+		TRACEPRINTF("%02x *", scsicommand);
+		DC395x_write8(TRM_S1040_SCSI_COMMAND, scsicommand);
+	}
+	return return_code;
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *		DC395x_initAdapter
+ ********************************************************************
+ */
+
+/**
+ * dc395x_handle_interrupt - Handle an interrupt that has been confirmed to
+ *                           have been triggered for this card.
+ *
+ * @pACB:	 a pointer to the adpter control block
+ * @scsi_status: the status return when we checked the card
+ **/
+static void dc395x_handle_interrupt(struct AdapterCtlBlk *pACB, u16 scsi_status)
+{
+	struct DeviceCtlBlk *pDCB;
+	struct ScsiReqBlk *pSRB;
+	u16 phase;
+	u8 scsi_intstatus;
+	unsigned long flags;
+	void (*DC395x_stateV) (struct AdapterCtlBlk *, struct ScsiReqBlk *,
+			       u16 *);
+
+	DC395x_LOCK_IO(pACB->pScsiHost);
+
+	/* This acknowledges the IRQ */
+	scsi_intstatus = DC395x_read8(TRM_S1040_SCSI_INTSTATUS);
+	if ((scsi_status & 0x2007) == 0x2002)
+		printk(DC395X_NAME ": COP after COP completed? %04x\n",
+		       scsi_status);
+#if 1				/*def DC395x_DEBUG0 */
+	if (DC395x_monitor_next_IRQ) {
+		printk(KERN_INFO DC395X_NAME
+		       ": status=%04x intstatus=%02x\n", scsi_status,
+		       scsi_intstatus);
+		DC395x_monitor_next_IRQ--;
+	}
+#endif
+	/*DC395x_ACB_LOCK(pACB,acb_flags); */
+#ifdef DC395x_DEBUG_KG
+	if (scsi_intstatus & INT_SELTIMEOUT)
+		printk(KERN_INFO DC395X_NAME ": Sel Timeout IRQ\n");
+#endif
+	/*printk (DC395X_NAME ": DC395x_IRQ: intstatus = %02x ", scsi_intstatus); */
+
+	if (timer_pending(&pACB->SelTO_Timer))
+		del_timer(&pACB->SelTO_Timer);
+
+	if (scsi_intstatus & (INT_SELTIMEOUT | INT_DISCONNECT)) {
+		DC395x_Disconnect(pACB);	/* bus free interrupt  */
+		goto out_unlock;
+	}
+	if (scsi_intstatus & INT_RESELECTED) {
+		DC395x_Reselect(pACB);
+		goto out_unlock;
+	}
+	if (scsi_intstatus & INT_SELECT) {
+		printk(KERN_INFO DC395X_NAME
+		       ": Host does not support target mode!\n");
+		goto out_unlock;
+	}
+	if (scsi_intstatus & INT_SCSIRESET) {
+		DC395x_ScsiRstDetect(pACB);
+		goto out_unlock;
+	}
+	if (scsi_intstatus & (INT_BUSSERVICE | INT_CMDDONE)) {
+		pDCB = pACB->pActiveDCB;
+		if (!pDCB) {
+			printk(DC395X_NAME
+			       ": Oops: BusService (%04x %02x) w/o ActiveDCB!\n",
+			       scsi_status, scsi_intstatus);
+			goto out_unlock;
+		}
+		pSRB = pDCB->pActiveSRB;
+		if (pDCB->DCBFlag & ABORT_DEV_) {
+#ifdef DC395x_DEBUG0
+			printk(KERN_INFO "MsgOut Abort Device..... ");
+#endif
+			DC395x_EnableMsgOut_Abort(pACB, pSRB);
+		}
+		/*
+		 ************************************************************
+		 * software sequential machine
+		 ************************************************************
+		 */
+		phase = (u16) pSRB->ScsiPhase;
+		/* 
+		 * 62037 or 62137
+		 * call  DC395x_SCSI_phase0[]... "phase entry"
+		 * handle every phase before start transfer
+		 */
+		/* DC395x_DataOutPhase0,     phase:0 */
+		/* DC395x_DataInPhase0,      phase:1 */
+		/* DC395x_CommandPhase0,     phase:2 */
+		/* DC395x_StatusPhase0,      phase:3 */
+		/* DC395x_Nop0,              phase:4 PH_BUS_FREE .. initial phase */
+		/* DC395x_Nop0,              phase:5 PH_BUS_FREE .. initial phase */
+		/* DC395x_MsgOutPhase0,      phase:6 */
+		/* DC395x_MsgInPhase0,       phase:7 */
+		DC395x_stateV = (void *) DC395x_SCSI_phase0[phase];
+		DC395x_stateV(pACB, pSRB, &scsi_status);
+		/* 
+		 *$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 
+		 *
+		 *        if there were any exception occured
+		 *        scsi_status will be modify to bus free phase
+		 * new scsi_status transfer out from ... previous DC395x_stateV
+		 *
+		 *$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 
+		 */
+		pSRB->ScsiPhase = scsi_status & PHASEMASK;
+		phase = (u16) scsi_status & PHASEMASK;
+		/* 
+		 * call  DC395x_SCSI_phase1[]... "phase entry"
+		 * handle every phase do transfer
+		 */
+		/* DC395x_DataOutPhase1,     phase:0 */
+		/* DC395x_DataInPhase1,      phase:1 */
+		/* DC395x_CommandPhase1,     phase:2 */
+		/* DC395x_StatusPhase1,      phase:3 */
+		/* DC395x_Nop1,              phase:4 PH_BUS_FREE .. initial phase */
+		/* DC395x_Nop1,              phase:5 PH_BUS_FREE .. initial phase */
+		/* DC395x_MsgOutPhase1,      phase:6 */
+		/* DC395x_MsgInPhase1,       phase:7 */
+		DC395x_stateV = (void *) DC395x_SCSI_phase1[phase];
+		DC395x_stateV(pACB, pSRB, &scsi_status);
+	}
+      out_unlock:
+	DC395x_UNLOCK_IO(pACB->pScsiHost);
+	return;
+}
+
+/*inline */
+irqreturn_t DC395x_Interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+	struct AdapterCtlBlk *pACB = DC395x_pACB_start;
+	u16 scsi_status;
+	u8 dma_status;
+	irqreturn_t handled = IRQ_NONE;
+
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME ": DC395x_Interrupt..............\n ");
+#endif
+	DEBUGRECURSION(if (in_driver++ > NORM_REC_LVL)
+		       printk(DC395X_NAME ": %i interrupt recursion?\n",
+			      in_driver);)
+
+	/*
+	 * Find which card generated the interrupt. Note that it may have
+	 * been something else that we share the interupt with which
+	 * actually generated it.
+	 *
+	 * We'll check the interupt status register of each card that
+	 * is on the IRQ that was responsible for this interupt.
+	 */
+	for (; pACB != NULL; pACB = pACB->pNextACB) {
+		if (pACB->IRQLevel != (u8) irq) {
+			/* card is not on the irq that triggered */
+			continue;
+		}
+
+		/*
+		 * Ok, we've found a card on the correct irq,
+		 * let's check if an interupt is pending
+		 */
+		scsi_status = DC395x_read16(TRM_S1040_SCSI_STATUS);
+		dma_status = DC395x_read8(TRM_S1040_DMA_STATUS);
+		if (scsi_status & SCSIINTERRUPT) {
+			/* interupt pending - let's process it! */
+			dc395x_handle_interrupt(pACB, scsi_status);
+			handled = IRQ_HANDLED;
+		}
+		else if (dma_status & 0x20) {
+			/* Error from the DMA engine */
+			printk(DC395X_NAME ": Interrupt from DMA engine: %02x!\n",
+			       dma_status);
+#if 0
+			printk(DC395X_NAME ": This means DMA error! Try to handle ...\n");
+			if (pACB->pActiveDCB) {
+				pACB->pActiveDCB-> DCBFlag |= ABORT_DEV_;
+				if (pACB->pActiveDCB->pActiveSRB)
+					DC395x_EnableMsgOut_Abort(pACB, pACB->pActiveDCB->pActiveSRB);
+			}
+			DC395x_write8(TRM_S1040_DMA_CONTROL, ABORTXFER | CLRXFIFO);
+#else
+			printk(DC395X_NAME ": Ignoring DMA error (probably a bad thing) ...\n");
+			pACB = (struct AdapterCtlBlk *)NULL;
+#endif
+			handled = IRQ_HANDLED;
+		}
+	}
+
+	DEBUGRECURSION(in_driver--;)
+	return handled;
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *	DC395x_MsgOutPhase0: one of DC395x_SCSI_phase0[] vectors
+ *	 DC395x_stateV = (void *)DC395x_SCSI_phase0[phase]
+ *			           if phase =6
+ ********************************************************************
+ */
+static void
+DC395x_MsgOutPhase0(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB,
+		    u16 * pscsi_status)
+{
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME ": DC395x_MsgOutPhase0..... ");
+#endif
+	if (pSRB->SRBState & (SRB_UNEXPECT_RESEL + SRB_ABORT_SENT)) {
+		*pscsi_status = PH_BUS_FREE;	/*.. initial phase */
+	}
+	DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_DATALATCH);	/* it's important for atn stop */
+	pSRB->SRBState &= ~SRB_MSGOUT;
+	TRACEPRINTF("MOP0 *");
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *	DC395x_MsgOutPhase1: one of DC395x_SCSI_phase0[] vectors
+ *	 DC395x_stateV = (void *)DC395x_SCSI_phase0[phase]
+ *					if phase =6	    
+ ********************************************************************
+ */
+static void
+DC395x_MsgOutPhase1(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB,
+		    u16 * pscsi_status)
+{
+	u16 i;
+	u8 *ptr;
+	struct DeviceCtlBlk *pDCB;
+
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME
+	       ": DC395x_MsgOutPhase1..............\n ");
+#endif
+	TRACEPRINTF("MOP1*");
+	pDCB = pACB->pActiveDCB;
+	DC395x_clrfifo(pACB, "MOP1");
+	if (!(pSRB->SRBState & SRB_MSGOUT)) {
+		pSRB->SRBState |= SRB_MSGOUT;
+		printk(DC395X_NAME ": Debug: pid %li: MsgOut Phase unexpected.\n", pSRB->pcmd->pid);	/* So what ? */
+	}
+	if (!pSRB->MsgCnt) {
+		DEBUG0(printk
+		       (DC395X_NAME
+			": Debug: pid %li: NOP Msg (no output message there).\n",
+			pSRB->pcmd->pid);
+		    )
+		    DC395x_write8(TRM_S1040_SCSI_FIFO, MSG_NOP);
+		DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_DATALATCH);	/* it's important for atn stop */
+		DC395x_write8(TRM_S1040_SCSI_COMMAND, SCMD_FIFO_OUT);
+		TRACEPRINTF("\\*");
+		TRACEOUT(" %s\n", pSRB->debugtrace);
+		return;
+	}
+	ptr = (u8 *) pSRB->MsgOutBuf;
+	TRACEPRINTF("(*");
+	/*printk (DC395X_NAME ": Send msg: "); DC395x_printMsg (ptr, pSRB->MsgCnt); */
+	/*printk (DC395X_NAME ": MsgOut: "); */
+	for (i = 0; i < pSRB->MsgCnt; i++) {
+		TRACEPRINTF("%02x *", *ptr);
+		DC395x_write8(TRM_S1040_SCSI_FIFO, *ptr++);
+	}
+	TRACEPRINTF(")*");
+	pSRB->MsgCnt = 0;
+	/*printk ("\n"); */
+	if (			/*(pDCB->DCBFlag & ABORT_DEV_) && */
+		   (pSRB->MsgOutBuf[0] == MSG_ABORT))
+		pSRB->SRBState = SRB_ABORT_SENT;
+
+	/*1.25 */
+	/*DC395x_write16 (TRM_S1040_SCSI_CONTROL, DO_DATALATCH); *//* it's important for atn stop */
+	/*
+	 ** SCSI command 
+	 */
+	/*TRACEPRINTF (".*"); */
+	DC395x_write8(TRM_S1040_SCSI_COMMAND, SCMD_FIFO_OUT);
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *	DC395x_CommandPhase0: one of DC395x_SCSI_phase0[] vectors
+ *	 DC395x_stateV = (void *)DC395x_SCSI_phase0[phase]
+ *				if phase =2 
+ ********************************************************************
+ */
+static void
+DC395x_CommandPhase0(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB,
+		     u16 * pscsi_status)
+{
+	TRACEPRINTF("COP0 *");
+	/*1.25 */
+	/*DC395x_clrfifo (pACB, COP0); */
+	DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_DATALATCH);
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *	DC395x_CommandPhase1: one of DC395x_SCSI_phase1[] vectors
+ *	 DC395x_stateV = (void *)DC395x_SCSI_phase1[phase]
+ *				if phase =2    	 
+ ********************************************************************
+ */
+static void
+DC395x_CommandPhase1(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB,
+		     u16 * pscsi_status)
+{
+	struct DeviceCtlBlk *pDCB;
+	u8 *ptr;
+	u16 i;
+
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME
+	       ": DC395x_CommandPhase1..............\n ");
+#endif
+	TRACEPRINTF("COP1*");
+	DC395x_clrfifo(pACB, "COP1");
+	DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_CLRATN);
+	if (!(pSRB->SRBFlag & AUTO_REQSENSE)) {
+		ptr = (u8 *) pSRB->pcmd->cmnd;
+		for (i = 0; i < pSRB->pcmd->cmd_len; i++) {
+			DC395x_write8(TRM_S1040_SCSI_FIFO, *ptr);
+			ptr++;
+		}
+	} else {
+		DC395x_write8(TRM_S1040_SCSI_FIFO, REQUEST_SENSE);
+		pDCB = pACB->pActiveDCB;
+		/* target id */
+		DC395x_write8(TRM_S1040_SCSI_FIFO, (pDCB->TargetLUN << 5));
+		DC395x_write8(TRM_S1040_SCSI_FIFO, 0);
+		DC395x_write8(TRM_S1040_SCSI_FIFO, 0);
+		DC395x_write8(TRM_S1040_SCSI_FIFO,
+			      sizeof(pSRB->pcmd->sense_buffer));
+		DC395x_write8(TRM_S1040_SCSI_FIFO, 0);
+	}
+	pSRB->SRBState |= SRB_COMMAND;
+	/* it's important for atn stop */
+	DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_DATALATCH);
+	/* SCSI command */
+	TRACEPRINTF(".*");
+	DC395x_write8(TRM_S1040_SCSI_COMMAND, SCMD_FIFO_OUT);
+}
+
+
+/* Do sanity checks for S/G list */
+#ifdef DC395x_SGPARANOIA
+static inline void DC395x_check_SG(struct ScsiReqBlk *pSRB)
+{
+	unsigned Length = 0;
+	unsigned Idx = pSRB->SRBSGIndex;
+	struct SGentry *psge = pSRB->SegmentX + Idx;
+	for (; Idx < pSRB->SRBSGCount; psge++, Idx++)
+		Length += psge->length;
+	if (Length != pSRB->SRBTotalXferLength)
+		printk(DC395X_NAME
+		       ": Inconsistent SRB S/G lengths (Tot=%i, Count=%i) !!\n",
+		       pSRB->SRBTotalXferLength, Length);
+}
+#else
+static inline void DC395x_check_SG(struct ScsiReqBlk *pSRB)
+{
+}
+#endif
+
+
+/*
+ * Compute the next Scatter Gather list index and adjust its length
+ * and address if necessary; also compute virt_addr
+ */
+void DC395x_update_SGlist(struct ScsiReqBlk *pSRB, u32 Left)
+{
+	struct SGentry *psge;
+	u32 Xferred = 0;
+	u8 Idx;
+	Scsi_Cmnd *pcmd = pSRB->pcmd;
+	struct scatterlist *sg;
+	int segment = pcmd->use_sg;
+
+#ifdef DC395x_DEBUG_KG
+	printk(DC395X_NAME ": Update SG: Total %i, Left %i\n",
+	       pSRB->SRBTotalXferLength, Left);
+#endif
+	DC395x_check_SG(pSRB);
+	psge = pSRB->SegmentX + pSRB->SRBSGIndex;
+	/* data that has already been transferred */
+	Xferred = pSRB->SRBTotalXferLength - Left;
+	if (pSRB->SRBTotalXferLength != Left) {
+		/*DC395x_check_SG_TX (pSRB, Xferred); */
+		/* Remaining */
+		pSRB->SRBTotalXferLength = Left;
+		/* parsing from last time disconnect SGIndex */
+		for (Idx = pSRB->SRBSGIndex; Idx < pSRB->SRBSGCount; Idx++) {
+			/* Complete SG entries done */
+			if (Xferred >= psge->length)
+				Xferred -= psge->length;
+			/* Partial SG entries done */
+			else {
+				psge->length -= Xferred;	/* residue data length  */
+				psge->address += Xferred;	/* residue data pointer */
+				pSRB->SRBSGIndex = Idx;
+				pci_dma_sync_single(pSRB->pSRBDCB->
+						    pDCBACB->pdev,
+						    pSRB->SRBSGBusAddr,
+						    sizeof(struct SGentry)
+						    *
+						    DC395x_MAX_SG_LISTENTRY,
+						    PCI_DMA_TODEVICE);
+				break;
+			}
+			psge++;
+		}
+		DC395x_check_SG(pSRB);
+	}
+	/* We need the corresponding virtual address sg_to_virt */
+	/*printk (DC395X_NAME ": sg_to_virt: bus %08x -> virt ", psge->address); */
+	if (!segment) {
+		pSRB->virt_addr += Xferred;
+		/*printk ("%p\n", pSRB->virt_addr); */
+		return;
+	}
+	/* We have to walk the scatterlist to find it */
+	sg = (struct scatterlist *) pcmd->request_buffer;
+	while (segment--) {
+		/*printk ("(%08x)%p ", BUS_ADDR(*sg), PAGE_ADDRESS(sg)); */
+		unsigned long mask =
+		    ~((unsigned long) sg->length - 1) & PAGE_MASK;
+		if ((BUS_ADDR(*sg) & mask) == (psge->address & mask)) {
+			pSRB->virt_addr = (PAGE_ADDRESS(sg)
+					   + psge->address -
+					   (psge->address & PAGE_MASK));
+			/*printk ("%p\n", pSRB->virt_addr); */
+			return;
+		}
+		++sg;
+	}
+	printk(DC395X_NAME ": sg_to_virt failed!\n");
+	pSRB->virt_addr = 0;
+}
+
+
+/* 
+ * DC395x_cleanup_after_transfer
+ * 
+ * Makes sure, DMA and SCSI engine are empty, after the transfer has finished
+ * KG: Currently called from  StatusPhase1 ()
+ * Should probably also be called from other places
+ * Best might be to call it in DataXXPhase0, if new phase will differ 
+ */
+static void
+DC395x_cleanup_after_transfer(struct AdapterCtlBlk *pACB,
+			      struct ScsiReqBlk *pSRB)
+{
+	TRACEPRINTF(" Cln*");
+	/*DC395x_write8 (TRM_S1040_DMA_STATUS, FORCEDMACOMP); */
+	if (DC395x_read16(TRM_S1040_DMA_COMMAND) & 0x0001) {	/* read */
+		if (!(DC395x_read8(TRM_S1040_SCSI_FIFOCNT) & 0x40))
+			DC395x_clrfifo(pACB, "ClnIn");
+
+		if (!(DC395x_read8(TRM_S1040_DMA_FIFOSTAT) & 0x80))
+			DC395x_write8(TRM_S1040_DMA_CONTROL, CLRXFIFO);
+	} else {		/* write */
+		if (!(DC395x_read8(TRM_S1040_DMA_FIFOSTAT) & 0x80))
+			DC395x_write8(TRM_S1040_DMA_CONTROL, CLRXFIFO);
+
+		if (!(DC395x_read8(TRM_S1040_SCSI_FIFOCNT) & 0x40))
+			DC395x_clrfifo(pACB, "ClnOut");
+
+	}
+	/*1.25 */
+	DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_DATALATCH);
+}
+
+
+/*
+ * Those no of bytes will be transfered w/ PIO through the SCSI FIFO
+ * Seems to be needed for unknown reasons; could be a hardware bug :-(
+ */
+#define DC395x_LASTPIO 4
+/*
+ ********************************************************************
+ * scsiio
+ *	DC395x_DataOutPhase0: one of DC395x_SCSI_phase0[] vectors
+ *	 DC395x_stateV = (void *)DC395x_SCSI_phase0[phase]
+ *				if phase =0 
+ ********************************************************************
+ */
+void
+DC395x_DataOutPhase0(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB,
+		     u16 * pscsi_status)
+{
+	u16 scsi_status;
+	u32 dLeftCounter = 0;
+	struct DeviceCtlBlk *pDCB = pSRB->pSRBDCB;
+
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME ": DC395x_DataOutPhase0.....\n ");
+#endif
+	TRACEPRINTF("DOP0*");
+	pDCB = pSRB->pSRBDCB;
+	scsi_status = *pscsi_status;
+
+	/*
+	 * KG: We need to drain the buffers before we draw any conclusions!
+	 * This means telling the DMA to push the rest into SCSI, telling
+	 * SCSI to push the rest to the bus.
+	 * However, the device might have been the one to stop us (phase
+	 * change), and the data in transit just needs to be accounted so
+	 * it can be retransmitted.)
+	 */
+	/* 
+	 * KG: Stop DMA engine pushing more data into the SCSI FIFO
+	 * If we need more data, the DMA SG list will be freshly set up, anyway
+	 */
+#ifdef DC395x_DEBUGPIO
+	printk(DC395X_NAME
+	       ": DOP0: DMA_FCNT: %02x, DMA_FSTAT: %02x, SCSI_FCNT: %02x, CTR %06x, stat %04x, Tot: %06x\n",
+	       DC395x_read8(TRM_S1040_DMA_FIFOCNT),
+	       DC395x_read8(TRM_S1040_DMA_FIFOSTAT),
+	       DC395x_read8(TRM_S1040_SCSI_FIFOCNT),
+	       DC395x_read32(TRM_S1040_SCSI_COUNTER), scsi_status,
+	       pSRB->SRBTotalXferLength);
+	/*DC395x_dumpinfo(pACB, pDCB, pSRB); */
+#endif
+	DC395x_write8(TRM_S1040_DMA_CONTROL, STOPDMAXFER | CLRXFIFO);
+
+	if (!(pSRB->SRBState & SRB_XFERPAD)) {
+		if (scsi_status & PARITYERROR)
+			pSRB->SRBStatus |= PARITY_ERROR;
+
+		/*
+		 * KG: Right, we can't just rely on the SCSI_COUNTER, because this
+		 * is the no of bytes it got from the DMA engine not the no it 
+		 * transferred successfully to the device. (And the difference could
+		 * be as much as the FIFO size, I guess ...)
+		 */
+		if (!(scsi_status & SCSIXFERDONE)) {
+			/*
+			 * when data transfer from DMA FIFO to SCSI FIFO
+			 * if there was some data left in SCSI FIFO
+			 */
+			dLeftCounter =
+			    (u32) (DC395x_read8(TRM_S1040_SCSI_FIFOCNT) &
+				   0x1F);
+			if (pDCB->SyncPeriod & WIDE_SYNC)
+				dLeftCounter <<= 1;
+
+#ifdef DC395x_DEBUG_KG
+			printk(DC395X_NAME
+			       ": Debug: SCSI FIFO contains %i %s in DOP0\n",
+			       DC395x_read8(TRM_S1040_SCSI_FIFOCNT),
+			       (pDCB->
+				SyncPeriod & WIDE_SYNC) ? "words" :
+			       "bytes");
+			printk(DC395X_NAME
+			       ": SCSI FIFOCNT %02x, SCSI CTR %08x\n",
+			       DC395x_read8(TRM_S1040_SCSI_FIFOCNT),
+			       DC395x_read32(TRM_S1040_SCSI_COUNTER));
+			printk(DC395X_NAME
+			       ": DMA FIFOCNT %04x, FIFOSTAT %02x, DMA CTR %08x\n",
+			       DC395x_read8(TRM_S1040_DMA_FIFOCNT),
+			       DC395x_read8(TRM_S1040_DMA_FIFOSTAT),
+			       DC395x_read32(TRM_S1040_DMA_CXCNT));
+#endif
+			/*
+			 * if WIDE scsi SCSI FIFOCNT unit is word !!!
+			 * so need to *= 2
+			 */
+		}
+		/*
+		 * calculate all the residue data that not yet tranfered
+		 * SCSI transfer counter + left in SCSI FIFO data
+		 *
+		 * .....TRM_S1040_SCSI_COUNTER (24bits)
+		 * The counter always decrement by one for every SCSI byte transfer.
+		 * .....TRM_S1040_SCSI_FIFOCNT ( 5bits)
+		 * The counter is SCSI FIFO offset counter (in units of bytes or! words)
+		 */
+		if (pSRB->SRBTotalXferLength > DC395x_LASTPIO)
+			dLeftCounter +=
+			    DC395x_read32(TRM_S1040_SCSI_COUNTER);
+		TRACEPRINTF("%06x *", dLeftCounter);
+
+		/* Is this a good idea? */
+		/*DC395x_clrfifo (pACB, "DOP1"); */
+		/* KG: What is this supposed to be useful for? WIDE padding stuff? */
+		if (dLeftCounter == 1 && pDCB->SyncPeriod & WIDE_SYNC
+		    && pSRB->pcmd->request_bufflen % 2) {
+			dLeftCounter = 0;
+			printk(DC395X_NAME
+			       ": DOP0: Discard 1 byte. (%02x)\n",
+			       scsi_status);
+		}
+		/*
+		 * KG: Oops again. Same thinko as above: The SCSI might have been
+		 * faster than the DMA engine, so that it ran out of data.
+		 * In that case, we have to do just nothing! 
+		 * But: Why the interrupt: No phase change. No XFERCNT_2_ZERO. Or?
+		 */
+		/*
+		 * KG: This is nonsense: We have been WRITING data to the bus
+		 * If the SCSI engine has no bytes left, how should the DMA engine?
+		 */
+		if ((dLeftCounter ==
+		     0) /*|| (scsi_status & SCSIXFERCNT_2_ZERO) ) */ ) {
+			/*
+			 * int ctr = 6000000; u8 TempDMAstatus;
+			 * do
+			 * {
+			 *  TempDMAstatus = DC395x_read8(TRM_S1040_DMA_STATUS);
+			 * } while( !(TempDMAstatus & DMAXFERCOMP) && --ctr);
+			 * if (ctr < 6000000-1) printk (DC395X_NAME ": DMA should be complete ... in DOP1\n");
+			 * if (!ctr) printk (KERN_ERR DC395X_NAME ": Deadlock in DataOutPhase0 !!\n");
+			 */
+			pSRB->SRBTotalXferLength = 0;
+		} else {	/* Update SG list         */
+			/*
+			 * if transfer not yet complete
+			 * there were some data residue in SCSI FIFO or
+			 * SCSI transfer counter not empty
+			 */
+			long oldXferred =
+			    pSRB->SRBTotalXferLength - dLeftCounter;
+			const int diff =
+			    (pDCB->SyncPeriod & WIDE_SYNC) ? 2 : 1;
+			DC395x_update_SGlist(pSRB, dLeftCounter);
+			/* KG: Most ugly hack! Apparently, this works around a chip bug */
+			if ((pSRB->SegmentX[pSRB->SRBSGIndex].length ==
+			     diff && pSRB->pcmd->use_sg)
+			    || ((oldXferred & ~PAGE_MASK) ==
+				(PAGE_SIZE - diff))
+			    ) {
+				printk(DC395X_NAME
+				       ": Work around chip bug (%i)?\n",
+				       diff);
+				dLeftCounter =
+				    pSRB->SRBTotalXferLength - diff;
+				DC395x_update_SGlist(pSRB, dLeftCounter);
+				/*pSRB->SRBTotalXferLength -= diff; */
+				/*pSRB->virt_addr += diff; */
+				/*if (pSRB->pcmd->use_sg) */
+				/*      pSRB->SRBSGIndex++; */
+			}
+		}
+	}
+#if 0
+	if (!(DC395x_read8(TRM_S1040_SCSI_FIFOCNT) & 0x40))
+		printk(DC395X_NAME
+		       ": DOP0(%li): %i bytes in SCSI FIFO! (Clear!)\n",
+		       pSRB->pcmd->pid,
+		       DC395x_read8(TRM_S1040_SCSI_FIFOCNT) & 0x1f);
+#endif
+	/*DC395x_clrfifo (pACB, "DOP0"); */
+	/*DC395x_write8 (TRM_S1040_DMA_CONTROL, CLRXFIFO | ABORTXFER); */
+#if 1
+	if ((*pscsi_status & PHASEMASK) != PH_DATA_OUT) {
+		/*printk (DC395X_NAME ": Debug: Clean up after Data Out ...\n"); */
+		DC395x_cleanup_after_transfer(pACB, pSRB);
+	}
+#endif
+	TRACEPRINTF(".*");
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *	DC395x_DataOutPhase1: one of DC395x_SCSI_phase0[] vectors
+ *	 DC395x_stateV = (void *)DC395x_SCSI_phase0[phase]
+ *				if phase =0    
+ *		62037
+ ********************************************************************
+ */
+static void
+DC395x_DataOutPhase1(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB,
+		     u16 * pscsi_status)
+{
+
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME ": DC395x_DataOutPhase1.....\n");
+#endif
+	/*1.25 */
+	TRACEPRINTF("DOP1*");
+	DC395x_clrfifo(pACB, "DOP1");
+	/*
+	 ** do prepare befor transfer when data out phase
+	 */
+	DC395x_DataIO_transfer(pACB, pSRB, XFERDATAOUT);
+	TRACEPRINTF(".*");
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *	DC395x_DataInPhase0: one of DC395x_SCSI_phase1[] vectors
+ *	 DC395x_stateV = (void *)DC395x_SCSI_phase1[phase]
+ *				if phase =1  
+ ********************************************************************
+ */
+void
+DC395x_DataInPhase0(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB,
+		    u16 * pscsi_status)
+{
+	u16 scsi_status;
+	u32 dLeftCounter = 0;
+	/*struct DeviceCtlBlk*   pDCB = pSRB->pSRBDCB; */
+	/*u8 bval; */
+
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME
+	       ": DC395x_DataInPhase0..............\n ");
+#endif
+	TRACEPRINTF("DIP0*");
+	scsi_status = *pscsi_status;
+
+	/*
+	 * KG: DataIn is much more tricky than DataOut. When the device is finished
+	 * and switches to another phase, the SCSI engine should be finished too.
+	 * But: There might still be bytes left in its FIFO to be fetched by the DMA
+	 * engine and transferred to memory.
+	 * We should wait for the FIFOs to be emptied by that (is there any way to 
+	 * enforce this?) and then stop the DMA engine, because it might think, that
+	 * there are more bytes to follow. Yes, the device might disconnect prior to
+	 * having all bytes transferred! 
+	 * Also we should make sure that all data from the DMA engine buffer's really
+	 * made its way to the system memory! Some documentation on this would not
+	 * seem to be a bad idea, actually.
+	 */
+	if (!(pSRB->SRBState & SRB_XFERPAD)) {
+		if (scsi_status & PARITYERROR) {
+			printk(DC395X_NAME
+			       ": Parity Error (pid %li, target %02i-%i)\n",
+			       pSRB->pcmd->pid, pSRB->pcmd->device->id,
+			       pSRB->pcmd->device->lun);
+			pSRB->SRBStatus |= PARITY_ERROR;
+		}
+		/*
+		 * KG: We should wait for the DMA FIFO to be empty ...
+		 * but: it would be better to wait first for the SCSI FIFO and then the
+		 * the DMA FIFO to become empty? How do we know, that the device not already
+		 * sent data to the FIFO in a MsgIn phase, eg.?
+		 */
+		if (!(DC395x_read8(TRM_S1040_DMA_FIFOSTAT) & 0x80)) {
+#if 0
+			int ctr = 6000000;
+			printk(DC395X_NAME
+			       ": DIP0: Wait for DMA FIFO to flush ...\n");
+			/*DC395x_write8  (TRM_S1040_DMA_CONTROL, STOPDMAXFER); */
+			/*DC395x_write32 (TRM_S1040_SCSI_COUNTER, 7); */
+			/*DC395x_write8  (TRM_S1040_SCSI_COMMAND, SCMD_DMA_IN); */
+			while (!
+			       (DC395x_read16(TRM_S1040_DMA_FIFOSTAT) &
+				0x80) && --ctr);
+			if (ctr < 6000000 - 1)
+				printk(DC395X_NAME
+				       ": Debug: DIP0: Had to wait for DMA ...\n");
+			if (!ctr)
+				printk(KERN_ERR DC395X_NAME
+				       ": Deadlock in DIP0 waiting for DMA FIFO empty!!\n");
+			/*DC395x_write32 (TRM_S1040_SCSI_COUNTER, 0); */
+#endif
+#ifdef DC395x_DEBUG_KG
+			printk(DC395X_NAME ": DIP0: DMA_FIFO: %02x %02x\n",
+			       DC395x_read8(TRM_S1040_DMA_FIFOCNT),
+			       DC395x_read8(TRM_S1040_DMA_FIFOSTAT));
+#endif
+		}
+		/* Now: Check remainig data: The SCSI counters should tell us ... */
+		dLeftCounter = DC395x_read32(TRM_S1040_SCSI_COUNTER)
+		    + ((DC395x_read8(TRM_S1040_SCSI_FIFOCNT) & 0x1f)
+		       << ((pSRB->pSRBDCB->SyncPeriod & WIDE_SYNC) ? 1 :
+			   0));
+
+#ifdef DC395x_DEBUG_KG
+		printk(DC395X_NAME
+		       ": Debug: SCSI FIFO contains %i %s in DIP0\n",
+		       DC395x_read8(TRM_S1040_SCSI_FIFOCNT) & 0x1f,
+		       (pSRB->pSRBDCB->
+			SyncPeriod & WIDE_SYNC) ? "words" : "bytes");
+		printk(DC395X_NAME ": SCSI FIFOCNT %02x, SCSI CTR %08x\n",
+		       DC395x_read8(TRM_S1040_SCSI_FIFOCNT),
+		       DC395x_read32(TRM_S1040_SCSI_COUNTER));
+		printk(DC395X_NAME
+		       ": DMA FIFOCNT %02x,%02x DMA CTR %08x\n",
+		       DC395x_read8(TRM_S1040_DMA_FIFOCNT),
+		       DC395x_read8(TRM_S1040_DMA_FIFOSTAT),
+		       DC395x_read32(TRM_S1040_DMA_CXCNT));
+		printk(DC395X_NAME
+		       ": Remaining: TotXfer: %i, SCSI FIFO+Ctr: %i\n",
+		       pSRB->SRBTotalXferLength, dLeftCounter);
+#endif
+#if DC395x_LASTPIO
+		/* KG: Less than or equal to 4 bytes can not be transfered via DMA, it seems. */
+		if (dLeftCounter
+		    && pSRB->SRBTotalXferLength <= DC395x_LASTPIO) {
+			/*u32 addr = (pSRB->SegmentX[pSRB->SRBSGIndex].address); */
+			/*DC395x_update_SGlist (pSRB, dLeftCounter); */
+			DEBUGPIO(printk
+				 (DC395X_NAME
+				  ": DIP0: PIO (%i %s) to %p for remaining %i bytes:",
+				  DC395x_read8(TRM_S1040_SCSI_FIFOCNT) &
+				  0x1f,
+				  (pSRB->pSRBDCB->
+				   SyncPeriod & WIDE_SYNC) ? "words" :
+				  "bytes", pSRB->virt_addr,
+				  pSRB->SRBTotalXferLength);
+			    )
+
+			    if (pSRB->pSRBDCB->SyncPeriod & WIDE_SYNC)
+				DC395x_write8(TRM_S1040_SCSI_CONFIG2,
+					      CFG2_WIDEFIFO);
+
+			while (DC395x_read8(TRM_S1040_SCSI_FIFOCNT) !=
+			       0x40) {
+				u8 byte =
+				    DC395x_read8(TRM_S1040_SCSI_FIFO);
+				*(pSRB->virt_addr)++ = byte;
+				DEBUGPIO(printk(" %02x", byte);
+				    )
+				    pSRB->SRBTotalXferLength--;
+				dLeftCounter--;
+				pSRB->SegmentX[pSRB->SRBSGIndex].length--;
+				if (pSRB->SRBTotalXferLength
+				    && !pSRB->SegmentX[pSRB->SRBSGIndex].
+				    length) {
+					DEBUGPIO(printk(" (next segment)");
+					    )
+					    pSRB->SRBSGIndex++;
+					DC395x_update_SGlist(pSRB,
+							     dLeftCounter);
+				}
+			}
+			if (pSRB->pSRBDCB->SyncPeriod & WIDE_SYNC) {
+#if 1				/* Read the last byte ... */
+				if (pSRB->SRBTotalXferLength > 0) {
+					u8 byte =
+					    DC395x_read8
+					    (TRM_S1040_SCSI_FIFO);
+					*(pSRB->virt_addr)++ = byte;
+					pSRB->SRBTotalXferLength--;
+					DEBUGPIO(printk(" %02x", byte);
+					    )
+				}
+#endif
+				DC395x_write8(TRM_S1040_SCSI_CONFIG2, 0);
+			}
+			/*printk (" %08x", *(u32*)(bus_to_virt (addr))); */
+			/*pSRB->SRBTotalXferLength = 0; */
+			DEBUGPIO(printk("\n");
+			    )
+		}
+#endif				/* DC395x_LASTPIO */
+
+#if 0
+		/*
+		 * KG: This was in DATAOUT. Does it also belong here?
+		 * Nobody seems to know what counter and fifo_cnt count exactly ...
+		 */
+		if (!(scsi_status & SCSIXFERDONE)) {
+			/*
+			 * when data transfer from DMA FIFO to SCSI FIFO
+			 * if there was some data left in SCSI FIFO
+			 */
+			dLeftCounter =
+			    (u32) (DC395x_read8(TRM_S1040_SCSI_FIFOCNT) &
+				   0x1F);
+			if (pSRB->pSRBDCB->SyncPeriod & WIDE_SYNC)
+				dLeftCounter <<= 1;
+			/*
+			 * if WIDE scsi SCSI FIFOCNT unit is word !!!
+			 * so need to *= 2
+			 * KG: Seems to be correct ...
+			 */
+		}
+#endif
+		/*dLeftCounter += DC395x_read32(TRM_S1040_SCSI_COUNTER); */
+#if 0
+		printk(DC395X_NAME
+		       ": DIP0: ctr=%08x, DMA_FIFO=%02x,%02x SCSI_FIFO=%02x\n",
+		       dLeftCounter, DC395x_read8(TRM_S1040_DMA_FIFOCNT),
+		       DC395x_read8(TRM_S1040_DMA_FIFOSTAT),
+		       DC395x_read8(TRM_S1040_SCSI_FIFOCNT));
+		printk(DC395X_NAME ": DIP0: DMAStat %02x\n",
+		       DC395x_read8(TRM_S1040_DMA_STATUS));
+#endif
+
+		/* KG: This should not be needed any more! */
+		if ((dLeftCounter == 0)
+		    || (scsi_status & SCSIXFERCNT_2_ZERO)) {
+#if 0
+			int ctr = 6000000;
+			u8 TempDMAstatus;
+			do {
+				TempDMAstatus =
+				    DC395x_read8(TRM_S1040_DMA_STATUS);
+			} while (!(TempDMAstatus & DMAXFERCOMP) && --ctr);
+			if (!ctr)
+				printk(KERN_ERR DC395X_NAME
+				       ": Deadlock in DataInPhase0 waiting for DMA!!\n");
+			pSRB->SRBTotalXferLength = 0;
+#endif
+#if 0				/*def DC395x_DEBUG_KG             */
+			printk(DC395X_NAME
+			       ": DIP0: DMA not yet ready: %02x: %i -> %i bytes\n",
+			       DC395x_read8(TRM_S1040_DMA_STATUS),
+			       pSRB->SRBTotalXferLength, dLeftCounter);
+#endif
+			pSRB->SRBTotalXferLength = dLeftCounter;
+		} else {	/* phase changed */
+			/*
+			 * parsing the case:
+			 * when a transfer not yet complete 
+			 * but be disconnected by target
+			 * if transfer not yet complete
+			 * there were some data residue in SCSI FIFO or
+			 * SCSI transfer counter not empty
+			 */
+			DC395x_update_SGlist(pSRB, dLeftCounter);
+		}
+	}
+	/* KG: The target may decide to disconnect: Empty FIFO before! */
+	if ((*pscsi_status & PHASEMASK) != PH_DATA_IN) {
+		/*printk (DC395X_NAME ": Debug: Clean up after Data In  ...\n"); */
+		DC395x_cleanup_after_transfer(pACB, pSRB);
+	}
+#if 0
+	/* KG: Make sure, no previous transfers are pending! */
+	bval = DC395x_read8(TRM_S1040_SCSI_FIFOCNT);
+	if (!(bval & 0x40)) {
+		bval &= 0x1f;
+		printk(DC395X_NAME
+		       ": DIP0(%li): %i bytes in SCSI FIFO (stat %04x) (left %08x)!!\n",
+		       pSRB->pcmd->pid, bval & 0x1f, scsi_status,
+		       dLeftCounter);
+		if ((dLeftCounter == 0)
+		    || (scsi_status & SCSIXFERCNT_2_ZERO)) {
+			printk(DC395X_NAME ": Clear FIFO!\n");
+			DC395x_clrfifo(pACB, "DIP0");
+		}
+	}
+#endif
+	/*DC395x_write8 (TRM_S1040_DMA_CONTROL, CLRXFIFO | ABORTXFER); */
+
+	/*DC395x_clrfifo (pACB, "DIP0"); */
+	/*DC395x_write16 (TRM_S1040_SCSI_CONTROL, DO_DATALATCH); */
+	TRACEPRINTF(".*");
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *	DC395x_DataInPhase1: one of DC395x_SCSI_phase0[] vectors
+ *	 DC395x_stateV = (void *)DC395x_SCSI_phase0[phase]
+ *				if phase =1 
+ ********************************************************************
+ */
+static void
+DC395x_DataInPhase1(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB,
+		    u16 * pscsi_status)
+{
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME ": DC395x_DataInPhase1..... ");
+#endif
+	/* FIFO should be cleared, if previous phase was not DataPhase */
+	/*DC395x_clrfifo (pACB, "DIP1"); */
+	/* Allow data in! */
+	/*DC395x_write16 (TRM_S1040_SCSI_CONTROL, DO_DATALATCH); */
+	TRACEPRINTF("DIP1:*");
+	/*
+	 ** do prepare before transfer when data in phase
+	 */
+	DC395x_DataIO_transfer(pACB, pSRB, XFERDATAIN);
+	TRACEPRINTF(".*");
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *		DC395x_DataOutPhase1
+ *		DC395x_DataInPhase1
+ ********************************************************************
+ */
+void
+DC395x_DataIO_transfer(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB,
+		       u16 ioDir)
+{
+	u8 bval;
+	struct DeviceCtlBlk *pDCB;
+
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME
+	       ": DataIO_transfer %c (pid %li): len = %i, SG: %i/%i\n",
+	       ((ioDir & DMACMD_DIR) ? 'r' : 'w'), pSRB->pcmd->pid,
+	       pSRB->SRBTotalXferLength, pSRB->SRBSGIndex,
+	       pSRB->SRBSGCount);
+#endif
+	TRACEPRINTF("%05x(%i/%i)*", pSRB->SRBTotalXferLength,
+		    pSRB->SRBSGIndex, pSRB->SRBSGCount);
+	pDCB = pSRB->pSRBDCB;
+	if (pSRB == pACB->pTmpSRB) {
+		printk(DC395X_NAME
+		       ": ERROR! Using TmpSRB in DataPhase!\n");
+	}
+	if (pSRB->SRBSGIndex < pSRB->SRBSGCount) {
+		if (pSRB->SRBTotalXferLength > DC395x_LASTPIO) {
+			u8 dma_status = DC395x_read8(TRM_S1040_DMA_STATUS);
+			/*
+			 * KG: What should we do: Use SCSI Cmd 0x90/0x92?
+			 * Maybe, even ABORTXFER would be appropriate
+			 */
+			if (dma_status & XFERPENDING) {
+				printk(DC395X_NAME
+				       ": Xfer pending! Expect trouble!!\n");
+				DC395x_dumpinfo(pACB, pDCB, pSRB);
+				DC395x_write8(TRM_S1040_DMA_CONTROL,
+					      CLRXFIFO);
+			}
+			/*DC395x_clrfifo (pACB, "IO"); */
+			/* 
+			 * load what physical address of Scatter/Gather list table want to be
+			 * transfer 
+			 */
+			pSRB->SRBState |= SRB_DATA_XFER;
+			DC395x_write32(TRM_S1040_DMA_XHIGHADDR, 0);
+			if (pSRB->pcmd->use_sg) {	/* with S/G */
+				ioDir |= DMACMD_SG;
+				DC395x_write32(TRM_S1040_DMA_XLOWADDR,
+					       pSRB->SRBSGBusAddr +
+					       sizeof(struct SGentry) *
+					       pSRB->SRBSGIndex);
+				/* load how many bytes in the Scatter/Gather list table */
+				DC395x_write32(TRM_S1040_DMA_XCNT,
+					       ((u32)
+						(pSRB->SRBSGCount -
+						 pSRB->SRBSGIndex) << 3));
+			} else {	/* without S/G */
+				ioDir &= ~DMACMD_SG;
+				DC395x_write32(TRM_S1040_DMA_XLOWADDR,
+					       pSRB->SegmentX[0].address);
+				DC395x_write32(TRM_S1040_DMA_XCNT,
+					       pSRB->SegmentX[0].length);
+			}
+			/* load total transfer length (24bits) max value 16Mbyte */
+			DC395x_write32(TRM_S1040_SCSI_COUNTER,
+				       pSRB->SRBTotalXferLength);
+			DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_DATALATCH);	/* it's important for atn stop */
+			if (ioDir & DMACMD_DIR) {	/* read */
+				DC395x_write8(TRM_S1040_SCSI_COMMAND,
+					      SCMD_DMA_IN);
+				DC395x_write16(TRM_S1040_DMA_COMMAND,
+					       ioDir);
+			} else {
+				DC395x_write16(TRM_S1040_DMA_COMMAND,
+					       ioDir);
+				DC395x_write8(TRM_S1040_SCSI_COMMAND,
+					      SCMD_DMA_OUT);
+			}
+
+		}
+#if DC395x_LASTPIO
+		else if (pSRB->SRBTotalXferLength > 0) {	/* The last four bytes: Do PIO */
+			/*DC395x_clrfifo (pACB, "IO"); */
+			/* 
+			 * load what physical address of Scatter/Gather list table want to be
+			 * transfer 
+			 */
+			pSRB->SRBState |= SRB_DATA_XFER;
+			/* load total transfer length (24bits) max value 16Mbyte */
+			DC395x_write32(TRM_S1040_SCSI_COUNTER,
+				       pSRB->SRBTotalXferLength);
+			DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_DATALATCH);	/* it's important for atn stop */
+			if (ioDir & DMACMD_DIR) {	/* read */
+				DC395x_write8(TRM_S1040_SCSI_COMMAND,
+					      SCMD_FIFO_IN);
+			} else {	/* write */
+				int ln = pSRB->SRBTotalXferLength;
+				if (pSRB->pSRBDCB->SyncPeriod & WIDE_SYNC)
+					DC395x_write8
+					    (TRM_S1040_SCSI_CONFIG2,
+					     CFG2_WIDEFIFO);
+				DEBUGPIO(printk
+					 (DC395X_NAME
+					  ": DOP1: PIO %i bytes from %p:",
+					  pSRB->SRBTotalXferLength,
+					  pSRB->virt_addr);
+				    )
+				    while (pSRB->SRBTotalXferLength) {
+					DEBUGPIO(printk
+						 (" %02x",
+						  (unsigned char) *(pSRB->
+								    virt_addr));
+					    )
+					    DC395x_write8
+					    (TRM_S1040_SCSI_FIFO,
+					     *(pSRB->virt_addr)++);
+					pSRB->SRBTotalXferLength--;
+					pSRB->SegmentX[pSRB->SRBSGIndex].
+					    length--;
+					if (pSRB->SRBTotalXferLength
+					    && !pSRB->SegmentX[pSRB->
+							       SRBSGIndex].
+					    length) {
+						DEBUGPIO(printk
+							 (" (next segment)");
+						    )
+						    pSRB->SRBSGIndex++;
+						DC395x_update_SGlist(pSRB,
+								     pSRB->
+								     SRBTotalXferLength);
+					}
+				}
+				if (pSRB->pSRBDCB->SyncPeriod & WIDE_SYNC) {
+					if (ln % 2) {
+						DC395x_write8
+						    (TRM_S1040_SCSI_FIFO,
+						     0);
+						DEBUGPIO(printk(" |00");
+						    )
+					}
+					DC395x_write8
+					    (TRM_S1040_SCSI_CONFIG2, 0);
+				}
+				/*DC395x_write32(TRM_S1040_SCSI_COUNTER, ln); */
+				DEBUGPIO(printk("\n");
+				    )
+				    DC395x_write8(TRM_S1040_SCSI_COMMAND,
+						  SCMD_FIFO_OUT);
+			}
+		}
+#endif				/* DC395x_LASTPIO */
+		else {		/* xfer pad */
+
+			u8 data = 0, data2 = 0;
+			if (pSRB->SRBSGCount) {
+				pSRB->AdaptStatus = H_OVER_UNDER_RUN;
+				pSRB->SRBStatus |= OVER_RUN;
+			}
+			/*
+			 * KG: despite the fact that we are using 16 bits I/O ops
+			 * the SCSI FIFO is only 8 bits according to the docs
+			 * (we can set bit 1 in 0x8f to serialize FIFO access ...)
+			 */
+			if (pDCB->SyncPeriod & WIDE_SYNC) {
+				DC395x_write32(TRM_S1040_SCSI_COUNTER, 2);
+				DC395x_write8(TRM_S1040_SCSI_CONFIG2,
+					      CFG2_WIDEFIFO);
+				if (ioDir & DMACMD_DIR) {	/* read */
+					data =
+					    DC395x_read8
+					    (TRM_S1040_SCSI_FIFO);
+					data2 =
+					    DC395x_read8
+					    (TRM_S1040_SCSI_FIFO);
+					/*printk (DC395X_NAME ": DataIO: Xfer pad: %02x %02x\n", data, data2); */
+				} else {
+					/* Danger, Robinson: If you find KGs scattered over the wide
+					 * disk, the driver or chip is to blame :-( */
+					DC395x_write8(TRM_S1040_SCSI_FIFO,
+						      'K');
+					DC395x_write8(TRM_S1040_SCSI_FIFO,
+						      'G');
+				}
+				DC395x_write8(TRM_S1040_SCSI_CONFIG2, 0);
+			} else {
+				DC395x_write32(TRM_S1040_SCSI_COUNTER, 1);
+				/* Danger, Robinson: If you find a collection of Ks on your disk
+				 * something broke :-( */
+				if (ioDir & DMACMD_DIR) {	/* read */
+					data =
+					    DC395x_read8
+					    (TRM_S1040_SCSI_FIFO);
+					/*printk (DC395X_NAME ": DataIO: Xfer pad: %02x\n", data); */
+				} else {
+					DC395x_write8(TRM_S1040_SCSI_FIFO,
+						      'K');
+				}
+			}
+			pSRB->SRBState |= SRB_XFERPAD;
+			DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_DATALATCH);	/* it's important for atn stop */
+			/*
+			 * SCSI command 
+			 */
+			bval =
+			    (ioDir & DMACMD_DIR) ? SCMD_FIFO_IN :
+			    SCMD_FIFO_OUT;
+			DC395x_write8(TRM_S1040_SCSI_COMMAND, bval);
+		}
+	}
+	/*DC395x_monitor_next_IRQ = 2; */
+	/*printk (" done\n"); */
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *	DC395x_StatusPhase0: one of DC395x_SCSI_phase0[] vectors
+ *	 DC395x_stateV = (void *)DC395x_SCSI_phase0[phase]
+ *				if phase =3  
+ ********************************************************************
+ */
+static void
+DC395x_StatusPhase0(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB,
+		    u16 * pscsi_status)
+{
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME ": StatusPhase0 (pid %li)\n",
+	       pSRB->pcmd->pid);
+#endif
+	TRACEPRINTF("STP0 *");
+	pSRB->TargetStatus = DC395x_read8(TRM_S1040_SCSI_FIFO);
+	pSRB->EndMessage = DC395x_read8(TRM_S1040_SCSI_FIFO);	/* get message */
+	pSRB->SRBState = SRB_COMPLETED;
+	*pscsi_status = PH_BUS_FREE;	/*.. initial phase */
+	/*1.25 */
+	/*DC395x_clrfifo (pACB, "STP0"); */
+	DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_DATALATCH);	/* it's important for atn stop */
+	/*
+	 ** SCSI command 
+	 */
+	DC395x_write8(TRM_S1040_SCSI_COMMAND, SCMD_MSGACCEPT);
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *	DC395x_StatusPhase1: one of DC395x_SCSI_phase1[] vectors
+ *	 DC395x_stateV = (void *)DC395x_SCSI_phase1[phase]
+ *				if phase =3 
+ ********************************************************************
+ */
+static void
+DC395x_StatusPhase1(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB,
+		    u16 * pscsi_status)
+{
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME ": StatusPhase1 (pid=%li)\n",
+	       pSRB->pcmd->pid);
+#endif
+	TRACEPRINTF("STP1 *");
+	/* Cleanup is now done at the end of DataXXPhase0 */
+	/*DC395x_cleanup_after_transfer (pACB, pSRB); */
+
+	pSRB->SRBState = SRB_STATUS;
+	DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_DATALATCH);	/* it's important for atn stop */
+	/*
+	 * SCSI command 
+	 */
+	DC395x_write8(TRM_S1040_SCSI_COMMAND, SCMD_COMP);
+}
+
+/* Message handling */
+
+#if 0
+/* Print received message */
+static void DC395x_printMsg(u8 * MsgBuf, u32 len)
+{
+	int i;
+	printk(" %02x", MsgBuf[0]);
+	for (i = 1; i < len; i++)
+		printk(" %02x", MsgBuf[i]);
+	printk("\n");
+}
+#endif
+
+/* Check if the message is complete */
+static inline u8 DC395x_MsgIn_complete(u8 * msgbuf, u32 len)
+{
+	if (*msgbuf == EXTENDED_MESSAGE) {
+		if (len < 2)
+			return 0;
+		if (len < msgbuf[1] + 2)
+			return 0;
+	} else if (*msgbuf >= 0x20 && *msgbuf <= 0x2f)	/* two byte messages */
+		if (len < 2)
+			return 0;
+	return 1;
+}
+
+#define DC395x_ENABLE_MSGOUT \
+ DC395x_write16 (TRM_S1040_SCSI_CONTROL, DO_SETATN); \
+ pSRB->SRBState |= SRB_MSGOUT
+
+
+/* reject_msg */
+static inline void
+DC395x_MsgIn_reject(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB)
+{
+	pSRB->MsgOutBuf[0] = MESSAGE_REJECT;
+	pSRB->MsgCnt = 1;
+	DC395x_ENABLE_MSGOUT;
+	pSRB->SRBState &= ~SRB_MSGIN;
+	pSRB->SRBState |= SRB_MSGOUT;
+	printk(KERN_INFO DC395X_NAME
+	       ": Reject message %02x from %02i-%i\n", pSRB->MsgInBuf[0],
+	       pSRB->pSRBDCB->TargetID, pSRB->pSRBDCB->TargetLUN);
+	TRACEPRINTF("\\*");
+}
+
+
+/* abort command */
+static inline void
+DC395x_EnableMsgOut_Abort(struct AdapterCtlBlk *pACB,
+			  struct ScsiReqBlk *pSRB)
+{
+	pSRB->MsgOutBuf[0] = ABORT;
+	pSRB->MsgCnt = 1;
+	DC395x_ENABLE_MSGOUT;
+	pSRB->SRBState &= ~SRB_MSGIN;
+	pSRB->SRBState |= SRB_MSGOUT;
+	/*
+	   if (pSRB->pSRBDCB)
+	   pSRB->pSRBDCB->DCBFlag &= ~ABORT_DEV_;
+	 */
+	TRACEPRINTF("#*");
+}
+
+
+static struct ScsiReqBlk *DC395x_MsgIn_QTag(struct AdapterCtlBlk *pACB,
+					    struct DeviceCtlBlk *pDCB,
+					    u8 tag)
+{
+	struct ScsiReqBlk *lastSRB = pDCB->pGoingLast;
+	struct ScsiReqBlk *pSRB = pDCB->pGoingSRB;
+#ifdef DC395x_DEBUG0
+	printk(DC395X_NAME ": QTag Msg (SRB %p): %i ", pSRB, tag);
+#endif
+	if (!(pDCB->TagMask & (1 << tag)))
+		printk(DC395X_NAME
+		       ": MsgIn_QTag: TagMask (%08x) does not reserve tag %i!\n",
+		       pDCB->TagMask, tag);
+
+	if (!pSRB)
+		goto mingx0;
+	while (pSRB) {
+		if (pSRB->TagNumber == tag)
+			break;
+		if (pSRB == lastSRB)
+			goto mingx0;
+		pSRB = pSRB->pNextSRB;
+	}
+#ifdef DC395x_DEBUG0
+	printk("pid %li (%i-%i)\n", pSRB->pcmd->pid,
+	       pSRB->pSRBDCB->TargetID, pSRB->pSRBDCB->TargetLUN);
+#endif
+	if (pDCB->DCBFlag & ABORT_DEV_) {
+		/*pSRB->SRBState = SRB_ABORT_SENT; */
+		DC395x_EnableMsgOut_Abort(pACB, pSRB);
+	}
+
+	if (!(pSRB->SRBState & SRB_DISCONNECT))
+		goto mingx0;
+
+	/* Tag found */
+	TRACEPRINTF("[%s]*", pDCB->pActiveSRB->debugtrace);
+	TRACEPRINTF("RTag*");
+	/* Just for debugging ... */
+	lastSRB = pSRB;
+	pSRB = pDCB->pActiveSRB;
+	TRACEPRINTF("Found.*");
+	pSRB = lastSRB;
+
+	memcpy(pSRB->MsgInBuf, pDCB->pActiveSRB->MsgInBuf, pACB->MsgLen);
+	pSRB->SRBState |= pDCB->pActiveSRB->SRBState;
+	pSRB->SRBState |= SRB_DATA_XFER;
+	pDCB->pActiveSRB = pSRB;
+	/* How can we make the DORS happy? */
+	return pSRB;
+
+      mingx0:
+	pSRB = pACB->pTmpSRB;
+	pSRB->SRBState = SRB_UNEXPECT_RESEL;
+	pDCB->pActiveSRB = pSRB;
+	pSRB->MsgOutBuf[0] = MSG_ABORT_TAG;
+	pSRB->MsgCnt = 1;
+	DC395x_ENABLE_MSGOUT;
+	TRACEPRINTF("?*");
+	printk(DC395X_NAME ": Unknown tag received: %i: abort !!\n", tag);
+	return pSRB;
+}
+
+
+/* Reprogram registers */
+static inline void
+DC395x_reprog(struct AdapterCtlBlk *pACB, struct DeviceCtlBlk *pDCB)
+{
+	DC395x_write8(TRM_S1040_SCSI_TARGETID, pDCB->TargetID);
+	DC395x_write8(TRM_S1040_SCSI_SYNC, pDCB->SyncPeriod);
+	DC395x_write8(TRM_S1040_SCSI_OFFSET, pDCB->SyncOffset);
+	DC395x_SetXferRate(pACB, pDCB);
+}
+
+
+/* set async transfer mode */
+static void
+DC395x_MsgIn_set_async(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB)
+{
+	struct DeviceCtlBlk *pDCB = pSRB->pSRBDCB;
+	printk(DC395X_NAME ": Target %02i: No sync transfers\n",
+	       pDCB->TargetID);
+	TRACEPRINTF("!S *");
+	pDCB->SyncMode &= ~(SYNC_NEGO_ENABLE);
+	pDCB->SyncMode |= SYNC_NEGO_DONE;
+	/*pDCB->SyncPeriod &= 0; */
+	pDCB->SyncOffset = 0;
+	pDCB->MinNegoPeriod = 200 >> 2;	/* 200ns <=> 5 MHz */
+	pSRB->SRBState &= ~SRB_DO_SYNC_NEGO;
+	DC395x_reprog(pACB, pDCB);
+	if ((pDCB->SyncMode & WIDE_NEGO_ENABLE)
+	    && !(pDCB->SyncMode & WIDE_NEGO_DONE)) {
+		DC395x_Build_WDTR(pACB, pDCB, pSRB);
+		DC395x_ENABLE_MSGOUT;
+		DEBUG0(printk
+		       (DC395X_NAME ": SDTR(rej): Try WDTR anyway ...\n");
+		    )
+	}
+}
+
+
+/* set sync transfer mode */
+static void
+DC395x_MsgIn_set_sync(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB)
+{
+	u8 bval;
+	int fact;
+	struct DeviceCtlBlk *pDCB = pSRB->pSRBDCB;
+	/*u8 oldsyncperiod = pDCB->SyncPeriod; */
+	/*u8 oldsyncoffset = pDCB->SyncOffset; */
+
+#ifdef DC395x_DEBUG1
+	printk(KERN_INFO DC395X_NAME
+	       ": Target %02i: Sync: %ins (%02i.%01i MHz) Offset %i\n",
+	       pDCB->TargetID, pSRB->MsgInBuf[3] << 2,
+	       (250 / pSRB->MsgInBuf[3]),
+	       ((250 % pSRB->MsgInBuf[3]) * 10) / pSRB->MsgInBuf[3],
+	       pSRB->MsgInBuf[4]);
+#endif
+
+	if (pSRB->MsgInBuf[4] > 15)
+		pSRB->MsgInBuf[4] = 15;
+	if (!(pDCB->DevMode & NTC_DO_SYNC_NEGO))
+		pDCB->SyncOffset = 0;
+	else if (pDCB->SyncOffset == 0)
+		pDCB->SyncOffset = pSRB->MsgInBuf[4];
+	if (pSRB->MsgInBuf[4] > pDCB->SyncOffset)
+		pSRB->MsgInBuf[4] = pDCB->SyncOffset;
+	else
+		pDCB->SyncOffset = pSRB->MsgInBuf[4];
+	bval = 0;
+	while (bval < 7 && (pSRB->MsgInBuf[3] > dc395x_clock_period[bval]
+			    || pDCB->MinNegoPeriod >
+			    dc395x_clock_period[bval]))
+		bval++;
+	if (pSRB->MsgInBuf[3] < dc395x_clock_period[bval])
+		printk(KERN_INFO DC395X_NAME
+		       ": Increase sync nego period to %ins\n",
+		       dc395x_clock_period[bval] << 2);
+	pSRB->MsgInBuf[3] = dc395x_clock_period[bval];
+	pDCB->SyncPeriod &= 0xf0;
+	pDCB->SyncPeriod |= ALT_SYNC | bval;
+	pDCB->MinNegoPeriod = pSRB->MsgInBuf[3];
+
+	if (pDCB->SyncPeriod & WIDE_SYNC)
+		fact = 500;
+	else
+		fact = 250;
+
+	printk(KERN_INFO DC395X_NAME
+	       ": Target %02i: %s Sync: %ins Offset %i (%02i.%01i MB/s)\n",
+	       pDCB->TargetID, (fact == 500) ? "Wide16" : "",
+	       pDCB->MinNegoPeriod << 2, pDCB->SyncOffset,
+	       (fact / pDCB->MinNegoPeriod),
+	       ((fact % pDCB->MinNegoPeriod) * 10 +
+		pDCB->MinNegoPeriod / 2) / pDCB->MinNegoPeriod);
+
+	TRACEPRINTF("S%i *", pDCB->MinNegoPeriod << 2);
+	if (!(pSRB->SRBState & SRB_DO_SYNC_NEGO)) {
+		/* Reply with corrected SDTR Message */
+		printk(DC395X_NAME ": .. answer w/  %ins %i\n",
+		       pSRB->MsgInBuf[3] << 2, pSRB->MsgInBuf[4]);
+
+		memcpy(pSRB->MsgOutBuf, pSRB->MsgInBuf, 5);
+		pSRB->MsgCnt = 5;
+		DC395x_ENABLE_MSGOUT;
+		pDCB->SyncMode |= SYNC_NEGO_DONE;
+	} else {
+		if ((pDCB->SyncMode & WIDE_NEGO_ENABLE)
+		    && !(pDCB->SyncMode & WIDE_NEGO_DONE)) {
+			DC395x_Build_WDTR(pACB, pDCB, pSRB);
+			DC395x_ENABLE_MSGOUT;
+			DEBUG0(printk
+			       (DC395X_NAME ": SDTR: Also try WDTR ...\n");
+			    )
+		}
+	}
+	pSRB->SRBState &= ~SRB_DO_SYNC_NEGO;
+	pDCB->SyncMode |= SYNC_NEGO_DONE | SYNC_NEGO_ENABLE;
+
+	DC395x_reprog(pACB, pDCB);
+}
+
+
+static inline void
+DC395x_MsgIn_set_nowide(struct AdapterCtlBlk *pACB,
+			struct ScsiReqBlk *pSRB)
+{
+	struct DeviceCtlBlk *pDCB = pSRB->pSRBDCB;
+#ifdef DC395x_DEBUG_KG
+	printk(DC395X_NAME ": WDTR got rejected from target %02i\n",
+	       pDCB->TargetID);
+#endif
+	TRACEPRINTF("!W *");
+	pDCB->SyncPeriod &= ~WIDE_SYNC;
+	pDCB->SyncMode &= ~(WIDE_NEGO_ENABLE);
+	pDCB->SyncMode |= WIDE_NEGO_DONE;
+	pSRB->SRBState &= ~SRB_DO_WIDE_NEGO;
+	DC395x_reprog(pACB, pDCB);
+	if ((pDCB->SyncMode & SYNC_NEGO_ENABLE)
+	    && !(pDCB->SyncMode & SYNC_NEGO_DONE)) {
+		DC395x_Build_SDTR(pACB, pDCB, pSRB);
+		DC395x_ENABLE_MSGOUT;
+		DEBUG0(printk
+		       (DC395X_NAME ": WDTR(rej): Try SDTR anyway ...\n");
+		    )
+	}
+}
+
+static void
+DC395x_MsgIn_set_wide(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB)
+{
+	struct DeviceCtlBlk *pDCB = pSRB->pSRBDCB;
+	u8 wide = (pDCB->DevMode & NTC_DO_WIDE_NEGO
+		   && pACB->Config & HCC_WIDE_CARD) ? 1 : 0;
+	if (pSRB->MsgInBuf[3] > wide)
+		pSRB->MsgInBuf[3] = wide;
+	/* Completed */
+	if (!(pSRB->SRBState & SRB_DO_WIDE_NEGO)) {
+		printk(DC395X_NAME
+		       ": Target %02i initiates Wide Nego ...\n",
+		       pDCB->TargetID);
+		memcpy(pSRB->MsgOutBuf, pSRB->MsgInBuf, 4);
+		pSRB->MsgCnt = 4;
+		pSRB->SRBState |= SRB_DO_WIDE_NEGO;
+		DC395x_ENABLE_MSGOUT;
+	}
+
+	pDCB->SyncMode |= (WIDE_NEGO_ENABLE | WIDE_NEGO_DONE);
+	if (pSRB->MsgInBuf[3] > 0)
+		pDCB->SyncPeriod |= WIDE_SYNC;
+	else
+		pDCB->SyncPeriod &= ~WIDE_SYNC;
+	pSRB->SRBState &= ~SRB_DO_WIDE_NEGO;
+	TRACEPRINTF("W%i *", (pDCB->SyncPeriod & WIDE_SYNC ? 1 : 0));
+	/*pDCB->SyncMode &= ~(WIDE_NEGO_ENABLE+WIDE_NEGO_DONE); */
+#ifdef DC395x_DEBUG_KG
+	printk(DC395X_NAME
+	       ": Wide transfers (%i bit) negotiated with target %02i\n",
+	       (8 << pSRB->MsgInBuf[3]), pDCB->TargetID);
+#endif
+	DC395x_reprog(pACB, pDCB);
+	if ((pDCB->SyncMode & SYNC_NEGO_ENABLE)
+	    && !(pDCB->SyncMode & SYNC_NEGO_DONE)) {
+		DC395x_Build_SDTR(pACB, pDCB, pSRB);
+		DC395x_ENABLE_MSGOUT;
+		DEBUG0(printk(DC395X_NAME ": WDTR: Also try SDTR ...\n");
+		    )
+	}
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *	DC395x_MsgInPhase0: one of DC395x_SCSI_phase0[] vectors
+ *	 DC395x_stateV = (void *)DC395x_SCSI_phase0[phase]
+ *				if phase =7   
+ *
+ * extended message codes:
+ *
+ *	code	description
+ *
+ *	02h	Reserved
+ *	00h	MODIFY DATA  POINTER
+ *	01h	SYNCHRONOUS DATA TRANSFER REQUEST
+ *	03h	WIDE DATA TRANSFER REQUEST
+ *   04h - 7Fh	Reserved
+ *   80h - FFh	Vendor specific
+ *  
+ ********************************************************************
+ */
+void
+DC395x_MsgInPhase0(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB,
+		   u16 * pscsi_status)
+{
+	struct DeviceCtlBlk *pDCB;
+
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME
+	       ": DC395x_MsgInPhase0..............\n ");
+#endif
+	TRACEPRINTF("MIP0*");
+	pDCB = pACB->pActiveDCB;
+
+	pSRB->MsgInBuf[pACB->MsgLen++] = DC395x_read8(TRM_S1040_SCSI_FIFO);
+	if (DC395x_MsgIn_complete(pSRB->MsgInBuf, pACB->MsgLen)) {
+		TRACEPRINTF("(%02x)*", pSRB->MsgInBuf[0]);
+		/*printk (KERN_INFO DC395X_NAME ": MsgIn:"); */
+		/*DC395x_printMsg (pSRB->MsgInBuf, pACB->MsgLen); */
+
+		/* Now eval the msg */
+		switch (pSRB->MsgInBuf[0]) {
+		case DISCONNECT:
+			pSRB->SRBState = SRB_DISCONNECT;
+			break;
+
+		case SIMPLE_QUEUE_TAG:
+		case HEAD_OF_QUEUE_TAG:
+		case ORDERED_QUEUE_TAG:
+			TRACEPRINTF("(%02x)*", pSRB->MsgInBuf[1]);
+			pSRB =
+			    DC395x_MsgIn_QTag(pACB, pDCB,
+					      pSRB->MsgInBuf[1]);
+			break;
+
+		case MESSAGE_REJECT:
+			DC395x_write16(TRM_S1040_SCSI_CONTROL,
+				       DO_CLRATN | DO_DATALATCH);
+			/* A sync nego message was rejected ! */
+			if (pSRB->SRBState & SRB_DO_SYNC_NEGO) {
+				DC395x_MsgIn_set_async(pACB, pSRB);
+				break;
+			}
+			/* A wide nego message was rejected ! */
+			if (pSRB->SRBState & SRB_DO_WIDE_NEGO) {
+				DC395x_MsgIn_set_nowide(pACB, pSRB);
+				break;
+			}
+			DC395x_EnableMsgOut_Abort(pACB, pSRB);
+			/*pSRB->SRBState |= SRB_ABORT_SENT */
+			break;
+
+		case EXTENDED_MESSAGE:
+			TRACEPRINTF("(%02x)*", pSRB->MsgInBuf[2]);
+			/* SDTR */
+			if (pSRB->MsgInBuf[1] == 3
+			    && pSRB->MsgInBuf[2] == EXTENDED_SDTR) {
+				DC395x_MsgIn_set_sync(pACB, pSRB);
+				break;
+			}
+			/* WDTR */
+			if (pSRB->MsgInBuf[1] == 2 && pSRB->MsgInBuf[2] == EXTENDED_WDTR && pSRB->MsgInBuf[3] <= 2) {	/* sanity check ... */
+				DC395x_MsgIn_set_wide(pACB, pSRB);
+				break;
+			}
+			DC395x_MsgIn_reject(pACB, pSRB);
+			break;
+
+			/* Discard  wide residual */
+		case MSG_IGNOREWIDE:
+			DEBUG0(printk
+			       (DC395X_NAME ": Ignore Wide Residual!\n");
+			    )
+			    /*DC395x_write32 (TRM_S1040_SCSI_COUNTER, 1); */
+			    /*DC395x_read8 (TRM_S1040_SCSI_FIFO); */
+			    break;
+
+			/* nothing has to be done */
+		case COMMAND_COMPLETE:
+			break;
+
+			/*
+			 * SAVE POINTER may be ignored as we have the struct ScsiReqBlk* associated with the
+			 * scsi command. Thanks, Gérard, for pointing it out.
+			 */
+		case SAVE_POINTERS:
+#ifdef DC395x_DEBUG0
+			printk(DC395X_NAME
+			       ": SAVE POINTER message received (pid %li: rem.%i) ... ignore :-(\n",
+			       pSRB->pcmd->pid, pSRB->SRBTotalXferLength);
+#endif
+			/*pSRB->Saved_Ptr = pSRB->TotalXferredLen; */
+			break;
+			/* The device might want to restart transfer with a RESTORE */
+		case RESTORE_POINTERS:
+			printk(DC395X_NAME
+			       ": RESTORE POINTER message received ... ignore :-(\n");
+			/*dc395x_restore_ptr (pACB, pSRB); */
+			break;
+		case ABORT:
+			printk(DC395X_NAME
+			       ": ABORT msg received (pid %li %02i-%i)\n",
+			       pSRB->pcmd->pid, pDCB->TargetID,
+			       pDCB->TargetLUN);
+			pDCB->DCBFlag |= ABORT_DEV_;
+			DC395x_EnableMsgOut_Abort(pACB, pSRB);
+			break;
+			/* reject unknown messages */
+		default:
+			if (pSRB->MsgInBuf[0] & IDENTIFY_BASE) {
+				printk(DC395X_NAME
+				       ": Identify Message received?\n");
+				/*TRACEOUT (" %s\n", pSRB->debugtrace); */
+				pSRB->MsgCnt = 1;
+				pSRB->MsgOutBuf[0] = pDCB->IdentifyMsg;
+				DC395x_ENABLE_MSGOUT;
+				pSRB->SRBState |= SRB_MSGOUT;
+				/*break; */
+			}
+			DC395x_MsgIn_reject(pACB, pSRB);
+			TRACEOUT(" %s\n", pSRB->debugtrace);
+		}
+		TRACEPRINTF(".*");
+
+		/* Clear counter and MsgIn state */
+		pSRB->SRBState &= ~SRB_MSGIN;
+		pACB->MsgLen = 0;
+	}
+
+	/*1.25 */
+	if ((*pscsi_status & PHASEMASK) != PH_MSG_IN)
+#if 0
+		DC395x_clrfifo(pACB, "MIP0_");
+#else
+		TRACEPRINTF("N/Cln *");
+#endif
+	*pscsi_status = PH_BUS_FREE;
+	DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_DATALATCH);	/* it's important ... you know! */
+	DC395x_write8(TRM_S1040_SCSI_COMMAND, SCMD_MSGACCEPT);
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *	DC395x_MsgInPhase1: one of DC395x_SCSI_phase1[] vectors
+ *	 DC395x_stateV = (void *)DC395x_SCSI_phase1[phase]
+ *				if phase =7	   
+ ********************************************************************
+ */
+static void
+DC395x_MsgInPhase1(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB,
+		   u16 * pscsi_status)
+{
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME
+	       ": DC395x_MsgInPhase1..............\n ");
+#endif
+	TRACEPRINTF("MIP1 *");
+	DC395x_clrfifo(pACB, "MIP1");
+	DC395x_write32(TRM_S1040_SCSI_COUNTER, 1);
+	if (!(pSRB->SRBState & SRB_MSGIN)) {
+		pSRB->SRBState &= ~SRB_DISCONNECT;
+		pSRB->SRBState |= SRB_MSGIN;
+	}
+	DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_DATALATCH);	/* it's important for atn stop */
+	/*
+	 * SCSI command 
+	 */
+	DC395x_write8(TRM_S1040_SCSI_COMMAND, SCMD_FIFO_IN);
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *	DC395x_Nop0: one of DC395x_SCSI_phase1[] ,DC395x_SCSI_phase0[] vectors
+ *	 DC395x_stateV = (void *)DC395x_SCSI_phase0[phase]
+ *	 DC395x_stateV = (void *)DC395x_SCSI_phase1[phase]
+ *				if phase =4 ..PH_BUS_FREE
+ ********************************************************************
+ */
+static void
+DC395x_Nop0(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB,
+	    u16 * pscsi_status)
+{
+	/*TRACEPRINTF("NOP0 *"); */
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *	DC395x_Nop1: one of DC395x_SCSI_phase0[] ,DC395x_SCSI_phase1[] vectors
+ *	 DC395x_stateV = (void *)DC395x_SCSI_phase0[phase]
+ *	 DC395x_stateV = (void *)DC395x_SCSI_phase1[phase]
+ *				if phase =5
+ ********************************************************************
+ */
+static void
+DC395x_Nop1(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB,
+	    u16 * pscsi_status)
+{
+	/*TRACEPRINTF("NOP1 *"); */
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *		DC395x_MsgInPhase0
+ ********************************************************************
+ */
+static void
+DC395x_SetXferRate(struct AdapterCtlBlk *pACB, struct DeviceCtlBlk *pDCB)
+{
+	u8 bval;
+	u16 cnt, i;
+	struct DeviceCtlBlk *pDCBTemp;
+
+	/*
+	 ** set all lun device's  period , offset
+	 */
+	if (!(pDCB->IdentifyMsg & 0x07)) {
+		if (pACB->scan_devices)
+			DC395x_CurrSyncOffset = pDCB->SyncOffset;
+		else {
+			pDCBTemp = pACB->pLinkDCB;
+			cnt = pACB->DCBCnt;
+			bval = pDCB->TargetID;
+			for (i = 0; i < cnt; i++) {
+				if (pDCBTemp->TargetID == bval) {
+					pDCBTemp->SyncPeriod =
+					    pDCB->SyncPeriod;
+					pDCBTemp->SyncOffset =
+					    pDCB->SyncOffset;
+					pDCBTemp->SyncMode =
+					    pDCB->SyncMode;
+					pDCBTemp->MinNegoPeriod =
+					    pDCB->MinNegoPeriod;
+				}
+				pDCBTemp = pDCBTemp->pNextDCB;
+			}
+		}
+	}
+	return;
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *		DC395x_Interrupt
+ ********************************************************************
+ */
+void DC395x_Disconnect(struct AdapterCtlBlk *pACB)
+{
+	struct DeviceCtlBlk *pDCB;
+	struct ScsiReqBlk *pSRB;
+
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME ": Disconnect (pid=%li)\n",
+	       pACB->pActiveDCB->pActiveSRB->pcmd->pid);
+#endif
+	pDCB = pACB->pActiveDCB;
+	if (!pDCB) {
+		printk(KERN_ERR DC395X_NAME
+		       ": Disc: Exception Disconnect pDCB=NULL !!\n ");
+		udelay(500);
+		/* Suspend queue for a while */
+		pACB->pScsiHost->last_reset =
+		    jiffies + HZ / 2 +
+		    HZ *
+		    dc395x_trm_eepromBuf[pACB->AdapterIndex].
+		    NvramDelayTime;
+		DC395x_clrfifo(pACB, "DiscEx");
+		DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_HWRESELECT);
+		return;
+	}
+	pSRB = pDCB->pActiveSRB;
+	pACB->pActiveDCB = 0;
+	TRACEPRINTF("DISC *");
+
+	pSRB->ScsiPhase = PH_BUS_FREE;	/* initial phase */
+	DC395x_clrfifo(pACB, "Disc");
+	DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_HWRESELECT);
+	if (pSRB->SRBState & SRB_UNEXPECT_RESEL) {
+		printk(KERN_ERR DC395X_NAME
+		       ": Disc: Unexpected Reselection (%i-%i)\n",
+		       pDCB->TargetID, pDCB->TargetLUN);
+		pSRB->SRBState = 0;
+		DC395x_Waiting_process(pACB);
+	} else if (pSRB->SRBState & SRB_ABORT_SENT) {
+		/*Scsi_Cmnd* pcmd = pSRB->pcmd; */
+		pDCB->DCBFlag &= ~ABORT_DEV_;
+		pACB->pScsiHost->last_reset = jiffies + HZ / 2 + 1;
+		printk(KERN_ERR DC395X_NAME ": Disc: SRB_ABORT_SENT!\n");
+		DC395x_DoingSRB_Done(pACB, DID_ABORT, pSRB->pcmd, 1);
+		DC395x_Query_to_Waiting(pACB);
+		DC395x_Waiting_process(pACB);
+	} else {
+		if ((pSRB->SRBState & (SRB_START_ + SRB_MSGOUT))
+		    || !(pSRB->
+			 SRBState & (SRB_DISCONNECT + SRB_COMPLETED))) {
+			/*
+			 * Selection time out 
+			 * SRB_START_ || SRB_MSGOUT || (!SRB_DISCONNECT && !SRB_COMPLETED)
+			 */
+			/* Unexp. Disc / Sel Timeout */
+			if (pSRB->SRBState != SRB_START_
+			    && pSRB->SRBState != SRB_MSGOUT) {
+				pSRB->SRBState = SRB_READY;
+				printk(DC395X_NAME
+				       ": Unexpected Disconnection (pid %li)!\n",
+				       pSRB->pcmd->pid);
+				pSRB->TargetStatus = SCSI_STAT_SEL_TIMEOUT;
+				TRACEPRINTF("UnExpD *");
+				TRACEOUT("%s\n", pSRB->debugtrace);
+				goto disc1;
+			} else {
+				/* Normal selection timeout */
+				TRACEPRINTF("SlTO *");
+#ifdef DC395x_DEBUG_KG
+				printk(DC395X_NAME
+				       ": Disc: SelTO (pid=%li) for dev %02i-%i\n",
+				       pSRB->pcmd->pid, pDCB->TargetID,
+				       pDCB->TargetLUN);
+#endif
+				if (pSRB->RetryCnt++ > DC395x_MAX_RETRIES
+				    || pACB->scan_devices) {
+					pSRB->TargetStatus =
+					    SCSI_STAT_SEL_TIMEOUT;
+					goto disc1;
+				}
+				DC395x_freetag(pDCB, pSRB);
+				DC395x_Going_to_Waiting(pDCB, pSRB);
+#ifdef DC395x_DEBUG_KG
+				printk(DC395X_NAME ": Retry pid %li ...\n",
+				       pSRB->pcmd->pid);
+#endif
+				DC395x_waiting_timer(pACB, HZ / 20);
+			}
+		} else if (pSRB->SRBState & SRB_DISCONNECT) {
+			u8 bval = DC395x_read8(TRM_S1040_SCSI_SIGNAL);
+			/*
+			 * SRB_DISCONNECT (This is what we expect!)
+			 */
+			/* printk (DC395X_NAME ": DoWaitingSRB (pid=%li)\n", pSRB->pcmd->pid); */
+			TRACEPRINTF("+*");
+			if (bval & 0x40) {
+				DEBUG0(printk
+				       (DC395X_NAME
+					": Debug: DISC: SCSI bus stat %02x: ACK set! Other controllers?\n",
+					bval);
+				    )
+				    /* It could come from another initiator, therefore don't do much ! */
+				    TRACEPRINTF("ACK(%02x) *", bval);
+				/*DC395x_dumpinfo (pACB, pDCB, pSRB); */
+				/*TRACEOUT (" %s\n", pSRB->debugtrace); */
+				/*pDCB->DCBFlag |= ABORT_DEV_; */
+				/*DC395x_EnableMsgOut_Abort (pACB, pSRB); */
+				/*DC395x_write16 (TRM_S1040_SCSI_CONTROL, DO_CLRFIFO | DO_CLRATN | DO_HWRESELECT); */
+			} else
+				DC395x_Waiting_process(pACB);
+		} else if (pSRB->SRBState & SRB_COMPLETED) {
+		      disc1:
+			/*
+			 ** SRB_COMPLETED
+			 */
+			DC395x_freetag(pDCB, pSRB);
+			pDCB->pActiveSRB = 0;
+			pSRB->SRBState = SRB_FREE;
+			/*printk (DC395X_NAME ": done (pid=%li)\n", pSRB->pcmd->pid); */
+			DC395x_SRBdone(pACB, pDCB, pSRB);
+		}
+	}
+	return;
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *		DC395x_Reselect
+ ********************************************************************
+ */
+void DC395x_Reselect(struct AdapterCtlBlk *pACB)
+{
+	struct DeviceCtlBlk *pDCB;
+	struct ScsiReqBlk *pSRB = 0;
+	u16 RselTarLunId;
+	u8 id, lun;
+	u8 arblostflag = 0;
+
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME ": DC395x_Reselect..............\n ");
+#endif
+
+	DC395x_clrfifo(pACB, "Resel");
+	/*DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_HWRESELECT | DO_DATALATCH); */
+	/* Read Reselected Target ID and LUN */
+	RselTarLunId = DC395x_read16(TRM_S1040_SCSI_TARGETID);
+	pDCB = pACB->pActiveDCB;
+	if (pDCB) {		/* Arbitration lost but Reselection win */
+		pSRB = pDCB->pActiveSRB;
+		if (!pSRB) {
+			printk(DC395X_NAME
+			       ": Arb lost Resel won, but pActiveSRB == 0!\n");
+			DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_DATALATCH);	/* it's important for atn stop */
+			return;
+		}
+		/* Why the if ? */
+		if (!(pACB->scan_devices)) {
+#ifdef DC395x_DEBUG_KG
+			printk(DC395X_NAME
+			       ": Arb lost but Resel win pid %li (%02i-%i) Rsel %04x Stat %04x\n",
+			       pSRB->pcmd->pid, pDCB->TargetID,
+			       pDCB->TargetLUN, RselTarLunId,
+			       DC395x_read16(TRM_S1040_SCSI_STATUS));
+#endif
+			TRACEPRINTF("ArbLResel!*");
+			/*TRACEOUT (" %s\n", pSRB->debugtrace); */
+			arblostflag = 1;
+			/*pSRB->SRBState |= SRB_DISCONNECT; */
+
+			pSRB->SRBState = SRB_READY;
+			DC395x_freetag(pDCB, pSRB);
+			DC395x_Going_to_Waiting(pDCB, pSRB);
+			DC395x_waiting_timer(pACB, HZ / 20);
+
+			/* return; */
+		}
+	}
+	/* Read Reselected Target Id and LUN */
+	if (!(RselTarLunId & (IDENTIFY_BASE << 8)))
+		printk(DC395X_NAME
+		       ": Resel expects identify msg! Got %04x!\n",
+		       RselTarLunId);
+	id = RselTarLunId & 0xff;
+	lun = (RselTarLunId >> 8) & 7;
+	pDCB = DC395x_findDCB(pACB, id, lun);
+	if (!pDCB) {
+		printk(KERN_ERR DC395X_NAME
+		       ": Reselect from non existing device (%02i-%i)\n",
+		       id, lun);
+		DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_DATALATCH);	/* it's important for atn stop */
+		return;
+	}
+
+	pACB->pActiveDCB = pDCB;
+
+	if (!(pDCB->DevMode & NTC_DO_DISCONNECT))
+		printk(DC395X_NAME
+		       ": Reselection in spite of forbidden disconnection? (%02i-%i)\n",
+		       pDCB->TargetID, pDCB->TargetLUN);
+
+	if ((pDCB->SyncMode & EN_TAG_QUEUEING) /*&& !arblostflag */ ) {
+		struct ScsiReqBlk *oldSRB = pSRB;
+		pSRB = pACB->pTmpSRB;
+#ifdef DC395x_DEBUGTRACE
+		pSRB->debugpos = 0;
+		pSRB->debugtrace[0] = 0;
+#endif
+		pDCB->pActiveSRB = pSRB;
+		if (oldSRB)
+			TRACEPRINTF("ArbLResel(%li):*", oldSRB->pcmd->pid);
+		/*if (arblostflag) printk (DC395X_NAME ": Reselect: Wait for Tag ... \n"); */
+	} else {
+		/* There can be only one! */
+		pSRB = pDCB->pActiveSRB;
+		if (pSRB)
+			TRACEPRINTF("RSel *");
+		if (!pSRB || !(pSRB->SRBState & SRB_DISCONNECT)) {
+			/*
+			 * abort command
+			 */
+			printk(DC395X_NAME
+			       ": Reselected w/o disconnected cmds from %02i-%i?\n",
+			       pDCB->TargetID, pDCB->TargetLUN);
+			pSRB = pACB->pTmpSRB;
+			pSRB->SRBState = SRB_UNEXPECT_RESEL;
+			pDCB->pActiveSRB = pSRB;
+			DC395x_EnableMsgOut_Abort(pACB, pSRB);
+		} else {
+			if (pDCB->DCBFlag & ABORT_DEV_) {
+				/*pSRB->SRBState = SRB_ABORT_SENT; */
+				DC395x_EnableMsgOut_Abort(pACB, pSRB);
+			} else
+				pSRB->SRBState = SRB_DATA_XFER;
+
+		}
+		/*if (arblostflag) TRACEOUT (" %s\n", pSRB->debugtrace); */
+	}
+	pSRB->ScsiPhase = PH_BUS_FREE;	/* initial phase */
+	/* 
+	 ***********************************************
+	 ** Program HA ID, target ID, period and offset
+	 ***********************************************
+	 */
+	DC395x_write8(TRM_S1040_SCSI_HOSTID, pACB->pScsiHost->this_id);	/* host   ID */
+	DC395x_write8(TRM_S1040_SCSI_TARGETID, pDCB->TargetID);	/* target ID */
+	DC395x_write8(TRM_S1040_SCSI_OFFSET, pDCB->SyncOffset);	/* offset    */
+	DC395x_write8(TRM_S1040_SCSI_SYNC, pDCB->SyncPeriod);	/* sync period, wide */
+	DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_DATALATCH);	/* it's important for atn stop */
+	/* SCSI command */
+	DC395x_write8(TRM_S1040_SCSI_COMMAND, SCMD_MSGACCEPT);
+}
+
+
+/* Dynamic device handling */
+
+/* Remove dev (and DCB) */
+static void
+DC395x_remove_dev(struct AdapterCtlBlk *pACB, struct DeviceCtlBlk *pDCB)
+{
+	struct DeviceCtlBlk *pPrevDCB = pACB->pLinkDCB;
+
+	if (pDCB->GoingSRBCnt > 1) {
+		DCBDEBUG(printk
+			 (KERN_INFO DC395X_NAME
+			  ": Driver won't free DCB (ID %i, LUN %i): 0x%08x because of SRBCnt %i\n",
+			  pDCB->TargetID, pDCB->TargetLUN, (int) pDCB,
+			  pDCB->GoingSRBCnt);
+		    )
+		    return;
+	}
+	pACB->DCBmap[pDCB->TargetID] &= ~(1 << pDCB->TargetLUN);
+	pACB->children[pDCB->TargetID][pDCB->TargetLUN] = NULL;
+
+	/* The first one */
+	if (pDCB == pACB->pLinkDCB) {
+		/* The last one */
+		if (pACB->pLastDCB == pDCB) {
+			pDCB->pNextDCB = 0;
+			pACB->pLastDCB = 0;
+		}
+		pACB->pLinkDCB = pDCB->pNextDCB;
+	} else {
+		while (pPrevDCB->pNextDCB != pDCB)
+			pPrevDCB = pPrevDCB->pNextDCB;
+		pPrevDCB->pNextDCB = pDCB->pNextDCB;
+		if (pDCB == pACB->pLastDCB)
+			pACB->pLastDCB = pPrevDCB;
+	}
+
+	DCBDEBUG(printk
+		 (KERN_INFO DC395X_NAME
+		  ": Driver about to free DCB (ID %i, LUN %i): %p\n",
+		  pDCB->TargetID, pDCB->TargetLUN, pDCB);
+	    )
+	    if (pDCB == pACB->pActiveDCB)
+		pACB->pActiveDCB = 0;
+	if (pDCB == pACB->pLinkDCB)
+		pACB->pLinkDCB = pDCB->pNextDCB;
+	if (pDCB == pACB->pDCBRunRobin)
+		pACB->pDCBRunRobin = pDCB->pNextDCB;
+	pACB->DCBCnt--;
+	KFREE(pDCB);
+	/* pACB->DeviceCnt--; */
+}
+
+
+static inline u8 DC395x_tagq_blacklist(char *name)
+{
+#ifndef DC395x_NO_TAGQ
+#if 0
+	u8 i;
+	for (i = 0; i < BADDEVCNT; i++)
+		if (memcmp(name, DC395x_baddevname1[i], 28) == 0)
+			return 1;
+#endif
+	return 0;
+#else
+	return 1;
+#endif
+}
+
+
+static void
+DC395x_disc_tagq_set(struct DeviceCtlBlk *pDCB, struct ScsiInqData *ptr)
+{
+	/* Check for SCSI format (ANSI and Response data format) */
+	if ((ptr->Vers & 0x07) >= 2 || (ptr->RDF & 0x0F) == 2) {
+		if ((ptr->Flags & SCSI_INQ_CMDQUEUE)
+		    && (pDCB->DevMode & NTC_DO_TAG_QUEUEING) &&
+		    /*(pDCB->DevMode & NTC_DO_DISCONNECT) */
+		    /* ((pDCB->DevType == TYPE_DISK) 
+		       || (pDCB->DevType == TYPE_MOD)) && */
+		    !DC395x_tagq_blacklist(((char *) ptr) + 8)) {
+			if (pDCB->MaxCommand == 1)
+				pDCB->MaxCommand =
+				    pDCB->pDCBACB->TagMaxNum;
+			pDCB->SyncMode |= EN_TAG_QUEUEING;
+			/*pDCB->TagMask = 0; */
+		} else
+			pDCB->MaxCommand = 1;
+	}
+}
+
+
+static void
+DC395x_add_dev(struct AdapterCtlBlk *pACB, struct DeviceCtlBlk *pDCB,
+	       struct ScsiInqData *ptr)
+{
+	u8 bval1 = ptr->DevType & SCSI_DEVTYPE;
+	pDCB->DevType = bval1;
+	/* if (bval1 == TYPE_DISK || bval1 == TYPE_MOD) */
+	DC395x_disc_tagq_set(pDCB, ptr);
+}
+
+
+/* 
+ ********************************************************************
+ * unmap mapped pci regions from SRB
+ ********************************************************************
+ */
+static void
+DC395x_pci_unmap(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB)
+{
+	int dir;
+	Scsi_Cmnd *pcmd = pSRB->pcmd;
+	dir = scsi_to_pci_dma_dir(pcmd->sc_data_direction);
+	if (pcmd->use_sg && dir != PCI_DMA_NONE) {
+		/* unmap DC395x SG list */
+#ifdef DC395x_SGPARANOIA
+		printk(DC395X_NAME
+		       ": Unmap SG descriptor list %08x (%05x)\n",
+		       pSRB->SRBSGBusAddr,
+		       sizeof(struct SGentry) * DC395x_MAX_SG_LISTENTRY);
+#endif
+		pci_unmap_single(pACB->pdev, pSRB->SRBSGBusAddr,
+				 sizeof(struct SGentry) *
+				 DC395x_MAX_SG_LISTENTRY,
+				 PCI_DMA_TODEVICE);
+#ifdef DC395x_SGPARANOIA
+		printk(DC395X_NAME ": Unmap %i SG segments from %p\n",
+		       pcmd->use_sg, pcmd->request_buffer);
+#endif
+		/* unmap the sg segments */
+		pci_unmap_sg(pACB->pdev,
+			     (struct scatterlist *) pcmd->request_buffer,
+			     pcmd->use_sg, dir);
+	} else if (pcmd->request_buffer && dir != PCI_DMA_NONE) {
+#ifdef DC395x_SGPARANOIA
+		printk(DC395X_NAME ": Unmap buffer at %08x (%05x)\n",
+		       pSRB->SegmentX[0].address, pcmd->request_bufflen);
+#endif
+		pci_unmap_single(pACB->pdev, pSRB->SegmentX[0].address,
+				 pcmd->request_bufflen, dir);
+	}
+}
+
+
+/* 
+ ********************************************************************
+ * unmap mapped pci sense buffer from SRB
+ ********************************************************************
+ */
+static void
+DC395x_pci_unmap_sense(struct AdapterCtlBlk *pACB, struct ScsiReqBlk *pSRB)
+{
+	if (!(pSRB->SRBFlag & AUTO_REQSENSE))
+		return;
+	/* Unmap sense buffer */
+#ifdef DC395x_SGPARANOIA
+	printk(DC395X_NAME ": Unmap sense buffer from %08x (%05x)\n",
+	       pSRB->SegmentX[0].address, sizeof(pcmd->sense_buffer));
+#endif
+	pci_unmap_single(pACB->pdev, pSRB->SegmentX[0].address,
+			 pSRB->SegmentX[0].length, PCI_DMA_FROMDEVICE);
+	/* Restore SG stuff */
+	/*printk ("Auto_ReqSense finished: Restore Counters ...\n"); */
+	pSRB->SRBTotalXferLength = pSRB->Xferred;
+	pSRB->SegmentX[0].address =
+	    pSRB->SegmentX[DC395x_MAX_SG_LISTENTRY - 1].address;
+	pSRB->SegmentX[0].length =
+	    pSRB->SegmentX[DC395x_MAX_SG_LISTENTRY - 1].length;
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *		DC395x_Disconnected
+ *	Complete execution of a SCSI command
+ *	Signal completion to the generic SCSI driver  
+ ********************************************************************
+ */
+void
+DC395x_SRBdone(struct AdapterCtlBlk *pACB, struct DeviceCtlBlk *pDCB,
+	       struct ScsiReqBlk *pSRB)
+{
+	u8 tempcnt, status;
+	Scsi_Cmnd *pcmd;
+	struct ScsiInqData *ptr;
+	/*u32              drv_flags=0; */
+	int dir;
+
+	pcmd = pSRB->pcmd;
+	TRACEPRINTF("DONE *");
+
+	dir = scsi_to_pci_dma_dir(pcmd->sc_data_direction);
+	ptr = (struct ScsiInqData *) (pcmd->request_buffer);
+	if (pcmd->use_sg)
+		ptr =
+		    (struct ScsiInqData *) CPU_ADDR(*(struct scatterlist *)
+						    ptr);
+#ifdef DC395x_SGPARANOIA
+	printk(KERN_INFO DC395X_NAME
+	       ": SRBdone SG=%i (%i/%i), req_buf = %p, adr = %p\n",
+	       pcmd->use_sg, pSRB->SRBSGIndex, pSRB->SRBSGCount,
+	       pcmd->request_buffer, ptr);
+#endif
+#ifdef DC395x_DEBUG_KG
+	printk(KERN_INFO DC395X_NAME
+	       ": SRBdone (pid %li, target %02i-%i): ", pSRB->pcmd->pid,
+	       pSRB->pcmd->device->id, pSRB->pcmd->device->lun);
+#endif
+	status = pSRB->TargetStatus;
+	if (pSRB->SRBFlag & AUTO_REQSENSE) {
+#ifdef DC395x_DEBUG0
+		printk(KERN_INFO "AUTO_REQSENSE1..............\n ");
+#endif
+		DC395x_pci_unmap_sense(pACB, pSRB);
+		/*
+		 ** target status..........................
+		 */
+		pSRB->SRBFlag &= ~AUTO_REQSENSE;
+		pSRB->AdaptStatus = 0;
+		pSRB->TargetStatus = CHECK_CONDITION << 1;
+#ifdef DC395x_DEBUG_KG
+		switch (pcmd->sense_buffer[2] & 0x0f) {
+		case NOT_READY:
+			printk
+			    ("\nDC395x:  ReqSense: NOT_READY (Cmnd = 0x%02x, Dev = %i-%i, Stat = %i, Scan = %i) ",
+			     pcmd->cmnd[0], pDCB->TargetID,
+			     pDCB->TargetLUN, status, pACB->scan_devices);
+			break;
+		case UNIT_ATTENTION:
+			printk
+			    ("\nDC395x:  ReqSense: UNIT_ATTENTION (Cmnd = 0x%02x, Dev = %i-%i, Stat = %i, Scan = %i) ",
+			     pcmd->cmnd[0], pDCB->TargetID,
+			     pDCB->TargetLUN, status, pACB->scan_devices);
+			break;
+		case ILLEGAL_REQUEST:
+			printk
+			    ("\nDC395x:  ReqSense: ILLEGAL_REQUEST (Cmnd = 0x%02x, Dev = %i-%i, Stat = %i, Scan = %i) ",
+			     pcmd->cmnd[0], pDCB->TargetID,
+			     pDCB->TargetLUN, status, pACB->scan_devices);
+			break;
+		case MEDIUM_ERROR:
+			printk
+			    ("\nDC395x:  ReqSense: MEDIUM_ERROR (Cmnd = 0x%02x, Dev = %i-%i, Stat = %i, Scan = %i) ",
+			     pcmd->cmnd[0], pDCB->TargetID,
+			     pDCB->TargetLUN, status, pACB->scan_devices);
+			break;
+		case HARDWARE_ERROR:
+			printk
+			    ("\nDC395x:  ReqSense: HARDWARE_ERROR (Cmnd = 0x%02x, Dev = %i-%i, Stat = %i, Scan = %i) ",
+			     pcmd->cmnd[0], pDCB->TargetID,
+			     pDCB->TargetLUN, status, pACB->scan_devices);
+			break;
+		}
+		if (pcmd->sense_buffer[7] >= 6)
+			printk
+			    ("\nDC395x:  Sense=%02x, ASC=%02x, ASCQ=%02x (%08x %08x) ",
+			     pcmd->sense_buffer[2], pcmd->sense_buffer[12],
+			     pcmd->sense_buffer[13],
+			     *((unsigned int *) (pcmd->sense_buffer + 3)),
+			     *((unsigned int *) (pcmd->sense_buffer + 8)));
+		else
+			printk
+			    ("\nDC395x:  Sense=%02x, No ASC/ASCQ (%08x) ",
+			     pcmd->sense_buffer[2],
+			     *((unsigned int *) (pcmd->sense_buffer + 3)));
+#endif
+
+		if (status == (CHECK_CONDITION << 1)) {
+			pcmd->result = DID_BAD_TARGET << 16;
+			goto ckc_e;
+		}
+#ifdef DC395x_DEBUG0
+		printk(KERN_INFO "AUTO_REQSENSE2..............\n ");
+#endif
+
+		if ((pSRB->SRBTotalXferLength)
+		    && (pSRB->SRBTotalXferLength >= pcmd->underflow))
+			pcmd->result =
+			    MK_RES_LNX(DRIVER_SENSE, DID_OK,
+				       pSRB->EndMessage, CHECK_CONDITION);
+		/*SET_RES_DID(pcmd->result,DID_OK) */
+		else
+			pcmd->result =
+			    MK_RES_LNX(DRIVER_SENSE, DID_OK,
+				       pSRB->EndMessage, CHECK_CONDITION);
+
+		goto ckc_e;
+	}
+
+/*************************************************************/
+	if (status) {
+		/*
+		 * target status..........................
+		 */
+		if (status_byte(status) == CHECK_CONDITION) {
+			DC395x_RequestSense(pACB, pDCB, pSRB);
+			return;
+		} else if (status_byte(status) == QUEUE_FULL) {
+			tempcnt = (u8) pDCB->GoingSRBCnt;
+			printk
+			    ("\nDC395x:  QUEUE_FULL for dev %02i-%i with %i cmnds\n",
+			     pDCB->TargetID, pDCB->TargetLUN, tempcnt);
+			if (tempcnt > 1)
+				tempcnt--;
+			pDCB->MaxCommand = tempcnt;
+			DC395x_freetag(pDCB, pSRB);
+			DC395x_Going_to_Waiting(pDCB, pSRB);
+			DC395x_waiting_timer(pACB, HZ / 20);
+			pSRB->AdaptStatus = 0;
+			pSRB->TargetStatus = 0;
+			return;
+		} else if (status == SCSI_STAT_SEL_TIMEOUT) {
+			pSRB->AdaptStatus = H_SEL_TIMEOUT;
+			pSRB->TargetStatus = 0;
+			pcmd->result = DID_NO_CONNECT << 16;
+		} else {
+			pSRB->AdaptStatus = 0;
+			SET_RES_DID(pcmd->result, DID_ERROR);
+			SET_RES_MSG(pcmd->result, pSRB->EndMessage);
+			SET_RES_TARGET(pcmd->result, status);
+
+		}
+	} else {
+		/*
+		 ** process initiator status..........................
+		 */
+		status = pSRB->AdaptStatus;
+		if (status & H_OVER_UNDER_RUN) {
+			pSRB->TargetStatus = 0;
+			SET_RES_DID(pcmd->result, DID_OK);
+			SET_RES_MSG(pcmd->result, pSRB->EndMessage);
+		} else if (pSRB->SRBStatus & PARITY_ERROR) {
+			SET_RES_DID(pcmd->result, DID_PARITY);
+			SET_RES_MSG(pcmd->result, pSRB->EndMessage);
+		} else {	/* No error */
+
+			pSRB->AdaptStatus = 0;
+			pSRB->TargetStatus = 0;
+			SET_RES_DID(pcmd->result, DID_OK);
+		}
+	}
+
+	if (dir != PCI_DMA_NONE) {
+		if (pcmd->use_sg)
+			pci_dma_sync_sg(pACB->pdev,
+					(struct scatterlist *) pcmd->
+					request_buffer, pcmd->use_sg, dir);
+		else if (pcmd->request_buffer)
+			pci_dma_sync_single(pACB->pdev,
+					    pSRB->SegmentX[0].address,
+					    pcmd->request_bufflen, dir);
+	}
+
+	if ((pcmd->result & RES_DID) == 0 && pcmd->cmnd[0] == INQUIRY
+	    && pcmd->cmnd[2] == 0 && pcmd->request_bufflen >= 8
+	    && dir != PCI_DMA_NONE && ptr && (ptr->Vers & 0x07) >= 2)
+		pDCB->Inquiry7 = ptr->Flags;
+/* Check Error Conditions */
+      ckc_e:
+
+	/*if( pSRB->pcmd->cmnd[0] == INQUIRY && */
+	/*  (host_byte(pcmd->result) == DID_OK || status_byte(pcmd->result) & CHECK_CONDITION) ) */
+	if (pcmd->cmnd[0] == INQUIRY && (pcmd->result == (DID_OK << 16)
+					 || status_byte(pcmd->
+							result) &
+					 CHECK_CONDITION)) {
+
+		if (!pDCB->init_TCQ_flag) {
+			DC395x_add_dev(pACB, pDCB, ptr);
+			pDCB->init_TCQ_flag = 1;
+		}
+
+	}
+
+
+	/* Here is the info for Doug Gilbert's sg3 ... */
+	pcmd->resid = pSRB->SRBTotalXferLength;
+	/* This may be interpreted by sb. or not ... */
+	pcmd->SCp.this_residual = pSRB->SRBTotalXferLength;
+	pcmd->SCp.buffers_residual = 0;
+#ifdef DC395x_DEBUG_KG
+	if (pSRB->SRBTotalXferLength)
+		printk
+		    ("\nDC395x:  pid %li: %02x (%02i-%i): Missed %i bytes\n",
+		     pcmd->pid, pcmd->cmnd[0], pcmd->device->id,
+		     pcmd->device->lun, pSRB->SRBTotalXferLength);
+#endif
+
+	DC395x_Going_remove(pDCB, pSRB, 0);
+	/* Add to free list */
+	if (pSRB == pACB->pTmpSRB)
+		printk("\nDC395x:  ERROR! Completed Cmnd with TmpSRB!\n");
+	else
+		DC395x_Free_insert(pACB, pSRB);
+
+	DEBUG0(printk
+	       (KERN_DEBUG DC395X_NAME ":  SRBdone: done pid %li\n",
+		pcmd->pid);
+	    )
+#ifdef DC395x_DEBUG_KG
+	    printk(" 0x%08x\n", pcmd->result);
+#endif
+	TRACEPRINTF("%08x(%li)*", pcmd->result, jiffies);
+	DC395x_pci_unmap(pACB, pSRB);
+	/*DC395x_UNLOCK_ACB_NI; */
+	pcmd->scsi_done(pcmd);
+	/*DC395x_LOCK_ACB_NI; */
+	TRACEOUTALL(KERN_INFO " %s\n", pSRB->debugtrace);
+
+	DC395x_Query_to_Waiting(pACB);
+	DC395x_Waiting_process(pACB);
+	return;
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *		DC395x_reset
+ * abort all cmds in our queues
+ ********************************************************************
+ */
+void
+DC395x_DoingSRB_Done(struct AdapterCtlBlk *pACB, u8 did_flag,
+		     Scsi_Cmnd * cmd, u8 force)
+{
+	struct DeviceCtlBlk *pDCB;
+	struct ScsiReqBlk *pSRB;
+	struct ScsiReqBlk *pSRBTemp;
+	u16 cnt;
+	Scsi_Cmnd *pcmd;
+
+	pDCB = pACB->pLinkDCB;
+	if (!pDCB)
+		return;
+	printk(KERN_INFO DC395X_NAME ": DC395x_DoingSRB_Done: pids ");
+	do {
+		/* As the ML may queue cmnds again, cache old values */
+		struct ScsiReqBlk *pWaitingSRB = pDCB->pWaitingSRB;
+		/*struct ScsiReqBlk* pWaitLast = pDCB->pWaitLast; */
+		u16 WaitSRBCnt = pDCB->WaitSRBCnt;
+		/* Going queue */
+		cnt = pDCB->GoingSRBCnt;
+		pSRB = pDCB->pGoingSRB;
+		while (cnt--) {
+			int result;
+			int dir;
+			pSRBTemp = pSRB->pNextSRB;
+			pcmd = pSRB->pcmd;
+			dir = scsi_to_pci_dma_dir(pcmd->sc_data_direction);
+			result = MK_RES(0, did_flag, 0, 0);
+			/*result = MK_RES(0,DID_RESET,0,0); */
+			TRACEPRINTF("Reset(%li):%08x*", jiffies, result);
+			printk(" (G)");
+#if 1				/*ndef DC395x_DEBUGTRACE */
+			printk("%li(%02i-%i) ", pcmd->pid,
+			       pcmd->device->id, pcmd->device->lun);
+#endif
+			TRACEOUT("%s\n", pSRB->debugtrace);
+			pDCB->pGoingSRB = pSRBTemp;
+			pDCB->GoingSRBCnt--;
+			if (!pSRBTemp)
+				pDCB->pGoingLast = NULL;
+			DC395x_freetag(pDCB, pSRB);
+			DC395x_Free_insert(pACB, pSRB);
+			pcmd->result = result;
+			DC395x_pci_unmap_sense(pACB, pSRB);
+			DC395x_pci_unmap(pACB, pSRB);
+			if (force) {
+				/* For new EH, we normally don't need to give commands back,
+				 * as they all complete or all time out */
+				/* do we need the aic7xxx hack and conditionally decrease retry ? */
+				/*DC395x_SCSI_DONE_ACB_UNLOCK; */
+				pcmd->scsi_done(pcmd);
+				/*DC395x_SCSI_DONE_ACB_LOCK; */
+			}
+			pSRB = pSRBTemp;
+		}
+		if (pDCB->pGoingSRB)
+			printk(DC395X_NAME
+			       ": How could the ML send cmnds to the Going queue? (%02i-%i)!!\n",
+			       pDCB->TargetID, pDCB->TargetLUN);
+		if (pDCB->TagMask)
+			printk(DC395X_NAME
+			       ": TagMask for %02i-%i should be empty, is %08x!\n",
+			       pDCB->TargetID, pDCB->TargetLUN,
+			       pDCB->TagMask);
+		/*pDCB->GoingSRBCnt = 0;; */
+		/*pDCB->pGoingSRB = NULL; pDCB->pGoingLast = NULL; */
+
+		/* Waiting queue */
+		cnt = WaitSRBCnt;
+		pSRB = pWaitingSRB;
+		while (cnt--) {
+			int result;
+			pSRBTemp = pSRB->pNextSRB;
+			pcmd = pSRB->pcmd;
+			result = MK_RES(0, did_flag, 0, 0);
+			TRACEPRINTF("Reset(%li):%08x*", jiffies, result);
+			printk(" (W)");
+#if 1				/*ndef DC395x_DEBUGTRACE */
+			printk("%li(%i-%i)", pcmd->pid, pcmd->device->id,
+			       pcmd->device->lun);
+#endif
+			TRACEOUT("%s\n", pSRB->debugtrace);
+			pDCB->pWaitingSRB = pSRBTemp;
+			pDCB->WaitSRBCnt--;
+			if (!pSRBTemp)
+				pDCB->pWaitLast = NULL;
+			DC395x_Free_insert(pACB, pSRB);
+
+			pcmd->result = result;
+			DC395x_pci_unmap_sense(pACB, pSRB);
+			DC395x_pci_unmap(pACB, pSRB);
+			if (force) {
+				/* For new EH, we normally don't need to give commands back,
+				 * as they all complete or all time out */
+				/* do we need the aic7xxx hack and conditionally decrease retry ? */
+				/*DC395x_SCSI_DONE_ACB_UNLOCK; */
+				pcmd->scsi_done(pcmd);
+				/*DC395x_SCSI_DONE_ACB_LOCK; */
+				pSRB = pSRBTemp;
+			}
+		}
+		if (pDCB->WaitSRBCnt)
+			printk
+			    ("\nDC395x: Debug: ML queued %i cmnds again to %02i-%i\n",
+			     pDCB->WaitSRBCnt, pDCB->TargetID,
+			     pDCB->TargetLUN);
+		/* The ML could have queued the cmnds again! */
+		/*pDCB->WaitSRBCnt = 0;; */
+		/*pDCB->pWaitingSRB = NULL; pDCB->pWaitLast = NULL; */
+		pDCB->DCBFlag &= ~ABORT_DEV_;
+		pDCB = pDCB->pNextDCB;
+	}
+	while (pDCB != pACB->pLinkDCB && pDCB);
+	printk("\n");
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *		DC395x_shutdown   DC395x_reset
+ ********************************************************************
+ */
+static void DC395x_ResetSCSIBus(struct AdapterCtlBlk *pACB)
+{
+	/*u32  drv_flags=0; */
+
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME
+	       ": DC395x_ResetSCSIBus..............\n ");
+#endif
+
+	/*DC395x_DRV_LOCK(drv_flags); */
+	pACB->ACBFlag |= RESET_DEV;	/* RESET_DETECT, RESET_DONE, RESET_DEV */
+
+	DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_RSTSCSI);
+	while (!(DC395x_read8(TRM_S1040_SCSI_INTSTATUS) & INT_SCSIRESET));
+
+	/*DC395x_DRV_UNLOCK(drv_flags); */
+	return;
+}
+
+
+/* Set basic config */
+static void DC395x_basic_config(struct AdapterCtlBlk *pACB)
+{
+	u8 bval;
+	u16 wval;
+	DC395x_write8(TRM_S1040_SCSI_TIMEOUT, pACB->sel_timeout);
+	if (pACB->Config & HCC_PARITY)
+		bval = PHASELATCH | INITIATOR | BLOCKRST | PARITYCHECK;
+	else
+		bval = PHASELATCH | INITIATOR | BLOCKRST;
+
+	DC395x_write8(TRM_S1040_SCSI_CONFIG0, bval);
+
+	/* program configuration 1: Act_Neg (+ Act_Neg_Enh? + Fast_Filter? + DataDis?) */
+	DC395x_write8(TRM_S1040_SCSI_CONFIG1, 0x03);	/* was 0x13: default */
+	/* program Host ID                  */
+	DC395x_write8(TRM_S1040_SCSI_HOSTID, pACB->pScsiHost->this_id);
+	/* set ansynchronous transfer       */
+	DC395x_write8(TRM_S1040_SCSI_OFFSET, 0x00);
+	/* Turn LED control off */
+	wval = DC395x_read16(TRM_S1040_GEN_CONTROL) & 0x7F;
+	DC395x_write16(TRM_S1040_GEN_CONTROL, wval);
+	/* DMA config          */
+	wval = DC395x_read16(TRM_S1040_DMA_CONFIG) & ~DMA_FIFO_CTRL;
+	wval |=
+	    DMA_FIFO_HALF_HALF | DMA_ENHANCE /*| DMA_MEM_MULTI_READ */ ;
+	/*printk (KERN_INFO DC395X_NAME "DMA_Config: %04x\n", wval); */
+	DC395x_write16(TRM_S1040_DMA_CONFIG, wval);
+	/* Clear pending interrupt status */
+	DC395x_read8(TRM_S1040_SCSI_INTSTATUS);
+	/* Enable SCSI interrupt    */
+	DC395x_write8(TRM_S1040_SCSI_INTEN, 0x7F);
+	DC395x_write8(TRM_S1040_DMA_INTEN, EN_SCSIINTR | EN_DMAXFERERROR
+		      /*| EN_DMAXFERABORT | EN_DMAXFERCOMP | EN_FORCEDMACOMP */
+		      );
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *		DC395x_Interrupt
+ ********************************************************************
+ */
+static void DC395x_ScsiRstDetect(struct AdapterCtlBlk *pACB)
+{
+	printk(KERN_INFO DC395X_NAME ": DC395x_ScsiRstDetect\n");
+	/* delay half a second */
+	if (timer_pending(&pACB->Waiting_Timer))
+		del_timer(&pACB->Waiting_Timer);
+
+	DC395x_write8(TRM_S1040_SCSI_CONTROL, DO_RSTMODULE);
+	DC395x_write8(TRM_S1040_DMA_CONTROL, DMARESETMODULE);
+	/*DC395x_write8(TRM_S1040_DMA_CONTROL,STOPDMAXFER); */
+	udelay(500);
+	/* Maybe we locked up the bus? Then lets wait even longer ... */
+	pACB->pScsiHost->last_reset =
+	    jiffies + 5 * HZ / 2 +
+	    HZ * dc395x_trm_eepromBuf[pACB->AdapterIndex].NvramDelayTime;
+
+	DC395x_clrfifo(pACB, "RstDet");
+	DC395x_basic_config(pACB);
+	/*1.25 */
+	/*DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_HWRESELECT); */
+
+	if (pACB->ACBFlag & RESET_DEV) {	/* RESET_DETECT, RESET_DONE, RESET_DEV */
+		pACB->ACBFlag |= RESET_DONE;
+	} else {
+		pACB->ACBFlag |= RESET_DETECT;
+		DC395x_ResetDevParam(pACB);
+		DC395x_DoingSRB_Done(pACB, DID_RESET, 0, 1);
+		/*DC395x_RecoverSRB( pACB ); */
+		pACB->pActiveDCB = NULL;
+		pACB->ACBFlag = 0;
+		DC395x_Waiting_process(pACB);
+	}
+
+	return;
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *		DC395x_SRBdone
+ ********************************************************************
+ */
+static void
+DC395x_RequestSense(struct AdapterCtlBlk *pACB, struct DeviceCtlBlk *pDCB,
+		    struct ScsiReqBlk *pSRB)
+{
+	Scsi_Cmnd *pcmd;
+
+	pcmd = pSRB->pcmd;
+#ifdef DC395x_DEBUG_KG
+	printk(KERN_INFO DC395X_NAME
+	       ": DC395x_RequestSense for pid %li, target %02i-%i\n",
+	       pcmd->pid, pcmd->device->id, pcmd->device->lun);
+#endif
+	TRACEPRINTF("RqSn*");
+	pSRB->SRBFlag |= AUTO_REQSENSE;
+	pSRB->AdaptStatus = 0;
+	pSRB->TargetStatus = 0;
+
+	/* KG: Can this prevent crap sense data ? */
+	memset(pcmd->sense_buffer, 0, sizeof(pcmd->sense_buffer));
+
+	/* Save some data */
+	pSRB->SegmentX[DC395x_MAX_SG_LISTENTRY - 1].address =
+	    pSRB->SegmentX[0].address;
+	pSRB->SegmentX[DC395x_MAX_SG_LISTENTRY - 1].length =
+	    pSRB->SegmentX[0].length;
+	pSRB->Xferred = pSRB->SRBTotalXferLength;
+	/* pSRB->SegmentX : a one entry of S/G list table */
+	pSRB->SRBTotalXferLength = sizeof(pcmd->sense_buffer);
+	pSRB->SegmentX[0].length = sizeof(pcmd->sense_buffer);
+	/* Map sense buffer */
+	pSRB->SegmentX[0].address =
+	    pci_map_single(pACB->pdev, pcmd->sense_buffer,
+			   sizeof(pcmd->sense_buffer), PCI_DMA_FROMDEVICE);
+#ifdef DC395x_SGPARANOIA
+	printk(DC395X_NAME ": Map sense buffer at %p (%05x) to %08x\n",
+	       pcmd->sense_buffer, sizeof(pcmd->sense_buffer),
+	       pSRB->SegmentX[0].address);
+#endif
+	pSRB->SRBSGCount = 1;
+	pSRB->SRBSGIndex = 0;
+
+	if (DC395x_StartSCSI(pACB, pDCB, pSRB)) {	/* Should only happen, if sb. else grabs the bus */
+		printk(DC395X_NAME
+		       ": Request Sense failed for pid %li (%02i-%i)!\n",
+		       pSRB->pcmd->pid, pDCB->TargetID, pDCB->TargetLUN);
+		TRACEPRINTF("?*");
+		DC395x_Going_to_Waiting(pDCB, pSRB);
+		DC395x_waiting_timer(pACB, HZ / 100);
+	}
+	TRACEPRINTF(".*");
+}
+
+
+/*
+ *********************************************************************
+ *		DC395x_queue_command
+ *
+ * Function : void DC395x_initDCB
+ *  Purpose : initialize the internal structures for a given DCB
+ *   Inputs : cmd - pointer to this scsi cmd request block structure
+ *********************************************************************
+ */
+void
+DC395x_initDCB(struct AdapterCtlBlk *pACB, struct DeviceCtlBlk **ppDCB,
+	       u8 target, u8 lun)
+{
+	struct NvRamType *eeprom;
+	u8 PeriodIndex;
+	u16 index;
+	struct DeviceCtlBlk *pDCB;
+	struct DeviceCtlBlk *pDCB2;
+
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME ": DC395x_initDCB..............\n ");
+#endif
+	pDCB = KMALLOC(sizeof(struct DeviceCtlBlk), GFP_ATOMIC);
+	/*pDCB = DC395x_findDCB (pACB, target, lun); */
+	*ppDCB = pDCB;
+	pDCB2 = 0;
+	if (!pDCB)
+		return;
+
+	if (pACB->DCBCnt == 0) {
+		pACB->pLinkDCB = pDCB;
+		pACB->pDCBRunRobin = pDCB;
+	} else {
+		pACB->pLastDCB->pNextDCB = pDCB;
+	}
+
+	pACB->DCBCnt++;
+	pDCB->pNextDCB = pACB->pLinkDCB;
+	pACB->pLastDCB = pDCB;
+
+	/* $$$$$$$ */
+	pDCB->pDCBACB = pACB;
+	pDCB->TargetID = target;
+	pDCB->TargetLUN = lun;
+	/* $$$$$$$ */
+	pDCB->pWaitingSRB = NULL;
+	pDCB->pGoingSRB = NULL;
+	pDCB->GoingSRBCnt = 0;
+	pDCB->WaitSRBCnt = 0;
+	pDCB->pActiveSRB = NULL;
+	/* $$$$$$$ */
+	pDCB->TagMask = 0;
+	pDCB->DCBFlag = 0;
+	pDCB->MaxCommand = 1;
+	pDCB->AdaptIndex = pACB->AdapterIndex;
+	/* $$$$$$$ */
+	index = pACB->AdapterIndex;
+	eeprom = &dc395x_trm_eepromBuf[index];
+	pDCB->DevMode = eeprom->NvramTarget[target].NvmTarCfg0;
+	/*pDCB->AdpMode = eeprom->NvramChannelCfg; */
+	pDCB->Inquiry7 = 0;
+	pDCB->SyncMode = 0;
+	pDCB->last_derated = pACB->pScsiHost->last_reset - 2;
+	/* $$$$$$$ */
+	pDCB->SyncPeriod = 0;
+	pDCB->SyncOffset = 0;
+	PeriodIndex = eeprom->NvramTarget[target].NvmTarPeriod & 0x07;
+	pDCB->MinNegoPeriod = dc395x_clock_period[PeriodIndex];
+
+#ifndef DC395x_NO_WIDE
+	if ((pDCB->DevMode & NTC_DO_WIDE_NEGO)
+	    && (pACB->Config & HCC_WIDE_CARD))
+		pDCB->SyncMode |= WIDE_NEGO_ENABLE;
+#endif
+#ifndef DC395x_NO_SYNC
+	if (pDCB->DevMode & NTC_DO_SYNC_NEGO)
+		if (!(lun) || DC395x_CurrSyncOffset)
+			pDCB->SyncMode |= SYNC_NEGO_ENABLE;
+#endif
+	/* $$$$$$$ */
+#ifndef DC395x_NO_DISCONNECT
+	pDCB->IdentifyMsg =
+	    IDENTIFY(pDCB->DevMode & NTC_DO_DISCONNECT, lun);
+#else
+	pDCB->IdentifyMsg = IDENTIFY(0, lun);
+#endif
+	/* $$$$$$$ */
+	if (pDCB->TargetLUN != 0) {
+		/* Copy settings */
+		struct DeviceCtlBlk *prevDCB = pACB->pLinkDCB;
+		while (prevDCB->TargetID != pDCB->TargetID)
+			prevDCB = prevDCB->pNextDCB;
+#ifdef DC395x_DEBUG_KG
+		printk(DC395X_NAME
+		       ": Copy settings from %02i-%02i to %02i-%02i\n",
+		       prevDCB->TargetID, prevDCB->TargetLUN,
+		       pDCB->TargetID, pDCB->TargetLUN);
+#endif
+		pDCB->SyncMode = prevDCB->SyncMode;
+		pDCB->SyncPeriod = prevDCB->SyncPeriod;
+		pDCB->MinNegoPeriod = prevDCB->MinNegoPeriod;
+		pDCB->SyncOffset = prevDCB->SyncOffset;
+		pDCB->Inquiry7 = prevDCB->Inquiry7;
+	};
+
+	pACB->DCBmap[target] |= (1 << lun);
+	pACB->children[target][lun] = pDCB;
+}
+
+
+/* Dynamically allocated memory handling */
+
+#ifdef DC395x_DEBUGTRACE
+/* Memory for trace buffers */
+void DC395x_free_tracebufs(struct AdapterCtlBlk *pACB, int SRBIdx)
+{
+	int srbidx;
+	const unsigned bufs_per_page = PAGE_SIZE / DEBUGTRACEBUFSZ;
+	for (srbidx = 0; srbidx < SRBIdx; srbidx += bufs_per_page) {
+		/*printk (DC395X_NAME ": Free tracebuf %p (for %i)\n", */
+		/*      pACB->SRB_array[srbidx].debugtrace, srbidx); */
+		KFREE(pACB->SRB_array[srbidx].debugtrace);
+	}
+}
+
+
+int DC395x_alloc_tracebufs(struct AdapterCtlBlk *pACB)
+{
+	const unsigned mem_needed =
+	    (DC395x_MAX_SRB_CNT + 1) * DEBUGTRACEBUFSZ;
+	int pages = (mem_needed + (PAGE_SIZE - 1)) / PAGE_SIZE;
+	const unsigned bufs_per_page = PAGE_SIZE / DEBUGTRACEBUFSZ;
+	int SRBIdx = 0;
+	unsigned i = 0;
+	unsigned char *ptr;
+	/*printk (DC395X_NAME ": Alloc %i pages for tracebufs\n", pages); */
+	while (pages--) {
+		ptr = KMALLOC(PAGE_SIZE, GFP_KERNEL);
+		if (!ptr) {
+			DC395x_free_tracebufs(pACB, SRBIdx);
+			return 1;
+		}
+		/*printk (DC395X_NAME ": Alloc %li bytes at %p for tracebuf %i\n", */
+		/*      PAGE_SIZE, ptr, SRBIdx); */
+		i = 0;
+		while (i < bufs_per_page && SRBIdx < DC395x_MAX_SRB_CNT)
+			pACB->SRB_array[SRBIdx++].debugtrace =
+			    ptr + (i++ * DEBUGTRACEBUFSZ);
+	}
+	if (i < bufs_per_page) {
+		pACB->TmpSRB.debugtrace = ptr + (i * DEBUGTRACEBUFSZ);
+		pACB->TmpSRB.debugtrace[0] = 0;
+	} else
+		printk(DC395X_NAME
+		       ": No space for tmpSRB tracebuf reserved?!\n");
+	return 0;
+}
+#endif
+
+
+/* Free SG tables */
+void DC395x_free_SG_tables(struct AdapterCtlBlk *pACB, int SRBIdx)
+{
+	int srbidx;
+	const unsigned SRBs_per_page =
+	    PAGE_SIZE / (DC395x_MAX_SG_LISTENTRY * sizeof(struct SGentry));
+	for (srbidx = 0; srbidx < SRBIdx; srbidx += SRBs_per_page) {
+		/*printk (DC395X_NAME ": Free SG segs %p (for %i)\n", */
+		/*      pACB->SRB_array[srbidx].SegmentX, srbidx); */
+		KFREE(pACB->SRB_array[srbidx].SegmentX);
+	}
+}
+
+
+/*
+ * Allocate SG tables; as we have to pci_map them, an SG list (struct SGentry*)
+ * should never cross a page boundary */
+int DC395x_alloc_SG_tables(struct AdapterCtlBlk *pACB)
+{
+	const unsigned mem_needed =
+	    (DC395x_MAX_SRB_CNT +
+	     1) * DC395x_MAX_SG_LISTENTRY * sizeof(struct SGentry);
+	int pages = (mem_needed + (PAGE_SIZE - 1)) / PAGE_SIZE;
+	const unsigned SRBs_per_page =
+	    PAGE_SIZE / (DC395x_MAX_SG_LISTENTRY * sizeof(struct SGentry));
+	int SRBIdx = 0;
+	unsigned i = 0;
+	struct SGentry *ptr;
+	/*printk (DC395X_NAME ": Alloc %i pages for SG tables\n", pages); */
+	while (pages--) {
+		ptr = (struct SGentry *) KMALLOC(PAGE_SIZE, GFP_KERNEL);
+		if (!ptr) {
+			DC395x_free_SG_tables(pACB, SRBIdx);
+			return 1;
+		}
+		/*printk (DC395X_NAME ": Alloc %li bytes at %p for SG segments %i\n", */
+		/*      PAGE_SIZE, ptr, SRBIdx); */
+		i = 0;
+		while (i < SRBs_per_page && SRBIdx < DC395x_MAX_SRB_CNT)
+			pACB->SRB_array[SRBIdx++].SegmentX =
+			    ptr + (i++ * DC395x_MAX_SG_LISTENTRY);
+	}
+	if (i < SRBs_per_page)
+		pACB->TmpSRB.SegmentX =
+		    ptr + (i * DC395x_MAX_SG_LISTENTRY);
+	else
+		printk(DC395X_NAME
+		       ": No space for tmpSRB SG table reserved?!\n");
+	return 0;
+}
+
+
+/*
+ ********************************************************************
+ * scsiio
+ *		DC395x_initACB
+ ********************************************************************
+ */
+void __init DC395x_linkSRB(struct AdapterCtlBlk *pACB)
+{
+	int i;
+
+	for (i = 0; i < pACB->SRBCount - 1; i++)
+		pACB->SRB_array[i].pNextSRB = &pACB->SRB_array[i + 1];
+	pACB->SRB_array[i].pNextSRB = NULL;
+	/*DC395x_Free_integrity (pACB);     */
+}
+
+
+/*
+ ***********************************************************************
+ *		DC395x_init
+ *
+ * Function : static void DC395x_initACB
+ *  Purpose :  initialize the internal structures for a given SCSI host
+ *   Inputs : host - pointer to this host adapter's structure
+ ***********************************************************************
+ */
+int __init
+DC395x_initACB(struct Scsi_Host *host, u32 io_port, u8 irq, u16 index)
+{
+	struct NvRamType *eeprom;
+	struct AdapterCtlBlk *pACB;
+	u16 i;
+
+	eeprom = &dc395x_trm_eepromBuf[index];
+	host->max_cmd_len = 24;
+	host->can_queue = DC395x_MAX_CMD_QUEUE;
+	host->cmd_per_lun = DC395x_MAX_CMD_PER_LUN;
+	host->this_id = (int) eeprom->NvramScsiId;
+	host->io_port = io_port;
+	host->n_io_port = 0x80;
+	host->dma_channel = -1;
+	host->unique_id = io_port;
+	host->irq = irq;
+	host->last_reset = jiffies;
+
+	pACB = (struct AdapterCtlBlk *) host->hostdata;
+
+	host->max_id = 16;
+	if (host->max_id - 1 == eeprom->NvramScsiId)
+		host->max_id--;
+#ifdef	CONFIG_SCSI_MULTI_LUN
+	if (eeprom->NvramChannelCfg & NAC_SCANLUN)
+		host->max_lun = 8;
+	else
+		host->max_lun = 1;
+#else
+	host->max_lun = 1;
+#endif
+	/*
+	 ********************************
+	 */
+	pACB->pScsiHost = host;
+	pACB->IOPortBase = (u16) io_port;
+	pACB->pLinkDCB = NULL;
+	pACB->pDCBRunRobin = NULL;
+	pACB->pActiveDCB = NULL;
+	pACB->SRBCount = DC395x_MAX_SRB_CNT;
+	pACB->AdapterIndex = index;
+	pACB->status = 0;
+	pACB->pScsiHost->this_id = eeprom->NvramScsiId;
+	pACB->HostID_Bit = (1 << pACB->pScsiHost->this_id);
+	/*pACB->pScsiHost->this_lun = 0; */
+	pACB->DCBCnt = 0;
+	pACB->DeviceCnt = 0;
+	pACB->IRQLevel = irq;
+	pACB->TagMaxNum = 1 << eeprom->NvramMaxTag;
+	if (pACB->TagMaxNum > 30)
+		pACB->TagMaxNum = 30;
+	pACB->ACBFlag = 0;	/* RESET_DETECT, RESET_DONE, RESET_DEV */
+	pACB->scan_devices = 1;
+	pACB->MsgLen = 0;
+	pACB->Gmode2 = eeprom->NvramChannelCfg;
+	if (eeprom->NvramChannelCfg & NAC_SCANLUN)
+		pACB->LUNchk = 1;
+	/* 
+	 * link all device's SRB Q of this adapter 
+	 */
+	if (DC395x_alloc_SG_tables(pACB)) {
+		printk(DC395X_NAME ": SG table allocation failed!\n");
+		return 1;
+	}
+#ifdef DC395x_DEBUGTRACE
+	if (DC395x_alloc_tracebufs(pACB)) {
+		printk(DC395X_NAME
+		       ": SG trace buffer allocation failed!\n");
+		DC395x_free_SG_tables(pACB, DC395x_MAX_SRB_CNT);
+		return 1;
+	}
+#endif
+	DC395x_linkSRB(pACB);
+	pACB->pFreeSRB = pACB->SRB_array;
+	/* 
+	 * temp SRB for Q tag used or abort command used 
+	 */
+	pACB->pTmpSRB = &pACB->TmpSRB;
+	pACB->TmpSRB.pSRBDCB = 0;
+	pACB->TmpSRB.pNextSRB = 0;
+	init_timer(&pACB->Waiting_Timer);
+
+	for (i = 0; i < DC395x_MAX_SCSI_ID; i++)
+		pACB->DCBmap[i] = 0;
+#ifdef DC395x_DEBUG0
+	printk(KERN_INFO DC395X_NAME
+	       ": pACB = %p, pDCBmap = %p, pSRB_array = %p\n", pACB,
+	       pACB->DCBmap, pACB->SRB_array);
+	printk(KERN_INFO DC395X_NAME
+	       ": ACB size= %04lx, DCB size= %04lx, SRB size= %04lx\n",
+	       sizeof(struct AdapterCtlBlk), sizeof(struct DeviceCtlBlk),
+	       sizeof(struct ScsiReqBlk));
+#endif
+	return 0;
+}
+
+
+/*===========================================================================
+                                Init
+  ===========================================================================*/
+/*
+ * Intialise the SCSI chip control registers
+ *
+ * @param host     This hosts adapter strcuture
+ * @param io_port  The base I/O port
+ * @param irq      IRQ
+ * @param index    Card number?? (for multiple cards?)
+ */
+static int __init
+DC395x_initAdapter(struct Scsi_Host *host, u32 io_port, u8 irq, u16 index)
+{
+	struct NvRamType *eeprom;
+	struct AdapterCtlBlk *pACB;
+	struct AdapterCtlBlk *pTempACB;
+	u16 used_irq = 0;
+
+	eeprom = &dc395x_trm_eepromBuf[index];
+	pTempACB = DC395x_pACB_start;
+	if (pTempACB != NULL) {
+		for (; (pTempACB != (struct AdapterCtlBlk *) -1);) {
+			if (pTempACB->IRQLevel == irq) {
+				used_irq = 1;
+				break;
+			} else
+				pTempACB = pTempACB->pNextACB;
+		}
+	}
+
+	if (!request_region(io_port, host->n_io_port, DC395X_NAME)) {
+		printk(KERN_ERR DC395X_NAME
+		       ": Failed to reserve IO region 0x%x\n", io_port);
+		return -1;
+	}
+	if (!used_irq) {
+		if (request_irq
+		    (irq, DC395x_Interrupt, SA_SHIRQ, DC395X_NAME,
+		     (void *) host->hostdata)) {
+			printk(KERN_INFO DC395X_NAME
+			       ": Failed to register IRQ!\n");
+			return -1;
+		}
+	}
+
+	pACB = (struct AdapterCtlBlk *) host->hostdata;
+	pACB->IOPortBase = io_port;
+
+	/* selection timeout = 250 ms */
+	pACB->sel_timeout = DC395x_SEL_TIMEOUT;
+
+	/* Mask all the interrupt */
+	DC395x_write8(TRM_S1040_DMA_INTEN, 0x00);
+	DC395x_write8(TRM_S1040_SCSI_INTEN, 0x00);
+
+	/* Reset SCSI module */
+	DC395x_write16(TRM_S1040_SCSI_CONTROL, DO_RSTMODULE);
+
+	/* Reset PCI/DMA module */
+	DC395x_write8(TRM_S1040_DMA_CONTROL, DMARESETMODULE);
+	udelay(20);
+
+	/* program configuration 0 */
+	pACB->Config = HCC_AUTOTERM | HCC_PARITY;
+	if (DC395x_read8(TRM_S1040_GEN_STATUS) & WIDESCSI)
+		pACB->Config |= HCC_WIDE_CARD;
+
+	if (eeprom->NvramChannelCfg & NAC_POWERON_SCSI_RESET)
+		pACB->Config |= HCC_SCSI_RESET;
+
+	if (pACB->Config & HCC_SCSI_RESET) {
+		printk(KERN_INFO DC395X_NAME
+		       ": Performing initial SCSI bus reset\n");
+		DC395x_write8(TRM_S1040_SCSI_CONTROL, DO_RSTSCSI);
+
+		/*while (!( DC395x_read8(TRM_S1040_SCSI_INTSTATUS) & INT_SCSIRESET )); */
+		/*spin_unlock_irq (&io_request_lock); */
+		udelay(500);
+
+		pACB->pScsiHost->last_reset =
+		    jiffies + HZ / 2 +
+		    HZ *
+		    dc395x_trm_eepromBuf[pACB->AdapterIndex].
+		    NvramDelayTime;
+
+		/*spin_lock_irq (&io_request_lock); */
+	}
+	DC395x_basic_config(pACB);
+	return 0;
+}
+
+
+/*
+ * eeprom - wait 30 us
+ *
+ * Waits for 30us (using the chip by the looks of it..)
+ *
+ * @param io_port  - base I/O address
+ */
+static void __init TRM_S1040_wait_30us(u16 io_port)
+{
+	/* ScsiPortStallExecution(30); wait 30 us */
+	outb(5, io_port + TRM_S1040_GEN_TIMER);
+	while (!(inb(io_port + TRM_S1040_GEN_STATUS) & GTIMEOUT))
+		/* nothing */ ;
+	return;
+}
+
+
+/*
+ * eeprom - write command and address to chip
+ *
+ * Write the specified command and address 
+ *
+ * @param io_port - base I/O address
+ * @param cmd     - SB + op code (command) to send
+ * @param addr    - address to send
+ */
+static void __init TRM_S1040_write_cmd(u16 io_port, u8 cmd, u8 addr)
+{
+	int i;
+	u8 send_data;
+
+	/* program SB + OP code */
+	for (i = 0; i < 3; i++, cmd <<= 1) {
+		send_data = NVR_SELECT;
+		if (cmd & 0x04)	/* Start from bit 2 */
+			send_data |= NVR_BITOUT;
+
+		outb(send_data, io_port + TRM_S1040_GEN_NVRAM);
+		TRM_S1040_wait_30us(io_port);
+		outb((send_data | NVR_CLOCK),
+		     io_port + TRM_S1040_GEN_NVRAM);
+		TRM_S1040_wait_30us(io_port);
+	}
+
+	/* send address */
+	for (i = 0; i < 7; i++, addr <<= 1) {
+		send_data = NVR_SELECT;
+		if (addr & 0x40)	/* Start from bit 6 */
+			send_data |= NVR_BITOUT;
+
+		outb(send_data, io_port + TRM_S1040_GEN_NVRAM);
+		TRM_S1040_wait_30us(io_port);
+		outb((send_data | NVR_CLOCK),
+		     io_port + TRM_S1040_GEN_NVRAM);
+		TRM_S1040_wait_30us(io_port);
+	}
+	outb(NVR_SELECT, io_port + TRM_S1040_GEN_NVRAM);
+	TRM_S1040_wait_30us(io_port);
+}
+
+
+/*
+ * eeprom - store a single byte in the SEEPROM
+ *
+ * Called from write all to write a single byte into the SSEEPROM
+ * Which is done one bit at a time.
+ *
+ * @param io_port - base I/O address
+ * @param addr    - offset into EEPROM
+ * @param byte    - bytes to write
+ */
+static void __init TRM_S1040_set_data(u16 io_port, u8 addr, u8 byte)
+{
+	int i;
+	u8 send_data;
+
+	/* Send write command & address */
+	TRM_S1040_write_cmd(io_port, 0x05, addr);
+
+	/* Write data */
+	for (i = 0; i < 8; i++, byte <<= 1) {
+		send_data = NVR_SELECT;
+		if (byte & 0x80)	/* Start from bit 7 */
+			send_data |= NVR_BITOUT;
+
+		outb(send_data, io_port + TRM_S1040_GEN_NVRAM);
+		TRM_S1040_wait_30us(io_port);
+		outb((send_data | NVR_CLOCK),
+		     io_port + TRM_S1040_GEN_NVRAM);
+		TRM_S1040_wait_30us(io_port);
+	}
+	outb(NVR_SELECT, io_port + TRM_S1040_GEN_NVRAM);
+	TRM_S1040_wait_30us(io_port);
+
+	/* Disable chip select */
+	outb(0, io_port + TRM_S1040_GEN_NVRAM);
+	TRM_S1040_wait_30us(io_port);
+
+	outb(NVR_SELECT, io_port + TRM_S1040_GEN_NVRAM);
+	TRM_S1040_wait_30us(io_port);
+
+	/* Wait for write ready */
+	while (1) {
+		outb((NVR_SELECT | NVR_CLOCK),
+		     io_port + TRM_S1040_GEN_NVRAM);
+		TRM_S1040_wait_30us(io_port);
+
+		outb(NVR_SELECT, io_port + TRM_S1040_GEN_NVRAM);
+		TRM_S1040_wait_30us(io_port);
+
+		if (inb(io_port + TRM_S1040_GEN_NVRAM) & NVR_BITIN)
+			break;
+	}
+
+	/*  Disable chip select */
+	outb(0, io_port + TRM_S1040_GEN_NVRAM);
+}
+
+
+/*
+ * eeprom - write 128 bytes to the SEEPROM
+ *
+ * Write the supplied 128 bytes to the chips SEEPROM
+ *
+ * @param eeprom  - the data to write
+ * @param io_port - the base io port
+ */
+static void __init
+TRM_S1040_write_all(struct NvRamType *eeprom, u16 io_port)
+{
+	u8 *b_eeprom = (u8 *) eeprom;
+	u8 addr;
+
+	/* Enable SEEPROM */
+	outb((inb(io_port + TRM_S1040_GEN_CONTROL) | EN_EEPROM),
+	     io_port + TRM_S1040_GEN_CONTROL);
+
+	/* write enable */
+	TRM_S1040_write_cmd(io_port, 0x04, 0xFF);
+	outb(0, io_port + TRM_S1040_GEN_NVRAM);
+	TRM_S1040_wait_30us(io_port);
+
+	/* write */
+	for (addr = 0; addr < 128; addr++, b_eeprom++) {
+		TRM_S1040_set_data(io_port, addr, *b_eeprom);
+	}
+
+	/* write disable */
+	TRM_S1040_write_cmd(io_port, 0x04, 0x00);
+	outb(0, io_port + TRM_S1040_GEN_NVRAM);
+	TRM_S1040_wait_30us(io_port);
+
+	/* Disable SEEPROM */
+	outb((inb(io_port + TRM_S1040_GEN_CONTROL) & ~EN_EEPROM),
+	     io_port + TRM_S1040_GEN_CONTROL);
+}
+
+
+/*
+ * eeprom - get a single byte from the SEEPROM
+ *
+ * Called from read all to read a single byte into the SSEEPROM
+ * Which is done one bit at a time.
+ *
+ * @param io_port  - base I/O address
+ * @param addr     - offset into SEEPROM
+ * @return         - the byte read
+ */
+static u8 __init TRM_S1040_get_data(u16 io_port, u8 addr)
+{
+	int i;
+	u8 read_byte;
+	u8 result = 0;
+
+	/* Send read command & address */
+	TRM_S1040_write_cmd(io_port, 0x06, addr);
+
+	/* read data */
+	for (i = 0; i < 8; i++) {
+		outb((NVR_SELECT | NVR_CLOCK),
+		     io_port + TRM_S1040_GEN_NVRAM);
+		TRM_S1040_wait_30us(io_port);
+		outb(NVR_SELECT, io_port + TRM_S1040_GEN_NVRAM);
+
+		/* Get data bit while falling edge */
+		read_byte = inb(io_port + TRM_S1040_GEN_NVRAM);
+		result <<= 1;
+		if (read_byte & NVR_BITIN)
+			result |= 1;
+
+		TRM_S1040_wait_30us(io_port);
+	}
+
+	/* Disable chip select */
+	outb(0, io_port + TRM_S1040_GEN_NVRAM);
+	return result;
+}
+
+
+/*
+ * eeprom - read_all
+ *
+ * Read the 128 bytes from the SEEPROM.
+ *
+ * @param eeprom - where to store the data
+ * @param io_port - the base io port
+ */
+static void __init
+TRM_S1040_read_all(struct NvRamType *eeprom, u16 io_port)
+{
+	u8 *b_eeprom = (u8 *) eeprom;
+	u8 addr;
+
+	/* Enable SEEPROM */
+	outb((inb(io_port + TRM_S1040_GEN_CONTROL) | EN_EEPROM),
+	     io_port + TRM_S1040_GEN_CONTROL);
+
+	/* read details */
+	for (addr = 0; addr < 128; addr++, b_eeprom++) {
+		*b_eeprom = TRM_S1040_get_data(io_port, addr);
+	}
+
+	/* Disable SEEPROM */
+	outb((inb(io_port + TRM_S1040_GEN_CONTROL) & ~EN_EEPROM),
+	     io_port + TRM_S1040_GEN_CONTROL);
+}
+
+
+
+/*
+ * eeprom - get and check contents
+ *
+ * Read seeprom 128 bytes into the memory provider in eeprom.
+ * Checks the checksum and if it's not correct it uses a set of default
+ * values.
+ *
+ * @param eeprom  - caller allocated strcuture to read the eeprom data into
+ * @param io_port - io port to read from
+ */
+static void __init
+DC395x_check_eeprom(struct NvRamType *eeprom, u16 io_port)
+{
+	u16 *w_eeprom = (u16 *) eeprom;
+	u16 w_addr;
+	u16 cksum;
+	u32 d_addr;
+	u32 *d_eeprom;
+
+	TRM_S1040_read_all(eeprom, io_port);	/* read eeprom */
+
+	cksum = 0;
+	for (w_addr = 0, w_eeprom = (u16 *) eeprom; w_addr < 64;
+	     w_addr++, w_eeprom++)
+		cksum += *w_eeprom;
+	if (cksum != 0x1234) {
+		/*
+		 * Checksum is wrong. 
+		 * Load a set of defaults into the eeprom buffer
+		 */
+		printk(KERN_WARNING DC395X_NAME
+		       ": EEProm checksum error: using default values and options.\n");
+		eeprom->NvramSubVendorID[0] = (u8) PCI_VENDOR_ID_TEKRAM;
+		eeprom->NvramSubVendorID[1] =
+		    (u8) (PCI_VENDOR_ID_TEKRAM >> 8);
+		eeprom->NvramSubSysID[0] =
+		    (u8) PCI_DEVICE_ID_TEKRAM_TRMS1040;
+		eeprom->NvramSubSysID[1] =
+		    (u8) (PCI_DEVICE_ID_TEKRAM_TRMS1040 >> 8);
+		eeprom->NvramSubClass = 0x00;
+		eeprom->NvramVendorID[0] = (u8) PCI_VENDOR_ID_TEKRAM;
+		eeprom->NvramVendorID[1] =
+		    (u8) (PCI_VENDOR_ID_TEKRAM >> 8);
+		eeprom->NvramDeviceID[0] =
+		    (u8) PCI_DEVICE_ID_TEKRAM_TRMS1040;
+		eeprom->NvramDeviceID[1] =
+		    (u8) (PCI_DEVICE_ID_TEKRAM_TRMS1040 >> 8);
+		eeprom->NvramReserved = 0x00;
+
+		for (d_addr = 0, d_eeprom = (u32 *) eeprom->NvramTarget;
+		     d_addr < 16; d_addr++, d_eeprom++)
+			*d_eeprom = 0x00000077;	/* NvmTarCfg3,NvmTarCfg2,NvmTarPeriod,NvmTarCfg0 */
+
+		*d_eeprom++ = 0x04000F07;	/* NvramMaxTag,NvramDelayTime,NvramChannelCfg,NvramScsiId */
+		*d_eeprom++ = 0x00000015;	/* NvramReserved1,NvramBootLun,NvramBootTarget,NvramReserved0 */
+		for (d_addr = 0; d_addr < 12; d_addr++, d_eeprom++)
+			*d_eeprom = 0x00;
+
+		/* Now load defaults (maybe set by boot/module params) */
+		DC395x_check_for_safe_settings();
+		DC395x_fill_with_defaults();
+		DC395x_EEprom_Override(eeprom);
+
+		eeprom->NvramCheckSum = 0x00;
+		for (w_addr = 0, cksum = 0, w_eeprom = (u16 *) eeprom;
+		     w_addr < 63; w_addr++, w_eeprom++)
+			cksum += *w_eeprom;
+
+		*w_eeprom = 0x1234 - cksum;
+		TRM_S1040_write_all(eeprom, io_port);
+		eeprom->NvramDelayTime = dc395x_trm[5];
+	} else {
+		DC395x_check_for_safe_settings();
+		DC395x_interpret_delay(eeprom);
+		DC395x_EEprom_Override(eeprom);
+	}
+}
+
+
+/* 
+ * adapter - print connection and terminiation config
+ *
+ * @param pACB - adapter control block
+ */
+static void __init DC395x_print_config(struct AdapterCtlBlk *pACB)
+{
+	u8 bval;
+
+	bval = DC395x_read8(TRM_S1040_GEN_STATUS);
+	printk(KERN_INFO DC395X_NAME "%c: Connectors: ",
+	       ((bval & WIDESCSI) ? 'W' : ' '));
+	if (!(bval & CON5068))
+		printk("ext%s ", !(bval & EXT68HIGH) ? "68" : "50");
+	if (!(bval & CON68))
+		printk("int68%s ", !(bval & INT68HIGH) ? "" : "(50)");
+	if (!(bval & CON50))
+		printk("int50 ");
+	if ((bval & (CON5068 | CON50 | CON68)) ==
+	    0 /*(CON5068 | CON50 | CON68) */ )
+		printk(" Oops! (All 3?) ");
+	bval = DC395x_read8(TRM_S1040_GEN_CONTROL);
+	printk(" Termination: ");
+	if (bval & DIS_TERM)
+		printk("Disabled\n");
+	else {
+		if (bval & AUTOTERM)
+			printk("Auto ");
+		if (bval & LOW8TERM)
+			printk("Low ");
+		if (bval & UP8TERM)
+			printk("High ");
+		printk("\n");
+	}
+}
+
+
+/*
+ *********************************************************************
+ *			DC395x_detect
+ *
+ *      Function : static int DC395x_init (struct Scsi_Host *host)
+ *       Purpose : initialize the internal structures for a given SCSI host
+ *        Inputs : host - pointer to this host adapter's structure/
+ * Preconditions : when this function is called, the chip_type
+ *		   field of the pACB structure MUST have been set.
+ *********************************************************************
+ */
+static struct Scsi_Host *__init
+DC395x_init(Scsi_Host_Template * host_template, u32 io_port, u8 irq,
+	    u16 index)
+{
+	struct Scsi_Host *host;
+	struct AdapterCtlBlk *pACB;
+
+	/*
+	 * Read the eeprom contents info the buffer we supply. Use
+	 * defaults is eeprom checksum is wrong.
+	 */
+	DC395x_check_eeprom(&dc395x_trm_eepromBuf[index], (u16) io_port);
+
+	/*$$$$$$$$$$$  MEMORY ALLOCATE FOR ADAPTER CONTROL BLOCK $$$$$$$$$$$$ */
+	host = scsi_register(host_template, sizeof(struct AdapterCtlBlk));
+	if (!host) {
+		printk(KERN_INFO DC395X_NAME
+		       " : pSH scsi_register ERROR\n");
+		return 0;
+	}
+	printk(KERN_INFO DC395X_NAME
+	       ": Used settings: AdapterID=%02i, Speed=%i(%02i.%01iMHz), DevMode=0x%02x\n",
+	       dc395x_trm_eepromBuf[index].NvramScsiId,
+	       dc395x_trm_eepromBuf[index].NvramTarget[0].NvmTarPeriod,
+	       dc395x_clock_speed[dc395x_trm_eepromBuf[index].
+				  NvramTarget[0].NvmTarPeriod] / 10,
+	       dc395x_clock_speed[dc395x_trm_eepromBuf[index].
+				  NvramTarget[0].NvmTarPeriod] % 10,
+	       dc395x_trm_eepromBuf[index].NvramTarget[0].NvmTarCfg0);
+	printk(KERN_INFO DC395X_NAME
+	       ":      AdaptMode=0x%02x, Tags=%i(%02i), DelayReset=%is\n",
+	       dc395x_trm_eepromBuf[index].NvramChannelCfg,
+	       dc395x_trm_eepromBuf[index].NvramMaxTag,
+	       1 << dc395x_trm_eepromBuf[index].NvramMaxTag,
+	       dc395x_trm_eepromBuf[index].NvramDelayTime);
+
+	pACB = (struct AdapterCtlBlk *) host->hostdata;
+	/*DC395x_ACB_INITLOCK(pACB); */
+	/*DC395x_ACB_LOCK(pACB,acb_flags); */
+	/*$$$$$$$$ INITIAL ADAPTER CONTROL BLOCK $$$$$$$$$$$$ */
+	if (DC395x_initACB(host, io_port, irq, index)) {
+		scsi_unregister(host);
+		/*DC395x_ACB_UNLOCK(pACB,acb_flags); */
+		return 0;
+	}
+	DC395x_print_config(pACB);
+	/*$$$$$$$$$$$$$$$$$ INITIAL ADAPTER $$$$$$$$$$$$$$$$$ */
+	if (!DC395x_initAdapter(host, io_port, irq, index)) {
+		if (!DC395x_pACB_start) {
+			DC395x_pACB_start = pACB;
+			DC395x_pACB_current = pACB;
+			pACB->pNextACB = (struct AdapterCtlBlk *) -1;
+		} else {
+			DC395x_pACB_current->pNextACB = pACB;
+			DC395x_pACB_current = pACB;
+			pACB->pNextACB = (struct AdapterCtlBlk *) -1;
+		}
+		/*DC395x_ACB_UNLOCK(pACB,acb_flags); */
+		return host;
+	} else {
+		printk(KERN_INFO DC395X_NAME
+		       ": DC395x_initAdapter initial ERROR\n");
+		scsi_unregister(host);
+		/*DC395x_ACB_UNLOCK(pACB,acb_flags); */
+		return 0;
+	}
+}
+
+
+/*
+ * DC395x_detect
+ *
+ * Detect TRM-S1040 cards, acquire resources and initialise the card.
+ * Argument is a pointer to the host driver's scsi_hosts entry.
+ *
+ * Returns the number of adapters found.
+ *
+ * This function is called during system initialization and must not
+ * call SCSI mid-level functions including scsi_malloc() and
+ * scsi_free().
+ */
+static int __init DC395x_detect(Scsi_Host_Template * host_template)
+{
+	struct pci_dev *pdev = NULL;
+	unsigned int io_port;
+	u8 irq;
+	DC395x_pACB_start = NULL;
+
+	/* without PCI we cannot do anything */
+	if (pci_present() == 0) {
+		printk(KERN_INFO DC395X_NAME ": PCI not present\n");
+		return 0;
+	}
+	printk(KERN_INFO DC395X_NAME ": %s %s\n", DC395X_BANNER,
+	       DC395X_VERSION);
+
+	while ((pdev =
+		pci_find_device(PCI_VENDOR_ID_TEKRAM,
+				PCI_DEVICE_ID_TEKRAM_TRMS1040, pdev))) {
+		struct Scsi_Host *scsi_host;
+		if (pci_enable_device(pdev))
+			continue;
+
+		io_port =
+		    pci_resource_start(pdev, 0) & PCI_BASE_ADDRESS_IO_MASK;
+		irq = pdev->irq;
+#ifdef DC395x_DEBUG0
+		printk(KERN_INFO DC395X_NAME ": IO_PORT=%04x,IRQ=%x\n",
+		       (unsigned int) io_port, irq);
+#endif
+		if ((scsi_host =
+		     DC395x_init(host_template, io_port, irq,
+				 DC395x_adapterCnt))) {
+			pci_set_master(pdev);
+			((struct AdapterCtlBlk *) (scsi_host->hostdata))->
+			    pdev = pdev;
+			/*DC395x_set_pci_cfg(pdev); */
+			DC395x_adapterCnt++;
+		}
+	}
+
+	if (DC395x_adapterCnt) {
+		host_template->proc_name = DC395X_NAME;
+	}
+	printk(KERN_INFO DC395X_NAME ": %s: %i adapters found\n",
+	       DC395X_BANNER, DC395x_adapterCnt);
+
+	return DC395x_adapterCnt;
+}
+
+
+/*
+ * Functions: DC395x_inquiry(), DC395x_inquiry_done()
+ *
+ * Purpose: When changing speed etc., we have to issue an INQUIRY
+ *	    command to make sure, we agree upon the nego parameters
+ *	    with the device
+ */
+static void DC395x_inquiry_done(Scsi_Cmnd * cmd)
+{
+	struct AdapterCtlBlk *pACB =
+	    (struct AdapterCtlBlk *) cmd->device->host->hostdata;
+	struct DeviceCtlBlk *pDCB =
+	    DC395x_findDCB(pACB, cmd->device->id, cmd->device->lun);
+#ifdef DC395x_DEBUGTRACE
+	struct ScsiReqBlk *pSRB = pACB->pFreeSRB;
+#endif
+	printk(KERN_INFO DC395X_NAME
+	       ": INQUIRY (%02i-%i) returned %08x: %02x %02x %02x %02x ...\n",
+	       cmd->device->id, cmd->device->lun, cmd->result,
+	       ((u8 *) cmd->request_buffer)[0],
+	       ((u8 *) cmd->request_buffer)[1],
+	       ((u8 *) cmd->request_buffer)[2],
+	       ((u8 *) cmd->request_buffer)[3]);
+	/*TRACEOUT ("%s\n", pSRB->debugtrace); */
+	if (cmd->result) {
+		printk(DC395X_NAME ": Unsetting Wide, Sync and TagQ!\n");
+		if (pDCB) {
+			TRACEOUT("%s\n", pSRB->debugtrace);
+			pDCB->DevMode &=
+			    ~(NTC_DO_SYNC_NEGO | NTC_DO_WIDE_NEGO |
+			      NTC_DO_TAG_QUEUEING);
+			DC395x_updateDCB(pACB, pDCB);
+		}
+	}
+	if (pDCB) {
+		if (!(pDCB->SyncMode & SYNC_NEGO_DONE)) {
+			pDCB->SyncOffset = 0;	/*pDCB->SyncMode &= ~SYNC_NEGO_ENABLE; */
+		}
+		if (!(pDCB->SyncMode & WIDE_NEGO_DONE)) {
+			pDCB->SyncPeriod &= ~WIDE_SYNC;
+			pDCB->SyncMode &= ~WIDE_NEGO_ENABLE;
+		}
+	} else {
+		printk(DC395X_NAME
+		       ": ERROR! No DCB existent for %02i-%i ?\n",
+		       cmd->device->id, cmd->device->lun);
+	}
+	kfree(cmd->buffer);
+	kfree(cmd);
+}
+
+
+/*
+ * Perform INQUIRY
+ */
+void DC395x_inquiry(struct AdapterCtlBlk *pACB, struct DeviceCtlBlk *pDCB)
+{
+	char *buffer;
+	Scsi_Cmnd *cmd;
+	cmd = KMALLOC(sizeof(Scsi_Cmnd), GFP_ATOMIC);
+	if (!cmd) {
+		printk(DC395X_NAME ": kmalloc failed in inquiry!\n");
+		return;
+	}
+	buffer = kmalloc(256, GFP_ATOMIC);
+	if (!buffer) {
+		kfree(cmd);
+		printk(DC395X_NAME ": kmalloc failed in inquiry!\n");
+		return;
+	}
+
+	memset(cmd, 0, sizeof(Scsi_Cmnd));
+	cmd->cmnd[0] = INQUIRY;
+	cmd->cmnd[1] = (pDCB->TargetLUN << 5) & 0xe0;
+	cmd->cmnd[4] = 0xff;
+
+	cmd->cmd_len = 6;
+	cmd->old_cmd_len = 6;
+	cmd->device->host = pACB->pScsiHost;
+	cmd->device->id = pDCB->TargetID;
+	cmd->device->lun = pDCB->TargetLUN;
+	cmd->serial_number = 1;
+	cmd->pid = 395;
+	cmd->bufflen = 128;
+	cmd->buffer = buffer;
+	cmd->request_bufflen = 128;
+	cmd->request_buffer = &buffer[128];
+	cmd->done = DC395x_inquiry_done;
+	cmd->scsi_done = DC395x_inquiry_done;
+	cmd->timeout_per_command = HZ;
+
+#if 0
+	/* XXX */
+	cmd->request.rq_status = RQ_SCSI_BUSY;
+#endif
+
+	pDCB->SyncMode &= ~SYNC_NEGO_DONE;
+	pDCB->SyncMode |= SYNC_NEGO_ENABLE;
+	pDCB->SyncMode &= ~WIDE_NEGO_DONE;
+	pDCB->SyncMode |= WIDE_NEGO_ENABLE;
+	printk(KERN_INFO DC395X_NAME
+	       ": Queue INQUIRY command to dev %02i-%i\n", pDCB->TargetID,
+	       pDCB->TargetLUN);
+	DC395x_queue_command(cmd, DC395x_inquiry_done);
+}
+
+#undef SEARCH
+#undef YESNO
+#undef SCANF
+
+
+/*
+ ******************************************************************
+ * Function: DC395x_proc_info(char* buffer, char **start,
+ *			 off_t offset, int length, int hostno, int inout)
+ *  Purpose: return SCSI Adapter/Device Info
+ *    Input:
+ *          buffer: Pointer to a buffer where to write info
+ *		 start :
+ *		 offset:
+ *		 hostno: Host adapter index
+ *		 inout : Read (=0) or set(!=0) info
+ *   Output:
+ *          buffer: contains info length 
+ *		         
+ *    return value: length of info in buffer
+ *
+ ******************************************************************
+ */
+
+/* KG: proc_info taken from driver aha152x.c */
+
+#undef SPRINTF
+#define SPRINTF(args...) pos += sprintf(pos, args)
+
+#define YESNO(YN) \
+ if (YN) SPRINTF(" Yes ");\
+ else SPRINTF(" No  ")
+
+static int
+DC395x_proc_info(char *buffer, char **start, off_t offset, int length,
+		 int hostno, int inout)
+{
+	int dev, spd, spd1;
+	char *pos = buffer;
+	struct Scsi_Host *shpnt = NULL;
+	struct AdapterCtlBlk *pACB;
+	struct DeviceCtlBlk *pDCB;
+	unsigned long flags;
+	Scsi_Cmnd *pcmd;
+
+	/*  Scsi_Cmnd *ptr; */
+
+	pACB = DC395x_pACB_start;
+
+	while (pACB != (struct AdapterCtlBlk *) -1) {
+		shpnt = pACB->pScsiHost;
+		if (shpnt->host_no == hostno)
+			break;
+		pACB = pACB->pNextACB;
+	}
+	if (pACB == (struct AdapterCtlBlk *) -1)
+		return -ESRCH;
+
+	if (!shpnt)
+		return -ESRCH;
+
+	if (inout)		/* Has data been written to the file ? */
+		return -EPERM;
+
+	SPRINTF(DC395X_BANNER " PCI SCSI Host Adapter\n");
+	SPRINTF(" Driver Version " DC395X_VERSION "\n");
+
+	DC395x_LOCK_IO(pACB->pScsiHost);
+
+	SPRINTF("SCSI Host Nr %i, ", shpnt->host_no);
+	SPRINTF("DC395U/UW/F DC315/U %s Adapter Nr %i\n",
+		(pACB->Config & HCC_WIDE_CARD) ? "Wide" : "",
+		pACB->AdapterIndex);
+	SPRINTF("IOPortBase 0x%04x, ", pACB->IOPortBase);
+	SPRINTF("IRQLevel 0x%02x, ", pACB->IRQLevel);
+	SPRINTF(" SelTimeout %ims\n", (1638 * pACB->sel_timeout) / 1000);
+
+	SPRINTF("MaxID %i, MaxLUN %i, ", shpnt->max_id, shpnt->max_lun);
+	SPRINTF("AdapterID %i\n", shpnt->this_id);
+
+	SPRINTF("TagMaxNum %i, Status %i", pACB->TagMaxNum, pACB->status);
+	/*SPRINTF(", DMA_Status %i\n", DC395x_read8(TRM_S1040_DMA_STATUS)); */
+	SPRINTF(", FilterCfg 0x%02x",
+		DC395x_read8(TRM_S1040_SCSI_CONFIG1));
+	SPRINTF(", DelayReset %is\n",
+		dc395x_trm_eepromBuf[pACB->AdapterIndex].NvramDelayTime);
+	/*SPRINTF("\n"); */
+
+	SPRINTF("Nr of attached devices: %i, Nr of DCBs: %i\n",
+		pACB->DeviceCnt, pACB->DCBCnt);
+	SPRINTF
+	    ("Map of attached LUNs: %02x %02x %02x %02x %02x %02x %02x %02x\n",
+	     pACB->DCBmap[0], pACB->DCBmap[1], pACB->DCBmap[2],
+	     pACB->DCBmap[3], pACB->DCBmap[4], pACB->DCBmap[5],
+	     pACB->DCBmap[6], pACB->DCBmap[7]);
+	SPRINTF
+	    ("                      %02x %02x %02x %02x %02x %02x %02x %02x\n",
+	     pACB->DCBmap[8], pACB->DCBmap[9], pACB->DCBmap[10],
+	     pACB->DCBmap[11], pACB->DCBmap[12], pACB->DCBmap[13],
+	     pACB->DCBmap[14], pACB->DCBmap[15]);
+
+	SPRINTF
+	    ("Un ID LUN Prty Sync Wide DsCn SndS TagQ NegoPeriod SyncFreq SyncOffs MaxCmd\n");
+
+	pDCB = pACB->pLinkDCB;
+	for (dev = 0; dev < pACB->DCBCnt; dev++) {
+		int NegoPeriod;
+		SPRINTF("%02i %02i  %02i ", dev, pDCB->TargetID,
+			pDCB->TargetLUN);
+		YESNO(pDCB->DevMode & NTC_DO_PARITY_CHK);
+		YESNO(pDCB->SyncOffset);
+		YESNO(pDCB->SyncPeriod & WIDE_SYNC);
+		YESNO(pDCB->DevMode & NTC_DO_DISCONNECT);
+		YESNO(pDCB->DevMode & NTC_DO_SEND_START);
+		YESNO(pDCB->SyncMode & EN_TAG_QUEUEING);
+		NegoPeriod =
+		    dc395x_clock_period[pDCB->SyncPeriod & 0x07] << 2;
+		if (pDCB->SyncOffset)
+			SPRINTF("  %03i ns ", NegoPeriod);
+		else
+			SPRINTF(" (%03i ns)", (pDCB->MinNegoPeriod << 2));
+
+		if (pDCB->SyncOffset & 0x0f) {
+			spd = 1000 / (NegoPeriod);
+			spd1 = 1000 % (NegoPeriod);
+			spd1 = (spd1 * 10 + NegoPeriod / 2) / (NegoPeriod);
+			SPRINTF("   %2i.%1i M     %02i ", spd, spd1,
+				(pDCB->SyncOffset & 0x0f));
+		} else
+			SPRINTF("                 ");
+
+		/* Add more info ... */
+		SPRINTF("     %02i\n", pDCB->MaxCommand);
+		pDCB = pDCB->pNextDCB;
+	}
+
+	SPRINTF("Commands in Queues: Query: %i:", pACB->QueryCnt);
+	for (pcmd = pACB->pQueryHead; pcmd;
+	     pcmd = (Scsi_Cmnd *) pcmd->host_scribble)
+		SPRINTF(" %li", pcmd->pid);
+	if (timer_pending(&pACB->Waiting_Timer))
+		SPRINTF("Waiting queue timer running\n");
+	else
+		SPRINTF("\n");
+	pDCB = pACB->pLinkDCB;
+
+	for (dev = 0; dev < pACB->DCBCnt; dev++) {
+		struct ScsiReqBlk *pSRB;
+		if (pDCB->WaitSRBCnt)
+			SPRINTF("DCB (%02i-%i): Waiting: %i:",
+				pDCB->TargetID, pDCB->TargetLUN,
+				pDCB->WaitSRBCnt);
+		for (pSRB = pDCB->pWaitingSRB; pSRB; pSRB = pSRB->pNextSRB)
+			SPRINTF(" %li", pSRB->pcmd->pid);
+		if (pDCB->GoingSRBCnt)
+			SPRINTF("\nDCB (%02i-%i): Going  : %i:",
+				pDCB->TargetID, pDCB->TargetLUN,
+				pDCB->GoingSRBCnt);
+		for (pSRB = pDCB->pGoingSRB; pSRB; pSRB = pSRB->pNextSRB)
+#ifdef DC395x_DEBUGTRACE
+			SPRINTF("\n  %s", pSRB->debugtrace);
+#else
+			SPRINTF(" %li", pSRB->pcmd->pid);
+#endif
+		if (pDCB->WaitSRBCnt || pDCB->GoingSRBCnt)
+			SPRINTF("\n");
+		pDCB = pDCB->pNextDCB;
+	}
+
+#ifdef DC395x_DEBUGDCB
+	SPRINTF("DCB list for ACB %p:\n", pACB);
+	pDCB = pACB->pLinkDCB;
+	SPRINTF("%p", pDCB);
+	for (dev = 0; dev < pACB->DCBCnt; dev++, pDCB = pDCB->pNextDCB)
+		SPRINTF("->%p", pDCB->pNextDCB);
+	SPRINTF("\n");
+#endif
+
+	*start = buffer + offset;
+	DC395x_UNLOCK_IO(pACB->pScsiHost);
+
+	if (pos - buffer < offset)
+		return 0;
+	else if (pos - buffer - offset < length)
+		return pos - buffer - offset;
+	else
+		return length;
+}
+
+
+/*
+ * Function : int DC395x_shutdown (struct Scsi_Host *host)
+ *  Purpose : does a clean (we hope) shutdown of the SCSI chip.
+ *		Use prior to dumping core, unloading the driver, etc.
+ *  Returns : 0 on success
+ */
+int DC395x_shutdown(struct Scsi_Host *host)
+{
+	struct AdapterCtlBlk *pACB;
+	pACB = (struct AdapterCtlBlk *) (host->hostdata);
+
+	/* pACB->soft_reset(host); */
+
+	/* disable interrupt */
+	DC395x_write8(TRM_S1040_DMA_INTEN, 0);
+	DC395x_write8(TRM_S1040_SCSI_INTEN, 0);
+	if (timer_pending(&pACB->Waiting_Timer))
+		del_timer(&pACB->Waiting_Timer);
+	if (timer_pending(&pACB->SelTO_Timer))
+		del_timer(&pACB->SelTO_Timer);
+
+	if (1 || pACB->Config & HCC_SCSI_RESET)
+		DC395x_ResetSCSIBus(pACB);
+
+	DC395x_read8(TRM_S1040_SCSI_INTSTATUS);
+#ifdef DC395x_DEBUGTRACE
+	DC395x_free_tracebufs(pACB, DC395x_MAX_SRB_CNT);
+#endif
+	DC395x_free_SG_tables(pACB, DC395x_MAX_SRB_CNT);
+	return 0;
+}
+
+
+/*
+ * Free all DCBs
+ */
+void DC395x_freeDCBs(struct Scsi_Host *host)
+{
+	struct DeviceCtlBlk *pDCB;
+	struct DeviceCtlBlk *nDCB;
+	struct AdapterCtlBlk *pACB =
+	    (struct AdapterCtlBlk *) (host->hostdata);
+
+	DCBDEBUG(printk
+		 (KERN_INFO DC395X_NAME ": Free %i DCBs\n", pACB->DCBCnt);
+	    )
+	    pDCB = pACB->pLinkDCB;
+	if (pDCB) {
+		do {
+			nDCB = pDCB->pNextDCB;
+			DCBDEBUG(printk
+				 (KERN_INFO DC395X_NAME
+				  ": Free DCB (ID %i, LUN %i): %p\n",
+				  pDCB->TargetID, pDCB->TargetLUN, pDCB);
+			    )
+			    DC395x_remove_dev(pACB, pDCB);	/* includes a KFREE(pDCB); */
+			printk(".");
+			pDCB = nDCB;
+		} while (pDCB && pACB->pLinkDCB);
+	}
+}
+
+
+/*
+ * Release method
+ *
+ * Called when we are to shutdown the controller and release all of
+ * it's resources.
+ */
+static int DC395x_release(struct Scsi_Host *host)
+{
+	struct AdapterCtlBlk *pACB =
+	    (struct AdapterCtlBlk *) (host->hostdata);
+	unsigned long flags;
+
+	printk(DC395X_NAME ": release");
+
+	DC395x_LOCK_IO(pACB->pScsiHost);
+	DC395x_shutdown(host);
+	DC395x_freeDCBs(host);
+
+	if (host->irq != NO_IRQ) {
+		/*
+		 * Find the IRQ to release. XXX Why didn't we just store the
+		 * appropriate IRQ details when we request_irq it?
+		 */
+		int irq_count;
+		for (irq_count = 0, pACB = DC395x_pACB_start;
+		     pACB != (struct AdapterCtlBlk *) -1;
+		     pACB = pACB->pNextACB) {
+			if (pACB->IRQLevel == host->irq)
+				++irq_count;
+		}
+		if (irq_count == 1)
+			free_irq(host->irq, DC395x_pACB_start);
+	}
+	release_region(host->io_port, host->n_io_port);
+
+	DC395x_UNLOCK_IO(pACB->pScsiHost);
+
+	return 1;
+}
+
+
+/*
+ * SCSI host template
+ */
+static Scsi_Host_Template driver_template = {
+	.proc_name = DC395X_NAME,
+	.proc_info = DC395x_proc_info,
+	.name = DC395X_BANNER " " DC395X_VERSION,
+	.detect = DC395x_detect,
+	.release = DC395x_release,
+	.queuecommand = DC395x_queue_command,
+	.bios_param = DC395x_bios_param,
+	.slave_alloc = DC395x_slave_alloc,
+	.slave_destroy = DC395x_slave_destroy,
+	.can_queue = DC395x_MAX_CAN_QUEUE,
+	.this_id = 7,
+	.sg_tablesize = DC395x_MAX_SG_TABLESIZE,
+	.cmd_per_lun = DC395x_MAX_CMD_PER_LUN,
+	.eh_abort_handler = DC395x_eh_abort,
+	.eh_bus_reset_handler = DC395x_eh_bus_reset,
+	.unchecked_isa_dma = 0,
+	.use_clustering = DISABLE_CLUSTERING,
+};
+/*
+ * The following code deals with registering the above scsi host
+ * template with the higher level scsi code and results in the detect
+ * method from the template being called during initialisation.
+ */
+#include "scsi_module.c"
diff -Nru a/drivers/scsi/dc395x.h b/drivers/scsi/dc395x.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/scsi/dc395x.h	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,659 @@
+/************************************************************************/
+/*									*/
+/*	dc395x.h							*/
+/*									*/
+/*	Device Driver for Tekram DC395(U/UW/F), DC315(U)		*/
+/*	PCI SCSI Bus Master Host Adapter				*/
+/*	(SCSI chip set used Tekram ASIC TRM-S1040)			*/
+/*									*/
+/************************************************************************/
+
+#ifndef DC395x_H
+#define DC395x_H
+
+/************************************************************************/
+/*									*/
+/*	Name, Banner and Version					*/
+/*									*/
+/************************************************************************/
+#define DC395X_NAME			"dc395x"
+#define DC395X_BANNER			"Tekram DC395(U/UW/F), DC315(U) - ASIC TRM-S1040"
+#define DC395X_VERSION			"v2.02, 2003/04/20"
+
+/************************************************************************/
+/*									*/
+/*	Initial values							*/
+/*									*/
+/************************************************************************/
+#define DC395x_MAX_CMD_QUEUE		32
+/* #define DC395x_MAX_QTAGS		32 */
+#define DC395x_MAX_QTAGS		16
+#define DC395x_MAX_ADAPTER_NUM		4
+#define DC395x_MAX_SCSI_ID		16
+#define DC395x_MAX_CMD_PER_LUN		DC395x_MAX_QTAGS
+#define DC395x_MAX_SG_TABLESIZE		64	/* HW limitation			*/
+#define DC395x_MAX_SG_LISTENTRY		64	/* Must be equal or lower to previous	*/
+						/* item					*/
+#define DC395x_MAX_SRB_CNT		63
+/* #define DC395x_MAX_CAN_QUEUE		7 * DC395x_MAX_QTAGS */
+#define DC395x_MAX_CAN_QUEUE		DC395x_MAX_SRB_CNT
+#define DC395x_END_SCAN			2
+#define DC395x_SEL_TIMEOUT		153	/* 250 ms selection timeout (@ 40 MHz)	*/
+#define DC395x_MAX_RETRIES		3
+
+#if 0
+#define SYNC_FIRST
+#endif
+
+#define NORM_REC_LVL			0
+
+/************************************************************************/
+/*									*/
+/*	Various definitions						*/
+/*									*/
+/************************************************************************/
+#define BIT31				0x80000000
+#define BIT30				0x40000000
+#define BIT29				0x20000000
+#define BIT28				0x10000000
+#define BIT27				0x08000000
+#define BIT26				0x04000000
+#define BIT25				0x02000000
+#define BIT24				0x01000000
+#define BIT23				0x00800000
+#define BIT22				0x00400000
+#define BIT21				0x00200000
+#define BIT20				0x00100000
+#define BIT19				0x00080000
+#define BIT18				0x00040000
+#define BIT17				0x00020000
+#define BIT16				0x00010000
+#define BIT15				0x00008000
+#define BIT14				0x00004000
+#define BIT13				0x00002000
+#define BIT12				0x00001000
+#define BIT11				0x00000800
+#define BIT10				0x00000400
+#define BIT9				0x00000200
+#define BIT8				0x00000100
+#define BIT7				0x00000080
+#define BIT6				0x00000040
+#define BIT5				0x00000020
+#define BIT4				0x00000010
+#define BIT3				0x00000008
+#define BIT2				0x00000004
+#define BIT1				0x00000002
+#define BIT0				0x00000001
+
+/* UnitCtrlFlag */
+#define UNIT_ALLOCATED			BIT0
+#define UNIT_INFO_CHANGED		BIT1
+#define FORMATING_MEDIA			BIT2
+#define UNIT_RETRY			BIT3
+
+/* UnitFlags */
+#define DASD_SUPPORT			BIT0
+#define SCSI_SUPPORT			BIT1
+#define ASPI_SUPPORT			BIT2
+
+/* SRBState machine definition */
+#define SRB_FREE			0x0000
+#define SRB_WAIT			0x0001
+#define SRB_READY			0x0002
+#define SRB_MSGOUT			0x0004	/* arbitration+msg_out 1st byte		*/
+#define SRB_MSGIN			0x0008
+#define SRB_EXTEND_MSGIN		0x0010
+#define SRB_COMMAND			0x0020
+#define SRB_START_			0x0040	/* arbitration+msg_out+command_out	*/
+#define SRB_DISCONNECT			0x0080
+#define SRB_DATA_XFER			0x0100
+#define SRB_XFERPAD			0x0200
+#define SRB_STATUS			0x0400
+#define SRB_COMPLETED			0x0800
+#define SRB_ABORT_SENT			0x1000
+#define SRB_DO_SYNC_NEGO		0x2000
+#define SRB_DO_WIDE_NEGO		0x4000
+#define SRB_UNEXPECT_RESEL		0x8000
+
+/************************************************************************/
+/*									*/
+/*	ACB Config							*/
+/*									*/
+/************************************************************************/
+#define HCC_WIDE_CARD			0x20
+#define HCC_SCSI_RESET			0x10
+#define HCC_PARITY			0x08
+#define HCC_AUTOTERM			0x04
+#define HCC_LOW8TERM			0x02
+#define HCC_UP8TERM			0x01
+
+/* ACBFlag */
+#define RESET_DEV			BIT0
+#define RESET_DETECT			BIT1
+#define RESET_DONE			BIT2
+
+/* DCBFlag */
+#define ABORT_DEV_			BIT0
+
+/* SRBstatus */
+#define SRB_OK				BIT0
+#define ABORTION			BIT1
+#define OVER_RUN			BIT2
+#define UNDER_RUN			BIT3
+#define PARITY_ERROR			BIT4
+#define SRB_ERROR			BIT5
+
+/* SRBFlag */
+#define DATAOUT				BIT7
+#define DATAIN				BIT6
+#define RESIDUAL_VALID			BIT5
+#define ENABLE_TIMER			BIT4
+#define RESET_DEV0			BIT2
+#define ABORT_DEV			BIT1
+#define AUTO_REQSENSE			BIT0
+
+/* Adapter status */
+#define H_STATUS_GOOD			0
+#define H_SEL_TIMEOUT			0x11
+#define H_OVER_UNDER_RUN		0x12
+#define H_UNEXP_BUS_FREE		0x13
+#define H_TARGET_PHASE_F		0x14
+#define H_INVALID_CCB_OP		0x16
+#define H_LINK_CCB_BAD			0x17
+#define H_BAD_TARGET_DIR		0x18
+#define H_DUPLICATE_CCB			0x19
+#define H_BAD_CCB_OR_SG			0x1A
+#define H_ABORT				0x0FF
+
+/* SCSI BUS Status byte codes */
+#define SCSI_STAT_GOOD			0x0	/* Good status				*/
+#define SCSI_STAT_CHECKCOND		0x02	/* SCSI Check Condition			*/
+#define SCSI_STAT_CONDMET		0x04	/* Condition Met			*/
+#define SCSI_STAT_BUSY			0x08	/* Target busy status			*/
+#define SCSI_STAT_INTER			0x10	/* Intermediate status			*/
+#define SCSI_STAT_INTERCONDMET		0x14	/* Intermediate condition met		*/
+#define SCSI_STAT_RESCONFLICT		0x18	/* Reservation conflict			*/
+#define SCSI_STAT_CMDTERM		0x22	/* Command Terminated			*/
+#define SCSI_STAT_QUEUEFULL		0x28	/* Queue Full				*/
+#define SCSI_STAT_UNEXP_BUS_F		0xFD	/* Unexpect Bus Free			*/
+#define SCSI_STAT_BUS_RST_DETECT	0xFE	/* Scsi Bus Reset detected		*/
+#define SCSI_STAT_SEL_TIMEOUT		0xFF	/* Selection Time out			*/
+
+/* Sync_Mode */
+#define SYNC_WIDE_TAG_ATNT_DISABLE	0
+#define SYNC_NEGO_ENABLE		BIT0
+#define SYNC_NEGO_DONE			BIT1
+#define WIDE_NEGO_ENABLE		BIT2
+#define WIDE_NEGO_DONE			BIT3
+#define WIDE_NEGO_STATE			BIT4
+#define EN_TAG_QUEUEING			BIT5
+#define EN_ATN_STOP			BIT6
+
+#define SYNC_NEGO_OFFSET		15
+
+/* SCSI MSG BYTE */
+#define MSG_COMPLETE			0x00
+#define MSG_EXTENDED			0x01
+#define MSG_SAVE_PTR			0x02
+#define MSG_RESTORE_PTR			0x03
+#define MSG_DISCONNECT			0x04
+#define MSG_INITIATOR_ERROR		0x05
+#define MSG_ABORT			0x06
+#define MSG_REJECT_			0x07
+#define MSG_NOP				0x08
+#define MSG_PARITY_ERROR		0x09
+#define MSG_LINK_CMD_COMPL		0x0A
+#define MSG_LINK_CMD_COMPL_FLG		0x0B
+#define MSG_BUS_RESET			0x0C
+#define MSG_ABORT_TAG			0x0D
+#define MSG_SIMPLE_QTAG			0x20
+#define MSG_HEAD_QTAG			0x21
+#define MSG_ORDER_QTAG			0x22
+#define MSG_IGNOREWIDE			0x23
+#define MSG_IDENTIFY			0x80
+#define MSG_HOST_ID			0xC0
+
+/* SCSI STATUS BYTE */
+#define STATUS_GOOD			0x00
+#define CHECK_CONDITION_		0x02
+#define STATUS_BUSY			0x08
+#define STATUS_INTERMEDIATE		0x10
+#define RESERVE_CONFLICT		0x18
+
+/* cmd->result */
+#define STATUS_MASK_			0xFF
+#define MSG_MASK			0xFF00
+#define RETURN_MASK			0xFF0000
+
+/************************************************************************/
+/*									*/
+/*	Inquiry Data format						*/
+/*									*/
+/************************************************************************/
+struct ScsiInqData
+{						/* INQ					*/
+	u8 DevType;				/* Periph Qualifier & Periph Dev Type	*/
+	u8 RMB_TypeMod;				/* rem media bit & Dev Type Modifier	*/
+	u8 Vers;				/* ISO, ECMA, & ANSI versions		*/
+	u8 RDF;					/* AEN, TRMIOP, & response data format	*/
+	u8 AddLen;				/* length of additional data		*/
+	u8 Res1;				/* reserved				*/
+	u8 Res2;				/* reserved				*/
+	u8 Flags;				/* RelADr, Wbus32, Wbus16, Sync, etc.	*/
+	u8 VendorID[8];				/* Vendor Identification		*/
+	u8 ProductID[16];			/* Product Identification		*/
+	u8 ProductRev[4];			/* Product Revision			*/
+};
+
+						/* Inquiry byte 0 masks			*/
+#define SCSI_DEVTYPE			0x1F	/* Peripheral Device Type		*/
+#define SCSI_PERIPHQUAL			0xE0	/* Peripheral Qualifier			*/
+						/* Inquiry byte 1 mask			*/
+#define SCSI_REMOVABLE_MEDIA		0x80	/* Removable Media bit (1=removable)	*/
+						/* Peripheral Device Type definitions	*/
+						/* See include/scsi/scsi.h		*/
+#define TYPE_NODEV		SCSI_DEVTYPE	/* Unknown or no device type		*/
+#ifndef TYPE_PRINTER				/*					*/
+# define TYPE_PRINTER			0x02	/* Printer device			*/
+#endif						/*					*/
+#ifndef TYPE_COMM				/*					*/
+# define TYPE_COMM			0x09	/* Communications device		*/
+#endif
+
+/************************************************************************/
+/*									*/
+/*	Inquiry flag definitions (Inq data byte 7)			*/
+/*									*/
+/************************************************************************/
+#define SCSI_INQ_RELADR			0x80	/* device supports relative addressing	*/
+#define SCSI_INQ_WBUS32			0x40	/* device supports 32 bit data xfers	*/
+#define SCSI_INQ_WBUS16			0x20	/* device supports 16 bit data xfers	*/
+#define SCSI_INQ_SYNC			0x10	/* device supports synchronous xfer	*/
+#define SCSI_INQ_LINKED			0x08	/* device supports linked commands	*/
+#define SCSI_INQ_CMDQUEUE		0x02	/* device supports command queueing	*/
+#define SCSI_INQ_SFTRE			0x01	/* device supports soft resets		*/
+
+#define ENABLE_CE			1
+#define DISABLE_CE			0
+#define EEPROM_READ			0x80
+
+/************************************************************************/
+/*									*/
+/*	The PCI configuration register offset for TRM_S1040		*/
+/*									*/
+/************************************************************************/
+#define TRM_S1040_ID			0x00	/* Vendor and Device ID			*/
+#define TRM_S1040_COMMAND		0x04	/* PCI command register			*/
+#define TRM_S1040_IOBASE		0x10	/* I/O Space base address		*/
+#define TRM_S1040_ROMBASE		0x30	/* Expansion ROM Base Address		*/
+#define TRM_S1040_INTLINE		0x3C	/* Interrupt line			*/
+
+/************************************************************************/
+/*									*/
+/*	The SCSI register offset for TRM_S1040				*/
+/*									*/
+/************************************************************************/
+#define TRM_S1040_SCSI_STATUS		0x80	/* SCSI Status (R)			*/
+#define COMMANDPHASEDONE		0x2000	/* SCSI command phase done		*/
+#define SCSIXFERDONE			0x0800	/* SCSI SCSI transfer done		*/
+#define SCSIXFERCNT_2_ZERO		0x0100	/* SCSI SCSI transfer count to zero	*/
+#define SCSIINTERRUPT			0x0080	/* SCSI interrupt pending		*/
+#define COMMANDABORT			0x0040	/* SCSI command abort			*/
+#define SEQUENCERACTIVE			0x0020	/* SCSI sequencer active		*/
+#define PHASEMISMATCH			0x0010	/* SCSI phase mismatch			*/
+#define PARITYERROR			0x0008	/* SCSI parity error			*/
+
+#define PHASEMASK			0x0007	/* Phase MSG/CD/IO			*/
+#define PH_DATA_OUT			0x00	/* Data out phase			*/
+#define PH_DATA_IN			0x01	/* Data in phase			*/
+#define PH_COMMAND			0x02	/* Command phase			*/
+#define PH_STATUS			0x03	/* Status phase				*/
+#define PH_BUS_FREE			0x05	/* Invalid phase used as bus free	*/
+#define PH_MSG_OUT			0x06	/* Message out phase			*/
+#define PH_MSG_IN			0x07	/* Message in phase			*/
+
+#define TRM_S1040_SCSI_CONTROL		0x80	/* SCSI Control (W)			*/
+#define DO_CLRATN			0x0400	/* Clear ATN				*/
+#define DO_SETATN			0x0200	/* Set ATN				*/
+#define DO_CMDABORT			0x0100	/* Abort SCSI command			*/
+#define DO_RSTMODULE			0x0010	/* Reset SCSI chip			*/
+#define DO_RSTSCSI			0x0008	/* Reset SCSI bus			*/
+#define DO_CLRFIFO			0x0004	/* Clear SCSI transfer FIFO		*/
+#define DO_DATALATCH			0x0002	/* Enable SCSI bus data input (latched)	*/
+/* #define DO_DATALATCH			0x0000 */	/* KG: DISable SCSI bus data latch	*/
+#define DO_HWRESELECT			0x0001	/* Enable hardware reselection		*/
+
+#define TRM_S1040_SCSI_FIFOCNT		0x82	/* SCSI FIFO Counter 5bits(R)		*/
+#define TRM_S1040_SCSI_SIGNAL		0x83	/* SCSI low level signal (R/W)		*/
+
+#define TRM_S1040_SCSI_INTSTATUS	0x84	/* SCSI Interrupt Status (R)		*/
+#define INT_SCAM			0x80	/* SCAM selection interrupt		*/
+#define INT_SELECT			0x40	/* Selection interrupt			*/
+#define INT_SELTIMEOUT			0x20	/* Selection timeout interrupt		*/
+#define INT_DISCONNECT			0x10	/* Bus disconnected interrupt		*/
+#define INT_RESELECTED			0x08	/* Reselected interrupt			*/
+#define INT_SCSIRESET			0x04	/* SCSI reset detected interrupt	*/
+#define INT_BUSSERVICE			0x02	/* Bus service interrupt		*/
+#define INT_CMDDONE			0x01	/* SCSI command done interrupt		*/
+
+#define TRM_S1040_SCSI_OFFSET		0x84	/* SCSI Offset Count (W)		*/
+
+/************************************************************************/
+/*									*/
+/*	Bit		Name		Definition			*/
+/*	---------	-------------	----------------------------	*/
+/*	07-05	0	RSVD		Reversed. Always 0.		*/
+/*	04	0	OFFSET4		Reversed for LVDS. Always 0.	*/
+/*	03-00	0	OFFSET[03:00]	Offset number from 0 to 15	*/
+/*									*/
+/************************************************************************/
+
+#define TRM_S1040_SCSI_SYNC		0x85	/* SCSI Synchronous Control (R/W)	*/
+#define LVDS_SYNC			0x20	/* Enable LVDS synchronous		*/
+#define WIDE_SYNC			0x10	/* Enable WIDE synchronous		*/
+#define ALT_SYNC			0x08	/* Enable Fast-20 alternate synchronous	*/
+
+/************************************************************************/
+/*									*/
+/*	SYNCM	7    6    5    4    3       2       1       0		*/
+/*	Name	RSVD RSVD LVDS WIDE ALTPERD PERIOD2 PERIOD1 PERIOD0	*/
+/*	Default	0    0    0    0    0       0       0       0		*/
+/*									*/
+/*	Bit		Name		Definition			*/
+/*	---------	-------------	---------------------------	*/
+/*	07-06	0	RSVD		Reversed. Always read 0		*/
+/*	05	0	LVDS		Reversed. Always read 0		*/
+/*	04	0	WIDE/WSCSI	Enable wide (16-bits) SCSI	*/
+/*					transfer.			*/
+/*	03	0	ALTPERD/ALTPD	Alternate (Sync./Period) mode.	*/
+/*									*/
+/*			@@ When this bit is set,			*/
+/*			   the synchronous period bits 2:0		*/
+/*			   in the Synchronous Mode register		*/
+/*			   are used to transfer data			*/
+/*			   at the Fast-20 rate.				*/
+/*			@@ When this bit is unset,			*/
+/*			   the synchronous period bits 2:0		*/
+/*			   in the Synchronous Mode Register		*/
+/*			   are used to transfer data			*/
+/*			   at the Fast-10 rate (or Fast-40 w/ LVDS).	*/
+/*									*/
+/*	02-00	0	PERIOD[2:0]/	Synchronous SCSI Transfer Rate.	*/
+/*			SXPD[02:00]	These 3 bits specify		*/
+/*					the Synchronous SCSI Transfer	*/
+/*					Rate for Fast-20 and Fast-10.	*/
+/*					These bits are also reset	*/
+/*					by a SCSI Bus reset.		*/
+/*									*/
+/*	For Fast-10 bit ALTPD = 0 and LVDS = 0				*/
+/*	and bit2,bit1,bit0 is defined as follows :			*/
+/*									*/
+/*	000	100ns, 10.0 MHz						*/
+/*	001	150ns,  6.6 MHz						*/
+/*	010	200ns,  5.0 MHz						*/
+/*	011	250ns,  4.0 MHz						*/
+/*	100	300ns,  3.3 MHz						*/
+/*	101	350ns,  2.8 MHz						*/
+/*	110	400ns,  2.5 MHz						*/
+/*	111	450ns,  2.2 MHz						*/
+/*									*/
+/*	For Fast-20 bit ALTPD = 1 and LVDS = 0				*/
+/*	and bit2,bit1,bit0 is defined as follows :			*/
+/*									*/
+/*	000	 50ns, 20.0 MHz						*/
+/*	001	 75ns, 13.3 MHz						*/
+/*	010	100ns, 10.0 MHz						*/
+/*	011	125ns,  8.0 MHz						*/
+/*	100	150ns,  6.6 MHz						*/
+/*	101	175ns,  5.7 MHz						*/
+/*	110	200ns,  5.0 MHz						*/
+/*	111	250ns,  4.0 MHz   KG: Maybe 225ns, 4.4 MHz		*/
+/*									*/
+/*	For Fast-40 bit ALTPD = 0 and LVDS = 1				*/
+/*	and bit2,bit1,bit0 is defined as follows :			*/
+/*									*/
+/*	000	 25ns, 40.0 MHz						*/
+/*	001	 50ns, 20.0 MHz						*/
+/*	010	 75ns, 13.3 MHz						*/
+/*	011	100ns, 10.0 MHz						*/
+/*	100	125ns,  8.0 MHz						*/
+/*	101	150ns,  6.6 MHz						*/
+/*	110	175ns,  5.7 MHz						*/
+/*	111	200ns,  5.0 MHz						*/
+/*									*/
+/************************************************************************/
+
+#define TRM_S1040_SCSI_TARGETID		0x86	/* SCSI Target ID (R/W)			*/
+#define TRM_S1040_SCSI_IDMSG		0x87	/* SCSI Identify Message (R)		*/
+#define TRM_S1040_SCSI_HOSTID		0x87	/* SCSI Host ID (W)			*/
+#define TRM_S1040_SCSI_COUNTER		0x88	/* SCSI Transfer Counter 24bits(R/W)	*/
+
+#define TRM_S1040_SCSI_INTEN		0x8C	/* SCSI Interrupt Enable (R/W)		*/
+#define EN_SCAM				0x80	/* Enable SCAM selection interrupt	*/
+#define EN_SELECT			0x40	/* Enable selection interrupt		*/
+#define EN_SELTIMEOUT			0x20	/* Enable selection timeout interrupt	*/
+#define EN_DISCONNECT			0x10	/* Enable bus disconnected interrupt	*/
+#define EN_RESELECTED			0x08	/* Enable reselected interrupt		*/
+#define EN_SCSIRESET			0x04	/* Enable SCSI reset detected interrupt	*/
+#define EN_BUSSERVICE			0x02	/* Enable bus service interrupt		*/
+#define EN_CMDDONE			0x01	/* Enable SCSI command done interrupt	*/
+
+#define TRM_S1040_SCSI_CONFIG0		0x8D	/* SCSI Configuration 0 (R/W)		*/
+#define PHASELATCH			0x40	/* Enable phase latch			*/
+#define INITIATOR			0x20	/* Enable initiator mode		*/
+#define PARITYCHECK			0x10	/* Enable parity check			*/
+#define BLOCKRST			0x01	/* Disable SCSI reset1			*/
+
+#define TRM_S1040_SCSI_CONFIG1		0x8E	/* SCSI Configuration 1 (R/W)		*/
+#define ACTIVE_NEGPLUS			0x10	/* Enhance active negation		*/
+#define FILTER_DISABLE			0x08	/* Disable SCSI data filter		*/
+#define FAST_FILTER			0x04	/* ?					*/
+#define ACTIVE_NEG			0x02	/* Enable active negation		*/
+
+#define TRM_S1040_SCSI_CONFIG2		0x8F	/* SCSI Configuration 2 (R/W)		*/
+#define CFG2_WIDEFIFO			0x02	/*					*/
+
+#define TRM_S1040_SCSI_COMMAND		0x90	/* SCSI Command (R/W)			*/
+#define SCMD_COMP			0x12	/* Command complete			*/
+#define SCMD_SEL_ATN			0x60	/* Selection with ATN			*/
+#define SCMD_SEL_ATN3			0x64	/* Selection with ATN3			*/
+#define SCMD_SEL_ATNSTOP		0xB8	/* Selection with ATN and Stop		*/
+#define SCMD_FIFO_OUT			0xC0	/* SCSI FIFO transfer out		*/
+#define SCMD_DMA_OUT			0xC1	/* SCSI DMA transfer out		*/
+#define SCMD_FIFO_IN			0xC2	/* SCSI FIFO transfer in		*/
+#define SCMD_DMA_IN			0xC3	/* SCSI DMA transfer in			*/
+#define SCMD_MSGACCEPT			0xD8	/* Message accept			*/
+
+/************************************************************************/
+/*									*/
+/*	Code	Command Description					*/
+/*	----	----------------------------------------		*/
+/*	02	Enable reselection with FIFO				*/
+/*	40	Select without ATN with FIFO				*/
+/*	60	Select with ATN with FIFO				*/
+/*	64	Select with ATN3 with FIFO				*/
+/*	A0	Select with ATN and stop with FIFO			*/
+/*	C0	Transfer information out with FIFO			*/
+/*	C1	Transfer information out with DMA			*/
+/*	C2	Transfer information in with FIFO			*/
+/*	C3	Transfer information in with DMA			*/
+/*	12	Initiator command complete with FIFO			*/
+/*	50	Initiator transfer information out sequence without ATN	*/
+/*		with FIFO						*/
+/*	70	Initiator transfer information out sequence with ATN	*/
+/*		with FIFO						*/
+/*	74	Initiator transfer information out sequence with ATN3	*/
+/*		with FIFO						*/
+/*	52	Initiator transfer information in sequence without ATN	*/
+/*		with FIFO						*/
+/*	72	Initiator transfer information in sequence with ATN	*/
+/*		with FIFO						*/
+/*	76	Initiator transfer information in sequence with ATN3	*/
+/*		with FIFO						*/
+/*	90	Initiator transfer information out command complete	*/
+/*		with FIFO						*/
+/*	92	Initiator transfer information in command complete	*/
+/*		with FIFO						*/
+/*	D2	Enable selection					*/
+/*	08	Reselection						*/
+/*	48	Disconnect command with FIFO				*/
+/*	88	Terminate command with FIFO				*/
+/*	C8	Target command complete with FIFO			*/
+/*	18	SCAM Arbitration/ Selection				*/
+/*	5A	Enable reselection					*/
+/*	98	Select without ATN with FIFO				*/
+/*	B8	Select with ATN with FIFO				*/
+/*	D8	Message Accepted					*/
+/*	58	NOP							*/
+/*									*/
+/************************************************************************/
+
+#define TRM_S1040_SCSI_TIMEOUT		0x91	/* SCSI Time Out Value (R/W)		*/
+#define TRM_S1040_SCSI_FIFO		0x98	/* SCSI FIFO (R/W)			*/
+
+#define TRM_S1040_SCSI_TCR0		0x9C	/* SCSI Target Control 0 (R/W)		*/
+#define TCR0_WIDE_NEGO_DONE		0x8000	/* Wide nego done			*/
+#define TCR0_SYNC_NEGO_DONE		0x4000	/* Synchronous nego done		*/
+#define TCR0_ENABLE_LVDS		0x2000	/* Enable LVDS synchronous		*/
+#define TCR0_ENABLE_WIDE		0x1000	/* Enable WIDE synchronous		*/
+#define TCR0_ENABLE_ALT			0x0800	/* Enable alternate synchronous		*/
+#define TCR0_PERIOD_MASK		0x0700	/* Transfer rate			*/
+
+#define TCR0_DO_WIDE_NEGO		0x0080	/* Do wide NEGO				*/
+#define TCR0_DO_SYNC_NEGO		0x0040	/* Do sync NEGO				*/
+#define TCR0_DISCONNECT_EN		0x0020	/* Disconnection enable			*/
+#define TCR0_OFFSET_MASK		0x001F	/* Offset number			*/
+
+#define TRM_S1040_SCSI_TCR1		0x9E	/* SCSI Target Control 1 (R/W)		*/
+#define MAXTAG_MASK			0x7F00	/* Maximum tags (127)			*/
+#define NON_TAG_BUSY			0x0080	/* Non tag command active		*/
+#define ACTTAG_MASK			0x007F	/* Active tags				*/
+
+/************************************************************************/
+/*									*/
+/*	The DMA register offset for TRM_S1040				*/
+/*									*/
+/************************************************************************/
+#define TRM_S1040_DMA_COMMAND		0xA0	/* DMA Command (R/W)			*/
+#define DMACMD_SG			0x02	/* Enable HW S/G support		*/
+#define DMACMD_DIR			0x01	/* 1 = read from SCSI write to Host	*/
+#define XFERDATAIN_SG			0x0103	/* Transfer data in  w/  SG		*/
+#define XFERDATAOUT_SG			0x0102	/* Transfer data out w/  SG		*/
+#define XFERDATAIN			0x0101	/* Transfer data in  w/o SG		*/
+#define XFERDATAOUT			0x0100	/* Transfer data out w/o SG		*/
+
+#define TRM_S1040_DMA_FIFOCNT		0xA1	/* DMA FIFO Counter (R)			*/
+
+#define TRM_S1040_DMA_CONTROL		0xA1	/* DMA Control (W)			*/
+#define DMARESETMODULE			0x10	/* Reset PCI/DMA module			*/
+#define STOPDMAXFER			0x08	/* Stop  DMA transfer			*/
+#define ABORTXFER			0x04	/* Abort DMA transfer			*/
+#define CLRXFIFO			0x02	/* Clear DMA transfer FIFO		*/
+#define STARTDMAXFER			0x01	/* Start DMA transfer			*/
+
+#define TRM_S1040_DMA_FIFOSTAT		0xA2	/* DMA FIFO Status (R)			*/
+
+#define TRM_S1040_DMA_STATUS		0xA3	/* DMA Interrupt Status (R/W)		*/
+#define XFERPENDING			0x80	/* Transfer pending			*/
+#define SCSIBUSY			0x40	/* SCSI busy				*/
+#define GLOBALINT			0x20	/* DMA_INTEN bit 0-4 set		*/
+#define FORCEDMACOMP			0x10	/* Force DMA transfer complete		*/
+#define DMAXFERERROR			0x08	/* DMA transfer error			*/
+#define DMAXFERABORT			0x04	/* DMA transfer abort			*/
+#define DMAXFERCOMP			0x02	/* Bus Master XFER Complete status	*/
+#define SCSICOMP			0x01	/* SCSI complete interrupt		*/
+
+#define TRM_S1040_DMA_INTEN		0xA4	/* DMA Interrupt Enable (R/W)		*/
+#define EN_FORCEDMACOMP			0x10	/* Force DMA transfer complete		*/
+#define EN_DMAXFERERROR			0x08	/* DMA transfer error			*/
+#define EN_DMAXFERABORT			0x04	/* DMA transfer abort			*/
+#define EN_DMAXFERCOMP			0x02	/* Bus Master XFER Complete status	*/
+#define EN_SCSIINTR			0x01	/* Enable SCSI complete interrupt	*/
+
+#define TRM_S1040_DMA_CONFIG		0xA6	/* DMA Configuration (R/W)		*/
+#define DMA_ENHANCE			0x8000	/* Enable DMA enhance feature (SG?)	*/
+#define DMA_PCI_DUAL_ADDR		0x4000	/*					*/
+#define DMA_CFG_RES			0x2000	/* Always 1				*/
+#define DMA_AUTO_CLR_FIFO		0x1000	/* DISable DMA auto clear FIFO		*/
+#define DMA_MEM_MULTI_READ		0x0800	/*					*/
+#define DMA_MEM_WRITE_INVAL		0x0400	/* Memory write and invalidate		*/
+#define DMA_FIFO_CTRL			0x0300	/* Control FIFO operation with DMA	*/
+#define DMA_FIFO_HALF_HALF		0x0200	/* Keep half filled on both read/write	*/
+
+#define TRM_S1040_DMA_XCNT		0xA8	/* DMA Transfer Counter (R/W), 24bits	*/
+#define TRM_S1040_DMA_CXCNT		0xAC	/* DMA Current Transfer Counter (R)	*/
+#define TRM_S1040_DMA_XLOWADDR		0xB0	/* DMA Transfer Physical Low Address	*/
+#define TRM_S1040_DMA_XHIGHADDR		0xB4	/* DMA Transfer Physical High Address	*/
+
+/************************************************************************/
+/*									*/
+/*	The general register offset for TRM_S1040			*/
+/*									*/
+/************************************************************************/
+#define TRM_S1040_GEN_CONTROL		0xD4	/* Global Control			*/
+#define CTRL_LED			0x80	/* Control onboard LED			*/
+#define EN_EEPROM			0x10	/* Enable EEPROM programming		*/
+#define DIS_TERM			0x08	/* Disable onboard termination		*/
+#define AUTOTERM			0x04	/* Enable Auto SCSI terminator		*/
+#define LOW8TERM			0x02	/* Enable Lower 8 bit SCSI terminator	*/
+#define UP8TERM				0x01	/* Enable Upper 8 bit SCSI terminator	*/
+
+#define TRM_S1040_GEN_STATUS		0xD5	/* Global Status			*/
+#define GTIMEOUT			0x80	/* Global timer reach 0			*/
+#define EXT68HIGH			0x40	/* Higher 8 bit connected externally	*/
+#define INT68HIGH			0x20	/* Higher 8 bit connected internally	*/
+#define CON5068				0x10	/* External 50/68 pin connected (low)	*/
+#define CON68				0x08	/* Internal 68 pin connected (low)	*/
+#define CON50				0x04	/* Internal 50 pin connected (low!)	*/
+#define WIDESCSI			0x02	/* Wide SCSI card			*/
+#define STATUS_LOAD_DEFAULT		0x01	/*					*/
+
+#define TRM_S1040_GEN_NVRAM		0xD6	/* Serial NON-VOLATILE RAM port		*/
+#define NVR_BITOUT			0x08	/* Serial data out			*/
+#define NVR_BITIN			0x04	/* Serial data in			*/
+#define NVR_CLOCK			0x02	/* Serial clock				*/
+#define NVR_SELECT			0x01	/* Serial select			*/
+
+#define TRM_S1040_GEN_EDATA		0xD7	/* Parallel EEPROM data port		*/
+#define TRM_S1040_GEN_EADDRESS		0xD8	/* Parallel EEPROM address		*/
+#define TRM_S1040_GEN_TIMER		0xDB	/* Global timer				*/
+
+/************************************************************************/
+/*									*/
+/*	NvmTarCfg0: Target configuration byte 0 :..pDCB->DevMode	*/
+/*									*/
+/************************************************************************/
+#define NTC_DO_WIDE_NEGO		0x20	/* Wide negotiate			*/
+#define NTC_DO_TAG_QUEUEING		0x10	/* Enable SCSI tag queuing		*/
+#define NTC_DO_SEND_START		0x08	/* Send start command SPINUP		*/
+#define NTC_DO_DISCONNECT		0x04	/* Enable SCSI disconnect		*/
+#define NTC_DO_SYNC_NEGO		0x02	/* Sync negotiation			*/
+#define NTC_DO_PARITY_CHK		0x01	/* (it sould define at NAC)		*/
+						/* Parity check enable			*/
+
+/************************************************************************/
+/*									*/
+/*	Nvram Initiater bits definition					*/
+/*									*/
+/************************************************************************/
+#if 0
+#define MORE2_DRV			BIT0
+#define GREATER_1G			BIT1
+#define RST_SCSI_BUS			BIT2
+#define ACTIVE_NEGATION			BIT3
+#define NO_SEEK				BIT4
+#define LUN_CHECK			BIT5
+#endif
+
+/************************************************************************/
+/*									*/
+/*	Nvram Adapter Cfg bits definition				*/
+/*									*/
+/************************************************************************/
+#define NAC_SCANLUN			0x20	/* Include LUN as BIOS device		*/
+#define NAC_POWERON_SCSI_RESET		0x04	/* Power on reset enable		*/
+#define NAC_GREATER_1G			0x02	/* > 1G support enable			*/
+#define NAC_GT2DRIVES			0x01	/* Support more than 2 drives		*/
+/* #define NAC_DO_PARITY_CHK		0x08 */	/* Parity check enable			*/
+
+#endif
diff -Nru a/drivers/scsi/dmx3191d.c b/drivers/scsi/dmx3191d.c
--- a/drivers/scsi/dmx3191d.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/scsi/dmx3191d.c	Wed Apr 30 22:28:10 2003
@@ -96,7 +96,7 @@
 			printk(KERN_WARNING "dmx3191: IRQ %d not available - switching to polled mode.\n", pdev->irq);
 			/* Steam powered scsi controllers run without an IRQ
 			   anyway */
-			instance->irq = IRQ_NONE;
+			instance->irq = SCSI_IRQ_NONE;
 		}
 
 		boards++;
@@ -113,7 +113,7 @@
 static int dmx3191d_release_resources(struct Scsi_Host *instance)
 {
 	release_region(instance->io_port, DMX3191D_REGION);
-	if(instance->irq!=IRQ_NONE)
+	if(instance->irq!=SCSI_IRQ_NONE)
 		free_irq(instance->irq, instance);
 
 	return 0;
diff -Nru a/drivers/scsi/dtc.c b/drivers/scsi/dtc.c
--- a/drivers/scsi/dtc.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/scsi/dtc.c	Wed Apr 30 22:28:13 2003
@@ -269,27 +269,27 @@
 #ifndef DONT_USE_INTR
 		/* With interrupts enabled, it will sometimes hang when doing heavy
 		 * reads. So better not enable them until I finger it out. */
-		if (instance->irq != IRQ_NONE)
+		if (instance->irq != SCSI_IRQ_NONE)
 			if (request_irq(instance->irq, dtc_intr, SA_INTERRUPT, "dtc", instance)) {
 				printk(KERN_ERR "scsi%d : IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq);
-				instance->irq = IRQ_NONE;
+				instance->irq = SCSI_IRQ_NONE;
 			}
 
-		if (instance->irq == IRQ_NONE) {
+		if (instance->irq == SCSI_IRQ_NONE) {
 			printk(KERN_WARNING "scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
 			printk(KERN_WARNING "scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
 		}
 #else
-		if (instance->irq != IRQ_NONE)
+		if (instance->irq != SCSI_IRQ_NONE)
 			printk(KERN_WARNING "scsi%d : interrupts not used. Might as well not jumper it.\n", instance->host_no);
-		instance->irq = IRQ_NONE;
+		instance->irq = SCSI_IRQ_NONE;
 #endif
 #if defined(DTCDEBUG) && (DTCDEBUG & DTCDEBUG_INIT)
 		printk("scsi%d : irq = %d\n", instance->host_no, instance->irq);
 #endif
 
 		printk(KERN_INFO "scsi%d : at 0x%05X", instance->host_no, (int) instance->base);
-		if (instance->irq == IRQ_NONE)
+		if (instance->irq == SCSI_IRQ_NONE)
 			printk(" interrupts disabled");
 		else
 			printk(" irq %d", instance->irq);
@@ -361,7 +361,7 @@
 	i = 0;
 	NCR5380_read(RESET_PARITY_INTERRUPT_REG);
 	NCR5380_write(MODE_REG, MR_ENABLE_EOP_INTR | MR_DMA_MODE);
-	if (instance->irq == IRQ_NONE)
+	if (instance->irq == SCSI_IRQ_NONE)
 		NCR5380_write(DTC_CONTROL_REG, CSR_DIR_READ);
 	else
 		NCR5380_write(DTC_CONTROL_REG, CSR_DIR_READ | CSR_INT_BASE);
@@ -412,7 +412,7 @@
 	NCR5380_read(RESET_PARITY_INTERRUPT_REG);
 	NCR5380_write(MODE_REG, MR_ENABLE_EOP_INTR | MR_DMA_MODE);
 	/* set direction (write) */
-	if (instance->irq == IRQ_NONE)
+	if (instance->irq == SCSI_IRQ_NONE)
 		NCR5380_write(DTC_CONTROL_REG, 0);
 	else
 		NCR5380_write(DTC_CONTROL_REG, CSR_5380_INTR);
diff -Nru a/drivers/scsi/eata.c b/drivers/scsi/eata.c
--- a/drivers/scsi/eata.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/scsi/eata.c	Wed Apr 30 22:28:16 2003
@@ -815,7 +815,7 @@
 /* But transfer orientation from the 16 bit data register is Little Endian */
 #define REG2H(x)   le16_to_cpu(x)
 
-static void do_interrupt_handler(int, void *, struct pt_regs *);
+static irqreturn_t do_interrupt_handler(int, void *, struct pt_regs *);
 static void flush_dev(Scsi_Device *, unsigned long, unsigned int, unsigned int);
 static int do_trace = FALSE;
 static int setup_done = FALSE;
@@ -2332,16 +2332,19 @@
    return;
 }
 
-static void do_interrupt_handler(int irq, void *shap, struct pt_regs *regs) {
+static irqreturn_t do_interrupt_handler(int irq, void *shap,
+					struct pt_regs *regs) {
    unsigned int j;
    unsigned long spin_flags;
 
    /* Check if the interrupt must be processed by this handler */
-   if ((j = (unsigned int)((char *)shap - sha)) >= num_boards) return;
+   if ((j = (unsigned int)((char *)shap - sha)) >= num_boards)
+	return IRQ_NONE;
 
    spin_lock_irqsave(sh[j]->host_lock, spin_flags);
    ihdlr(irq, j);
    spin_unlock_irqrestore(sh[j]->host_lock, spin_flags);
+   return IRQ_HANDLED;
 }
 
 static int eata2x_release(struct Scsi_Host *shpnt) {
diff -Nru a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c
--- a/drivers/scsi/eata_pio.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/scsi/eata_pio.c	Wed Apr 30 22:28:11 2003
@@ -155,24 +155,6 @@
     if (pos > offset + length)
 	goto stop_output;
     
-    size = sprintf(buffer+len,"Attached devices: %s\n", 
-		   (!list_empty(&shost->my_devices))?"":"none");
-    len += size; 
-    pos = begin + len;
-    
-    list_for_each_entry(sdev, &shost->my_devices, siblings) {
-	    proc_print_scsidevice(sdev, buffer, &size, len);
-	    len += size; 
-	    pos = begin + len;
-	    
-	    if (pos < offset) {
-		len = 0;
-		begin = pos;
-	    }
-	    if (pos > offset + length)
-		goto stop_output;
-    }
-    
  stop_output:
     DBG(DBG_PROC, printk("2pos: %ld offset: %ld len: %d\n", pos, offset, len));
     *start=buffer+(offset-begin);   /* Start of wanted data */
@@ -213,7 +195,8 @@
 
 static void eata_pio_int_handler(int irq, void *dev_id, struct pt_regs *regs);
 
-static void do_eata_pio_int_handler(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t do_eata_pio_int_handler(int irq, void *dev_id,
+						struct pt_regs *regs)
 {
 	unsigned long flags;
 	struct Scsi_Host *dev = dev_id;
@@ -221,6 +204,7 @@
 	spin_lock_irqsave(dev->host_lock, flags);
 	eata_pio_int_handler(irq, dev_id, regs);
 	spin_unlock_irqrestore(dev->host_lock, flags);
+	return IRQ_HANDLED;
 }
 
 static void eata_pio_int_handler(int irq, void *dev_id, struct pt_regs *regs)
diff -Nru a/drivers/scsi/esp.c b/drivers/scsi/esp.c
--- a/drivers/scsi/esp.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/scsi/esp.c	Wed Apr 30 22:28:19 2003
@@ -186,7 +186,7 @@
 static int esps_running = 0;
 
 /* Forward declarations. */
-static void esp_intr(int irq, void *dev_id, struct pt_regs *pregs);
+static irqreturn_t esp_intr(int irq, void *dev_id, struct pt_regs *pregs);
 
 /* Debugging routines */
 struct esp_cmdstrings {
@@ -4321,7 +4321,7 @@
 }
 
 /* Service only the ESP described by dev_id. */
-static void esp_intr(int irq, void *dev_id, struct pt_regs *pregs)
+static irqreturn_t esp_intr(int irq, void *dev_id, struct pt_regs *pregs)
 {
 	struct esp *esp = dev_id;
 	unsigned long flags;
@@ -4337,6 +4337,8 @@
 		ESP_INTSON(esp->dregs);
 	}
 	spin_unlock_irqrestore(esp->ehost->host_lock, flags);
+
+	return IRQ_HANDLED;
 }
 
 static int esp_slave_alloc(Scsi_Device *SDptr)
diff -Nru a/drivers/scsi/fd_mcs.c b/drivers/scsi/fd_mcs.c
--- a/drivers/scsi/fd_mcs.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/scsi/fd_mcs.c	Wed Apr 30 22:28:08 2003
@@ -283,7 +283,7 @@
 
 #define FD_BRDS sizeof(fd_mcs_adapters)/sizeof(struct fd_mcs_adapters_struct)
 
-static void fd_mcs_intr(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t fd_mcs_intr(int irq, void *dev_id, struct pt_regs *regs);
 
 static unsigned long addresses[] = { 0xc8000, 0xca000, 0xce000, 0xde000 };
 static unsigned short ports[] = { 0x140, 0x150, 0x160, 0x170 };
@@ -679,7 +679,7 @@
 }
 
 /* only my_done needs to be protected  */
-static void fd_mcs_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t fd_mcs_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	unsigned long flags;
 	int status;
@@ -699,7 +699,7 @@
 
 	/* return if some other device on this IRQ caused the interrupt */
 	if (!shpnt) {
-		return;
+		return IRQ_NONE;
 	}
 
 	INTR_Processed++;
@@ -711,7 +711,7 @@
 #if DEBUG_ABORT
 		printk("Interrupt after abort, ignoring\n");
 #endif
-		/* return; */
+		/* return IRQ_HANDLED; */
 	}
 #if DEBUG_RACE
 	++in_interrupt_flag;
@@ -726,7 +726,7 @@
 			spin_lock_irqsave(shpnt->host_lock, flags);
 			my_done(shpnt, DID_BUS_BUSY << 16);
 			spin_unlock_irqrestore(shpnt->host_lock, flags);
-			return;
+			return IRQ_HANDLED;
 		}
 		current_SC->SCp.phase = in_selection;
 
@@ -752,7 +752,7 @@
 				spin_lock_irqsave(shpnt->host_lock, flags);
 				my_done(shpnt, DID_NO_CONNECT << 16);
 				spin_unlock_irqrestore(shpnt->host_lock, flags);
-				return;
+				return IRQ_HANDLED;
 			} else {
 #if EVERY_ACCESS
 				printk(" AltSel ");
@@ -767,7 +767,7 @@
 #if DEBUG_RACE
 		in_interrupt_flag = 0;
 #endif
-		return;
+		return IRQ_HANDLED;
 	}
 
 	/* current_SC->SCp.phase == in_other: this is the body of the routine */
@@ -1117,7 +1117,7 @@
 #if DEBUG_RACE
 	in_interrupt_flag = 0;
 #endif
-	return;
+	return IRQ_HANDLED;
 }
 
 static int fd_mcs_release(struct Scsi_Host *shpnt)
diff -Nru a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c
--- a/drivers/scsi/fdomain.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/scsi/fdomain.c	Wed Apr 30 22:28:13 2003
@@ -418,7 +418,7 @@
 static int               FIFO_Size = 0x2000; /* 8k FIFO for
 						pre-tmc18c30 chips */
 
-static void              do_fdomain_16x0_intr( int irq, void *dev_id,
+static irqreturn_t       do_fdomain_16x0_intr( int irq, void *dev_id,
 					    struct pt_regs * regs );
 int		 	fdomain_16x0_bus_reset(Scsi_Cmnd *SCpnt);
 
@@ -1201,7 +1201,8 @@
 #endif
 }
 
-static void do_fdomain_16x0_intr( int irq, void *dev_id, struct pt_regs * regs )
+static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id,
+					struct pt_regs * regs )
 {
    unsigned long flags;
    int      status;
@@ -1216,7 +1217,7 @@
 
    /* Check for other IRQ sources */
    if((inb(TMC_Status_port)&0x01)==0)   
-   	return;
+   	return IRQ_NONE;
 
    /* It is our IRQ */   	
    outb( 0x00, Interrupt_Cntl_port );
@@ -1227,7 +1228,7 @@
       printk( "Spurious interrupt, in_command = %d, current_SC = %x\n",
 	      in_command, current_SC );
 #endif
-      return;
+      return IRQ_NONE;
    }
 
    /* Abort calls my_done, so we do nothing here. */
@@ -1236,7 +1237,7 @@
       printk( "scsi: <fdomain> Interrupt after abort, ignoring\n" );
 #endif
       /*
-      return; */
+      return IRQ_HANDLED; */
    }
 
 #if DEBUG_RACE
@@ -1252,7 +1253,7 @@
          spin_lock_irqsave(current_SC->device->host->host_lock, flags);
 	 my_done( DID_BUS_BUSY << 16 );
          spin_unlock_irqrestore(current_SC->device->host->host_lock, flags);
-	 return;
+	 return IRQ_HANDLED;
       }
       current_SC->SCp.phase = in_selection;
       
@@ -1266,7 +1267,7 @@
 #if DEBUG_RACE
       in_interrupt_flag = 0;
 #endif
-      return;
+      return IRQ_HANDLED;
    } else if (current_SC->SCp.phase & in_selection) {
       status = inb( SCSI_Status_port );
       if (!(status & 0x01)) {
@@ -1278,7 +1279,7 @@
             spin_lock_irqsave(current_SC->device->host->host_lock, flags);
 	    my_done( DID_NO_CONNECT << 16 );
             spin_unlock_irqrestore(current_SC->device->host->host_lock, flags);
-	    return;
+	    return IRQ_HANDLED;
 	 } else {
 #if EVERY_ACCESS
 	    printk( " AltSel " );
@@ -1293,7 +1294,7 @@
 #if DEBUG_RACE
       in_interrupt_flag = 0;
 #endif
-      return;
+      return IRQ_HANDLED;
    }
    
    /* current_SC->SCp.phase == in_other: this is the body of the routine */
@@ -1492,7 +1493,7 @@
 #if DEBUG_RACE
    in_interrupt_flag = 0;
 #endif
-   return;
+   return IRQ_HANDLED;
 }
 
 static int fdomain_16x0_queue( Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *))
diff -Nru a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c
--- a/drivers/scsi/g_NCR5380.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/scsi/g_NCR5380.c	Wed Apr 30 22:28:05 2003
@@ -115,6 +115,7 @@
 #include <linux/ioport.h>
 #include <linux/isapnp.h>
 #include <linux/delay.h>
+#include <linux/interrupt.h>
 
 #define NCR_NOT_SET 0
 static int ncr_irq = NCR_NOT_SET;
@@ -336,7 +337,7 @@
 			if (pnp_irq_valid(dev, 0))
 				overrides[count].irq = pnp_irq(dev, 0);
 			else
-				overrides[count].irq = IRQ_NONE;
+				overrides[count].irq = SCSI_IRQ_NONE;
 			if (pnp_dma_valid(dev, 0))
 				overrides[count].dma = pnp_dma(dev, 0);
 			else
@@ -433,19 +434,19 @@
 		else
 			instance->irq = NCR5380_probe_irq(instance, 0xffff);
 
-		if (instance->irq != IRQ_NONE)
+		if (instance->irq != SCSI_IRQ_NONE)
 			if (request_irq(instance->irq, generic_NCR5380_intr, SA_INTERRUPT, "NCR5380", NULL)) {
 				printk(KERN_WARNING "scsi%d : IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq);
-				instance->irq = IRQ_NONE;
+				instance->irq = SCSI_IRQ_NONE;
 			}
 
-		if (instance->irq == IRQ_NONE) {
+		if (instance->irq == SCSI_IRQ_NONE) {
 			printk(KERN_INFO "scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
 			printk(KERN_INFO "scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
 		}
 
 		printk(KERN_INFO "scsi%d : at " STRVAL(NCR5380_map_name) " 0x%x", instance->host_no, (unsigned int) instance->NCR5380_instance_name);
-		if (instance->irq == IRQ_NONE)
+		if (instance->irq == SCSI_IRQ_NONE)
 			printk(" interrupts disabled");
 		else
 			printk(" irq %d", instance->irq);
@@ -492,7 +493,7 @@
 	release_mem_region(instance->NCR5380_instance_name, NCR5380_region_size);
 #endif
 
-	if (instance->irq != IRQ_NONE)
+	if (instance->irq != SCSI_IRQ_NONE)
 		free_irq(instance->irq, NULL);
 
 	return 0;
@@ -804,7 +805,7 @@
 	PRINTP("NO NCR53C400 driver extensions\n");
 #endif
 	PRINTP("Using %s mapping at %s 0x%lx, " ANDP STRVAL(NCR5380_map_config) ANDP STRVAL(NCR5380_map_name) ANDP scsi_ptr->NCR5380_instance_name);
-	if (scsi_ptr->irq == IRQ_NONE)
+	if (scsi_ptr->irq == SCSI_IRQ_NONE)
 		PRINTP("no interrupt\n");
 	else
 		PRINTP("on interrupt %d\n" ANDP scsi_ptr->irq);
diff -Nru a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
--- a/drivers/scsi/gdth.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/scsi/gdth.c	Wed Apr 30 22:28:11 2003
@@ -372,11 +372,7 @@
 
 static void gdth_delay(int milliseconds);
 static void gdth_eval_mapping(ulong32 size, int *cyls, int *heads, int *secs);
-#if LINUX_VERSION_CODE >= 0x010346
-static void gdth_interrupt(int irq,void *dev_id,struct pt_regs *regs);
-#else
-static void gdth_interrupt(int irq,struct pt_regs *regs);
-#endif
+static irqreturn_t gdth_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp);
 static int gdth_async_event(int hanum);
 static void gdth_log_event(gdth_evt_data *dvr, char *buffer);
@@ -747,9 +743,9 @@
 #ifdef GDTH_IOCTL_CHRDEV
 /* ioctl interface */
 static struct file_operations gdth_fops = {
-    ioctl:gdth_ioctl,
-    open:gdth_open,
-    release:gdth_close,
+	.ioctl		= gdth_ioctl,
+	.open		= gdth_open,
+	.release	= gdth_close,
 };
 #endif
 
@@ -1925,11 +1921,7 @@
 
     gdth_from_wait = TRUE;
     do {
-#if LINUX_VERSION_CODE >= 0x010346
         gdth_interrupt((int)ha->irq,ha,NULL);
-#else
-        gdth_interrupt((int)ha->irq,NULL);
-#endif
         if (wait_hanum==hanum && wait_index==index) {
             answer_found = TRUE;
             break;
@@ -3362,11 +3354,7 @@
 
 /* SCSI interface functions */
 
-#if LINUX_VERSION_CODE >= 0x010346
-static void gdth_interrupt(int irq,void *dev_id,struct pt_regs *regs)
-#else
-static void gdth_interrupt(int irq,struct pt_regs *regs)
-#endif
+static irqreturn_t gdth_interrupt(int irq,void *dev_id,struct pt_regs *regs)
 {
     register gdth_ha_str *ha;
     gdt6m_dpram_str *dp6m_ptr;
@@ -3383,7 +3371,7 @@
     /* if polling and not from gdth_wait() -> return */
     if (gdth_polling) {
         if (!gdth_from_wait) {
-            return;
+            return IRQ_HANDLED;
         }
     }
 
@@ -3396,7 +3384,7 @@
         /* spurious interrupt */
         if (!gdth_polling)
             GDTH_UNLOCK_HA((gdth_ha_str *)dev_id,flags);
-        return;
+        return IRQ_HANDLED;
     }
 
 #ifdef GDTH_STATISTICS
@@ -3492,7 +3480,7 @@
         TRACE2(("gdth_interrupt() unknown controller type\n"));
         if (!gdth_polling)
             GDTH_UNLOCK_HA((gdth_ha_str *)dev_id,flags);
-        return;
+        return IRQ_HANDLED;
     }
 
     TRACE(("gdth_interrupt() index %d stat %d info %d\n",
@@ -3509,7 +3497,7 @@
         if (!gdth_polling)
             GDTH_UNLOCK_HA((gdth_ha_str *)dev_id,flags);
         gdth_next(hanum);
-        return;
+        return IRQ_HANDLED;
     } 
 
     if (IStatus == SPEZINDEX) {
@@ -3519,7 +3507,7 @@
         gdth_store_event(ha, ES_DRIVER, 4, &ha->dvr);
         if (!gdth_polling)
             GDTH_UNLOCK_HA((gdth_ha_str *)dev_id,flags);
-        return;
+        return IRQ_HANDLED;
     }
     scp     = ha->cmd_tab[IStatus-2].cmnd;
     Service = ha->cmd_tab[IStatus-2].service;
@@ -3532,13 +3520,13 @@
         gdth_store_event(ha, ES_DRIVER, 1, &ha->dvr);
         if (!gdth_polling)
             GDTH_UNLOCK_HA((gdth_ha_str *)dev_id,flags);
-        return;
+        return IRQ_HANDLED;
     }
     if (scp == INTERNAL_CMND) {
         TRACE(("gdth_interrupt() answer to internal command\n"));
         if (!gdth_polling)
             GDTH_UNLOCK_HA((gdth_ha_str *)dev_id,flags);
-        return;
+        return IRQ_HANDLED;
     }
 
     TRACE(("gdth_interrupt() sync. status\n"));
@@ -3563,6 +3551,7 @@
 #endif
     }
     gdth_next(hanum);
+    return IRQ_HANDLED;
 }
 
 static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp)
@@ -3672,9 +3661,9 @@
         else if (scp->SCp.Status == GDTH_MAP_SINGLE) 
             pci_unmap_single(ha->pdev,scp->SCp.dma_handle,
                          scp->request_bufflen,scp->SCp.Message);
-        if (scp->SCp.buffer)
-            pci_unmap_single(ha->pdev,(dma_addr_t)scp->SCp.buffer,
-                             16,PCI_DMA_FROMDEVICE);
+        if (scp->SCp.buffer) 
+            pci_unmap_single(ha->pdev,(dma_addr_t)(u32)scp->SCp.buffer,
+						16,PCI_DMA_FROMDEVICE);
 #endif
         if (ha->status == S_OK) {
             scp->SCp.Status = S_OK;
@@ -4226,6 +4215,9 @@
 
     /* scanning for controllers, at first: ISA controller */
     for (isa_bios=0xc8000UL; isa_bios<=0xd8000UL; isa_bios+=0x8000UL) {
+
+	dma_addr_t scratch_dma_handle;
+
         if (gdth_ctr_count >= MAXHA) 
             break;
         if (gdth_search_isa(isa_bios)) {        /* controller found */
@@ -4282,7 +4274,8 @@
 #if LINUX_VERSION_CODE >= 0x020400
             ha->pdev = NULL;
             ha->pscratch = pci_alloc_consistent(ha->pdev, GDTH_SCRATCH, 
-                                                &ha->scratch_phys); 
+						&scratch_dma_handle);
+            ha->scratch_phys = (ulong32)scratch_dma_handle;
 #else
             ha->pscratch = scsi_init_malloc(GDTH_SCRATCH, GFP_ATOMIC | GFP_DMA);
             if (ha->pscratch)
@@ -4349,6 +4342,9 @@
 
     /* scanning for EISA controllers */
     for (eisa_slot=0x1000; eisa_slot<=0x8000; eisa_slot+=0x1000) {
+
+	dma_addr_t scratch_dma_handle;
+
         if (gdth_ctr_count >= MAXHA) 
             break;
         if (gdth_search_eisa(eisa_slot)) {      /* controller found */
@@ -4392,7 +4388,8 @@
 #if LINUX_VERSION_CODE >= 0x020400
             ha->pdev = NULL;
             ha->pscratch = pci_alloc_consistent(ha->pdev, GDTH_SCRATCH, 
-                                                &ha->scratch_phys); 
+						&scratch_dma_handle);
+            ha->scratch_phys = (ulong32) scratch_dma_handle;
             ha->ccb_phys = 
                 pci_map_single(ha->pdev,ha->pccb,
                                sizeof(gdth_cmd_str),PCI_DMA_BIDIRECTIONAL);
@@ -4475,6 +4472,9 @@
         printk("GDT: Found %d PCI Storage RAID Controllers\n",cnt);
         gdth_sort_pci(pcistr,cnt);
         for (ctr = 0; ctr < cnt; ++ctr) {
+
+	    dma_addr_t scratch_dma_handle;
+
             if (gdth_ctr_count >= MAXHA)
                 break;
             shp = scsi_register(shtp,sizeof(gdth_ext_str));
@@ -4516,7 +4516,8 @@
             ha->ccb_phys = 0L;
 #if LINUX_VERSION_CODE >= 0x020400
             ha->pscratch = pci_alloc_consistent(ha->pdev, GDTH_SCRATCH, 
-                                                &ha->scratch_phys); 
+						&scratch_dma_handle);
+            ha->scratch_phys = (ulong32)scratch_dma_handle;
 #else
             ha->pscratch = scsi_init_malloc(GDTH_SCRATCH, GFP_ATOMIC | GFP_DMA);
             if (ha->pscratch)
@@ -4892,90 +4893,156 @@
     return 0;
 }
 
-static int gdth_ioctl(struct inode *inode, struct file *filep,
-                      unsigned int cmd, unsigned long arg)
+static int ioc_event(unsigned long arg)
 {
-    gdth_ha_str *ha; 
-#if LINUX_VERSION_CODE >= 0x020503
-    Scsi_Request *srp;
-    Scsi_Cmnd *scp;
-    Scsi_Device *sdev;
-#elif LINUX_VERSION_CODE >= 0x020322
-    Scsi_Cmnd *scp;
-    Scsi_Device *sdev;
-#else
-    Scsi_Cmnd scp;
-    Scsi_Device sdev;
-#endif
-    ulong flags;
-    char cmnd[MAX_COMMAND_SIZE];   
-    memset(cmnd, 0xff, 12);
-    
-    TRACE(("gdth_ioctl() cmd 0x%x\n", cmd));
- 
-    switch (cmd) {
-      case GDTIOCTL_CTRCNT:
-      { 
-        int cnt = gdth_ctr_count;
-        put_user(cnt, (int *)arg);
-        break;
-      }
+        gdth_ioctl_event evt;
+        gdth_ha_str *ha;
+        ulong flags;
 
-      case GDTIOCTL_DRVERS:
-      { 
-        int ver = (GDTH_VERSION<<8) | GDTH_SUBVERSION;
-        put_user(ver, (int *)arg);
-        break;
-      }
-      
-      case GDTIOCTL_OSVERS:
-      { 
-        gdth_ioctl_osvers osv; 
+        if (copy_from_user(&evt, (char *)arg, sizeof(gdth_ioctl_event)) ||
+            evt.ionode >= gdth_ctr_count)
+            return -EFAULT;
+        ha = HADATA(gdth_ctr_tab[evt.ionode]);
 
-        osv.version = (unchar)(LINUX_VERSION_CODE >> 16);
-        osv.subversion = (unchar)(LINUX_VERSION_CODE >> 8);
-        osv.revision = (ushort)(LINUX_VERSION_CODE & 0xff);
-        copy_to_user((char *)arg, &osv, sizeof(gdth_ioctl_osvers));
-        break;
-      }
+        if (evt.erase == 0xff) {
+            if (evt.event.event_source == ES_TEST)
+                evt.event.event_data.size=sizeof(evt.event.event_data.eu.test); 
+            else if (evt.event.event_source == ES_DRIVER)
+                evt.event.event_data.size=sizeof(evt.event.event_data.eu.driver); 
+            else if (evt.event.event_source == ES_SYNC)
+                evt.event.event_data.size=sizeof(evt.event.event_data.eu.sync); 
+            else
+                evt.event.event_data.size=sizeof(evt.event.event_data.eu.async);
+            GDTH_LOCK_HA(ha, flags);
+            gdth_store_event(ha, evt.event.event_source, evt.event.event_idx,
+                             &evt.event.event_data);
+            GDTH_UNLOCK_HA(ha, flags);
+        } else if (evt.erase == 0xfe) {
+            gdth_clear_events();
+        } else if (evt.erase == 0) {
+            evt.handle = gdth_read_event(ha, evt.handle, &evt.event);
+        } else {
+            gdth_readapp_event(ha, evt.erase, &evt.event);
+        }     
+        if (copy_to_user((char *)arg, &evt, sizeof(gdth_ioctl_event)))
+            return -EFAULT;
+        return 0;
+}
 
-      case GDTIOCTL_CTRTYPE:
-      { 
-        gdth_ioctl_ctrtype ctrt;
-        
-        if (copy_from_user(&ctrt, (char *)arg, sizeof(gdth_ioctl_ctrtype)) ||
-            ctrt.ionode >= gdth_ctr_count)
+static int ioc_lockdrv(unsigned long arg)
+{
+        gdth_ioctl_lockdrv ldrv;
+        unchar i, j;
+        ulong flags;
+        gdth_ha_str *ha;
+
+        if (copy_from_user(&ldrv, (char *)arg, sizeof(gdth_ioctl_lockdrv)) ||
+            ldrv.ionode >= gdth_ctr_count)
             return -EFAULT;
-        ha = HADATA(gdth_ctr_tab[ctrt.ionode]);
-        if (ha->type == GDT_ISA || ha->type == GDT_EISA) {
-            ctrt.type = (unchar)((ha->stype>>20) - 0x10);
-        } else {
-            if (ha->type != GDT_PCIMPR) {
-                ctrt.type = (unchar)((ha->stype<<4) + 6);
+        ha = HADATA(gdth_ctr_tab[ldrv.ionode]);
+ 
+        for (i = 0; i < ldrv.drive_cnt && i < MAX_HDRIVES; ++i) {
+            j = ldrv.drives[i];
+            if (j >= MAX_HDRIVES || !ha->hdr[j].present)
+                continue;
+            if (ldrv.lock) {
+                GDTH_LOCK_HA(ha, flags);
+                ha->hdr[j].lock = 1;
+                GDTH_UNLOCK_HA(ha, flags);
+                gdth_wait_completion(ldrv.ionode, ha->bus_cnt, j); 
+                gdth_stop_timeout(ldrv.ionode, ha->bus_cnt, j); 
             } else {
-                ctrt.type = 
-                    (ha->oem_id == OEM_ID_INTEL ? 0xfd : 0xfe);
-                if (ha->stype >= 0x300)
-                    ctrt.ext_type = 0x6000 | ha->subdevice_id;
-                else 
-                    ctrt.ext_type = 0x6000 | ha->stype;
+                GDTH_LOCK_HA(ha, flags);
+                ha->hdr[j].lock = 0;
+                GDTH_UNLOCK_HA(ha, flags);
+                gdth_start_timeout(ldrv.ionode, ha->bus_cnt, j); 
+                gdth_next(ldrv.ionode); 
             }
-            ctrt.device_id = ha->stype;
-            ctrt.sub_device_id = ha->subdevice_id;
-        }
-        ctrt.info = ha->brd_phys;
-        ctrt.oem_id = ha->oem_id;
-        if (copy_to_user((char *)arg, &ctrt, sizeof(gdth_ioctl_ctrtype)))
+        } 
+        return 0;
+}
+
+static int ioc_resetdrv(unsigned long arg, char *cmnd)
+{
+        gdth_ioctl_reset res;
+        gdth_cmd_str cmd;
+        int hanum;
+        gdth_ha_str *ha;
+#if LINUX_VERSION_CODE >= 0x020503
+	Scsi_Request *srp;
+	Scsi_Device *sdev;
+#elif LINUX_VERSION_CODE >= 0x020322
+	Scsi_Cmnd *scp;
+	Scsi_Device *sdev;
+#else
+	Scsi_Cmnd scp;
+	Scsi_Device sdev;
+#endif
+
+        if (copy_from_user(&res, (char *)arg, sizeof(gdth_ioctl_reset)) ||
+            res.ionode >= gdth_ctr_count || res.number >= MAX_HDRIVES)
             return -EFAULT;
-        break;
-      }
-        
-      case GDTIOCTL_GENERAL:
-      {
+        hanum = res.ionode;
+        ha = HADATA(gdth_ctr_tab[hanum]);
+ 
+        if (!ha->hdr[res.number].present)
+            return 0;
+        cmd.Service = CACHESERVICE;
+        cmd.OpCode = GDT_CLUST_RESET;
+        cmd.u.cache.DeviceNo = res.number;
+#if LINUX_VERSION_CODE >= 0x020503
+        sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]);
+        srp  = scsi_allocate_request(sdev);
+        if (!srp)
+            return -ENOMEM;
+        srp->sr_cmd_len = 12;
+        srp->sr_use_sg = 0;
+        gdth_do_req(srp, &cmd, cmnd, 30);
+        res.status = (ushort)srp->sr_command->SCp.Status;
+        scsi_release_request(srp);
+        scsi_free_host_dev(sdev);
+#elif LINUX_VERSION_CODE >= 0x020322
+        sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]);
+        scp  = scsi_allocate_device(sdev, 1, FALSE);
+        if (!scp)
+            return -ENOMEM;
+        scp->cmd_len = 12;
+        scp->use_sg = 0;
+        gdth_do_cmd(scp, &cmd, cmnd, 30);
+        res.status = (ushort)scp->SCp.Status;
+        scsi_release_command(scp);
+        scsi_free_host_dev(sdev);
+#else
+        memset(&sdev,0,sizeof(Scsi_Device));
+        memset(&scp, 0,sizeof(Scsi_Cmnd));
+        sdev.host = scp.host = gdth_ctr_tab[hanum];
+        sdev.id = scp.target = sdev.host->this_id;
+        scp.device = &sdev;
+        gdth_do_cmd(&scp, &cmd, cmnd, 30);
+        res.status = (ushort)scp.SCp.Status;
+#endif
+        if (copy_to_user((char *)arg, &res, sizeof(gdth_ioctl_reset)))
+            return -EFAULT;
+        return 0;
+}
+
+static int ioc_general(unsigned long arg, char *cmnd)
+{
         gdth_ioctl_general gen;
         char *buf = NULL;
         ulong32 paddr; 
         int hanum;
+	gdth_ha_str *ha; 
+#if LINUX_VERSION_CODE >= 0x020503
+	Scsi_Request *srp;
+	Scsi_Device *sdev;
+#elif LINUX_VERSION_CODE >= 0x020322
+	Scsi_Cmnd *scp;
+	Scsi_Device *sdev;
+#else
+	Scsi_Cmnd scp;
+	Scsi_Device sdev;
+#endif
         
         if (copy_from_user(&gen, (char *)arg, sizeof(gdth_ioctl_general)) ||
             gen.ionode >= gdth_ctr_count)
@@ -5070,116 +5137,115 @@
             return -EFAULT;
         }
         gdth_ioctl_free(hanum, gen.data_len+gen.sense_len, buf, paddr);
-        break;
-      }
+        return 0;
+}
  
-      case GDTIOCTL_EVENT:
-      {
-        gdth_ioctl_event evt;
+static int ioc_hdrlist(unsigned long arg, char *cmnd)
+{
+        gdth_ioctl_rescan rsc;
+        gdth_cmd_str cmd;
         gdth_ha_str *ha;
-        ulong flags;
-
-        if (copy_from_user(&evt, (char *)arg, sizeof(gdth_ioctl_event)) ||
-            evt.ionode >= gdth_ctr_count)
-            return -EFAULT;
-        ha = HADATA(gdth_ctr_tab[evt.ionode]);
-
-        if (evt.erase == 0xff) {
-            if (evt.event.event_source == ES_TEST)
-                evt.event.event_data.size=sizeof(evt.event.event_data.eu.test); 
-            else if (evt.event.event_source == ES_DRIVER)
-                evt.event.event_data.size=sizeof(evt.event.event_data.eu.driver); 
-            else if (evt.event.event_source == ES_SYNC)
-                evt.event.event_data.size=sizeof(evt.event.event_data.eu.sync); 
-            else
-                evt.event.event_data.size=sizeof(evt.event.event_data.eu.async);
-            GDTH_LOCK_HA(ha, flags);
-            gdth_store_event(ha, evt.event.event_source, evt.event.event_idx,
-                             &evt.event.event_data);
-            GDTH_UNLOCK_HA(ha, flags);
-        } else if (evt.erase == 0xfe) {
-            gdth_clear_events();
-        } else if (evt.erase == 0) {
-            evt.handle = gdth_read_event(ha, evt.handle, &evt.event);
-        } else {
-            gdth_readapp_event(ha, evt.erase, &evt.event);
-        }     
-        if (copy_to_user((char *)arg, &evt, sizeof(gdth_ioctl_event)))
+        unchar i;
+        int hanum;
+#if LINUX_VERSION_CODE >= 0x020503
+	Scsi_Request *srp;
+	Scsi_Device *sdev;
+#elif LINUX_VERSION_CODE >= 0x020322
+	Scsi_Cmnd *scp;
+	Scsi_Device *sdev;
+#else
+	Scsi_Cmnd scp;
+	Scsi_Device sdev;
+#endif
+        
+        if (copy_from_user(&rsc, (char *)arg, sizeof(gdth_ioctl_rescan)) ||
+            rsc.ionode >= gdth_ctr_count)
             return -EFAULT;
-        break;
-      }
-
-      case GDTIOCTL_LOCKDRV:
-      {
-        gdth_ioctl_lockdrv ldrv;
-        unchar i, j;
+        hanum = rsc.ionode;
+        ha = HADATA(gdth_ctr_tab[hanum]);
+   
+#if LINUX_VERSION_CODE >= 0x020503
+        sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]);
+        srp  = scsi_allocate_request(sdev);
+        if (!srp)
+            return -ENOMEM;
+        srp->sr_cmd_len = 12;
+        srp->sr_use_sg = 0;
+#elif LINUX_VERSION_CODE >= 0x020322
+        sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]);
+        scp  = scsi_allocate_device(sdev, 1, FALSE);
+        if (!scp)
+            return -ENOMEM;
+        scp->cmd_len = 12;
+        scp->use_sg = 0;
+#else
+        memset(&sdev,0,sizeof(Scsi_Device));
+        memset(&scp, 0,sizeof(Scsi_Cmnd));
+        sdev.host = scp.host = gdth_ctr_tab[hanum];
+        sdev.id = scp.target = sdev.host->this_id;
+        scp.device = &sdev;
+#endif
 
-        if (copy_from_user(&ldrv, (char *)arg, sizeof(gdth_ioctl_lockdrv)) ||
-            ldrv.ionode >= gdth_ctr_count)
-            return -EFAULT;
-        ha = HADATA(gdth_ctr_tab[ldrv.ionode]);
- 
-        for (i = 0; i < ldrv.drive_cnt && i < MAX_HDRIVES; ++i) {
-            j = ldrv.drives[i];
-            if (j >= MAX_HDRIVES || !ha->hdr[j].present)
+        for (i = 0; i < MAX_HDRIVES; ++i) { 
+            if (!ha->hdr[i].present) {
+                rsc.hdr_list[i].bus = 0xff; 
                 continue;
-            if (ldrv.lock) {
-                GDTH_LOCK_HA(ha, flags);
-                ha->hdr[j].lock = 1;
-                GDTH_UNLOCK_HA(ha, flags);
-                gdth_wait_completion(ldrv.ionode, ha->bus_cnt, j); 
-                gdth_stop_timeout(ldrv.ionode, ha->bus_cnt, j); 
-            } else {
-                GDTH_LOCK_HA(ha, flags);
-                ha->hdr[j].lock = 0;
-                GDTH_UNLOCK_HA(ha, flags);
-                gdth_start_timeout(ldrv.ionode, ha->bus_cnt, j); 
-                gdth_next(ldrv.ionode); 
+            } 
+            rsc.hdr_list[i].bus = ha->virt_bus;
+            rsc.hdr_list[i].target = i;
+            rsc.hdr_list[i].lun = 0;
+            rsc.hdr_list[i].cluster_type = ha->hdr[i].cluster_type;
+            if (ha->hdr[i].cluster_type & CLUSTER_DRIVE) { 
+                cmd.Service = CACHESERVICE;
+                cmd.OpCode = GDT_CLUST_INFO;
+                cmd.u.cache.DeviceNo = i;
+#if LINUX_VERSION_CODE >= 0x020503
+                gdth_do_req(srp, &cmd, cmnd, 30);
+                if (srp->sr_command->SCp.Status == S_OK)
+                    rsc.hdr_list[i].cluster_type = srp->sr_command->SCp.Message;
+#elif LINUX_VERSION_CODE >= 0x020322
+                gdth_do_cmd(scp, &cmd, cmnd, 30);
+                if (scp->SCp.Status == S_OK)
+                    rsc.hdr_list[i].cluster_type = scp->SCp.Message;
+#else
+                gdth_do_cmd(&scp, &cmd, cmnd, 30);
+                if (scp.SCp.Status == S_OK)
+                    rsc.hdr_list[i].cluster_type = scp.SCp.Message;
+#endif
             }
         } 
-        break;
-      }
-
-      case GDTIOCTL_LOCKCHN:
-      {
-        gdth_ioctl_lockchn lchn;
-        unchar i, j;
-
-        if (copy_from_user(&lchn, (char *)arg, sizeof(gdth_ioctl_lockchn)) ||
-            lchn.ionode >= gdth_ctr_count)
+#if LINUX_VERSION_CODE >= 0x020503
+        scsi_release_request(srp);
+        scsi_free_host_dev(sdev);
+#elif LINUX_VERSION_CODE >= 0x020322
+        scsi_release_command(scp);
+        scsi_free_host_dev(sdev);
+#endif       
+ 
+        if (copy_to_user((char *)arg, &rsc, sizeof(gdth_ioctl_rescan)))
             return -EFAULT;
-        ha = HADATA(gdth_ctr_tab[lchn.ionode]);
-        
-        i = lchn.channel;
-        if (i < ha->bus_cnt) {
-            if (lchn.lock) {
-                GDTH_LOCK_HA(ha, flags);
-                ha->raw[i].lock = 1;
-                GDTH_UNLOCK_HA(ha, flags);
-                for (j = 0; j < ha->tid_cnt; ++j) {
-                    gdth_wait_completion(lchn.ionode, i, j); 
-                    gdth_stop_timeout(lchn.ionode, i, j); 
-                }
-            } else {
-                GDTH_LOCK_HA(ha, flags);
-                ha->raw[i].lock = 0;
-                GDTH_UNLOCK_HA(ha, flags);
-                for (j = 0; j < ha->tid_cnt; ++j) {
-                    gdth_start_timeout(lchn.ionode, i, j); 
-                    gdth_next(lchn.ionode); 
-                }
-            }
-        } 
-        break;
-      }
+        return 0;
+}
 
-      case GDTIOCTL_RESCAN:
-      {
+static int ioc_rescan(unsigned long arg, char *cmnd)
+{
         gdth_ioctl_rescan rsc;
         gdth_cmd_str cmd;
         ushort i, status, hdr_cnt;
         ulong32 info;
         int hanum, cyls, hds, secs;
+	ulong flags;
+	gdth_ha_str *ha; 
+#if LINUX_VERSION_CODE >= 0x020503
+	Scsi_Request *srp;
+	Scsi_Device *sdev;
+#elif LINUX_VERSION_CODE >= 0x020322
+	Scsi_Cmnd *scp;
+	Scsi_Device *sdev;
+#else
+	Scsi_Cmnd scp;
+	Scsi_Device sdev;
+#endif
         
         if (copy_from_user(&rsc, (char *)arg, sizeof(gdth_ioctl_rescan)) ||
             rsc.ionode >= gdth_ctr_count)
@@ -5344,85 +5410,134 @@
  
         if (copy_to_user((char *)arg, &rsc, sizeof(gdth_ioctl_rescan)))
             return -EFAULT;
-        break;
-      }
+        return 0;
+}
   
-      case GDTIOCTL_HDRLIST:
-      {
-        gdth_ioctl_rescan rsc;
-        gdth_cmd_str cmd;
-        gdth_ha_str *ha;
-        unchar i;
-        int hanum;
-        
-        if (copy_from_user(&rsc, (char *)arg, sizeof(gdth_ioctl_rescan)) ||
-            rsc.ionode >= gdth_ctr_count)
-            return -EFAULT;
-        hanum = rsc.ionode;
-        ha = HADATA(gdth_ctr_tab[hanum]);
-   
+static int gdth_ioctl(struct inode *inode, struct file *filep,
+                      unsigned int cmd, unsigned long arg)
+{
+    gdth_ha_str *ha; 
 #if LINUX_VERSION_CODE >= 0x020503
-        sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]);
-        srp  = scsi_allocate_request(sdev);
-        if (!srp)
-            return -ENOMEM;
-        srp->sr_cmd_len = 12;
-        srp->sr_use_sg = 0;
+    Scsi_Cmnd *scp;
+    Scsi_Device *sdev;
 #elif LINUX_VERSION_CODE >= 0x020322
-        sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]);
-        scp  = scsi_allocate_device(sdev, 1, FALSE);
-        if (!scp)
-            return -ENOMEM;
-        scp->cmd_len = 12;
-        scp->use_sg = 0;
+    Scsi_Cmnd *scp;
+    Scsi_Device *sdev;
 #else
-        memset(&sdev,0,sizeof(Scsi_Device));
-        memset(&scp, 0,sizeof(Scsi_Cmnd));
-        sdev.host = scp.host = gdth_ctr_tab[hanum];
-        sdev.id = scp.target = sdev.host->this_id;
-        scp.device = &sdev;
+    Scsi_Cmnd scp;
+    Scsi_Device sdev;
 #endif
+    ulong flags;
+    char cmnd[MAX_COMMAND_SIZE];   
 
-        for (i = 0; i < MAX_HDRIVES; ++i) { 
-            if (!ha->hdr[i].present) {
-                rsc.hdr_list[i].bus = 0xff; 
-                continue;
-            } 
-            rsc.hdr_list[i].bus = ha->virt_bus;
-            rsc.hdr_list[i].target = i;
-            rsc.hdr_list[i].lun = 0;
-            rsc.hdr_list[i].cluster_type = ha->hdr[i].cluster_type;
-            if (ha->hdr[i].cluster_type & CLUSTER_DRIVE) { 
-                cmd.Service = CACHESERVICE;
-                cmd.OpCode = GDT_CLUST_INFO;
-                cmd.u.cache.DeviceNo = i;
-#if LINUX_VERSION_CODE >= 0x020503
-                gdth_do_req(srp, &cmd, cmnd, 30);
-                if (srp->sr_command->SCp.Status == S_OK)
-                    rsc.hdr_list[i].cluster_type = srp->sr_command->SCp.Message;
-#elif LINUX_VERSION_CODE >= 0x020322
-                gdth_do_cmd(scp, &cmd, cmnd, 30);
-                if (scp->SCp.Status == S_OK)
-                    rsc.hdr_list[i].cluster_type = scp->SCp.Message;
-#else
-                gdth_do_cmd(&scp, &cmd, cmnd, 30);
-                if (scp.SCp.Status == S_OK)
-                    rsc.hdr_list[i].cluster_type = scp.SCp.Message;
-#endif
-            }
-        } 
-#if LINUX_VERSION_CODE >= 0x020503
-        scsi_release_request(srp);
-        scsi_free_host_dev(sdev);
-#elif LINUX_VERSION_CODE >= 0x020322
-        scsi_release_command(scp);
-        scsi_free_host_dev(sdev);
-#endif       
+    memset(cmnd, 0xff, 12);
+    
+    TRACE(("gdth_ioctl() cmd 0x%x\n", cmd));
  
-        if (copy_to_user((char *)arg, &rsc, sizeof(gdth_ioctl_rescan)))
+    switch (cmd) {
+      case GDTIOCTL_CTRCNT:
+      { 
+        int cnt = gdth_ctr_count;
+        put_user(cnt, (int *)arg);
+        break;
+      }
+
+      case GDTIOCTL_DRVERS:
+      { 
+        int ver = (GDTH_VERSION<<8) | GDTH_SUBVERSION;
+        put_user(ver, (int *)arg);
+        break;
+      }
+      
+      case GDTIOCTL_OSVERS:
+      { 
+        gdth_ioctl_osvers osv; 
+
+        osv.version = (unchar)(LINUX_VERSION_CODE >> 16);
+        osv.subversion = (unchar)(LINUX_VERSION_CODE >> 8);
+        osv.revision = (ushort)(LINUX_VERSION_CODE & 0xff);
+        copy_to_user((char *)arg, &osv, sizeof(gdth_ioctl_osvers));
+        break;
+      }
+
+      case GDTIOCTL_CTRTYPE:
+      { 
+        gdth_ioctl_ctrtype ctrt;
+        
+        if (copy_from_user(&ctrt, (char *)arg, sizeof(gdth_ioctl_ctrtype)) ||
+            ctrt.ionode >= gdth_ctr_count)
+            return -EFAULT;
+        ha = HADATA(gdth_ctr_tab[ctrt.ionode]);
+        if (ha->type == GDT_ISA || ha->type == GDT_EISA) {
+            ctrt.type = (unchar)((ha->stype>>20) - 0x10);
+        } else {
+            if (ha->type != GDT_PCIMPR) {
+                ctrt.type = (unchar)((ha->stype<<4) + 6);
+            } else {
+                ctrt.type = 
+                    (ha->oem_id == OEM_ID_INTEL ? 0xfd : 0xfe);
+                if (ha->stype >= 0x300)
+                    ctrt.ext_type = 0x6000 | ha->subdevice_id;
+                else 
+                    ctrt.ext_type = 0x6000 | ha->stype;
+            }
+            ctrt.device_id = ha->stype;
+            ctrt.sub_device_id = ha->subdevice_id;
+        }
+        ctrt.info = ha->brd_phys;
+        ctrt.oem_id = ha->oem_id;
+        if (copy_to_user((char *)arg, &ctrt, sizeof(gdth_ioctl_ctrtype)))
             return -EFAULT;
         break;
       }
+        
+      case GDTIOCTL_GENERAL:
+	return ioc_general(arg, cmnd);
+
+      case GDTIOCTL_EVENT:
+	return ioc_event(arg);
+
+      case GDTIOCTL_LOCKDRV:
+	return ioc_lockdrv(arg);
+
+      case GDTIOCTL_LOCKCHN:
+      {
+        gdth_ioctl_lockchn lchn;
+        unchar i, j;
+
+        if (copy_from_user(&lchn, (char *)arg, sizeof(gdth_ioctl_lockchn)) ||
+            lchn.ionode >= gdth_ctr_count)
+            return -EFAULT;
+        ha = HADATA(gdth_ctr_tab[lchn.ionode]);
+        
+        i = lchn.channel;
+        if (i < ha->bus_cnt) {
+            if (lchn.lock) {
+                GDTH_LOCK_HA(ha, flags);
+                ha->raw[i].lock = 1;
+                GDTH_UNLOCK_HA(ha, flags);
+                for (j = 0; j < ha->tid_cnt; ++j) {
+                    gdth_wait_completion(lchn.ionode, i, j); 
+                    gdth_stop_timeout(lchn.ionode, i, j); 
+                }
+            } else {
+                GDTH_LOCK_HA(ha, flags);
+                ha->raw[i].lock = 0;
+                GDTH_UNLOCK_HA(ha, flags);
+                for (j = 0; j < ha->tid_cnt; ++j) {
+                    gdth_start_timeout(lchn.ionode, i, j); 
+                    gdth_next(lchn.ionode); 
+                }
+            }
+        } 
+        break;
+      }
+
+      case GDTIOCTL_RESCAN:
+	return ioc_rescan(arg, cmnd);
+
+      case GDTIOCTL_HDRLIST:
+	return ioc_hdrlist(arg, cmnd);
 
       case GDTIOCTL_RESET_BUS:
       {
@@ -5481,57 +5596,7 @@
       }
 
       case GDTIOCTL_RESET_DRV:
-      {
-        gdth_ioctl_reset res;
-        gdth_cmd_str cmd;
-        int hanum;
-
-        if (copy_from_user(&res, (char *)arg, sizeof(gdth_ioctl_reset)) ||
-            res.ionode >= gdth_ctr_count || res.number >= MAX_HDRIVES)
-            return -EFAULT;
-        hanum = res.ionode;
-        ha = HADATA(gdth_ctr_tab[hanum]);
- 
-        if (!ha->hdr[res.number].present)
-            return 0;
-        cmd.Service = CACHESERVICE;
-        cmd.OpCode = GDT_CLUST_RESET;
-        cmd.u.cache.DeviceNo = res.number;
-#if LINUX_VERSION_CODE >= 0x020503
-        sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]);
-        srp  = scsi_allocate_request(sdev);
-        if (!srp)
-            return -ENOMEM;
-        srp->sr_cmd_len = 12;
-        srp->sr_use_sg = 0;
-        gdth_do_req(srp, &cmd, cmnd, 30);
-        res.status = (ushort)srp->sr_command->SCp.Status;
-        scsi_release_request(srp);
-        scsi_free_host_dev(sdev);
-#elif LINUX_VERSION_CODE >= 0x020322
-        sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]);
-        scp  = scsi_allocate_device(sdev, 1, FALSE);
-        if (!scp)
-            return -ENOMEM;
-        scp->cmd_len = 12;
-        scp->use_sg = 0;
-        gdth_do_cmd(scp, &cmd, cmnd, 30);
-        res.status = (ushort)scp->SCp.Status;
-        scsi_release_command(scp);
-        scsi_free_host_dev(sdev);
-#else
-        memset(&sdev,0,sizeof(Scsi_Device));
-        memset(&scp, 0,sizeof(Scsi_Cmnd));
-        sdev.host = scp.host = gdth_ctr_tab[hanum];
-        sdev.id = scp.target = sdev.host->this_id;
-        scp.device = &sdev;
-        gdth_do_cmd(&scp, &cmd, cmnd, 30);
-        res.status = (ushort)scp.SCp.Status;
-#endif
-        if (copy_to_user((char *)arg, &res, sizeof(gdth_ioctl_reset)))
-            return -EFAULT;
-        break;
-      }
+	return ioc_resetdrv(arg, cmnd);
 
       default:
         break; 
diff -Nru a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c
--- a/drivers/scsi/gdth_proc.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/scsi/gdth_proc.c	Wed Apr 30 22:28:09 2003
@@ -1471,7 +1471,10 @@
         ret_val = NULL;
     } else {
 #if LINUX_VERSION_CODE >= 0x020400
-        ret_val = pci_alloc_consistent(ha->pdev, size, paddr);
+	dma_addr_t dma_addr;
+
+        ret_val = pci_alloc_consistent(ha->pdev, size, &dma_addr);
+	*paddr = (ulong32)dma_addr;
 #else
         ret_val = scsi_init_malloc(size, GFP_ATOMIC | GFP_DMA);
         if (ret_val)
diff -Nru a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
--- a/drivers/scsi/hosts.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/scsi/hosts.c	Wed Apr 30 22:28:04 2003
@@ -294,7 +294,6 @@
 			sht->info ? sht->info(shost) : sht->name);
 
 	if (dev) {
-		dev->class_data = shost;
 		shost->host_gendev = dev;
 	}
 
diff -Nru a/drivers/scsi/hosts.h b/drivers/scsi/hosts.h
--- a/drivers/scsi/hosts.h	Wed Apr 30 22:28:07 2003
+++ b/drivers/scsi/hosts.h	Wed Apr 30 22:28:07 2003
@@ -495,7 +495,7 @@
         __attribute__ ((aligned (sizeof(unsigned long))));
 };
 
-#define	to_scsi_host(d)	d->class_data
+#define	to_scsi_host(d)	d->driver_data	/* Major logical breakage, but we compile again... */
 	
 /*
  * These two functions are used to allocate and free a pseudo device
@@ -607,7 +607,7 @@
 extern int scsi_upper_driver_register(struct Scsi_Device_Template *);
 extern void scsi_upper_driver_unregister(struct Scsi_Device_Template *);
 
-extern struct device_class shost_devclass;
+extern struct class shost_class;
 
 #endif
 /*
diff -Nru a/drivers/scsi/ibmmca.c b/drivers/scsi/ibmmca.c
--- a/drivers/scsi/ibmmca.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/scsi/ibmmca.c	Wed Apr 30 22:28:04 2003
@@ -477,7 +477,6 @@
 static char ibm_ansi_order = 0;
 #endif
 
-static void interrupt_handler(int, void *, struct pt_regs *);
 static void issue_cmd(int, unsigned long, unsigned char);
 static void internal_done(Scsi_Cmnd * cmd);
 static void check_devices(int, int);
@@ -501,7 +500,8 @@
 static int ldn_access_load(int, int);
 static int ldn_access_total_read_write(int);
 
-static void interrupt_handler(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t interrupt_handler(int irq, void *dev_id,
+					struct pt_regs *regs)
 {
 	int host_index, ihost_index;
 	unsigned int intr_reg;
@@ -517,7 +517,7 @@
 	/* return if some other device on this IRQ caused the interrupt */
 	if (!hosts[host_index]) {
 		spin_unlock(dev->host_lock);
-		return;
+		return IRQ_NONE;
 	}
 
 	/* the reset-function already did all the job, even ints got
@@ -525,7 +525,7 @@
 	if ((reset_status(host_index) == IM_RESET_NOT_IN_PROGRESS_NO_INT) || (reset_status(host_index) == IM_RESET_FINISHED_OK_NO_INT)) {
 		reset_status(host_index) = IM_RESET_NOT_IN_PROGRESS;
 		spin_unlock(dev->host_lock);
-		return;
+		return IRQ_HANDLED;
 	}
 
 	/*must wait for attention reg not busy, then send EOI to subsystem */
@@ -612,7 +612,7 @@
 		reset_status(ihost_index) = IM_RESET_FINISHED_OK;
 		last_scsi_command(ihost_index)[ldn] = NO_SCSI;
 		spin_unlock(dev->host_lock);
-		return;
+		return IRQ_HANDLED;
 	}
 	/* handling of commands coming from upper level of scsi driver */
 	if (last_scsi_type(ihost_index)[ldn] == IM_IMM_CMD) {
@@ -632,7 +632,7 @@
 			last_scsi_command(ihost_index)[ldn] = NO_SCSI;
 			last_scsi_type(ihost_index)[ldn] = 0;
 			spin_unlock(dev->host_lock);
-			return;
+			return IRQ_HANDLED;
 		} else if (last_scsi_command(ihost_index)[ldn] == IM_ABORT_IMM_CMD) {
 			/* react on SCSI abort command */
 #ifdef IM_DEBUG_PROBE
@@ -652,7 +652,7 @@
 			if (cmd->scsi_done)
 				(cmd->scsi_done) (cmd);	/* should be the internal_done */
 			spin_unlock(dev->host_lock);
-			return;
+			return IRQ_HANDLED;
 		} else {
 			disk_rw_in_progress = 0;
 			PS2_DISK_LED_OFF();
@@ -660,7 +660,7 @@
 			stat_result(ihost_index) = cmd_result;
 			last_scsi_command(ihost_index)[ldn] = NO_SCSI;
 			spin_unlock(dev->host_lock);
-			return;
+			return IRQ_HANDLED;
 		}
 	}
 	last_scsi_command(ihost_index)[ldn] = NO_SCSI;
@@ -671,7 +671,7 @@
 	if (cmd) {
 		if ((cmd->target == TIMEOUT_PUN) && (cmd->device->lun == TIMEOUT_LUN)) {
 			printk("IBM MCA SCSI: Ignoring interrupt from pun=%x, lun=%x.\n", cmd->target, cmd->device->lun);
-			return;
+			return IRQ_HANDLED;
 		}
 	}
 #endif
@@ -679,7 +679,7 @@
 	if (!cmd)
 	{
 		spin_unlock(dev->host_lock);
-		return;
+		return IRQ_HANDLED;
 	}
 
 #ifdef IM_DEBUG_INT
@@ -710,7 +710,7 @@
 	if (cmd->scsi_done)
 		(cmd->scsi_done) (cmd);
 	spin_unlock(dev->host_lock);
-	return;
+	return IRQ_HANDLED;
 }
 
 static void issue_cmd(int host_index, unsigned long cmd_reg, unsigned char attn_reg)
diff -Nru a/drivers/scsi/in2000.c b/drivers/scsi/in2000.c
--- a/drivers/scsi/in2000.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/scsi/in2000.c	Wed Apr 30 22:28:13 2003
@@ -832,7 +832,7 @@
  * but it _does_ need to be able to compile and run in an SMP kernel.)
  */
 
-static void in2000_intr(int irqnum, void *dev_id, struct pt_regs *ptregs)
+static irqreturn_t in2000_intr(int irqnum, void *dev_id, struct pt_regs *ptregs)
 {
 	struct Scsi_Host *instance = dev_id;
 	struct IN2000_hostdata *hostdata;
@@ -986,7 +986,7 @@
 
 /* release the SMP spin_lock and restore irq state */
 		spin_unlock_irqrestore(instance->host_lock, flags);
-		return;
+		return IRQ_HANDLED;
 	}
 
 /* This interrupt was triggered by the WD33c93 chip. The fifo interrupt
@@ -1004,7 +1004,7 @@
 
 /* release the SMP spin_lock and restore irq state */
 		spin_unlock_irqrestore(instance->host_lock, flags);
-		return;
+		return IRQ_HANDLED;
 	}
 
 	DB(DB_INTR, printk("{%02x:%02x-", asr, sr))
@@ -1416,7 +1416,7 @@
 
 /* release the SMP spin_lock and restore irq state */
 			spin_unlock_irqrestore(instance->host_lock, flags);
-			return;
+			return IRQ_HANDLED;
 		}
 		DB(DB_INTR, printk("UNEXP_DISC-%ld", cmd->pid))
 		    hostdata->connected = NULL;
@@ -1589,7 +1589,7 @@
 
 /* release the SMP spin_lock and restore irq state */
 	    spin_unlock_irqrestore(instance->host_lock, flags);
-
+	return IRQ_HANDLED;
 }
 
 
@@ -1910,7 +1910,7 @@
 	unsigned short base;
 	uchar switches;
 	uchar hrev;
-	int flags;
+	unsigned long flags;
 	int val;
 	char buf[32];
 
diff -Nru a/drivers/scsi/ini9100u.c b/drivers/scsi/ini9100u.c
--- a/drivers/scsi/ini9100u.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/scsi/ini9100u.c	Wed Apr 30 22:28:06 2003
@@ -166,14 +166,14 @@
 
 static char *setup_str = (char *) NULL;
 
-static void i91u_intr0(int irq, void *dev_id, struct pt_regs *);
-static void i91u_intr1(int irq, void *dev_id, struct pt_regs *);
-static void i91u_intr2(int irq, void *dev_id, struct pt_regs *);
-static void i91u_intr3(int irq, void *dev_id, struct pt_regs *);
-static void i91u_intr4(int irq, void *dev_id, struct pt_regs *);
-static void i91u_intr5(int irq, void *dev_id, struct pt_regs *);
-static void i91u_intr6(int irq, void *dev_id, struct pt_regs *);
-static void i91u_intr7(int irq, void *dev_id, struct pt_regs *);
+static irqreturn_t i91u_intr0(int irq, void *dev_id, struct pt_regs *);
+static irqreturn_t i91u_intr1(int irq, void *dev_id, struct pt_regs *);
+static irqreturn_t i91u_intr2(int irq, void *dev_id, struct pt_regs *);
+static irqreturn_t i91u_intr3(int irq, void *dev_id, struct pt_regs *);
+static irqreturn_t i91u_intr4(int irq, void *dev_id, struct pt_regs *);
+static irqreturn_t i91u_intr5(int irq, void *dev_id, struct pt_regs *);
+static irqreturn_t i91u_intr6(int irq, void *dev_id, struct pt_regs *);
+static irqreturn_t i91u_intr7(int irq, void *dev_id, struct pt_regs *);
 
 static void i91u_panic(char *msg);
 
@@ -697,124 +697,132 @@
 /*
  * Interrupts handler (main routine of the driver)
  */
-static void i91u_intr0(int irqno, void *dev_id, struct pt_regs *regs)
+static irqreturn_t i91u_intr0(int irqno, void *dev_id, struct pt_regs *regs)
 {
 	unsigned long flags;
 	struct Scsi_Host *dev = dev_id;
 	
 	if (tul_hcs[0].HCS_Intr != irqno)
-		return;
+		return IRQ_NONE;
 
 	spin_lock_irqsave(dev->host_lock, flags);
 
 	tul_isr(&tul_hcs[0]);
 
 	spin_unlock_irqrestore(dev->host_lock, flags);
+	return IRQ_HANDLED;
 }
 
-static void i91u_intr1(int irqno, void *dev_id, struct pt_regs *regs)
+static irqreturn_t i91u_intr1(int irqno, void *dev_id, struct pt_regs *regs)
 {
 	unsigned long flags;
 	struct Scsi_Host *dev = dev_id;
 	
 	if (tul_hcs[1].HCS_Intr != irqno)
-		return;
+		return IRQ_NONE;
 
 	spin_lock_irqsave(dev->host_lock, flags);
 
 	tul_isr(&tul_hcs[1]);
 
 	spin_unlock_irqrestore(dev->host_lock, flags);
+	return IRQ_HANDLED;
 }
 
-static void i91u_intr2(int irqno, void *dev_id, struct pt_regs *regs)
+static irqreturn_t i91u_intr2(int irqno, void *dev_id, struct pt_regs *regs)
 {
 	unsigned long flags;
 	struct Scsi_Host *dev = dev_id;
 	
 	if (tul_hcs[2].HCS_Intr != irqno)
-		return;
+		return IRQ_NONE;
 
 	spin_lock_irqsave(dev->host_lock, flags);
 
 	tul_isr(&tul_hcs[2]);
 
 	spin_unlock_irqrestore(dev->host_lock, flags);
+	return IRQ_HANDLED;
 }
 
-static void i91u_intr3(int irqno, void *dev_id, struct pt_regs *regs)
+static irqreturn_t i91u_intr3(int irqno, void *dev_id, struct pt_regs *regs)
 {
 	unsigned long flags;
 	struct Scsi_Host *dev = dev_id;
 	
 	if (tul_hcs[3].HCS_Intr != irqno)
-		return;
+		return IRQ_NONE;
 
 	spin_lock_irqsave(dev->host_lock, flags);
 
 	tul_isr(&tul_hcs[3]);
 
 	spin_unlock_irqrestore(dev->host_lock, flags);
+	return IRQ_HANDLED;
 }
 
-static void i91u_intr4(int irqno, void *dev_id, struct pt_regs *regs)
+static irqreturn_t i91u_intr4(int irqno, void *dev_id, struct pt_regs *regs)
 {
 	unsigned long flags;
 	struct Scsi_Host *dev = dev_id;
 	
 	if (tul_hcs[4].HCS_Intr != irqno)
-		return;
+		return IRQ_NONE;
 
 	spin_lock_irqsave(dev->host_lock, flags);
 
 	tul_isr(&tul_hcs[4]);
 
 	spin_unlock_irqrestore(dev->host_lock, flags);
+	return IRQ_HANDLED;
 }
 
-static void i91u_intr5(int irqno, void *dev_id, struct pt_regs *regs)
+static irqreturn_t i91u_intr5(int irqno, void *dev_id, struct pt_regs *regs)
 {
 	unsigned long flags;
 	struct Scsi_Host *dev = dev_id;
 	
 	if (tul_hcs[5].HCS_Intr != irqno)
-		return;
+		return IRQ_NONE;
 
 	spin_lock_irqsave(dev->host_lock, flags);
 
 	tul_isr(&tul_hcs[5]);
 
 	spin_unlock_irqrestore(dev->host_lock, flags);
+	return IRQ_HANDLED;
 }
-
-static void i91u_intr6(int irqno, void *dev_id, struct pt_regs *regs)
+	
+static irqreturn_t i91u_intr6(int irqno, void *dev_id, struct pt_regs *regs)
 {
 	unsigned long flags;
 	struct Scsi_Host *dev = dev_id;
 	
 	if (tul_hcs[6].HCS_Intr != irqno)
-		return;
+		return IRQ_NONE;
 
 	spin_lock_irqsave(dev->host_lock, flags);
 
 	tul_isr(&tul_hcs[6]);
 
 	spin_unlock_irqrestore(dev->host_lock, flags);
+	return IRQ_HANDLED;
 }
 
-static void i91u_intr7(int irqno, void *dev_id, struct pt_regs *regs)
+static irqreturn_t i91u_intr7(int irqno, void *dev_id, struct pt_regs *regs)
 {
 	unsigned long flags;
 	struct Scsi_Host *dev = dev_id;
 	
 	if (tul_hcs[7].HCS_Intr != irqno)
-		return;
+		return IRQ_NONE;
 
 	spin_lock_irqsave(dev->host_lock, flags);
 
 	tul_isr(&tul_hcs[7]);
 
 	spin_unlock_irqrestore(dev->host_lock, flags);
+	return IRQ_HANDLED;
 }
 
 /* 
diff -Nru a/drivers/scsi/inia100.c b/drivers/scsi/inia100.c
--- a/drivers/scsi/inia100.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/scsi/inia100.c	Wed Apr 30 22:28:07 2003
@@ -108,7 +108,7 @@
 #define NUMBER(arr)     (sizeof(arr) / sizeof(arr[0]))
 static char *setup_str = (char *) NULL;
 
-static void inia100_intr(int, void *, struct pt_regs *);
+static irqreturn_t inia100_intr(int, void *, struct pt_regs *);
 static void inia100_panic(char *msg);
 
 /* ---- EXTERNAL FUNCTIONS ---- */
@@ -659,7 +659,7 @@
 /*
  * Interrupt handler (main routine of the driver)
  */
-static void inia100_intr(int irqno, void *devid, struct pt_regs *regs)
+static irqreturn_t inia100_intr(int irqno, void *devid, struct pt_regs *regs)
 {
 	struct Scsi_Host *host = (struct Scsi_Host *)devid;
 	ORC_HCS *pHcb;
@@ -669,6 +669,7 @@
 	spin_lock_irqsave(host->host_lock, flags);
 	orc_interrupt(pHcb);
 	spin_unlock_irqrestore(host->host_lock, flags);
+	return IRQ_HANDLED;
 }
 
 /* 
diff -Nru a/drivers/scsi/ips.c b/drivers/scsi/ips.c
--- a/drivers/scsi/ips.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/scsi/ips.c	Wed Apr 30 22:28:03 2003
@@ -375,7 +375,7 @@
 int ips_eh_reset(Scsi_Cmnd *);
 int ips_queue(Scsi_Cmnd *, void (*) (Scsi_Cmnd *));
 const char * ips_info(struct Scsi_Host *);
-void do_ipsintr(int, void *, struct pt_regs *);
+irqreturn_t do_ipsintr(int, void *, struct pt_regs *);
 static int ips_hainit(ips_ha_t *);
 static int ips_map_status(ips_ha_t *, ips_scb_t *, ips_stat_t *);
 static int ips_send_wait(ips_ha_t *, ips_scb_t *, int, int);
@@ -1264,7 +1264,7 @@
 /*   Wrapper for the interrupt handler                                      */
 /*                                                                          */
 /****************************************************************************/
-void
+irqreturn_t
 do_ipsintr(int irq, void *dev_id, struct pt_regs *regs) {
    ips_ha_t         *ha;
    unsigned long     cpu_flags;
@@ -1274,19 +1274,19 @@
 
    ha = (ips_ha_t *) dev_id;
    if (!ha) 
-      return;
+      return IRQ_NONE;
    host = ips_sh[ha->host_num];
    /* interrupt during initialization */
    if(!host){
       (*ha->func.intr)(ha);
-      return;
+      return IRQ_HANDLED;
    }
 
    IPS_LOCK_SAVE(host->host_lock, cpu_flags);
 
    if (!ha->active) {
       IPS_UNLOCK_RESTORE(host->host_lock, cpu_flags);
-      return;
+      return IRQ_HANDLED;
    }
 
    (*ha->func.intr)(ha);
@@ -1295,6 +1295,7 @@
 
    /* start the next command */
    ips_next(ha, IPS_INTR_ON);
+   return IRQ_HANDLED;
 }
 
 /****************************************************************************/
diff -Nru a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c
--- a/drivers/scsi/mac_scsi.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/scsi/mac_scsi.c	Wed Apr 30 22:28:04 2003
@@ -253,16 +253,16 @@
 
     ((struct NCR5380_hostdata *)instance->hostdata)->ctrl = 0;
 
-    if (instance->irq != IRQ_NONE)
+    if (instance->irq != SCSI_IRQ_NONE)
 	if (request_irq(instance->irq, NCR5380_intr, IRQ_FLG_SLOW, 
 		"ncr5380", NCR5380_intr)) {
 	    printk(KERN_WARNING "scsi%d: IRQ%d not free, interrupts disabled\n",
 		   instance->host_no, instance->irq);
-	    instance->irq = IRQ_NONE;
+	    instance->irq = SCSI_IRQ_NONE;
 	}
 
     printk(KERN_INFO "scsi%d: generic 5380 at port %lX irq", instance->host_no, instance->io_port);
-    if (instance->irq == IRQ_NONE)
+    if (instance->irq == SCSI_IRQ_NONE)
 	printk (KERN_INFO "s disabled");
     else
 	printk (KERN_INFO " %d", instance->irq);
@@ -277,7 +277,7 @@
 
 int macscsi_release (struct Scsi_Host *shpnt)
 {
-	if (shpnt->irq != IRQ_NONE)
+	if (shpnt->irq != SCSI_IRQ_NONE)
 		free_irq (shpnt->irq, NCR5380_intr);
 
 	return 0;
diff -Nru a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
--- a/drivers/scsi/megaraid.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/scsi/megaraid.c	Wed Apr 30 22:28:03 2003
@@ -1,4077 +1,3843 @@
-/*===================================================================
- *
- *                    Linux MegaRAID device driver
- *
- * Copyright 2001  American Megatrends Inc.
- *
- *              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; either version
- *              2 of the License, or (at your option) any later version.
- *
- * Version : v1.18 (Oct 11, 2001)
- *
- * Description: Linux device driver for LSI Logic MegaRAID controller
- *
- * Supported controllers: MegaRAID 418, 428, 438, 466, 762, 467, 471, 490
- *                                      493.
- * History:
- *
- * Version 0.90:
- *     Original source contributed by Dell; integrated it into the kernel and
- *     cleaned up some things.  Added support for 438/466 controllers.
- * Version 0.91:
- *     Aligned mailbox area on 16-byte boundary.
- *     Added schedule() at the end to properly clean up.
- *     Made improvements for conformity to linux driver standards.
- *
- * Version 0.92:
- *     Added support for 2.1 kernels.
- *         Reads from pci_dev struct, so it's not dependent on pcibios.
- *         Added some missing virt_to_bus() translations.
- *     Added support for SMP.
- *         Changed global cli()'s to spinlocks for 2.1, and simulated
- *          spinlocks for 2.0.
- *     Removed setting of SA_INTERRUPT flag when requesting Irq.
- *
- * Version 0.92ac:
- *     Small changes to the comments/formatting. Plus a couple of
- *      added notes. Returned to the authors. No actual code changes
- *      save printk levels.
- *     8 Oct 98        Alan Cox <alan.cox@linux.org>
- *
- *     Merged with 2.1.131 source tree.
- *     12 Dec 98       K. Baranowski <kgb@knm.org.pl>
- *
- * Version 0.93:
- *     Added support for vendor specific ioctl commands (M_RD_IOCTL_CMD+xxh)
- *     Changed some fields in MEGARAID struct to better values.
- *     Added signature check for Rp controllers under 2.0 kernels
- *     Changed busy-wait loop to be time-based
- *     Fixed SMP race condition in isr
- *     Added kfree (sgList) on release
- *     Added #include linux/version.h to megaraid.h for hosts.h
- *     Changed max_id to represent max logical drives instead of targets.
- *
- * Version 0.94:
- *     Got rid of some excess locking/unlocking
- *     Fixed slight memory corruption problem while memcpy'ing into mailbox
- *     Changed logical drives to be reported as luns rather than targets
- *     Changed max_id to 16 since it is now max targets/chan again.
- *     Improved ioctl interface for upcoming megamgr
- *
- * Version 0.95:
- *     Fixed problem of queueing multiple commands to adapter;
- *       still has some strange problems on some setups, so still
- *       defaults to single.  To enable parallel commands change
- *       #define MULTI_IO in megaraid.h
- *     Changed kmalloc allocation to be done in beginning.
- *     Got rid of C++ style comments
- *
- * Version 0.96:
- *     762 fully supported.
- *
- * Version 0.97:
- *     Changed megaraid_command to use wait_queue.
- *
- * Version 1.00:
- *     Checks to see if an irq occurred while in isr, and runs through
- *       routine again.
- *     Copies mailbox to temp area before processing in isr
- *     Added barrier() in busy wait to fix volatility bug
- *     Uses separate list for freed Scbs, keeps track of cmd state
- *     Put spinlocks around entire queue function for now...
- *     Full multi-io commands working stablely without previous problems
- *     Added skipXX LILO option for Madrona motherboard support
- *
- * Version 1.01:
- *     Fixed bug in mega_cmd_done() for megamgr control commands,
- *       the host_byte in the result code from the scsi request to
- *       scsi midlayer is set to DID_BAD_TARGET when adapter's
- *       returned codes are 0xF0 and 0xF4.
- *
- * Version 1.02:
- *     Fixed the tape drive bug by extending the adapter timeout value
- *       for passthrough command to 60 seconds in mega_build_cmd().
- *
- * Version 1.03:
- *    Fixed Madrona support.
- *    Changed the adapter timeout value from 60 sec in 1.02 to 10 min
- *      for bigger and slower tape drive.
- *    Added driver version printout at driver loadup time
- *
- * Version 1.04
- *    Added code for 40 ld FW support.
- *    Added new ioctl command 0x81 to support NEW_READ/WRITE_CONFIG with
- *      data area greater than 4 KB, which is the upper bound for data
- *      tranfer through scsi_ioctl interface.
- *    The additional 32 bit field for 64bit address in the newly defined
- *      mailbox64 structure is set to 0 at this point.
- *
- * Version 1.05
- *    Changed the queing implementation for handling SCBs and completed
- *      commands.
- *    Added spinlocks in the interrupt service routine to enable the driver
- *      function in the SMP environment.
- *    Fixed the problem of unnecessary aborts in the abort entry point, which
- *      also enables the driver to handle large amount of I/O requests for
- *      long duration of time.
- * Version 1.06
- *              Intel Release
- * Version 1.07
- *    Removed the usage of uaccess.h file for kernel versions less than
- *    2.0.36, as this file is not present in those versions.
- *
- * Version 108
- *    Modified mega_ioctl so that 40LD megamanager would run
- *    Made some changes for 2.3.XX compilation , esp wait structures
- *    Code merge between 1.05 and 1.06 .
- *    Bug fixed problem with ioctl interface for concurrency between
- *    8ld and 40ld firwmare
- *    Removed the flawed semaphore logic for handling new config command
- *    Added support for building own scatter / gather list for big user
- *    mode buffers
- *    Added /proc file system support ,so that information is available in
- *    human readable format
- *
- * Version 1a08
- *    Changes for IA64 kernels. Checked for CONFIG_PROC_FS flag
- *
- * Version 1b08
- *    Include file changes.
- * Version 1b08b
- *    Change PCI ID value for the 471 card, use #defines when searching
- *    for megaraid cards.
- *
- * Version 1.10
- *
- *      I) Changes made to make following ioctl commands work in 0x81 interface
- *              a)DCMD_DELETE_LOGDRV
- *              b)DCMD_GET_DISK_CONFIG
- *              c)DCMD_DELETE_DRIVEGROUP
- *              d)NC_SUBOP_ENQUIRY3
- *              e)DCMD_CHANGE_LDNO
- *              f)DCMD_CHANGE_LOOPID
- *              g)DCMD_FC_READ_NVRAM_CONFIG
- *      h)DCMD_WRITE_CONFIG
- *      II) Added mega_build_kernel_sg function
- *  III)Firmware flashing option added
- *
- * Version 1.10a
- *
- *      I)Dell updates included in the source code.
- *              Note:   This change is not tested due to the unavailability of IA64 kernel
- *      and it is in the #ifdef DELL_MODIFICATION macro which is not defined
- *
- * Version 1.10b
- *
- *      I)In M_RD_IOCTL_CMD_NEW command the wrong way of copying the data
- *    to the user address corrected
- *
- * Version 1.10c
- *
- *      I) DCMD_GET_DISK_CONFIG opcode updated for the firmware changes.
- *
- * Version 1.11
- *      I)  Version number changed from 1.10c to 1.11
- *  II) DCMD_WRITE_CONFIG(0x0D) command in the driver changed from
- *      scatter/gather list mode to direct pointer mode..
- *     Fixed bug of undesirably detecting HP onboard controllers which
- *       are disabled.
- *
- *      Version 1.12 (Sep 21, 2000)
- *
- *     I. Changes have been made for Dynamic DMA mapping in IA64 platform.
- *                To enable all these changes define M_RD_DYNAMIC_DMA_SUPPORT in megaraid.h
- *        II. Got rid of windows mode comments
- *       III. Removed unwanted code segments
- *    IV. Fixed bug of HP onboard controller information (commented with
- *                 MEGA_HP_FIX)
- *
- *      Version 1a12
- *      I.      reboot notifier and new ioctl changes ported from 1c09
- *
- *      Version 1b12
- *      I.      Changes in new ioctl interface routines ( Nov 06, 2000 )
- *
- *      Version 1c12
- *      I.      Changes in new ioctl interface routines ( Nov 07, 2000 )
- *
- *      Version 1d12
- *      I.      Compilation error under kernel 2.4.0 for 32-bit machine in mega_ioctl
- *
- *      Version 1e12, 1f12
- *      1.  Fixes for pci_map_single, pci_alloc_consistent along with mailbox
- *          alignment
- *
- *	Version 1.13beta
- *	Added Support for Full 64bit address space support. If firmware
- *	supports 64bit, it goes to 64 bit mode even on x86 32bit 
- *	systems. Data Corruption Issues while running on test9 kernel
- *	on IA64 systems. This issue not seen on test11 on x86 system
- *
- *	Version 1.13c
- *	1. Resolved Memory Leak when using M_RD_IOCTL_CMD interface
- *	2. Resolved Queuing problem when MailBox Blocks
- *	3. Added unregister_reboot_notifier support
- * 
- *	Version 1.13d
- *	Experimental changes in interfacing with the controller in ISR
- *
- *	Version 1.13e
- *	Fixed Broken 2.2.XX compilation changes + misc changes
- *
- *	Version 1.13f to 1.13i
- *	misc changes + code clean up
- *	Cleaned up the ioctl code and added set_mbox_xfer_addr()
- *	Support for START_DEV (6)
- * 	
- *	Version 1.13j
- *	Moved some code to megaraid.h file, replaced some hard coded values 
- *      with respective macros. Changed some functions to static
- *
- *	Version 1.13k
- *	Only some idendation correction to 1.13j 
- *
- *	Version 1.13l , 1.13m, 1.13n, 1.13o
- *	Minor Identation changes + misc changes
- *
- *	Version 1.13q
- *	Paded the new uioctl_t MIMD structure for maintaining alignment 
- *	and size across 32 / 64 bit platforms
- *	Changed the way MIMD IOCTL interface used virt_to_bus() to use pci
- *	memory location
- *
- *	Version 1.13r
- *	2.4.xx SCSI Changes.
- *
- *	Version 1.13s
- *	Stats counter fixes
- *	Temporary fix for some 64 bit firmwares in 2.4.XX kernels
- *
- *	Version	1.13t
- *	Support for 64bit version of READ/WRITE/VIEW DISK CONFIG
- *
- *	Version 1.14
- *	Did away with MEGADEV_IOCTL flag. It is now standard part of driver
- *	without need for a special #define flag
- *	Disabled old scsi ioctl path for kernel versions > 2.3.xx. This is due
- *	to the nature in which the new scsi code queues a new scsi command to 
- *	controller during SCSI IO Completion
- *	Driver now checks for sub-system vendor id before taking ownership of
- *	the controller
- *
- *	Version 1.14a
- *	Added Host re-ordering
- *
- *	Version 1.14b
- *	Corrected some issue which caused the older cards not to work
- *	
- *	Version 1.14c
- *	IOCTL changes for not handling the non-64bit firmwares under 2.4.XX
- *	kernel
- *
- *	Version 1.14d
- *	Fixed Various MIMD Synchronization Issues
- *	
- *	Version 1.14e
- *	Fixed the error handling during card initialization
- *
- *	Version 1.14f
- *	Multiple invocations of mimd phase I ioctl stalls the cpu. Replaced
- *	spinlock with semaphore(mutex)
- *
- *	Version 1.14g
- *	Fixed running out of scbs issues while running MIMD apps under heavy IO
- *
- *	Version 1.14g-ac - 02/03/01
- *	Reformatted to Linux format so I could compare to old one and cross
- *	check bug fixes
- *	Re fixed the assorted missing 'static' cases
- *	Removed some unneeded version checks
- *	Cleaned up some of the VERSION checks in the code
- *	Left 2.0 support but removed 2.1.x support.
- *	Collected much of the compat glue into one spot
- *
- *	Version 1.14g-ac2 - 22/03/01
- *	Fixed a non obvious dereference after free in the driver unload path
- *
- *	Version 1.14i
- *	changes for making 32bit application run on IA64
- *
- *	Version 1.14j
- *	Tue Mar 13 14:27:54 EST 2001 - AM
- *	Changes made in the driver to be able to run applications if the
- *	system has memory >4GB.
- *
- *
- *	Version 1.14k
- *	Thu Mar 15 18:38:11 EST 2001 - AM
- *
- *	Firmware version check removed if subsysid==0x1111 and
- *	subsysvid==0x1111, since it's not yet initialized.
- *
- *	changes made to correctly calculate the base in mega_findCard.
- *
- *	Driver informational messages now appear on the console as well as
- *	with dmesg
- *
- *	Older ioctl interface is returned failure on newer(2.4.xx) kernels.
- *
- *	Inclusion of "modversions.h" is still a debatable question. It is
- *	included anyway with this release.
- *
- *	Version 1.14l
- *	Mon Mar 19 17:39:46 EST 2001 - AM
- *
- *	Assorted changes to remove compilation error in 1.14k when compiled
- *	with kernel < 2.4.0
- *
- *	Version 1.14m
- *	Tue Mar 27 12:09:22 EST 2001 - AM
- *
- *	Added support for extended CDBs ( > 10 bytes ) and OBDR ( One Button
- *	Disaster Recovery ) feature.
- *
- *
- *	Version 1.14n
- *	Tue Apr 10 14:28:13 EDT 2001 - AM
- *
- *	"modeversions.h" is no longer included in the code.
- *	2.4.xx style mutex initialization used for older kernels also
- *
- *	Version 1.14o
- *	Wed Apr 18 17:47:26 EDT 2001 - PJ
- *
- *	Before returning status for 'inquiry', we first check if request buffer
- *	is SG list, and then return appropriate status
- *
- *	Version 1.14p
- *	Wed Apr 25 13:44:48 EDT 2001 - PJ
- *
- *	SCSI result made appropriate in case of check conditions for extended
- *	passthru commands
- *
- *	Do not support lun >7 for physically accessed devices 
- *
- *	
- *	Version 1.15
- *	Thu Apr 19 09:38:38 EDT 2001 - AM
- *
- *	1.14l rollover to 1.15 - merged with main trunk after 1.15d
- *
- *	Version 1.15b
- *  Wed May 16 20:10:01 EDT 2001 - AM
- *
- *	"modeversions.h" is no longer included in the code.
- *	2.4.xx style mutex initialization used for older kernels also
- *	Brought in-sync with Alan's changes in 2.4.4
- *	Note: 1.15a is on OBDR branch(main trunk), and is not merged with yet.
- *
- * Version 1.15c
- * Mon May 21 23:10:42 EDT 2001 - AM
- *
- * ioctl interface uses 2.4.x conforming pci dma calls
- * similar calls used for older kernels
- *
- * Version 1.15d
- * Wed May 30 17:30:41 EDT 2001 - AM
- *
- * NULL is not a valid first argument for pci_alloc_consistent() on
- * IA64(2.4.3-2.10.1). Code shuffling done in ioctl interface to get
- * "pci_dev" before making calls to pci interface routines.
- *
- * Version 1.16pre
- * Fri Jun  1 19:40:48 EDT 2001 - AM
- *
- * 1.14p and 1.15d merged
- * ROMB support added
- *
- * Version 1.16-pre1
- * Mon Jun  4 15:01:01 EDT 2001 - AM
- *
- * Non-ROMB firmware do no DMA support 0xA9 command. Value 0xFF
- * (all channels are raid ) is chosen for those firmware.
- *
- * Version 1.16-pre2
- * Mon Jun 11 18:15:31 EDT 2001 - AM
- *
- * Changes for boot from any logical drive
- *
- * Version 1.16
- * Tue Jun 26 18:07:02 EDT 2001 - AM
- *
- * branched at 1.14p
- *
- * Check added for HP 1M/2M controllers if having firmware H.01.07 or
- * H.01.08. If found, disable 64 bit support since these firmware have
- * limitations for 64 bit addressing
- *
- *
- * Version 1.17
- * Thu Jul 12 11:14:09 EDT 2001 - AM
- *
- * 1.16pre2 and 1.16 merged.
- *
- * init_MUTEX and init_MUTEX_LOCKED are defined in 2.2.19. Pre-processor
- * statements are added for them
- *
- * Linus's 2.4.7pre3 kernel introduces a new field 'max_sectors' in Scsi_Host
- * structure, to improve IO performance.
- *
- *
- * Version 1.17a
- * Fri Jul 13 18:44:01 EDT 2001 - AM
- *
- * Starting from kernel 2.4.x, LUN is not < 8 - following SCSI-III. So to have
- * our current formula working to calculate logical drive number, return
- * failure for LUN > 7
- *
- *
- * Version 1.17b
- * Mon Jul 30 19:24:02 EDT 2001 - AM
- *
- * Added support for random deletion of logical drives
- *
- * Version 1.17c
- * Tue Sep 25 09:37:49 EDT 2001 - Atul Mukker <atulm@lsil.com>
- *
- * With single and dual channel controllers, some virtaul channels are
- * displayed negative.
- *
- * Version 1.17a-ac
- * Mon Aug 6 14:59:29 BST 2001 - "Michael Johnson" <johnsom@home.com>
- *
- * Make the HP print formatting and check for buggy firmware runtime not
- * ifdef dependent.
- *
- *
- * Version 1.17d
- * Thu Oct 11 10:48:45 EDT 2001 - Atul Mukker <atulm@lsil.com>
+/*
  *
- * Driver 1.17c oops when loaded without controller.
+ *			Linux MegaRAID device driver
  *
- * Special case for "use_sg == 1" removed while building the scatter gather
- * list.
+ * Copyright © 2002  LSI Logic Corporation.
  *
- * Version 1.18
- * Thu Oct 11 15:02:53 EDT 2001 - Atul Mukker <atulm@lsil.com>
+ *	   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; either version
+ *	   2 of the License, or (at your option) any later version.
  *
- * References to AMI have been changed to LSI Logic.
+ * Copyright (c) 2002  Red Hat, Inc. All rights reserved.
+ *	  - fixes
+ *	  - speed-ups (list handling fixes, issued_list, optimizations.)
+ *	  - lots of cleanups.
  *
+ * Version : v2.00.3 (Feb 19, 2003) - Atul Mukker <Atul.Mukker@lsil.com>
  *
- * BUGS:
- *     Some older 2.1 kernels (eg. 2.1.90) have a bug in pci.c that
- *     fails to detect the controller as a pci device on the system.
+ * Description: Linux device driver for LSI Logic MegaRAID controller
  *
- *     Timeout period for upper scsi layer, i.e. SD_TIMEOUT in
- *     /drivers/scsi/sd.c, is too short for this controller. SD_TIMEOUT
- *     value must be increased to (30 * HZ) otherwise false timeouts
- *     will occur in the upper layer.
+ * Supported controllers: MegaRAID 418, 428, 438, 466, 762, 467, 471, 490, 493
+ *					518, 520, 531, 532
  *
- *     Never set skip_id. The existing PCI code the megaraid uses fails
- *     to properly check the vendor subid in some cases. Setting this then
- *     makes it steal other i960's and crashes some boxes
+ * This driver is supported by LSI Logic, with assistance from Red Hat, Dell,
+ * and others. Please send updates to the public mailing list
+ * linux-megaraid-devel@dell.com, and subscribe to and read archives of this
+ * list at http://lists.us.dell.com/.
  *
- *     Far too many ifdefs for versions.
+ * For history of changes, see ChangeLog.megaraid.
  *
- *===================================================================*/
+ */
 
-#include <linux/config.h>
-#include <linux/version.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/kernel.h>
-#include <linux/ioport.h>
-#include <linux/fcntl.h>
-#include <linux/delay.h>
-#include <linux/pci.h>
-#include <linux/proc_fs.h>
+#include <linux/mm.h>
+#include <linux/fs.h>
 #include <linux/blk.h>
-#include <linux/wait.h>
-#include <linux/workqueue.h>
+#include <asm/uaccess.h>
+#include <asm/io.h>
+#include <linux/delay.h>
+#include <linux/reboot.h>
+#include <linux/module.h>
+#include <linux/list.h>
 #include <linux/interrupt.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <asm/pgtable.h>
+#include <scsi/scsicam.h>
 
-#include <linux/sched.h>
-#include <linux/stat.h>
-#include <linux/slab.h>	/* for kmalloc() */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)	/* 0x20100 */
-#include <linux/bios32.h>
-#else
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)	/* 0x20300 */
-#include <asm/spinlock.h>
-#else
-#include <linux/spinlock.h>
-#endif
-#endif
+#include "scsi.h"
+#include "hosts.h"
 
-#include <asm/io.h>
-#include <asm/irq.h>
+#include "megaraid.h"
 
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,0,24)	/* 0x020024 */
-#include <asm/uaccess.h>
-#endif
+MODULE_AUTHOR ("LSI Logic Corporation");
+MODULE_DESCRIPTION ("LSI Logic MegaRAID driver");
+MODULE_LICENSE ("GPL");
+
+static unsigned int max_cmd_per_lun = DEF_CMD_PER_LUN;
+MODULE_PARM(max_cmd_per_lun, "i");
+MODULE_PARM_DESC(max_cmd_per_lun, "Maximum number of commands which can be issued to a single LUN (default=DEF_CMD_PER_LUN=63)");
+
+static unsigned short int max_sectors_per_io = MAX_SECTORS_PER_IO;
+MODULE_PARM(max_sectors_per_io, "h");
+MODULE_PARM_DESC(max_sectors_per_io, "Maximum number of sectors per I/O request (default=MAX_SECTORS_PER_IO=128)");
+
+
+static unsigned short int max_mbox_busy_wait = MBOX_BUSY_WAIT;
+MODULE_PARM(max_mbox_busy_wait, "h");
+MODULE_PARM_DESC(max_mbox_busy_wait, "Maximum wait for mailbox in microseconds if busy (default=MBOX_BUSY_WAIT=10)");
+
+#define RDINDOOR(adapter)		readl((adapter)->base + 0x20)
+#define RDOUTDOOR(adapter)		readl((adapter)->base + 0x2C)
+#define WRINDOOR(adapter,value)		writel(value, (adapter)->base + 0x20)
+#define WROUTDOOR(adapter,value)	writel(value, (adapter)->base + 0x2C)
 
 /*
- * These header files are required for Shutdown Notification routines
+ * Global variables
  */
-#include <linux/notifier.h>
-#include <linux/reboot.h>
-#include <linux/init.h>
-#include "scsi.h"
-#include "hosts.h"
-#include <scsi/scsicam.h>
 
-#include "megaraid.h"
+static int hba_count;
+static adapter_t *hba_soft_state[MAX_CONTROLLERS];
+static struct proc_dir_entry *mega_proc_dir_entry;
+
+static struct notifier_block mega_notifier = {
+	.notifier_call = megaraid_reboot_notify
+};
+
+/* For controller re-ordering */
+static struct mega_hbas mega_hbas[MAX_CONTROLLERS];
 
 /*
- *================================================================
- *  #Defines
- *================================================================
+ * The File Operations structure for the serial/ioctl interface of the driver
  */
+static struct file_operations megadev_fops = {
+	.owner		= THIS_MODULE,
+	.ioctl		= megadev_ioctl,
+	.open		= megadev_open,
+};
 
-#define MAX_SERBUF 160
-#define COM_BASE 0x2f8
+/*
+ * Array to structures for storing the information about the controllers. This
+ * information is sent to the user level applications, when they do an ioctl
+ * for this information.
+ */
+static struct mcontroller mcontroller[MAX_CONTROLLERS];
 
-static ulong RDINDOOR (mega_host_config * megaCfg)
-{
-	return readl (megaCfg->base + 0x20);
-}
+/* The current driver version */
+static u32 driver_ver = 0x02000000;
 
-static void WRINDOOR (mega_host_config * megaCfg, ulong value)
-{
-	writel (value, megaCfg->base + 0x20);
-}
+/* major number used by the device for character interface */
+static int major;
+
+#define IS_RAID_CH(hba, ch)	(((hba)->mega_ch_class >> (ch)) & 0x01)
+
+
+/*
+ * Debug variable to print some diagnostic messages
+ */
+static int trace_level;
 
-static ulong RDOUTDOOR (mega_host_config * megaCfg)
+/*
+ * megaraid_validate_parms()
+ *
+ * Validate that any module parms passed in
+ * have proper values.
+ */
+static void
+megaraid_validate_parms(void)
 {
-	return readl (megaCfg->base + 0x2C);
+	if( (max_cmd_per_lun <= 0) || (max_cmd_per_lun > MAX_CMD_PER_LUN) )
+		max_cmd_per_lun = MAX_CMD_PER_LUN;
+	if( max_mbox_busy_wait > MBOX_BUSY_WAIT )
+		max_mbox_busy_wait = MBOX_BUSY_WAIT;
 }
 
-static void WROUTDOOR (mega_host_config * megaCfg, ulong value)
+
+/**
+ * megaraid_detect()
+ * @host_template - Our soft state maintained by mid-layer
+ *
+ * the detect entry point for the mid-layer.
+ * We scan the PCI bus for our controllers and start them.
+ *
+ * Note: PCI_DEVICE_ID_PERC4_DI below represents the PERC4/Di class of
+ * products. All of them share the same vendor id, device id, and subsystem
+ * vendor id but different subsystem ids. As of now, driver does not use the
+ * subsystem id.
+ */
+static int
+megaraid_detect(Scsi_Host_Template *host_template)
 {
-	writel (value, megaCfg->base + 0x2C);
-}
+	int	i;
+	u16	dev_sw_table[] = {	/* Table of all supported
+					   vendor/device ids */
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)	/* 0x020200 */
-#include <linux/smp.h>
-#define cpuid smp_processor_id()
-#endif
+		PCI_VENDOR_ID_DELL,		PCI_DEVICE_ID_DISCOVERY, 
+		PCI_VENDOR_ID_DELL,		PCI_DEVICE_ID_PERC4_DI, 
+		PCI_VENDOR_ID_LSI_LOGIC,	PCI_DEVICE_ID_PERC4_QC_VERDE, 
+		PCI_VENDOR_ID_AMI,		PCI_DEVICE_ID_AMI_MEGARAID, 
+		PCI_VENDOR_ID_AMI,		PCI_DEVICE_ID_AMI_MEGARAID2, 
+		PCI_VENDOR_ID_AMI,		PCI_DEVICE_ID_AMI_MEGARAID3, 
+		PCI_VENDOR_ID_INTEL,		PCI_DEVICE_ID_AMI_MEGARAID3, 
+		PCI_VENDOR_ID_LSI_LOGIC,	PCI_DEVICE_ID_AMI_MEGARAID3 };
+
+	host_template->proc_name = "megaraid";
+
+	printk(KERN_NOTICE "megaraid: " MEGARAID_VERSION);
+
+	megaraid_validate_parms();
+
+	memset(mega_hbas, 0, sizeof (mega_hbas));
+
+	hba_count = 0;
+
+	/*
+	 * Scan PCI bus for our all devices.
+	 */
+	for( i = 0; i < sizeof(dev_sw_table)/sizeof(u16); i += 2 ) {
+
+		mega_find_card(host_template, dev_sw_table[i],
+				dev_sw_table[i+1]);
+	}
+
+	if(hba_count) {
+		/*
+		 * re-order hosts so that one with bootable logical drive
+		 * comes first
+		 */
+#ifdef CONFIG_PROC_FS
+		mega_proc_dir_entry = proc_mkdir("megaraid", &proc_root);
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4)
-#define scsi_set_pci_device(x,y)
+		if(!mega_proc_dir_entry) {
+			printk(KERN_WARNING
+				"megaraid: failed to create megaraid root\n");
+		}
+		else {
+			for(i = 0; i < hba_count; i++) {
+				mega_create_proc_entry(i, mega_proc_dir_entry);
+			}
+		}
 #endif
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)	/* 0x020400 */
+		/*
+		 * Register the driver as a character device, for applications
+		 * to access it for ioctls.
+		 * First argument (major) to register_chrdev implies a dynamic
+		 * major number allocation.
+		 */
+		major = register_chrdev(0, "megadev", &megadev_fops);
 
-/*
- *	Linux 2.4 and higher
- *
- *	No driver private lock
- *	Use the io_request_lock not cli/sti
- *	queue task is a simple api without irq forms
- */
+		/*
+		 * Register the Shutdown Notification hook in kernel
+		 */
+		if(register_reboot_notifier(&mega_notifier)) {
+			printk(KERN_WARNING
+				"MegaRAID Shutdown routine not registered!!\n");
+		}
 
-MODULE_AUTHOR ("LSI Logic Corporation");
-MODULE_DESCRIPTION ("LSI Logic MegaRAID driver");
-MODULE_LICENSE ("GPL");
+	}
 
-#define DRIVER_LOCK_T
-#define DRIVER_LOCK_INIT(p)
-#define DRIVER_LOCK(p)
-#define DRIVER_UNLOCK(p)
-#define IO_LOCK_T unsigned long io_flags = 0
-#define IO_LOCK(host) spin_lock_irqsave(host->host_lock,io_flags)
-#define IO_UNLOCK(host) spin_unlock_irqrestore(host->host_lock,io_flags)
-#define IO_LOCK_IRQ(host) spin_lock_irq(host->host_lock)
-#define IO_UNLOCK_IRQ(host) spin_unlock_irq(host->host_lock)
+	return hba_count;
+}
 
-#define queue_task_irq(a,b)     queue_task(a,b)
-#define queue_task_irq_off(a,b) queue_task(a,b)
 
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)	/* 0x020200 */
 
-/*
- *	Linux 2.2 and higher
+/**
+ * mega_find_card() - find and start this controller
+ * @host_template - Our soft state maintained by mid-layer
+ * @pci_vendor - pci vendor id for this controller
+ * @pci_device - pci device id for this controller
+ *
+ * Scans the PCI bus for this vendor and device id combination, setup the
+ * resources, and register ourselves as a SCSI HBA driver, and setup all
+ * parameters for our soft state.
  *
- *	No driver private lock
- *	Use the io_request_lock not cli/sti
- *	No pci region api
- *	queue_task is now a single simple API
+ * This routine also checks for some buggy firmware and ajust the flags
+ * accordingly.
  */
+static void
+mega_find_card(Scsi_Host_Template *host_template, u16 pci_vendor,
+	u16 pci_device)
+{
+	struct Scsi_Host	*host = NULL;
+	adapter_t	*adapter = NULL;
+	u32	magic64;
+	unsigned long	mega_baseport;
+	u16	subsysid, subsysvid;
+	u8	pci_bus;
+	u8	pci_dev_func;
+	u8	irq;
+	struct pci_dev	*pdev = NULL;
+	u8	did_ioremap_f = 0;
+	u8	did_req_region_f = 0;
+	u8	did_scsi_reg_f = 0;
+	u8	alloc_int_buf_f = 0;
+	u8	alloc_scb_f = 0;
+	u8	got_irq_f = 0;
+	u8	did_setup_mbox_f = 0;
+	unsigned long	tbase;
+	unsigned long	flag = 0;
+	int	i, j;
 
-static char kernel_version[] = UTS_RELEASE;
-MODULE_AUTHOR ("LSI Logic Corporation");
-MODULE_DESCRIPTION ("LSI Logic MegaRAID driver");
+	while((pdev = pci_find_device(pci_vendor, pci_device, pdev))) {
 
-#define DRIVER_LOCK_T
-#define DRIVER_LOCK_INIT(p)
-#define DRIVER_LOCK(p)
-#define DRIVER_UNLOCK(p)
-#define IO_LOCK_T unsigned long io_flags = 0
-#define IO_LOCK(host) spin_lock_irqsave(host->host_lock,io_flags);
-#define IO_UNLOCK(host) spin_unlock_irqrestore(host->host_lock,io_flags);
-
-#define pci_free_consistent(a,b,c,d)
-#define pci_unmap_single(a,b,c,d)
-#define pci_enable_device(x) (0)
-#define queue_task_irq(a,b)     queue_task(a,b)
-#define queue_task_irq_off(a,b) queue_task(a,b)
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,19)	/* 0x020219 */
-#define init_MUTEX_LOCKED(x)    (*(x)=MUTEX_LOCKED)
-#define init_MUTEX(x)           (*(x)=MUTEX)
-#define DECLARE_WAIT_QUEUE_HEAD(x)	struct wait_queue *x = NULL
-#endif
+		if(pci_enable_device (pdev)) continue;
 
+		pci_bus = pdev->bus->number;
+		pci_dev_func = pdev->devfn;
 
-#else
+		/*
+		 * For these vendor and device ids, signature offsets are not
+		 * valid and 64 bit is implicit
+		 */
+		if( (pci_vendor == PCI_VENDOR_ID_DELL &&
+			pci_device == PCI_DEVICE_ID_PERC4_DI) ||
+			(pci_vendor == PCI_VENDOR_ID_LSI_LOGIC &&
+			pci_device == PCI_DEVICE_ID_PERC4_QC_VERDE) ) {
 
-/*
- *	Linux 2.0 macros. Here we have to provide some of our own
- *	functionality. We also only work little endian 32bit.
- *	Again no pci_alloc/free api
- *	IO_LOCK/IO_LOCK_T were never used in 2.0 so now are empty 
- */
- 
-#define cpuid 0
-#define DRIVER_LOCK_T long cpu_flags;
-#define DRIVER_LOCK_INIT(p)
-#define DRIVER_LOCK(p) \
-       		save_flags(cpu_flags); \
-       		cli();
-#define DRIVER_UNLOCK(p) \
-       		restore_flags(cpu_flags);
-#define IO_LOCK_T
-#define IO_LOCK(p)
-#define IO_UNLOCK(p)
-#define le32_to_cpu(x) (x)
-#define cpu_to_le32(x) (x)
+			flag |= BOARD_64BIT;
+		}
+		else {
+			pci_read_config_dword(pdev, PCI_CONF_AMISIG64,
+					&magic64);
 
-#define pci_free_consistent(a,b,c,d)
-#define pci_unmap_single(a,b,c,d)
+			if (magic64 == HBA_SIGNATURE_64BIT)
+				flag |= BOARD_64BIT;
+		}
 
-#define init_MUTEX_LOCKED(x)    (*(x)=MUTEX_LOCKED)
-#define init_MUTEX(x)           (*(x)=MUTEX)
+		subsysvid = pdev->subsystem_vendor;
+		subsysid = pdev->subsystem_device;
 
-#define pci_enable_device(x) (0)
+		/*
+		 * If we do not find the valid subsys vendor id, refuse to
+		 * load the driver. This is part of PCI200X compliance
+		 * We load the driver if subsysvid is 0.
+		 */
+		if( subsysvid && (subsysvid != AMI_SUBSYS_VID) &&
+				(subsysvid != DELL_SUBSYS_VID) &&
+				(subsysvid != HP_SUBSYS_VID) &&
+				(subsysvid != LSI_SUBSYS_VID) ) continue;
 
-/*
- *	2.0 lacks spinlocks, iounmap/ioremap
- */
 
-#define ioremap vremap
-#define iounmap vfree
+		printk(KERN_NOTICE "megaraid: found 0x%4.04x:0x%4.04x:bus %d:",
+			pci_vendor, pci_device, pci_bus);
 
- /* simulate spin locks */
-typedef struct {
-	volatile char lock;
-} spinlock_t;
+		printk("slot %d:func %d\n",
+			PCI_SLOT(pci_dev_func), PCI_FUNC(pci_dev_func));
 
-#define spin_lock_init(x) { (x)->lock = 0;}
-#define spin_lock_irqsave(x,flags) { while ((x)->lock) barrier();\
-                                        (x)->lock=1; save_flags(flags);\
-                                        cli();}
-#define spin_unlock_irqrestore(x,flags) { (x)->lock=0; restore_flags(flags);}
+		/* Read the base port and IRQ from PCI */
+		mega_baseport = pci_resource_start(pdev, 0);
+		irq = pdev->irq;
 
-#define DECLARE_WAIT_QUEUE_HEAD(x)	struct wait_queue *x = NULL
+		tbase = mega_baseport;
 
-#endif
+		if( pci_resource_flags(pdev, 0) & IORESOURCE_MEM ) {
 
+			if (!request_mem_region(mega_baseport, 128,
+					"MegaRAID: LSI Logic Corporation.")) {
+				printk(KERN_WARNING
+					"megaraid: mem region busy!\n");
+				continue;
+			}
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)	/* 0x020400 */
-#define dma_alloc_consistent pci_alloc_consistent
-#define dma_free_consistent pci_free_consistent
-#else
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,19)	/* 0x020219 */
-typedef unsigned long dma_addr_t;
-#endif
-void *dma_alloc_consistent(void *, size_t, dma_addr_t *);
-void dma_free_consistent(void *, size_t, void *, dma_addr_t);
-int mega_get_order(int);
-int pow_2(int);
-#endif
+			mega_baseport =
+				(unsigned long)ioremap(mega_baseport, 128);
 
-/* set SERDEBUG to 1 to enable serial debugging */
-#define SERDEBUG 0
-#if SERDEBUG
-static void ser_init (void);
-static void ser_puts (char *str);
-static void ser_putc (char c);
-static int ser_printk (const char *fmt, ...);
-#endif
+			if( !mega_baseport ) {
+				printk(KERN_WARNING
+					"megaraid: could not map hba memory\n");
 
-#ifdef CONFIG_PROC_FS
-#define COPY_BACK if (offset > megaCfg->procidx) { \
-		*eof = TRUE; \
-        megaCfg->procidx = 0; \
-        megaCfg->procbuf[0] = 0; \
-        return 0;} \
- if ((count + offset) > megaCfg->procidx) { \
-      count = megaCfg->procidx - offset; \
-      *eof = TRUE; } \
-      memcpy(page, &megaCfg->procbuf[offset], count); \
-      megaCfg->procidx = 0; \
-      megaCfg->procbuf[0] = 0;
-#endif
+				release_mem_region(tbase, 128);
 
-/*
- * ================================================================
- *                    Global variables
- *================================================================
- */
+				continue;
+			}
 
-/*  Use "megaraid=skipXX" as LILO option to prohibit driver from scanning
-    XX scsi id on each channel.  Used for Madrona motherboard, where SAF_TE
-    processor id cannot be scanned */
-
-static char *megaraid;
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,1,0)	/* 0x20100 */
-#ifdef MODULE
-MODULE_PARM (megaraid, "s");
-#endif
-#endif
-static int skip_id = -1;
-static int numCtlrs = 0;
-static mega_host_config *megaCtlrs[FC_MAX_CHANNELS] = { 0 };
-static struct proc_dir_entry *mega_proc_dir_entry;
+			flag |= BOARD_MEMMAP;
 
-#if DEBUG
-static u32 maxCmdTime = 0;
-#endif
+			did_ioremap_f = 1;
+		}
+		else {
+			mega_baseport += 0x10;
 
-static mega_scb *pLastScb = NULL;
-static struct notifier_block mega_notifier = {
-	megaraid_reboot_notify,
-	NULL,
-	0
-};
+			if( !request_region(mega_baseport, 16, "megaraid") )
+				goto fail_attach;
 
-/* For controller re-ordering */
-struct mega_hbas mega_hbas[MAX_CONTROLLERS];
+			flag |= BOARD_IOMAP;
 
-/*
- * The File Operations structure for the serial/ioctl interface of the driver
- */
-/* For controller re-ordering */ 
+			did_req_region_f = 1;
+		}
 
-static struct file_operations megadev_fops = {
-	.owner			= THIS_MODULE,
-	.ioctl			= megadev_ioctl_entry,
-};
+		/* Initialize SCSI Host structure */
+		host = scsi_register(host_template, sizeof(adapter_t));
 
-/*
- * Array to structures for storing the information about the controllers. This
- * information is sent to the user level applications, when they do an ioctl
- * for this information.
- */
-static struct mcontroller mcontroller[MAX_CONTROLLERS];
+		if(!host) goto fail_attach;
 
-/* The current driver version */
-static u32 driver_ver = 114;
+		did_scsi_reg_f = 1;
 
-/* major number used by the device for character interface */
-static int major;
+		scsi_set_device(host, &pdev->dev);
 
-static struct semaphore mimd_ioctl_sem;
-static struct semaphore mimd_entry_mtx;
+		adapter = (adapter_t *)host->hostdata;
+		memset(adapter, 0, sizeof(adapter_t));
 
-#if SERDEBUG
-volatile static spinlock_t serial_lock;
-#endif
+		printk(KERN_NOTICE
+			"scsi%d:Found MegaRAID controller at 0x%lx, IRQ:%d\n",
+			host->host_no, mega_baseport, irq);
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)	/* 0x20300 */
-static struct proc_dir_entry proc_scsi_megaraid = {
-	PROC_SCSI_MEGARAID, 8, "megaraid",
-	S_IFDIR | S_IRUGO | S_IXUGO, 2
-};
-#endif
+		adapter->base = mega_baseport;
 
-#ifdef CONFIG_PROC_FS
-extern struct proc_dir_entry proc_root;
-#endif
+		/* Copy resource info into structure */
+		INIT_LIST_HEAD(&adapter->free_list);
+		INIT_LIST_HEAD(&adapter->pending_list);
+		INIT_LIST_HEAD(&adapter->completed_list);
 
-static char mega_ch_class;	/* channels are raid or scsi */
-#define	IS_RAID_CH(ch)	( (mega_ch_class >> (ch)) & 0x01 )
+		adapter->flag = flag;
+		spin_lock_init(&adapter->lock);
+		scsi_assign_lock(host, &adapter->lock);
 
-#if SERDEBUG
-static char strbuf[MAX_SERBUF + 1];
+		host->cmd_per_lun = max_cmd_per_lun;
+		host->max_sectors = max_sectors_per_io;
 
-static void ser_init (void)
-{
-	unsigned port = COM_BASE;
+		adapter->dev = pdev;
+		adapter->host = host;
 
-	outb (0x80, port + 3);
-	outb (0, port + 1);
-	/* 9600 Baud, if 19200: outb(6,port) */
-	outb (12, port);
-	outb (3, port + 3);
-	outb (0, port + 1);
-}
+		adapter->host->irq = irq;
 
-static void ser_puts (char *str)
-{
-	char *ptr;
+		if( flag & BOARD_MEMMAP ) {
+			adapter->host->base = tbase;
+		}
+		else {
+			adapter->host->io_port = tbase;
+			adapter->host->n_io_port = 16;
+		}
 
-	ser_init ();
-	for (ptr = str; *ptr; ++ptr)
-		ser_putc (*ptr);
-}
+		adapter->host->unique_id = (pci_bus << 8) | pci_dev_func;
 
-static void ser_putc (char c)
-{
-	unsigned port = COM_BASE;
+		/*
+		 * Allocate buffer to issue internal commands.
+		 */
+		adapter->mega_buffer = pci_alloc_consistent(adapter->dev,
+			MEGA_BUFFER_SIZE, &adapter->buf_dma_handle);
 
-	while ((inb (port + 5) & 0x20) == 0) ;
-	outb (c, port);
-	if (c == 0x0a) {
-		while ((inb (port + 5) & 0x20) == 0) ;
-		outb (0x0d, port);
-	}
-}
+		if( !adapter->mega_buffer ) {
+			printk(KERN_WARNING "megaraid: out of RAM.\n");
+			goto fail_attach;
+		}
+		alloc_int_buf_f = 1;
 
-static int ser_printk (const char *fmt, ...)
-{
-	va_list args;
-	int i;
-	long flags;
+		adapter->scb_list = kmalloc(sizeof(scb_t)*MAX_COMMANDS,
+				GFP_KERNEL);
 
-	spin_lock_irqsave (&serial_lock, flags);
-	va_start (args, fmt);
-	i = vsprintf (strbuf, fmt, args);
-	ser_puts (strbuf);
-	va_end (args);
-	spin_unlock_irqrestore (&serial_lock, flags);
+		if(!adapter->scb_list) {
+			printk(KERN_WARNING "megaraid: out of RAM.\n");
+			goto fail_attach;
+		}
 
-	return i;
-}
+		alloc_scb_f = 1;
 
-#define TRACE(a)    { ser_printk a;}
+		/* Request our IRQ */
+		if( adapter->flag & BOARD_MEMMAP ) {
+			if(request_irq(irq, megaraid_isr_memmapped, SA_SHIRQ,
+						"megaraid", adapter)) {
+				printk(KERN_WARNING
+					"megaraid: Couldn't register IRQ %d!\n",
+					irq);
+				goto fail_attach;
+			}
+		}
+		else {
+			if(request_irq(irq, megaraid_isr_iomapped, SA_SHIRQ,
+						"megaraid", adapter)) {
+				printk(KERN_WARNING
+					"megaraid: Couldn't register IRQ %d!\n",
+					irq);
+				goto fail_attach;
+			}
+		}
+		got_irq_f = 1;
 
-#else
-#define TRACE(A)
-#endif
+		if( mega_setup_mailbox(adapter) != 0 )
+			goto fail_attach;
 
-#define TRACE1(a)
+		did_setup_mbox_f = 1;
 
-static void callDone (Scsi_Cmnd * SCpnt)
-{
-	if (SCpnt->result) {
-		TRACE (("*** %.08lx %.02x <%d.%d.%d> = %x\n",
-			SCpnt->serial_number, SCpnt->cmnd[0], SCpnt->device->channel,
-			SCpnt->device->id, SCpnt->device->lun, SCpnt->result));
-	}
-	SCpnt->scsi_done (SCpnt);
-}
+		if( mega_query_adapter(adapter) != 0 )
+			goto fail_attach;
 
-/*-------------------------------------------------------------------------
- *
- *                      Local functions
- *
- *-------------------------------------------------------------------------*/
+		/*
+		 * Have checks for some buggy f/w
+		 */
+		if((subsysid == 0x1111) && (subsysvid == 0x1111)) {
+			/*
+			 * Which firmware
+			 */
+			if (!strcmp(adapter->fw_version, "3.00") ||
+					!strcmp(adapter->fw_version, "3.01")) {
 
-/*=======================
- * Free a SCB structure
- *=======================
- */
-static void mega_freeSCB (mega_host_config * megaCfg, mega_scb * pScb)
-{
+				printk( KERN_WARNING
+					"megaraid: Your  card is a Dell PERC "
+					"2/SC RAID controller with  "
+					"firmware\nmegaraid: 3.00 or 3.01.  "
+					"This driver is known to have "
+					"corruption issues\nmegaraid: with "
+					"those firmware versions on this "
+					"specific card.  In order\nmegaraid: "
+					"to protect your data, please upgrade "
+					"your firmware to version\nmegaraid: "
+					"3.10 or later, available from the "
+					"Dell Technical Support web\n"
+					"megaraid: site at\nhttp://support."
+					"dell.com/us/en/filelib/download/"
+					"index.asp?fileid=2940\n"
+				);
+			}
+		}
 
-	mega_scb *pScbtmp;
+		/*
+		 * If we have a HP 1M(0x60E7)/2M(0x60E8) controller with
+		 * firmware H.01.07, H.01.08, and H.01.09 disable 64 bit
+		 * support, since this firmware cannot handle 64 bit
+		 * addressing
+		 */
 
-	if ((pScb == NULL) || (pScb->idx >= 0xFE)) {
-		return;
-	}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	switch (pScb->dma_type) {
-	case M_RD_DMA_TYPE_NONE:
-		break;
-	case M_RD_PTHRU_WITH_BULK_DATA:
-		pci_unmap_single (megaCfg->dev, pScb->dma_h_bulkdata,
-				  pScb->pthru->dataxferlen,
-				  pScb->dma_direction);
-		break;
-	case M_RD_EPTHRU_WITH_BULK_DATA:
-		pci_unmap_single (megaCfg->dev, pScb->dma_h_bulkdata,
-				  pScb->epthru->dataxferlen,
-				  pScb->dma_direction);
-		break;
-	case M_RD_PTHRU_WITH_SGLIST:
-	{
-		int count;
-		for (count = 0; count < pScb->sglist_count; count++) {
-			pci_unmap_single (megaCfg->dev,
-					  pScb->dma_h_sglist[count],
-					  pScb->sgList[count].length,
-					  pScb->dma_direction);
+		if((subsysvid == HP_SUBSYS_VID) &&
+				((subsysid == 0x60E7)||(subsysid == 0x60E8))) {
 
+			/*
+			 * which firmware
+			 */
+			if( !strcmp(adapter->fw_version, "H01.07") ||
+				!strcmp(adapter->fw_version, "H01.08") ||
+				!strcmp(adapter->fw_version, "H01.09") ) {
+
+				printk(KERN_WARNING
+					"megaraid: Firmware H.01.07, "
+					"H.01.08, and H.01.09 on 1M/2M "
+					"controllers\n"
+					"megaraid: do not support 64 bit "
+					"addressing.\nmegaraid: DISABLING "
+					"64 bit support.\n");
+				adapter->flag &= ~BOARD_64BIT;
+			}
 		}
-		break;
-	}
-	case M_RD_BULK_DATA_ONLY:
-		pci_unmap_single (megaCfg->dev,
-				  pScb->dma_h_bulkdata,
-				  pScb->iDataSize, pScb->dma_direction);
 
-		break;
-	case M_RD_SGLIST_ONLY:
-		pci_unmap_sg (megaCfg->dev,
-			      pScb->SCpnt->request_buffer,
-			      pScb->SCpnt->use_sg, pScb->dma_direction);
-		break;
-	default:
-		break;
-	}
-#endif
 
-	/* Unlink from pending queue */
-	if (pScb == megaCfg->qPendingH) {
+		if(mega_is_bios_enabled(adapter)) {
+			mega_hbas[hba_count].is_bios_enabled = 1;
+		}
+		mega_hbas[hba_count].hostdata_addr = adapter;
 
-		if (megaCfg->qPendingH == megaCfg->qPendingT)
-			megaCfg->qPendingH = megaCfg->qPendingT = NULL;
-		else
-			megaCfg->qPendingH = megaCfg->qPendingH->next;
+		/*
+		 * Find out which channel is raid and which is scsi. This is
+		 * for ROMB support.
+		 */
+		mega_enum_raid_scsi(adapter);
 
-		megaCfg->qPcnt--;
+		/*
+		 * Find out if a logical drive is set as the boot drive. If
+		 * there is one, will make that as the first logical drive.
+		 * ROMB: Do we have to boot from a physical drive. Then all
+		 * the physical drives would appear before the logical disks.
+		 * Else, all the physical drives would be exported to the mid
+		 * layer after logical drives.
+		 */
+		mega_get_boot_drv(adapter);
 
-	} else {
-		for (pScbtmp = megaCfg->qPendingH; pScbtmp;
-		     pScbtmp = pScbtmp->next) {
+		if( ! adapter->boot_pdrv_enabled ) {
+			for( i = 0; i < NVIRT_CHAN; i++ )
+				adapter->logdrv_chan[i] = 1;
 
-			if (pScbtmp->next == pScb) {
+			for( i = NVIRT_CHAN; i<MAX_CHANNELS+NVIRT_CHAN; i++ )
+				adapter->logdrv_chan[i] = 0;
 
-				pScbtmp->next = pScb->next;
+			adapter->mega_ch_class <<= NVIRT_CHAN;
+		}
+		else {
+			j = adapter->product_info.nchannels;
+			for( i = 0; i < j; i++ )
+				adapter->logdrv_chan[i] = 0;
 
-				if (pScb == megaCfg->qPendingT) {
-					megaCfg->qPendingT = pScbtmp;
-				}
+			for( i = j; i < NVIRT_CHAN + j; i++ )
+				adapter->logdrv_chan[i] = 1;
+		}
 
-				megaCfg->qPcnt--;
-				break;
-			}
+
+		/*
+		 * Do we support random deletion and addition of logical
+		 * drives
+		 */
+		adapter->read_ldidmap = 0;	/* set it after first logdrv
+						   delete cmd */
+		adapter->support_random_del = mega_support_random_del(adapter);
+
+		/* Initialize SCBs */
+		if(mega_init_scb(adapter)) {
+			goto fail_attach;
 		}
-	}
 
-	/* Link back into free list */
-	pScb->state = SCB_FREE;
-	pScb->SCpnt = NULL;
+		/*
+		 * Reset the pending commands counter
+		 */
+		atomic_set(&adapter->pend_cmds, 0);
 
-	if (megaCfg->qFreeH == (mega_scb *) NULL) {
-		megaCfg->qFreeH = megaCfg->qFreeT = pScb;
-	} else {
-		megaCfg->qFreeT->next = pScb;
-		megaCfg->qFreeT = pScb;
-	}
+		/*
+		 * Reset the adapter quiescent flag
+		 */
+		atomic_set(&adapter->quiescent, 0);
 
-	megaCfg->qFreeT->next = NULL;
-	megaCfg->qFcnt++;
+		hba_soft_state[hba_count] = adapter;
 
-}
+		/*
+		 * Fill in the structure which needs to be passed back to the
+		 * application when it does an ioctl() for controller related
+		 * information.
+		 */
+		i = hba_count;
 
-/*===========================
- * Allocate a SCB structure
- *===========================
- */
-static mega_scb *mega_allocateSCB (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt)
-{
-	mega_scb *pScb;
+		mcontroller[i].base = mega_baseport;
+		mcontroller[i].irq = irq;
+		mcontroller[i].numldrv = adapter->numldrv;
+		mcontroller[i].pcibus = pci_bus;
+		mcontroller[i].pcidev = pci_device;
+		mcontroller[i].pcifun = PCI_FUNC (pci_dev_func);
+		mcontroller[i].pciid = -1;
+		mcontroller[i].pcivendor = pci_vendor;
+		mcontroller[i].pcislot = PCI_SLOT (pci_dev_func);
+		mcontroller[i].uid = (pci_bus << 8) | pci_dev_func;
+
+
+		/* Set the Mode of addressing to 64 bit if we can */
+		if((adapter->flag & BOARD_64BIT)&&(sizeof(dma_addr_t) == 8)) {
+			pci_set_dma_mask(pdev, 0xffffffffffffffff);
+			adapter->has_64bit_addr = 1;
+		}
+		else  {
+			pci_set_dma_mask(pdev, 0xffffffff);
+			adapter->has_64bit_addr = 0;
+		}
+		
+		init_MUTEX(&adapter->int_mtx);
+		init_waitqueue_head(&adapter->int_waitq);
 
-	/* Unlink command from Free List */
-	if ((pScb = megaCfg->qFreeH) != NULL) {
-		megaCfg->qFreeH = pScb->next;
-		megaCfg->qFcnt--;
-
-		pScb->isrcount = jiffies;
-		pScb->next = NULL;
-		pScb->state = SCB_ACTIVE;
-		pScb->SCpnt = SCpnt;
+		adapter->this_id = DEFAULT_INITIATOR_ID;
+		adapter->host->this_id = DEFAULT_INITIATOR_ID;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		pScb->dma_type = M_RD_DMA_TYPE_NONE;
+#if MEGA_HAVE_CLUSTERING
+		/*
+		 * Is cluster support enabled on this controller
+		 * Note: In a cluster the HBAs ( the initiators ) will have
+		 * different target IDs and we cannot assume it to be 7. Call
+		 * to mega_support_cluster() will get the target ids also if
+		 * the cluster support is available
+		 */
+		adapter->has_cluster = mega_support_cluster(adapter);
+
+		if( adapter->has_cluster ) {
+			printk(KERN_NOTICE
+				"megaraid: Cluster driver, initiator id:%d\n",
+				adapter->this_id);
+		}
 #endif
 
-		return pScb;
-	}
+		hba_count++;
+		continue;
 
-	printk (KERN_WARNING "Megaraid: Could not allocate free SCB!!!\n");
+fail_attach:
+		if( did_setup_mbox_f ) {
+			pci_free_consistent(adapter->dev, sizeof(mbox64_t),
+					(void *)adapter->una_mbox64,
+					adapter->una_mbox64_dma);
+		}
 
-	return NULL;
-}
+		if( got_irq_f ) {
+			irq_disable(adapter);
+			free_irq(adapter->host->irq, adapter);
+		}
 
-/* Run through the list of completed requests  and finish it */
-static void mega_rundoneq (mega_host_config * megaCfg)
-{
-	Scsi_Cmnd *SCpnt;
+		if( alloc_scb_f ) {
+			kfree(adapter->scb_list);
+		}
+
+		if( alloc_int_buf_f ) {
+			pci_free_consistent(adapter->dev, MEGA_BUFFER_SIZE,
+					(void *)adapter->mega_buffer,
+					adapter->buf_dma_handle);
+		}
 
-	while ((SCpnt = megaCfg->qCompletedH) != NULL) {
-		megaCfg->qCompletedH = (Scsi_Cmnd *) SCpnt->host_scribble;
-		megaCfg->qCcnt--;
+		if( did_scsi_reg_f ) scsi_unregister(host);
 
-		SCpnt->host_scribble = (unsigned char *) NULL;	/* XC : sep 14 */
-		/* Callback */
-		callDone (SCpnt);
+		if( did_ioremap_f ) {
+			iounmap((void *)mega_baseport);
+			release_mem_region(tbase, 128);
+		}
+
+		if( did_req_region_f )
+			release_region(mega_baseport, 16);
 	}
 
-	megaCfg->qCompletedH = megaCfg->qCompletedT = NULL;
+	return;
 }
 
-/*
- * Runs through the list of pending requests
- * Assumes that mega_lock spin_lock has been acquired.
+
+/**
+ * mega_setup_mailbox()
+ * @adapter - pointer to our soft state
+ *
+ * Allocates a 8 byte aligned memory for the handshake mailbox.
  */
-static int mega_runpendq (mega_host_config * megaCfg)
+static int
+mega_setup_mailbox(adapter_t *adapter)
 {
-	mega_scb *pScb;
-	int rc;
+	unsigned long	align;
 
-	/* Issue any pending commands to the card */
-	for (pScb = megaCfg->qPendingH; pScb; pScb = pScb->next) {
-		if (pScb->state == SCB_ACTIVE) {
-			if ((rc =
-			     megaIssueCmd (megaCfg, pScb->mboxData, pScb, 1)) == -1)
-				return rc;
-		}
+	adapter->una_mbox64 = pci_alloc_consistent(adapter->dev,
+			sizeof(mbox64_t), &adapter->una_mbox64_dma);
+
+	if( !adapter->una_mbox64 ) return -1;
+		
+	adapter->mbox = &adapter->una_mbox64->mbox;
+
+	adapter->mbox = (mbox_t *)((((unsigned long) adapter->mbox) + 15) &
+			(~0UL ^ 0xFUL));
+
+	adapter->mbox64 = (mbox64_t *)(((unsigned long)adapter->mbox) - 8);
+
+	align = ((void *)adapter->mbox) - ((void *)&adapter->una_mbox64->mbox);
+
+	adapter->mbox_dma = adapter->una_mbox64_dma + 8 + align;
+
+	/*
+	 * Register the mailbox if the controller is an io-mapped controller
+	 */
+	if( adapter->flag & BOARD_IOMAP ) {
+
+		outb_p(adapter->mbox_dma & 0xFF,
+				adapter->host->io_port + MBOX_PORT0);
+
+		outb_p((adapter->mbox_dma >> 8) & 0xFF,
+				adapter->host->io_port + MBOX_PORT1);
+
+		outb_p((adapter->mbox_dma >> 16) & 0xFF,
+				adapter->host->io_port + MBOX_PORT2);
+
+		outb_p((adapter->mbox_dma >> 24) & 0xFF,
+				adapter->host->io_port + MBOX_PORT3);
+
+		outb_p(ENABLE_MBOX_BYTE,
+				adapter->host->io_port + ENABLE_MBOX_REGION);
+
+		irq_ack(adapter);
+
+		irq_enable(adapter);
 	}
+
 	return 0;
 }
 
-/* Add command to the list of completed requests */
 
-static void mega_cmd_done (mega_host_config * megaCfg, mega_scb * pScb, int status)
+/*
+ * mega_query_adapter()
+ * @adapter - pointer to our soft state
+ *
+ * Issue the adapter inquiry commands to the controller and find out
+ * information and parameter about the devices attached
+ */
+static int
+mega_query_adapter(adapter_t *adapter)
 {
-	int islogical;
-	Scsi_Cmnd *SCpnt;
-	mega_passthru *pthru;
-	mega_ext_passthru *epthru;
-	mega_mailbox *mbox;
-	struct scatterlist *sgList;
-	u8	c;
+	dma_addr_t	prod_info_dma_handle;
+	mega_inquiry3	*inquiry3;
+	u8	raw_mbox[16];
+	mbox_t	*mbox;
+	int	retval;
 
-	if (pScb == NULL) {
-		TRACE (("NULL pScb in mega_cmd_done!"));
-		printk(KERN_CRIT "NULL pScb in mega_cmd_done!");
-	}
+	/* Initialize adapter inquiry mailbox */
 
-	SCpnt = pScb->SCpnt;
+	mbox = (mbox_t *)raw_mbox;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	pthru = pScb->pthru;
-	epthru = pScb->epthru;
-#else
-	pthru = &pScb->pthru;
-	epthru = &pScb->epthru;
-#endif
+	memset((void *)adapter->mega_buffer, 0, MEGA_BUFFER_SIZE);
+	memset(mbox, 0, 16);
 
-	mbox = (mega_mailbox *) & pScb->mboxData;
+	/*
+	 * Try to issue Inquiry3 command
+	 * if not succeeded, then issue MEGA_MBOXCMD_ADAPTERINQ command and
+	 * update enquiry3 structure
+	 */
+	mbox->xferaddr = (u32)adapter->buf_dma_handle;
 
-	if (SCpnt == NULL) {
-		TRACE (("NULL SCpnt in mega_cmd_done!"));
-		TRACE (("pScb->idx = ", pScb->idx));
-		TRACE (("pScb->state = ", pScb->state));
-		TRACE (("pScb->state = ", pScb->state));
-		panic(KERN_ERR "megaraid:Problem...!\n");
-	}
+	inquiry3 = (mega_inquiry3 *)adapter->mega_buffer;
 
-	islogical = ( (SCpnt->device->channel >= megaCfg->productInfo.SCSIChanPresent) &&
-					(SCpnt->device->channel <= megaCfg->host->max_channel) );
-#if 0
-	islogical = (SCpnt->device->channel == megaCfg->host->max_channel);
-#endif
+	raw_mbox[0] = FC_NEW_CONFIG;		/* i.e. mbox->cmd=0xA1 */
+	raw_mbox[2] = NC_SUBOP_ENQUIRY3;	/* i.e. 0x0F */
+	raw_mbox[3] = ENQ3_GET_SOLICITED_FULL;	/* i.e. 0x02 */
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	/* Special Case to handle PassThrough->XferAddrress > 4GB */
-	switch (SCpnt->cmnd[0]) {
-	case INQUIRY:
-	case READ_CAPACITY:
-		memcpy (SCpnt->request_buffer,
-			pScb->bounce_buffer, SCpnt->request_bufflen);
-		break;
+	/* Issue a blocking command to the card */
+	if ((retval = issue_scb_block(adapter, raw_mbox))) {
+		/* the adapter does not support 40ld */
+
+		mraid_ext_inquiry	*ext_inq;
+		mraid_inquiry		*inq;
+		dma_addr_t		dma_handle;
+
+		ext_inq = pci_alloc_consistent(adapter->dev,
+				sizeof(mraid_ext_inquiry), &dma_handle);
+
+		if( ext_inq == NULL ) return -1;
+
+		inq = &ext_inq->raid_inq;
+
+		mbox->xferaddr = (u32)dma_handle;
+
+		/*issue old 0x04 command to adapter */
+		mbox->cmd = MEGA_MBOXCMD_ADPEXTINQ;
+
+		issue_scb_block(adapter, raw_mbox);
+
+		/*
+		 * update Enquiry3 and ProductInfo structures with
+		 * mraid_inquiry structure
+		 */
+		mega_8_to_40ld(inq, inquiry3,
+				(mega_product_info *)&adapter->product_info);
+
+		pci_free_consistent(adapter->dev, sizeof(mraid_ext_inquiry),
+				ext_inq, dma_handle);
+
+	} else {		/*adapter supports 40ld */
+		adapter->flag |= BOARD_40LD;
+
+		/*
+		 * get product_info, which is static information and will be
+		 * unchanged
+		 */
+		prod_info_dma_handle = pci_map_single(adapter->dev, (void *)
+				&adapter->product_info,
+				sizeof(mega_product_info), PCI_DMA_FROMDEVICE);
+
+		mbox->xferaddr = prod_info_dma_handle;
+
+		raw_mbox[0] = FC_NEW_CONFIG;	/* i.e. mbox->cmd=0xA1 */
+		raw_mbox[2] = NC_SUBOP_PRODUCT_INFO;	/* i.e. 0x0E */
+
+		if ((retval = issue_scb_block(adapter, raw_mbox)))
+			printk(KERN_WARNING
+			"megaraid: Product_info cmd failed with error: %d\n",
+				retval);
+
+		pci_dma_sync_single(adapter->dev, prod_info_dma_handle,
+				sizeof(mega_product_info),
+				PCI_DMA_FROMDEVICE);
+
+		pci_unmap_single(adapter->dev, prod_info_dma_handle,
+				sizeof(mega_product_info), PCI_DMA_FROMDEVICE);
 	}
-#endif
 
-	mega_freeSCB (megaCfg, pScb);
 
 	/*
-	 * Do not return the presence of hard disk on the channel so, inquiry
-	 * sent, and returned data==hard disk or removable hard disk and not
-	 * logical, request should return failure! - PJ
+	 * kernel scans the channels from 0 to <= max_channel
 	 */
-#if 0
-	if (SCpnt->cmnd[0] == INQUIRY && ((((u_char *) SCpnt->request_buffer)[0] & 0x1F) == TYPE_DISK) && !islogical) {
-		status = 0xF0;
-	}
-#endif
-	
-	if (SCpnt->cmnd[0] == INQUIRY && !islogical) {
-		if ( SCpnt->use_sg ) {
-			sgList = (struct scatterlist *)SCpnt->request_buffer;
-			memcpy(&c, cpu_to_le32(sg_dma_address(&sgList[0])), 0x1);
-		} else {
-			memcpy(&c, SCpnt->request_buffer, 0x1);
-		}
-#if 0
-		if( (c & 0x1F ) == TYPE_DISK ) {
-			status = 0xF0;
-		}
-#endif
-		if( IS_RAID_CH(SCpnt->device->channel) && ((c & 0x1F ) == TYPE_DISK) ) {
-			status = 0xF0;
-		}
-	}
+	adapter->host->max_channel =
+		adapter->product_info.nchannels + NVIRT_CHAN -1;
 
+	adapter->host->max_id = 16;	/* max targets per channel */
 
-	/* clear result; otherwise, success returns corrupt value */
-	SCpnt->result = 0;
+	adapter->host->max_lun = 7;	/* Upto 7 luns for non disk devices */
 
-	if ((SCpnt->cmnd[0] & M_RD_IOCTL_CMD)) {	/* i.e. ioctl cmd such as M_RD_IOCTL_CMD, M_RD_IOCTL_CMD_NEW of megamgr */
-		switch (status) {
-		case 2:
-		case 0xF0:
-		case 0xF4:
-			SCpnt->result = (DID_BAD_TARGET << 16) | status;
-			break;
-		default:
-			SCpnt->result |= status;
-		}		/*end of switch */
-	} else {
-		/* Convert MegaRAID status to Linux error code */
-		switch (status) {
-		case 0x00:	/* SUCCESS , i.e. SCSI_STATUS_GOOD */
-			SCpnt->result |= (DID_OK << 16);
-			break;
+	adapter->host->cmd_per_lun = max_cmd_per_lun;
 
-		case 0x02:	/* ERROR_ABORTED, i.e. SCSI_STATUS_CHECK_CONDITION */
+	adapter->numldrv = inquiry3->num_ldrv;
 
-			/*set sense_buffer and result fields */
-			if (mbox->cmd == MEGA_MBOXCMD_PASSTHRU) {
-				memcpy (SCpnt->sense_buffer, pthru->reqsensearea, 14);
-			} else if (mbox->cmd == MEGA_MBOXCMD_EXTPASSTHRU) {
-				SCpnt->result = (DRIVER_SENSE << 24) | (DID_OK << 16) | (CHECK_CONDITION < 1);
-				memcpy(
-					SCpnt->sense_buffer,
-					epthru->reqsensearea, 14
-				);
-				SCpnt->result = (DRIVER_SENSE << 24) | (DID_OK << 16) | (CHECK_CONDITION < 1);
-				/*SCpnt->result =
-					(DRIVER_SENSE << 24) |
-					(DID_ERROR << 16) | status;*/
-			} else {
-				SCpnt->sense_buffer[0] = 0x70;
-				SCpnt->sense_buffer[2] = ABORTED_COMMAND;
-				SCpnt->result |= (CHECK_CONDITION << 1);
-			}
-			break;
+	adapter->max_cmds = adapter->product_info.max_commands;
 
-		case 0x08:	/* ERR_DEST_DRIVE_FAILED, i.e. SCSI_STATUS_BUSY */
-			SCpnt->result |= (DID_BUS_BUSY << 16) | status;
-			break;
+	if(adapter->max_cmds > MAX_COMMANDS)
+		adapter->max_cmds = MAX_COMMANDS;
 
-		default:
-			SCpnt->result |= (DID_BAD_TARGET << 16) | status;
-			break;
-		}
-	}
+	adapter->host->can_queue = adapter->max_cmds - 1;
 
-	/* Add Scsi_Command to end of completed queue */
-	if (megaCfg->qCompletedH == NULL) {
-		megaCfg->qCompletedH = megaCfg->qCompletedT = SCpnt;
+	/*
+	 * Get the maximum number of scatter-gather elements supported by this
+	 * firmware
+	 */
+	mega_get_max_sgl(adapter);
+
+	adapter->host->sg_tablesize = adapter->sglen;
+
+
+	/* use HP firmware and bios version encoding */
+	if (adapter->product_info.subsysvid == HP_SUBSYS_VID) {
+		sprintf (adapter->fw_version, "%c%d%d.%d%d",
+			 adapter->product_info.fw_version[2],
+			 adapter->product_info.fw_version[1] >> 8,
+			 adapter->product_info.fw_version[1] & 0x0f,
+			 adapter->product_info.fw_version[0] >> 8,
+			 adapter->product_info.fw_version[0] & 0x0f);
+		sprintf (adapter->bios_version, "%c%d%d.%d%d",
+			 adapter->product_info.bios_version[2],
+			 adapter->product_info.bios_version[1] >> 8,
+			 adapter->product_info.bios_version[1] & 0x0f,
+			 adapter->product_info.bios_version[0] >> 8,
+			 adapter->product_info.bios_version[0] & 0x0f);
 	} else {
-		megaCfg->qCompletedT->host_scribble = (unsigned char *) SCpnt;
-		megaCfg->qCompletedT = SCpnt;
+		memcpy(adapter->fw_version,
+				(char *)adapter->product_info.fw_version, 4);
+		adapter->fw_version[4] = 0;
+
+		memcpy(adapter->bios_version,
+				(char *)adapter->product_info.bios_version, 4);
+
+		adapter->bios_version[4] = 0;
 	}
 
-	megaCfg->qCompletedT->host_scribble = (unsigned char *) NULL;
-	megaCfg->qCcnt++;
+	printk(KERN_NOTICE "megaraid: [%s:%s] detected %d logical drives.\n",
+		adapter->fw_version, adapter->bios_version, adapter->numldrv);
+
+	/*
+	 * Do we support extended (>10 bytes) cdbs
+	 */
+	adapter->support_ext_cdb = mega_support_ext_cdb(adapter);
+	if (adapter->support_ext_cdb)
+		printk(KERN_NOTICE "megaraid: supports extended CDBs.\n");
+
+
+	return 0;
 }
 
-/*-------------------------------------------------------------------
+
+/*
+ * megaraid_queue()
+ * @scmd - Issue this scsi command
+ * @done - the callback hook into the scsi mid-layer
  *
- *                 Build a SCB from a Scsi_Cmnd
+ * The command queuing entry point for the mid-layer.
+ */
+static int
+megaraid_queue(Scsi_Cmnd *scmd, void (*done)(Scsi_Cmnd *))
+{
+	adapter_t	*adapter;
+	scb_t	*scb;
+	int	busy=0;
+
+	adapter = (adapter_t *)scmd->device->host->hostdata;
+
+	scmd->scsi_done = done;
+
+
+	/*
+	 * Allocate and build a SCB request
+	 * busy flag will be set if mega_build_cmd() command could not
+	 * allocate scb. We will return non-zero status in that case.
+	 * NOTE: scb can be null even though certain commands completed
+	 * successfully, e.g., MODE_SENSE and TEST_UNIT_READY, we would
+	 * return 0 in that case.
+	 */
+
+	scb = mega_build_cmd(adapter, scmd, &busy);
+
+	if(scb) {
+		scb->state |= SCB_PENDQ;
+		list_add_tail(&scb->list, &adapter->pending_list);
+
+		/*
+		 * Check if the HBA is in quiescent state, e.g., during a
+		 * delete logical drive opertion. If it is, don't run
+		 * the pending_list.
+		 */
+		if(atomic_read(&adapter->quiescent) == 0) {
+			mega_runpendq(adapter);
+		}
+		return 0;
+	}
+
+	return busy;
+}
+
+
+/**
+ * mega_build_cmd()
+ * @adapter - pointer to our soft state
+ * @cmd - Prepare using this scsi command
+ * @busy - busy flag if no resources
  *
- * Returns a SCB pointer, or NULL
- * If NULL is returned, the scsi_done function MUST have been called
+ * Prepares a command and scatter gather list for the controller. This routine
+ * also finds out if the commands is intended for a logical drive or a
+ * physical device and prepares the controller command accordingly.
  *
- *-------------------------------------------------------------------*/
-
-static mega_scb *mega_build_cmd (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt)
+ * We also re-order the logical drives and physical devices based on their
+ * boot settings.
+ */
+static scb_t *
+mega_build_cmd(adapter_t *adapter, Scsi_Cmnd *cmd, int *busy)
 {
-	mega_scb *pScb;
-	mega_mailbox *mbox;
-	mega_passthru *pthru;
-	mega_ext_passthru *epthru;
-	long seg;
-	char islogical;
-	int lun = SCpnt->device->lun;
-	int		max_lun;
-
-	if ((SCpnt->cmnd[0] == MEGADEVIOC))
-		return megadev_doioctl (megaCfg, SCpnt);
-
-	if ((SCpnt->cmnd[0] == M_RD_IOCTL_CMD)
-		    || (SCpnt->cmnd[0] == M_RD_IOCTL_CMD_NEW))
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)  
-		return mega_ioctl (megaCfg, SCpnt);	/* Handle IOCTL command */
-#else
-	{
-		printk(KERN_WARNING "megaraid ioctl: older interface - "
-				"not supported.\n");
-		return NULL;
+	mega_ext_passthru	*epthru;
+	mega_passthru	*pthru;
+	scb_t	*scb;
+	mbox_t	*mbox;
+	long	seg;
+	char	islogical;
+	int	max_ldrv_num;
+	int	channel = 0;
+	int	target = 0;
+	int	ldrv_num = 0;   /* logical drive number */
+
+
+	/*
+	 * filter the internal and ioctl commands
+	 */
+	if((cmd->cmnd[0] == MEGA_INTERNAL_CMD)) {
+		return cmd->buffer;
 	}
-#endif
 
-	islogical = ( (SCpnt->device->channel >= megaCfg->productInfo.SCSIChanPresent) &&
-					(SCpnt->device->channel <= megaCfg->host->max_channel) );
-#if 0
-	islogical = (IS_RAID_CH(SCpnt->device->channel) && /* virtual ch is raid - AM */
-						(SCpnt->device->channel == megaCfg->host->max_channel));
-#endif
 
-	if ( ! megaCfg->support_ext_cdb ) {
-		if (!islogical && lun != 0) {
-			SCpnt->result = (DID_BAD_TARGET << 16);
-			callDone (SCpnt);
-			return NULL;
+	/*
+	 * We know what channels our logical drives are on - mega_find_card()
+	 */
+	islogical = adapter->logdrv_chan[cmd->device->channel];
+
+	/*
+	 * The theory: If physical drive is chosen for boot, all the physical
+	 * devices are exported before the logical drives, otherwise physical
+	 * devices are pushed after logical drives, in which case - Kernel sees
+	 * the physical devices on virtual channel which is obviously converted
+	 * to actual channel on the HBA.
+	 */
+	if( adapter->boot_pdrv_enabled ) {
+		if( islogical ) {
+			/* logical channel */
+			channel = cmd->device->channel -
+				adapter->product_info.nchannels;
 		}
-	}
+		else {
+			/* this is physical channel */
+			channel = cmd->device->channel; 
+			target = cmd->device->id;
 
-	if (!islogical && SCpnt->device->id == skip_id) {
-		SCpnt->result = (DID_BAD_TARGET << 16);
-		callDone (SCpnt);
-		return NULL;
+			/*
+			 * boot from a physical disk, that disk needs to be
+			 * exposed first IF both the channels are SCSI, then
+			 * booting from the second channel is not allowed.
+			 */
+			if( target == 0 ) {
+				target = adapter->boot_pdrv_tgt;
+			}
+			else if( target == adapter->boot_pdrv_tgt ) {
+				target = 0;
+			}
+		}
+	}
+	else {
+		if( islogical ) {
+			/* this is the logical channel */
+			channel = cmd->device->channel;	
+		}
+		else {
+			/* physical channel */
+			channel = cmd->device->channel - NVIRT_CHAN;	
+			target = cmd->device->id;
+		}
 	}
 
-	if (islogical) {
+
+	if(islogical) {
 
 		/* have just LUN 0 for each target on virtual channels */
-		if( SCpnt->device->lun != 0 ) {
-			SCpnt->result = (DID_BAD_TARGET << 16);
-			callDone (SCpnt);
+		if (cmd->device->lun) {
+			cmd->result = (DID_BAD_TARGET << 16);
+			cmd->scsi_done(cmd);
 			return NULL;
 		}
 
-		lun = mega_get_lun(megaCfg, SCpnt);
+		ldrv_num = mega_get_ldrv_num(adapter, cmd, channel);
 
-	    max_lun = (megaCfg->flag & BOARD_40LD) ?
-						FC_MAX_LOGICAL_DRIVES : MAX_LOGICAL_DRIVES;
 
-		 /*
-		  * max_lun increases by 0x80 if some logical drive was deleted.
-		  */
-		if(megaCfg->read_ldidmap) {
-			max_lun += 0x80;
-		}
-
-		if( lun > max_lun ) {
-			SCpnt->result = (DID_BAD_TARGET << 16);
-			callDone (SCpnt);
-			return NULL;
-		}
+		max_ldrv_num = (adapter->flag & BOARD_40LD) ?
+			MAX_LOGICAL_DRIVES_40LD : MAX_LOGICAL_DRIVES_8LD;
 
 		/*
-		 * If we have a logical drive with boot enabled, project it first
+		 * max_ldrv_num increases by 0x80 if some logical drive was
+		 * deleted.
 		 */
-		if( megaCfg->boot_ldrv_enabled ) {
-			if( lun == 0 ) {
-				lun = megaCfg->boot_ldrv;
-			}
-			else {
-				if( lun <= megaCfg->boot_ldrv ) {
-					lun--;
-				}
-			}
+		if(adapter->read_ldidmap)
+			max_ldrv_num += 0x80;
+
+		if(ldrv_num > max_ldrv_num ) {
+			cmd->result = (DID_BAD_TARGET << 16);
+			cmd->scsi_done(cmd);
+			return NULL;
 		}
-	} else {
-		if ( lun > 7) {
-				/* Do not support lun >7 for physically accessed devices */
-			SCpnt->result = (DID_BAD_TARGET << 16);
-			callDone (SCpnt);
+
+	}
+	else {
+		if( cmd->device->lun > 7) {
+			/*
+			 * Do not support lun >7 for physically accessed
+			 * devices
+			 */
+			cmd->result = (DID_BAD_TARGET << 16);
+			cmd->scsi_done(cmd);
 			return NULL;
 		}
 	}
-	/*-----------------------------------------------------
+
+	/*
 	 *
-	 *               Logical drive commands
+	 * Logical drive commands
 	 *
-	 *-----------------------------------------------------*/
-	if (islogical) {
-		switch (SCpnt->cmnd[0]) {
+	 */
+	if(islogical) {
+		switch (cmd->cmnd[0]) {
 		case TEST_UNIT_READY:
-			memset (SCpnt->request_buffer, 0, SCpnt->request_bufflen);
-			SCpnt->result = (DID_OK << 16);
-			callDone (SCpnt);
+			memset(cmd->request_buffer, 0, cmd->request_bufflen);
+
+#if MEGA_HAVE_CLUSTERING
+			/*
+			 * Do we support clustering and is the support enabled
+			 * If no, return success always
+			 */
+			if( !adapter->has_cluster ) {
+				cmd->result = (DID_OK << 16);
+				cmd->scsi_done(cmd);
+				return NULL;
+			}
+
+			if(!(scb = mega_allocate_scb(adapter, cmd))) {
+
+				cmd->result = (DID_ERROR << 16);
+				cmd->scsi_done(cmd);
+				*busy = 1;
+
+				return NULL;
+			}
+
+			scb->raw_mbox[0] = MEGA_CLUSTER_CMD;
+			scb->raw_mbox[2] = MEGA_RESERVATION_STATUS;
+			scb->raw_mbox[3] = ldrv_num;
+
+			scb->dma_direction = PCI_DMA_NONE;
+
+			return scb;
+#else
+			cmd->result = (DID_OK << 16);
+			cmd->scsi_done(cmd);
 			return NULL;
+#endif
 
 		case MODE_SENSE:
-			memset (SCpnt->request_buffer, 0, SCpnt->cmnd[4]);
-			SCpnt->result = (DID_OK << 16);
-			callDone (SCpnt);
+			memset(cmd->request_buffer, 0, cmd->cmnd[4]);
+			cmd->result = (DID_OK << 16);
+			cmd->scsi_done(cmd);
 			return NULL;
 
 		case READ_CAPACITY:
 		case INQUIRY:
+
+			if(!(adapter->flag & (1L << cmd->device->channel))) {
+
+				printk(KERN_NOTICE
+					"scsi%d: scanning scsi channel %d ",
+						adapter->host->host_no,
+						cmd->device->channel);
+				printk("for logical drives.\n");
+
+				adapter->flag |= (1L << cmd->device->channel);
+			}
+
 			/* Allocate a SCB and initialize passthru */
-			if ((pScb = mega_allocateSCB (megaCfg, SCpnt)) == NULL) {
-				SCpnt->result = (DID_ERROR << 16);
-				callDone (SCpnt);
+			if(!(scb = mega_allocate_scb(adapter, cmd))) {
+
+				cmd->result = (DID_ERROR << 16);
+				cmd->scsi_done(cmd);
+				*busy = 1;
+
 				return NULL;
 			}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-			pthru = pScb->pthru;
-#else
-			pthru = &pScb->pthru;
-#endif
+			pthru = scb->pthru;
+
+			mbox = (mbox_t *)scb->raw_mbox;
+			memset(mbox, 0, sizeof(scb->raw_mbox));
+			memset(pthru, 0, sizeof(mega_passthru));
 
-			mbox = (mega_mailbox *) & pScb->mboxData;
-			memset (mbox, 0, sizeof (pScb->mboxData));
-			memset (pthru, 0, sizeof (mega_passthru));
 			pthru->timeout = 0;
 			pthru->ars = 1;
 			pthru->reqsenselen = 14;
 			pthru->islogical = 1;
-			pthru->logdrv = lun;
-			pthru->cdblen = SCpnt->cmd_len;
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-			/*Not sure about the direction */
-			pScb->dma_direction = PCI_DMA_BIDIRECTIONAL;
-			pScb->dma_type = M_RD_PTHRU_WITH_BULK_DATA;
+			pthru->logdrv = ldrv_num;
+			pthru->cdblen = cmd->cmd_len;
+			memcpy(pthru->cdb, cmd->cmnd, cmd->cmd_len);
 
-#if 0
-/* Normal Code w/o the need for bounce buffer */
-			pScb->dma_h_bulkdata
-			    = pci_map_single (megaCfg->dev,
-					      SCpnt->request_buffer,
-					      SCpnt->request_bufflen,
-					      pScb->dma_direction);
-
-			pthru->dataxferaddr = pScb->dma_h_bulkdata;
-#else
-/* Special Code to use bounce buffer for READ_CAPA/INQ */
-			pthru->dataxferaddr = pScb->dma_bounce_buffer;
-			pScb->dma_type = M_RD_DMA_TYPE_NONE;
-#endif
+			if( adapter->has_64bit_addr ) {
+				mbox->cmd = MEGA_MBOXCMD_PASSTHRU64;
+			}
+			else {
+				mbox->cmd = MEGA_MBOXCMD_PASSTHRU;
+			}
 
-#else
-			pthru->dataxferaddr =
-			    virt_to_bus (SCpnt->request_buffer);
-#endif
+			scb->dma_direction = PCI_DMA_FROMDEVICE;
 
-			pthru->dataxferlen = SCpnt->request_bufflen;
-			memcpy (pthru->cdb, SCpnt->cmnd, SCpnt->cmd_len);
+			pthru->numsgelements = mega_build_sglist(adapter, scb,
+				&pthru->dataxferaddr, &pthru->dataxferlen);
 
-			/* Initialize mailbox area */
-			mbox->cmd = MEGA_MBOXCMD_PASSTHRU;
+			mbox->xferaddr = scb->pthru_dma_addr;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-			mbox->xferaddr = pScb->dma_passthruhandle64;
-			TRACE1 (("M_RD_PTHRU_WITH_BULK_DATA Enabled \n"));
-#else
-			mbox->xferaddr = virt_to_bus (pthru);
-#endif
-			return pScb;
+			return scb;
 
 		case READ_6:
 		case WRITE_6:
 		case READ_10:
 		case WRITE_10:
+		case READ_12:
+		case WRITE_12:
+
 			/* Allocate a SCB and initialize mailbox */
-			if ((pScb = mega_allocateSCB (megaCfg, SCpnt)) == NULL) {
-				SCpnt->result = (DID_ERROR << 16);
-				callDone (SCpnt);
+			if(!(scb = mega_allocate_scb(adapter, cmd))) {
+
+				cmd->result = (DID_ERROR << 16);
+				cmd->scsi_done(cmd);
+				*busy = 1;
+
 				return NULL;
 			}
-			mbox = (mega_mailbox *) & pScb->mboxData;
+			mbox = (mbox_t *)scb->raw_mbox;
 
-			memset (mbox, 0, sizeof (pScb->mboxData));
-			mbox->logdrv = lun;
+			memset(mbox, 0, sizeof(scb->raw_mbox));
+			mbox->logdrv = ldrv_num;
+
+			/*
+			 * A little hack: 2nd bit is zero for all scsi read
+			 * commands and is set for all scsi write commands
+			 */
+			if( adapter->has_64bit_addr ) {
+				mbox->cmd = (*cmd->cmnd & 0x02) ?
+					MEGA_MBOXCMD_LWRITE64:
+					MEGA_MBOXCMD_LREAD64 ;
+			}
+			else {
+				mbox->cmd = (*cmd->cmnd & 0x02) ?
+					MEGA_MBOXCMD_LWRITE:
+					MEGA_MBOXCMD_LREAD ;
+			}
 
-			if (megaCfg->flag & BOARD_64BIT) {
-				mbox->cmd = (*SCpnt->cmnd == READ_6
-					     || *SCpnt->cmnd ==
-					     READ_10) ? MEGA_MBOXCMD_LREAD64 :
-				    MEGA_MBOXCMD_LWRITE64;
-			} else {
-				mbox->cmd = (*SCpnt->cmnd == READ_6
-					     || *SCpnt->cmnd ==
-					     READ_10) ? MEGA_MBOXCMD_LREAD :
-				    MEGA_MBOXCMD_LWRITE;
-			}
-
-			/* 6-byte */
-			if (*SCpnt->cmnd == READ_6 || *SCpnt->cmnd == WRITE_6) {
-				mbox->numsectors = (u32) SCpnt->cmnd[4];
+			/*
+			 * 6-byte READ(0x08) or WRITE(0x0A) cdb
+			 */
+			if( cmd->cmd_len == 6 ) {
+				mbox->numsectors = (u32) cmd->cmnd[4];
 				mbox->lba =
-				    ((u32) SCpnt->cmnd[1] << 16) |
-				    ((u32) SCpnt->cmnd[2] << 8) |
-				    (u32) SCpnt->cmnd[3];
+					((u32)cmd->cmnd[1] << 16) |
+					((u32)cmd->cmnd[2] << 8) |
+					(u32)cmd->cmnd[3];
+
 				mbox->lba &= 0x1FFFFF;
 
-				if (*SCpnt->cmnd == READ_6) {
-					megaCfg->nReads[(int) lun]++;
-					megaCfg->nReadBlocks[(int) lun] +=
-					    mbox->numsectors;
+#if MEGA_HAVE_STATS
+				/*
+				 * Take modulo 0x80, since the logical drive
+				 * number increases by 0x80 when a logical
+				 * drive was deleted
+				 */
+				if (*cmd->cmnd == READ_6) {
+					adapter->nreads[ldrv_num%0x80]++;
+					adapter->nreadblocks[ldrv_num%0x80] +=
+						mbox->numsectors;
 				} else {
-					megaCfg->nWrites[(int) lun]++;
-					megaCfg->nWriteBlocks[(int) lun] +=
-					    mbox->numsectors;
+					adapter->nwrites[ldrv_num%0x80]++;
+					adapter->nwriteblocks[ldrv_num%0x80] +=
+						mbox->numsectors;
 				}
+#endif
 			}
 
-			/* 10-byte */
-			if (*SCpnt->cmnd == READ_10 || *SCpnt->cmnd == WRITE_10) {
+			/*
+			 * 10-byte READ(0x28) or WRITE(0x2A) cdb
+			 */
+			if( cmd->cmd_len == 10 ) {
 				mbox->numsectors =
-				    (u32) SCpnt->cmnd[8] |
-				    ((u32) SCpnt->cmnd[7] << 8);
+					(u32)cmd->cmnd[8] |
+					((u32)cmd->cmnd[7] << 8);
 				mbox->lba =
-				    ((u32) SCpnt->cmnd[2] << 24) |
-				    ((u32) SCpnt->cmnd[3] << 16) |
-				    ((u32) SCpnt->cmnd[4] << 8) |
-				    (u32) SCpnt->cmnd[5];
-
-				if (*SCpnt->cmnd == READ_10) {
-					megaCfg->nReads[(int) lun]++;
-					megaCfg->nReadBlocks[(int) lun] +=
-					    mbox->numsectors;
+					((u32)cmd->cmnd[2] << 24) |
+					((u32)cmd->cmnd[3] << 16) |
+					((u32)cmd->cmnd[4] << 8) |
+					(u32)cmd->cmnd[5];
+
+#if MEGA_HAVE_STATS
+				if (*cmd->cmnd == READ_10) {
+					adapter->nreads[ldrv_num%0x80]++;
+					adapter->nreadblocks[ldrv_num%0x80] +=
+						mbox->numsectors;
 				} else {
-					megaCfg->nWrites[(int) lun]++;
-					megaCfg->nWriteBlocks[(int) lun] +=
-					    mbox->numsectors;
+					adapter->nwrites[ldrv_num%0x80]++;
+					adapter->nwriteblocks[ldrv_num%0x80] +=
+						mbox->numsectors;
 				}
+#endif
 			}
 
-			/* 12-byte */
-			if (*SCpnt->cmnd == READ_12 || *SCpnt->cmnd == WRITE_12) {
+			/*
+			 * 12-byte READ(0xA8) or WRITE(0xAA) cdb
+			 */
+			if( cmd->cmd_len == 12 ) {
 				mbox->lba =
-				    ((u32) SCpnt->cmnd[2] << 24) |
-				    ((u32) SCpnt->cmnd[3] << 16) |
-				    ((u32) SCpnt->cmnd[4] << 8) |
-				    (u32) SCpnt->cmnd[5];
+					((u32)cmd->cmnd[2] << 24) |
+					((u32)cmd->cmnd[3] << 16) |
+					((u32)cmd->cmnd[4] << 8) |
+					(u32)cmd->cmnd[5];
 
 				mbox->numsectors =
-				    ((u32) SCpnt->cmnd[6] << 24) |
-				    ((u32) SCpnt->cmnd[7] << 16) |
-				    ((u32) SCpnt->cmnd[8] << 8) |
-				    (u32) SCpnt->cmnd[9];
-
-				if (*SCpnt->cmnd == READ_12) {
-					megaCfg->nReads[(int) lun]++;
-					megaCfg->nReadBlocks[(int) lun] +=
-					    mbox->numsectors;
+					((u32)cmd->cmnd[6] << 24) |
+					((u32)cmd->cmnd[7] << 16) |
+					((u32)cmd->cmnd[8] << 8) |
+					(u32)cmd->cmnd[9];
+
+#if MEGA_HAVE_STATS
+				if (*cmd->cmnd == READ_12) {
+					adapter->nreads[ldrv_num%0x80]++;
+					adapter->nreadblocks[ldrv_num%0x80] +=
+						mbox->numsectors;
 				} else {
-					megaCfg->nWrites[(int) lun]++;
-					megaCfg->nWriteBlocks[(int) lun] +=
-					    mbox->numsectors;
+					adapter->nwrites[ldrv_num%0x80]++;
+					adapter->nwriteblocks[ldrv_num%0x80] +=
+						mbox->numsectors;
 				}
+#endif
 			}
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-			if (*SCpnt->cmnd == READ_6 || *SCpnt->cmnd == READ_10
-					|| *SCpnt->cmnd == READ_12) {
-				pScb->dma_direction = PCI_DMA_FROMDEVICE;
-			} else {	/*WRITE_6 or WRITE_10 */
-				pScb->dma_direction = PCI_DMA_TODEVICE;
+			/*
+			 * If it is a read command
+			 */
+			if( (*cmd->cmnd & 0x0F) == 0x08 ) {
+				scb->dma_direction = PCI_DMA_FROMDEVICE;
+			}
+			else {
+				scb->dma_direction = PCI_DMA_TODEVICE;
 			}
-#endif
 
 			/* Calculate Scatter-Gather info */
-			mbox->numsgelements = mega_build_sglist (megaCfg, pScb,
-								 (u32 *)&mbox->xferaddr, (u32 *)&seg);
+			mbox->numsgelements = mega_build_sglist(adapter, scb,
+					(u32 *)&mbox->xferaddr, (u32 *)&seg);
+
+			return scb;
+
+#if MEGA_HAVE_CLUSTERING
+		case RESERVE:	/* Fall through */
+		case RELEASE:
+
+			/*
+			 * Do we support clustering and is the support enabled
+			 */
+			if( ! adapter->has_cluster ) {
+
+				cmd->result = (DID_BAD_TARGET << 16);
+				cmd->scsi_done(cmd);
+				return NULL;
+			}
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-			pScb->iDataSize = seg;
+			/* Allocate a SCB and initialize mailbox */
+			if(!(scb = mega_allocate_scb(adapter, cmd))) {
+
+				cmd->result = (DID_ERROR << 16);
+				cmd->scsi_done(cmd);
+				*busy = 1;
 
-			if (mbox->numsgelements) {
-				pScb->dma_type = M_RD_SGLIST_ONLY;
-				TRACE1 (("M_RD_SGLIST_ONLY Enabled \n"));
-			} else {
-				pScb->dma_type = M_RD_BULK_DATA_ONLY;
-				TRACE1 (("M_RD_BULK_DATA_ONLY Enabled \n"));
+				return NULL;
 			}
+
+			scb->raw_mbox[0] = MEGA_CLUSTER_CMD;
+			scb->raw_mbox[2] = ( *cmd->cmnd == RESERVE ) ?
+				MEGA_RESERVE_LD : MEGA_RELEASE_LD;
+
+			scb->raw_mbox[3] = ldrv_num;
+
+			scb->dma_direction = PCI_DMA_NONE;
+
+			return scb;
 #endif
 
-			return pScb;
 		default:
-			SCpnt->result = (DID_BAD_TARGET << 16);
-			callDone (SCpnt);
+			cmd->result = (DID_BAD_TARGET << 16);
+			cmd->scsi_done(cmd);
 			return NULL;
 		}
 	}
-	/*-----------------------------------------------------
-	 *
-	 *               Passthru drive commands
-	 *
-	 *-----------------------------------------------------*/
+
+	/*
+	 * Passthru drive commands
+	 */
 	else {
 		/* Allocate a SCB and initialize passthru */
-		if ((pScb = mega_allocateSCB (megaCfg, SCpnt)) == NULL) {
-			SCpnt->result = (DID_ERROR << 16);
-			callDone (SCpnt);
+		if(!(scb = mega_allocate_scb(adapter, cmd))) {
+
+			cmd->result = (DID_ERROR << 16);
+			cmd->scsi_done(cmd);
+			*busy = 1;
+
 			return NULL;
 		}
 
-		mbox = (mega_mailbox *) pScb->mboxData;
-		memset (mbox, 0, sizeof (pScb->mboxData));
+		mbox = (mbox_t *)scb->raw_mbox;
+		memset(mbox, 0, sizeof(scb->raw_mbox));
+
+		if( adapter->support_ext_cdb ) {
+
+			epthru = mega_prepare_extpassthru(adapter, scb, cmd,
+					channel, target);
+
+			mbox->cmd = MEGA_MBOXCMD_EXTPTHRU;
+
+			mbox->xferaddr = scb->epthru_dma_addr;
 
-		if ( megaCfg->support_ext_cdb && SCpnt->cmd_len > 10 ) {
-			epthru = mega_prepare_extpassthru(megaCfg, pScb, SCpnt);
-			mbox->cmd = MEGA_MBOXCMD_EXTPASSTHRU;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-			mbox->xferaddr = pScb->dma_ext_passthruhandle64;
-
-			if(epthru->numsgelements) {
-				pScb->dma_type = M_RD_PTHRU_WITH_SGLIST;
-			} else {
-				pScb->dma_type = M_RD_EPTHRU_WITH_BULK_DATA;
-			}
-#else
-			mbox->xferaddr = virt_to_bus(epthru);
-#endif
 		}
 		else {
-			pthru = mega_prepare_passthru(megaCfg, pScb, SCpnt);
+
+			pthru = mega_prepare_passthru(adapter, scb, cmd,
+					channel, target);
 
 			/* Initialize mailbox */
-			mbox->cmd = MEGA_MBOXCMD_PASSTHRU;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-			mbox->xferaddr = pScb->dma_passthruhandle64;
-
-			if (pthru->numsgelements) {
-				pScb->dma_type = M_RD_PTHRU_WITH_SGLIST;
-			} else {
-				pScb->dma_type = M_RD_PTHRU_WITH_BULK_DATA;
+			if( adapter->has_64bit_addr ) {
+				mbox->cmd = MEGA_MBOXCMD_PASSTHRU64;
+			}
+			else {
+				mbox->cmd = MEGA_MBOXCMD_PASSTHRU;
 			}
-#else
-			mbox->xferaddr = virt_to_bus(pthru);
-#endif
-		}
-		return pScb;
-	}
-	return NULL;
-}
-
-static int
-mega_get_lun(mega_host_config *this_hba, Scsi_Cmnd *sc)
-{
-	int		tgt;
-	int		lun;
-	int		virt_chan;
-
-	tgt = sc->device->id;
-	
-	if ( tgt > 7 ) tgt--;	/* we do not get inquires for tgt 7 */
-
-	virt_chan = sc->device->channel - this_hba->productInfo.SCSIChanPresent;
-	lun = (virt_chan * 15) + tgt;
 
-	/*
-	 * If "delete logical drive" feature is enabled on this controller.
-	 * Do only if at least one delete logical drive operation was done.
-	 *
-	 * Also, after logical drive deletion, instead of logical drive number,
-	 * the value returned should be 0x80+logical drive id.
-	 *
-	 * These is valid only for IO commands.
-	 */
+			mbox->xferaddr = scb->pthru_dma_addr;
 
-	 if( this_hba->support_random_del && this_hba->read_ldidmap ) {
-		switch(sc->cmnd[0]) {
-		case READ_6:	/* fall through */
-		case WRITE_6:	/* fall through */
-		case READ_10:	/* fall through */
-		case WRITE_10:
-			lun += 0x80;
 		}
-	 }
-
-	 return lun;
+		return scb;
+	}
+	return NULL;
 }
 
 
+/**
+ * mega_prepare_passthru()
+ * @adapter - pointer to our soft state
+ * @scb - our scsi control block
+ * @cmd - scsi command from the mid-layer
+ * @channel - actual channel on the controller
+ * @target - actual id on the controller.
+ *
+ * prepare a command for the scsi physical devices.
+ */
 static mega_passthru *
-mega_prepare_passthru(mega_host_config *megacfg, mega_scb *scb, Scsi_Cmnd *sc)
+mega_prepare_passthru(adapter_t *adapter, scb_t *scb, Scsi_Cmnd *cmd,
+		int channel, int target)
 {
 	mega_passthru *pthru;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	pthru = scb->pthru;
-#else
-	pthru = &scb->pthru;
-#endif
-	memset (pthru, 0, sizeof (mega_passthru));
+	memset(pthru, 0, sizeof (mega_passthru));
 
-	/* set adapter timeout value to 10 min. for tape drive	*/
-	/* 0=6sec/1=60sec/2=10min/3=3hrs 			*/
+	/* 0=6sec/1=60sec/2=10min/3=3hrs */
 	pthru->timeout = 2;
+
 	pthru->ars = 1;
 	pthru->reqsenselen = 14;
 	pthru->islogical = 0;
-	pthru->channel = (megacfg->flag & BOARD_40LD) ? 0 : sc->device->channel;
-	pthru->target = (megacfg->flag & BOARD_40LD) ?
-	    (sc->device->channel << 4) | sc->device->id : sc->device->id;
-	pthru->cdblen = sc->cmd_len;
-	pthru->logdrv = sc->device->lun;
 
-	memcpy (pthru->cdb, sc->cmnd, sc->cmd_len);
+	pthru->channel = (adapter->flag & BOARD_40LD) ? 0 : channel;
+
+	pthru->target = (adapter->flag & BOARD_40LD) ?
+		(channel << 4) | target : target;
+
+	pthru->cdblen = cmd->cmd_len;
+	pthru->logdrv = cmd->device->lun;
+
+	memcpy(pthru->cdb, cmd->cmnd, cmd->cmd_len);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	/* Not sure about the direction */
 	scb->dma_direction = PCI_DMA_BIDIRECTIONAL;
 
 	/* Special Code for Handling READ_CAPA/ INQ using bounce buffers */
-	switch (sc->cmnd[0]) {
+	switch (cmd->cmnd[0]) {
 	case INQUIRY:
 	case READ_CAPACITY:
-		pthru->numsgelements = 0;
-		pthru->dataxferaddr = scb->dma_bounce_buffer;
-		pthru->dataxferlen = sc->request_bufflen;
-		break;
+		if(!(adapter->flag & (1L << cmd->device->channel))) {
+
+			printk(KERN_NOTICE
+				"scsi%d: scanning scsi channel %d [P%d] ",
+					adapter->host->host_no,
+					cmd->device->channel, channel);
+			printk("for physical devices.\n");
+
+			adapter->flag |= (1L << cmd->device->channel);
+		}
+		/* Fall through */
 	default:
-		pthru->numsgelements =
-			mega_build_sglist(
-				megacfg, scb, (u32 *)&pthru->dataxferaddr,
-				(u32 *)&pthru->dataxferlen
-			);
+		pthru->numsgelements = mega_build_sglist(adapter, scb,
+				&pthru->dataxferaddr, &pthru->dataxferlen);
 		break;
 	}
-#else
-	pthru->numsgelements =
-		mega_build_sglist(
-			megacfg, scb, (u32 *)&pthru->dataxferaddr,
-			(u32 *)&pthru->dataxferlen
-		);
-#endif
 	return pthru;
 }
 
+
+/**
+ * mega_prepare_extpassthru()
+ * @adapter - pointer to our soft state
+ * @scb - our scsi control block
+ * @cmd - scsi command from the mid-layer
+ * @channel - actual channel on the controller
+ * @target - actual id on the controller.
+ *
+ * prepare a command for the scsi physical devices. This rountine prepares
+ * commands for devices which can take extended CDBs (>10 bytes)
+ */
 static mega_ext_passthru *
-mega_prepare_extpassthru(mega_host_config *megacfg, mega_scb *scb, Scsi_Cmnd *sc)
+mega_prepare_extpassthru(adapter_t *adapter, scb_t *scb, Scsi_Cmnd *cmd,
+		int channel, int target)
 {
-	mega_ext_passthru *epthru;
+	mega_ext_passthru	*epthru;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	epthru = scb->epthru;
-#else
-	epthru = &scb->epthru;
-#endif
 	memset(epthru, 0, sizeof(mega_ext_passthru));
 
-	/* set adapter timeout value to 10 min. for tape drive	*/
-	/* 0=6sec/1=60sec/2=10min/3=3hrs 			*/
+	/* 0=6sec/1=60sec/2=10min/3=3hrs */
 	epthru->timeout = 2;
+
 	epthru->ars = 1;
 	epthru->reqsenselen = 14;
 	epthru->islogical = 0;
-	epthru->channel = (megacfg->flag & BOARD_40LD) ? 0 : sc->device->channel;
-	epthru->target = (megacfg->flag & BOARD_40LD) ?
-	    (sc->device->channel << 4) | sc->device->id : sc->device->id;
-	epthru->cdblen = sc->cmd_len;
-	epthru->logdrv = sc->device->lun;
 
-	memcpy(epthru->cdb, sc->cmnd, sc->cmd_len);
+	epthru->channel = (adapter->flag & BOARD_40LD) ? 0 : channel;
+	epthru->target = (adapter->flag & BOARD_40LD) ?
+		(channel << 4) | target : target;
+
+	epthru->cdblen = cmd->cmd_len;
+	epthru->logdrv = cmd->device->lun;
+
+	memcpy(epthru->cdb, cmd->cmnd, cmd->cmd_len);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	/* Not sure about the direction */
 	scb->dma_direction = PCI_DMA_BIDIRECTIONAL;
 
-	/* Special Code for Handling READ_CAPA/ INQ using bounce buffers */
-	switch (sc->cmnd[0]) {
+	switch(cmd->cmnd[0]) {
 	case INQUIRY:
 	case READ_CAPACITY:
-		epthru->numsgelements = 0;
-		epthru->dataxferaddr = scb->dma_bounce_buffer;
-		epthru->dataxferlen = sc->request_bufflen;
-		break;
+		if(!(adapter->flag & (1L << cmd->device->channel))) {
+
+			printk(KERN_NOTICE
+				"scsi%d: scanning scsi channel %d [P%d] ",
+					adapter->host->host_no,
+					cmd->device->channel, channel);
+			printk("for physical devices.\n");
+
+			adapter->flag |= (1L << cmd->device->channel);
+		}
+		/* Fall through */
 	default:
-		epthru->numsgelements =
-			mega_build_sglist(
-				megacfg, scb, (u32 *)&epthru->dataxferaddr,
-				(u32 *)&epthru->dataxferlen
-			);
+		epthru->numsgelements = mega_build_sglist(adapter, scb,
+				&epthru->dataxferaddr, &epthru->dataxferlen);
 		break;
 	}
-#else
-	epthru->numsgelements =
-		mega_build_sglist(
-			megacfg, scb, (u32 *)&epthru->dataxferaddr,
-			(u32 *)&epthru->dataxferlen
-		);
-#endif
+
 	return epthru;
 }
 
-/* Handle Driver Level IOCTLs
- * Return value of 0 indicates this function could not handle , so continue
- * processing
-*/
 
-static int mega_driver_ioctl (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt)
+/**
+ * mega_allocate_scb()
+ * @adapter - pointer to our soft state
+ * @cmd - scsi command from the mid-layer
+ *
+ * Allocate a SCB structure. This is the central structure for controller
+ * commands.
+ */
+static inline scb_t *
+mega_allocate_scb(adapter_t *adapter, Scsi_Cmnd *cmd)
 {
-	unsigned char *data = (unsigned char *) SCpnt->request_buffer;
-	mega_driver_info driver_info;
+	struct list_head *head = &adapter->free_list;
+	scb_t	*scb;
 
-	/* If this is not our command don't do anything */
-	if (SCpnt->cmnd[0] != M_RD_DRIVER_IOCTL_INTERFACE)
-		return 0;
+	/* Unlink command from Free List */
+	if( !list_empty(head) ) {
 
-	switch (SCpnt->cmnd[1]) {
-	case GET_DRIVER_INFO:
-		if (SCpnt->request_bufflen < sizeof (driver_info)) {
-			SCpnt->result = DID_BAD_TARGET << 16;
-			callDone (SCpnt);
-			return 1;
+		scb = list_entry(head->next, scb_t, list);
+
+		list_del_init(head->next);
+
+		scb->state = SCB_ACTIVE;
+		scb->cmd = cmd;
+		scb->dma_type = MEGA_DMA_TYPE_NONE;
+
+		return scb;
+	}
+
+	return NULL;
+}
+
+
+/**
+ * mega_runpendq()
+ * @adapter - pointer to our soft state
+ *
+ * Runs through the list of pending requests.
+ */
+static inline void
+mega_runpendq(adapter_t *adapter)
+{
+	if(!list_empty(&adapter->pending_list))
+		__mega_runpendq(adapter);
+}
+
+static void
+__mega_runpendq(adapter_t *adapter)
+{
+	scb_t *scb;
+	struct list_head *pos, *next;
+
+	/* Issue any pending commands to the card */
+	list_for_each_safe(pos, next, &adapter->pending_list) {
+
+		scb = list_entry(pos, scb_t, list);
+
+		if( !(scb->state & SCB_ISSUED) ) {
+
+			if( issue_scb(adapter, scb) != 0 )
+				return;
 		}
+	}
+
+	return;
+}
+
+
+/**
+ * issue_scb()
+ * @adapter - pointer to our soft state
+ * @scb - scsi control block
+ *
+ * Post a command to the card if the mailbox is available, otherwise return
+ * busy. We also take the scb from the pending list if the mailbox is
+ * available.
+ */
+static inline int
+issue_scb(adapter_t *adapter, scb_t *scb)
+{
+	volatile mbox64_t	*mbox64 = adapter->mbox64;
+	volatile mbox_t		*mbox = adapter->mbox;
+	unsigned int	i = 0;
+
+	if(unlikely(mbox->busy)) {
+		do {
+			udelay(1);
+			i++;
+		} while( mbox->busy && (i < max_mbox_busy_wait) );
+
+		if(mbox->busy) return -1;
+	}
+
+	/* Copy mailbox data into host structure */
+	memcpy((char *)mbox, (char *)scb->raw_mbox, 16);
+
+	mbox->cmdid = scb->idx;	/* Set cmdid */
+	mbox->busy = 1;		/* Set busy */
+
+
+	/*
+	 * Increment the pending queue counter
+	 */
+	atomic_inc(&adapter->pend_cmds);
 
-		driver_info.size = sizeof (driver_info) - sizeof (int);
-		driver_info.version = MEGARAID_IOCTL_VERSION;
-		memcpy (data, &driver_info, sizeof (driver_info));
+	switch (mbox->cmd) {
+	case MEGA_MBOXCMD_LREAD64:
+	case MEGA_MBOXCMD_LWRITE64:
+	case MEGA_MBOXCMD_PASSTHRU64:
+	case MEGA_MBOXCMD_EXTPTHRU:
+		mbox64->xfer_segment_lo = mbox->xferaddr;
+		mbox64->xfer_segment_hi = 0;
+		mbox->xferaddr = 0xFFFFFFFF;
 		break;
 	default:
-		SCpnt->result = DID_BAD_TARGET << 16;
+		mbox64->xfer_segment_lo = 0;
+		mbox64->xfer_segment_hi = 0;
+	}
+
+	/*
+	 * post the command
+	 */
+	scb->state |= SCB_ISSUED;
+
+	if( likely(adapter->flag & BOARD_MEMMAP) ) {
+		mbox->poll = 0;
+		mbox->ack = 0;
+		WRINDOOR(adapter, adapter->mbox_dma | 0x1);
+	}
+	else {
+		irq_enable(adapter);
+		issue_command(adapter);
 	}
 
-	callDone (SCpnt);
-	return 1;
+	return 0;
 }
 
-static inline void set_mbox_xfer_addr (mega_host_config * megaCfg, mega_scb * pScb,
-		    mega_ioctl_mbox * mbox, u32 direction)
+
+/**
+ * issue_scb_block()
+ * @adapter - pointer to our soft state
+ * @raw_mbox - the mailbox
+ *
+ * Issue a scb in synchronous and non-interrupt mode
+ */
+static int
+issue_scb_block(adapter_t *adapter, u_char *raw_mbox)
 {
+	volatile mbox64_t *mbox64 = adapter->mbox64;
+	volatile mbox_t *mbox = adapter->mbox;
+	u8	byte;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	switch (direction) {
-	case TO_DEVICE:
-		pScb->dma_direction = PCI_DMA_TODEVICE;
-		break;
-	case FROM_DEVICE:
-		pScb->dma_direction = PCI_DMA_FROMDEVICE;
-		break;
-	case FROMTO_DEVICE:
-		pScb->dma_direction = PCI_DMA_BIDIRECTIONAL;
+	raw_mbox[0x1] = 0xFE;	/* Set cmdid */
+	raw_mbox[0xF] = 1;	/* Set busy */
+
+	/* Wait until mailbox is free */
+	if(mega_busywait_mbox (adapter))
+		goto bug_blocked_mailbox;
+
+	/* Copy mailbox data into host structure */
+	memcpy((char *) mbox, raw_mbox, 16);
+
+	switch (raw_mbox[0]) {
+	case MEGA_MBOXCMD_LREAD64:
+	case MEGA_MBOXCMD_LWRITE64:
+	case MEGA_MBOXCMD_PASSTHRU64:
+	case MEGA_MBOXCMD_EXTPTHRU:
+		mbox64->xfer_segment_lo = mbox->xferaddr;
+		mbox64->xfer_segment_hi = 0;
+		mbox->xferaddr = 0xFFFFFFFF;
 		break;
+	default:
+		mbox64->xfer_segment_lo = 0;
+		mbox64->xfer_segment_hi = 0;
 	}
 
-	pScb->dma_h_bulkdata
-	    = pci_map_single (megaCfg->dev,
-			      pScb->buff_ptr,
-			      pScb->iDataSize, pScb->dma_direction);
-	mbox->xferaddr = pScb->dma_h_bulkdata;
-	pScb->dma_type = M_RD_BULK_DATA_ONLY;
-	TRACE1 (("M_RD_BULK_DATA_ONLY Enabled \n"));
-#else
-	mbox->xferaddr = virt_to_bus (pScb->buff_ptr);
-#endif
-}
+	if( likely(adapter->flag & BOARD_MEMMAP) ) {
+		mbox->poll = 0;
+		mbox->ack = 0;
+		mbox->numstatus = 0xFF;
+		mbox->status = 0xFF;
+		WRINDOOR(adapter, adapter->mbox_dma | 0x1);
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
+		while((volatile u8)mbox->numstatus == 0xFF)
+			cpu_relax();
 
-/*--------------------------------------------------------------------
- * build RAID commands for controller, passed down through ioctl()
- *--------------------------------------------------------------------*/
-static mega_scb *mega_ioctl (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt)
-{
-	mega_scb *pScb;
-	mega_ioctl_mbox *mbox;
-	mega_mailbox *mailbox;
-	mega_passthru *pthru;
-	u8 *mboxdata;
-	long seg, i = 0;
-	unsigned char *data = (unsigned char *) SCpnt->request_buffer;
-
-	if ((pScb = mega_allocateSCB (megaCfg, SCpnt)) == NULL) {
-		SCpnt->result = (DID_ERROR << 16);
-		callDone (SCpnt);
-		return NULL;
-	}
-	pthru = &pScb->pthru;
-
-	mboxdata = (u8 *) & pScb->mboxData;
-	mbox = (mega_ioctl_mbox *) & pScb->mboxData;
-	mailbox = (mega_mailbox *) & pScb->mboxData;
-	memset (mailbox, 0, sizeof (pScb->mboxData));
-
-	if (data[0] == 0x03) {	/* passthrough command */
-		unsigned char cdblen = data[2];
-		memset (pthru, 0, sizeof (mega_passthru));
-		pthru->islogical = (data[cdblen + 3] & 0x80) ? 1 : 0;
-		pthru->timeout = data[cdblen + 3] & 0x07;
-		pthru->reqsenselen = 14;
-		pthru->ars = (data[cdblen + 3] & 0x08) ? 1 : 0;
-		pthru->logdrv = data[cdblen + 4];
-		pthru->channel = data[cdblen + 5];
-		pthru->target = data[cdblen + 6];
-		pthru->cdblen = cdblen;
-		memcpy (pthru->cdb, &data[3], cdblen);
-
-		mailbox->cmd = MEGA_MBOXCMD_PASSTHRU;
-
-
-		pthru->numsgelements = mega_build_sglist (megaCfg, pScb,
-							  (u32 *) & pthru->
-							  dataxferaddr,
-							  (u32 *) & pthru->
-							  dataxferlen);
-
-		mailbox->xferaddr = virt_to_bus (pthru);
-
-		for (i = 0; i < (SCpnt->request_bufflen - cdblen - 7); i++) {
-			data[i] = data[i + cdblen + 7];
-		}
-		return pScb;
-	}
-	/* else normal (nonpassthru) command */
-
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,0,24)	/*0x020024 */
-	/*
-	 *usage of the function copy from user is used in case of data more than
-	 *4KB.This is used only with adapters which supports more than 8 logical
-	 * drives.This feature is disabled on kernels earlier or same as 2.0.36
-	 * as the uaccess.h file is not available with those kernels.
-	 */
-
-	if (SCpnt->cmnd[0] == M_RD_IOCTL_CMD_NEW) {
-		/* use external data area for large xfers  */
-		/* If cmnd[0] is set to M_RD_IOCTL_CMD_NEW then *
-		 *   cmnd[4..7] = external user buffer     *
-		 *   cmnd[8..11] = length of buffer        *
-		 *                                         */
-      	char *user_area = (char *)*((u32*)&SCpnt->cmnd[4]);
-		u32 xfer_size = *((u32 *) & SCpnt->cmnd[8]);
-		switch (data[0]) {
-		case FW_FIRE_WRITE:
-		case FW_FIRE_FLASH:
-			if ((ulong) user_area & (PAGE_SIZE - 1)) {
-				printk
-				    ("megaraid:user address not aligned on 4K boundary.Error.\n");
-				SCpnt->result = (DID_ERROR << 16);
-				callDone (SCpnt);
-				return NULL;
-			}
-			break;
-		default:
-			break;
-		}
+		mbox->numstatus = 0xFF;
 
-		if (!(pScb->buff_ptr = kmalloc (xfer_size, GFP_KERNEL))) {
-			printk
-			    ("megaraid: Insufficient mem for M_RD_IOCTL_CMD_NEW.\n");
-			SCpnt->result = (DID_ERROR << 16);
-			callDone (SCpnt);
-			return NULL;
-		}
+		while( (volatile u8)mbox->poll != 0x77 )
+			cpu_relax();
 
-		copy_from_user (pScb->buff_ptr, user_area, xfer_size);
-		pScb->iDataSize = xfer_size;
+		mbox->poll = 0;
+		mbox->ack = 0x77;
 
-		switch (data[0]) {
-		case DCMD_FC_CMD:
-			switch (data[1]) {
-			case DCMD_FC_READ_NVRAM_CONFIG:
-			case DCMD_GET_DISK_CONFIG:
-				{
-					if ((ulong) pScb->
-					    buff_ptr & (PAGE_SIZE - 1)) {
-						printk
-						    ("megaraid:user address not sufficient Error.\n");
-						SCpnt->result =
-						    (DID_ERROR << 16);
-						callDone (SCpnt);
-						return NULL;
-					}
-
-					/*building SG list */
-					mega_build_kernel_sg (pScb->buff_ptr,
-							      xfer_size,
-							      pScb, mbox);
-					break;
-				}
-			default:
-				break;
-			}	/*switch (data[1]) */
-			break;
-		}
+		WRINDOOR(adapter, adapter->mbox_dma | 0x2);
 
+		while(RDINDOOR(adapter) & 0x2)
+			cpu_relax();
 	}
-#endif
+	else {
+		irq_disable(adapter);
+		issue_command(adapter);
 
-	mbox->cmd = data[0];
-	mbox->channel = data[1];
-	mbox->param = data[2];
-	mbox->pad[0] = data[3];
-	mbox->logdrv = data[4];
-
-	if (SCpnt->cmnd[0] == M_RD_IOCTL_CMD_NEW) {
-		switch (data[0]) {
-		case FW_FIRE_WRITE:
-			mbox->cmd = FW_FIRE_WRITE;
-			mbox->channel = data[1];	/* Current Block Number */
-			set_mbox_xfer_addr (megaCfg, pScb, mbox, TO_DEVICE);
-			mbox->numsgelements = 0;
-			break;
-		case FW_FIRE_FLASH:
-			mbox->cmd = FW_FIRE_FLASH;
-			mbox->channel = data[1] | 0x80;	/* Origin */
-			set_mbox_xfer_addr (megaCfg, pScb, mbox, TO_DEVICE);
-			mbox->numsgelements = 0;
-			break;
-		case DCMD_FC_CMD:
-			*(mboxdata + 0) = data[0];	/*mailbox byte 0: DCMD_FC_CMD */
-			*(mboxdata + 2) = data[1];	/*sub command */
-			switch (data[1]) {
-			case DCMD_FC_READ_NVRAM_CONFIG:
-			case DCMD_FC_READ_NVRAM_CONFIG_64:
-				/* number of elements in SG list */
-				*(mboxdata + 3) = mbox->numsgelements;
-				if (megaCfg->flag & BOARD_64BIT)
-					*(mboxdata + 2) =
-					    DCMD_FC_READ_NVRAM_CONFIG_64;
-				break;
-			case DCMD_WRITE_CONFIG:
-			case DCMD_WRITE_CONFIG_64:
-				if (megaCfg->flag & BOARD_64BIT)
-					*(mboxdata + 2) = DCMD_WRITE_CONFIG_64;
-				set_mbox_xfer_addr (megaCfg, pScb, mbox,
-						    TO_DEVICE);
-				mbox->numsgelements = 0;
-				break;
-			case DCMD_GET_DISK_CONFIG:
-			case DCMD_GET_DISK_CONFIG_64:
-				if (megaCfg->flag & BOARD_64BIT)
-					*(mboxdata + 2) =
-					    DCMD_GET_DISK_CONFIG_64;
-				*(mboxdata + 3) = data[2];	/*number of elements in SG list */
-				/*nr of elements in SG list */
-				*(mboxdata + 4) = mbox->numsgelements;
-				break;
-			case DCMD_DELETE_LOGDRV:
-			case DCMD_DELETE_DRIVEGROUP:
-			case NC_SUBOP_ENQUIRY3:
-				*(mboxdata + 3) = data[2];
-				set_mbox_xfer_addr (megaCfg, pScb, mbox,
-						    FROMTO_DEVICE);
-				mbox->numsgelements = 0;
-				break;
-			case DCMD_CHANGE_LDNO:
-			case DCMD_CHANGE_LOOPID:
-				*(mboxdata + 3) = data[2];
-				*(mboxdata + 4) = data[3];
-				set_mbox_xfer_addr (megaCfg, pScb, mbox,
-						    TO_DEVICE);
-				mbox->numsgelements = 0;
-				break;
-			default:
-				set_mbox_xfer_addr (megaCfg, pScb, mbox,
-						    FROMTO_DEVICE);
-				mbox->numsgelements = 0;
-				break;
-			}	/*switch */
-			break;
-		default:
-			set_mbox_xfer_addr (megaCfg, pScb, mbox, FROMTO_DEVICE);
-			mbox->numsgelements = 0;
-			break;
-		}
-	} else {
+		while (!((byte = irq_state(adapter)) & INTR_VALID))
+			cpu_relax();
 
-		mbox->numsgelements = mega_build_sglist (megaCfg, pScb,
-							 (u32 *) & mbox->
-							 xferaddr,
-							 (u32 *) & seg);
-
-		/* Handling some of the fw special commands */
-		switch (data[0]) {
-		case 6:	/* START_DEV */
-			mbox->xferaddr = *((u32 *) & data[i + 6]);
-			break;
-		default:
-			break;
+		set_irq_state(adapter, byte);
+		irq_enable(adapter);
+		irq_ack(adapter);
+	}
+
+	return mbox->status;
+
+bug_blocked_mailbox:
+	printk(KERN_WARNING "megaraid: Blocked mailbox......!!\n");
+	udelay (1000);
+	return -1;
+}
+
+
+/**
+ * megaraid_isr_iomapped()
+ * @irq - irq
+ * @devp - pointer to our soft state
+ * @regs - unused
+ *
+ * Interrupt service routine for io-mapped controllers.
+ * Find out if our device is interrupting. If yes, acknowledge the interrupt
+ * and service the completed commands.
+ */
+static irqreturn_t
+megaraid_isr_iomapped(int irq, void *devp, struct pt_regs *regs)
+{
+	adapter_t	*adapter = devp;
+	unsigned long	flags;
+	u8	status;
+	u8	nstatus;
+	u8	completed[MAX_FIRMWARE_STATUS];
+	u8	byte;
+	int	handled = 0;
+
+
+	/*
+	 * loop till F/W has more commands for us to complete.
+	 */
+	spin_lock_irqsave(&adapter->lock, flags);
+
+	do {
+		/* Check if a valid interrupt is pending */
+		byte = irq_state(adapter);
+		if( (byte & VALID_INTR_BYTE) == 0 ) {
+			/*
+			 * No more pending commands
+			 */
+			goto out_unlock;
 		}
+		set_irq_state(adapter, byte);
 
-		for (i = 0; i < (SCpnt->request_bufflen - 6); i++) {
-			data[i] = data[i + 6];
+		while((nstatus = (volatile u8)adapter->mbox->numstatus)
+				== 0xFF)
+			cpu_relax();
+		adapter->mbox->numstatus = 0xFF;
+
+		status = adapter->mbox->status;
+
+		/*
+		 * decrement the pending queue counter
+		 */
+		atomic_sub(nstatus, &adapter->pend_cmds);
+
+		memcpy(completed, (void *)adapter->mbox->completed, nstatus);
+
+		/* Acknowledge interrupt */
+		irq_ack(adapter);
+
+		mega_cmd_done(adapter, completed, nstatus, status);
+
+		mega_rundoneq(adapter);
+
+		handled = 1;
+
+		/* Loop through any pending requests */
+		if(atomic_read(&adapter->quiescent) == 0) {
+			mega_runpendq(adapter);
 		}
-	}
 
-	return (pScb);
+	} while(1);
+
+ out_unlock:
+
+	spin_unlock_irqrestore(&adapter->lock, flags);
+
+	return IRQ_RETVAL(handled);
 }
 
 
-static void mega_build_kernel_sg (char *barea, ulong xfersize, mega_scb * pScb, mega_ioctl_mbox * mbox)
+/**
+ * megaraid_isr_memmapped()
+ * @irq - irq
+ * @devp - pointer to our soft state
+ * @regs - unused
+ *
+ * Interrupt service routine for memory-mapped controllers.
+ * Find out if our device is interrupting. If yes, acknowledge the interrupt
+ * and service the completed commands.
+ */
+static irqreturn_t
+megaraid_isr_memmapped(int irq, void *devp, struct pt_regs *regs)
 {
-	ulong i, buffer_area, len, end, end_page, x, idx = 0;
+	adapter_t	*adapter = devp;
+	unsigned long	flags;
+	u8	status;
+	u32	dword = 0;
+	u8	nstatus;
+	u8	completed[MAX_FIRMWARE_STATUS];
+	int	handled = 0;
 
-	buffer_area = (ulong) barea;
-	i = buffer_area;
-	end = buffer_area + xfersize;
-	end_page = (end) & ~(PAGE_SIZE - 1);
+
+	/*
+	 * loop till F/W has more commands for us to complete.
+	 */
+	spin_lock_irqsave(&adapter->lock, flags);
 
 	do {
-		len = PAGE_SIZE - (i % PAGE_SIZE);
-		x = pScb->sgList[idx].address =
-		    virt_to_bus ((volatile void *) i);
-		pScb->sgList[idx].length = len;
-		i += len;
-		idx++;
-	} while (i < end_page);
-
-	if ((end - i) < 0) {
-		printk ("megaraid:Error in user address\n");
-	}
-
-	if (end - i) {
-		pScb->sgList[idx].address = virt_to_bus ((volatile void *) i);
-		pScb->sgList[idx].length = end - i;
-		idx++;
-	}
-	mbox->xferaddr = virt_to_bus (pScb->sgList);
-	mbox->numsgelements = idx;
-}
-#endif
+		/* Check if a valid interrupt is pending */
+		dword = RDOUTDOOR(adapter);
+		if(dword != 0x10001234) {
+			/*
+			 * No more pending commands
+			 */
+			goto out_unlock;
+		}
+		WROUTDOOR(adapter, 0x10001234);
 
+		while((nstatus = (volatile u8)adapter->mbox->numstatus)
+				== 0xFF) {
+			cpu_relax();
+		}
+		adapter->mbox->numstatus = 0xFF;
 
-#if DEBUG
-static unsigned int cum_time = 0;
-static unsigned int cum_time_cnt = 0;
+		status = adapter->mbox->status;
 
-static void showMbox (mega_scb * pScb)
-{
-	mega_mailbox *mbox;
+		/*
+		 * decrement the pending queue counter
+		 */
+		atomic_sub(nstatus, &adapter->pend_cmds);
 
-	if (pScb == NULL)
-		return;
+		memcpy(completed, (void *)adapter->mbox->completed, nstatus);
 
-	mbox = (mega_mailbox *) pScb->mboxData;
-	printk ("%u cmd:%x id:%x #scts:%x lba:%x addr:%x logdrv:%x #sg:%x\n",
-		pScb->SCpnt->pid,
-		mbox->cmd, mbox->cmdid, mbox->numsectors,
-		mbox->lba, mbox->xferaddr, mbox->logdrv, mbox->numsgelements);
-}
+		/* Acknowledge interrupt */
+		WRINDOOR(adapter, 0x2);
 
-#endif
+		handled = 1;
+
+		while( RDINDOOR(adapter) & 0x02 ) cpu_relax();
+
+		mega_cmd_done(adapter, completed, nstatus, status);
 
-/*--------------------------------------------------------------------
- * Interrupt service routine
- *--------------------------------------------------------------------*/
-static void megaraid_isr (int irq, void *devp, struct pt_regs *regs)
-{
-	IO_LOCK_T;
-	mega_host_config * megaCfg;
-	u_char byte, idx, sIdx, tmpBox[MAILBOX_SIZE];
-	u32 dword = 0;
-	mega_mailbox *mbox;
-	mega_scb *pScb;
-	u_char qCnt, qStatus;
-	u_char completed[MAX_FIRMWARE_STATUS];
-	Scsi_Cmnd *SCpnt;
-
-	megaCfg = (mega_host_config *) devp;
-	mbox = (mega_mailbox *) tmpBox;
-
-	if (megaCfg->host->irq == irq) {
-		if (megaCfg->flag & IN_ISR) {
-			TRACE (("ISR called reentrantly!!\n"));
-			printk ("ISR called reentrantly!!\n");
+		mega_rundoneq(adapter);
+
+		/* Loop through any pending requests */
+		if(atomic_read(&adapter->quiescent) == 0) {
+			mega_runpendq(adapter);
 		}
-		megaCfg->flag |= IN_ISR;
 
-		if (mega_busyWaitMbox (megaCfg)) {
-			printk (KERN_WARNING "Error: mailbox busy in isr!\n");
+	} while(1);
+
+ out_unlock:
+
+	spin_unlock_irqrestore(&adapter->lock, flags);
+
+	return IRQ_RETVAL(handled);
+}
+/**
+ * mega_cmd_done()
+ * @adapter - pointer to our soft state
+ * @completed - array of ids of completed commands
+ * @nstatus - number of completed commands
+ * @status - status of the last command completed
+ *
+ * Complete the comamnds and call the scsi mid-layer callback hooks.
+ */
+static inline void
+mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)
+{
+	mega_ext_passthru	*epthru = NULL;
+	struct scatterlist	*sgl;
+	Scsi_Cmnd	*cmd = NULL;
+	mega_passthru	*pthru = NULL;
+	mbox_t	*mbox = NULL;
+	u8	c;
+	scb_t	*scb;
+	int	islogical;
+	int	cmdid;
+	int	i;
+
+	/*
+	 * for all the commands completed, call the mid-layer callback routine
+	 * and free the scb.
+	 */
+	for( i = 0; i < nstatus; i++ ) {
+
+		cmdid = completed[i];
+
+		if( cmdid == CMDID_INT_CMDS ) { /* internal command */
+			scb = &adapter->int_scb;
+			cmd = scb->cmd;
+			mbox = (mbox_t *)scb->raw_mbox;
+
+			/*
+			 * Internal command interface do not fire the extended
+			 * passthru or 64-bit passthru
+			 */
+			pthru = scb->pthru;
+
 		}
+		else {
+			scb = &adapter->scb_list[cmdid];
 
-		/* Check if a valid interrupt is pending */
-		if (megaCfg->flag & BOARD_QUARTZ) {
-			dword = RDOUTDOOR (megaCfg);
-			if (dword != 0x10001234) {
-				/* Spurious interrupt */
-				megaCfg->flag &= ~IN_ISR;
-				return;
+			/*
+			 * Make sure f/w has completed a valid command
+			 */
+			if( !(scb->state & SCB_ISSUED) || scb->cmd == NULL ) {
+				printk(KERN_CRIT
+					"megaraid: invalid command ");
+				printk("Id %d, scb->state:%x, scsi cmd:%p\n",
+					cmdid, scb->state, scb->cmd);
+
+				continue;
 			}
-		} else {
-			byte = READ_PORT (megaCfg->host->io_port, INTR_PORT);
-			if ((byte & VALID_INTR_BYTE) == 0) {
-				/* Spurious interrupt */
-				megaCfg->flag &= ~IN_ISR;
-				return;
+
+			/*
+			 * Was a abort issued for this command
+			 */
+			if( scb->state & SCB_ABORT ) {
+
+				printk(KERN_WARNING
+				"megaraid: aborted cmd %lx[%x] complete.\n",
+					scb->cmd->serial_number, scb->idx);
+
+				scb->cmd->result = (DID_ABORT << 16);
+
+				list_add_tail(SCSI_LIST(scb->cmd),
+						&adapter->completed_list);
+
+				mega_free_scb(adapter, scb);
+
+				continue;
 			}
-			WRITE_PORT (megaCfg->host->io_port, INTR_PORT, byte);
-		}
 
-		for (idx = 0; idx < MAX_FIRMWARE_STATUS; idx++)
-			completed[idx] = 0;
+			/*
+			 * Was a reset issued for this command
+			 */
+			if( scb->state & SCB_RESET ) {
 
-		IO_LOCK(megaCfg->host);
+				printk(KERN_WARNING
+				"megaraid: reset cmd %lx[%x] complete.\n",
+					scb->cmd->serial_number, scb->idx);
 
-		megaCfg->nInterrupts++;
-		qCnt = 0xff;
-		while ((qCnt = megaCfg->mbox->numstatus) == 0xFF) ;
+				scb->cmd->result = (DID_RESET << 16);
 
-		qStatus = 0xff;
-		while ((qStatus = megaCfg->mbox->status) == 0xFF) ;
+				list_add_tail(SCSI_LIST(scb->cmd),
+						&adapter->completed_list);
 
-		/* Get list of completed requests */
-		for (idx = 0; idx < qCnt; idx++) {
-			while ((sIdx = megaCfg->mbox->completed[idx]) == 0xFF) {
-				printk ("p");
+				mega_free_scb (adapter, scb);
+
+				continue;
 			}
-			completed[idx] = sIdx;
-			sIdx = 0xFF;
-		}
 
-		if (megaCfg->flag & BOARD_QUARTZ) {
-			WROUTDOOR (megaCfg, dword);
-			/* Acknowledge interrupt */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-			/* In this case mbox contains physical address */
-#if 0
-			WRINDOOR (megaCfg, megaCfg->adjdmahandle64 | 0x2);
-#else
-			WRINDOOR (megaCfg, 0x2);
-#endif
+			cmd = scb->cmd;
+			pthru = scb->pthru;
+			epthru = scb->epthru;
+			mbox = (mbox_t *)scb->raw_mbox;
 
-#else
+#if MEGA_HAVE_STATS
+			{
 
-#if 0
-			WRINDOOR (megaCfg, virt_to_bus (megaCfg->mbox) | 0x2);
-#else
-			WRINDOOR (megaCfg, 0x2);
-#endif
+			int	logdrv = mbox->logdrv;
 
-#endif
+			islogical = adapter->logdrv_chan[cmd->channel];
+			/*
+			 * Maintain an error counter for the logical drive.
+			 * Some application like SNMP agent need such
+			 * statistics
+			 */
+			if( status && islogical && (cmd->cmnd[0] == READ_6 ||
+						cmd->cmnd[0] == READ_10 ||
+						cmd->cmnd[0] == READ_12)) {
+				/*
+				 * Logical drive number increases by 0x80 when
+				 * a logical drive is deleted
+				 */
+				adapter->rd_errors[logdrv%0x80]++;
+			}
 
-#if 0
-			while (RDINDOOR (megaCfg) & 0x02) ;
+			if( status && islogical && (cmd->cmnd[0] == WRITE_6 ||
+						cmd->cmnd[0] == WRITE_10 ||
+						cmd->cmnd[0] == WRITE_12)) {
+				/*
+				 * Logical drive number increases by 0x80 when
+				 * a logical drive is deleted
+				 */
+				adapter->wr_errors[logdrv%0x80]++;
+			}
+
+			}
 #endif
-		} else {
-			CLEAR_INTR (megaCfg->host->io_port);
 		}
 
-#if DEBUG
-		if (qCnt >= MAX_FIRMWARE_STATUS) {
-			printk ("megaraid_isr: cmplt=%d ", qCnt);
-		}
-#endif
+		/*
+		 * Do not return the presence of hard disk on the channel so,
+		 * inquiry sent, and returned data==hard disk or removable
+		 * hard disk and not logical, request should return failure! -
+		 * PJ
+		 */
+		islogical = adapter->logdrv_chan[cmd->device->channel];
+		if( cmd->cmnd[0] == INQUIRY && !islogical ) {
 
-		for (idx = 0; idx < qCnt; idx++) {
-			sIdx = completed[idx];
-			if ((sIdx > 0) && (sIdx <= MAX_COMMANDS)) {
-				pScb = &megaCfg->scbList[sIdx - 1];
-
-				/* ASSERT(pScb->state == SCB_ISSUED); */
-
-#if DEBUG
-				if (((jiffies) - pScb->isrcount) > maxCmdTime) {
-					maxCmdTime = (jiffies) - pScb->isrcount;
-					printk
-					    ("megaraid_isr : cmd time = %u\n",
-					     maxCmdTime);
+			if( cmd->use_sg ) {
+				sgl = (struct scatterlist *)
+					cmd->request_buffer;
+
+				if( sgl->page ) {
+					c = *(unsigned char *)
+					page_address((&sgl[0])->page) +
+					(&sgl[0])->offset; 
 				}
-#endif
-				/*
-				 * Assuming that the scsi command, for which 
-				 * an abort request was received earlier, has 
-				 * completed.
-				 */
-				if (pScb->state == SCB_ABORTED) {
-					SCpnt = pScb->SCpnt;
-				}
-				if (pScb->state == SCB_RESET) {
-					SCpnt = pScb->SCpnt;
-					mega_freeSCB (megaCfg, pScb);
-					SCpnt->result = (DID_RESET << 16);
-					if (megaCfg->qCompletedH == NULL) {
-						megaCfg->qCompletedH =
-						    megaCfg->qCompletedT =
-						    SCpnt;
-					} else {
-						megaCfg->qCompletedT->
-						    host_scribble =
-						    (unsigned char *) SCpnt;
-						megaCfg->qCompletedT = SCpnt;
-					}
-					megaCfg->qCompletedT->host_scribble =
-					    (unsigned char *) NULL;
-					megaCfg->qCcnt++;
-					continue;
+				else {
+					printk(KERN_WARNING
+						"megaraid: invalid sg.\n");
+					c = 0;
 				}
+			}
+			else {
+				c = *(u8 *)cmd->request_buffer;
+			}
 
-				/* We don't want the ISR routine to touch M_RD_IOCTL_CMD_NEW commands, so
-				 * don't mark them as complete, instead we pop their semaphore so
-				 * that the queue routine can finish them off
-				 */
-				if (pScb->SCpnt->cmnd[0] == M_RD_IOCTL_CMD_NEW) {
-					/* save the status byte for the queue routine to use */
-					pScb->SCpnt->result = qStatus;
-					up (&pScb->ioctl_sem);
-				} else {
-					/* Mark command as completed */
-					mega_cmd_done (megaCfg, pScb, qStatus);
-				}
-			} else {
-				printk
-				    ("megaraid: wrong cmd id completed from firmware:id=%x\n",
-				     sIdx);
+			if(IS_RAID_CH(adapter, cmd->device->channel) &&
+					((c & 0x1F ) == TYPE_DISK)) {
+				status = 0xF0;
 			}
 		}
 
-		mega_rundoneq (megaCfg);
+		/* clear result; otherwise, success returns corrupt value */
+		cmd->result = 0;
 
-		megaCfg->flag &= ~IN_ISR;
-		/* Loop through any pending requests */
-		mega_runpendq (megaCfg);
-		IO_UNLOCK(megaCfg->host);
+		/* Convert MegaRAID status to Linux error code */
+		switch (status) {
+		case 0x00:	/* SUCCESS , i.e. SCSI_STATUS_GOOD */
+			cmd->result |= (DID_OK << 16);
+			break;
 
-	}
+		case 0x02:	/* ERROR_ABORTED, i.e.
+				   SCSI_STATUS_CHECK_CONDITION */
 
-}
+			/* set sense_buffer and result fields */
+			if( mbox->cmd == MEGA_MBOXCMD_PASSTHRU ||
+				mbox->cmd == MEGA_MBOXCMD_PASSTHRU64 ) {
+
+				memcpy(cmd->sense_buffer, pthru->reqsensearea,
+						14);
+
+				cmd->result = (DRIVER_SENSE << 24) |
+					(DID_OK << 16) |
+					(CHECK_CONDITION << 1);
+			}
+			else {
+				if (mbox->cmd == MEGA_MBOXCMD_EXTPTHRU) {
 
-/*==================================================*/
-/* Wait until the controller's mailbox is available */
-/*==================================================*/
+					memcpy(cmd->sense_buffer,
+						epthru->reqsensearea, 14);
 
-static int mega_busyWaitMbox (mega_host_config * megaCfg)
-{
-	mega_mailbox *mbox = (mega_mailbox *) megaCfg->mbox;
-	long counter;
+					cmd->result = (DRIVER_SENSE << 24) |
+						(DID_OK << 16) |
+						(CHECK_CONDITION << 1);
+				} else {
+					cmd->sense_buffer[0] = 0x70;
+					cmd->sense_buffer[2] = ABORTED_COMMAND;
+					cmd->result |= (CHECK_CONDITION << 1);
+				}
+			}
+			break;
 
-	for (counter = 0; counter < 10000; counter++) {
-		if (!mbox->busy) {
-			return 0;
+		case 0x08:	/* ERR_DEST_DRIVE_FAILED, i.e.
+				   SCSI_STATUS_BUSY */
+			cmd->result |= (DID_BUS_BUSY << 16) | status;
+			break;
+
+		default:
+#if MEGA_HAVE_CLUSTERING
+			/*
+			 * If TEST_UNIT_READY fails, we know
+			 * MEGA_RESERVATION_STATUS failed
+			 */
+			if( cmd->cmnd[0] == TEST_UNIT_READY ) {
+				cmd->result |= (DID_ERROR << 16) |
+					(RESERVATION_CONFLICT << 1);
+			}
+			else
+			/*
+			 * Error code returned is 1 if Reserve or Release
+			 * failed or the input parameter is invalid
+			 */
+			if( status == 1 &&
+				(cmd->cmnd[0] == RESERVE ||
+					 cmd->cmnd[0] == RELEASE) ) {
+
+				cmd->result |= (DID_ERROR << 16) |
+					(RESERVATION_CONFLICT << 1);
+			}
+			else
+#endif
+				cmd->result |= (DID_BAD_TARGET << 16)|status;
+		}
+
+		/*
+		 * Only free SCBs for the commands coming down from the
+		 * mid-layer, not for which were issued internally
+		 *
+		 * For internal command, restore the status returned by the
+		 * firmware so that user can interpret it.
+		 */
+		if( cmdid == CMDID_INT_CMDS ) { /* internal command */
+			cmd->result = status;
+
+			/*
+			 * Remove the internal command from the pending list
+			 */
+			list_del_init(&scb->list);
+			scb->state = SCB_FREE;
+		}
+		else {
+			mega_free_scb(adapter, scb);
 		}
-		udelay (100);
-		barrier ();
+
+		/* Add Scsi_Command to end of completed queue */
+		list_add_tail(SCSI_LIST(cmd), &adapter->completed_list);
 	}
-	return -1;		/* give up after 1 second */
 }
 
-/*=====================================================
- * Post a command to the card
+
+/*
+ * mega_runpendq()
  *
- * Arguments:
- *   mega_host_config *megaCfg - Controller structure
- *   u_char *mboxData - Mailbox area, 16 bytes
- *   mega_scb *pScb   - SCB posting (or NULL if N/A)
- *   int intr         - if 1, interrupt, 0 is blocking
- * Return Value: (added on 7/26 for 40ld/64bit)
- *   -1: the command was not actually issued out
- *   other cases:
- *     intr==0, return ScsiStatus, i.e. mbox->status
- *     intr==1, return 0
- *=====================================================
+ * Run through the list of completed requests and finish it
  */
-static int megaIssueCmd (mega_host_config * megaCfg, u_char * mboxData, 
-		mega_scb * pScb, int intr)
+static void
+mega_rundoneq (adapter_t *adapter)
 {
-	volatile mega_mailbox *mbox = (mega_mailbox *) megaCfg->mbox;
+	Scsi_Cmnd *cmd;
+	struct list_head *pos;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	volatile mega_mailbox64 *mbox64 = (mega_mailbox64 *) megaCfg->mbox64;
-#endif
-
-	u_char byte;
+	list_for_each(pos, &adapter->completed_list) {
 
-#ifdef __LP64__
-	u64 phys_mbox;
-#else
-	u32 phys_mbox;
-#endif
-	u8 retval = -1;
+		Scsi_Pointer* spos = (Scsi_Pointer *)pos;
 
-	mboxData[0x1] = (pScb ? pScb->idx + 1 : 0xFE);	/* Set cmdid */
-	mboxData[0xF] = 1;	/* Set busy */
+		cmd = list_entry(spos, Scsi_Cmnd, SCp);
+		cmd->scsi_done(cmd);
+	}
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	/* In this case mbox contains physical address */
-	phys_mbox = megaCfg->adjdmahandle64;
-#else
-	phys_mbox = virt_to_bus (megaCfg->mbox);
-#endif
+	INIT_LIST_HEAD(&adapter->completed_list);
+}
 
-#if DEBUG
-	ShowMbox (pScb);
-#endif
 
-	/* Wait until mailbox is free */
-	if (mega_busyWaitMbox (megaCfg)) {
-		printk ("Blocked mailbox......!!\n");
-		udelay (1000);
+/*
+ * Free a SCB structure
+ * Note: We assume the scsi commands associated with this scb is not free yet.
+ */
+static void
+mega_free_scb(adapter_t *adapter, scb_t *scb)
+{
+	switch( scb->dma_type ) {
 
-#if DEBUG
-		showMbox (pLastScb);
-#endif
+	case MEGA_DMA_TYPE_NONE:
+		break;
 
-		/* Abort command */
-		if (pScb == NULL) {
-			TRACE (("NULL pScb in megaIssue\n"));
-			printk ("NULL pScb in megaIssue\n");
+	case MEGA_BULK_DATA:
+		pci_unmap_page(adapter->dev, scb->dma_h_bulkdata,
+			scb->cmd->request_bufflen, scb->dma_direction);
+
+		if( scb->dma_direction == PCI_DMA_FROMDEVICE ) {
+			pci_dma_sync_single(adapter->dev,
+					scb->dma_h_bulkdata,
+					scb->cmd->request_bufflen,
+					PCI_DMA_FROMDEVICE);
 		}
-		mega_cmd_done (megaCfg, pScb, 0x08);
-		return -1;
-	}
 
-	pLastScb = pScb;
+		break;
 
-	/* Copy mailbox data into host structure */
-	megaCfg->mbox64->xferSegment_lo = 0;
-	megaCfg->mbox64->xferSegment_hi = 0;
+	case MEGA_SGLIST:
+		pci_unmap_sg(adapter->dev, scb->cmd->request_buffer,
+			scb->cmd->use_sg, scb->dma_direction);
+
+		if( scb->dma_direction == PCI_DMA_FROMDEVICE ) {
+			pci_dma_sync_sg(adapter->dev,
+					scb->cmd->request_buffer,
+					scb->cmd->use_sg, PCI_DMA_FROMDEVICE);
+		}
 
-	memcpy ((char *) mbox, mboxData, 16);
+		break;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	switch (mboxData[0]) {
-	case MEGA_MBOXCMD_LREAD64:
-	case MEGA_MBOXCMD_LWRITE64:
-		mbox64->xferSegment_lo = mbox->xferaddr;
-		mbox64->xferSegment_hi = 0;
-		mbox->xferaddr = 0xFFFFFFFF;
+	default:
 		break;
 	}
-#endif
 
-	/* Kick IO */
-	if (intr) {
-		/* Issue interrupt (non-blocking) command */
-		if (megaCfg->flag & BOARD_QUARTZ) {
-			mbox->mraid_poll = 0;
-			mbox->mraid_ack = 0;
-
-			WRINDOOR (megaCfg, phys_mbox | 0x1);
-		} else {
-			ENABLE_INTR (megaCfg->host->io_port);
-			ISSUE_COMMAND (megaCfg->host->io_port);
-		}
-		pScb->state = SCB_ISSUED;
-
-		retval = 0;
-	} else {		/* Issue non-ISR (blocking) command */
-		disable_irq (megaCfg->host->irq);
-		if (megaCfg->flag & BOARD_QUARTZ) {
-			mbox->mraid_poll = 0;
-			mbox->mraid_ack = 0;
-			mbox->numstatus = 0xFF;
-			mbox->status = 0xFF;
-			WRINDOOR (megaCfg, phys_mbox | 0x1);
-
-			while (mbox->numstatus == 0xFF) ;
-			while (mbox->status == 0xFF) ;
-			while (mbox->mraid_poll != 0x77) ;
-			mbox->mraid_poll = 0;
-			mbox->mraid_ack = 0x77;
-
-			/* while ((cmdDone = RDOUTDOOR (megaCfg)) != 0x10001234);
-			   WROUTDOOR (megaCfg, cmdDone); */
-
-			if (pScb) {
-				mega_cmd_done (megaCfg, pScb, mbox->status);
-			}
-
-			WRINDOOR (megaCfg, phys_mbox | 0x2);
-			while (RDINDOOR (megaCfg) & 0x2) ;
-
-		} else {
-			DISABLE_INTR (megaCfg->host->io_port);
-			ISSUE_COMMAND (megaCfg->host->io_port);
-
-			while (!
-			       ((byte =
-				 READ_PORT (megaCfg->host->io_port,
-					    INTR_PORT)) & INTR_VALID)) ;
-			WRITE_PORT (megaCfg->host->io_port, INTR_PORT, byte);
-
-			ENABLE_INTR (megaCfg->host->io_port);
-			CLEAR_INTR (megaCfg->host->io_port);
-
-			if (pScb) {
-				mega_cmd_done (megaCfg, pScb, mbox->status);
-			} else {
-				TRACE (("Error: NULL pScb!\n"));
-			}
-		}
-		enable_irq (megaCfg->host->irq);
-		retval = mbox->status;
-	}
-#if DEBUG
-	while (mega_busyWaitMbox (megaCfg)) {
-		printk(KERN_ERR "Blocked mailbox on exit......!\n");
-		udelay (1000);
-	}
-#endif
+	/*
+	 * Remove from the pending list
+	 */
+	list_del_init(&scb->list);
+
+	/* Link the scb back into free list */
+	scb->state = SCB_FREE;
+	scb->cmd = NULL;
 
-	return retval;
+	list_add(&scb->list, &adapter->free_list);
 }
 
-/*-------------------------------------------------------------------
- * Copies data to SGLIST
- *-------------------------------------------------------------------*/
-/* Note:
-	For 64 bit cards, we need a minimum of one SG element for read/write
-*/
+
+/*
+ * Wait until the controller's mailbox is available
+ */
+static inline int
+mega_busywait_mbox (adapter_t *adapter)
+{
+	if (adapter->mbox->busy)
+		return __mega_busywait_mbox(adapter);
+	return 0;
+}
 
 static int
-mega_build_sglist (mega_host_config * megaCfg, mega_scb * scb,
-		   u32 * buffer, u32 * length)
+__mega_busywait_mbox (adapter_t *adapter)
 {
-	struct scatterlist *sgList;
-	int idx;
+	volatile mbox_t *mbox = adapter->mbox;
+	long counter;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	int sgcnt;
-#endif
+	for (counter = 0; counter < 10000; counter++) {
+		if (!mbox->busy)
+			return 0;
+		udelay(100); yield();
+	}
+	return -1;		/* give up after 1 second */
+}
+
+/*
+ * Copies data to SGLIST
+ * Note: For 64 bit cards, we need a minimum of one SG element for read/write
+ */
+static int
+mega_build_sglist(adapter_t *adapter, scb_t *scb, u32 *buf, u32 *len)
+{
+	struct scatterlist	*sgl;
+	struct page	*page;
+	unsigned long	offset;
+	Scsi_Cmnd	*cmd;
+	int	sgcnt;
+	int	idx;
 
-	mega_mailbox *mbox = NULL;
+	cmd = scb->cmd;
 
-	mbox = (mega_mailbox *) scb->mboxData;
 	/* Scatter-gather not used */
-	if (scb->SCpnt->use_sg == 0) {
+	if( !cmd->use_sg ) {
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		scb->dma_h_bulkdata = pci_map_single (megaCfg->dev,
-				      scb->SCpnt->request_buffer,
-				      scb->SCpnt->request_bufflen,
-				      scb->dma_direction);
-		/* We need to handle special commands like READ64, WRITE64
-		   as they need a minimum of 1 SG irrespective of actually SG
-		 */
-		if ((megaCfg->flag & BOARD_64BIT) &&
-		    ((mbox->cmd == MEGA_MBOXCMD_LREAD64) ||
-		     (mbox->cmd == MEGA_MBOXCMD_LWRITE64))) {
-			scb->sg64List[0].address = scb->dma_h_bulkdata;
-			scb->sg64List[0].length = scb->SCpnt->request_bufflen;
-			*buffer = scb->dma_sghandle64;
-			*length = 0;
-			scb->sglist_count = 1;
-			return 1;
-		} else {
-			*buffer = scb->dma_h_bulkdata;
-			*length = (u32) scb->SCpnt->request_bufflen;
-		}
-#else
-		*buffer = virt_to_bus (scb->SCpnt->request_buffer);
-		*length = (u32) scb->SCpnt->request_bufflen;
-#endif
-		return 0;
-	}
+		page = virt_to_page(cmd->request_buffer);
 
-	sgList = (struct scatterlist *) scb->SCpnt->request_buffer;
-#if 0
-	if (scb->SCpnt->use_sg == 1) {
+		offset = ((unsigned long)cmd->request_buffer & ~PAGE_MASK);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		scb->dma_h_bulkdata = pci_map_single (megaCfg->dev,
-				      sgList[0].address,
-				      sgList[0].length, scb->dma_direction);
-
-		if ((megaCfg->flag & BOARD_64BIT) &&
-		    ((mbox->cmd == MEGA_MBOXCMD_LREAD64) ||
-		     (mbox->cmd == MEGA_MBOXCMD_LWRITE64))) {
-			scb->sg64List[0].address = scb->dma_h_bulkdata;
-			scb->sg64List[0].length = scb->SCpnt->request_bufflen;
-			*buffer = scb->dma_sghandle64;
-			*length = 0;
-			scb->sglist_count = 1;
+		scb->dma_h_bulkdata = pci_map_page(adapter->dev,
+						  page, offset,
+						  cmd->request_bufflen,
+						  scb->dma_direction);
+		scb->dma_type = MEGA_BULK_DATA;
+
+		/*
+		 * We need to handle special 64-bit commands that need a
+		 * minimum of 1 SG
+		 */
+		if( adapter->has_64bit_addr ) {
+			scb->sgl64[0].address = scb->dma_h_bulkdata;
+			scb->sgl64[0].length = cmd->request_bufflen;
+			*buf = (u32)scb->sgl_dma_addr;
+			*len = (u32)cmd->request_bufflen;
 			return 1;
-		} else {
-			*buffer = scb->dma_h_bulkdata;
-			*length = (u32) sgList[0].length;
 		}
-#else
-		*buffer = virt_to_bus (sgList[0].address);
-		*length = (u32) sgList[0].length;
-#endif
+		else {
+			*buf = (u32)scb->dma_h_bulkdata;
+			*len = (u32)cmd->request_bufflen;
+		}
 
-		return 0;
-	}
-#endif
-	/* Copy Scatter-Gather list info into controller structure */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	sgcnt = pci_map_sg (megaCfg->dev,
-			    sgList, scb->SCpnt->use_sg, scb->dma_direction);
-
-	/* Determine the validity of the new count  */
-	if (sgcnt == 0)
-		printk ("pci_map_sg returned zero!!! ");
-
-	for (idx = 0; idx < sgcnt; idx++, sgList++) {
-
-		if ((megaCfg->flag & BOARD_64BIT) &&
-		    ((mbox->cmd == MEGA_MBOXCMD_LREAD64) ||
-		     (mbox->cmd == MEGA_MBOXCMD_LWRITE64))) {
-			scb->sg64List[idx].address = sg_dma_address (sgList);
-			scb->sg64List[idx].length = sg_dma_len (sgList);
-		} else {
-			scb->sgList[idx].address = sg_dma_address (sgList);
-			scb->sgList[idx].length = sg_dma_len (sgList);
+		if( scb->dma_direction == PCI_DMA_TODEVICE ) {
+			pci_dma_sync_single(adapter->dev,
+					scb->dma_h_bulkdata,
+					cmd->request_bufflen,
+					PCI_DMA_TODEVICE);
 		}
 
+		return 0;
 	}
 
-#else
-	for (idx = 0; idx < scb->SCpnt->use_sg; idx++) {
-		scb->sgList[idx].address = virt_to_bus (sgList[idx].address);
-		scb->sgList[idx].length = (u32) sgList[idx].length;
-	}
-#endif
+	sgl = (struct scatterlist *)cmd->request_buffer;
 
-	/* Reset pointer and length fields */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	*buffer = scb->dma_sghandle64;
-	scb->sglist_count = scb->SCpnt->use_sg;
-#else
-	*buffer = virt_to_bus (scb->sgList);
-#endif
-	*length = 0;
+	/*
+	 * Copy Scatter-Gather list info into controller structure.
+	 *
+	 * The number of sg elements returned must not exceed our limit
+	 */
+	sgcnt = pci_map_sg(adapter->dev, sgl, cmd->use_sg,
+			scb->dma_direction);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	/* Return count of SG requests */
-	return sgcnt;
-#else
-	/* Return count of SG requests */
-	return scb->SCpnt->use_sg;
-#endif
-}
+	scb->dma_type = MEGA_SGLIST;
 
-/*--------------------------------------------------------------------
- * Initializes the address of the controller's mailbox register
- *  The mailbox register is used to issue commands to the card.
- *  Format of the mailbox area:
- *   00 01 command
- *   01 01 command id
- *   02 02 # of sectors
- *   04 04 logical bus address
- *   08 04 physical buffer address
- *   0C 01 logical drive #
- *   0D 01 length of scatter/gather list
- *   0E 01 reserved
- *   0F 01 mailbox busy
- *   10 01 numstatus byte
- *   11 01 status byte
- *--------------------------------------------------------------------*/
-static int
-mega_register_mailbox (mega_host_config * megaCfg, u32 paddr)
-{
-	/* align on 16-byte boundary */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	megaCfg->mbox = &megaCfg->mailbox64ptr->mailbox;
-#else
-	megaCfg->mbox = &megaCfg->mailbox64.mailbox;
-#endif
+	if( sgcnt > adapter->sglen ) BUG();
 
-#ifdef __LP64__
-	megaCfg->mbox = (mega_mailbox *) ((((u64) megaCfg->mbox) + 16) & ((u64) (-1) ^ 0x0F));
-	megaCfg->adjdmahandle64 = (megaCfg->dma_handle64 + 16) & ((u64) (-1) ^ 0x0F);
-	megaCfg->mbox64 = (mega_mailbox64 *) ((u_char *) megaCfg->mbox - sizeof (u64));
-	paddr = (paddr + 4 + 16) & ((u64) (-1) ^ 0x0F);
-#else
-	megaCfg->mbox
-	    = (mega_mailbox *) ((((u32) megaCfg->mbox) + 16) & 0xFFFFFFF0);
+	for( idx = 0; idx < sgcnt; idx++, sgl++ ) {
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	megaCfg->adjdmahandle64 = ((megaCfg->dma_handle64 + 16) & 0xFFFFFFF0);
-#endif
+		if( adapter->has_64bit_addr ) {
+			scb->sgl64[idx].address = sg_dma_address(sgl);
+			scb->sgl64[idx].length = sg_dma_len(sgl);
+		}
+		else {
+			scb->sgl[idx].address = sg_dma_address(sgl);
+			scb->sgl[idx].length = sg_dma_len(sgl);
+		}
+	}
 
-	megaCfg->mbox64 = (mega_mailbox64 *) ((u_char *) megaCfg->mbox - 8);
-	paddr = (paddr + 4 + 16) & 0xFFFFFFF0;
-#endif
+	/* Reset pointer and length fields */
+	*buf = scb->sgl_dma_addr;
 
-	/* Register mailbox area with the firmware */
-	if (!(megaCfg->flag & BOARD_QUARTZ)) {
-		WRITE_PORT (megaCfg->host->io_port, MBOX_PORT0, paddr & 0xFF);
-		WRITE_PORT (megaCfg->host->io_port, MBOX_PORT1,
-			    (paddr >> 8) & 0xFF);
-		WRITE_PORT (megaCfg->host->io_port, MBOX_PORT2,
-			    (paddr >> 16) & 0xFF);
-		WRITE_PORT (megaCfg->host->io_port, MBOX_PORT3,
-			    (paddr >> 24) & 0xFF);
-		WRITE_PORT (megaCfg->host->io_port, ENABLE_MBOX_REGION,
-			    ENABLE_MBOX_BYTE);
+	/*
+	 * For passthru command, dataxferlen must be set, even for commands
+	 * with a sg list
+	 */
+	*len = (u32)cmd->request_bufflen;
 
-		CLEAR_INTR (megaCfg->host->io_port);
-		ENABLE_INTR (megaCfg->host->io_port);
+	if( scb->dma_direction == PCI_DMA_TODEVICE ) {
+		pci_dma_sync_sg(adapter->dev, sgl, cmd->use_sg,
+				PCI_DMA_TODEVICE);
 	}
-	return 0;
+
+	/* Return count of SG requests */
+	return sgcnt;
 }
 
-/*---------------------------------------------------------------------------
- * mega_Convert8ldTo40ld() -- takes all info in AdapterInquiry structure and
- * puts it into ProductInfo and Enquiry3 structures for later use
- *---------------------------------------------------------------------------*/
-static void mega_Convert8ldTo40ld (mega_RAIDINQ * inquiry,
-		       mega_Enquiry3 * enquiry3,
-		       megaRaidProductInfo * productInfo)
+
+/*
+ * mega_8_to_40ld()
+ *
+ * takes all info in AdapterInquiry structure and puts it into ProductInfo and
+ * Enquiry3 structures for later use
+ */
+static void
+mega_8_to_40ld(mraid_inquiry *inquiry, mega_inquiry3 *enquiry3,
+		mega_product_info *product_info)
 {
 	int i;
 
-	productInfo->MaxConcCmds = inquiry->AdpInfo.MaxConcCmds;
-	enquiry3->rbldRate = inquiry->AdpInfo.RbldRate;
-	productInfo->SCSIChanPresent = inquiry->AdpInfo.ChanPresent;
+	product_info->max_commands = inquiry->adapter_info.max_commands;
+	enquiry3->rebuild_rate = inquiry->adapter_info.rebuild_rate;
+	product_info->nchannels = inquiry->adapter_info.nchannels;
 
 	for (i = 0; i < 4; i++) {
-		productInfo->FwVer[i] = inquiry->AdpInfo.FwVer[i];
-		productInfo->BiosVer[i] = inquiry->AdpInfo.BiosVer[i];
+		product_info->fw_version[i] =
+			inquiry->adapter_info.fw_version[i];
+
+		product_info->bios_version[i] =
+			inquiry->adapter_info.bios_version[i];
 	}
-	enquiry3->cacheFlushInterval = inquiry->AdpInfo.CacheFlushInterval;
-	productInfo->DramSize = inquiry->AdpInfo.DramSize;
+	enquiry3->cache_flush_interval =
+		inquiry->adapter_info.cache_flush_interval;
 
-	enquiry3->numLDrv = inquiry->LogdrvInfo.NumLDrv;
+	product_info->dram_size = inquiry->adapter_info.dram_size;
 
-	for (i = 0; i < MAX_LOGICAL_DRIVES; i++) {
-		enquiry3->lDrvSize[i] = inquiry->LogdrvInfo.LDrvSize[i];
-		enquiry3->lDrvProp[i] = inquiry->LogdrvInfo.LDrvProp[i];
-		enquiry3->lDrvState[i]
-		    = inquiry->LogdrvInfo.LDrvState[i];
-	}
+	enquiry3->num_ldrv = inquiry->logdrv_info.num_ldrv;
 
-	for (i = 0; i < (MAX_PHYSICAL_DRIVES); i++) {
-		enquiry3->pDrvState[i]
-		    = inquiry->PhysdrvInfo.PDrvState[i];
+	for (i = 0; i < MAX_LOGICAL_DRIVES_8LD; i++) {
+		enquiry3->ldrv_size[i] = inquiry->logdrv_info.ldrv_size[i];
+		enquiry3->ldrv_prop[i] = inquiry->logdrv_info.ldrv_prop[i];
+		enquiry3->ldrv_state[i] = inquiry->logdrv_info.ldrv_state[i];
 	}
+
+	for (i = 0; i < (MAX_PHYSICAL_DRIVES); i++)
+		enquiry3->pdrv_state[i] = inquiry->pdrv_info.pdrv_state[i];
 }
 
-/*-------------------------------------------------------------------
- * Issue an adapter info query to the controller
- *-------------------------------------------------------------------*/
-static int mega_i_query_adapter (mega_host_config * megaCfg)
+
+/*
+ * megaraid_proc_info()
+ *
+ * Returns data to be displayed in /proc/scsi/megaraid/X
+ */
+static int
+megaraid_proc_info(char *buffer, char **start, off_t offset, int length,
+		int host_no, int inout)
 {
-	mega_Enquiry3 *enquiry3Pnt;
-	mega_mailbox *mbox;
-	u_char mboxData[16];
+	*start = buffer;
+	return 0;
+}
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	dma_addr_t raid_inq_dma_handle = 0, prod_info_dma_handle = 0, enquiry3_dma_handle = 0;
-#endif
-	u8 retval;
 
-	/* Initialize adapter inquiry mailbox */
+/*
+ * Release the controller's resources
+ */
+static int
+megaraid_release(struct Scsi_Host *host)
+{
+	adapter_t	*adapter;
+	mbox_t	*mbox;
+	u_char	raw_mbox[16];
+	char	buf[12] = { 0 };
 
-	mbox = (mega_mailbox *) mboxData;
+	adapter = (adapter_t *)host->hostdata;
+	mbox = (mbox_t *)raw_mbox;
 
-	memset ((void *) megaCfg->mega_buffer, 0,
-		sizeof (megaCfg->mega_buffer));
-	memset (mbox, 0, 16);
+	printk(KERN_NOTICE "megaraid: being unloaded...");
 
-/*
- * Try to issue Enquiry3 command
- * if not succeeded, then issue MEGA_MBOXCMD_ADAPTERINQ command and
- * update enquiry3 structure
- */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	enquiry3_dma_handle = pci_map_single (megaCfg->dev,
-			      (void *) megaCfg->mega_buffer,
-			      (2 * 1024L), PCI_DMA_FROMDEVICE);
+	/* Flush adapter cache */
+	memset(mbox, 0, 16);
+	raw_mbox[0] = FLUSH_ADAPTER;
 
-	mbox->xferaddr = enquiry3_dma_handle;
-#else
-	/*Taken care */
-	mbox->xferaddr = virt_to_bus ((void *) megaCfg->mega_buffer);
-#endif
+	irq_disable(adapter);
+	free_irq(adapter->host->irq, adapter);
 
-	/* Initialize mailbox databuffer addr */
-	enquiry3Pnt = (mega_Enquiry3 *) megaCfg->mega_buffer;
-	/* point mega_Enguiry3 to the data buf */
-
-	mboxData[0] = FC_NEW_CONFIG;	/* i.e. mbox->cmd=0xA1 */
-	mboxData[2] = NC_SUBOP_ENQUIRY3;	/* i.e. 0x0F */
-	mboxData[3] = ENQ3_GET_SOLICITED_FULL;	/* i.e. 0x02 */
+	/* Issue a blocking (interrupts disabled) command to the card */
+	issue_scb_block(adapter, raw_mbox);
 
-	/* Issue a blocking command to the card */
-	if ((retval = megaIssueCmd (megaCfg, mboxData, NULL, 0)) != 0) {	/* the adapter does not support 40ld */
-		mega_RAIDINQ adapterInquiryData;
-		mega_RAIDINQ *adapterInquiryPnt = &adapterInquiryData;
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		raid_inq_dma_handle = pci_map_single (megaCfg->dev,
-				      (void *) adapterInquiryPnt,
-				      sizeof (mega_RAIDINQ),
-				      PCI_DMA_FROMDEVICE);
-		mbox->xferaddr = raid_inq_dma_handle;
-#else
-		/*taken care */
-		mbox->xferaddr = virt_to_bus ((void *) adapterInquiryPnt);
-#endif
+	/* Flush disks cache */
+	memset(mbox, 0, 16);
+	raw_mbox[0] = FLUSH_SYSTEM;
 
-		mbox->cmd = MEGA_MBOXCMD_ADAPTERINQ;	/*issue old 0x05 command to adapter */
-		/* Issue a blocking command to the card */ ;
-		retval = megaIssueCmd (megaCfg, mboxData, NULL, 0);
-
-		pci_unmap_single (megaCfg->dev,
-				  raid_inq_dma_handle,
-				  sizeof (mega_RAIDINQ), PCI_DMA_FROMDEVICE);
-
-		/*update Enquiry3 and ProductInfo structures with mega_RAIDINQ structure*/
-		mega_Convert8ldTo40ld (adapterInquiryPnt,
-				       enquiry3Pnt,
-				       (megaRaidProductInfo *) & megaCfg->
-				       productInfo);
-
-	} else {		/* adapter supports 40ld */
-		megaCfg->flag |= BOARD_40LD;
-
-		pci_unmap_single (megaCfg->dev,
-				  enquiry3_dma_handle,
-				  (2 * 1024L), PCI_DMA_FROMDEVICE);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-/*get productInfo, which is static information and will be unchanged*/
-		prod_info_dma_handle
-		    = pci_map_single (megaCfg->dev,
-				      (void *) &megaCfg->productInfo,
-				      sizeof (megaRaidProductInfo),
-				      PCI_DMA_FROMDEVICE);
-		mbox->xferaddr = prod_info_dma_handle;
-#else
-		/*taken care */
-		mbox->xferaddr = virt_to_bus ((void *) &megaCfg->productInfo);
+	/* Issue a blocking (interrupts disabled) command to the card */
+	issue_scb_block(adapter, raw_mbox);
+
+
+	/* Free our resources */
+	if( adapter->flag & BOARD_MEMMAP ) {
+		iounmap((void *)adapter->base);
+		release_mem_region(adapter->host->base, 128);
+	}
+	else {
+		release_region(adapter->base, 16);
+	}
+
+	mega_free_sgl(adapter);
+
+#ifdef CONFIG_PROC_FS
+	if( adapter->controller_proc_dir_entry ) {
+		remove_proc_entry("stat", adapter->controller_proc_dir_entry);
+		remove_proc_entry("config",
+				adapter->controller_proc_dir_entry);
+		remove_proc_entry("mailbox",
+				adapter->controller_proc_dir_entry);
+#if MEGA_HAVE_ENH_PROC
+		remove_proc_entry("rebuild-rate",
+				adapter->controller_proc_dir_entry);
+		remove_proc_entry("battery-status",
+				adapter->controller_proc_dir_entry);
+
+		remove_proc_entry("diskdrives-ch0",
+				adapter->controller_proc_dir_entry);
+		remove_proc_entry("diskdrives-ch1",
+				adapter->controller_proc_dir_entry);
+		remove_proc_entry("diskdrives-ch2",
+				adapter->controller_proc_dir_entry);
+		remove_proc_entry("diskdrives-ch3",
+				adapter->controller_proc_dir_entry);
+
+		remove_proc_entry("raiddrives-0-9",
+				adapter->controller_proc_dir_entry);
+		remove_proc_entry("raiddrives-10-19",
+				adapter->controller_proc_dir_entry);
+		remove_proc_entry("raiddrives-20-29",
+				adapter->controller_proc_dir_entry);
+		remove_proc_entry("raiddrives-30-39",
+				adapter->controller_proc_dir_entry);
+#endif
+
+		sprintf(buf, "hba%d", adapter->host->host_no);
+		remove_proc_entry(buf, mega_proc_dir_entry);
+	}
 #endif
 
-		mboxData[0] = FC_NEW_CONFIG;	/* i.e. mbox->cmd=0xA1 */
-		mboxData[2] = NC_SUBOP_PRODUCT_INFO;	/* i.e. 0x0E */
+	pci_free_consistent(adapter->dev, MEGA_BUFFER_SIZE,
+			adapter->mega_buffer, adapter->buf_dma_handle);
+	kfree(adapter->scb_list);
+	pci_free_consistent(adapter->dev, sizeof(mbox64_t),
+			(void *)adapter->una_mbox64, adapter->una_mbox64_dma);
 
-		if ((retval = megaIssueCmd (megaCfg, mboxData, NULL, 0)) != 0)
-			printk ("megaraid: Product_info cmd failed with error: %d\n",
-				retval);
+	hba_count--;
+
+	if( hba_count == 0 ) {
+
+		/*
+		 * Unregister the character device interface to the driver.
+		 */
+		unregister_chrdev(major, "megadev");
+
+		unregister_reboot_notifier(&mega_notifier);
+
+#ifdef CONFIG_PROC_FS
+		if( adapter->controller_proc_dir_entry ) {
+			remove_proc_entry ("megaraid", &proc_root);
+		}
+#endif
 
-		pci_unmap_single (megaCfg->dev,
-				  prod_info_dma_handle,
-				  sizeof (megaRaidProductInfo),
-				  PCI_DMA_FROMDEVICE);
 	}
 
 	/*
-	 * kernel scans the channels from 0 to <= max_channel
+	 * Release the controller memory. A word of warning this frees
+	 * hostdata and that includes adapter-> so be careful what you
+	 * dereference beyond this point
 	 */
-	megaCfg->host->max_channel =
-		megaCfg->productInfo.SCSIChanPresent + NVIRT_CHAN -1;
+	scsi_unregister(host);
 
-	megaCfg->host->max_id = 16;	/* max targets per channel */
-	/*(megaCfg->flag & BOARD_40LD)?FC_MAX_TARGETS_PER_CHANNEL:MAX_TARGET+1; */
-#if 0
-	megaCfg->host->max_lun =	/* max lun */
-	    (megaCfg->flag & BOARD_40LD) ?
-			FC_MAX_LOGICAL_DRIVES : MAX_LOGICAL_DRIVES;
-#endif
-	megaCfg->host->max_lun = 7;	/* Upto 7 luns for non disk devices */
 
-	megaCfg->host->cmd_per_lun = MAX_CMD_PER_LUN;
+	printk("ok.\n");
 
-	megaCfg->numldrv = enquiry3Pnt->numLDrv;
-	megaCfg->max_cmds = megaCfg->productInfo.MaxConcCmds;
-	if (megaCfg->max_cmds > MAX_COMMANDS)
-		megaCfg->max_cmds = MAX_COMMANDS - 1;
+	return 0;
+}
 
-	megaCfg->host->can_queue = megaCfg->max_cmds - 1;
+static inline void
+mega_free_sgl(adapter_t *adapter)
+{
+	scb_t	*scb;
+	int	i;
 
-#if 0
-	if (megaCfg->host->can_queue >= MAX_COMMANDS) {
-		megaCfg->host->can_queue = MAX_COMMANDS - 16;
-	}
-#endif
+	for(i = 0; i < adapter->max_cmds; i++) {
 
-	/* use HP firmware and bios version encoding */
-	if (megaCfg->productInfo.subSystemVendorID == HP_SUBSYS_ID) {
-		sprintf (megaCfg->fwVer, "%c%d%d.%d%d",
-			 megaCfg->productInfo.FwVer[2],
-			 megaCfg->productInfo.FwVer[1] >> 8,
-			 megaCfg->productInfo.FwVer[1] & 0x0f,
-			 megaCfg->productInfo.FwVer[0] >> 8,
-			 megaCfg->productInfo.FwVer[0] & 0x0f);
-		sprintf (megaCfg->biosVer, "%c%d%d.%d%d",
-			 megaCfg->productInfo.BiosVer[2],
-			 megaCfg->productInfo.BiosVer[1] >> 8,
-			 megaCfg->productInfo.BiosVer[1] & 0x0f,
-			 megaCfg->productInfo.BiosVer[0] >> 8,
-			 megaCfg->productInfo.BiosVer[0] & 0x0f);
-	} else {
-		memcpy (megaCfg->fwVer, (char *) megaCfg->productInfo.FwVer, 4);
-		megaCfg->fwVer[4] = 0;
+		scb = &adapter->scb_list[i];
 
-		memcpy (megaCfg->biosVer, (char *) megaCfg->productInfo.BiosVer, 4);
-		megaCfg->biosVer[4] = 0;
-	}
-	megaCfg->support_ext_cdb = mega_support_ext_cdb(megaCfg);
+		if( scb->sgl64 ) {
+			pci_free_consistent(adapter->dev,
+				sizeof(mega_sgl64) * adapter->sglen,
+				scb->sgl64,
+				scb->sgl_dma_addr);
 
-	printk (KERN_NOTICE "megaraid: [%s:%s] detected %d logical drives" M_RD_CRLFSTR,
-		megaCfg->fwVer, megaCfg->biosVer, megaCfg->numldrv);
+			scb->sgl64 = NULL;
+		}
+
+		if( scb->pthru ) {
+			pci_free_consistent(adapter->dev, sizeof(mega_passthru),
+				scb->pthru, scb->pthru_dma_addr);
+
+			scb->pthru = NULL;
+		}
+
+		if( scb->epthru ) {
+			pci_free_consistent(adapter->dev,
+				sizeof(mega_ext_passthru),
+				scb->epthru, scb->epthru_dma_addr);
+
+			scb->epthru = NULL;
+		}
 
-	if ( megaCfg->support_ext_cdb ) {
-		printk(KERN_NOTICE "megaraid: supports extended CDBs.\n");
 	}
+}
 
-	/*
-	 * I hope that I can unmap here, reason DMA transaction is not required any more
-	 * after this
-	 */
 
-	return 0;
+/*
+ * Get information about the card/driver
+ */
+const char *
+megaraid_info(struct Scsi_Host *host)
+{
+	static char buffer[512];
+	adapter_t *adapter;
+
+	adapter = (adapter_t *)host->hostdata;
+
+	sprintf (buffer,
+		 "LSI Logic MegaRAID %s %d commands %d targs %d chans %d luns",
+		 adapter->fw_version, adapter->product_info.max_commands,
+		 adapter->host->max_id, adapter->host->max_channel,
+		 adapter->host->max_lun);
+	return buffer;
 }
 
-/*-------------------------------------------------------------------------
- *
- *                      Driver interface functions
- *
- *-------------------------------------------------------------------------*/
+volatile static int internal_done_flag = 0;
+volatile static int internal_done_errcode = 0;
 
-/*----------------------------------------------------------
- * Returns data to be displayed in /proc/scsi/megaraid/X
- *----------------------------------------------------------*/
+static DECLARE_WAIT_QUEUE_HEAD (internal_wait);
 
-int megaraid_proc_info (char *buffer, char **start, off_t offset,
-		    int length, int host_no, int inout)
+static void internal_done (Scsi_Cmnd *cmd)
 {
-	*start = buffer;
-	return 0;
+	internal_done_errcode = cmd->result;
+	internal_done_flag++;
+	wake_up (&internal_wait);
 }
 
-static int mega_findCard (Scsi_Host_Template * pHostTmpl,
-	       u16 pciVendor, u16 pciDev, long flag)
+/* shouldn't be used, but included for completeness */
+
+static int
+megaraid_command (Scsi_Cmnd *cmd)
 {
-	mega_host_config *megaCfg = NULL;
-	struct Scsi_Host *host = NULL;
-	u_char pciBus, pciDevFun, megaIrq;
-
-	u16 magic;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	u32 magic64;
-#endif
+	internal_done_flag = 0;
 
-	int		i;
+	/* Queue command, and wait until it has completed */
+	megaraid_queue (cmd, internal_done);
 
-#ifdef __LP64__
-	u64 megaBase;
-#else
-	u32 megaBase;
-#endif
+	while (!internal_done_flag)
+		interruptible_sleep_on (&internal_wait);
 
-	u16 pciIdx = 0;
-	u16 numFound = 0;
-	u16 subsysid, subsysvid;
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)	/* 0x20100 */
-	while (!pcibios_find_device
-	       (pciVendor, pciDev, pciIdx, &pciBus, &pciDevFun)) {
-#else
+	return internal_done_errcode;
+}
 
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)	/*0x20300 */
-	struct pci_dev *pdev = NULL;
-#else
-	struct pci_dev *pdev = pci_devices;
-#endif
 
-	while ((pdev = pci_find_device (pciVendor, pciDev, pdev))) {
-		if(pci_enable_device (pdev))
-			continue;
-		pciBus = pdev->bus->number;
-		pciDevFun = pdev->devfn;
-#endif
-		if ((flag & BOARD_QUARTZ) && (skip_id == -1)) {
-			pci_read_config_word (pdev, PCI_CONF_AMISIG, &magic);
-			if ((magic != AMI_SIGNATURE)
-			    && (magic != AMI_SIGNATURE_471)) {
-				pciIdx++;
-				continue;	/* not an AMI board */
-			}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-			pci_read_config_dword (pdev, PCI_CONF_AMISIG64, &magic64);
+/*
+ * Abort a previous SCSI request. Only commands on the pending list can be
+ * aborted. All the commands issued to the F/W must complete.
+ */
+static int
+megaraid_abort(Scsi_Cmnd *cmd)
+{
+	adapter_t	*adapter;
+	int		rval;
 
-			if (magic64 == AMI_64BIT_SIGNATURE)
-				flag |= BOARD_64BIT;
-#endif
-		}
+	adapter = (adapter_t *)cmd->device->host->hostdata;
 
-		/* Hmmm...Should we not make this more modularized so that in future we don't add
-		   for each firmware */
+	rval =  megaraid_abort_and_reset(adapter, cmd, SCB_ABORT);
 
-		if (flag & BOARD_QUARTZ) {
-			/* Check to see if this is a Dell PERC RAID controller model 466 */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)	/* 0x20100 */
-			pcibios_read_config_word (pciBus, pciDevFun,
-						  PCI_SUBSYSTEM_VENDOR_ID,
-						  &subsysvid);
-			pcibios_read_config_word (pciBus, pciDevFun,
-						  PCI_SUBSYSTEM_ID, &subsysid);
-#else
-			pci_read_config_word (pdev,
-					      PCI_SUBSYSTEM_VENDOR_ID,
-					      &subsysvid);
-			pci_read_config_word (pdev,
-					      PCI_SUBSYSTEM_ID, &subsysid);
-#endif
+	/*
+	 * This is required here to complete any completed requests
+	 * to be communicated over to the mid layer.
+	 */
+	mega_rundoneq(adapter);
 
-#if 0
-			/*
-			 * This routine is called with well know values and we
-			 * should not be getting what we have not asked.
-			 * Also, the check is not right. It should have been for
-			 * pci_vendor_id not subsysvid - AM
-			 */
+	return rval;
+}
 
-			/* If we don't detect this valid subsystem vendor id's 
-			   we refuse to load the driver 
-			   PART of PC200X compliance
-			 */
 
-			if ((subsysvid != AMI_SUBSYS_ID)
-			    && (subsysvid != DELL_SUBSYS_ID)
-			    && (subsysvid != HP_SUBSYS_ID))
-				continue;
-#endif
-		}
+static int
+megaraid_reset(Scsi_Cmnd *cmd)
+{
+	adapter_t	*adapter;
+	megacmd_t	mc;
+	int		rval;
 
-		printk (KERN_NOTICE
-			"megaraid: found 0x%4.04x:0x%4.04x:idx %d:bus %d:slot %d:func %d\n",
-			pciVendor, pciDev, pciIdx, pciBus, PCI_SLOT (pciDevFun),
-			PCI_FUNC (pciDevFun));
-		/* Read the base port and IRQ from PCI */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)	/* 0x20100 */
-		pcibios_read_config_dword (pciBus, pciDevFun,
-					   PCI_BASE_ADDRESS_0,
-					   (u_int *) & megaBase);
-		pcibios_read_config_byte (pciBus, pciDevFun,
-					  PCI_INTERRUPT_LINE, &megaIrq);
-#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)	/*0x20300 */
-		megaBase = pdev->base_address[0];
-		megaIrq = pdev->irq;
-#else
+	adapter = (adapter_t *)cmd->device->host->hostdata;
 
-		megaBase = pci_resource_start (pdev, 0);
-		megaIrq = pdev->irq;
-#endif
+#if MEGA_HAVE_CLUSTERING
+	mc.cmd = MEGA_CLUSTER_CMD;
+	mc.opcode = MEGA_RESET_RESERVATIONS;
 
-		pciIdx++;
+	spin_unlock_irq(&adapter->lock);
+	if( mega_internal_command(adapter, LOCK_INT, &mc, NULL) != 0 ) {
+		printk(KERN_WARNING
+				"megaraid: reservation reset failed.\n");
+	}
+	else {
+		printk(KERN_INFO "megaraid: reservation reset.\n");
+	}
+	spin_lock_irq(&adapter->lock);
+#endif
 
-		if (flag & BOARD_QUARTZ) {
-			megaBase &= PCI_BASE_ADDRESS_MEM_MASK;
-			megaBase = (long) ioremap (megaBase, 128);
-			if (!megaBase)
-				continue;
-		} else {
-			megaBase &= PCI_BASE_ADDRESS_IO_MASK;
-			megaBase += 0x10;
-		}
+	rval =  megaraid_abort_and_reset(adapter, cmd, SCB_RESET);
 
-		/* Initialize SCSI Host structure */
-		host = scsi_register (pHostTmpl, sizeof (mega_host_config));
-		if (!host)
-			goto err_unmap;
+	/*
+	 * This is required here to complete any completed requests
+	 * to be communicated over to the mid layer.
+	 */
+	mega_rundoneq(adapter);
 
-		/*
-		 * Comment the following initialization if you know 'max_sectors' is
-		 * not defined for this kernel.
-		 * This field was introduced in Linus's kernel 2.4.7pre3 and it
-		 * greatly increases the IO performance - AM
-		 */
-		host->max_sectors = 1024;
+	return rval;
+}
 
-		scsi_set_device(host, &pdev->dev);
-		megaCfg = (mega_host_config *) host->hostdata;
-		memset (megaCfg, 0, sizeof (mega_host_config));
 
-		printk (KERN_NOTICE "scsi%d : Found a MegaRAID controller at 0x%x, IRQ: %d"
-			M_RD_CRLFSTR, host->host_no, (u_int) megaBase, megaIrq);
 
-		if (flag & BOARD_64BIT)
-			printk (KERN_NOTICE "scsi%d : Enabling 64 bit support\n",
-				host->host_no);
+/**
+ * megaraid_abort_and_reset()
+ * @adapter - megaraid soft state
+ * @cmd - scsi command to be aborted or reset
+ * @aor - abort or reset flag
+ *
+ * Try to locate the scsi command in the pending queue. If found and is not
+ * issued to the controller, abort/reset it. Otherwise return failure
+ */
+static int
+megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor)
+{
+	struct list_head	*pos, *next;
+	scb_t			*scb;
 
-		/* Copy resource info into structure */
-		megaCfg->qCompletedH = NULL;
-		megaCfg->qCompletedT = NULL;
-		megaCfg->qPendingH = NULL;
-		megaCfg->qPendingT = NULL;
-		megaCfg->qFreeH = NULL;
-		megaCfg->qFreeT = NULL;
-		megaCfg->qFcnt = 0;
-		megaCfg->qPcnt = 0;
-		megaCfg->qCcnt = 0;
-		megaCfg->lock_free = SPIN_LOCK_UNLOCKED;
-		megaCfg->lock_pend = SPIN_LOCK_UNLOCKED;
-		megaCfg->lock_scsicmd = SPIN_LOCK_UNLOCKED;
-		megaCfg->flag = flag;
-		megaCfg->int_qh = NULL;
-		megaCfg->int_qt = NULL;
-		megaCfg->int_qlen = 0;
+	printk(KERN_WARNING "megaraid: %s-%lx cmd=%x <c=%d t=%d l=%d>\n",
+	     (aor == SCB_ABORT)? "ABORTING":"RESET", cmd->serial_number,
+	     cmd->cmnd[0], cmd->device->channel, 
+	     cmd->device->id, cmd->device->lun);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		megaCfg->dev = pdev;
-#endif
-		megaCfg->host = host;
-		megaCfg->base = megaBase;
-		megaCfg->host->irq = megaIrq;
-		megaCfg->host->io_port = megaBase;
-		megaCfg->host->n_io_port = 16;
-		megaCfg->host->unique_id = (pciBus << 8) | pciDevFun;
-		megaCtlrs[numCtlrs] = megaCfg;
-
-		if (!(flag & BOARD_QUARTZ)) {
-			/* Request our IO Range */
-			if (!request_region(megaBase, 16, "megaraid")) {
-				printk(KERN_WARNING "megaraid: Couldn't register I/O range!\n");
-				goto err_unregister;
-			}
-		}
+	if(list_empty(&adapter->pending_list))
+		return FALSE;
 
-		/* Request our IRQ */
-		if (request_irq (megaIrq, megaraid_isr, SA_SHIRQ,
-				 "megaraid", megaCfg)) {
-			printk (KERN_WARNING
-				"megaraid: Couldn't register IRQ %d!\n",
-				megaIrq);
-			goto err_release;
-		}
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		/*
-		 * unmap while releasing the driver, Is it required to be 
-		 * PCI_DMA_BIDIRECTIONAL 
-		*/
-
-		megaCfg->mailbox64ptr
-		    = pci_alloc_consistent (megaCfg->dev,
-					    sizeof (mega_mailbox64),
-					    &(megaCfg->dma_handle64));
+	list_for_each_safe(pos, next, &adapter->pending_list) {
 
-		mega_register_mailbox (megaCfg, megaCfg->dma_handle64);
-#else
-		mega_register_mailbox (megaCfg,
-				       virt_to_bus ((void *) &megaCfg->
-						    mailbox64));
-#endif
+		scb = list_entry(pos, scb_t, list);
 
-		mega_i_query_adapter (megaCfg);
+		if (scb->cmd == cmd) { /* Found command */
 
-		if ((subsysid == 0x1111) && (subsysvid == 0x1111)) {
+			scb->state |= aor;
 
 			/*
-			 * Which firmware
+			 * Check if this command has firmare owenership. If
+			 * yes, we cannot reset this command. Whenever, f/w
+			 * completes this command, we will return appropriate
+			 * status from ISR.
 			 */
-			if( strcmp(megaCfg->fwVer, "3.00") == 0 ||
-					strcmp(megaCfg->fwVer, "3.01") == 0 ) {
+			if( scb->state & SCB_ISSUED ) {
 
-				printk( KERN_WARNING
-					"megaraid: Your  card is a Dell PERC 2/SC RAID controller "
-					"with  firmware\nmegaraid: 3.00 or 3.01.  This driver is "
-					"known to have corruption issues\nmegaraid: with those "
-					"firmware versions on this specific card.  In order\n"
-					"megaraid: to protect your data, please upgrade your "
-					"firmware to version\nmegaraid: 3.10 or later, available "
-					"from the Dell Technical Support web\nmegaraid: site at\n"
-					"http://support.dell.com/us/en/filelib/download/"
-					"index.asp?fileid=2940\n"
-				);
+				printk(KERN_WARNING
+					"megaraid: %s-%lx[%x], fw owner.\n",
+					(aor==SCB_ABORT) ? "ABORTING":"RESET",
+					cmd->serial_number, scb->idx);
+
+				return FALSE;
 			}
-		}
+			else {
 
-		/*
-		 * If we have a HP 1M(0x60E7)/2M(0x60E8) controller with
-		 * firmware H.01.07 or H.01.08, disable 64 bit support,
-		 * since this firmware cannot handle 64 bit addressing
-		 */
+				/*
+				 * Not yet issued! Remove from the pending
+				 * list
+				 */
+				printk(KERN_WARNING
+					"megaraid: %s-%lx[%x], driver owner.\n",
+					(aor==SCB_ABORT) ? "ABORTING":"RESET",
+					cmd->serial_number, scb->idx);
 
-		if( (subsysvid == HP_SUBSYS_ID) &&
-				((subsysid == 0x60E7)||(subsysid == 0x60E8)) ) {
+				mega_free_scb(adapter, scb);
 
-			/*
-			 * which firmware
-			 */
-			if( strcmp(megaCfg->fwVer, "H01.07") == 0 ||
-					strcmp(megaCfg->fwVer, "H01.08") == 0 ) {
-				printk(KERN_WARNING
-						"megaraid: Firmware H.01.07 or H.01.08 on 1M/2M "
-						"controllers\nmegaraid: do not support 64 bit "
-						"addressing.\n"
-						"megaraid: DISABLING 64 bit support.\n");
-				megaCfg->flag &= ~BOARD_64BIT;
+				if( aor == SCB_ABORT ) {
+					cmd->result = (DID_ABORT << 16);
+				}
+				else {
+					cmd->result = (DID_RESET << 16);
+				}
+
+				list_add_tail(SCSI_LIST(cmd),
+						&adapter->completed_list);
+
+				return TRUE;
 			}
 		}
+	}
 
-		if (mega_is_bios_enabled (megaCfg)) {
-			mega_hbas[numCtlrs].is_bios_enabled = 1;
-		}
+	return FALSE;
+}
 
-		/*
-		 * Find out which channel is raid and which is scsi
-		 */
-		mega_enum_raid_scsi(megaCfg);
-		for( i = 0; i < megaCfg->productInfo.SCSIChanPresent; i++ ) {
-			if(IS_RAID_CH(i))
-				printk(KERN_NOTICE"megaraid: channel[%d] is raid.\n", i+1);
-			else
-				printk(KERN_NOTICE"megaraid: channel[%d] is scsi.\n", i+1);
-		}
 
-		/*
-		 * Find out if a logical drive is set as the boot drive. If there is
-		 * one, will make that as the first logical drive.
-		 */
-		mega_get_boot_ldrv(megaCfg);
+#ifdef CONFIG_PROC_FS
+/* Following code handles /proc fs  */
 
-		mega_hbas[numCtlrs].hostdata_addr = megaCfg;
+#define CREATE_READ_PROC(string, func)	create_proc_read_entry(string,	\
+					S_IRUSR | S_IFREG,		\
+					controller_proc_dir_entry,	\
+					func, adapter)
+
+/**
+ * mega_create_proc_entry()
+ * @index - index in soft state array
+ * @parent - parent node for this /proc entry
+ *
+ * Creates /proc entries for our controllers.
+ */
+static void
+mega_create_proc_entry(int index, struct proc_dir_entry *parent)
+{
+	struct proc_dir_entry	*controller_proc_dir_entry = NULL;
+	u8		string[64] = { 0 };
+	adapter_t	*adapter = hba_soft_state[index];
 
-		/*
-		 * Do we support random deletion and addition of logical drives
-		 */
-		megaCfg->read_ldidmap = 0;	/* set it after first logdrv delete cmd */
-		megaCfg->support_random_del = mega_support_random_del(megaCfg);
+	sprintf(string, "hba%d", adapter->host->host_no);
 
-		/* Initialize SCBs */
-		if (mega_init_scb (megaCfg)) {
-			pci_free_consistent (megaCfg->dev,
-					     sizeof (mega_mailbox64),
-					     (void *) megaCfg->mailbox64ptr,
-					     megaCfg->dma_handle64);
-			scsi_unregister (host);
-			continue;
-		}
+	controller_proc_dir_entry =
+		adapter->controller_proc_dir_entry = proc_mkdir(string, parent);
 
-		/*
-		 * Fill in the structure which needs to be passed back to the
-		 * application when it does an ioctl() for controller related
-		 * information.
-		 */
+	if(!controller_proc_dir_entry) {
+		printk(KERN_WARNING "\nmegaraid: proc_mkdir failed\n");
+		return;
+	}
+	adapter->proc_read = CREATE_READ_PROC("config", proc_read_config);
+	adapter->proc_stat = CREATE_READ_PROC("stat", proc_read_stat);
+	adapter->proc_mbox = CREATE_READ_PROC("mailbox", proc_read_mbox);
+#if MEGA_HAVE_ENH_PROC
+	adapter->proc_rr = CREATE_READ_PROC("rebuild-rate", proc_rebuild_rate);
+	adapter->proc_battery = CREATE_READ_PROC("battery-status",
+			proc_battery);
 
-		i = numCtlrs;
-		numCtlrs++;
+	/*
+	 * Display each physical drive on its channel
+	 */
+	adapter->proc_pdrvstat[0] = CREATE_READ_PROC("diskdrives-ch0",
+					proc_pdrv_ch0);
+	adapter->proc_pdrvstat[1] = CREATE_READ_PROC("diskdrives-ch1",
+					proc_pdrv_ch1);
+	adapter->proc_pdrvstat[2] = CREATE_READ_PROC("diskdrives-ch2",
+					proc_pdrv_ch2);
+	adapter->proc_pdrvstat[3] = CREATE_READ_PROC("diskdrives-ch3",
+					proc_pdrv_ch3);
 
-		mcontroller[i].base = megaBase;
-		mcontroller[i].irq = megaIrq;
-		mcontroller[i].numldrv = megaCfg->numldrv;
-		mcontroller[i].pcibus = pciBus;
-		mcontroller[i].pcidev = pciDev;
-		mcontroller[i].pcifun = PCI_FUNC (pciDevFun);
-		mcontroller[i].pciid = pciIdx;
-		mcontroller[i].pcivendor = pciVendor;
-		mcontroller[i].pcislot = PCI_SLOT (pciDevFun);
-		mcontroller[i].uid = (pciBus << 8) | pciDevFun;
-
-		numFound++;
-
-		/* Set the Mode of addressing to 64 bit */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		if ((megaCfg->flag & BOARD_64BIT) && BITS_PER_LONG == 64)
-#ifdef __LP64__
-			pdev->dma_mask = 0xffffffffffffffff;
-#else
-			pdev->dma_mask = 0xffffffff;
-#endif
+	/*
+	 * Display a set of up to 10 logical drive through each of following
+	 * /proc entries
+	 */
+	adapter->proc_rdrvstat[0] = CREATE_READ_PROC("raiddrives-0-9",
+					proc_rdrv_10);
+	adapter->proc_rdrvstat[1] = CREATE_READ_PROC("raiddrives-10-19",
+					proc_rdrv_20);
+	adapter->proc_rdrvstat[2] = CREATE_READ_PROC("raiddrives-20-29",
+					proc_rdrv_30);
+	adapter->proc_rdrvstat[3] = CREATE_READ_PROC("raiddrives-30-39",
+					proc_rdrv_40);
 #endif
-		continue;
-	      err_release:
-		if (flag & BOARD_QUARTZ)
-			release_region (megaBase, 16);
-	      err_unregister:
-		scsi_unregister (host);
-	      err_unmap:
-		if (flag & BOARD_QUARTZ)
-			iounmap ((void *) megaBase);
-	}
-	return numFound;
 }
 
-/*---------------------------------------------------------
- * Detects if a megaraid controller exists in this system
- *---------------------------------------------------------*/
 
-int megaraid_detect (Scsi_Host_Template * pHostTmpl)
+/**
+ * proc_read_config()
+ * @page - buffer to write the data in
+ * @start - where the actual data has been written in page
+ * @offset - same meaning as the read system call
+ * @count - same meaning as the read system call
+ * @eof - set if no more data needs to be returned
+ * @data - pointer to our soft state
+ *
+ * Display configuration information about the controller.
+ */
+static int
+proc_read_config(char *page, char **start, off_t offset, int count, int *eof,
+		void *data)
 {
-	int ctlridx = 0, count = 0;
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)	/*0x20300 */
-	pHostTmpl->proc_dir = &proc_scsi_megaraid;
-#else
-	pHostTmpl->proc_name = "megaraid";
-#endif
+	adapter_t *adapter = (adapter_t *)data;
+	int len = 0;
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)	/* 0x20100 */
-	if (!pcibios_present ()) {
-		printk (KERN_WARNING "megaraid: PCI bios not present."
-			M_RD_CRLFSTR);
-		return 0;
+	len += sprintf(page+len, "%s", MEGARAID_VERSION);
+
+	if(adapter->product_info.product_name[0])
+		len += sprintf(page+len, "%s\n",
+				adapter->product_info.product_name);
+
+	len += sprintf(page+len, "Controller Type: ");
+
+	if( adapter->flag & BOARD_MEMMAP ) {
+		len += sprintf(page+len,
+			"438/466/467/471/493/518/520/531/532\n");
 	}
-#endif
-	skip_id = -1;
-	if (megaraid && !strncmp (megaraid, "skip", strlen ("skip"))) {
-		if (megaraid[4] != '\0') {
-			skip_id = megaraid[4] - '0';
-			if (megaraid[5] != '\0') {
-				skip_id = (skip_id * 10) + (megaraid[5] - '0');
-			}
-		}
-		skip_id = (skip_id > 15) ? -1 : skip_id;
+	else {
+		len += sprintf(page+len,
+			"418/428/434\n");
 	}
 
-	printk (KERN_NOTICE "megaraid: " MEGARAID_VERSION);
+	if(adapter->flag & BOARD_40LD) {
+		len += sprintf(page+len,
+				"Controller Supports 40 Logical Drives\n");
+	}
 
-	memset (mega_hbas, 0, sizeof (mega_hbas));
+	if(adapter->flag & BOARD_64BIT) {
+		len += sprintf(page+len,
+		"Controller capable of 64-bit memory addressing\n");
+	}
+	if( adapter->has_64bit_addr ) {
+		len += sprintf(page+len,
+			"Controller using 64-bit memory addressing\n");
+	}
+	else {
+		len += sprintf(page+len,
+			"Controller is not using 64-bit memory addressing\n");
+	}
 
-	count += mega_findCard (pHostTmpl, PCI_VENDOR_ID_AMI,
-				PCI_DEVICE_ID_AMI_MEGARAID, 0);
-	count += mega_findCard (pHostTmpl, PCI_VENDOR_ID_AMI,
-				PCI_DEVICE_ID_AMI_MEGARAID2, 0);
-	count += mega_findCard (pHostTmpl, 0x8086,
-				PCI_DEVICE_ID_AMI_MEGARAID3, BOARD_QUARTZ);
-	count += mega_findCard (pHostTmpl, PCI_VENDOR_ID_AMI,
-				PCI_DEVICE_ID_AMI_MEGARAID3, BOARD_QUARTZ);
+	len += sprintf(page+len, "Base = %08lx, Irq = %d, ", adapter->base,
+			adapter->host->irq);
 
+	len += sprintf(page+len, "Logical Drives = %d, Channels = %d\n",
+			adapter->numldrv, adapter->product_info.nchannels);
+
+	len += sprintf(page+len, "Version =%s:%s, DRAM = %dMb\n",
+			adapter->fw_version, adapter->bios_version,
+			adapter->product_info.dram_size);
+
+	len += sprintf(page+len,
+		"Controller Queue Depth = %d, Driver Queue Depth = %d\n",
+		adapter->product_info.max_commands, adapter->max_cmds);
+
+	len += sprintf(page+len, "support_ext_cdb    = %d\n",
+			adapter->support_ext_cdb);
+	len += sprintf(page+len, "support_random_del = %d\n",
+			adapter->support_random_del);
+	len += sprintf(page+len, "boot_ldrv_enabled  = %d\n",
+			adapter->boot_ldrv_enabled);
+	len += sprintf(page+len, "boot_ldrv          = %d\n",
+			adapter->boot_ldrv);
+	len += sprintf(page+len, "boot_pdrv_enabled  = %d\n",
+			adapter->boot_pdrv_enabled);
+	len += sprintf(page+len, "boot_pdrv_ch       = %d\n",
+			adapter->boot_pdrv_ch);
+	len += sprintf(page+len, "boot_pdrv_tgt      = %d\n",
+			adapter->boot_pdrv_tgt);
+	len += sprintf(page+len, "quiescent          = %d\n",
+			atomic_read(&adapter->quiescent));
+	len += sprintf(page+len, "has_cluster        = %d\n",
+			adapter->has_cluster);
+
+	len += sprintf(page+len, "\nModule Parameters:\n");
+	len += sprintf(page+len, "max_cmd_per_lun    = %d\n",
+			max_cmd_per_lun);
+	len += sprintf(page+len, "max_sectors_per_io = %d\n",
+			max_sectors_per_io);
+
+	*eof = 1;
+
+	return len;
+}
 
-#ifdef CONFIG_PROC_FS
-	if (count) {
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)	/*0x20300 */
-		mega_proc_dir_entry = proc_mkdir ("megaraid", &proc_root);
-#else
-		mega_proc_dir_entry = create_proc_entry ("megaraid",
-							 S_IFDIR | S_IRUGO |
-							 S_IXUGO, &proc_root);
-#endif
-		if (!mega_proc_dir_entry)
-			printk ("megaraid: failed to create megaraid root\n");
-		else
-			for (ctlridx = 0; ctlridx < count; ctlridx++)
-				mega_create_proc_entry (ctlridx,
-							mega_proc_dir_entry);
-	}
-#endif
 
-	/*
-	 * Register the driver as a character device, for applications to access
-	 * it for ioctls.
-	 * Ideally, this should go in the init_module() routine, but since it is
-	 * hidden in the file "scsi_module.c" ( included in the end ), we define
-	 * it here
-	 * First argument (major) to register_chrdev implies a dynamic major
-	 * number allocation.
-	 */
-	if (count) {
-		major = register_chrdev (0, "megadev", &megadev_fops);
 
-		/*
-		 * Register the Shutdown Notification hook in kernel
-		 */
-		if (register_reboot_notifier (&mega_notifier)) {
-			printk ("MegaRAID Shutdown routine not registered!!\n");
-		}
+/**
+ * proc_read_stat()
+ * @page - buffer to write the data in
+ * @start - where the actual data has been written in page
+ * @offset - same meaning as the read system call
+ * @count - same meaning as the read system call
+ * @eof - set if no more data needs to be returned
+ * @data - pointer to our soft state
+ *
+ * Diaplay statistical information about the I/O activity.
+ */
+static int
+proc_read_stat(char *page, char **start, off_t offset, int count, int *eof,
+		void *data)
+{
+	adapter_t	*adapter;
+	int	len;
+	int	i;
 
-		init_MUTEX (&mimd_entry_mtx);
+	i = 0;	/* avoid compilation warnings */
+	len = 0;
+	adapter = (adapter_t *)data;
+
+	len = sprintf(page, "Statistical Information for this controller\n");
+	len += sprintf(page+len, "pend_cmds = %d\n",
+			atomic_read(&adapter->pend_cmds));
+#if MEGA_HAVE_STATS
+	for(i = 0; i < adapter->numldrv; i++) {
+		len += sprintf(page+len, "Logical Drive %d:\n", i);
+
+		len += sprintf(page+len,
+			"\tReads Issued = %lu, Writes Issued = %lu\n",
+			adapter->nreads[i], adapter->nwrites[i]);
+
+		len += sprintf(page+len,
+			"\tSectors Read = %lu, Sectors Written = %lu\n",
+			adapter->nreadblocks[i], adapter->nwriteblocks[i]);
+
+		len += sprintf(page+len,
+			"\tRead errors = %lu, Write errors = %lu\n\n",
+			adapter->rd_errors[i], adapter->wr_errors[i]);
 	}
+#else
+	len += sprintf(page+len,
+			"IO and error counters not compiled in driver.\n");
+#endif
+
+	*eof = 1;
 
-	return count;
+	return len;
 }
 
-/*---------------------------------------------------------------------
- * Release the controller's resources
- *---------------------------------------------------------------------*/
-int megaraid_release (struct Scsi_Host *pSHost)
+
+/**
+ * proc_read_mbox()
+ * @page - buffer to write the data in
+ * @start - where the actual data has been written in page
+ * @offset - same meaning as the read system call
+ * @count - same meaning as the read system call
+ * @eof - set if no more data needs to be returned
+ * @data - pointer to our soft state
+ *
+ * Display mailbox information for the last command issued. This information
+ * is good for debugging.
+ */
+static int
+proc_read_mbox(char *page, char **start, off_t offset, int count, int *eof,
+		void *data)
 {
-	mega_host_config *megaCfg;
-	mega_mailbox *mbox;
-	u_char mboxData[16];
-	int i;
 
-	megaCfg = (mega_host_config *) pSHost->hostdata;
-	mbox = (mega_mailbox *) mboxData;
+	adapter_t	*adapter = (adapter_t *)data;
+	volatile mbox_t	*mbox = adapter->mbox;
+	int	len = 0;
+
+	len = sprintf(page, "Contents of Mail Box Structure\n");
+	len += sprintf(page+len, "  Fw Command   = 0x%02x\n", mbox->cmd);
+	len += sprintf(page+len, "  Cmd Sequence = 0x%02x\n", mbox->cmdid);
+	len += sprintf(page+len, "  No of Sectors= %04d\n", mbox->numsectors);
+	len += sprintf(page+len, "  LBA          = 0x%02x\n", mbox->lba);
+	len += sprintf(page+len, "  DTA          = 0x%08x\n", mbox->xferaddr);
+	len += sprintf(page+len, "  Logical Drive= 0x%02x\n", mbox->logdrv);
+	len += sprintf(page+len, "  No of SG Elmt= 0x%02x\n",
+			mbox->numsgelements);
+	len += sprintf(page+len, "  Busy         = %01x\n", mbox->busy);
+	len += sprintf(page+len, "  Status       = 0x%02x\n", mbox->status);
+
+	*eof = 1;
+
+	return len;
+}
 
-	/* Flush cache to disk */
-	memset (mbox, 0, 16);
-	mboxData[0] = 0xA;
 
-	free_irq (megaCfg->host->irq, megaCfg);	/* Must be freed first, otherwise
-						   extra interrupt is generated */
+/**
+ * proc_rebuild_rate()
+ * @page - buffer to write the data in
+ * @start - where the actual data has been written in page
+ * @offset - same meaning as the read system call
+ * @count - same meaning as the read system call
+ * @eof - set if no more data needs to be returned
+ * @data - pointer to our soft state
+ *
+ * Display current rebuild rate
+ */
+static int
+proc_rebuild_rate(char *page, char **start, off_t offset, int count, int *eof,
+		void *data)
+{
+	adapter_t	*adapter = (adapter_t *)data;
+	dma_addr_t	dma_handle;
+	caddr_t		inquiry;
+	struct pci_dev	*pdev;
+	int	len = 0;
 
-	/* Issue a blocking (interrupts disabled) command to the card */
-	megaIssueCmd (megaCfg, mboxData, NULL, 0);
+	if( make_local_pdev(adapter, &pdev) != 0 ) {
+		*eof = 1;
+		return len;
+	}
 
-	/* Free our resources */
-	if (megaCfg->flag & BOARD_QUARTZ) {
-		iounmap ((void *) megaCfg->base);
-	} else {
-		release_region (megaCfg->host->io_port, 16);
+	if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) {
+		free_local_pdev(pdev);
+		*eof = 1;
+		return len;
 	}
 
-	mega_freeSgList (megaCfg);
-	pci_free_consistent (megaCfg->dev,
-			     sizeof (mega_mailbox64),
-			     (void *) megaCfg->mailbox64ptr,
-			     megaCfg->dma_handle64);
+	if( mega_adapinq(adapter, dma_handle) != 0 ) {
 
-#ifdef CONFIG_PROC_FS
-	if (megaCfg->controller_proc_dir_entry) {
-		remove_proc_entry ("stat", megaCfg->controller_proc_dir_entry);
-		remove_proc_entry ("status",
-				   megaCfg->controller_proc_dir_entry);
-		remove_proc_entry ("config",
-				   megaCfg->controller_proc_dir_entry);
-		remove_proc_entry ("mailbox",
-				   megaCfg->controller_proc_dir_entry);
-		for (i = 0; i < numCtlrs; i++) {
-			char buf[12] = { 0 };
-			sprintf (buf, "%d", i);
-			remove_proc_entry (buf, mega_proc_dir_entry);
-		}
-		remove_proc_entry ("megaraid", &proc_root);
-	}
-#endif
+		len = sprintf(page, "Adapter inquiry failed.\n");
 
-	/*
-	 *	Release the controller memory. A word of warning this frees
-	 *	hostdata and that includes megaCfg-> so be careful what you
-	 *	dereference beyond this point
-	 */
-	 
-	scsi_unregister (pSHost);
+		printk(KERN_WARNING "megaraid: inquiry failed.\n");
 
-	/*
-	 * Unregister the character device interface to the driver. Ideally this
-	 * should have been done in cleanup_module routine. Since this is hidden
-	 * in file "scsi_module.c", we do it here.
-	 * major is the major number of the character device returned by call to
-	 * register_chrdev() routine.
-	 */
+		mega_free_inquiry(inquiry, dma_handle, pdev);
 
-	unregister_chrdev (major, "megadev");
-	unregister_reboot_notifier (&mega_notifier);
+		free_local_pdev(pdev);
 
-	return 0;
-}
+		*eof = 1;
 
-static int mega_is_bios_enabled (mega_host_config * megacfg)
-{
-	mega_mailbox *mboxpnt;
-	unsigned char mbox[16];
-	int ret;
+		return len;
+	}
 
-	mboxpnt = (mega_mailbox *) mbox;
+	if( adapter->flag & BOARD_40LD ) {
+		len = sprintf(page, "Rebuild Rate: [%d%%]\n",
+			((mega_inquiry3 *)inquiry)->rebuild_rate);
+	}
+	else {
+		len = sprintf(page, "Rebuild Rate: [%d%%]\n",
+			((mraid_ext_inquiry *)
+			inquiry)->raid_inq.adapter_info.rebuild_rate);
+	}
 
-	memset (mbox, 0, sizeof (mbox));
-	memset ((void *) megacfg->mega_buffer,
-		0, sizeof (megacfg->mega_buffer));
 
-	/*
-	 * issue command to find out if the BIOS is enabled for this controller
-	 */
-	mbox[0] = IS_BIOS_ENABLED;
-	mbox[2] = GET_BIOS;
+	mega_free_inquiry(inquiry, dma_handle, pdev);
 
-	mboxpnt->xferaddr = virt_to_bus ((void *) megacfg->mega_buffer);
+	free_local_pdev(pdev);
 
-	ret = megaIssueCmd (megacfg, mbox, NULL, 0);
+	*eof = 1;
 
-	return (*(char *) megacfg->mega_buffer);
+	return len;
 }
 
-/*
- * Find out what channels are RAID/SCSI
+
+/**
+ * proc_battery()
+ * @page - buffer to write the data in
+ * @start - where the actual data has been written in page
+ * @offset - same meaning as the read system call
+ * @count - same meaning as the read system call
+ * @eof - set if no more data needs to be returned
+ * @data - pointer to our soft state
+ *
+ * Display information about the battery module on the controller.
  */
-void
-mega_enum_raid_scsi(mega_host_config *megacfg)
+static int
+proc_battery(char *page, char **start, off_t offset, int count, int *eof,
+		void *data)
 {
-	mega_mailbox *mboxp;
-	unsigned char mbox[16];
-	int		i;
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+	adapter_t	*adapter = (adapter_t *)data;
 	dma_addr_t	dma_handle;
-#endif
+	caddr_t		inquiry;
+	struct pci_dev	*pdev;
+	u8	battery_status = 0;
+	char	str[256];
+	int	len = 0;
 
-	mboxp = (mega_mailbox *)mbox;
+	if( make_local_pdev(adapter, &pdev) != 0 ) {
+		*eof = 1;
+		return len;
+	}
 
-	memset(mbox, 0, sizeof(mbox));
-	/*
-	 * issue command to find out what channels are raid/scsi
-	 */
-	mbox[0] = CHNL_CLASS;
-	mbox[2] = GET_CHNL_CLASS;
+	if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) {
+		free_local_pdev(pdev);
+		*eof = 1;
+		return len;
+	}
 
-	memset((void *)megacfg->mega_buffer, 0, sizeof(megacfg->mega_buffer));
+	if( mega_adapinq(adapter, dma_handle) != 0 ) {
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	dma_handle = pci_map_single(megacfg->dev, (void *)megacfg->mega_buffer,
-			      (2 * 1024L), PCI_DMA_FROMDEVICE);
+		len = sprintf(page, "Adapter inquiry failed.\n");
 
-	mboxp->xferaddr = dma_handle;
-#else
-	mboxp->xferaddr = virt_to_bus((void *)megacfg->mega_buffer);
-#endif
+		printk(KERN_WARNING "megaraid: inquiry failed.\n");
 
-	/*
-	 * Non-ROMB firware fail this command, so all channels
-	 * must be shown RAID
-	 */
-	if( megaIssueCmd(megacfg, mbox, NULL, 0) == 0 ) {
-		mega_ch_class = *((char *)megacfg->mega_buffer);
+		mega_free_inquiry(inquiry, dma_handle, pdev);
 
-		for( i = 0; i < NVIRT_CHAN; i++ ) {
-			/* logical drives channel is RAID */
-			mega_ch_class |= (0x01 << (megacfg->productInfo.SCSIChanPresent+i));
-		}
+		free_local_pdev(pdev);
+
+		*eof = 1;
+
+		return len;
+	}
+
+	if( adapter->flag & BOARD_40LD ) {
+		battery_status = ((mega_inquiry3 *)inquiry)->battery_status;
 	}
 	else {
-		mega_ch_class = 0xFF;
+		battery_status = ((mraid_ext_inquiry *)inquiry)->
+			raid_inq.adapter_info.battery_status;
 	}
 
+	/*
+	 * Decode the battery status
+	 */
+	sprintf(str, "Battery Status:[%d]", battery_status);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	pci_unmap_single(megacfg->dev, dma_handle,
-				  (2 * 1024L), PCI_DMA_FROMDEVICE);
-#endif
+	if(battery_status == MEGA_BATT_CHARGE_DONE)
+		strcat(str, " Charge Done");
 
+	if(battery_status & MEGA_BATT_MODULE_MISSING)
+		strcat(str, " Module Missing");
+	
+	if(battery_status & MEGA_BATT_LOW_VOLTAGE)
+		strcat(str, " Low Voltage");
+	
+	if(battery_status & MEGA_BATT_TEMP_HIGH)
+		strcat(str, " Temperature High");
+	
+	if(battery_status & MEGA_BATT_PACK_MISSING)
+		strcat(str, " Pack Missing");
+	
+	if(battery_status & MEGA_BATT_CHARGE_INPROG)
+		strcat(str, " Charge In-progress");
+	
+	if(battery_status & MEGA_BATT_CHARGE_FAIL)
+		strcat(str, " Charge Fail");
+	
+	if(battery_status & MEGA_BATT_CYCLES_EXCEEDED)
+		strcat(str, " Cycles Exceeded");
+
+	len = sprintf(page, "%s\n", str);
+
+
+	mega_free_inquiry(inquiry, dma_handle, pdev);
+
+	free_local_pdev(pdev);
+
+	*eof = 1;
+
+	return len;
 }
 
 
-/*
- * get the boot logical drive number if enabled
+/**
+ * proc_pdrv_ch0()
+ * @page - buffer to write the data in
+ * @start - where the actual data has been written in page
+ * @offset - same meaning as the read system call
+ * @count - same meaning as the read system call
+ * @eof - set if no more data needs to be returned
+ * @data - pointer to our soft state
+ *
+ * Display information about the physical drives on physical channel 0.
  */
-void
-mega_get_boot_ldrv(mega_host_config *megacfg)
+static int
+proc_pdrv_ch0(char *page, char **start, off_t offset, int count, int *eof,
+		void *data)
 {
-	mega_mailbox *mboxp;
-	unsigned char mbox[16];
-	struct private_bios_data *prv_bios_data;
-	u16		cksum = 0;
-	char	*cksum_p;
-	int		i;
+	adapter_t *adapter = (adapter_t *)data;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	dma_addr_t	dma_handle;
-#endif
+	*eof = 1;
 
-	mboxp = (mega_mailbox *)mbox;
+	return (proc_pdrv(adapter, page, 0));
+}
 
-	memset(mbox, 0, sizeof(mbox));
 
-	mbox[0] = BIOS_PVT_DATA;
-	mbox[2] = GET_BIOS_PVT_DATA;
+/**
+ * proc_pdrv_ch1()
+ * @page - buffer to write the data in
+ * @start - where the actual data has been written in page
+ * @offset - same meaning as the read system call
+ * @count - same meaning as the read system call
+ * @eof - set if no more data needs to be returned
+ * @data - pointer to our soft state
+ *
+ * Display information about the physical drives on physical channel 1.
+ */
+static int
+proc_pdrv_ch1(char *page, char **start, off_t offset, int count, int *eof,
+		void *data)
+{
+	adapter_t *adapter = (adapter_t *)data;
 
-	memset((void *)megacfg->mega_buffer, 0, sizeof(megacfg->mega_buffer));
+	*eof = 1;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	dma_handle = pci_map_single(megacfg->dev, (void *)megacfg->mega_buffer,
-			      (2 * 1024L), PCI_DMA_FROMDEVICE);
+	return (proc_pdrv(adapter, page, 1));
+}
 
-	mboxp->xferaddr = dma_handle;
-#else
-	mboxp->xferaddr = virt_to_bus((void *)megacfg->mega_buffer);
-#endif
 
-	megacfg->boot_ldrv_enabled = 0;
-	megacfg->boot_ldrv = 0;
-	if( megaIssueCmd(megacfg, mbox, NULL, 0) == 0 ) {
+/**
+ * proc_pdrv_ch2()
+ * @page - buffer to write the data in
+ * @start - where the actual data has been written in page
+ * @offset - same meaning as the read system call
+ * @count - same meaning as the read system call
+ * @eof - set if no more data needs to be returned
+ * @data - pointer to our soft state
+ *
+ * Display information about the physical drives on physical channel 2.
+ */
+static int
+proc_pdrv_ch2(char *page, char **start, off_t offset, int count, int *eof,
+		void *data)
+{
+	adapter_t *adapter = (adapter_t *)data;
 
-		prv_bios_data = (struct private_bios_data *)megacfg->mega_buffer;
+	*eof = 1;
 
-		cksum = 0;
-		cksum_p = (char *)prv_bios_data;
-		for( i = 0; i < 14; i++ ) {
-			cksum += (u16)(*cksum_p++);
-		}
+	return (proc_pdrv(adapter, page, 2));
+}
 
-		if( prv_bios_data->cksum == (u16)(0-cksum) ) {
-			megacfg->boot_ldrv_enabled = 1;
-			megacfg->boot_ldrv = prv_bios_data->boot_ldrv;
-		}
-	}
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	pci_unmap_single(megacfg->dev, dma_handle,
-				  (2 * 1024L), PCI_DMA_FROMDEVICE);
-#endif
+/**
+ * proc_pdrv_ch3()
+ * @page - buffer to write the data in
+ * @start - where the actual data has been written in page
+ * @offset - same meaning as the read system call
+ * @count - same meaning as the read system call
+ * @eof - set if no more data needs to be returned
+ * @data - pointer to our soft state
+ *
+ * Display information about the physical drives on physical channel 3.
+ */
+static int
+proc_pdrv_ch3(char *page, char **start, off_t offset, int count, int *eof,
+		void *data)
+{
+	adapter_t *adapter = (adapter_t *)data;
 
+	*eof = 1;
+
+	return (proc_pdrv(adapter, page, 3));
 }
 
 
-static inline void mega_freeSgList (mega_host_config * megaCfg)
+/**
+ * proc_pdrv()
+ * @page - buffer to write the data in
+ * @adapter - pointer to our soft state
+ *
+ * Display information about the physical drives.
+ */
+static int
+proc_pdrv(adapter_t *adapter, char *page, int channel)
 {
-	int i;
+	dma_addr_t	dma_handle;
+	char		*scsi_inq;
+	dma_addr_t	scsi_inq_dma_handle;
+	caddr_t		inquiry;
+	struct pci_dev	*pdev;
+	u8	*pdrv_state;
+	u8	state;
+	int	tgt;
+	int	max_channels;
+	int	len = 0;
+	char	str[80];
+	int	i;
 
-	for (i = 0; i < megaCfg->max_cmds; i++) {
-		if (megaCfg->scbList[i].sgList)
-			pci_free_consistent (megaCfg->dev,
-					     sizeof (mega_64sglist) *
-					     MAX_SGLIST,
-					     megaCfg->scbList[i].sgList,
-					     megaCfg->scbList[i].
-					     dma_sghandle64);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)	/* 0x020400 */
-			kfree (megaCfg->scbList[i].sgList);	/* free sgList */
-#endif
+	if( make_local_pdev(adapter, &pdev) != 0 ) {
+		return len;
 	}
-}
 
-/*----------------------------------------------
- * Get information about the card/driver
- *----------------------------------------------*/
-const char *megaraid_info (struct Scsi_Host *pSHost)
-{
-	static char buffer[512];
-	mega_host_config *megaCfg;
+	if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) {
+		free_local_pdev(pdev);
+		return len;
+	}
 
-	megaCfg = (mega_host_config *) pSHost->hostdata;
+	if( mega_adapinq(adapter, dma_handle) != 0 ) {
 
-	sprintf (buffer,
-		 "LSI Logic MegaRAID %s %d commands %d targs %d chans %d luns",
-		 megaCfg->fwVer, megaCfg->productInfo.MaxConcCmds,
-		 megaCfg->host->max_id, megaCfg->host->max_channel,
-		 megaCfg->host->max_lun);
-	return buffer;
-}
+		len = sprintf(page, "Adapter inquiry failed.\n");
+
+		printk(KERN_WARNING "megaraid: inquiry failed.\n");
+
+		mega_free_inquiry(inquiry, dma_handle, pdev);
 
-/*-----------------------------------------------------------------
- * Perform a SCSI command
- * Mailbox area:
- *   00 01 command
- *   01 01 command id
- *   02 02 # of sectors
- *   04 04 logical bus address
- *   08 04 physical buffer address
- *   0C 01 logical drive #
- *   0D 01 length of scatter/gather list
- *   0E 01 reserved
- *   0F 01 mailbox busy
- *   10 01 numstatus byte
- *   11 01 status byte
- *-----------------------------------------------------------------*/
-int megaraid_queue (Scsi_Cmnd * SCpnt, void (*pktComp) (Scsi_Cmnd *))
-{
-	DRIVER_LOCK_T mega_host_config * megaCfg;
-	mega_scb *pScb;
-	char *user_area = NULL;
-
-	megaCfg = (mega_host_config *) SCpnt->device->host->hostdata;
-	DRIVER_LOCK (megaCfg);
-
-	if (!(megaCfg->flag & (1L << SCpnt->device->channel))) {
-		if (SCpnt->device->channel < megaCfg->productInfo.SCSIChanPresent)
-			printk ( KERN_NOTICE
-				"scsi%d: scanning channel %d for devices.\n",
-				megaCfg->host->host_no, SCpnt->device->channel);
-		else
-			printk ( KERN_NOTICE
-				"scsi%d: scanning virtual channel %d for logical drives.\n",
-				megaCfg->host->host_no,
-				SCpnt->device->channel-megaCfg->productInfo.SCSIChanPresent+1);
+		free_local_pdev(pdev);
 
-		megaCfg->flag |= (1L << SCpnt->device->channel);
+		return len;
 	}
 
-	SCpnt->scsi_done = pktComp;
 
-	if (mega_driver_ioctl (megaCfg, SCpnt))
-		return 0;
+	scsi_inq = pci_alloc_consistent(pdev, 256, &scsi_inq_dma_handle);
 
-	/* If driver in abort or reset.. cancel this command */
-	if (megaCfg->flag & IN_ABORT) {
-		SCpnt->result = (DID_ABORT << 16);
-		/* Add Scsi_Command to end of completed queue */
-		if (megaCfg->qCompletedH == NULL) {
-			megaCfg->qCompletedH = megaCfg->qCompletedT = SCpnt;
-		} else {
-			megaCfg->qCompletedT->host_scribble =
-			    (unsigned char *) SCpnt;
-			megaCfg->qCompletedT = SCpnt;
-		}
-		megaCfg->qCompletedT->host_scribble = (unsigned char *) NULL;
-		megaCfg->qCcnt++;
+	if( scsi_inq == NULL ) {
+		len = sprintf(page, "memory not available for scsi inq.\n");
 
-		DRIVER_UNLOCK (megaCfg);
-		return 0;
-	} else if (megaCfg->flag & IN_RESET) {
-		SCpnt->result = (DID_RESET << 16);
-		/* Add Scsi_Command to end of completed queue */
-		if (megaCfg->qCompletedH == NULL) {
-			megaCfg->qCompletedH = megaCfg->qCompletedT = SCpnt;
-		} else {
-			megaCfg->qCompletedT->host_scribble =
-			    (unsigned char *) SCpnt;
-			megaCfg->qCompletedT = SCpnt;
-		}
-		megaCfg->qCompletedT->host_scribble = (unsigned char *) NULL;
-		megaCfg->qCcnt++;
+		mega_free_inquiry(inquiry, dma_handle, pdev);
 
-		DRIVER_UNLOCK (megaCfg);
-		return 0;
+		free_local_pdev(pdev);
+
+		return len;
 	}
 
-	megaCfg->flag |= IN_QUEUE;
-	/* Allocate and build a SCB request */
-	if ((pScb = mega_build_cmd (megaCfg, SCpnt)) != NULL) {
-
-		/*
-		 * Check if the HBA is in quiescent state, e.g., during a delete
-		 * logical drive opertion. If it is, queue the commands in the
-		 * internal queue until the delete operation is complete.
-		 */
-		if( ! megaCfg->quiescent ) {
-			/* Add SCB to the head of the pending queue */
-			if (megaCfg->qPendingH == NULL) {
-				megaCfg->qPendingH = megaCfg->qPendingT = pScb;
-			} else {
-				megaCfg->qPendingT->next = pScb;
-				megaCfg->qPendingT = pScb;
-			}
-			megaCfg->qPendingT->next = NULL;
-			megaCfg->qPcnt++;
-
-			if (mega_runpendq (megaCfg) == -1) {
-				DRIVER_UNLOCK (megaCfg);
-				return 0;
-			}
+	if( adapter->flag & BOARD_40LD ) {
+		pdrv_state = ((mega_inquiry3 *)inquiry)->pdrv_state;
+	}
+	else {
+		pdrv_state = ((mraid_ext_inquiry *)inquiry)->
+			raid_inq.pdrv_info.pdrv_state;
+	}
+
+	max_channels = adapter->product_info.nchannels;
+
+	if( channel >= max_channels ) return 0;
+
+	for( tgt = 0; tgt <= MAX_TARGET; tgt++ ) {
+
+		i = channel*16 + tgt;
+
+		state = *(pdrv_state + i);
+
+		switch( state & 0x0F ) {
+
+		case PDRV_ONLINE:
+			sprintf(str,
+			"Channel:%2d Id:%2d State: Online",
+				channel, tgt);
+			break;
+
+		case PDRV_FAILED:
+			sprintf(str,
+			"Channel:%2d Id:%2d State: Failed",
+				channel, tgt);
+			break;
+
+		case PDRV_RBLD:
+			sprintf(str,
+			"Channel:%2d Id:%2d State: Rebuild",
+				channel, tgt);
+			break;
+
+		case PDRV_HOTSPARE:
+			sprintf(str,
+			"Channel:%2d Id:%2d State: Hot spare",
+				channel, tgt);
+			break;
+
+		default:
+			sprintf(str,
+			"Channel:%2d Id:%2d State: Un-configured",
+				channel, tgt);
+			break;
+
 		}
-		else {
-			/* Add SCB to the internal queue */
-			if (megaCfg->int_qh == NULL) {
-				megaCfg->int_qh = megaCfg->int_qt = pScb;
-			} else {
-				megaCfg->int_qt->next = pScb;
-				megaCfg->int_qt = pScb;
-			}
-			megaCfg->int_qt->next = NULL;
-			megaCfg->int_qlen++;
-		}
-
-		if (pScb->SCpnt->cmnd[0] == M_RD_IOCTL_CMD_NEW) {
-			init_MUTEX_LOCKED (&pScb->ioctl_sem);
-			IO_UNLOCK_IRQ(megaCfg->host);
-			down (&pScb->ioctl_sem);
-    		user_area = (char *)*((u32*)&pScb->SCpnt->cmnd[4]);
-			if (copy_to_user
-			    (user_area, pScb->buff_ptr, pScb->iDataSize)) {
-				printk
-				    ("megaraid: Error copying ioctl return value to user buffer.\n");
-				pScb->SCpnt->result = (DID_ERROR << 16);
-			}
-		    IO_LOCK_IRQ(megaCfg->host);
-			DRIVER_LOCK (megaCfg);
-			kfree (pScb->buff_ptr);
-			pScb->buff_ptr = NULL;
-			mega_cmd_done (megaCfg, pScb, pScb->SCpnt->result);
-			mega_rundoneq (megaCfg);
-			mega_runpendq (megaCfg);
-			DRIVER_UNLOCK (megaCfg);
+
+		/*
+		 * This interface displays inquiries for disk drives
+		 * only. Inquries for logical drives and non-disk
+		 * devices are available through /proc/scsi/scsi
+		 */
+		memset(scsi_inq, 0, 256);
+		if( mega_internal_dev_inquiry(adapter, channel, tgt,
+				scsi_inq_dma_handle) ||
+				(scsi_inq[0] & 0x1F) != TYPE_DISK ) {
+			continue;
 		}
 
-		megaCfg->flag &= ~IN_QUEUE;
+		/*
+		 * Check for overflow. We print less than 240
+		 * characters for inquiry
+		 */
+		if( (len + 240) >= PAGE_SIZE ) break;
+
+		len += sprintf(page+len, "%s.\n", str);
 
+		len += mega_print_inquiry(page+len, scsi_inq);
 	}
 
-	DRIVER_UNLOCK (megaCfg);
-	return 0;
-}
+	pci_free_consistent(pdev, 256, scsi_inq, scsi_inq_dma_handle);
 
-/*----------------------------------------------------------------------
- * Issue a blocking command to the controller
- *----------------------------------------------------------------------*/
-volatile static int internal_done_flag = 0;
-volatile static int internal_done_errcode = 0;
+	mega_free_inquiry(inquiry, dma_handle, pdev);
 
-static DECLARE_WAIT_QUEUE_HEAD (internal_wait);
+	free_local_pdev(pdev);
 
-static void internal_done (Scsi_Cmnd * SCpnt)
-{
-	internal_done_errcode = SCpnt->result;
-	internal_done_flag++;
-	wake_up (&internal_wait);
+	return len;
 }
 
-/* shouldn't be used, but included for completeness */
 
-int megaraid_command (Scsi_Cmnd * SCpnt)
+/*
+ * Display scsi inquiry
+ */
+static int
+mega_print_inquiry(char *page, char *scsi_inq)
 {
-	internal_done_flag = 0;
-
-	/* Queue command, and wait until it has completed */
-	megaraid_queue (SCpnt, internal_done);
+	int	len = 0;
+	int	i;
 
-	while (!internal_done_flag) {
-		interruptible_sleep_on (&internal_wait);
+	len = sprintf(page, "  Vendor: ");
+	for( i = 8; i < 16; i++ ) {
+		len += sprintf(page+len, "%c", scsi_inq[i]);
 	}
 
-	return internal_done_errcode;
-}
+	len += sprintf(page+len, "  Model: ");
 
-/*---------------------------------------------------------------------
- * Abort a previous SCSI request
- *---------------------------------------------------------------------*/
-int megaraid_abort (Scsi_Cmnd * SCpnt)
-{
-	mega_host_config *megaCfg;
-	int rc;			/*, idx; */
-	mega_scb *pScb;
-
-	rc = SCSI_ABORT_NOT_RUNNING;
-
-	megaCfg = (mega_host_config *) SCpnt->device->host->hostdata;
-
-	megaCfg->flag |= IN_ABORT;
-
-	for (pScb = megaCfg->qPendingH; pScb; pScb = pScb->next) {
-		if (pScb->SCpnt == SCpnt) {
-			/* Found an aborting command */
-#if DEBUG
-			showMbox (pScb);
-#endif
+	for( i = 16; i < 32; i++ ) {
+		len += sprintf(page+len, "%c", scsi_inq[i]);
+	}
 
-	/*
-	 * If the command is queued to be issued to the firmware, abort the scsi cmd,
-	 * If the command is already aborted in a previous call to the _abort entry
-	 *  point, return SCSI_ABORT_SNOOZE, suggesting a reset.
-	 * If the command is issued to the firmware, which might complete after
-	 *  some time, we will mark the scb as aborted, and return to the mid layer,
-	 *  that abort could not be done.
-	 *  In the ISR, when this command actually completes, we will perform a normal
-	 *  completion.
-	 *
-	 * Oct 27, 1999
-	 */
+	len += sprintf(page+len, "  Rev: ");
 
-			switch (pScb->state) {
-			case SCB_ABORTED:	/* Already aborted */
-				rc = SCSI_ABORT_SNOOZE;
-				break;
-			case SCB_ISSUED:	/* Waiting on ISR result */
-				rc = SCSI_ABORT_NOT_RUNNING;
-				pScb->state = SCB_ABORTED;
-				break;
-			case SCB_ACTIVE:	/* still on the pending queue */
-				mega_freeSCB (megaCfg, pScb);
-				SCpnt->result = (DID_ABORT << 16);
-				if (megaCfg->qCompletedH == NULL) {
-					megaCfg->qCompletedH =
-					    megaCfg->qCompletedT = SCpnt;
-				} else {
-					megaCfg->qCompletedT->host_scribble =
-					    (unsigned char *) SCpnt;
-					megaCfg->qCompletedT = SCpnt;
-				}
-				megaCfg->qCompletedT->host_scribble =
-				    (unsigned char *) NULL;
-				megaCfg->qCcnt++;
-				rc = SCSI_ABORT_SUCCESS;
-				break;
-			default:
-				printk
-				    ("megaraid_abort: unknown command state!!\n");
-				rc = SCSI_ABORT_NOT_RUNNING;
-				break;
-			}
-			break;
-		}
+	for( i = 32; i < 36; i++ ) {
+		len += sprintf(page+len, "%c", scsi_inq[i]);
 	}
 
-	megaCfg->flag &= ~IN_ABORT;
+	len += sprintf(page+len, "\n");
 
-#if DEBUG
-	if (megaCfg->flag & IN_QUEUE)
-		printk ("ma:flag is in queue\n");
-	if (megaCfg->qCompletedH == NULL)
-		printk ("ma:qchead == null\n");
-#endif
+	i = scsi_inq[0] & 0x1f;
 
-	/*
-	 * This is required here to complete any completed requests to be communicated
-	 * over to the mid layer.
-	 * Calling just mega_rundoneq() did not work.
-	 */
-	if (megaCfg->qCompletedH) {
-		SCpnt = megaCfg->qCompletedH;
-		megaCfg->qCompletedH = (Scsi_Cmnd *) SCpnt->host_scribble;
-		megaCfg->qCcnt--;
+	len += sprintf(page+len, "  Type:   %s ",
+		i < MAX_SCSI_DEVICE_CODE ? scsi_device_types[i] :
+		   "Unknown          ");
 
-		SCpnt->host_scribble = (unsigned char *) NULL;
-		/* Callback */
-		callDone (SCpnt);
-	}
-	mega_rundoneq (megaCfg);
+	len += sprintf(page+len,
+	"                 ANSI SCSI revision: %02x", scsi_inq[2] & 0x07);
+
+	if( (scsi_inq[2] & 0x07) == 1 && (scsi_inq[3] & 0x0f) == 1 )
+		len += sprintf(page+len, " CCS\n");
+	else
+		len += sprintf(page+len, "\n");
 
-	return rc;
+	return len;
 }
 
-/*---------------------------------------------------------------------
- * Reset a previous SCSI request
- *---------------------------------------------------------------------*/
 
-int megaraid_reset (Scsi_Cmnd * SCpnt, unsigned int rstflags)
+/**
+ * proc_rdrv_10()
+ * @page - buffer to write the data in
+ * @start - where the actual data has been written in page
+ * @offset - same meaning as the read system call
+ * @count - same meaning as the read system call
+ * @eof - set if no more data needs to be returned
+ * @data - pointer to our soft state
+ *
+ * Display real time information about the logical drives 0 through 9.
+ */
+static int
+proc_rdrv_10(char *page, char **start, off_t offset, int count, int *eof,
+		void *data)
 {
-	mega_host_config *megaCfg;
-	int idx;
-	int rc;
-	mega_scb *pScb;
+	adapter_t *adapter = (adapter_t *)data;
 
-	rc = SCSI_RESET_NOT_RUNNING;
-	megaCfg = (mega_host_config *) SCpnt->device->host->hostdata;
+	*eof = 1;
 
-	megaCfg->flag |= IN_RESET;
-
-	printk
-	    ("megaraid_RESET: %.08lx cmd=%.02x <c=%d.t=%d.l=%d>, flag = %x\n",
-	     SCpnt->serial_number, SCpnt->cmnd[0], SCpnt->device->channel,
-	     SCpnt->device->id, SCpnt->device->lun, rstflags);
+	return (proc_rdrv(adapter, page, 0, 9));
+}
 
-	TRACE (("RESET: %.08lx %.02x <%d.%d.%d>\n",
-		SCpnt->serial_number, SCpnt->cmnd[0], SCpnt->device->channel,
-		SCpnt->device->id, SCpnt->device->lun));
 
-	/*
-	 * Walk list of SCBs for any that are still outstanding
-	 */
-	for (idx = 0; idx < megaCfg->max_cmds; idx++) {
-		if (megaCfg->scbList[idx].state != SCB_FREE) {
-			SCpnt = megaCfg->scbList[idx].SCpnt;
-			pScb = &megaCfg->scbList[idx];
-			if (SCpnt != NULL) {
-				pScb->state = SCB_RESET;
-				break;
-			}
-		}
-	}
+/**
+ * proc_rdrv_20()
+ * @page - buffer to write the data in
+ * @start - where the actual data has been written in page
+ * @offset - same meaning as the read system call
+ * @count - same meaning as the read system call
+ * @eof - set if no more data needs to be returned
+ * @data - pointer to our soft state
+ *
+ * Display real time information about the logical drives 0 through 9.
+ */
+static int
+proc_rdrv_20(char *page, char **start, off_t offset, int count, int *eof,
+		void *data)
+{
+	adapter_t *adapter = (adapter_t *)data;
 
-	megaCfg->flag &= ~IN_RESET;
+	*eof = 1;
 
-	mega_rundoneq (megaCfg);
-	return rc;
+	return (proc_rdrv(adapter, page, 10, 19));
 }
 
-#ifdef CONFIG_PROC_FS
-/* Following code handles /proc fs  */
-static int proc_printf (mega_host_config * megaCfg, const char *fmt, ...)
+
+/**
+ * proc_rdrv_30()
+ * @page - buffer to write the data in
+ * @start - where the actual data has been written in page
+ * @offset - same meaning as the read system call
+ * @count - same meaning as the read system call
+ * @eof - set if no more data needs to be returned
+ * @data - pointer to our soft state
+ *
+ * Display real time information about the logical drives 0 through 9.
+ */
+static int
+proc_rdrv_30(char *page, char **start, off_t offset, int count, int *eof,
+		void *data)
 {
-	va_list args;
-	int i;
+	adapter_t *adapter = (adapter_t *)data;
 
-	if (megaCfg->procidx > PROCBUFSIZE)
-		return 0;
+	*eof = 1;
+
+	return (proc_rdrv(adapter, page, 20, 29));
+}
+
+
+/**
+ * proc_rdrv_40()
+ * @page - buffer to write the data in
+ * @start - where the actual data has been written in page
+ * @offset - same meaning as the read system call
+ * @count - same meaning as the read system call
+ * @eof - set if no more data needs to be returned
+ * @data - pointer to our soft state
+ *
+ * Display real time information about the logical drives 0 through 9.
+ */
+static int
+proc_rdrv_40(char *page, char **start, off_t offset, int count, int *eof,
+		void *data)
+{
+	adapter_t *adapter = (adapter_t *)data;
 
-	va_start (args, fmt);
-	i = vsprintf ((megaCfg->procbuf + megaCfg->procidx), fmt, args);
-	va_end (args);
+	*eof = 1;
 
-	megaCfg->procidx += i;
-	return i;
+	return (proc_rdrv(adapter, page, 30, 39));
 }
 
-static int proc_read_config (char *page, char **start, off_t offset,
-		  int count, int *eof, void *data)
+
+/**
+ * proc_rdrv()
+ * @page - buffer to write the data in
+ * @adapter - pointer to our soft state
+ * @start - starting logical drive to display
+ * @end - ending logical drive to display
+ *
+ * We do not print the inquiry information since its already available through
+ * /proc/scsi/scsi interface
+ */
+static int
+proc_rdrv(adapter_t *adapter, char *page, int start, int end )
 {
+	dma_addr_t	dma_handle;
+	logdrv_param	*lparam;
+	megacmd_t	mc;
+	char		*disk_array;
+	dma_addr_t	disk_array_dma_handle;
+	caddr_t		inquiry;
+	struct pci_dev	*pdev;
+	u8	*rdrv_state;
+	int	num_ldrv;
+	u32	array_sz;
+	int	len = 0;
+	int	i;
+
+	if( make_local_pdev(adapter, &pdev) != 0 ) {
+		return len;
+	}
 
-	mega_host_config *megaCfg = (mega_host_config *) data;
+	if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) {
+		free_local_pdev(pdev);
+		return len;
+	}
 
-	*start = page;
+	if( mega_adapinq(adapter, dma_handle) != 0 ) {
 
-	if (megaCfg->productInfo.ProductName[0] != 0)
-		proc_printf (megaCfg, "%s\n", megaCfg->productInfo.ProductName);
+		len = sprintf(page, "Adapter inquiry failed.\n");
 
-	proc_printf (megaCfg, "Controller Type: ");
+		printk(KERN_WARNING "megaraid: inquiry failed.\n");
 
-	if (megaCfg->flag & BOARD_QUARTZ)
-		proc_printf (megaCfg, "438/466/467/471/493\n");
-	else
-		proc_printf (megaCfg, "418/428/434\n");
+		mega_free_inquiry(inquiry, dma_handle, pdev);
 
-	if (megaCfg->flag & BOARD_40LD)
-		proc_printf (megaCfg,
-			     "Controller Supports 40 Logical Drives\n");
+		free_local_pdev(pdev);
 
-	if (megaCfg->flag & BOARD_64BIT)
-		proc_printf (megaCfg,
-			     "Controller / Driver uses 64 bit memory addressing\n");
+		return len;
+	}
 
-	proc_printf (megaCfg, "Base = %08x, Irq = %d, ", megaCfg->base,
-		     megaCfg->host->irq);
+	memset(&mc, 0, sizeof(megacmd_t));
 
-	proc_printf (megaCfg, "Logical Drives = %d, Channels = %d\n",
-		     megaCfg->numldrv, megaCfg->productInfo.SCSIChanPresent);
+	if( adapter->flag & BOARD_40LD ) {
+		array_sz = sizeof(disk_array_40ld);
 
-	proc_printf (megaCfg, "Version =%s:%s, DRAM = %dMb\n",
-		     megaCfg->fwVer, megaCfg->biosVer,
-		     megaCfg->productInfo.DramSize);
+		rdrv_state = ((mega_inquiry3 *)inquiry)->ldrv_state;
 
-	proc_printf (megaCfg,
-		     "Controller Queue Depth = %d, Driver Queue Depth = %d\n",
-		     megaCfg->productInfo.MaxConcCmds, megaCfg->max_cmds);
-	COPY_BACK;
-	return count;
-}
+		num_ldrv = ((mega_inquiry3 *)inquiry)->num_ldrv;
+	}
+	else {
+		array_sz = sizeof(disk_array_8ld);
 
-static int proc_read_stat (char *page, char **start, off_t offset,
-		int count, int *eof, void *data)
-{
-	int i;
-	mega_host_config *megaCfg = (mega_host_config *) data;
+		rdrv_state = ((mraid_ext_inquiry *)inquiry)->
+			raid_inq.logdrv_info.ldrv_state;
 
-	*start = page;
+		num_ldrv = ((mraid_ext_inquiry *)inquiry)->
+			raid_inq.logdrv_info.num_ldrv;
+	}
 
-	proc_printf (megaCfg, "Statistical Information for this controller\n");
-	proc_printf (megaCfg, "Interrupts Collected = %lu\n",
-		     megaCfg->nInterrupts);
+	disk_array = pci_alloc_consistent(pdev, array_sz,
+			&disk_array_dma_handle);
 
-	for (i = 0; i < megaCfg->numldrv; i++) {
-		proc_printf (megaCfg, "Logical Drive %d:\n", i);
+	if( disk_array == NULL ) {
+		len = sprintf(page, "memory not available.\n");
 
-		proc_printf (megaCfg,
-			     "\tReads Issued = %lu, Writes Issued = %lu\n",
-			     megaCfg->nReads[i], megaCfg->nWrites[i]);
+		mega_free_inquiry(inquiry, dma_handle, pdev);
 
-		proc_printf (megaCfg,
-			     "\tSectors Read = %lu, Sectors Written = %lu\n\n",
-			     megaCfg->nReadBlocks[i], megaCfg->nWriteBlocks[i]);
+		free_local_pdev(pdev);
 
+		return len;
 	}
 
-	COPY_BACK;
-	return count;
-}
+	mc.xferaddr = (u32)disk_array_dma_handle;
 
-static int proc_read_status (char *page, char **start, off_t offset,
-		  int count, int *eof, void *data)
-{
-	mega_host_config *megaCfg = (mega_host_config *) data;
-	*start = page;
+	if( adapter->flag & BOARD_40LD ) {
+		mc.cmd = FC_NEW_CONFIG;
+		mc.opcode = OP_DCMD_READ_CONFIG;
 
-	proc_printf (megaCfg, "TBD\n");
-	COPY_BACK;
-	return count;
-}
+		if( mega_internal_command(adapter, LOCK_INT, &mc, NULL) ) {
 
-static int proc_read_mbox (char *page, char **start, off_t offset,
-		int count, int *eof, void *data)
-{
+			len = sprintf(page, "40LD read config failed.\n");
+
+			mega_free_inquiry(inquiry, dma_handle, pdev);
+
+			pci_free_consistent(pdev, array_sz, disk_array,
+					disk_array_dma_handle);
+
+			free_local_pdev(pdev);
+
+			return len;
+		}
+
+	}
+	else {
+		mc.cmd = NEW_READ_CONFIG_8LD;
+
+		if( mega_internal_command(adapter, LOCK_INT, &mc, NULL) ) {
 
-	mega_host_config *megaCfg = (mega_host_config *) data;
-	volatile mega_mailbox *mbox = megaCfg->mbox;
+			mc.cmd = READ_CONFIG_8LD;
 
-	*start = page;
+			if( mega_internal_command(adapter, LOCK_INT, &mc,
+						NULL) ){
 
-	proc_printf (megaCfg, "Contents of Mail Box Structure\n");
-	proc_printf (megaCfg, "  Fw Command   = 0x%02x\n", mbox->cmd);
-	proc_printf (megaCfg, "  Cmd Sequence = 0x%02x\n", mbox->cmdid);
-	proc_printf (megaCfg, "  No of Sectors= %04d\n", mbox->numsectors);
-	proc_printf (megaCfg, "  LBA          = 0x%02x\n", mbox->lba);
-	proc_printf (megaCfg, "  DTA          = 0x%08x\n", mbox->xferaddr);
-	proc_printf (megaCfg, "  Logical Drive= 0x%02x\n", mbox->logdrv);
-	proc_printf (megaCfg, "  No of SG Elmt= 0x%02x\n", mbox->numsgelements);
-	proc_printf (megaCfg, "  Busy         = %01x\n", mbox->busy);
-	proc_printf (megaCfg, "  Status       = 0x%02x\n", mbox->status);
+				len = sprintf(page,
+					"8LD read config failed.\n");
 
-	/* proc_printf(megaCfg, "Dump of MailBox\n");
-	for (i = 0; i < 16; i++)
-        	proc_printf(megaCfg, "%02x ",*(mbox + i));
+				mega_free_inquiry(inquiry, dma_handle, pdev);
 
-	proc_printf(megaCfg, "\n\nNumber of Status = %02d\n",mbox->numstatus);
+				pci_free_consistent(pdev, array_sz,
+						disk_array,
+						disk_array_dma_handle);
 
-	for (i = 0; i < 46; i++) {
-        	proc_printf(megaCfg,"%02d ",*(mbox + 16 + i));
-        if (i%16)
-                proc_printf(megaCfg,"\n");
+				free_local_pdev(pdev);
+
+				return len;
+			}
+		}
 	}
 
-	if (!mbox->numsgelements) {
-	        dta = phys_to_virt(mbox->xferaddr);
-	        for (i = 0; i < mbox->numsgelements; i++)
-	                if (dta) {
-	                        proc_printf(megaCfg,"Addr = %08x\n", (ulong)*(dta + i));                        proc_printf(megaCfg,"Length = %08x\n",
-	                                (ulong)*(dta + i + 4));
-	                }
-	}*/
-	COPY_BACK;
-	return count;
-}
+	for( i = start; i < ( (end+1 < num_ldrv) ? end+1 : num_ldrv ); i++ ) {
 
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)	/*0x20300 */
-#define CREATE_READ_PROC(string, fxn) create_proc_read_entry(string, \
-                                         S_IRUSR | S_IFREG,\
-                                         controller_proc_dir_entry,\
-                                         fxn, megaCfg)
-#else
-#define CREATE_READ_PROC(string, fxn) create_proc_read_entry(string,S_IRUSR | S_IFREG, controller_proc_dir_entry, fxn, megaCfg)
+		if( adapter->flag & BOARD_40LD ) {
+			lparam =
+			&((disk_array_40ld *)disk_array)->ldrv[i].lparam;
+		}
+		else {
+			lparam =
+			&((disk_array_8ld *)disk_array)->ldrv[i].lparam;
+		}
 
-static struct proc_dir_entry *
-create_proc_read_entry (const char *string,
-			int mode,
-			struct proc_dir_entry *parent,
-			read_proc_t * fxn, mega_host_config * megaCfg)
-{
-	struct proc_dir_entry *temp = NULL;
-
-	temp = kmalloc (sizeof (struct proc_dir_entry), GFP_KERNEL);
-	if (!temp)
-		return NULL;
-	memset (temp, 0, sizeof (struct proc_dir_entry));
-
-	if ((temp->name = kmalloc (strlen (string) + 1, GFP_KERNEL)) == NULL) {
-		kfree (temp);
-		return NULL;
-	}
-
-	strcpy ((char *) temp->name, string);
-	temp->namelen = strlen (string);
-	temp->mode = mode; /*S_IFREG | S_IRUSR */ ;
-	temp->data = (void *) megaCfg;
-	temp->read_proc = fxn;
-	proc_register (parent, temp);
-	return temp;
-}
-#endif
+		/*
+		 * Check for overflow. We print less than 240 characters for
+		 * information about each logical drive.
+		 */
+		if( (len + 240) >= PAGE_SIZE ) break;
 
-static void mega_create_proc_entry (int index, struct proc_dir_entry *parent)
-{
-	u_char string[64] = { 0 };
-	mega_host_config *megaCfg = megaCtlrs[index];
-	struct proc_dir_entry *controller_proc_dir_entry = NULL;
+		len += sprintf(page+len, "Logical drive:%2d:, ", i);
 
-	sprintf (string, "%d", index);
+		switch( rdrv_state[i] & 0x0F ) {
+		case RDRV_OFFLINE:
+			len += sprintf(page+len, "state: offline");
+			break;
 
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)	/*0x20300 */
-	controller_proc_dir_entry =
-	    megaCfg->controller_proc_dir_entry = proc_mkdir (string, parent);
-#else
-	controller_proc_dir_entry =
-	    megaCfg->controller_proc_dir_entry =
-	    create_proc_entry (string, S_IFDIR | S_IRUGO | S_IXUGO, parent);
-#endif
+		case RDRV_DEGRADED:
+			len += sprintf(page+len, "state: degraded");
+			break;
 
-	if (!controller_proc_dir_entry)
-		printk ("\nmegaraid: proc_mkdir failed\n");
-	else {
-		megaCfg->proc_read =
-		    CREATE_READ_PROC ("config", proc_read_config);
-		megaCfg->proc_status =
-		    CREATE_READ_PROC ("status", proc_read_status);
-		megaCfg->proc_stat = CREATE_READ_PROC ("stat", proc_read_stat);
-		megaCfg->proc_mbox =
-		    CREATE_READ_PROC ("mailbox", proc_read_mbox);
+		case RDRV_OPTIMAL:
+			len += sprintf(page+len, "state: optimal");
+			break;
+
+		case RDRV_DELETED:
+			len += sprintf(page+len, "state: deleted");
+			break;
+
+		default:
+			len += sprintf(page+len, "state: unknown");
+			break;
+		}
+
+		/*
+		 * Check if check consistency or initialization is going on
+		 * for this logical drive.
+		 */
+		if( (rdrv_state[i] & 0xF0) == 0x20 ) {
+			len += sprintf(page+len,
+					", check-consistency in progress");
+		}
+		else if( (rdrv_state[i] & 0xF0) == 0x10 ) {
+			len += sprintf(page+len,
+					", initialization in progress");
+		}
+		
+		len += sprintf(page+len, "\n");
+
+		len += sprintf(page+len, "Span depth:%3d, ",
+				lparam->span_depth);
+
+		len += sprintf(page+len, "RAID level:%3d, ",
+				lparam->level);
+
+		len += sprintf(page+len, "Stripe size:%3d, ",
+				lparam->stripe_sz ? lparam->stripe_sz/2: 128);
+
+		len += sprintf(page+len, "Row size:%3d\n",
+				lparam->row_size);
+
+
+		len += sprintf(page+len, "Read Policy: ");
+
+		switch(lparam->read_ahead) {
+
+		case NO_READ_AHEAD:
+			len += sprintf(page+len, "No read ahead, ");
+			break;
+
+		case READ_AHEAD:
+			len += sprintf(page+len, "Read ahead, ");
+			break;
+
+		case ADAP_READ_AHEAD:
+			len += sprintf(page+len, "Adaptive, ");
+			break;
+
+		}
+
+		len += sprintf(page+len, "Write Policy: ");
+
+		switch(lparam->write_mode) {
+
+		case WRMODE_WRITE_THRU:
+			len += sprintf(page+len, "Write thru, ");
+			break;
+
+		case WRMODE_WRITE_BACK:
+			len += sprintf(page+len, "Write back, ");
+			break;
+		}
+
+		len += sprintf(page+len, "Cache Policy: ");
+
+		switch(lparam->direct_io) {
+
+		case CACHED_IO:
+			len += sprintf(page+len, "Cached IO\n\n");
+			break;
+
+		case DIRECT_IO:
+			len += sprintf(page+len, "Direct IO\n\n");
+			break;
+		}
 	}
 
+	mega_free_inquiry(inquiry, dma_handle, pdev);
+
+	pci_free_consistent(pdev, array_sz, disk_array,
+			disk_array_dma_handle);
+
+	free_local_pdev(pdev);
+
+	return len;
 }
-#endif				/* CONFIG_PROC_FS */
 
-/*-------------------------------------------------------------
+#endif
+
+
+/**
+ * megaraid_biosparam()
+ *
  * Return the disk geometry for a particular disk
- * Input:
- *   Disk *disk - Disk geometry
- *   struct block_device *dev - Device node
- *   int *geom  - Returns geometry fields
- *     geom[0] = heads
- *     geom[1] = sectors
- *     geom[2] = cylinders
- *-------------------------------------------------------------*/
-int megaraid_biosparam (struct scsi_device *sdev, struct block_device *bdev,
-				sector_t capacity, int *geom)
+ */
+static int
+megaraid_biosparam(struct scsi_device *sdev, struct block_device *bdev,
+		    sector_t capacity, int geom[])
 {
-	int heads, sectors, cylinders;
-	mega_host_config *megaCfg;
+	adapter_t	*adapter;
+	unsigned char	*bh;
+	int	heads;
+	int	sectors;
+	int	cylinders;
+	int	rval;
 
 	/* Get pointer to host config structure */
-	megaCfg = (mega_host_config *) sdev->host->hostdata;
+	adapter = (adapter_t *)sdev->host->hostdata;
 
-	if( IS_RAID_CH(sdev->channel)) {
+	if (IS_RAID_CH(adapter, sdev->channel)) {
 			/* Default heads (64) & sectors (32) */
 			heads = 64;
 			sectors = 32;
-			cylinders = (unsigned long)capacity >> 11;
+			cylinders = (ulong)capacity / (heads * sectors);
 
-			/* Handle extended translation size for logical drives > 1Gb */
-			if (capacity >= 0x200000) {
+			/*
+			 * Handle extended translation size for logical drives
+			 * > 1Gb
+			 */
+			if ((ulong)capacity >= 0x200000) {
 				heads = 255;
 				sectors = 63;
-				cylinders = (unsigned long)capacity / (heads * sectors);
+				cylinders = (ulong)capacity / (heads * sectors);
 			}
 
 			/* return result */
@@ -4080,22 +3846,30 @@
 			geom[2] = cylinders;
 	}
 	else {
-		if( mega_partsize(bdev, capacity, geom) == 0 ) return 0;
+		bh = scsi_bios_ptable(bdev);
 
-		printk(KERN_WARNING
-				"megaraid: invalid partition on this disk on channel %d\n",
+		if( bh ) {
+			rval = scsi_partsize(bh, capacity,
+					    &geom[2], &geom[0], &geom[1]);
+			kfree(bh);
+			if( rval != -1 )
+				return rval;
+		}
+
+		printk(KERN_INFO
+		"megaraid: invalid partition on this disk on channel %d\n",
 				sdev->channel);
 
 		/* Default heads (64) & sectors (32) */
 		heads = 64;
 		sectors = 32;
-		cylinders = capacity >> 11;
+		cylinders = (ulong)capacity / (heads * sectors);
 
 		/* Handle extended translation size for logical drives > 1Gb */
-		if (capacity >= 0x200000) {
+		if ((ulong)capacity >= 0x200000) {
 			heads = 255;
 			sectors = 63;
-			cylinders = (unsigned long)capacity / (heads * sectors);
+			cylinders = (ulong)capacity / (heads * sectors);
 		}
 
 		/* return result */
@@ -4107,991 +3881,1505 @@
 	return 0;
 }
 
-/*
- * Function : static int mega_partsize(Disk * disk, struct block_device *bdev, int *geom)
+/**
+ * megaraid_reboot_notify()
+ * @this - unused
+ * @code - shutdown code
+ * @unused - unused
  *
- * Purpose : to determine the BIOS mapping used to create the partition
- *			table, storing the results (cyls, hds, and secs) in geom
- *
- * Note:	Code is picked from scsicam.h
- *
- * Returns : -1 on failure, 0 on success.
+ * This routine will be called when the use has done a forced shutdown on the
+ * system. Flush the Adapter and disks cache.
  */
 static int
-mega_partsize(struct block_device *bdev, sector_t capacity, int *geom)
+megaraid_reboot_notify (struct notifier_block *this, unsigned long code,
+		void *unused)
 {
-	struct partition *p, *largest = NULL;
-	int i, largest_cyl;
-	int heads, cyls, sectors;
-	unsigned char *buf;
+	adapter_t *adapter;
+	struct Scsi_Host *host;
+	u8 raw_mbox[16];
+	mbox_t *mbox;
+	int i,j;
 
-	if (!(buf = scsi_bios_ptable(bdev)))
-		return -1;
+	/*
+	 * Flush the controller's cache irrespective of the codes coming down.
+	 * SYS_DOWN, SYS_HALT, SYS_RESTART, SYS_POWER_OFF
+	 */
+	for( i = 0; i < hba_count; i++ ) {
+		printk(KERN_INFO "megaraid: flushing adapter %d..", i);
+		host = hba_soft_state[i]->host;
+
+		adapter = (adapter_t *)host->hostdata;
+		mbox = (mbox_t *)raw_mbox;
+
+		/* Flush adapter cache */
+		memset(mbox, 0, 16);
+		raw_mbox[0] = FLUSH_ADAPTER;
 
-	if( *(unsigned short *)(buf + 64) == 0xAA55 ) {
+		irq_disable(adapter);
+		free_irq(adapter->host->irq, adapter);
 
-		for( largest_cyl = -1, p = (struct partition *)buf,
-				i = 0; i < 4; ++i, ++p) {
+		/*
+		 * Issue a blocking (interrupts disabled) command to
+		 * the card
+		 */
+		issue_scb_block(adapter, raw_mbox);
 
-			if (!p->sys_ind) continue;
+		/* Flush disks cache */
+		memset(mbox, 0, 16);
+		raw_mbox[0] = FLUSH_SYSTEM;
 
-			cyls = p->end_cyl + ((p->end_sector & 0xc0) << 2);
+		issue_scb_block(adapter, raw_mbox);
 
-			if(cyls >= largest_cyl) {
-				largest_cyl = cyls;
-				largest = p;
-			}
-		}
-	}
-
-	if (largest) {
-		heads = largest->end_head + 1;
-		sectors = largest->end_sector & 0x3f;
+		printk("Done.\n");
 
-		if (heads == 0 || sectors == 0) {
-			kfree(buf);
-			return -1;
+		if( atomic_read(&adapter->pend_cmds) > 0 ) {
+			printk(KERN_WARNING "megaraid: pending commands!!\n");
 		}
+	}
 
-		cyls = (unsigned long)capacity/(heads * sectors);
-
-		geom[0] = heads;
-		geom[1] = sectors;
-		geom[2] = cyls;
-
-		kfree(buf);
-		return 0;
+	/*
+	 * Have a delibrate delay to make sure all the caches are
+	 * actually flushed.
+	 */
+	printk("megaraid: cache flush delay: ");
+	for( j = 10; j >= 0; j-- ) {
+		printk("[%d] ", j);
+		mdelay(1000);
 	}
+	printk("\n");
 
-	kfree(buf);
-	return -1;
+	return NOTIFY_DONE;
 }
 
-
-/*
- * This routine will be called when the use has done a forced shutdown on the
- * system. Flush the Adapter cache, that's the most we can do.
+/**
+ * mega_init_scb()
+ * @adapter - pointer to our soft state
+ *
+ * Allocate memory for the various pointers in the scb structures:
+ * scatter-gather list pointer, passthru and extended passthru structure
+ * pointers.
  */
-static int megaraid_reboot_notify (struct notifier_block *this, unsigned long code,
-			void *unused)
+static int
+mega_init_scb(adapter_t *adapter)
 {
-	struct Scsi_Host *pSHost;
-	mega_host_config *megaCfg;
-	mega_mailbox *mbox;
-	u_char mboxData[16];
-	int i;
+	scb_t	*scb;
+	int	i;
 
-	if (code == SYS_DOWN || code == SYS_HALT) {
-		for (i = 0; i < numCtlrs; i++) {
-			pSHost = megaCtlrs[i]->host;
-
-			megaCfg = (mega_host_config *) pSHost->hostdata;
-			mbox = (mega_mailbox *) mboxData;
-
-			/* Flush cache to disk */
-			memset (mbox, 0, 16);
-			mboxData[0] = 0xA;
+	for( i = 0; i < adapter->max_cmds; i++ ) {
 
-			/*
-			 * Free irq, otherwise extra interrupt is generated
-			 */
-			free_irq (megaCfg->host->irq, megaCfg);
+		scb = &adapter->scb_list[i];
 
-			/*
-			   * Issue a blocking (interrupts disabled) command to
-			   * the card
-			 */
-			megaIssueCmd (megaCfg, mboxData, NULL, 0);
-		}
+		scb->sgl64 = NULL;
+		scb->sgl = NULL;
+		scb->pthru = NULL;
+		scb->epthru = NULL;
 	}
-	return NOTIFY_DONE;
-}
 
-static int mega_init_scb (mega_host_config * megacfg)
-{
-	int idx;
+	for( i = 0; i < adapter->max_cmds; i++ ) {
 
-#if DEBUG
-	if (megacfg->max_cmds >= MAX_COMMANDS) {
-		printk ("megaraid:ctlr max cmds = %x : MAX_CMDS = %x",
-			megacfg->max_cmds, MAX_COMMANDS);
-	}
-#endif
+		scb = &adapter->scb_list[i];
 
-	for (idx = megacfg->max_cmds - 1; idx >= 0; idx--) {
+		scb->idx = i;
 
-		megacfg->scbList[idx].idx = idx;
+		scb->sgl64 = pci_alloc_consistent(adapter->dev,
+				sizeof(mega_sgl64) * adapter->sglen,
+				&scb->sgl_dma_addr);
 
-		/*
-		 * ISR will make this flag zero to indicate the command has been
-		 * completed. This is only for user ioctl calls. Rest of the driver
-		 * and the mid-layer operations are not connected with this flag.
-		 */
+		scb->sgl = (mega_sglist *)scb->sgl64;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		megacfg->scbList[idx].sgList =
-		    pci_alloc_consistent (megacfg->dev,
-					  sizeof (mega_64sglist) * MAX_SGLIST,
-					  &(megacfg->scbList[idx].
-					    dma_sghandle64));
+		if( !scb->sgl ) {
+			printk(KERN_WARNING "RAID: Can't allocate sglist.\n");
+			mega_free_sgl(adapter);
+			return -1;
+		}
 
-		megacfg->scbList[idx].sg64List =
-		    (mega_64sglist *) megacfg->scbList[idx].sgList;
-#else
-		megacfg->scbList[idx].sgList = kmalloc (sizeof (mega_sglist) * MAX_SGLIST, GFP_ATOMIC | GFP_DMA);
-#endif
+		scb->pthru = pci_alloc_consistent(adapter->dev,
+				sizeof(mega_passthru),
+				&scb->pthru_dma_addr);
+
+		if( !scb->pthru ) {
+			printk(KERN_WARNING "RAID: Can't allocate passthru.\n");
+			mega_free_sgl(adapter);
+			return -1;
+		}
 
-		if (megacfg->scbList[idx].sgList == NULL) {
-			printk (KERN_WARNING
-				"Can't allocate sglist for id %d\n", idx);
-			mega_freeSgList (megacfg);
+		scb->epthru = pci_alloc_consistent(adapter->dev,
+				sizeof(mega_ext_passthru),
+				&scb->epthru_dma_addr);
+
+		if( !scb->epthru ) {
+			printk(KERN_WARNING
+				"Can't allocate extended passthru.\n");
+			mega_free_sgl(adapter);
 			return -1;
 		}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		megacfg->scbList[idx].pthru = pci_alloc_consistent (megacfg->dev,
-					  sizeof (mega_passthru),
-					  &(megacfg->scbList[idx].
-					    dma_passthruhandle64));
-
-		if (megacfg->scbList[idx].pthru == NULL) {
-			printk (KERN_WARNING
-				"Can't allocate passthru for id %d\n", idx);
-		}
-
-		megacfg->scbList[idx].epthru =
-			pci_alloc_consistent(
-				megacfg->dev, sizeof(mega_ext_passthru),
-				&(megacfg->scbList[idx].dma_ext_passthruhandle64)
-			);
-
-		if (megacfg->scbList[idx].epthru == NULL) {
-			printk (KERN_WARNING
-				"Can't allocate extended passthru for id %d\n", idx);
-		}
-		/* 
-		 * Allocate a 256 Byte Bounce Buffer for handling INQ/RD_CAPA 
-		 */
-		megacfg->scbList[idx].bounce_buffer = pci_alloc_consistent (megacfg->dev,
-					  256,
-					  &(megacfg->scbList[idx].
-					    dma_bounce_buffer));
-
-		if (!megacfg->scbList[idx].bounce_buffer)
-			printk
-			    ("megaraid: allocation for bounce buffer failed\n");
 
-		megacfg->scbList[idx].dma_type = M_RD_DMA_TYPE_NONE;
-#endif
 
-		if (idx < MAX_COMMANDS) {
-			/*
-			 * Link to free list
-			 * lock not required since we are loading the driver, so no
-			 * commands possible right now.
-			 */
-			enq_scb_freelist (megacfg, &megacfg->scbList[idx],
-					  NO_LOCK, INTR_ENB);
+		scb->dma_type = MEGA_DMA_TYPE_NONE;
 
-		}
+		/*
+		 * Link to free list
+		 * lock not required since we are loading the driver, so no
+		 * commands possible right now.
+		 */
+		scb->state = SCB_FREE;
+		scb->cmd = NULL;
+		list_add(&scb->list, &adapter->free_list);
 	}
 
 	return 0;
 }
 
-/*
- * Enqueues a SCB
+
+/**
+ * megadev_open()
+ * @inode - unused
+ * @filep - unused
+ *
+ * Routines for the character/ioctl interface to the driver. Find out if this
+ * is a valid open. If yes, increment the module use count so that it cannot
+ * be unloaded.
  */
-static void enq_scb_freelist (mega_host_config * megacfg, mega_scb * scb, int lock,
-		  int intr)
+static int
+megadev_open (struct inode *inode, struct file *filep)
 {
+	/*
+	 * Only allow superuser to access private ioctl interface
+	 */
+	if( !capable(CAP_SYS_ADMIN) ) return -EACCES;
 
-	if (lock == INTERNAL_LOCK || intr == INTR_DIS) {
-		if (intr == INTR_DIS)
-			spin_lock_irq (&megacfg->lock_free);
-		else
-			spin_lock (&megacfg->lock_free);
-	}
+	return 0;
+}
 
-	scb->state = SCB_FREE;
-	scb->SCpnt = NULL;
 
-	if (megacfg->qFreeH == (mega_scb *) NULL) {
-		megacfg->qFreeH = megacfg->qFreeT = scb;
-	} else {
-		megacfg->qFreeT->next = scb;
-		megacfg->qFreeT = scb;
-	}
+/**
+ * megadev_ioctl()
+ * @inode - Our device inode
+ * @filep - unused
+ * @cmd - ioctl command
+ * @arg - user buffer
+ *
+ * ioctl entry point for our private ioctl interface. We move the data in from
+ * the user space, prepare the command (if necessary, convert the old MIMD
+ * ioctl to new ioctl command), and issue a synchronous command to the
+ * controller.
+ */
+static int
+megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
+		unsigned long arg)
+{
+	adapter_t	*adapter;
+	nitioctl_t	uioc;
+	int		adapno;
+	int		rval;
+	mega_passthru	*upthru;	/* user address for passthru */
+	mega_passthru	*pthru;		/* copy user passthru here */
+	dma_addr_t	pthru_dma_hndl;
+	void		*data = NULL;	/* data to be transferred */
+	dma_addr_t	data_dma_hndl;	/* dma handle for data xfer area */
+	megacmd_t	mc;
+	megastat_t	*ustats;
+	int		num_ldrv;
+	u32		uxferaddr = 0;
+	struct pci_dev	*pdev;
 
-	megacfg->qFreeT->next = NULL;
-	megacfg->qFcnt++;
+	ustats = NULL; /* avoid compilation warnings */
+	num_ldrv = 0;
 
-	if (lock == INTERNAL_LOCK || intr == INTR_DIS) {
-		if (intr == INTR_DIS)
-			spin_unlock_irq (&megacfg->lock_free);
-		else
-			spin_unlock (&megacfg->lock_free);
+	/*
+	 * Make sure only USCSICMD are issued through this interface.
+	 * MIMD application would still fire different command.
+	 */
+	if( (_IOC_TYPE(cmd) != MEGAIOC_MAGIC) && (cmd != USCSICMD) ) {
+		return -EINVAL;
 	}
-}
-
-static int megadev_ioctl_entry (struct inode *inode, struct file *filep,
-		     unsigned int cmd, unsigned long arg)
-{
-	int ret = -1;
 
 	/*
-	 * We do not allow parallel ioctls to the driver as of now.
+	 * Check and convert a possible MIMD command to NIT command.
+	 * mega_m_to_n() copies the data from the user space, so we do not
+	 * have to do it here.
+	 * NOTE: We will need some user address to copyout the data, therefore
+	 * the inteface layer will also provide us with the required user
+	 * addresses.
 	 */
-	down (&mimd_entry_mtx);
-	ret = megadev_ioctl (inode, filep, cmd, arg);
-	up (&mimd_entry_mtx);
+	memset(&uioc, 0, sizeof(nitioctl_t));
+	if( (rval = mega_m_to_n( (void *)arg, &uioc)) != 0 )
+		return rval;
 
-	return ret;
 
-}
+	switch( uioc.opcode ) {
 
-static int megadev_ioctl (struct inode *inode, struct file *filep,
-	       unsigned int cmd, unsigned long arg)
-{
-	int adapno;
-	u32 inlen;
-	struct uioctl_t ioc;
-	char *kvaddr = NULL;
-	int nadap = numCtlrs;
-	u8 opcode;
-	u32 outlen;
-	int ret;
-	u8 subopcode;
-	Scsi_Cmnd *scsicmd;
-	struct Scsi_Host *shpnt;
-	char *uaddr;
-	struct uioctl_t *uioc;
-	dma_addr_t	dma_addr;
-	u32		length;
-	mega_host_config *megacfg = NULL;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)	/* 0x020400 */
-	struct pci_dev pdev;
-	struct pci_dev *pdevp = &pdev;
-#else
-	char *pdevp = NULL;
-#endif
-	IO_LOCK_T;
+	case GET_DRIVER_VER:
+		if( put_user(driver_ver, (u32 *)uioc.uioc_uaddr) )
+			return (-EFAULT);
 
-	if (!inode)
-		return -EINVAL;
+		break;
 
-	if (_IOC_TYPE (cmd) != MEGAIOC_MAGIC)
-		return (-EINVAL);
+	case GET_N_ADAP:
+		if( put_user(hba_count, (u32 *)uioc.uioc_uaddr) )
+			return (-EFAULT);
 
-	/*
-	 * Get the user ioctl structure
-	 */
-	ret = verify_area (VERIFY_WRITE, (char *) arg, sizeof (struct uioctl_t));
+		/*
+		 * Shucks. MIMD interface returns a positive value for number
+		 * of adapters. TODO: Change it to return 0 when there is no
+		 * applicatio using mimd interface.
+		 */
+		return hba_count;
 
-	if (ret)
-		return ret;
+	case GET_ADAP_INFO:
 
-	if(copy_from_user (&ioc, (char *) arg, sizeof (struct uioctl_t)))
-		return -EFAULT;
+		/*
+		 * Which adapter
+		 */
+		if( (adapno = GETADAP(uioc.adapno)) >= hba_count )
+			return (-ENODEV);
 
-	/*
-	 * The first call the applications should make is to find out the
-	 * number of controllers in the system. The next logical call should
-	 * be for getting the list of controllers in the system as detected
-	 * by the driver.
-	 */
+		if( copy_to_user(uioc.uioc_uaddr, mcontroller+adapno,
+				sizeof(struct mcontroller)) )
+			return (-EFAULT);
+		break;
 
-	/*
-	 * Get the opcode and subopcode for the commands
-	 */
-	opcode = ioc.ui.fcs.opcode;
-	subopcode = ioc.ui.fcs.subopcode;
+#if MEGA_HAVE_STATS
 
-	switch (opcode) {
-	case M_RD_DRIVER_IOCTL_INTERFACE:
-		switch (subopcode) {
-		case MEGAIOC_QDRVRVER:	/* Query driver version */
-			put_user (driver_ver, (u32 *) ioc.data);
-			return 0;
+	case GET_STATS:
+		/*
+		 * Which adapter
+		 */
+		if( (adapno = GETADAP(uioc.adapno)) >= hba_count )
+			return (-ENODEV);
 
-		case MEGAIOC_QNADAP:	/* Get # of adapters */
-			put_user (nadap, (int *) ioc.data);
-			return nadap;
+		adapter = hba_soft_state[adapno];
 
-		case MEGAIOC_QADAPINFO:	/* Get adapter information */
-			/*
-			 * which adapter?
-			 */
-			adapno = ioc.ui.fcs.adapno;
+		ustats = (megastat_t *)uioc.uioc_uaddr;
 
-			/*
-			 * The adapter numbers do not start with 0, at least in
-			 * the user space. This is just to make sure, 0 is not the
-			 * default value which will refer to adapter 1. So the
-			 * user needs to make use of macros MKADAP() and GETADAP()
-			 * (See megaraid.h) while making ioctl() call.
-			 */
-			adapno = GETADAP (adapno);
+		if( copy_from_user(&num_ldrv, &ustats->num_ldrv, sizeof(int)) )
+			return (-EFAULT);
 
-			if (adapno >= numCtlrs)
-				return (-ENODEV);
+		/*
+		 * Check for the validity of the logical drive number
+		 */
+		if( num_ldrv >= MAX_LOGICAL_DRIVES_40LD ) return -EINVAL;
 
-			ret = verify_area (VERIFY_WRITE,
-					   ioc.data,
-					   sizeof (struct mcontroller));
-			if (ret)
-				return ret;
+		if( copy_to_user(ustats->nreads, adapter->nreads,
+					num_ldrv*sizeof(u32)) )
+			return -EFAULT;
+
+		if( copy_to_user(ustats->nreadblocks, adapter->nreadblocks,
+					num_ldrv*sizeof(u32)) )
+			return -EFAULT;
+
+		if( copy_to_user(ustats->nwrites, adapter->nwrites,
+					num_ldrv*sizeof(u32)) )
+			return -EFAULT;
+
+		if( copy_to_user(ustats->nwriteblocks, adapter->nwriteblocks,
+					num_ldrv*sizeof(u32)) )
+			return -EFAULT;
+
+		if( copy_to_user(ustats->rd_errors, adapter->rd_errors,
+					num_ldrv*sizeof(u32)) )
+			return -EFAULT;
+
+		if( copy_to_user(ustats->wr_errors, adapter->wr_errors,
+					num_ldrv*sizeof(u32)) )
+			return -EFAULT;
 
-			/*
-			 * Copy struct mcontroller to user area
-			 */
-			copy_to_user (ioc.data,
-				      mcontroller + adapno,
-				      sizeof (struct mcontroller));
-			return 0;
+		return 0;
 
-		default:
-			return (-EINVAL);
+#endif
+	case MBOX_CMD:
 
-		}		/* inner switch */
-		break;
+		/*
+		 * Which adapter
+		 */
+		if( (adapno = GETADAP(uioc.adapno)) >= hba_count )
+			return (-ENODEV);
 
-	case M_RD_IOCTL_CMD_NEW:
+		adapter = hba_soft_state[adapno];
 
 		/*
-		 * Deletion of logical drives is only handled in 0x80 commands
+		 * Deletion of logical drive is a special case. The adapter
+		 * should be quiescent before this command is issued.
 		 */
-		if( ioc.mbox[0] == FC_DEL_LOGDRV && ioc.mbox[2] == OP_DEL_LOGDRV ) {
-			return -EINVAL;
-		}
+		if( uioc.uioc_rmbox[0] == FC_DEL_LOGDRV &&
+				uioc.uioc_rmbox[2] == OP_DEL_LOGDRV ) {
 
-		/* which adapter?  */
-		adapno = ioc.ui.fcs.adapno;
+			/*
+			 * Do we support this feature
+			 */
+			if( !adapter->support_random_del ) {
+				printk(KERN_WARNING "megaraid: logdrv ");
+				printk("delete on non-supporting F/W.\n");
 
-		/* See comment above: MEGAIOC_QADAPINFO */
-		adapno = GETADAP(adapno);
+				return (-EINVAL);
+			}
 
-		if (adapno >= numCtlrs)
-			return(-ENODEV);
+			rval = mega_del_logdrv( adapter, uioc.uioc_rmbox[3] );
 
-		length = ioc.ui.fcs.length;
+			if( rval == 0 ) {
+				memset(&mc, 0, sizeof(megacmd_t));
 
-		/* Check for zero length buffer or very large buffers */
-		if( !length || length > 32*1024 )
-			return -EINVAL;
+				mc.status = rval;
 
-		/* save the user address */
-		uaddr = ioc.ui.fcs.buffer;
+				rval = mega_n_to_m((void *)arg, &mc);
+			}
 
+			return rval;
+		}
 		/*
-		 * For M_RD_IOCTL_CMD_NEW commands, the fields outlen and inlen of
-		 * uioctl_t structure are treated as flags. If outlen is 1, the
-		 * data is transferred from the device and if inlen is 1, the data
-		 * is transferred to the device.
+		 * This interface only support the regular passthru commands.
+		 * Reject extended passthru and 64-bit passthru
 		 */
-		outlen = ioc.outlen;
-		inlen = ioc.inlen;
+		if( uioc.uioc_rmbox[0] == MEGA_MBOXCMD_PASSTHRU64 ||
+			uioc.uioc_rmbox[0] == MEGA_MBOXCMD_EXTPTHRU ) {
 
-		if(outlen) {
-			ret = verify_area(VERIFY_WRITE, (char *)ioc.ui.fcs.buffer, length);
-			if (ret) return ret;
-		}
-		if(inlen) {
-			ret = verify_area(VERIFY_READ, (char *) ioc.ui.fcs.buffer, length);
-			if (ret) return ret;
+			printk(KERN_WARNING "megaraid: rejected passthru.\n");
+
+			return (-EINVAL);
 		}
 
 		/*
-		 * Find this host
+		 * For all internal commands, the buffer must be allocated in
+		 * <4GB address range
 		 */
-		shpnt = megaCtlrs[adapno]->host;
-		if(shpnt == NULL)  return -ENODEV;
+		if( make_local_pdev(adapter, &pdev) != 0 )
+			return -EIO;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		scsicmd = (Scsi_Cmnd *)kmalloc(sizeof(Scsi_Cmnd), GFP_KERNEL|GFP_DMA);
-#else
-		scsicmd = (Scsi_Cmnd *)scsi_init_malloc(sizeof(Scsi_Cmnd),
-							  GFP_ATOMIC | GFP_DMA);
-#endif
-		if(scsicmd == NULL) return -ENOMEM;
+		/* Is it a passthru command or a DCMD */
+		if( uioc.uioc_rmbox[0] == MEGA_MBOXCMD_PASSTHRU ) {
+			/* Passthru commands */
+
+			pthru = pci_alloc_consistent(pdev,
+					sizeof(mega_passthru),
+					&pthru_dma_hndl);
+
+			if( pthru == NULL ) {
+				free_local_pdev(pdev);
+				return (-ENOMEM);
+			}
 
-		memset(scsicmd, 0, sizeof(Scsi_Cmnd));
-		scsicmd->device->host = shpnt;
+			/*
+			 * The user passthru structure
+			 */
+			upthru = (mega_passthru *)MBOX(uioc)->xferaddr;
 
-		if( outlen || inlen ) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-			pdevp = &pdev;
-			memcpy(pdevp, megacfg->dev, sizeof(struct pci_dev));
-			pdevp->dma_mask = 0xffffffff;
-#else
-			pdevp = NULL;
-#endif
-			kvaddr = dma_alloc_consistent(pdevp, length, &dma_addr);
+			/*
+			 * Copy in the user passthru here.
+			 */
+			if( copy_from_user(pthru, (char *)upthru,
+						sizeof(mega_passthru)) ) {
 
-			if( kvaddr == NULL ) {
-				printk(KERN_WARNING "megaraid:allocation failed\n");
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)	/*0x20400 */
-				kfree(scsicmd);
-#else
-				scsi_init_free((char *)scsicmd, sizeof(Scsi_Cmnd));
-#endif
-				return -ENOMEM;
-			}
+				pci_free_consistent(pdev,
+						sizeof(mega_passthru), pthru,
+						pthru_dma_hndl);
 
-			ioc.ui.fcs.buffer = kvaddr;
+				free_local_pdev(pdev);
 
-			if (inlen) {
-				/* copyin the user data */
-				copy_from_user(kvaddr, (char *)uaddr, length );
+				return (-EFAULT);
 			}
-		}
 
-		scsicmd->cmnd[0] = MEGADEVIOC;
-		scsicmd->request_buffer = (void *)&ioc;
+			/*
+			 * Is there a data transfer
+			 */
+			if( pthru->dataxferlen ) {
+				data = pci_alloc_consistent(pdev,
+						pthru->dataxferlen,
+						&data_dma_hndl);
+
+				if( data == NULL ) {
+					pci_free_consistent(pdev,
+							sizeof(mega_passthru),
+							pthru,
+							pthru_dma_hndl);
 
-		init_MUTEX_LOCKED(&mimd_ioctl_sem);
+					free_local_pdev(pdev);
 
-		IO_LOCK(shpnt);
-		megaraid_queue(scsicmd, megadev_ioctl_done);
+					return (-ENOMEM);
+				}
 
-		IO_UNLOCK(shpnt);
+				/*
+				 * Save the user address and point the kernel
+				 * address at just allocated memory
+				 */
+				uxferaddr = pthru->dataxferaddr;
+				pthru->dataxferaddr = data_dma_hndl;
+			}
 
-		down(&mimd_ioctl_sem);
 
-		if( !scsicmd->result && outlen ) {
-			copy_to_user(uaddr, kvaddr, length);
-		}
+			/*
+			 * Is data coming down-stream
+			 */
+			if( pthru->dataxferlen && (uioc.flags & UIOC_WR) ) {
+				/*
+				 * Get the user data
+				 */
+				if( copy_from_user(data, (char *)uxferaddr,
+							pthru->dataxferlen) ) {
+					rval = (-EFAULT);
+					goto freemem_and_return;
+				}
+			}
 
-		/*
-		 * copyout the result
-		 */
-		uioc = (struct uioctl_t *)arg;
+			memset(&mc, 0, sizeof(megacmd_t));
 
-		if( ioc.mbox[0] == MEGA_MBOXCMD_PASSTHRU ) {
-			put_user( scsicmd->result, &uioc->pthru.scsistatus );
-		} else {
-			put_user(1, &uioc->mbox[16]);	/* numstatus */
-			/* status */
-			put_user (scsicmd->result, &uioc->mbox[17]);
-		}
+			mc.cmd = MEGA_MBOXCMD_PASSTHRU;
+			mc.xferaddr = (u32)pthru_dma_hndl;
 
-		if (kvaddr) {
-			dma_free_consistent(pdevp, length, kvaddr, dma_addr);
-		}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)	/*0x20400 */
-		kfree (scsicmd);
-#else
-		scsi_init_free((char *)scsicmd, sizeof(Scsi_Cmnd));
-#endif
+			/*
+			 * Issue the command
+			 */
+			mega_internal_command(adapter, LOCK_INT, &mc, pthru);
 
-		/* restore the user address */
-		ioc.ui.fcs.buffer = uaddr;
+			rval = mega_n_to_m((void *)arg, &mc);
 
-		return ret;
+			if( rval ) goto freemem_and_return;
 
-	case M_RD_IOCTL_CMD:
-		/* which adapter?  */
-		adapno = ioc.ui.fcs.adapno;
 
-		/* See comment above: MEGAIOC_QADAPINFO */
-		adapno = GETADAP (adapno);
+			/*
+			 * Is data going up-stream
+			 */
+			if( pthru->dataxferlen && (uioc.flags & UIOC_RD) ) {
+				if( copy_to_user((char *)uxferaddr, data,
+							pthru->dataxferlen) ) {
+					rval = (-EFAULT);
+				}
+			}
 
-		if (adapno >= numCtlrs)
-			return (-ENODEV);
+			/*
+			 * Send the request sense data also, irrespective of
+			 * whether the user has asked for it or not.
+			 */
+			copy_to_user(upthru->reqsensearea,
+					pthru->reqsensearea, 14);
 
-		/* save the user address */
-		uaddr = ioc.data;
-		outlen = ioc.outlen;
-		inlen = ioc.inlen;
+freemem_and_return:
+			if( pthru->dataxferlen ) {
+				pci_free_consistent(pdev,
+						pthru->dataxferlen, data,
+						data_dma_hndl);
+			}
 
-		if ((outlen >= IOCTL_MAX_DATALEN) || (inlen >= IOCTL_MAX_DATALEN))
-			return (-EINVAL);
+			pci_free_consistent(pdev, sizeof(mega_passthru),
+					pthru, pthru_dma_hndl);
 
-		if (outlen) {
-			ret = verify_area (VERIFY_WRITE, ioc.data, outlen);
-			if (ret) return ret;
-		}
-		if (inlen) {
-			ret = verify_area (VERIFY_READ, ioc.data, inlen);
-			if (ret) return ret;
-		}
+			free_local_pdev(pdev);
 
-		/*
-		 * Find this host
-		 */
-		shpnt = megaCtlrs[adapno]->host;
-		if(shpnt == NULL)  return -ENODEV;
+			return rval;
+		}
+		else {
+			/* DCMD commands */
 
-		/*
-		 * ioctls for deleting logical drives is a special case, so check
-		 * for it first
-		 */
-		if( ioc.mbox[0] == FC_DEL_LOGDRV && ioc.mbox[2] == OP_DEL_LOGDRV ) {
+			/*
+			 * Is there a data transfer
+			 */
+			if( uioc.xferlen ) {
+				data = pci_alloc_consistent(pdev,
+						uioc.xferlen, &data_dma_hndl);
+
+				if( data == NULL ) {
+					free_local_pdev(pdev);
+					return (-ENOMEM);
+				}
 
-			if( !megacfg->support_random_del ) {
-				printk("megaraid: logdrv delete on non supporting f/w.\n");
-				return -EINVAL;
+				uxferaddr = MBOX(uioc)->xferaddr;
 			}
 
-			uioc = (struct uioctl_t *)arg;
+			/*
+			 * Is data coming down-stream
+			 */
+			if( uioc.xferlen && (uioc.flags & UIOC_WR) ) {
+				/*
+				 * Get the user data
+				 */
+				if( copy_from_user(data, (char *)uxferaddr,
+							uioc.xferlen) ) {
 
-			ret = mega_del_logdrv(megacfg, ioc.mbox[3]);
+					pci_free_consistent(pdev,
+							uioc.xferlen,
+							data, data_dma_hndl);
 
-			put_user(1, &uioc->mbox[16]);	/* numstatus */
-			put_user(ret, &uioc->mbox[17]);	/* status */
+					free_local_pdev(pdev);
 
-			/* if deletion failed, let the user know by failing ioctl */
-			return ret;
-		}
+					return (-EFAULT);
+				}
+			}
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		scsicmd = (Scsi_Cmnd *)kmalloc(sizeof(Scsi_Cmnd), GFP_KERNEL|GFP_DMA);
-#else
-		scsicmd = (Scsi_Cmnd *)scsi_init_malloc(sizeof(Scsi_Cmnd),
-							  GFP_ATOMIC | GFP_DMA);
-#endif
-		if(scsicmd == NULL) return -ENOMEM;
+			memcpy(&mc, MBOX(uioc), sizeof(megacmd_t));
 
-		memset(scsicmd, 0, sizeof(Scsi_Cmnd));
-		scsicmd->device->host = shpnt;
+			mc.xferaddr = (u32)data_dma_hndl;
 
-		if (outlen || inlen) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-			pdevp = &pdev;
-			memcpy(pdevp, megacfg->dev, sizeof(struct pci_dev));
-			pdevp->dma_mask = 0xffffffff;
-#else
-			pdevp = NULL;
-#endif
 			/*
-			 * Allocate a page of kernel space.
+			 * Issue the command
 			 */
-			kvaddr = dma_alloc_consistent(pdevp, PAGE_SIZE, &dma_addr);
+			mega_internal_command(adapter, LOCK_INT, &mc, NULL);
 
-			if( kvaddr == NULL ) {
-				printk (KERN_WARNING "megaraid:allocation failed\n");
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)	/*0x20400 */
-				kfree(scsicmd);
-#else
-				scsi_init_free((char *)scsicmd, sizeof(Scsi_Cmnd));
-#endif
-				return -ENOMEM;
+			rval = mega_n_to_m((void *)arg, &mc);
+
+			if( rval ) {
+				if( uioc.xferlen ) {
+					pci_free_consistent(pdev,
+							uioc.xferlen, data,
+							data_dma_hndl);
+				}
+
+				free_local_pdev(pdev);
+
+				return rval;
 			}
 
-			ioc.data = kvaddr;
+			/*
+			 * Is data going up-stream
+			 */
+			if( uioc.xferlen && (uioc.flags & UIOC_RD) ) {
+				if( copy_to_user((char *)uxferaddr, data,
+							uioc.xferlen) ) {
 
-			if (inlen) {
-				if (ioc.mbox[0] == MEGA_MBOXCMD_PASSTHRU) {
-					/* copyin the user data */
-					copy_from_user (kvaddr, uaddr, ioc.pthru.dataxferlen);
-				} else {
-					copy_from_user (kvaddr, uaddr, inlen);
+					rval = (-EFAULT);
 				}
 			}
+
+			if( uioc.xferlen ) {
+				pci_free_consistent(pdev,
+						uioc.xferlen, data,
+						data_dma_hndl);
+			}
+
+			free_local_pdev(pdev);
+
+			return rval;
 		}
 
-		scsicmd->cmnd[0] = MEGADEVIOC;
-		scsicmd->request_buffer = (void *) &ioc;
+	default:
+		return (-EINVAL);
+	}
+
+	return 0;
+}
 
-		init_MUTEX_LOCKED (&mimd_ioctl_sem);
+/**
+ * mega_m_to_n()
+ * @arg - user address
+ * @uioc - new ioctl structure
+ *
+ * A thin layer to convert older mimd interface ioctl structure to NIT ioctl
+ * structure
+ *
+ * Converts the older mimd ioctl structure to newer NIT structure
+ */
+static int
+mega_m_to_n(void *arg, nitioctl_t *uioc)
+{
+	struct uioctl_t	uioc_mimd;
+	char	signature[8] = {0};
+	u8	opcode;
+	u8	subopcode;
 
-		IO_LOCK(shpnt);
-		megaraid_queue (scsicmd, megadev_ioctl_done);
 
-		IO_UNLOCK(shpnt);
-		down (&mimd_ioctl_sem);
+	/*
+	 * check is the application conforms to NIT. We do not have to do much
+	 * in that case.
+	 * We exploit the fact that the signature is stored in the very
+	 * begining of the structure.
+	 */
 
-		if (!scsicmd->result && outlen) {
-			if (ioc.mbox[0] == MEGA_MBOXCMD_PASSTHRU) {
-				copy_to_user (uaddr, kvaddr, ioc.pthru.dataxferlen);
-			} else {
-				copy_to_user (uaddr, kvaddr, outlen);
-			}
-		}
+	if( copy_from_user(signature, (char *)arg, 7) )
+		return (-EFAULT);
+
+	if( memcmp(signature, "MEGANIT", 7) == 0 ) {
 
 		/*
-		 * copyout the result
+		 * NOTE NOTE: The nit ioctl is still under flux because of
+		 * change of mailbox definition, in HPE. No applications yet
+		 * use this interface and let's not have applications use this
+		 * interface till the new specifitions are in place.
 		 */
-		uioc = (struct uioctl_t *) arg;
+		return -EINVAL;
+#if 0
+		if( copy_from_user(uioc, (char *)arg, sizeof(nitioctl_t)) )
+			return (-EFAULT);
+		return 0;
+#endif
+	}
 
-		if (ioc.mbox[0] == MEGA_MBOXCMD_PASSTHRU) {
-			put_user (scsicmd->result, &uioc->pthru.scsistatus);
-		} else {
-			put_user (1, &uioc->mbox[16]);	/* numstatus */
-			put_user (scsicmd->result, &uioc->mbox[17]); /* status */
-		}
+	/*
+	 * Else assume we have mimd uioctl_t as arg. Convert to nitioctl_t
+	 *
+	 * Get the user ioctl structure
+	 */
+	if( copy_from_user(&uioc_mimd, (char *)arg, sizeof(struct uioctl_t)) )
+		return (-EFAULT);
+
+
+	/*
+	 * Get the opcode and subopcode for the commands
+	 */
+	opcode = uioc_mimd.ui.fcs.opcode;
+	subopcode = uioc_mimd.ui.fcs.subopcode;
+
+	switch (opcode) {
+	case 0x82:
 
-		if (kvaddr) {
-			dma_free_consistent(pdevp, PAGE_SIZE, kvaddr, dma_addr );
+		switch (subopcode) {
+
+		case MEGAIOC_QDRVRVER:	/* Query driver version */
+			uioc->opcode = GET_DRIVER_VER;
+			uioc->uioc_uaddr = uioc_mimd.data;
+			break;
+
+		case MEGAIOC_QNADAP:	/* Get # of adapters */
+			uioc->opcode = GET_N_ADAP;
+			uioc->uioc_uaddr = uioc_mimd.data;
+			break;
+
+		case MEGAIOC_QADAPINFO:	/* Get adapter information */
+			uioc->opcode = GET_ADAP_INFO;
+			uioc->adapno = uioc_mimd.ui.fcs.adapno;
+			uioc->uioc_uaddr = uioc_mimd.data;
+			break;
+
+		default:
+			return(-EINVAL);
 		}
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		kfree (scsicmd);
-#else
-		scsi_init_free((char *)scsicmd, sizeof(Scsi_Cmnd));
-#endif
+		break;
+
+
+	case 0x81:
+
+		uioc->opcode = MBOX_CMD;
+		uioc->adapno = uioc_mimd.ui.fcs.adapno;
 
-		/* restore user pointer */
-		ioc.data = uaddr;
+		memcpy(uioc->uioc_rmbox, uioc_mimd.mbox, 18);
 
-		return ret;
+		uioc->xferlen = uioc_mimd.ui.fcs.length;
+
+		if( uioc_mimd.outlen ) uioc->flags = UIOC_RD;
+		if( uioc_mimd.inlen ) uioc->flags |= UIOC_WR;
+
+		break;
+
+	case 0x80:
+
+		uioc->opcode = MBOX_CMD;
+		uioc->adapno = uioc_mimd.ui.fcs.adapno;
+
+		memcpy(uioc->uioc_rmbox, uioc_mimd.mbox, 18);
+
+		/*
+		 * Choose the xferlen bigger of input and output data
+		 */
+		uioc->xferlen = uioc_mimd.outlen > uioc_mimd.inlen ?
+			uioc_mimd.outlen : uioc_mimd.inlen;
+
+		if( uioc_mimd.outlen ) uioc->flags = UIOC_RD;
+		if( uioc_mimd.inlen ) uioc->flags |= UIOC_WR;
+
+		break;
 
 	default:
 		return (-EINVAL);
 
-	}/* Outer switch */
+	}
 
 	return 0;
 }
 
-static void
-megadev_ioctl_done(Scsi_Cmnd *sc)
+/*
+ * mega_n_to_m()
+ * @arg - user address
+ * @mc - mailbox command
+ *
+ * Updates the status information to the application, depending on application
+ * conforms to older mimd ioctl interface or newer NIT ioctl interface
+ */
+static int
+mega_n_to_m(void *arg, megacmd_t *mc)
 {
-	up (&mimd_ioctl_sem);
-}
+	nitioctl_t	*uiocp;
+	megacmd_t	*umc;
+	mega_passthru	*upthru;
+	struct uioctl_t	*uioc_mimd;
+	char	signature[8] = {0};
 
-static mega_scb *
-megadev_doioctl (mega_host_config * megacfg, Scsi_Cmnd * sc)
-{
-	u8 cmd;
-	struct uioctl_t *ioc = NULL;
-	mega_mailbox *mbox = NULL;
-	mega_ioctl_mbox *mboxioc = NULL;
-	struct mbox_passthru *mboxpthru = NULL;
-	mega_scb *scb = NULL;
-	mega_passthru *pthru = NULL;
+	/*
+	 * check is the application conforms to NIT.
+	 */
+	if( copy_from_user(signature, (char *)arg, 7) )
+		return -EFAULT;
 
-	if ((scb = mega_allocateSCB (megacfg, sc)) == NULL) {
-		sc->result = (DID_ERROR << 16);
-		callDone (sc);
-		return NULL;
-	}
+	if( memcmp(signature, "MEGANIT", 7) == 0 ) {
 
-	ioc = (struct uioctl_t *) sc->request_buffer;
+		uiocp = (nitioctl_t *)arg;
 
-	memcpy (scb->mboxData, ioc->mbox, sizeof (scb->mboxData));
+		if( put_user(mc->status, (u8 *)&MBOX_P(uiocp)->status) )
+			return (-EFAULT);
 
-	/* The generic mailbox */
-	mbox = (mega_mailbox *) ioc->mbox;
+		if( mc->cmd == MEGA_MBOXCMD_PASSTHRU ) {
 
-	/*
-	 * Get the user command
-	 */
-	cmd = ioc->mbox[0];
+			umc = MBOX_P(uiocp);
 
-	switch (cmd) {
-	case MEGA_MBOXCMD_PASSTHRU:
-		/*
-		   * prepare the SCB with information from the user ioctl structure
-		 */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		pthru = scb->pthru;
-#else
-		pthru = &scb->pthru;
-#endif
-		memcpy (pthru, &ioc->pthru, sizeof (mega_passthru));
-		mboxpthru = (struct mbox_passthru *) scb->mboxData;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		if (megacfg->flag & BOARD_64BIT) {
-			/* This is just a sample with one element 
-			   * This if executes onlu on 2.4 kernels
-			 */
-			mboxpthru->dataxferaddr = scb->dma_passthruhandle64;
-			scb->sg64List[0].address =
-			    pci_map_single (megacfg->dev,
-					    ioc->data,
-					    4096, PCI_DMA_BIDIRECTIONAL);
-			scb->sg64List[0].length = 4096;	// TODO: Check this
-			pthru->dataxferaddr = scb->dma_sghandle64;
-			pthru->numsgelements = 1;
-			mboxpthru->cmd = 0xC3;
-		} else {
-			mboxpthru->dataxferaddr = scb->dma_passthruhandle64;
-			pthru->dataxferaddr =
-			    pci_map_single (megacfg->dev,
-					    ioc->data,
-					    4096, PCI_DMA_BIDIRECTIONAL);
-			pthru->numsgelements = 0;
-		}
+			upthru = (mega_passthru *)umc->xferaddr;
 
-#else
-		{
-			mboxpthru->dataxferaddr = virt_to_bus (&scb->pthru);
-			pthru->dataxferaddr = virt_to_bus (ioc->data);
-			pthru->numsgelements = 0;
+			if( put_user(mc->status, (u8 *)&upthru->scsistatus) )
+				return (-EFAULT);
 		}
-#endif
+	}
+	else {
+		uioc_mimd = (struct uioctl_t *)arg;
 
-		pthru->reqsenselen = 14;
-		break;
+		if( put_user(mc->status, (u8 *)&uioc_mimd->mbox[17]) )
+			return (-EFAULT);
 
-	default:		/* Normal command */
-		mboxioc = (mega_ioctl_mbox *) scb->mboxData;
+		if( mc->cmd == MEGA_MBOXCMD_PASSTHRU ) {
 
-		if (ioc->ui.fcs.opcode == M_RD_IOCTL_CMD_NEW) {
-			scb->buff_ptr = ioc->ui.fcs.buffer;
-			scb->iDataSize = ioc->ui.fcs.length;
-		} else {
-			scb->buff_ptr = ioc->data;
-			scb->iDataSize = 4096;	// TODO:check it
-		}
+			umc = (megacmd_t *)uioc_mimd->mbox;
 
-		set_mbox_xfer_addr (megacfg, scb, mboxioc, FROMTO_DEVICE);
-		mboxioc->numsgelements = 0;
-		break;
+			upthru = (mega_passthru *)umc->xferaddr;
+
+			if( put_user(mc->status, (u8 *)&upthru->scsistatus) )
+				return (-EFAULT);
+		}
 	}
 
-	return scb;
+	return 0;
 }
 
+
+/*
+ * MEGARAID 'FW' commands.
+ */
+
+/**
+ * mega_is_bios_enabled()
+ * @adapter - pointer to our soft state
+ *
+ * issue command to find out if the BIOS is enabled for this controller
+ */
 static int
-mega_support_ext_cdb(mega_host_config *this_hba)
+mega_is_bios_enabled(adapter_t *adapter)
 {
-	mega_mailbox *mboxpnt;
-	unsigned char mbox[16];
-	int ret;
+	unsigned char	raw_mbox[16];
+	mbox_t	*mbox;
+	int	ret;
 
-	mboxpnt = (mega_mailbox *) mbox;
+	mbox = (mbox_t *)raw_mbox;
+
+	memset(mbox, 0, sizeof(mbox));
+
+	memset((void *)adapter->mega_buffer, 0, MEGA_BUFFER_SIZE);
+
+	mbox->xferaddr = (u32)adapter->buf_dma_handle;
+
+	raw_mbox[0] = IS_BIOS_ENABLED;
+	raw_mbox[2] = GET_BIOS;
+
+
+	ret = issue_scb_block(adapter, raw_mbox);
+
+	return *(char *)adapter->mega_buffer;
+}
+
+
+/**
+ * mega_enum_raid_scsi()
+ * @adapter - pointer to our soft state
+ *
+ * Find out what channels are RAID/SCSI. This information is used to
+ * differentiate the virtual channels and physical channels and to support
+ * ROMB feature and non-disk devices.
+ */
+static void
+mega_enum_raid_scsi(adapter_t *adapter)
+{
+	unsigned char raw_mbox[16];
+	mbox_t *mbox;
+	int i;
+
+	mbox = (mbox_t *)raw_mbox;
+
+	memset(mbox, 0, sizeof(mbox));
 
-	memset(mbox, 0, sizeof (mbox));
 	/*
-	 * issue command to find out if controller supports extended CDBs.
+	 * issue command to find out what channels are raid/scsi
+	 */
+	raw_mbox[0] = CHNL_CLASS;
+	raw_mbox[2] = GET_CHNL_CLASS;
+
+	memset((void *)adapter->mega_buffer, 0, MEGA_BUFFER_SIZE);
+
+	mbox->xferaddr = (u32)adapter->buf_dma_handle;
+
+	/*
+	 * Non-ROMB firware fail this command, so all channels
+	 * must be shown RAID
 	 */
-	mbox[0] = 0xA4;
-	mbox[2] = 0x16;
+	adapter->mega_ch_class = 0xFF;
+
+	if(!issue_scb_block(adapter, raw_mbox)) {
+		adapter->mega_ch_class = *((char *)adapter->mega_buffer);
+
+	}
 
-	ret = megaIssueCmd(this_hba, mbox, NULL, 0);
+	for( i = 0; i < adapter->product_info.nchannels; i++ ) { 
+		if( (adapter->mega_ch_class >> i) & 0x01 ) {
+			printk(KERN_INFO "megaraid: channel[%d] is raid.\n",
+					i);
+		}
+		else {
+			printk(KERN_INFO "megaraid: channel[%d] is scsi.\n",
+					i);
+		}
+	}
 
-	return !ret;
+	return;
 }
 
 
-/*
+/**
+ * mega_get_boot_drv()
+ * @adapter - pointer to our soft state
+ *
+ * Find out which device is the boot device. Note, any logical drive or any
+ * phyical device (e.g., a CDROM) can be designated as a boot device.
+ */
+static void
+mega_get_boot_drv(adapter_t *adapter)
+{
+	struct private_bios_data	*prv_bios_data;
+	unsigned char	raw_mbox[16];
+	mbox_t	*mbox;
+	u16	cksum = 0;
+	u8	*cksum_p;
+	u8	boot_pdrv;
+	int	i;
+
+	mbox = (mbox_t *)raw_mbox;
+
+	memset(mbox, 0, sizeof(raw_mbox));
+
+	raw_mbox[0] = BIOS_PVT_DATA;
+	raw_mbox[2] = GET_BIOS_PVT_DATA;
+
+	memset((void *)adapter->mega_buffer, 0, MEGA_BUFFER_SIZE);
+
+	mbox->xferaddr = (u32)adapter->buf_dma_handle;
+
+	adapter->boot_ldrv_enabled = 0;
+	adapter->boot_ldrv = 0;
+
+	adapter->boot_pdrv_enabled = 0;
+	adapter->boot_pdrv_ch = 0;
+	adapter->boot_pdrv_tgt = 0;
+
+	if(issue_scb_block(adapter, raw_mbox) == 0) {
+		prv_bios_data =
+			(struct private_bios_data *)adapter->mega_buffer;
+
+		cksum = 0;
+		cksum_p = (char *)prv_bios_data;
+		for (i = 0; i < 14; i++ ) {
+			cksum += (u16)(*cksum_p++);
+		}
+
+		if (prv_bios_data->cksum == (u16)(0-cksum) ) {
+
+			/*
+			 * If MSB is set, a physical drive is set as boot
+			 * device
+			 */
+			if( prv_bios_data->boot_drv & 0x80 ) {
+				adapter->boot_pdrv_enabled = 1;
+				boot_pdrv = prv_bios_data->boot_drv & 0x7F;
+				adapter->boot_pdrv_ch = boot_pdrv / 16;
+				adapter->boot_pdrv_tgt = boot_pdrv % 16;
+			}
+			else {
+				adapter->boot_ldrv_enabled = 1;
+				adapter->boot_ldrv = prv_bios_data->boot_drv;
+			}
+		}
+	}
+
+}
+
+/**
+ * mega_support_random_del()
+ * @adapter - pointer to our soft state
+ *
  * Find out if this controller supports random deletion and addition of
  * logical drives
  */
 static int
-mega_support_random_del(mega_host_config *this_hba)
+mega_support_random_del(adapter_t *adapter)
 {
-	mega_mailbox *mboxpnt;
-	unsigned char mbox[16];
-	int ret;
+	unsigned char raw_mbox[16];
+	mbox_t *mbox;
+	int rval;
 
-	mboxpnt = (mega_mailbox *)mbox;
+	mbox = (mbox_t *)raw_mbox;
 
 	memset(mbox, 0, sizeof(mbox));
 
 	/*
 	 * issue command
 	 */
-	mbox[0] = FC_DEL_LOGDRV;
-	mbox[2] = OP_SUP_DEL_LOGDRV;
+	raw_mbox[0] = FC_DEL_LOGDRV;
+	raw_mbox[2] = OP_SUP_DEL_LOGDRV;
 
-	ret = megaIssueCmd(this_hba, mbox, NULL, 0);
+	rval = issue_scb_block(adapter, raw_mbox);
 
-	return !ret;
+	return !rval;
 }
 
+
+/**
+ * mega_support_ext_cdb()
+ * @adapter - pointer to our soft state
+ *
+ * Find out if this firmware support cdblen > 10
+ */
 static int
-mega_del_logdrv(mega_host_config *this_hba, int logdrv)
+mega_support_ext_cdb(adapter_t *adapter)
+{
+	unsigned char raw_mbox[16];
+	mbox_t *mbox;
+	int rval;
+
+	mbox = (mbox_t *)raw_mbox;
+
+	memset(mbox, 0, sizeof (mbox));
+	/*
+	 * issue command to find out if controller supports extended CDBs.
+	 */
+	raw_mbox[0] = 0xA4;
+	raw_mbox[2] = 0x16;
+
+	rval = issue_scb_block(adapter, raw_mbox);
+
+	return !rval;
+}
+
+
+/**
+ * mega_del_logdrv()
+ * @adapter - pointer to our soft state
+ * @logdrv - logical drive to be deleted
+ *
+ * Delete the specified logical drive. It is the responsibility of the user
+ * app to let the OS know about this operation.
+ */
+static int
+mega_del_logdrv(adapter_t *adapter, int logdrv)
 {
-	int		rval;
-	IO_LOCK_T;
 	DECLARE_WAIT_QUEUE_HEAD(wq);
-	mega_scb	*scbp;
+	unsigned long flags;
+	scb_t *scb;
+	int rval;
 
 	/*
 	 * Stop sending commands to the controller, queue them internally.
 	 * When deletion is complete, ISR will flush the queue.
 	 */
-	IO_LOCK(this_hba->host);
-	this_hba->quiescent = 1;
-	IO_UNLOCK(this_hba->host);
-
-	while( this_hba->qPcnt ) {
-			sleep_on_timeout( &wq, 1*HZ );	/* sleep for 1s */
-	}
-	rval = mega_do_del_logdrv(this_hba, logdrv);
+	atomic_set(&adapter->quiescent, 1);
 
-	IO_LOCK(this_hba->host);
 	/*
-	 * Attach the internal queue to the pending queue
+	 * Wait till all the issued commands are complete and there are no
+	 * commands in the pending queue
 	 */
-	if( this_hba->qPendingH == NULL ) {
-		/*
-		 * If pending queue head is null, make internal queue as
-		 * pending queue
-		 */
-		this_hba->qPendingH = this_hba->int_qh;
-		this_hba->qPendingT = this_hba->int_qt;
-		this_hba->qPcnt = this_hba->int_qlen;
-	}
-	else {
-		/*
-		 * Append pending queue to internal queue
-		 */
-		if( this_hba->int_qt ) {
-			this_hba->int_qt->next = this_hba->qPendingH;
+	while( atomic_read(&adapter->pend_cmds) > 0 ||
+			!list_empty(&adapter->pending_list) ) {
 
-			this_hba->qPendingH = this_hba->int_qh;
-			this_hba->qPcnt += this_hba->int_qlen;
-		}
+		sleep_on_timeout( &wq, 1*HZ );	/* sleep for 1s */
 	}
 
-	this_hba->int_qh = this_hba->int_qt = NULL;
-	this_hba->int_qlen = 0;
+	rval = mega_do_del_logdrv(adapter, logdrv);
+
+	spin_lock_irqsave(&adapter->lock, flags);
 
 	/*
 	 * If delete operation was successful, add 0x80 to the logical drive
 	 * ids for commands in the pending queue.
 	 */
-	if( this_hba->read_ldidmap) {
-		for( scbp = this_hba->qPendingH; scbp; scbp = scbp->next ) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-			if( scbp->pthru->logdrv < 0x80 )
-				scbp->pthru->logdrv += 0x80;
-#else
-			if( scbp->pthru.logdrv < 0x80 )
-				scbp->pthru.logdrv += 0x80;
-#endif
+	if (adapter->read_ldidmap) {
+		struct list_head *pos;
+		list_for_each(pos, &adapter->pending_list) {
+			scb = list_entry(pos, scb_t, list);
+			if (scb->pthru->logdrv < 0x80 )
+				scb->pthru->logdrv += 0x80;
 		}
 	}
-	this_hba->quiescent = 0;
 
-	IO_UNLOCK(this_hba->host);
+	atomic_set(&adapter->quiescent, 0);
+
+	mega_runpendq(adapter);
+
+	spin_unlock_irqrestore(&adapter->lock, flags);
 
 	return rval;
 }
 
 
 static int
-mega_do_del_logdrv(mega_host_config *this_hba, int logdrv)
+mega_do_del_logdrv(adapter_t *adapter, int logdrv)
 {
-	mega_mailbox *mboxpnt;
-	unsigned char mbox[16];
-	int rval;
+	megacmd_t	mc;
+	int	rval;
 
-	mboxpnt = (mega_mailbox *)mbox;
+	memset( &mc, 0, sizeof(megacmd_t));
 
-	memset(mbox, 0, sizeof(mbox));
-
-	mbox[0] = FC_DEL_LOGDRV;
-	mbox[2] = OP_DEL_LOGDRV;
-	mbox[3] = logdrv;
+	mc.cmd = FC_DEL_LOGDRV;
+	mc.opcode = OP_DEL_LOGDRV;
+	mc.subopcode = logdrv;
 
-	rval = megaIssueCmd(this_hba, mbox, NULL, 0);
+	rval = mega_internal_command(adapter, LOCK_INT, &mc, NULL);
 
 	/* log this event */
-	if( rval != 0 ) {
-		printk("megaraid: Attempt to delete logical drive %d failed.",
-				logdrv);
+	if(rval) {
+		printk(KERN_WARNING "megaraid: Delete LD-%d failed.", logdrv);
 		return rval;
 	}
 
-	printk("megaraid: logical drive %d deleted.\n", logdrv);
-
 	/*
 	 * After deleting first logical drive, the logical drives must be
 	 * addressed by adding 0x80 to the logical drive id.
 	 */
-	this_hba->read_ldidmap = 1;
+	adapter->read_ldidmap = 1;
 
 	return rval;
 }
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
-void *
-dma_alloc_consistent(void *dev, size_t size, dma_addr_t *dma_addr)
+
+/**
+ * mega_get_max_sgl()
+ * @adapter - pointer to our soft state
+ *
+ * Find out the maximum number of scatter-gather elements supported by this
+ * version of the firmware
+ */
+static void
+mega_get_max_sgl(adapter_t *adapter)
+{
+	unsigned char	raw_mbox[16];
+	mbox_t	*mbox;
+
+	mbox = (mbox_t *)raw_mbox;
+
+	memset(mbox, 0, sizeof(raw_mbox));
+
+	memset((void *)adapter->mega_buffer, 0, MEGA_BUFFER_SIZE);
+
+	mbox->xferaddr = (u32)adapter->buf_dma_handle;
+
+	raw_mbox[0] = MAIN_MISC_OPCODE;
+	raw_mbox[2] = GET_MAX_SG_SUPPORT;
+
+
+	if( issue_scb_block(adapter, raw_mbox) ) {
+		/*
+		 * f/w does not support this command. Choose the default value
+		 */
+		adapter->sglen = MIN_SGLIST;
+	}
+	else {
+		adapter->sglen = *((char *)adapter->mega_buffer);
+		
+		/*
+		 * Make sure this is not more than the resources we are
+		 * planning to allocate
+		 */
+		if ( adapter->sglen > MAX_SGLIST )
+			adapter->sglen = MAX_SGLIST;
+	}
+
+	return;
+}
+
+
+/**
+ * mega_support_cluster()
+ * @adapter - pointer to our soft state
+ *
+ * Find out if this firmware support cluster calls.
+ */
+static int
+mega_support_cluster(adapter_t *adapter)
 {
-	void	*_tv;
-	int		npages;
-	int		order = 0;
+	unsigned char	raw_mbox[16];
+	mbox_t	*mbox;
+
+	mbox = (mbox_t *)raw_mbox;
+
+	memset(mbox, 0, sizeof(raw_mbox));
+
+	memset((void *)adapter->mega_buffer, 0, MEGA_BUFFER_SIZE);
+
+	mbox->xferaddr = (u32)adapter->buf_dma_handle;
 
 	/*
-	 * How many pages application needs
+	 * Try to get the initiator id. This command will succeed iff the
+	 * clustering is available on this HBA.
 	 */
-	npages = size / PAGE_SIZE;
+	raw_mbox[0] = MEGA_GET_TARGET_ID;
+
+	if( issue_scb_block(adapter, raw_mbox) == 0 ) {
+
+		/*
+		 * Cluster support available. Get the initiator target id.
+		 * Tell our id to mid-layer too.
+		 */
+		adapter->this_id = *(u32 *)adapter->mega_buffer;
+		adapter->host->this_id = adapter->this_id;
+
+		return 1;
+	}
 
-	/* Do we need one more page */
-	if(size % PAGE_SIZE)
-		npages++;
+	return 0;
+}
 
-	order = mega_get_order(npages);
 
-	_tv = (void *)__get_free_pages(GFP_DMA, order);
 
-	if( _tv != NULL ) {
-		memset(_tv, 0, size);
-		*(dma_addr) = virt_to_bus(_tv);
+/**
+ * mega_get_ldrv_num()
+ * @adapter - pointer to our soft state
+ * @cmd - scsi mid layer command
+ * @channel - channel on the controller
+ *
+ * Calculate the logical drive number based on the information in scsi command
+ * and the channel number.
+ */
+static inline int
+mega_get_ldrv_num(adapter_t *adapter, Scsi_Cmnd *cmd, int channel)
+{
+	int		tgt;
+	int		ldrv_num;
+
+	tgt = cmd->device->id;
+	
+	if ( tgt > adapter->this_id )
+		tgt--;	/* we do not get inquires for initiator id */
+
+	ldrv_num = (channel * 15) + tgt;
+
+
+	/*
+	 * If we have a logical drive with boot enabled, project it first
+	 */
+	if( adapter->boot_ldrv_enabled ) {
+		if( ldrv_num == 0 ) {
+			ldrv_num = adapter->boot_ldrv;
+		}
+		else {
+			if( ldrv_num <= adapter->boot_ldrv ) {
+				ldrv_num--;
+			}
+		}
 	}
 
-	return _tv;
+	/*
+	 * If "delete logical drive" feature is enabled on this controller.
+	 * Do only if at least one delete logical drive operation was done.
+	 *
+	 * Also, after logical drive deletion, instead of logical drive number,
+	 * the value returned should be 0x80+logical drive id.
+	 *
+	 * These is valid only for IO commands.
+	 */
+
+	if (adapter->support_random_del && adapter->read_ldidmap )
+		switch (cmd->cmnd[0]) {
+		case READ_6:	/* fall through */
+		case WRITE_6:	/* fall through */
+		case READ_10:	/* fall through */
+		case WRITE_10:
+			ldrv_num += 0x80;
+		}
+
+	return ldrv_num;
 }
 
-/*
- * int mega_get_order(int)
+
+/**
+ * mega_adapinq()
+ * @adapter - pointer to our soft state
+ * @dma_handle - DMA address of the buffer
  *
- * returns the order to be used as 2nd argument to __get_free_pages() - which
- * return pages equal to pow(2, order) - AM
+ * Issue internal comamnds while interrupts are available.
+ * We only issue direct mailbox commands from within the driver. ioctl()
+ * interface using these routines can issue passthru commands.
  */
-int
-mega_get_order(int n)
+static int
+mega_adapinq(adapter_t *adapter, dma_addr_t dma_handle)
 {
-	int		i = 0;
+	megacmd_t	mc;
+
+	memset(&mc, 0, sizeof(megacmd_t));
+
+	if( adapter->flag & BOARD_40LD ) {
+		mc.cmd = FC_NEW_CONFIG;
+		mc.opcode = NC_SUBOP_ENQUIRY3;
+		mc.subopcode = ENQ3_GET_SOLICITED_FULL;
+	}
+	else {
+		mc.cmd = MEGA_MBOXCMD_ADPEXTINQ;
+	}
+
+	mc.xferaddr = (u32)dma_handle;
 
-	while( pow_2(i++) < n )
-		; /* null statement */
+	if ( mega_internal_command(adapter, LOCK_INT, &mc, NULL) != 0 ) {
+		return -1;
+	}
 
-	return i-1;
+	return 0;
 }
 
-/*
- * int pow_2(int)
+
+/**
+ * mega_allocate_inquiry()
+ * @dma_handle - handle returned for dma address
+ * @pdev - handle to pci device
  *
- * calculates pow(2, i)
+ * allocates memory for inquiry structure
  */
-int
-pow_2(int i)
+static inline caddr_t
+mega_allocate_inquiry(dma_addr_t *dma_handle, struct pci_dev *pdev)
 {
-	unsigned int	v = 1;
-	
-	while(i--)
-		v <<= 1;
+	return pci_alloc_consistent(pdev, sizeof(mega_inquiry3), dma_handle);
+}
 
-	return v;
+
+static inline void
+mega_free_inquiry(caddr_t inquiry, dma_addr_t dma_handle, struct pci_dev *pdev)
+{
+	pci_free_consistent(pdev, sizeof(mega_inquiry3), inquiry, dma_handle);
 }
 
-void
-dma_free_consistent(void *dev, size_t size, void *vaddr, dma_addr_t dma_addr)
+
+/** mega_internal_dev_inquiry()
+ * @adapter - pointer to our soft state
+ * @ch - channel for this device
+ * @tgt - ID of this device
+ * @buf_dma_handle - DMA address of the buffer
+ *
+ * Issue the scsi inquiry for the specified device.
+ */
+static int
+mega_internal_dev_inquiry(adapter_t *adapter, u8 ch, u8 tgt,
+		dma_addr_t buf_dma_handle)
 {
-	int		npages;
-	int		order = 0;
+	mega_passthru	*pthru;
+	dma_addr_t	pthru_dma_handle;
+	megacmd_t	mc;
+	int		rval;
+	struct pci_dev	*pdev;
 
-	npages = size / PAGE_SIZE;
 
-	if(size % PAGE_SIZE)
-		npages++;
+	/*
+	 * For all internal commands, the buffer must be allocated in <4GB
+	 * address range
+	 */
+	if( make_local_pdev(adapter, &pdev) != 0 ) return -1;
 
-	if (npages == 1)
-		order = 0;
-	else if (npages == 2)
-		order = 1;
-	else if (npages <= 4)
-		order = 2;
-	else
-		order = 3;
+	pthru = pci_alloc_consistent(pdev, sizeof(mega_passthru),
+			&pthru_dma_handle);
+
+	if( pthru == NULL ) {
+		free_local_pdev(pdev);
+		return -1;
+	}
+
+	pthru->timeout = 2;
+	pthru->ars = 1;
+	pthru->reqsenselen = 14;
+	pthru->islogical = 0;
+
+	pthru->channel = (adapter->flag & BOARD_40LD) ? 0 : ch;
+
+	pthru->target = (adapter->flag & BOARD_40LD) ? (ch << 4)|tgt : tgt;
 
-	free_pages((unsigned long)vaddr, order);
+	pthru->cdblen = 6;
 
+	pthru->cdb[0] = INQUIRY;
+	pthru->cdb[1] = 0;
+	pthru->cdb[2] = 0;
+	pthru->cdb[3] = 0;
+	pthru->cdb[4] = 255;
+	pthru->cdb[5] = 0;
+
+
+	pthru->dataxferaddr = (u32)buf_dma_handle;
+	pthru->dataxferlen = 256;
+
+	memset(&mc, 0, sizeof(megacmd_t));
+
+	mc.cmd = MEGA_MBOXCMD_PASSTHRU;
+	mc.xferaddr = (u32)pthru_dma_handle;
+
+	rval = mega_internal_command(adapter, LOCK_INT, &mc, pthru);
+
+	pci_free_consistent(pdev, sizeof(mega_passthru), pthru,
+			pthru_dma_handle);
+
+	free_local_pdev(pdev);
+
+	return rval;
 }
+
+
+/**
+ * mega_internal_command()
+ * @adapter - pointer to our soft state
+ * @ls - the scope of the exclusion lock.
+ * @mc - the mailbox command
+ * @pthru - Passthru structure for DCDB commands
+ *
+ * Issue the internal commands in interrupt mode.
+ * The last argument is the address of the passthru structure if the command
+ * to be fired is a passthru command
+ *
+ * lockscope specifies whether the caller has already acquired the lock. Of
+ * course, the caller must know which lock we are talking about.
+ *
+ * Note: parameter 'pthru' is null for non-passthru commands.
+ */
+static int
+mega_internal_command(adapter_t *adapter, lockscope_t ls, megacmd_t *mc,
+		mega_passthru *pthru )
+{
+	Scsi_Cmnd	*scmd;
+	struct	scsi_device *sdev;
+	unsigned long	flags = 0;
+	scb_t	*scb;
+	int	rval;
+
+	/*
+	 * The internal commands share one command id and hence are
+	 * serialized. This is so because we want to reserve maximum number of
+	 * available command ids for the I/O commands.
+	 */
+	down(&adapter->int_mtx);
+
+	scb = &adapter->int_scb;
+	memset(scb, 0, sizeof(scb_t));
+
+	scmd = &adapter->int_scmd;
+	memset(scmd, 0, sizeof(Scsi_Cmnd));
+
+	sdev = kmalloc(sizeof(struct scsi_device), GFP_KERNEL);
+	memset(sdev, 0, sizeof(struct scsi_device));
+	scmd->device = sdev;
+
+	scmd->device->host = adapter->host;
+	scmd->buffer = (void *)scb;
+	scmd->cmnd[0] = MEGA_INTERNAL_CMD;
+
+	scb->state |= SCB_ACTIVE;
+	scb->cmd = scmd;
+
+	memcpy(scb->raw_mbox, mc, sizeof(megacmd_t));
+
+	/*
+	 * Is it a passthru command
+	 */
+	if( mc->cmd == MEGA_MBOXCMD_PASSTHRU ) {
+
+		scb->pthru = pthru;
+	}
+
+	scb->idx = CMDID_INT_CMDS;
+
+	scmd->state = 0;
+
+	/*
+	 * Get the lock only if the caller has not acquired it already
+	 */
+	if( ls == LOCK_INT ) spin_lock_irqsave(&adapter->lock, flags);
+
+	megaraid_queue(scmd, mega_internal_done);
+
+	if( ls == LOCK_INT ) spin_unlock_irqrestore(&adapter->lock, flags);
+
+	/*
+	 * Wait till this command finishes. Do not use
+	 * wait_event_interruptible(). It causes panic if CTRL-C is hit when
+	 * dumping e.g., physical disk information through /proc interface.
+	 */
+#if 0
+	wait_event_interruptible(adapter->int_waitq, scmd->state);
 #endif
+	wait_event(adapter->int_waitq, scmd->state);
+
+	rval = scmd->result;
+	mc->status = scmd->result;
+	kfree(sdev);
+
+	/*
+	 * Print a debug message for all failed commands. Applications can use
+	 * this information.
+	 */
+	if( scmd->result && trace_level ) {
+		printk("megaraid: cmd [%x, %x, %x] status:[%x]\n",
+			mc->cmd, mc->opcode, mc->subopcode, scmd->result);
+	}
+
+	up(&adapter->int_mtx);
+
+	return rval;
+}
+
+
+/**
+ * mega_internal_done()
+ * @scmd - internal scsi command
+ *
+ * Callback routine for internal commands.
+ */
+static void
+mega_internal_done(Scsi_Cmnd *scmd)
+{
+	adapter_t	*adapter;
+
+	adapter = (adapter_t *)scmd->device->host->hostdata;
+
+	scmd->state = 1; /* thread waiting for its command to complete */
+
+	/*
+	 * See comment in mega_internal_command() routine for
+	 * wait_event_interruptible()
+	 */
+#if 0
+	wake_up_interruptible(&adapter->int_waitq);
+#endif
+	wake_up(&adapter->int_waitq);
+
+}
+
+
+static inline int
+make_local_pdev(adapter_t *adapter, struct pci_dev **pdev)
+{
+	*pdev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL);
+
+	if( *pdev == NULL ) return -1;
+
+	memcpy(*pdev, adapter->dev, sizeof(struct pci_dev));
+
+	if( pci_set_dma_mask(*pdev, 0xffffffff) != 0 ) {
+		kfree(*pdev);
+		return -1;
+	}
+
+	return 0;
+}
+
+static inline void
+free_local_pdev(struct pci_dev *pdev)
+{
+	kfree(pdev);
+}
+
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-static
-#endif				/* LINUX VERSION 2.4.XX */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) || defined(MODULE)
-Scsi_Host_Template driver_template = MEGARAID;
+static Scsi_Host_Template driver_template = MEGARAID;
 
 #include "scsi_module.c"
-#endif				/* LINUX VERSION 2.4.XX || MODULE */
 
-/* vi: set ts=4: */
+/* vi: set ts=8 sw=8 tw=78: */
diff -Nru a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h
--- a/drivers/scsi/megaraid.h	Wed Apr 30 22:28:10 2003
+++ b/drivers/scsi/megaraid.h	Wed Apr 30 22:28:10 2003
@@ -1,131 +1,67 @@
 #ifndef __MEGARAID_H__
 #define __MEGARAID_H__
 
-#ifndef LINUX_VERSION_CODE
 #include <linux/version.h>
-#endif
-
-/*
- * For state flag. Do not use LSB(8 bits) which are
- * reserved for storing info about channels.
- */
-#define IN_ISR		  	0x80000000L
-#define IN_ABORT		0x40000000L
-#define IN_RESET		0x20000000L
-#define IN_QUEUE		0x10000000L
-#define BOARD_QUARTZ	0x08000000L
-#define BOARD_40LD	   	0x04000000L
-#define BOARD_64BIT		0x02000000L
-
-#define SCB_FREE     0x0
-#define SCB_ACTIVE   0x1
-#define SCB_WAITQ    0x2
-#define SCB_ISSUED   0x3
-#define SCB_COMPLETE 0x4
-#define SCB_ABORTED  0x5
-#define SCB_RESET    0x6
-
-#define M_RD_CRLFSTR 			"\n"
-#define M_RD_IOCTL_CMD			0x80
-#define M_RD_IOCTL_CMD_NEW		0x81
-#define M_RD_DRIVER_IOCTL_INTERFACE	0x82
-
-#define MEGARAID_VERSION "v1.18 (Release Date: Thu Oct 11 15:02:53 EDT 2001)\n"
-
-#define MEGARAID_IOCTL_VERSION 	114
-
-/* Methods */
-#define GET_DRIVER_INFO 		0x1
-
-#define MEGA_CMD_TIMEOUT		10
-
-/* Feel free to fiddle with these.. max values are:
-   SGLIST     0..26
-   COMMANDS   0..253
-   CMDPERLUN  0..63
-*/
-
-#define MAX_SGLIST	      	0x1A
-#define MAX_COMMANDS	    	127
-#define MAX_CMD_PER_LUN	 	63
-#define MAX_FIRMWARE_STATUS     46
-
-#define MAX_LOGICAL_DRIVES      8
-#define MAX_CHANNEL	     	5
-#define MAX_TARGET	      	15
-#define MAX_PHYSICAL_DRIVES     MAX_CHANNEL*MAX_TARGET
+#include <linux/spinlock.h>
 
-#define INQUIRY_DATA_SIZE       0x24
-#define MAX_CDB_LEN	     		0x0A
-#define MAX_REQ_SENSE_LEN       0x20
 
-#define INTR_VALID	      	0x40
+#define MEGARAID_VERSION	\
+	"v2.00.3 (Release Date: Wed Feb 19 08:51:30 EST 2003)\n"
 
-/* Direction Macros for MBOX Data direction */
-#define TO_DEVICE		0x0
-#define FROM_DEVICE		0x1
-#define FROMTO_DEVICE		0x2
-
-/* Mailbox commands */
-#define MEGA_MBOXCMD_LREAD		0x01
-#define MEGA_MBOXCMD_LWRITE		0x02
-#define MEGA_MBOXCMD_LREAD64		0xA7
-#define MEGA_MBOXCMD_LWRITE64		0xA8
-#define MEGA_MBOXCMD_PASSTHRU		0x03
-#define MEGA_MBOXCMD_EXTPASSTHRU	0xE3
-#define MEGA_MBOXCMD_ADAPTERINQ		0x05
-
-
-/* Offsets into Mailbox */
-#define COMMAND_PORT       	0x00
-#define COMMAND_ID_PORT    	0x01
-#define SG_LIST_PORT0      	0x08
-#define SG_LIST_PORT1      	0x09
-#define SG_LIST_PORT2      	0x0a
-#define SG_LIST_PORT3      	0x0b
-#define SG_ELEMENT_PORT    	0x0d
-#define NO_FIRED_PORT      	0x0f
+/*
+ * Driver features - change the values to enable or disable features in the
+ * driver.
+ */
 
-/* I/O Port offsets */
-#define I_CMD_PORT	 	0x00
-#define I_ACK_PORT	 	0x00
-#define I_TOGGLE_PORT      	0x01
-#define INTR_PORT	  	0x0a
+/*
+ * Comand coalescing - This feature allows the driver to be able to combine
+ * two or more commands and issue as one command in order to boost I/O
+ * performance. Useful if the nature of the I/O is sequential. It is not very
+ * useful for random natured I/Os.
+ */
+#define MEGA_HAVE_COALESCING	0
 
-#define MAILBOX_SIZE       	(sizeof(mega_mailbox)-16)
-#define MBOX_BUSY_PORT     	0x00
-#define MBOX_PORT0	 	0x04
-#define MBOX_PORT1	 	0x05
-#define MBOX_PORT2	 	0x06
-#define MBOX_PORT3	 	0x07
-#define ENABLE_MBOX_REGION 	0x0B
+/*
+ * Clustering support - Set this flag if you are planning to use the
+ * clustering services provided by the megaraid controllers and planning to
+ * setup a cluster
+ */
+#define MEGA_HAVE_CLUSTERING	1
 
-/* I/O Port Values */
-#define ISSUE_BYTE	 	0x10
-#define ACK_BYTE	   	0x08
-#define ENABLE_INTR_BYTE   	0xc0
-#define DISABLE_INTR_BYTE  	0x00
-#define VALID_INTR_BYTE    	0x40
-#define MBOX_BUSY_BYTE     	0x10
-#define ENABLE_MBOX_BYTE   	0x00
+/*
+ * Driver statistics - Set this flag if you are interested in statics about
+ * number of I/O completed on each logical drive and how many interrupts
+ * generated. If enabled, this information is available through /proc
+ * interface and through the private ioctl. Setting this flag has a
+ * performance penalty.
+ */
+#define MEGA_HAVE_STATS		0
 
-/* Setup some port macros here */
-#define WRITE_MAILBOX(base,offset,value)   	*(base+offset)=value
-#define READ_MAILBOX(base,offset)		*(base+offset)
+/*
+ * Enhanced /proc interface - This feature will allow you to have a more
+ * detailed /proc interface for megaraid driver. E.g., a real time update of
+ * the status of the logical drives, battery status, physical drives etc.
+ */
+#define MEGA_HAVE_ENH_PROC	1
 
-#define WRITE_PORT(base,offset,value)      	outb_p(value,base+offset)
-#define READ_PORT(base,offset)	     		inb_p(base+offset)
+#define MAX_DEV_TYPE	32
 
-#define ISSUE_COMMAND(base)	WRITE_PORT(base,I_CMD_PORT,ISSUE_BYTE)
-#define CLEAR_INTR(base)	WRITE_PORT(base,I_ACK_PORT,ACK_BYTE)
-#define ENABLE_INTR(base)	WRITE_PORT(base,I_TOGGLE_PORT,ENABLE_INTR_BYTE)
-#define DISABLE_INTR(base)	WRITE_PORT(base,I_TOGGLE_PORT,DISABLE_INTR_BYTE)
+#ifndef PCI_VENDOR_ID_LSI_LOGIC
+#define PCI_VENDOR_ID_LSI_LOGIC		0x1000
+#endif
 
-/* Define AMI's PCI codes */
 #ifndef PCI_VENDOR_ID_AMI
 #define PCI_VENDOR_ID_AMI		0x101E
 #endif
 
+#ifndef PCI_VENDOR_ID_DELL
+#define PCI_VENDOR_ID_DELL		0x1028
+#endif
+
+#ifndef PCI_VENDOR_ID_INTEL
+#define PCI_VENDOR_ID_INTEL		0x8086
+#endif
+
 #ifndef PCI_DEVICE_ID_AMI_MEGARAID
 #define PCI_DEVICE_ID_AMI_MEGARAID	0x9010
 #endif
@@ -138,418 +74,110 @@
 #define PCI_DEVICE_ID_AMI_MEGARAID3	0x1960
 #endif
 
-/* Special Adapter Commands */
-#define FW_FIRE_WRITE   	0x2C
-#define FW_FIRE_FLASH   	0x2D
-
-#define FC_NEW_CONFIG	   		0xA1
-#define DCMD_FC_CMD			0xA1
-#define DCMD_FC_PROCEED	     		0x02
-#define DCMD_DELETE_LOGDRV	  	0x03
-#define DCMD_FC_READ_NVRAM_CONFIG   	0x04
-#define DCMD_FC_READ_NVRAM_CONFIG_64   	0xC0
-#define DCMD_FC_READ_FINAL_CONFIG   	0x05
-#define DCMD_GET_DISK_CONFIG		0x06
-#define DCMD_GET_DISK_CONFIG_64		0xC2
-#define DCMD_CHANGE_LDNO	    	0x07
-#define DCMD_COMPACT_CONFIG	 	0x08
-#define DCMD_DELETE_DRIVEGROUP      	0x09
-#define DCMD_GET_LOOPID_INFO		0x0A
-#define DCMD_CHANGE_LOOPID	  	0x0B
-#define DCMD_GET_NUM_SCSI_CHANS     	0x0C
-#define DCMD_WRITE_CONFIG	   	0x0D
-#define DCMD_WRITE_CONFIG_64   		0xC1
-
-#define NC_SUBOP_PRODUCT_INFO       	0x0E
-#define NC_SUBOP_ENQUIRY3	   	0x0F
-#define ENQ3_GET_SOLICITED_NOTIFY_ONLY  0x01
-#define ENQ3_GET_SOLICITED_FULL	 	0x02
-#define ENQ3_GET_UNSOLICITED	    	0x03
-
-#define PCI_CONF_BASE_ADDR_OFFSET  	0x10
-#define PCI_CONF_IRQ_OFFSET		0x3c
-#define PCI_CONF_AMISIG	    		0xa0
-#define PCI_CONF_AMISIG64		0xa4
-
-/* Sub-System Vendor ID sorted on alphabetical order*/
-#define	AMI_SUBSYS_ID			0x101E
-#define DELL_SUBSYS_ID			0x1028
-#define	HP_SUBSYS_ID			0x103C
-
-#define AMI_SIGNATURE	      		0x3344
-#define AMI_SIGNATURE_471	  	0xCCCC
-#define AMI_64BIT_SIGNATURE		0x0299
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)	/*0x20100 */
-#define MEGARAID \
-  { NULL,			      	/* Next				*/\
-    NULL,			        /* Usage Count Pointer		*/\
-    NULL,			       	/* proc Directory Entry		*/\
-    megaraid_proc_info,		 	/* proc Info Function		*/\
-    "MegaRAID",			 	/* Driver Name			*/\
-    megaraid_detect,		    	/* Detect Host Adapter		*/\
-    megaraid_release,		   	/* Release Host Adapter		*/\
-    megaraid_info,		      	/* Driver Info Function		*/\
-    megaraid_command,		   	/* Command Function		*/\
-    megaraid_queue,		     	/* Queue Command Function	*/\
-    megaraid_abort,		     	/* Abort Command Function	*/\
-    megaraid_reset,		     	/* Reset Command Function	*/\
-    NULL,			       	/* Slave Attach Function	*/\
-    megaraid_biosparam,		 	/* Disk BIOS Parameters		*/\
-    MAX_COMMANDS,		       	/* # of cmds that can be\
-					outstanding at any time		*/\
-    7,				  	/* HBA Target ID		*/\
-    MAX_SGLIST,			 	/* Scatter/Gather Table Size	*/\
-    MAX_CMD_PER_LUN,		    	/* SCSI Commands per LUN	*/\
-    0,				  	/* Present			*/\
-    0,				  	/* Default Unchecked ISA DMA	*/\
-    ENABLE_CLUSTERING }			/* Enable Clustering		*/
-#else
-#define MEGARAID \
-  {\
-    .name	    	= "MegaRAID",		/* Driver Name			*/\
-    .proc_info		= megaraid_proc_info,     /* /proc driver info		*/\
-    .detect		= megaraid_detect,	/* Detect Host Adapter		*/\
-    .release	  	= megaraid_release,	/* Release Host Adapter		*/\
-    .info	     	= megaraid_info,	   	/* Driver Info Function		*/\
-    .command	  	= megaraid_command,	/* Command Function		*/\
-    .queuecommand  	= megaraid_queue,		/* Queue Command Function	*/\
-    .bios_param     	= megaraid_biosparam, 	/* Disk BIOS Parameters		*/\
-    .can_queue		= MAX_COMMANDS,	    	/* Can Queue			*/\
-    .this_id	  	= 7,		       	/* HBA Target ID		*/\
-    .sg_tablesize   	= MAX_SGLIST,	  	/* Scatter/Gather Table Size	*/\
-    .cmd_per_lun    	= MAX_CMD_PER_LUN,	/* SCSI Commands per LUN	*/\
-    .present	  	= 0,		       	/* Present			*/\
-    .unchecked_isa_dma	= 0,		       	/* Default Unchecked ISA DMA	*/\
-    .use_clustering   	= ENABLE_CLUSTERING,  	/* Enable Clustering		*/\
-	.highmem_io		= 1,													\
-  }
-#endif
-
-/***********************************************************************
- * Structure Declarations for the Firmware supporting 40 Logical Drives
- * and 256 Physical Drives.
- ***********************************************************************/
-
-#define FC_MAX_LOGICAL_DRIVES       	40
-#define FC_MAX_LOG_DEVICES	  	FC_MAX_LOGICAL_DRIVES
-#define FC_MAX_SPAN_DEPTH	   	8
-#define FC_MAX_ROW_SIZE	     		32
-
-#define FC_MAX_CHANNELS	     		16
-#define FC_MAX_TARGETS_PER_CHANNEL  	16
-#define FC_MAX_PHYSICAL_DEVICES     	256
-
-/********************************************
- * PRODUCT_INFO
- ********************************************/
-
-#define SIG_40LOG_32STR_8SPN  0x00282008
-
-/*
- * Utilities declare this strcture size as 1024 bytes. So more fields can
- * be added in future.
- */
-
-struct MRaidProductInfo {
-	u32 DataSize;		/* current size in bytes (not including resvd) */
-	u32 ConfigSignature;
-	/* Current value is 0x00282008
-	 * 0x28=MAX_LOGICAL_DRIVES,
-	 * 0x20=Number of stripes and
-	 * 0x08=Number of spans */
-	u8 FwVer[16];		/* printable ASCI string */
-	u8 BiosVer[16];		/* printable ASCI string */
-	u8 ProductName[80];	/* printable ASCI string */
-
-	u8 MaxConcCmds;		/* Max. concurrent commands supported */
-	u8 SCSIChanPresent;	/* Number of SCSI Channels detected */
-	u8 FCLoopPresent;	/* Number of Fibre Loops detected */
-	u8 memType;		/* EDO, FPM, SDRAM etc */
-
-	u32 signature;
-	u16 DramSize;		/* In terms of MB */
-	u16 subSystemID;
-
-	u16 subSystemVendorID;
-	u8 numNotifyCounters;
-	u8 pad1k[889];		/* 135 + 889 resvd = 1024 total size */
-} __attribute__ ((packed));
-typedef struct MRaidProductInfo megaRaidProductInfo;
+#define PCI_DEVICE_ID_DISCOVERY		0x000E
+#define PCI_DEVICE_ID_PERC4_DI		0x000F
+#define PCI_DEVICE_ID_PERC4_QC_VERDE	0x0407
+
+/* Sub-System Vendor IDs */
+#define	AMI_SUBSYS_VID			0x101E
+#define DELL_SUBSYS_VID			0x1028
+#define	HP_SUBSYS_VID			0x103C
+#define LSI_SUBSYS_VID			0x1000
+
+#define HBA_SIGNATURE	      		0x3344
+#define HBA_SIGNATURE_471	  	0xCCCC
+#define HBA_SIGNATURE_64BIT		0x0299
+
+#define MBOX_BUSY_WAIT			10	/* wait for up to 10 usec for
+						   mailbox to be free */
+#define DEFAULT_INITIATOR_ID	7
+
+#define MAX_SGLIST		64	/* max supported in f/w */
+#define MIN_SGLIST		26	/* guaranteed to support these many */
+#define MAX_COMMANDS		126
+#define CMDID_INT_CMDS		MAX_COMMANDS+1	/* make sure CMDID_INT_CMDS
+					 	is less than max commands
+						supported by any f/w */
+
+#define MAX_CDB_LEN	     	10
+#define MAX_EXT_CDB_LEN		16	/* we support cdb length up to 16 */
+
+#define DEF_CMD_PER_LUN		63
+#define MAX_CMD_PER_LUN		MAX_COMMANDS
+#define MAX_FIRMWARE_STATUS	46
+#define MAX_XFER_PER_CMD	(64*1024)
+#define MAX_SECTORS_PER_IO	128
+
+#define MAX_LOGICAL_DRIVES_40LD		40
+#define FC_MAX_PHYSICAL_DEVICES		256
+#define MAX_LOGICAL_DRIVES_8LD		8
+#define MAX_CHANNELS			5
+#define MAX_TARGET			15
+#define MAX_PHYSICAL_DRIVES		MAX_CHANNELS*MAX_TARGET
+#define MAX_ROW_SIZE_40LD		32
+#define MAX_ROW_SIZE_8LD		8
+#define MAX_SPAN_DEPTH			8
+
+#define NVIRT_CHAN		4	/* # of virtual channels to represent
+					   up to 60 logical drives */
+
+#define MEGARAID						\
+{								\
+	.name =				"MegaRAID",		\
+	.proc_info =			megaraid_proc_info,	\
+	.detect =			megaraid_detect,	\
+	.release =			megaraid_release,	\
+	.info =				megaraid_info,		\
+	.command =			megaraid_command,	\
+	.queuecommand =			megaraid_queue,		\
+	.bios_param =			megaraid_biosparam,	\
+	.max_sectors =			MAX_SECTORS_PER_IO,	\
+	.can_queue =			MAX_COMMANDS,		\
+	.this_id =			DEFAULT_INITIATOR_ID,	\
+	.sg_tablesize =			MAX_SGLIST,		\
+	.cmd_per_lun =			DEF_CMD_PER_LUN,	\
+	.present =  			0,			\
+	.unchecked_isa_dma =		0,			\
+	.use_clustering =		ENABLE_CLUSTERING,	\
+	.eh_abort_handler =		megaraid_abort,		\
+	.eh_device_reset_handler =	megaraid_reset,		\
+	.eh_bus_reset_handler =		megaraid_reset,		\
+	.eh_host_reset_handler =	megaraid_reset,		\
+	.highmem_io =			1,			\
+}
 
-/********************************************
- * Standard ENQUIRY
- ********************************************/
-struct FC_ADP_INFO {
-	u8 MaxConcCmds;		/* Max. concurrent commands supported. */
-	u8 RbldRate;		/* Rebuild Rate. Varies from 0%-100% */
-	u8 MaxTargPerChan;	/* Max. Targets supported per chan. */
-	u8 ChanPresent;		/* No. of Chans present on this adapter. */
-	u8 FwVer[4];		/* Firmware version. */
-	u16 AgeOfFlash;		/* No. of times FW has been downloaded. */
-	u8 ChipSetValue;	/* Contents of 0xC0000832 */
-	u8 DramSize;		/* In terms of MB */
-	u8 CacheFlushInterval;	/* In terms of Seconds */
-	u8 BiosVersion[4];
-	u8 BoardType;
-	u8 sense_alert;
-	u8 write_config_count;	/* Increase with evry configuration change */
-	u8 drive_inserted_count;/* Increase with every drive inserted */
-	u8 inserted_drive;	/* Channel: Id of inserted drive */
-	u8 battery_status;
-	/*
-	   BIT 0 : battery module missing
-	   BIT 1 : VBAD
-	   BIT 2 : temp high
-	   BIT 3 : battery pack missing
-	   BIT 4,5 : 00 - charge complete
-	   01 - fast charge in prog
-	   10 - fast charge fail
-	   11 - undefined
-	   BIt 6 : counter > 1000
-	   Bit 7 : undefined
-	 */
-	u8 dec_fault_bus_info;	/* was resvd */
-} __attribute__ ((packed));
-
-struct FC_LDRV_INFO {
-	u8 NumLDrv;		/* No. of Log. Drvs configured. */
-	u8 recon_state[FC_MAX_LOGICAL_DRIVES / 8];
-	/* bit field for State of reconstruct */
-	u16 LDrvOpStatus[FC_MAX_LOGICAL_DRIVES / 8];
-	/* bit field Status of Long Operations. */
-
-	u32 LDrvSize[FC_MAX_LOGICAL_DRIVES];	/* Size of each log. Drv. */
-	u8 LDrvProp[FC_MAX_LOGICAL_DRIVES];
-	u8 LDrvState[FC_MAX_LOGICAL_DRIVES];	/* State of Logical Drives. */
-} __attribute__ ((packed));
-
-#define PREVSTAT_MASK   0xf0
-#define CURRSTAT_MASK   0x0f
-
-struct FC_PDRV_INFO {
-	u8 PDrvState[FC_MAX_PHYSICAL_DEVICES];	/* State of Phys Drvs. */
-} __attribute__ ((packed));
-
-struct FC_AdapterInq {
-	struct FC_ADP_INFO AdpInfo;
-	struct FC_LDRV_INFO LogdrvInfo;
-	struct FC_PDRV_INFO PhysdrvInfo;
-} __attribute__ ((packed));
 
-typedef struct FC_AdapterInq mega_RAIDINQ_FC;
 
-/********************************************
- * NOTIFICATION
- ********************************************/
-
-#define MAX_NOTIFY_SIZE     0x80
-#define CUR_NOTIFY_SIZE     sizeof(struct MegaRAID_Notify)
-
-/*
- * Utilities declare this strcture size as ?? bytes. So more fields can
- * be added in future.
- */
-struct MegaRAID_Notify {
-	u32 globalCounter;	/* Any change increments this counter */
+typedef struct {
+	/* 0x0 */ u8 cmd;
+	/* 0x1 */ u8 cmdid;
+	/* 0x2 */ u16 numsectors;
+	/* 0x4 */ u32 lba;
+	/* 0x8 */ u32 xferaddr;
+	/* 0xC */ u8 logdrv;
+	/* 0xD */ u8 numsgelements;
+	/* 0xE */ u8 resvd;
+	/* 0xF */ volatile u8 busy;
+	/* 0x10 */ volatile u8 numstatus;
+	/* 0x11 */ volatile u8 status;
+	/* 0x12 */ volatile u8 completed[MAX_FIRMWARE_STATUS];
+	volatile u8 poll;
+	volatile u8 ack;
+} __attribute__ ((packed)) mbox_t;
 
-	u8 paramCounter;	/* Indicates any params changed  */
-	u8 paramId;		/* Param modified - defined below */
-	u16 paramVal;		/* New val of last param modified */
-
-	u8 writeConfigCounter;	/* write config occurred */
-	u8 writeConfigRsvd[3];
-
-	u8 ldrvOpCounter;	/* Indicates ldrv op started/completed */
-	u8 ldrvOpId;		/* ldrv num */
-	u8 ldrvOpCmd;		/* ldrv operation - defined below */
-	u8 ldrvOpStatus;	/* status of the operation */
-
-	u8 ldrvStateCounter;	/* Indicates change of ldrv state */
-	u8 ldrvStateId;		/* ldrv num */
-	u8 ldrvStateNew;	/* New state */
-	u8 ldrvStateOld;	/* old state */
-
-	u8 pdrvStateCounter;	/* Indicates change of ldrv state */
-	u8 pdrvStateId;		/* pdrv id */
-	u8 pdrvStateNew;	/* New state */
-	u8 pdrvStateOld;	/* old state */
-
-	u8 pdrvFmtCounter;	/* Indicates pdrv format started/over */
-	u8 pdrvFmtId;		/* pdrv id */
-	u8 pdrvFmtVal;		/* format started/over */
-	u8 pdrvFmtRsvd;
-
-	u8 targXferCounter;	/* Indicates SCSI-2 Xfer rate change */
-	u8 targXferId;		/* pdrv Id  */
-	u8 targXferVal;		/* new Xfer params of last pdrv */
-	u8 targXferRsvd;
-
-	u8 fcLoopIdChgCounter;	/* Indicates loopid changed */
-	u8 fcLoopIdPdrvId;	/* pdrv id */
-	u8 fcLoopId0;		/* loopid on fc loop 0 */
-	u8 fcLoopId1;		/* loopid on fc loop 1 */
-
-	u8 fcLoopStateCounter;	/* Indicates loop state changed */
-	u8 fcLoopState0;	/* state of fc loop 0 */
-	u8 fcLoopState1;	/* state of fc loop 1 */
-	u8 fcLoopStateRsvd;
-} __attribute__ ((packed));
+typedef struct {
+	u32 xfer_segment_lo;
+	u32 xfer_segment_hi;
+	mbox_t mbox;
+} __attribute__ ((packed)) mbox64_t;
 
-/********************************************
- * PARAM IDs in Notify struct
- ********************************************/
-#define PARAM_RBLD_RATE		 0x01
-    /*--------------------------------------
-     * Param val =
-     *      byte 0: new rbld rate
-     *--------------------------------------*/
-#define PARAM_CACHE_FLUSH_INTERVAL      0x02
-    /*--------------------------------------
-     * Param val =
-     *      byte 0: new cache flush interval
-     *--------------------------------------*/
-#define PARAM_SENSE_ALERT	       0x03
-    /*--------------------------------------
-     * Param val =
-     *      byte 0: last pdrv id causing chkcond
-     *--------------------------------------*/
-#define PARAM_DRIVE_INSERTED	    0x04
-    /*--------------------------------------
-     * Param val =
-     *      byte 0: last pdrv id inserted
-     *--------------------------------------*/
-#define PARAM_BATTERY_STATUS	    0x05
-    /*--------------------------------------
-     * Param val =
-     *      byte 0: battery status
-     *--------------------------------------*/
-
-/********************************************
- * Ldrv operation cmd in Notify struct
- ********************************************/
-#define LDRV_CMD_CHKCONSISTANCY	 0x01
-#define LDRV_CMD_INITIALIZE	 0x02
-#define LDRV_CMD_RECONSTRUCTION	 0x03
-
-/********************************************
- * Ldrv operation status in Notify struct
- ********************************************/
-#define LDRV_OP_SUCCESS		 0x00
-#define LDRV_OP_FAILED		 0x01
-#define LDRV_OP_ABORTED		 0x02
-#define LDRV_OP_CORRECTED	 0x03
-#define LDRV_OP_STARTED		 0x04
-
-/********************************************
- * Raid Logical drive states.
- ********************************************/
-#define     RDRV_OFFLINE	0
-#define     RDRV_DEGRADED	1
-#define     RDRV_OPTIMAL	2
-#define     RDRV_DELETED	3
 
-/*******************************************
- * Physical drive states.
- *******************************************/
-#define     PDRV_UNCNF		0
-#define     PDRV_ONLINE		3
-#define     PDRV_FAILED		4
-#define     PDRV_RBLD		5
-
-/*******************************************
- * Formal val in Notify struct
- *******************************************/
-#define PDRV_FMT_START		0x01
-#define PDRV_FMT_OVER		0x02
-
-/********************************************
- * FC Loop State in Notify Struct
- ********************************************/
-#define ENQ_FCLOOP_FAILED	0
-#define ENQ_FCLOOP_ACTIVE	1
-#define ENQ_FCLOOP_TRANSIENT	2
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-#define M_RD_DMA_TYPE_NONE	      	0xFFFF
-#define M_RD_PTHRU_WITH_BULK_DATA   	0x0001
-#define M_RD_PTHRU_WITH_SGLIST	  	0x0002
-#define M_RD_BULK_DATA_ONLY	     	0x0004
-#define M_RD_SGLIST_ONLY		0x0008
-#define M_RD_EPTHRU_WITH_BULK_DATA   	0x0010
-#endif
-/********************************************
- * ENQUIRY3
- ********************************************/
 /*
- * Utilities declare this strcture size as 1024 bytes. So more fields can
- * be added in future.
+ * Passthru definitions
  */
-struct MegaRAID_Enquiry3 {
-	u32 dataSize;		/* current size in bytes (not including resvd) */
-
-	struct MegaRAID_Notify notify;
-
-	u8 notifyRsvd[MAX_NOTIFY_SIZE - CUR_NOTIFY_SIZE];
-
-	u8 rbldRate;		/* Rebuild rate (0% - 100%) */
-	u8 cacheFlushInterval;	/* In terms of Seconds */
-	u8 senseAlert;
-	u8 driveInsertedCount;	/* drive insertion count */
-
-	u8 batteryStatus;
-	u8 numLDrv;		/* No. of Log Drives configured */
-	u8 reconState[FC_MAX_LOGICAL_DRIVES / 8];	/* State of reconstruct */
-	u16 lDrvOpStatus[FC_MAX_LOGICAL_DRIVES / 8];	/* log. Drv Status */
-
-	u32 lDrvSize[FC_MAX_LOGICAL_DRIVES];	/* Size of each log. Drv */
-	u8 lDrvProp[FC_MAX_LOGICAL_DRIVES];
-	u8 lDrvState[FC_MAX_LOGICAL_DRIVES];	/* State of Logical Drives */
-	u8 pDrvState[FC_MAX_PHYSICAL_DEVICES];	/* State of Phys. Drvs. */
-	u16 physDrvFormat[FC_MAX_PHYSICAL_DEVICES / 16];
-
-	u8 targXfer[80];	/* phys device transfer rate */
-	u8 pad1k[263];		/* 761 + 263reserved = 1024 bytes total size */
-} __attribute__ ((packed));
-typedef struct MegaRAID_Enquiry3 mega_Enquiry3;
-
-/* Structures */
-typedef struct _mega_ADP_INFO {
-	u8 MaxConcCmds;
-	u8 RbldRate;
-	u8 MaxTargPerChan;
-	u8 ChanPresent;
-	u8 FwVer[4];
-	u16 AgeOfFlash;
-	u8 ChipSetValue;
-	u8 DramSize;
-	u8 CacheFlushInterval;
-	u8 BiosVer[4];
-	u8 resvd[7];
-} mega_ADP_INFO;
-
-typedef struct _mega_LDRV_INFO {
-	u8 NumLDrv;
-	u8 resvd[3];
-	u32 LDrvSize[MAX_LOGICAL_DRIVES];
-	u8 LDrvProp[MAX_LOGICAL_DRIVES];
-	u8 LDrvState[MAX_LOGICAL_DRIVES];
-} mega_LDRV_INFO;
-
-typedef struct _mega_PDRV_INFO {
-	u8 PDrvState[MAX_PHYSICAL_DRIVES];
-	u8 resvd;
-} mega_PDRV_INFO;
-
-/* RAID inquiry: Mailbox command 0x5*/
-typedef struct _mega_RAIDINQ {
-	mega_ADP_INFO AdpInfo;
-	mega_LDRV_INFO LogdrvInfo;
-	mega_PDRV_INFO PhysdrvInfo;
-} mega_RAIDINQ;
+#define MAX_REQ_SENSE_LEN       0x20
 
-/* Passthrough command: Mailbox command 0x3*/
-typedef struct mega_passthru {
+typedef struct {
 	u8 timeout:3;		/* 0=6sec/1=60sec/2=10min/3=3hrs */
 	u8 ars:1;
 	u8 reserved:3;
@@ -567,7 +195,8 @@
 	u8 scsistatus;
 	u32 dataxferaddr;
 	u32 dataxferlen;
-} mega_passthru;
+} __attribute__ ((packed)) mega_passthru;
+
 
 /*
  * Extended passthru: support CDB > 10 bytes
@@ -579,228 +208,318 @@
 	u8 cd_rom:1;
 	u8 rsvd2:1;
 	u8 islogical:1;
-
 	u8 logdrv;		/* if islogical == 1 */
 	u8 channel;		/* if islogical == 0 */
 	u8 target;		/* if islogical == 0 */
-
 	u8 queuetag;		/* unused */
 	u8 queueaction;		/* unused */
-
 	u8 cdblen;
 	u8 rsvd3;
-	u8 cdb[16];
-
+	u8 cdb[MAX_EXT_CDB_LEN];
 	u8 numsgelements;
 	u8 status;
 	u8 reqsenselen;
 	u8 reqsensearea[MAX_REQ_SENSE_LEN];
 	u8 rsvd4;
-
 	u32 dataxferaddr;
 	u32 dataxferlen;
-}mega_ext_passthru;
-
-struct _mega_mailbox {
-	/* 0x0 */ u8 cmd;
-	/* 0x1 */ u8 cmdid;
-	/* 0x2 */ u16 numsectors;
-	/* 0x4 */ u32 lba;
-	/* 0x8 */ u32 xferaddr;
-	/* 0xC */ u8 logdrv;
-	/* 0xD */ u8 numsgelements;
-	/* 0xE */ u8 resvd;
-	/* 0xF */ u8 busy;
-	/* 0x10 */ u8 numstatus;
-	/* 0x11 */ u8 status;
-	/* 0x12 */ u8 completed[46];
-	volatile u8 mraid_poll;
-	volatile u8 mraid_ack;
-	u8 pad[16];		/* for alignment purposes */
-} __attribute__ ((packed));
-typedef struct _mega_mailbox mega_mailbox;
+} __attribute__ ((packed)) mega_ext_passthru;
 
 typedef struct {
-	u32 xferSegment_lo;
-	u32 xferSegment_hi;
-	mega_mailbox mailbox;
-} mega_mailbox64;
-
-typedef struct _mega_ioctl_mbox {
-	/* 0x0 */ u8 cmd;
-	/* 0x1 */ u8 cmdid;
-	/* 0x2 */ u8 channel;
-	/* 0x3 */ u8 param;
-	/* 0x4 */ u8 pad[4];
-	/* 0x8 */ u32 xferaddr;
-	/* 0xC */ u8 logdrv;
-	/* 0xD */ u8 numsgelements;
-	/* 0xE */ u8 resvd;
-	/* 0xF */ u8 busy;
-	/* 0x10 */ u8 numstatus;
-	/* 0x11 */ u8 status;
-	/* 0x12 */ u8 completed[46];
-	u8 mraid_poll;
-	u8 mraid_ack;
-	u8 malign[16];
-} mega_ioctl_mbox;
-
-typedef struct _mega_64sglist32 {
 	u64 address;
 	u32 length;
-} __attribute__ ((packed)) mega_64sglist;
+} __attribute__ ((packed)) mega_sgl64;
 
-typedef struct _mega_sglist {
+typedef struct {
 	u32 address;
 	u32 length;
-} mega_sglist;
+} __attribute__ ((packed)) mega_sglist;
+
 
 /* Queued command data */
-typedef struct _mega_scb mega_scb;
+typedef struct {
+	int	idx;
+	u32	state;
+	struct list_head	list;
+	u8	raw_mbox[66];
+	u32	dma_type;
+	u32	dma_direction;
+
+	Scsi_Cmnd	*cmd;
+	dma_addr_t	dma_h_bulkdata;
+	dma_addr_t	dma_h_sgdata;
+
+	mega_sglist	*sgl;
+	mega_sgl64	*sgl64;
+	dma_addr_t	sgl_dma_addr;
+
+	mega_passthru		*pthru;
+	dma_addr_t		pthru_dma_addr;
+	mega_ext_passthru	*epthru;
+	dma_addr_t		epthru_dma_addr;
+} scb_t;
 
-struct _mega_scb {
-	int idx;
-	u32 state;
-	u32 isrcount;
-	u8 mboxData[16];
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	u32 dma_type;
-	dma_addr_t dma_h_bulkdata;	/*Dma handle for bulk data transfter */
-	u32 dma_direction;	/*Dma direction */
-	dma_addr_t dma_h_sgdata;	/*Dma handle for the sglist structure */
-	dma_addr_t dma_h_sglist[MAX_SGLIST];	/*Dma handle for all SGL elements */
-	u8 sglist_count;
-	dma_addr_t dma_sghandle64;
-	dma_addr_t dma_passthruhandle64;
-	dma_addr_t dma_ext_passthruhandle64;
-	dma_addr_t dma_bounce_buffer;
-	u8 *bounce_buffer;
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	mega_passthru *pthru;
-	mega_ext_passthru *epthru;
-#else
-	mega_passthru pthru;
-	mega_ext_passthru epthru;
-#endif
+/*
+ * Flags to follow the scb as it transitions between various stages
+ */
+#define SCB_FREE	0x0000	/* on the free list */
+#define SCB_ACTIVE	0x0001	/* off the free list */
+#define SCB_PENDQ	0x0002	/* on the pending queue */
+#define SCB_ISSUED	0x0004	/* issued - owner f/w */
+#define SCB_ABORT	0x0008	/* Got an abort for this one */
+#define SCB_RESET	0x0010	/* Got a reset for this one */
 
-	Scsi_Cmnd *SCpnt;
-	mega_sglist *sgList;
-	mega_64sglist *sg64List;
-	struct semaphore ioctl_sem;
-	void *buff_ptr;
-	u32 iDataSize;
-	mega_scb *next;
-};
+/*
+ * Utilities declare this strcture size as 1024 bytes. So more fields can
+ * be added in future.
+ */
+typedef struct {
+	u32	data_size; /* current size in bytes (not including resvd) */
 
-/* internal locking by the queue manipulting routines */
-#define INTERNAL_LOCK   0
-/* external locking by the queue manipulting routines */
-#define EXTERNAL_LOCK   1
-#define NO_LOCK		2
-#define INTR_ENB	0	/* do not disable interrupt while manipulating */
-#define INTR_DIS	1	/* disable interrupt while manipulating */
+	u32	config_signature;
+		/* Current value is 0x00282008
+		 * 0x28=MAX_LOGICAL_DRIVES,
+		 * 0x20=Number of stripes and
+		 * 0x08=Number of spans */
+
+	u8	fw_version[16];		/* printable ASCI string */
+	u8	bios_version[16];	/* printable ASCI string */
+	u8	product_name[80];	/* printable ASCI string */
+
+	u8	max_commands;		/* Max. concurrent commands supported */
+	u8	nchannels;		/* Number of SCSI Channels detected */
+	u8	fc_loop_present;	/* Number of Fibre Loops detected */
+	u8	mem_type;		/* EDO, FPM, SDRAM etc */
+
+	u32	signature;
+	u16	dram_size;		/* In terms of MB */
+	u16	subsysid;
+
+	u16	subsysvid;
+	u8	notify_counters;
+	u8	pad1k[889];		/* 135 + 889 resvd = 1024 total size */
+} __attribute__ ((packed)) mega_product_info;
+
+struct notify {
+	u32 global_counter;	/* Any change increments this counter */
+
+	u8 param_counter;	/* Indicates any params changed  */
+	u8 param_id;		/* Param modified - defined below */
+	u16 param_val;		/* New val of last param modified */
+
+	u8 write_config_counter;	/* write config occurred */
+	u8 write_config_rsvd[3];
+
+	u8 ldrv_op_counter;	/* Indicates ldrv op started/completed */
+	u8 ldrv_opid;		/* ldrv num */
+	u8 ldrv_opcmd;		/* ldrv operation - defined below */
+	u8 ldrv_opstatus;	/* status of the operation */
+
+	u8 ldrv_state_counter;	/* Indicates change of ldrv state */
+	u8 ldrv_state_id;		/* ldrv num */
+	u8 ldrv_state_new;	/* New state */
+	u8 ldrv_state_old;	/* old state */
+
+	u8 pdrv_state_counter;	/* Indicates change of ldrv state */
+	u8 pdrv_state_id;		/* pdrv id */
+	u8 pdrv_state_new;	/* New state */
+	u8 pdrv_state_old;	/* old state */
+
+	u8 pdrv_fmt_counter;	/* Indicates pdrv format started/over */
+	u8 pdrv_fmt_id;		/* pdrv id */
+	u8 pdrv_fmt_val;		/* format started/over */
+	u8 pdrv_fmt_rsvd;
+
+	u8 targ_xfer_counter;	/* Indicates SCSI-2 Xfer rate change */
+	u8 targ_xfer_id;	/* pdrv Id  */
+	u8 targ_xfer_val;		/* new Xfer params of last pdrv */
+	u8 targ_xfer_rsvd;
+
+	u8 fcloop_id_chg_counter;	/* Indicates loopid changed */
+	u8 fcloopid_pdrvid;		/* pdrv id */
+	u8 fcloop_id0;			/* loopid on fc loop 0 */
+	u8 fcloop_id1;			/* loopid on fc loop 1 */
+
+	u8 fcloop_state_counter;	/* Indicates loop state changed */
+	u8 fcloop_state0;		/* state of fc loop 0 */
+	u8 fcloop_state1;		/* state of fc loop 1 */
+	u8 fcloop_state_rsvd;
+} __attribute__ ((packed));
 
-/* Per-controller data */
-typedef struct _mega_host_config {
-	u8 numldrv;
-	u32 flag;
+#define MAX_NOTIFY_SIZE     0x80
+#define CUR_NOTIFY_SIZE     sizeof(struct notify)
 
-#ifdef __LP64__
-	u64 base;
-#else
-	u32 base;
-#endif
+typedef struct {
+	u32	data_size; /* current size in bytes (not including resvd) */
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-	dma_addr_t dma_handle64, adjdmahandle64;
-	struct pci_dev *dev;
-#endif
+	struct notify notify;
 
-	mega_scb *qFreeH;
-	mega_scb *qFreeT;
-	spinlock_t lock_free;
+	u8	notify_rsvd[MAX_NOTIFY_SIZE - CUR_NOTIFY_SIZE];
 
-	mega_scb *qPendingH;
-	mega_scb *qPendingT;
-	spinlock_t lock_pend;
+	u8	rebuild_rate;		/* Rebuild rate (0% - 100%) */
+	u8	cache_flush_interval;	/* In terms of Seconds */
+	u8	sense_alert;
+	u8	drive_insert_count;	/* drive insertion count */
+
+	u8	battery_status;
+	u8	num_ldrv;		/* No. of Log Drives configured */
+	u8	recon_state[MAX_LOGICAL_DRIVES_40LD / 8];	/* State of
+							   reconstruct */
+	u16	ldrv_op_status[MAX_LOGICAL_DRIVES_40LD / 8]; /* logdrv
+								 Status */
+
+	u32	ldrv_size[MAX_LOGICAL_DRIVES_40LD];/* Size of each log drv */
+	u8	ldrv_prop[MAX_LOGICAL_DRIVES_40LD];
+	u8	ldrv_state[MAX_LOGICAL_DRIVES_40LD];/* State of log drives */
+	u8	pdrv_state[FC_MAX_PHYSICAL_DEVICES];/* State of phys drvs. */
+	u16	pdrv_format[FC_MAX_PHYSICAL_DEVICES / 16];
+
+	u8	targ_xfer[80];	/* phys device transfer rate */
+	u8	pad1k[263];	/* 761 + 263reserved = 1024 bytes total size */
+} __attribute__ ((packed)) mega_inquiry3;
 
-	Scsi_Cmnd *qCompletedH;
-	Scsi_Cmnd *qCompletedT;
-	spinlock_t lock_scsicmd;
 
-	u32 qFcnt;
-	u32 qPcnt;
-	u32 qCcnt;
+/* Structures */
+typedef struct {
+	u8	max_commands;	/* Max concurrent commands supported */
+	u8	rebuild_rate;	/* Rebuild rate - 0% thru 100% */
+	u8	max_targ_per_chan;	/* Max targ per channel */
+	u8	nchannels;	/* Number of channels on HBA */
+	u8	fw_version[4];	/* Firmware version */
+	u16	age_of_flash;	/* Number of times FW has been flashed */
+	u8	chip_set_value;	/* Contents of 0xC0000832 */
+	u8	dram_size;	/* In MB */
+	u8	cache_flush_interval;	/* in seconds */
+	u8	bios_version[4];
+	u8	board_type;
+	u8	sense_alert;
+	u8	write_config_count;	/* Increase with every configuration
+					   change */
+	u8	drive_inserted_count;	/* Increase with every drive inserted
+					 */
+	u8	inserted_drive;	/* Channel:Id of inserted drive */
+	u8	battery_status;	/*
+				 * BIT 0: battery module missing
+				 * BIT 1: VBAD
+				 * BIT 2: temprature high
+				 * BIT 3: battery pack missing
+				 * BIT 4,5:
+				 *   00 - charge complete
+				 *   01 - fast charge in progress
+				 *   10 - fast charge fail
+				 *   11 - undefined
+				 * Bit 6: counter > 1000
+				 * Bit 7: Undefined
+				 */
+	u8	dec_fault_bus_info;
+} __attribute__ ((packed)) mega_adp_info;
 
-	unsigned long nReads[FC_MAX_LOGICAL_DRIVES];
-	unsigned long nReadBlocks[FC_MAX_LOGICAL_DRIVES];
-	unsigned long nWrites[FC_MAX_LOGICAL_DRIVES];
-	unsigned long nWriteBlocks[FC_MAX_LOGICAL_DRIVES];
-	unsigned long nInterrupts;
-	/* Host adapter parameters */
-	u8 fwVer[7];
-	u8 biosVer[7];
 
-	struct Scsi_Host *host;
+typedef struct {
+	u8	num_ldrv;	/* Number of logical drives configured */
+	u8	rsvd[3];
+	u32	ldrv_size[MAX_LOGICAL_DRIVES_8LD];
+	u8	ldrv_prop[MAX_LOGICAL_DRIVES_8LD];
+	u8	ldrv_state[MAX_LOGICAL_DRIVES_8LD];
+} __attribute__ ((packed)) mega_ldrv_info;
+
+typedef struct {
+	u8	pdrv_state[MAX_PHYSICAL_DRIVES];
+	u8	rsvd;
+} __attribute__ ((packed)) mega_pdrv_info;
+
+/* RAID inquiry: Mailbox command 0x05*/
+typedef struct {
+	mega_adp_info	adapter_info;
+	mega_ldrv_info	logdrv_info;
+	mega_pdrv_info	pdrv_info;
+} __attribute__ ((packed)) mraid_inquiry;
+
+
+/* RAID extended inquiry: Mailbox command 0x04*/
+typedef struct {
+	mraid_inquiry	raid_inq;
+	u16	phys_drv_format[MAX_CHANNELS];
+	u8	stack_attn;
+	u8	modem_status;
+	u8	rsvd[2];
+} __attribute__ ((packed)) mraid_ext_inquiry;
+
+
+typedef struct {
+	u8	channel;
+	u8	target;
+}__attribute__ ((packed)) adp_device;
+
+typedef struct {
+	u32		start_blk;	/* starting block */
+	u32		num_blks;	/* # of blocks */
+	adp_device	device[MAX_ROW_SIZE_40LD];
+}__attribute__ ((packed)) adp_span_40ld;
+
+typedef struct {
+	u32		start_blk;	/* starting block */
+	u32		num_blks;	/* # of blocks */
+	adp_device	device[MAX_ROW_SIZE_8LD];
+}__attribute__ ((packed)) adp_span_8ld;
+
+typedef struct {
+	u8	span_depth;	/* Total # of spans */
+	u8	level;		/* RAID level */
+	u8	read_ahead;	/* read ahead, no read ahead, adaptive read
+				   ahead */
+	u8	stripe_sz;	/* Encoded stripe size */
+	u8	status;		/* Status of the logical drive */
+	u8	write_mode;	/* write mode, write_through/write_back */
+	u8	direct_io;	/* direct io or through cache */
+	u8	row_size;	/* Number of stripes in a row */
+} __attribute__ ((packed)) logdrv_param;
+
+typedef struct {
+	logdrv_param	lparam;
+	adp_span_40ld	span[MAX_SPAN_DEPTH];
+}__attribute__ ((packed)) logdrv_40ld;
+
+typedef struct {
+	logdrv_param	lparam;
+	adp_span_8ld	span[MAX_SPAN_DEPTH];
+}__attribute__ ((packed)) logdrv_8ld;
+
+typedef struct {
+	u8	type;		/* Type of the device */
+	u8	cur_status;	/* current status of the device */
+	u8	tag_depth;	/* Level of tagging */
+	u8	sync_neg;	/* sync negotiation - ENABLE or DISBALE */
+	u32	size;		/* configurable size in terms of 512 byte
+				   blocks */
+}__attribute__ ((packed)) phys_drv;
 
-	volatile mega_mailbox64 *mbox64;	/* ptr to beginning of 64-bit mailbox */
-	volatile mega_mailbox *mbox;	/* ptr to beginning of standard mailbox */
+typedef struct {
+	u8		nlog_drives;		/* number of logical drives */
+	u8		resvd[3];
+	logdrv_40ld	ldrv[MAX_LOGICAL_DRIVES_40LD];
+	phys_drv	pdrv[MAX_PHYSICAL_DRIVES];
+}__attribute__ ((packed)) disk_array_40ld;
+
+typedef struct {
+	u8		nlog_drives;	/* number of logical drives */
+	u8		resvd[3];
+	logdrv_8ld	ldrv[MAX_LOGICAL_DRIVES_8LD];
+	phys_drv	pdrv[MAX_PHYSICAL_DRIVES];
+}__attribute__ ((packed)) disk_array_8ld;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-/* ptr to beginning of standard mailbox */
-	volatile mega_mailbox64 *mailbox64ptr;
-#else
-	volatile mega_mailbox64 mailbox64;
-#endif
-
-	volatile u8 mega_buffer[2 * 1024L];
-	volatile megaRaidProductInfo productInfo;
-
-	u8 max_cmds;
-	mega_scb scbList[MAX_COMMANDS];
-
-#define PROCBUFSIZE 4096
-	char procbuf[PROCBUFSIZE];
-	int procidx;
-	struct proc_dir_entry *controller_proc_dir_entry;
-	struct proc_dir_entry *proc_read, *proc_stat, *proc_status, *proc_mbox;
-	int		support_ext_cdb;
-	int		boot_ldrv_enabled;
-	int		boot_ldrv;
-
-	int		support_random_del;	/* Do we support random deletion of logdrvs */
-	int		read_ldidmap;	/* set after logical drive deltion. The logical
-								drive number must be read from the map */
-	int		quiescent;	/* a stage reached when delete logical drive needs to
-						   be done. Stop sending requests to the hba till
-						   delete operation is completed */
-
-	mega_scb	*int_qh;	/* commands are queued in the internal queue */
-	mega_scb	*int_qt;	/* while the hba is quiescent */
-	int			int_qlen;
-} mega_host_config;
-
-typedef struct _driver_info {
-	int size;
-	ulong version;
-} mega_driver_info;
 
 /*
  * User ioctl structure.
  * This structure will be used for Traditional Method ioctl interface
- * commands (M_RD_IOCTL_CMD),Alternate Buffer Method (M_RD_IOCTL_CMD_NEW) 
- * ioctl commands and the Driver ioctls(M_RD_DRIVER_IOCTL_INTERFACE).
- * The Driver ioctl interface handles the commands at
- * the driver level, without being sent to the card.
+ * commands (0x80),Alternate Buffer Method (0x81) ioctl commands and the
+ * Driver ioctls.
+ * The Driver ioctl interface handles the commands at the driver level,
+ * without being sent to the card.
  */
-#define MEGADEVIOC      0x84
-
 /* system call imposed limit. Change accordingly */
 #define IOCTL_MAX_DATALEN       4096
 
-#pragma pack(1)
 struct uioctl_t {
 	u32 inlen;
 	u32 outlen;
@@ -818,8 +537,8 @@
 			u8 *buffer;
 #endif
 			u32 length;
-		} fcs;
-	} ui;
+		} __attribute__ ((packed)) fcs;
+	} __attribute__ ((packed)) ui;
 	u8 mbox[18];		/* 16 bytes + 2 status bytes */
 	mega_passthru pthru;
 #if BITS_PER_LONG == 32
@@ -829,8 +548,7 @@
 #if BITS_PER_LONG == 64
 	char *data;
 #endif
-};
-#pragma pack()
+} __attribute__ ((packed));
 
 /*
  * struct mcontroller is used to pass information about the controllers in the
@@ -854,25 +572,26 @@
 	u32 uid;
 };
 
-struct mbox_passthru {
-	u8 cmd;
-	u8 cmdid;
-	u16 pad1;
-	u32 pad2;
-	u32 dataxferaddr;
-	u8 pad3;
-	u8 pad4;
-	u8 rsvd;
-	u8 mboxbusy;
-	u8 nstatus;
-	u8 status;
-};
+/*
+ * mailbox structure used for internal commands
+ */
+typedef struct {
+	u8	cmd;
+	u8	cmdid;
+	u8	opcode;
+	u8	subopcode;
+	u32	lba;
+	u32	xferaddr;
+	u8	logdrv;
+	u8	rsvd[3];
+	u8	numstatus;
+	u8	status;
+} __attribute__ ((packed)) megacmd_t;
 
 /*
- * Defines for Driver IOCTL interface, Op-code:M_RD_DRIVER_IOCTL_INTERFACE
+ * Defines for Driver IOCTL interface
  */
 #define MEGAIOC_MAGIC  	'm'
-#define MEGAIOCCMD     	_IOWR(MEGAIOC_MAGIC, 0)	/* Mega IOCTL command */
 
 #define MEGAIOC_QNADAP		'm'	/* Query # of adapters */
 #define MEGAIOC_QDRVRVER	'e'	/* Query driver version */
@@ -880,126 +599,508 @@
 #define MKADAP(adapno)	  	(MEGAIOC_MAGIC << 8 | (adapno) )
 #define GETADAP(mkadap)	 	( (mkadap) ^ MEGAIOC_MAGIC << 8 )
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)	/*0x20300 */
-extern struct proc_dir_entry proc_scsi_megaraid;
-#endif
+/*
+ * Definition for the new ioctl interface (NIT)
+ */
 
-/* For Host Re-Ordering */
-#define MAX_CONTROLLERS	32
+/*
+ * Vendor specific Group-7 commands
+ */
+#define VENDOR_SPECIFIC_COMMANDS	0xE0
+#define MEGA_INTERNAL_CMD		VENDOR_SPECIFIC_COMMANDS + 0x01
 
-struct mega_hbas {
-	int is_bios_enabled;
-	mega_host_config *hostdata_addr;
-};
+/*
+ * The ioctl command. No other command shall be used for this interface
+ */
+#define USCSICMD	VENDOR_SPECIFIC_COMMANDS
+
+/*
+ * Data direction flags
+ */
+#define UIOC_RD		0x00001
+#define UIOC_WR		0x00002
 
-#define		IS_BIOS_ENABLED		0x62
-#define		GET_BIOS		0x01
-#define		CHNL_CLASS		0xA9
-#define		GET_CHNL_CLASS	0x00
-#define		SET_CHNL_CLASS	0x01
-#define		CH_RAID			0x01
-#define		CH_SCSI			0x00
+/*
+ * ioctl opcodes
+ */
+#define MBOX_CMD	0x00000	/* DCMD or passthru command */
+#define GET_DRIVER_VER	0x10000	/* Get driver version */
+#define GET_N_ADAP	0x20000	/* Get number of adapters */
+#define GET_ADAP_INFO	0x30000	/* Get information about a adapter */
+#define GET_CAP		0x40000	/* Get ioctl capabilities */
+#define GET_STATS	0x50000	/* Get statistics, including error info */
 
 
-#define BIOS_PVT_DATA		0x40
-#define GET_BIOS_PVT_DATA	0x00
+/*
+ * The ioctl structure.
+ * MBOX macro converts a nitioctl_t structure to megacmd_t pointer and
+ * MBOX_P macro converts a nitioctl_t pointer to megacmd_t pointer.
+ */
+typedef struct {
+	char		signature[8];	/* Must contain "MEGANIT" */
+	u32		opcode;		/* opcode for the command */
+	u32		adapno;		/* adapter number */
+	union {
+		u8	__raw_mbox[18];
+		caddr_t	__uaddr; /* xferaddr for non-mbox cmds */
+	}__ua;
+
+#define uioc_rmbox	__ua.__raw_mbox
+#define MBOX(uioc)	((megacmd_t *)&((uioc).__ua.__raw_mbox[0]))
+#define MBOX_P(uioc)	((megacmd_t *)&((uioc)->__ua.__raw_mbox[0]))
+#define uioc_uaddr	__ua.__uaddr
+
+	u32		xferlen;	/* xferlen for DCMD and non-mbox
+					   commands */
+	u32		flags;		/* data direction flags */
+}nitioctl_t;
+
+
+/*
+ * I/O statistics for some applications like SNMP agent. The caller must
+ * provide the number of logical drives for which status should be reported.
+ */
+typedef struct {
+	int	num_ldrv;	/* Number for logical drives for which the
+				   status should be reported. */
+	u32	nreads[MAX_LOGICAL_DRIVES_40LD];	/* number of reads for
+							each logical drive */
+	u32	nreadblocks[MAX_LOGICAL_DRIVES_40LD];	/* number of blocks
+							read for each logical
+							drive */
+	u32	nwrites[MAX_LOGICAL_DRIVES_40LD];	/* number of writes
+							for each logical
+							drive */
+	u32	nwriteblocks[MAX_LOGICAL_DRIVES_40LD];	/* number of blocks
+							writes for each
+							logical drive */
+	u32	rd_errors[MAX_LOGICAL_DRIVES_40LD];	/* number of read
+							   errors for each
+							   logical drive */
+	u32	wr_errors[MAX_LOGICAL_DRIVES_40LD];	/* number of write
+							   errors for each
+							   logical drive */
+}megastat_t;
+
 
-#pragma pack(1)
 struct private_bios_data {
-	u8		geometry:4;		/*
-							 * bits 0-3 - BIOS geometry
-							 * 0x0001 - 1GB
-							 * 0x0010 - 2GB
-							 * 0x1000 - 8GB
-							 * Others values are invalid
-							 */
-	u8		unused:4;		/* bits 4-7 are unused */
-	u8		boot_ldrv;		/*
-							 * logical drive set as boot drive
-							 * 0..7 - for 8LD cards
-							 * 0..39 - for 40LD cards
+	u8	geometry:4;	/*
+				 * bits 0-3 - BIOS geometry
+				 * 0x0001 - 1GB
+				 * 0x0010 - 2GB
+				 * 0x1000 - 8GB
+				 * Others values are invalid
 							 */
-	u8		rsvd[12];
-	u16		cksum;			/* 0-(sum of first 13 bytes of this structure) */
-};
-#pragma pack()
+	u8	unused:4;	/* bits 4-7 are unused */
+	u8	boot_drv;	/*
+				 * logical drive set as boot drive
+				 * 0..7 - for 8LD cards
+				 * 0..39 - for 40LD cards
+				 */
+	u8	rsvd[12];
+	u16	cksum;	/* 0-(sum of first 13 bytes of this structure) */
+} __attribute__ ((packed));
+
+
+
+
+/*
+ * Mailbox and firmware commands and subopcodes used in this driver.
+ */
 
-#define NVIRT_CHAN		4	/* # of virtual channels to represent 60 logical
-							drives */
+#define MEGA_MBOXCMD_LREAD	0x01
+#define MEGA_MBOXCMD_LWRITE	0x02
+#define MEGA_MBOXCMD_PASSTHRU	0x03
+#define MEGA_MBOXCMD_ADPEXTINQ	0x04
+#define MEGA_MBOXCMD_ADAPTERINQ	0x05
+#define MEGA_MBOXCMD_LREAD64	0xA7
+#define MEGA_MBOXCMD_LWRITE64	0xA8
+#define MEGA_MBOXCMD_PASSTHRU64	0xC3
+#define MEGA_MBOXCMD_EXTPTHRU	0xE3
+
+#define MAIN_MISC_OPCODE	0xA4	/* f/w misc opcode */
+#define GET_MAX_SG_SUPPORT	0x01	/* get max sg len supported by f/w */
+
+#define FC_NEW_CONFIG		0xA1
+#define NC_SUBOP_PRODUCT_INFO	0x0E
+#define NC_SUBOP_ENQUIRY3	0x0F
+#define ENQ3_GET_SOLICITED_FULL	0x02
+#define OP_DCMD_READ_CONFIG	0x04
+#define NEW_READ_CONFIG_8LD	0x67
+#define READ_CONFIG_8LD		0x07
+#define FLUSH_ADAPTER		0x0A
+#define FLUSH_SYSTEM		0xFE
 
 /*
  * Command for random deletion of logical drives
  */
 #define	FC_DEL_LOGDRV		0xA4	/* f/w command */
 #define	OP_SUP_DEL_LOGDRV	0x2A	/* is feature supported */
-#define OP_GET_LDID_MAP		0x18	/* get logdrv id and logdrv number map */
+#define OP_GET_LDID_MAP		0x18	/* get ldid and logdrv number map */
 #define OP_DEL_LOGDRV		0x1C	/* delete logical drive */
 
-/*================================================================
- *
- *                    Function prototypes
- *
- *================================================================
+/*
+ * BIOS commands
+ */
+#define IS_BIOS_ENABLED		0x62
+#define GET_BIOS		0x01
+#define CHNL_CLASS		0xA9
+#define GET_CHNL_CLASS		0x00
+#define SET_CHNL_CLASS		0x01
+#define CH_RAID			0x01
+#define CH_SCSI			0x00
+#define BIOS_PVT_DATA		0x40
+#define GET_BIOS_PVT_DATA	0x00
+
+
+/*
+ * Commands to support clustering
  */
+#define MEGA_GET_TARGET_ID	0x7D
+#define MEGA_CLUSTER_OP		0x70
+#define MEGA_GET_CLUSTER_MODE	0x02
+#define MEGA_CLUSTER_CMD	0x6E
+#define MEGA_RESERVE_LD		0x01
+#define MEGA_RELEASE_LD		0x02
+#define MEGA_RESET_RESERVATIONS	0x03
+#define MEGA_RESERVATION_STATUS	0x04
+#define MEGA_RESERVE_PD		0x05
+#define MEGA_RELEASE_PD		0x06
+
+
+/*
+ * Module battery status
+ */
+#define MEGA_BATT_MODULE_MISSING	0x01
+#define MEGA_BATT_LOW_VOLTAGE		0x02
+#define MEGA_BATT_TEMP_HIGH		0x04
+#define MEGA_BATT_PACK_MISSING		0x08
+#define MEGA_BATT_CHARGE_MASK		0x30
+#define MEGA_BATT_CHARGE_DONE		0x00
+#define MEGA_BATT_CHARGE_INPROG		0x10
+#define MEGA_BATT_CHARGE_FAIL		0x20
+#define MEGA_BATT_CYCLES_EXCEEDED	0x40
+
+/*
+ * Physical drive states.
+ */
+#define PDRV_UNCNF	0
+#define PDRV_ONLINE	3
+#define PDRV_FAILED	4
+#define PDRV_RBLD	5
+#define PDRV_HOTSPARE	6
+
+
+/*
+ * Raid logical drive states.
+ */
+#define RDRV_OFFLINE	0
+#define RDRV_DEGRADED	1
+#define RDRV_OPTIMAL	2
+#define RDRV_DELETED	3
+
+/*
+ * Read, write and cache policies
+ */
+#define NO_READ_AHEAD		0
+#define READ_AHEAD		1
+#define ADAP_READ_AHEAD		2
+#define WRMODE_WRITE_THRU	0
+#define WRMODE_WRITE_BACK	1
+#define CACHED_IO		0
+#define DIRECT_IO		1
+
+
+#define SCSI_LIST(scp) ((struct list_head *)(&(scp)->SCp))
+
+/*
+ * Each controller's soft state
+ */
+typedef struct {
+	int	this_id;	/* our id, may set to different than 7 if
+				   clustering is available */
+	u32	flag;
+
+	unsigned long	base;
+
+	/* mbox64 with mbox not aligned on 16-byte boundry */
+	mbox64_t	*una_mbox64;
+	dma_addr_t	una_mbox64_dma;
+
+	volatile mbox64_t	*mbox64;/* ptr to 64-bit mailbox */
+	volatile mbox_t		*mbox;	/* ptr to standard mailbox */
+	dma_addr_t		mbox_dma;
+
+	struct pci_dev	*dev;
+
+	struct list_head	free_list;
+	struct list_head	pending_list;
+	struct list_head	completed_list;
+
+	struct Scsi_Host	*host;
+
+#define MEGA_BUFFER_SIZE (2*1024)
+	u8		*mega_buffer;
+	dma_addr_t	buf_dma_handle;
+
+	mega_product_info	product_info;
+
+	u8		max_cmds;
+	scb_t		*scb_list;
+
+	atomic_t	pend_cmds;	/* maintain a counter for pending
+					   commands in firmware */
+
+#if MEGA_HAVE_STATS
+	u32	nreads[MAX_LOGICAL_DRIVES_40LD];
+	u32	nreadblocks[MAX_LOGICAL_DRIVES_40LD];
+	u32	nwrites[MAX_LOGICAL_DRIVES_40LD];
+	u32	nwriteblocks[MAX_LOGICAL_DRIVES_40LD];
+	u32	rd_errors[MAX_LOGICAL_DRIVES_40LD];
+	u32	wr_errors[MAX_LOGICAL_DRIVES_40LD];
+#endif
+
+	/* Host adapter parameters */
+	u8	numldrv;
+	u8	fw_version[7];
+	u8	bios_version[7];
+
+#ifdef CONFIG_PROC_FS
+	struct proc_dir_entry	*controller_proc_dir_entry;
+	struct proc_dir_entry	*proc_read;
+	struct proc_dir_entry	*proc_stat;
+	struct proc_dir_entry	*proc_mbox;
+
+#if MEGA_HAVE_ENH_PROC
+	struct proc_dir_entry	*proc_rr;
+	struct proc_dir_entry	*proc_battery;
+#define MAX_PROC_CHANNELS	4
+	struct proc_dir_entry	*proc_pdrvstat[MAX_PROC_CHANNELS];
+	struct proc_dir_entry	*proc_rdrvstat[MAX_PROC_CHANNELS];
+#endif
+
+#endif
+
+	int	has_64bit_addr;		/* are we using 64-bit addressing */
+	int	support_ext_cdb;
+	int	boot_ldrv_enabled;
+	int	boot_ldrv;
+	int	boot_pdrv_enabled;	/* boot from physical drive */
+	int	boot_pdrv_ch;		/* boot physical drive channel */
+	int	boot_pdrv_tgt;		/* boot physical drive target */
+
+
+	int	support_random_del;	/* Do we support random deletion of
+					   logdrvs */
+	int	read_ldidmap;	/* set after logical drive deltion. The
+				   logical drive number must be read from the
+				   map */
+	atomic_t	quiescent;	/* a stage reached when delete logical
+					   drive needs to be done. Stop
+					   sending requests to the hba till
+					   delete operation is completed */
+	spinlock_t	lock;
+
+	u8	logdrv_chan[MAX_CHANNELS+NVIRT_CHAN]; /* logical drive are on
+							what channels. */
+	int	mega_ch_class;
+
+	u8	sglen;	/* f/w supported scatter-gather list length */
+
+	scb_t			int_scb;
+	Scsi_Cmnd		int_scmd;
+	struct semaphore	int_mtx;	/* To synchronize the internal
+						commands */
+	wait_queue_head_t	int_waitq;	/* wait queue for internal
+						 cmds */
+
+	int	has_cluster;	/* cluster support on this HBA */
+}adapter_t;
+
+
+struct mega_hbas {
+	int is_bios_enabled;
+	adapter_t *hostdata_addr;
+};
+
+
+/*
+ * For state flag. Do not use LSB(8 bits) which are
+ * reserved for storing info about channels.
+ */
+#define IN_ABORT	0x80000000L
+#define IN_RESET	0x40000000L
+#define BOARD_MEMMAP	0x20000000L
+#define BOARD_IOMAP	0x10000000L
+#define BOARD_40LD   	0x08000000L
+#define BOARD_64BIT	0x04000000L
+
+#define INTR_VALID			0x40
+
+#define PCI_CONF_AMISIG			0xa0
+#define PCI_CONF_AMISIG64		0xa4
+
+
+#define MEGA_DMA_TYPE_NONE		0xFFFF
+#define MEGA_BULK_DATA			0x0001
+#define MEGA_SGLIST			0x0002
+
+/*
+ * lockscope definitions, callers can specify the lock scope with this data
+ * type. LOCK_INT would mean the caller has not acquired the lock before
+ * making the call and LOCK_EXT would mean otherwise.
+ */
+typedef enum { LOCK_INT, LOCK_EXT } lockscope_t;
+
+/*
+ * Parameters for the io-mapped controllers
+ */
+
+/* I/O Port offsets */
+#define CMD_PORT	 	0x00
+#define ACK_PORT	 	0x00
+#define TOGGLE_PORT		0x01
+#define INTR_PORT	  	0x0a
+
+#define MBOX_BUSY_PORT     	0x00
+#define MBOX_PORT0	 	0x04
+#define MBOX_PORT1	 	0x05
+#define MBOX_PORT2	 	0x06
+#define MBOX_PORT3	 	0x07
+#define ENABLE_MBOX_REGION 	0x0B
+
+/* I/O Port Values */
+#define ISSUE_BYTE	 	0x10
+#define ACK_BYTE	   	0x08
+#define ENABLE_INTR_BYTE   	0xc0
+#define DISABLE_INTR_BYTE  	0x00
+#define VALID_INTR_BYTE    	0x40
+#define MBOX_BUSY_BYTE     	0x10
+#define ENABLE_MBOX_BYTE   	0x00
+
+
+/* Setup some port macros here */
+#define issue_command(adapter)	\
+		outb_p(ISSUE_BYTE, (adapter)->base + CMD_PORT)
+
+#define irq_state(adapter)	inb_p((adapter)->base + INTR_PORT)
+
+#define set_irq_state(adapter, value)	\
+		outb_p((value), (adapter)->base + INTR_PORT)
+
+#define irq_ack(adapter)	\
+		outb_p(ACK_BYTE, (adapter)->base + ACK_PORT)
+
+#define irq_enable(adapter)	\
+	outb_p(ENABLE_INTR_BYTE, (adapter)->base + TOGGLE_PORT)
+
+#define irq_disable(adapter)	\
+	outb_p(DISABLE_INTR_BYTE, (adapter)->base + TOGGLE_PORT)
+
+
+/*
+ * This is our SYSDEP area. All kernel specific detail should be placed here -
+ * as much as possible
+ */
+
+/*
+ * End of SYSDEP area
+ */
+
 const char *megaraid_info (struct Scsi_Host *);
-int megaraid_detect (Scsi_Host_Template *);
-int megaraid_release (struct Scsi_Host *);
-int megaraid_command (Scsi_Cmnd *);
-int megaraid_abort (Scsi_Cmnd *);
-int megaraid_reset (Scsi_Cmnd *, unsigned int);
-int megaraid_queue (Scsi_Cmnd *, void (*done) (Scsi_Cmnd *));
-int megaraid_biosparam (struct scsi_device *, struct block_device *,
-			sector_t, int *);
-int megaraid_proc_info (char *buffer, char **start, off_t offset,
-			int length, int hostno, int inout);
-
-static int megaIssueCmd (mega_host_config * megaCfg, u_char * mboxData,
-			 mega_scb * scb, int intr);
-static int mega_build_sglist (mega_host_config * megaCfg, mega_scb * scb,
-			      u32 * buffer, u32 * length);
-static int mega_busyWaitMbox (mega_host_config *);
-static int mega_runpendq (mega_host_config *);
-static void mega_rundoneq (mega_host_config *);
-static void mega_cmd_done (mega_host_config *, mega_scb *, int);
-static inline void mega_freeSgList (mega_host_config * megaCfg);
-static void mega_Convert8ldTo40ld (mega_RAIDINQ * inquiry,
-				   mega_Enquiry3 * enquiry3,
-				   megaRaidProductInfo * productInfo);
+
+static int megaraid_detect(Scsi_Host_Template *);
+static void mega_find_card(Scsi_Host_Template *, u16, u16);
+static int mega_query_adapter(adapter_t *);
+static inline int issue_scb(adapter_t *, scb_t *);
+static int mega_setup_mailbox(adapter_t *);
+
+static int megaraid_queue (Scsi_Cmnd *, void (*)(Scsi_Cmnd *));
+static scb_t * mega_build_cmd(adapter_t *, Scsi_Cmnd *, int *);
+static inline scb_t *mega_allocate_scb(adapter_t *, Scsi_Cmnd *);
+static void __mega_runpendq(adapter_t *);
+static inline void mega_runpendq(adapter_t *);
+static int issue_scb_block(adapter_t *, u_char *);
+
+static irqreturn_t megaraid_isr_memmapped(int, void *, struct pt_regs *);
+static irqreturn_t megaraid_isr_iomapped(int, void *, struct pt_regs *);
+
+static void mega_free_scb(adapter_t *, scb_t *);
+
+static int megaraid_release (struct Scsi_Host *);
+static int megaraid_command (Scsi_Cmnd *);
+static int megaraid_abort(Scsi_Cmnd *);
+static int megaraid_reset(Scsi_Cmnd *);
+static int megaraid_abort_and_reset(adapter_t *, Scsi_Cmnd *, int);
+static int megaraid_biosparam(struct scsi_device *, struct block_device *,
+		sector_t, int []);
+static int megaraid_proc_info (char *, char **, off_t, int, int, int);
+static int mega_print_inquiry(char *, char *);
+
+static int mega_build_sglist (adapter_t *adapter, scb_t *scb,
+			      u32 *buffer, u32 *length);
+static inline int mega_busywait_mbox (adapter_t *);
+static int __mega_busywait_mbox (adapter_t *);
+static void mega_rundoneq (adapter_t *);
+static inline void mega_cmd_done(adapter_t *, u8 [], int, int);
+static inline void mega_free_sgl (adapter_t *adapter);
+static void mega_8_to_40ld (mraid_inquiry *inquiry,
+		mega_inquiry3 *enquiry3, mega_product_info *);
 
 static int megaraid_reboot_notify (struct notifier_block *,
 				   unsigned long, void *);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)  
-static mega_scb *mega_ioctl (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt);
-static void mega_build_kernel_sg (char *barea, ulong xfersize, mega_scb * pScb,
-			   mega_ioctl_mbox * mbox);
-#endif
-
-static int megadev_ioctl_entry (struct inode *, struct file *,
-				unsigned int, unsigned long);
-static int megadev_ioctl (struct inode *, struct file *,
-			  unsigned int, unsigned long);
-static mega_scb *megadev_doioctl (mega_host_config *, Scsi_Cmnd *);
-static void megadev_ioctl_done (Scsi_Cmnd *);
-static int mega_init_scb (mega_host_config *);
-static void enq_scb_freelist (mega_host_config *, mega_scb *,
-			      int lock, int intr);
-
-static int mega_is_bios_enabled (mega_host_config *);
-
-static void mega_create_proc_entry (int index, struct proc_dir_entry *);
-static int mega_support_ext_cdb(mega_host_config *);
-static mega_passthru* mega_prepare_passthru(mega_host_config *, mega_scb *,
-		Scsi_Cmnd *);
-static mega_ext_passthru* mega_prepare_extpassthru(mega_host_config *,
-		mega_scb *, Scsi_Cmnd *);
-static void mega_enum_raid_scsi(mega_host_config *);
-static int mega_partsize(struct block_device *, sector_t, int *);
-static void mega_get_boot_ldrv(mega_host_config *);
-static int mega_get_lun(mega_host_config *, Scsi_Cmnd *);
-static int mega_support_random_del(mega_host_config *);
-static int mega_del_logdrv(mega_host_config *, int);
-static int mega_do_del_logdrv(mega_host_config *, int);
+static int megadev_open (struct inode *, struct file *);
+static int megadev_ioctl (struct inode *, struct file *, unsigned int,
+		unsigned long);
+static int mega_m_to_n(void *, nitioctl_t *);
+static int mega_n_to_m(void *, megacmd_t *);
+
+static int mega_init_scb (adapter_t *);
+
+static int mega_is_bios_enabled (adapter_t *);
+
+#ifdef CONFIG_PROC_FS
+static void mega_create_proc_entry(int, struct proc_dir_entry *);
+static int proc_read_config(char *, char **, off_t, int, int *, void *);
+static int proc_read_stat(char *, char **, off_t, int, int *, void *);
+static int proc_read_mbox(char *, char **, off_t, int, int *, void *);
+static int proc_rebuild_rate(char *, char **, off_t, int, int *, void *);
+static int proc_battery(char *, char **, off_t, int, int *, void *);
+static int proc_pdrv_ch0(char *, char **, off_t, int, int *, void *);
+static int proc_pdrv_ch1(char *, char **, off_t, int, int *, void *);
+static int proc_pdrv_ch2(char *, char **, off_t, int, int *, void *);
+static int proc_pdrv_ch3(char *, char **, off_t, int, int *, void *);
+static int proc_pdrv(adapter_t *, char *, int);
+static int proc_rdrv_10(char *, char **, off_t, int, int *, void *);
+static int proc_rdrv_20(char *, char **, off_t, int, int *, void *);
+static int proc_rdrv_30(char *, char **, off_t, int, int *, void *);
+static int proc_rdrv_40(char *, char **, off_t, int, int *, void *);
+static int proc_rdrv(adapter_t *, char *, int, int);
+#endif
 
+static int mega_adapinq(adapter_t *, dma_addr_t);
+static int mega_internal_dev_inquiry(adapter_t *, u8, u8, dma_addr_t);
+static inline caddr_t mega_allocate_inquiry(dma_addr_t *, struct pci_dev *);
+static inline void mega_free_inquiry(caddr_t, dma_addr_t, struct pci_dev *);
+static inline int make_local_pdev(adapter_t *, struct pci_dev **);
+static inline void free_local_pdev(struct pci_dev *);
+
+static int mega_support_ext_cdb(adapter_t *);
+static mega_passthru* mega_prepare_passthru(adapter_t *, scb_t *,
+		Scsi_Cmnd *, int, int);
+static mega_ext_passthru* mega_prepare_extpassthru(adapter_t *,
+		scb_t *, Scsi_Cmnd *, int, int);
+static void mega_enum_raid_scsi(adapter_t *);
+static void mega_get_boot_drv(adapter_t *);
+static inline int mega_get_ldrv_num(adapter_t *, Scsi_Cmnd *, int);
+static int mega_support_random_del(adapter_t *);
+static int mega_del_logdrv(adapter_t *, int);
+static int mega_do_del_logdrv(adapter_t *, int);
+static void mega_get_max_sgl(adapter_t *);
+static int mega_internal_command(adapter_t *, lockscope_t, megacmd_t *,
+		mega_passthru *);
+static void mega_internal_done(Scsi_Cmnd *);
+static int mega_support_cluster(adapter_t *);
 #endif
 
-/* vi: set ts=4: */
+/* vi: set ts=8 sw=8 tw=78: */
diff -Nru a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
--- a/drivers/scsi/ncr53c8xx.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/scsi/ncr53c8xx.c	Wed Apr 30 22:28:07 2003
@@ -115,15 +115,15 @@
 **==========================================================
 */
 
-#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
+#include <linux/version.h>
 
 #include <linux/module.h>
 #include <asm/dma.h>
 #include <asm/io.h>
 #include <asm/system.h>
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,17)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,17)
 #include <linux/spinlock.h>
-#elif LINUX_VERSION_CODE >= LinuxVersionCode(2,1,93)
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
 #include <asm/spinlock.h>
 #endif
 #include <linux/delay.h>
@@ -140,10 +140,9 @@
 #include <linux/timer.h>
 #include <linux/stat.h>
 
-#include <linux/version.h>
 #include <linux/blk.h>
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,35)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,35)
 #include <linux/init.h>
 #endif
 
@@ -154,7 +153,7 @@
 #define	__initdata
 #endif
 
-#if LINUX_VERSION_CODE <= LinuxVersionCode(2,1,92)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,1,92)
 #include <linux/bios32.h>
 #endif
 
@@ -205,7 +204,7 @@
 **	Donnot compile integrity checking code for Linux-2.3.0 
 **	and above since SCSI data structures are not ready yet.
 */
-/* #if LINUX_VERSION_CODE < LinuxVersionCode(2,3,0) */
+/* #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */
 #if 0
 #define	SCSI_NCR_INTEGRITY_CHECKING
 #endif
@@ -398,7 +397,7 @@
 
 #define ScsiResult(host_code, scsi_code) (((host_code) << 16) + ((scsi_code) & 0x7f))
 
-static void ncr53c8xx_intr(int irq, void *dev_id, struct pt_regs * regs);
+static irqreturn_t ncr53c8xx_intr(int irq, void *dev_id, struct pt_regs * regs);
 static void ncr53c8xx_timeout(unsigned long np);
 static int ncr53c8xx_proc_info(char *buffer, char **start, off_t offset,
 			int length, int hostno, int func);
@@ -1049,7 +1048,7 @@
 					/*  when lcb is not allocated.	*/
 	Scsi_Cmnd	*done_list;	/* Commands waiting for done()  */
 					/* callback to be invoked.      */ 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,93)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
 	spinlock_t	smp_lock;	/* Lock for SMP threading       */
 #endif
 
@@ -3816,7 +3815,7 @@
 	instance->max_id	= np->maxwide ? 16 : 8;
 	instance->max_lun	= SCSI_NCR_MAX_LUN;
 #ifndef SCSI_NCR_IOMAPPED
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,29)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,29)
 	instance->base		= (unsigned long) np->reg;
 #else
 	instance->base		= (char *) np->reg;
@@ -3901,7 +3900,7 @@
 
 	if (request_irq(device->slot.irq, ncr53c8xx_intr,
 			((driver_setup.irqm & 0x10) ? 0 : SA_SHIRQ) |
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,2,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,0)
 			((driver_setup.irqm & 0x20) ? 0 : SA_INTERRUPT),
 #else
 			0,
@@ -4883,7 +4882,7 @@
  * Return immediately if reset is in progress.
  */
 	if (np->settle_time) {
-		return SCSI_RESET_PUNT;
+		return FAILED;
 	}
 /*
  * Start the reset process.
@@ -4929,7 +4928,7 @@
 		ncr_queue_done_cmd(np, cmd);
 	}
 
-	return SCSI_RESET_SUCCESS;
+	return SUCCESS;
 }
 
 /*==========================================================
@@ -8775,7 +8774,7 @@
 **   routine for each host that uses this IRQ.
 */
 
-static void ncr53c8xx_intr(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t ncr53c8xx_intr(int irq, void *dev_id, struct pt_regs * regs)
 {
      unsigned long flags;
      ncb_p np = (ncb_p) dev_id;
@@ -8800,6 +8799,7 @@
           ncr_flush_done_cmds(done_list);
           NCR_UNLOCK_SCSI_DONE(done_list->device->host, flags);
      }
+     return IRQ_HANDLED;
 }
 
 /*
@@ -8829,59 +8829,24 @@
 **   Linux entry point of reset() function
 */
 
-#if defined SCSI_RESET_SYNCHRONOUS && defined SCSI_RESET_ASYNCHRONOUS
-int ncr53c8xx_reset(Scsi_Cmnd *cmd, unsigned int reset_flags)
-#else
-int ncr53c8xx_reset(Scsi_Cmnd *cmd)
-#endif
+int ncr53c8xx_bus_reset(Scsi_Cmnd *cmd)
 {
 	ncb_p np = ((struct host_data *) cmd->device->host->hostdata)->ncb;
 	int sts;
 	unsigned long flags;
 	Scsi_Cmnd *done_list;
 
-#if defined SCSI_RESET_SYNCHRONOUS && defined SCSI_RESET_ASYNCHRONOUS
-	printk("ncr53c8xx_reset: pid=%lu reset_flags=%x serial_number=%ld serial_number_at_timeout=%ld\n",
-		cmd->pid, reset_flags, cmd->serial_number, cmd->serial_number_at_timeout);
-#else
-	printk("ncr53c8xx_reset: command pid %lu\n", cmd->pid);
-#endif
-
 	NCR_LOCK_NCB(np, flags);
 
 	/*
-	 * We have to just ignore reset requests in some situations.
-	 */
-#if defined SCSI_RESET_NOT_RUNNING
-	if (cmd->serial_number != cmd->serial_number_at_timeout) {
-		sts = SCSI_RESET_NOT_RUNNING;
-		goto out;
-	}
-#endif
-	/*
 	 * If the mid-level driver told us reset is synchronous, it seems 
 	 * that we must call the done() callback for the involved command, 
 	 * even if this command was not queued to the low-level driver, 
-	 * before returning SCSI_RESET_SUCCESS.
+	 * before returning SUCCESS.
 	 */
 
-#if defined SCSI_RESET_SYNCHRONOUS && defined SCSI_RESET_ASYNCHRONOUS
-	sts = ncr_reset_bus(np, cmd,
-	(reset_flags & (SCSI_RESET_SYNCHRONOUS | SCSI_RESET_ASYNCHRONOUS)) == SCSI_RESET_SYNCHRONOUS);
-#else
-	sts = ncr_reset_bus(np, cmd, 0);
-#endif
+	sts = ncr_reset_bus(np, cmd, 1);
 
-	/*
-	 * Since we always reset the controller, when we return success, 
-	 * we add this information to the return code.
-	 */
-#if defined SCSI_RESET_HOST_RESET
-	if (sts == SCSI_RESET_SUCCESS)
-		sts |= SCSI_RESET_HOST_RESET;
-#endif
-
-out:
 	done_list     = np->done_list;
 	np->done_list = 0;
 	NCR_UNLOCK_NCB(np, flags);
@@ -9335,7 +9300,7 @@
 **
 **==========================================================
 */
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,27)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,27)
 static struct proc_dir_entry proc_scsi_ncr53c8xx = {
     PROC_SCSI_NCR53C8XX, 9, NAME53C8XX,
     S_IFDIR | S_IRUGO | S_IXUGO, 2
@@ -9350,7 +9315,7 @@
 */
 #ifdef	MODULE
 char *ncr53c8xx = 0;	/* command line passed by insmod */
-# if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,30)
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,30)
 MODULE_PARM(ncr53c8xx, "s");
 # endif
 #endif
@@ -9360,7 +9325,7 @@
 	return sym53c8xx__setup(str);
 }
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,13)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,13)
 #ifndef MODULE
 __setup("ncr53c8xx=", ncr53c8xx_setup);
 #endif
@@ -9469,7 +9434,7 @@
 	**    Initialize driver general stuff.
 	*/
 #ifdef SCSI_NCR_PROC_INFO_SUPPORT
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,27)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,27)
      tpnt->proc_dir  = &proc_scsi_ncr53c8xx;
 #else
      tpnt->proc_name = NAME53C8XX;
@@ -9502,10 +9467,10 @@
 */
 MODULE_LICENSE("GPL");
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 static
 #endif
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,0) || defined(MODULE)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) || defined(MODULE)
 #ifdef ENABLE_SCSI_ZALON
 Scsi_Host_Template driver_template =  {
 	.proc_name =		"zalon720",
@@ -9513,6 +9478,8 @@
 	.release =		zalon7xx_release,
 	.info =			ncr53c8xx_info,
 	.queuecommand =		ncr53c8xx_queue_command,
+	.slave_configure =	ncr53c8xx_slave_configure,
+	.eh_bus_reset_handler =	ncr53c8xx_bus_reset,
 	.can_queue =		SCSI_NCR_CAN_QUEUE,
 	.this_id =		7,
 	.sg_tablesize =		SCSI_NCR_SG_TABLESIZE,
diff -Nru a/drivers/scsi/ncr53c8xx.h b/drivers/scsi/ncr53c8xx.h
--- a/drivers/scsi/ncr53c8xx.h	Wed Apr 30 22:28:07 2003
+++ b/drivers/scsi/ncr53c8xx.h	Wed Apr 30 22:28:07 2003
@@ -63,34 +63,18 @@
 int ncr53c8xx_release(struct Scsi_Host *);
 
 
-#if	LINUX_VERSION_CODE >= LinuxVersionCode(2,1,75)
-
 #define NCR53C8XX {     .name           = "ncr53c8xx",		\
 			.detect         = ncr53c8xx_detect,	\
 			.release        = ncr53c8xx_release,	\
 			.info           = ncr53c8xx_info, 	\
 			.queuecommand   = ncr53c8xx_queue_command,\
 			.slave_configure = ncr53c8xx_slave_configure,\
-			.abort          = ncr53c8xx_abort,	\
-			.reset          = ncr53c8xx_reset,	\
+			.eh_bus_reset_handler = ncr53c8xx_bus_reset,	\
 			.can_queue      = SCSI_NCR_CAN_QUEUE,	\
 			.this_id        = 7,			\
 			.sg_tablesize   = SCSI_NCR_SG_TABLESIZE,	\
 			.cmd_per_lun    = SCSI_NCR_CMD_PER_LUN,	\
 			.use_clustering = DISABLE_CLUSTERING} 
-
-#else
-
-#define NCR53C8XX {	NULL, NULL, NULL, NULL,				\
-			NULL,			ncr53c8xx_detect,	\
-			ncr53c8xx_release,	ncr53c8xx_info,	NULL,	\
-			ncr53c8xx_queue_command,ncr53c8xx_abort,	\
-			ncr53c8xx_reset, NULL,	scsicam_bios_param,	\
-			SCSI_NCR_CAN_QUEUE,	7,			\
-			SCSI_NCR_SG_TABLESIZE,	SCSI_NCR_CMD_PER_LUN,	\
-			0,	0,	DISABLE_CLUSTERING} 
- 
-#endif /* LINUX_VERSION_CODE */
 
 #endif /* defined(HOSTS_C) || defined(MODULE) */ 
 
diff -Nru a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
--- a/drivers/scsi/nsp32.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/scsi/nsp32.c	Wed Apr 30 22:28:08 2003
@@ -26,6 +26,7 @@
 #include <linux/ioport.h>
 #include <linux/major.h>
 #include <linux/blk.h>
+#include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/ctype.h>
@@ -291,8 +292,8 @@
 static int __init init_nsp32(void);
 static void __exit exit_nsp32(void);
 
-static void nsp32_message(char *, int, char *, char *, ...);
-static void nsp32_dmessage(char *, int, int, char *, ...);
+static void nsp32_message(const char *, int, char *, char *, ...);
+static void nsp32_dmessage(const char *, int, int, char *, ...);
 static void nsp32_build_identify(nsp32_hw_data *, Scsi_Cmnd *);
 static void nsp32_build_sdtr(nsp32_hw_data *, unsigned char, unsigned char);
 static void nsp32_build_nop(nsp32_hw_data *);
@@ -318,7 +319,6 @@
 static void nsp32_sack_assert(nsp32_hw_data *);
 static void nsp32_sack_negate(nsp32_hw_data *);
 static void nsp32_do_bus_reset(nsp32_hw_data *);
-static void do_nsp32_isr(int, void *, struct pt_regs *);
 
 static int nsp32_getprom_param(nsp32_hw_data *);
 static int nsp32_getprom_new(nsp32_hw_data *);
@@ -398,7 +398,7 @@
 
 #define NSP32_DEBUG_BUF_LEN		100
 
-static void nsp32_message(char *func, int line, char *type, char *fmt, ...)
+static void nsp32_message(const char *func, int line, char *type, char *fmt, ...)
 {
 	va_list args;
 	char buf[NSP32_DEBUG_BUF_LEN];
@@ -414,7 +414,7 @@
 #endif
 }
 
-static void nsp32_dmessage(char *func, int line, int mask, char *fmt, ...)
+static void nsp32_dmessage(const char *func, int line, int mask, char *fmt, ...)
 {
 	va_list args;
 	char buf[NSP32_DEBUG_BUF_LEN];
@@ -1263,7 +1263,7 @@
 
 
 /* interrupt routine */
-static void do_nsp32_isr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t do_nsp32_isr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	nsp32_hw_data *data = dev_id;
 	unsigned int base = data->BaseAddress;
@@ -1272,6 +1272,7 @@
 	unsigned char busmon, busphase;
 	unsigned long flags;
 	int ret;
+	int handled = 0;
 
 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
 	struct Scsi_Host *host = data->Host;
@@ -1291,6 +1292,7 @@
 		nsp32_msg(KERN_INFO, "spurious interrupt: irq other 0x%x", irq_stat);
 		goto out2;
 	}
+	handled = 1;
 	nsp32_write2(base, IRQ_CONTROL, IRQ_CONTROL_ALL_IRQ_MASK);
 
 	busmon = nsp32_read1(base, SCSI_BUS_MONITOR);
@@ -1547,7 +1549,7 @@
 
 	nsp32_dbg(NSP32_DEBUG_INTR, "exit");
 
-	return;
+	return IRQ_RETVAL(handled);
 }
 
 #undef SPRINTF
diff -Nru a/drivers/scsi/nsp32.h b/drivers/scsi/nsp32.h
--- a/drivers/scsi/nsp32.h	Wed Apr 30 22:28:03 2003
+++ b/drivers/scsi/nsp32.h	Wed Apr 30 22:28:03 2003
@@ -425,5 +425,5 @@
 #define BUSPHASE_STATUS      ( BUSMON_STATUS      & BUSMON_PHASE_MASK )
 #define BUSPHASE_SELECT      ( BUSMON_SEL | BUSMON_IO )
 
-#endif _NSP32_H
+#endif	/* _NSP32_H */
 /* end */
diff -Nru a/drivers/scsi/nsp32_io.h b/drivers/scsi/nsp32_io.h
--- a/drivers/scsi/nsp32_io.h	Wed Apr 30 22:28:17 2003
+++ b/drivers/scsi/nsp32_io.h	Wed Apr 30 22:28:17 2003
@@ -265,5 +265,5 @@
 	nsp32_multi_write4(base, FIFO_DATA_LOW, buf, count);
 }
 
-#endif _NSP32_IO_H
+#endif	/* _NSP32_IO_H */
 /* end */
diff -Nru a/drivers/scsi/pas16.c b/drivers/scsi/pas16.c
--- a/drivers/scsi/pas16.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/scsi/pas16.c	Wed Apr 30 22:28:03 2003
@@ -103,11 +103,11 @@
  *   interrupts.  Ie, for a board at the default 0x388 base port,
  *   boot: linux pas16=0x388,255
  *
- *   IRQ_NONE (255) should be specified for no interrupt,
+ *   SCSI_IRQ_NONE (255) should be specified for no interrupt,
  *   IRQ_AUTO (254) to autoprobe for an IRQ line if overridden
  *   on the command line.
  *
- *   (IRQ_AUTO == 254, IRQ_NONE == 255 in NCR5380.h)
+ *   (IRQ_AUTO == 254, SCSI_IRQ_NONE == 255 in NCR5380.h)
  */
  
 #include <linux/module.h>
@@ -451,14 +451,14 @@
 	else 
 	    instance->irq = NCR5380_probe_irq(instance, PAS16_IRQS);
 
-	if (instance->irq != IRQ_NONE) 
+	if (instance->irq != SCSI_IRQ_NONE) 
 	    if (request_irq(instance->irq, pas16_intr, SA_INTERRUPT, "pas16", instance)) {
 		printk("scsi%d : IRQ%d not free, interrupts disabled\n", 
 		    instance->host_no, instance->irq);
-		instance->irq = IRQ_NONE;
+		instance->irq = SCSI_IRQ_NONE;
 	    } 
 
-	if (instance->irq == IRQ_NONE) {
+	if (instance->irq == SCSI_IRQ_NONE) {
 	    printk("scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
 	    printk("scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
 	    /* Disable 5380 interrupts, leave drive params the same */
@@ -472,7 +472,7 @@
 
 	printk("scsi%d : at 0x%04x", instance->host_no, (int) 
 	    instance->io_port);
-	if (instance->irq == IRQ_NONE)
+	if (instance->irq == SCSI_IRQ_NONE)
 	    printk (" interrupts disabled");
 	else 
 	    printk (" irq %d", instance->irq);
diff -Nru a/drivers/scsi/pci2000.c b/drivers/scsi/pci2000.c
--- a/drivers/scsi/pci2000.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/scsi/pci2000.c	Wed Apr 30 22:28:11 2003
@@ -262,7 +262,7 @@
  *	Returns:		TRUE if drive is not ready in time.
  *
  ****************************************************************/
-static void Irq_Handler (int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t Irq_Handler (int irq, void *dev_id, struct pt_regs *regs)
 	{
 	struct Scsi_Host   *shost = NULL;	// Pointer to host data block
 	PADAPTER2000		padapter;		// Pointer to adapter control structure
@@ -275,7 +275,7 @@
 	int					bus;
 	int					z;
     unsigned long		flags;
-
+    int handled = 0;
 
 	DEB(printk ("\npci2000 received interrupt "));
 	for ( z = 0; z < NumAdapters;  z++ )										// scan for interrupt to process
@@ -297,6 +297,7 @@
 		goto out;
 		}
 
+    handled = 1;
 	spin_lock_irqsave(shost->host_lock, flags);
 	padapter = HOSTDATA(shost);
 
@@ -391,7 +392,8 @@
 
 irq_return:
     spin_unlock_irqrestore(shost->host_lock, flags);
-out:;
+out:
+    return IRQ_RETVAL(handled);
 }
 /****************************************************************
  *	Name:	Pci2000_QueueCommand
diff -Nru a/drivers/scsi/pci2220i.c b/drivers/scsi/pci2220i.c
--- a/drivers/scsi/pci2220i.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/scsi/pci2220i.c	Wed Apr 30 22:28:03 2003
@@ -1586,7 +1586,7 @@
  *	Returns:		TRUE if drive is not ready in time.
  *
  ****************************************************************/
-static void Irq_Handler (int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t Irq_Handler (int irq, void *dev_id, struct pt_regs *regs)
 	{
 	struct Scsi_Host   *shost = NULL;	// Pointer to host data block
 	PADAPTER2220I		padapter;		// Pointer to adapter control structure
@@ -1600,6 +1600,7 @@
 	int					z;
 	ULONG				zl;
     unsigned long		flags;
+    int handled = 0;
 
 //	DEB (printk ("\npci2220i received interrupt\n"));
 
@@ -1621,6 +1622,7 @@
 		goto out;
 		}
 
+	handled = 1;
 	spin_lock_irqsave(shost->host_lock, flags);
 	padapter = HOSTDATA(shost);
 	pdev = padapter->pdev;
@@ -2025,8 +2027,10 @@
 	OpDone (padapter, zl);
 irq_return:
     spin_unlock_irqrestore(shost->host_lock, flags);
-out:;
-	}
+out:
+	return IRQ_RETVAL(handled);
+}
+
 /****************************************************************
  *	Name:	Pci2220i_QueueCommand
  *
diff -Nru a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c
--- a/drivers/scsi/pcmcia/aha152x_stub.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/scsi/pcmcia/aha152x_stub.c	Wed Apr 30 22:28:16 2003
@@ -113,16 +113,6 @@
 static dev_link_t *dev_list;
 static dev_info_t dev_info = "aha152x_cs";
 
-/*====================================================================*/
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
-/*====================================================================*/
-
 static dev_link_t *aha152x_attach(void)
 {
     scsi_info_t *info;
diff -Nru a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c
--- a/drivers/scsi/pcmcia/fdomain_stub.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/scsi/pcmcia/fdomain_stub.c	Wed Apr 30 22:28:10 2003
@@ -103,16 +103,6 @@
 
 static dev_info_t dev_info = "fdomain_cs";
 
-/*====================================================================*/
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-    error_info_t err = { func, ret };
-    CardServices(ReportError, handle, &err);
-}
-
-/*====================================================================*/
-
 static dev_link_t *fdomain_attach(void)
 {
     scsi_info_t *info;
diff -Nru a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
--- a/drivers/scsi/pcmcia/nsp_cs.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/scsi/pcmcia/nsp_cs.c	Wed Apr 30 22:28:19 2003
@@ -1469,13 +1469,6 @@
   PCMCIA functions
 **********************************************************************/
 
-/*====================================================================*/
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-	error_info_t err = { func, ret };
-	CardServices(ReportError, handle, &err);
-}
-
 /*======================================================================
     nsp_cs_attach() creates an "instance" of the driver, allocating
     local data structures for one device.  The device is registered
diff -Nru a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
--- a/drivers/scsi/pcmcia/qlogic_stub.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/scsi/pcmcia/qlogic_stub.c	Wed Apr 30 22:28:10 2003
@@ -102,16 +102,6 @@
 
 static dev_info_t dev_info = "qlogic_cs";
 
-/*====================================================================*/
-
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-	error_info_t err = { func, ret };
-	CardServices(ReportError, handle, &err);
-}
-
-/*====================================================================*/
-
 static dev_link_t *qlogic_attach(void)
 {
 	scsi_info_t *info;
diff -Nru a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
--- a/drivers/scsi/ppa.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/scsi/ppa.c	Wed Apr 30 22:28:10 2003
@@ -219,15 +219,12 @@
 	    printk("  supported by the imm (ZIP Plus) driver. If the\n");
 	    printk("  cable is marked with \"AutoDetect\", this is what has\n");
 	    printk("  happened.\n");
-	    spin_lock_irq(hreg->host_lock);
 	    return 0;
 	}
 	try_again = 1;
 	goto retry_entry;
-    } else {
-	spin_lock_irq(hreg->host_lock);
+    } else
 	return 1;		/* return number of hosts detected */
-    }
 }
 
 /* This is to give the ppa driver a way to modify the timings (and other
diff -Nru a/drivers/scsi/psi240i.c b/drivers/scsi/psi240i.c
--- a/drivers/scsi/psi240i.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/scsi/psi240i.c	Wed Apr 30 22:28:12 2003
@@ -54,7 +54,7 @@
 #define DEB(x)
 #endif
 
-#define MAXBOARDS 2	/* Increase this and the sizes of the arrays below, if you need more. */
+#define MAXBOARDS 6	/* Increase this and the sizes of the arrays below, if you need more. */
 
 #define	PORT_DATA				0
 #define	PORT_ERROR				1
@@ -367,15 +367,18 @@
 	SCpnt->result = DecodeError (shost, status);
 	SCpnt->scsi_done (SCpnt);
 	}
-static void do_Irq_Handler (int irq, void *dev_id, struct pt_regs *regs)
-	{
+
+static irqreturn_t do_Irq_Handler (int irq, void *dev_id, struct pt_regs *regs)
+{
 	unsigned long flags;
 	struct Scsi_Host *dev = dev_id;
 	
 	spin_lock_irqsave(dev->host_lock, flags);
 	Irq_Handler(irq, dev_id, regs);
 	spin_unlock_irqrestore(dev->host_lock, flags);
-	}
+	return IRQ_HANDLED;
+}
+
 /****************************************************************
  *	Name:	Psi240i_QueueCommand
  *
@@ -390,8 +393,8 @@
 int Psi240i_QueueCommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))
 	{
 	UCHAR		   *cdb = (UCHAR *)SCpnt->cmnd;					// Pointer to SCSI CDB
-	PADAPTER240I	padapter = HOSTDATA(SCpnt->host);			// Pointer to adapter control structure
-	POUR_DEVICE		pdev	 = &padapter->device[SCpnt->target];// Pointer to device information
+	PADAPTER240I	padapter = HOSTDATA (SCpnt->device->host); 			// Pointer to adapter control structure
+	POUR_DEVICE 		pdev	 = &padapter->device [SCpnt->device->id];// Pointer to device information
 	UCHAR			rc;											// command return code
 
 	SCpnt->scsi_done = done;
@@ -566,25 +569,25 @@
 	int					count = 0;
 	int					unit;
 	int					z;
-	USHORT				port;
+	USHORT				port, port_range = 16;
 	CHIP_CONFIG_N		chipConfig;
 	CHIP_DEVICE_N		chipDevice[8];
 	struct Scsi_Host   *pshost;
-	ULONG				flags;
 
-	for ( board = 0;  board < 6;  board++ )					// scan for I/O ports
+	for ( board = 0;  board < MAXBOARDS;  board++ )					// scan for I/O ports
 		{
+		pshost = NULL;
 		port = portAddr[board];								// get base address to test
-		if ( check_region (port, 16) )						// test for I/O addresses available
-			continue;										//   nope
-		if ( inb_p (port + REG_FAIL) != CHIP_ID )			// do the first test for likley hood that it is us
+		if ( !request_region (port, port_range, "psi240i") )
 			continue;
+		if ( inb_p (port + REG_FAIL) != CHIP_ID )			// do the first test for likley hood that it is us
+			goto host_init_failure;
 		outb_p (SEL_NONE, port + REG_SEL_FAIL);				// setup EEPROM/RAM access
 		outw (0, port + REG_ADDRESS);						// setup EEPROM address zero
 		if ( inb_p (port) != 0x55 )							// test 1st byte
-			continue;										//   nope
+			goto host_init_failure;									//   nope
 		if ( inb_p (port + 1) != 0xAA )						// test 2nd byte
-			continue;										//   nope
+			goto host_init_failure;								//   nope
 
 		// at this point our board is found and can be accessed.  Now we need to initialize
 		// our informatation and register with the kernel.
@@ -595,20 +598,11 @@
 		ReadChipMemory (&ChipSetup, CHIP_EEPROM_DATA, sizeof (ChipSetup), port);
 
 		if ( !chipConfig.numDrives )						// if no devices on this board
-			continue;
+			goto host_init_failure;
 
 		pshost = scsi_register (tpnt, sizeof(ADAPTER240I));
 		if(pshost == NULL)
-			continue;
-
-		save_flags (flags);
-		cli ();
-		if ( request_irq (chipConfig.irq, do_Irq_Handler, 0, "psi240i", pshost) )
-			{
-			printk ("Unable to allocate IRQ for PSI-240I controller.\n");
-			restore_flags (flags);
-			goto unregister;
-			}
+			goto host_init_failure;	
 
 		PsiHost[chipConfig.irq - 10] = pshost;
 		pshost->unique_id = port;
@@ -642,14 +636,22 @@
 			DEB (printk ("\n          blocks    = %lX", HOSTDATA(pshost)->device[unit].blocks));
 			}
 
-		restore_flags (flags);
-		printk("\nPSI-240I EIDE CONTROLLER: at I/O = %x  IRQ = %d\n", port, chipConfig.irq);
-		printk("(C) 1997 Perceptive Solutions, Inc. All rights reserved\n\n");
-		count++;
-		continue;
+		if ( request_irq (chipConfig.irq, do_Irq_Handler, 0, "psi240i", pshost) == 0 ) 
+			{
+			printk("\nPSI-240I EIDE CONTROLLER: at I/O = %x  IRQ = %d\n", port, chipConfig.irq);
+		        printk("(C) 1997 Perceptive Solutions, Inc. All rights reserved\n\n");
+		        count++;
+		        continue;
+			}
+
+		printk ("Unable to allocate IRQ for PSI-240I controller.\n");
+           
+host_init_failure:
+		
+		release_region (port, port_range);
+		if (pshost)
+			scsi_unregister (pshost);
 
-unregister:;
-		scsi_unregister (pshost);
 		}
 	return count;
 	}
diff -Nru a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
--- a/drivers/scsi/qla1280.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/scsi/qla1280.c	Wed Apr 30 22:28:20 2003
@@ -1736,11 +1736,12 @@
  * qla1280_intr_handler
  *   Handles the H/W interrupt
  **************************************************************************/
-void
+irqreturn_t
 qla1280_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct scsi_qla_host *ha;
 	struct device_reg *reg;
+	int handled = 0;
 	u16 data;
 
 	ENTER_INTR ("qla1280_intr_handler");
@@ -1757,6 +1758,7 @@
 	/* Check for pending interrupts. */
 	if (data & RISC_INT) {
 		qla1280_isr(ha, &ha->done_q_first, &ha->done_q_last);
+		handled = 1;
 	} else {
 		/* spurious interrupts can happen legally */
 		dprintk(1, "scsi(%ld): Spurious interrupt - ignoring\n",
@@ -1772,6 +1774,7 @@
 	WRT_REG_WORD(&reg->ictrl, (ISP_EN_INT | ISP_EN_RISC));
 
 	LEAVE_INTR("qla1280_intr_handler");
+	return IRQ_RETVAL(handled);
 }
 
 /**************************************************************************
diff -Nru a/drivers/scsi/qla1280.h b/drivers/scsi/qla1280.h
--- a/drivers/scsi/qla1280.h	Wed Apr 30 22:28:19 2003
+++ b/drivers/scsi/qla1280.h	Wed Apr 30 22:28:19 2003
@@ -1316,7 +1316,7 @@
 int qla1280_biosparam(struct scsi_device *, struct block_device *,
 		sector_t, int[]);
 static int qla1280_slave_configure(Scsi_Device *);
-void qla1280_intr_handler(int, void *, struct pt_regs *);
+irqreturn_t qla1280_intr_handler(int, void *, struct pt_regs *);
 void qla1280_setup(char *s, int *dummy);
 
 /*
diff -Nru a/drivers/scsi/qlogicfas.c b/drivers/scsi/qlogicfas.c
--- a/drivers/scsi/qlogicfas.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/scsi/qlogicfas.c	Wed Apr 30 22:28:20 2003
@@ -288,7 +288,9 @@
 
 static int ql_wai(void)
 {
-	int i, k;
+	int k;
+	unsigned long i;
+
 	k = 0;
 	i = jiffies + WATCHDOG;
 	while (time_before(jiffies, i) && !qabort && !((k = inb(qbase + 4)) & 0xe0)) {
@@ -359,7 +361,8 @@
 
 static unsigned int ql_pcmd(Scsi_Cmnd * cmd)
 {
-	unsigned int i, j, k;
+	unsigned int i, j;
+	unsigned long k;
 	unsigned int result;	/* ultimate return result */
 	unsigned int status;	/* scsi returned status */
 	unsigned int message;	/* scsi returned message */
@@ -526,7 +529,7 @@
 	(icmd->scsi_done) (icmd);
 }
 
-static void do_ql_ihandl(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t do_ql_ihandl(int irq, void *dev_id, struct pt_regs *regs)
 {
 	unsigned long flags;
 	struct Scsi_Host *host = dev_id;
@@ -534,6 +537,7 @@
 	spin_lock_irqsave(host->host_lock, flags);
 	ql_ihandl(irq, dev_id, regs);
 	spin_unlock_irqrestore(host->host_lock, flags);
+	return IRQ_HANDLED;
 }
 
 #endif
diff -Nru a/drivers/scsi/qlogicfc.c b/drivers/scsi/qlogicfc.c
--- a/drivers/scsi/qlogicfc.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/scsi/qlogicfc.c	Wed Apr 30 22:28:13 2003
@@ -660,7 +660,7 @@
 static int isp2x00_mbox_command(struct Scsi_Host *, u_short[]);
 static int isp2x00_return_status(Scsi_Cmnd *, struct Status_Entry *);
 static void isp2x00_intr_handler(int, void *, struct pt_regs *);
-static void do_isp2x00_intr_handler(int, void *, struct pt_regs *);
+static irqreturn_t do_isp2x00_intr_handler(int, void *, struct pt_regs *);
 static int isp2x00_make_portdb(struct Scsi_Host *);
 
 #if ISP2x00_FABRIC
@@ -1421,7 +1421,7 @@
 
 #define ASYNC_EVENT_INTERRUPT	0x01
 
-void do_isp2x00_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t do_isp2x00_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct Scsi_Host *host = dev_id;
 	unsigned long flags;
@@ -1429,6 +1429,8 @@
 	spin_lock_irqsave(host->host_lock, flags);
 	isp2x00_intr_handler(irq, dev_id, regs);
 	spin_unlock_irqrestore(host->host_lock, flags);
+
+	return IRQ_HANDLED;
 }
 
 void isp2x00_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
diff -Nru a/drivers/scsi/qlogicisp.c b/drivers/scsi/qlogicisp.c
--- a/drivers/scsi/qlogicisp.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/scsi/qlogicisp.c	Wed Apr 30 22:28:19 2003
@@ -606,7 +606,7 @@
 static int	isp1020_mbox_command(struct Scsi_Host *, u_short []); 
 static int	isp1020_return_status(struct Status_Entry *);
 static void	isp1020_intr_handler(int, void *, struct pt_regs *);
-static void	do_isp1020_intr_handler(int, void *, struct pt_regs *);
+static irqreturn_t do_isp1020_intr_handler(int, void *, struct pt_regs *);
 
 #if USE_NVRAM_DEFAULTS
 static int	isp1020_get_defaults(struct Scsi_Host *);
@@ -965,7 +965,7 @@
 
 #define ASYNC_EVENT_INTERRUPT	0x01
 
-void do_isp1020_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t do_isp1020_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct Scsi_Host *host = dev_id;
 	unsigned long flags;
@@ -973,6 +973,8 @@
 	spin_lock_irqsave(host->host_lock, flags);
 	isp1020_intr_handler(irq, dev_id, regs);
 	spin_unlock_irqrestore(host->host_lock, flags);
+
+	return IRQ_HANDLED;
 }
 
 void isp1020_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
diff -Nru a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
--- a/drivers/scsi/qlogicpti.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/scsi/qlogicpti.c	Wed Apr 30 22:28:12 2003
@@ -644,7 +644,7 @@
 	return 0;
 }
 
-static void qpti_intr(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t qpti_intr(int irq, void *dev_id, struct pt_regs *regs);
 
 static void __init qpti_chain_add(struct qlogicpti *qpti)
 {
@@ -1441,7 +1441,7 @@
 	return done_queue;
 }
 
-static void qpti_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t qpti_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct qlogicpti *qpti = dev_id;
 	unsigned long flags;
@@ -1463,6 +1463,8 @@
 		spin_unlock(qpti->qhost->host_lock);
 	}
 	local_irq_restore(flags);
+
+	return IRQ_HANDLED;
 }
 
 static int qlogicpti_abort(Scsi_Cmnd *Cmnd)
diff -Nru a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
--- a/drivers/scsi/scsi.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/scsi/scsi.c	Wed Apr 30 22:28:09 2003
@@ -38,38 +38,24 @@
 
 #include <linux/config.h>
 #include <linux/module.h>
-
+#include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/timer.h>
 #include <linux/string.h>
 #include <linux/slab.h>
-#include <linux/ioport.h>
-#include <linux/kernel.h>
-#include <linux/stat.h>
-#include <linux/blk.h>
-#include <linux/interrupt.h>
+#include <linux/blkdev.h>
 #include <linux/delay.h>
 #include <linux/init.h>
-#include <linux/smp_lock.h>
 #include <linux/completion.h>
-
-#define __KERNEL_SYSCALLS__
-
+#include <linux/devfs_fs_kernel.h>
 #include <linux/unistd.h>
 #include <linux/spinlock.h>
-
-#include <asm/system.h>
-#include <asm/irq.h>
-#include <asm/dma.h>
-#include <asm/uaccess.h>
+#include <linux/kmod.h>
+#include <linux/interrupt.h>
 
 #include "scsi.h"
 #include "hosts.h"
 
-#ifdef CONFIG_KMOD
-#include <linux/kmod.h>
-#endif
-
 
 /*
  * Definitions and constants.
@@ -86,18 +72,16 @@
  * vendor unique and we will depend upon the command length being
  * supplied correctly in cmd_len.
  */
-#define CDB_SIZE(SCpnt)	((((SCpnt->cmnd[0] >> 5) & 7) < 6) ? \
-				COMMAND_SIZE(SCpnt->cmnd[0]) : SCpnt->cmd_len)
+#define CDB_SIZE(cmd)	(((((cmd)->cmnd[0] >> 5) & 7) < 6) ? \
+				COMMAND_SIZE((cmd)->cmnd[0]) : (cmd)->cmd_len)
 
 /*
  * Data declarations.
  */
 unsigned long scsi_pid;
-Scsi_Cmnd *last_cmnd;
+struct scsi_cmnd *last_cmnd;
 static unsigned long serial_number;
 
-static struct list_head done_q[NR_CPUS] __cacheline_aligned;
-
 /*
  * List of all highlevel drivers.
  */
@@ -110,8 +94,7 @@
  */
 unsigned int scsi_logging_level;
 
-const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE] =
-{
+const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE] = {
 	"Direct-Access    ",
 	"Sequential-Access",
 	"Printer          ",
@@ -136,14 +119,12 @@
 /* 
  * Function prototypes.
  */
-extern void scsi_times_out(Scsi_Cmnd * SCpnt);
+extern void scsi_times_out(struct scsi_cmnd *cmd);
 
-#ifdef MODULE
 MODULE_PARM(scsi_logging_level, "i");
 MODULE_PARM_DESC(scsi_logging_level, "SCSI logging level; should be zero or nonzero");
 
-#else
-
+#ifndef MODULE
 static int __init scsi_logging_setup(char *str)
 {
 	int tmp;
@@ -157,9 +138,7 @@
 		return 0;
 	}
 }
-
 __setup("scsi_logging=", scsi_logging_setup);
-
 #endif
 
 /*
@@ -177,30 +156,26 @@
  *              to track the difference between a command and a
  *              request.  A request is a pending item in the queue that
  *              has not yet reached the top of the queue.
+ *
+ * XXX(hch):	Need to add a gfp_mask argument.
  */
-
-Scsi_Request *scsi_allocate_request(Scsi_Device * device)
+struct scsi_request *scsi_allocate_request(struct scsi_device *sdev)
 {
-  	Scsi_Request *SRpnt = NULL;
-        const int offset = ALIGN(sizeof(Scsi_Request), 4);
-        const int size = offset + sizeof(struct request);
-  
-  	if (!device)
-  		panic("No device passed to scsi_allocate_request().\n");
+	const int offset = ALIGN(sizeof(struct scsi_request), 4);
+	const int size = offset + sizeof(struct request);
+	struct scsi_request *sreq;
   
-        SRpnt = (Scsi_Request *) kmalloc(size, GFP_ATOMIC);
-	if( SRpnt == NULL )
-	{
-		return NULL;
-	}
-	memset(SRpnt, 0, size);
-        SRpnt->sr_request = (struct request *)(((char *)SRpnt) + offset);
-	SRpnt->sr_device = device;
-	SRpnt->sr_host = device->host;
-	SRpnt->sr_magic = SCSI_REQ_MAGIC;
-	SRpnt->sr_data_direction = SCSI_DATA_UNKNOWN;
+	sreq = kmalloc(size, GFP_ATOMIC);
+	if (likely(sreq != NULL)) {
+		memset(sreq, 0, size);
+		sreq->sr_request = (struct request *)(((char *)sreq) + offset);
+		sreq->sr_device = sdev;
+		sreq->sr_host = sdev->host;
+		sreq->sr_magic = SCSI_REQ_MAGIC;
+		sreq->sr_data_direction = SCSI_DATA_UNKNOWN;
+	}
 
-	return SRpnt;
+	return sreq;
 }
 
 /*
@@ -208,27 +183,21 @@
  *
  * Purpose:     Release a request descriptor.
  *
- * Arguments:   device    - device for which we want a request
+ * Arguments:   sreq    - request to release
  *
  * Lock status: No locks assumed to be held.  This function is SMP-safe.
- *
- * Returns:     Pointer to request block.
- *
- * Notes:       With the new queueing code, it becomes important
- *              to track the difference between a command and a
- *              request.  A request is a pending item in the queue that
- *              has not yet reached the top of the queue.  We still need
- *              to free a request when we are done with it, of course.
  */
-void scsi_release_request(Scsi_Request * req)
+void scsi_release_request(struct scsi_request *sreq)
 {
-	if( req->sr_command != NULL )
-	{
-		scsi_put_command(req->sr_command);
-		req->sr_command = NULL;
+	if (likely(sreq->sr_command != NULL)) {
+    		struct request_queue *q = sreq->sr_device->request_queue;
+
+		scsi_put_command(sreq->sr_command);
+		sreq->sr_command = NULL;
+		scsi_queue_next_request(q, NULL);
 	}
 
-	kfree(req);
+	kfree(sreq);
 }
 
 struct scsi_host_cmd_pool {
@@ -422,42 +391,31 @@
  *
  * Purpose:     Dispatch a command to the low-level driver.
  *
- * Arguments:   SCpnt - command block we are dispatching.
+ * Arguments:   cmd - command block we are dispatching.
  *
  * Notes:
  */
-int scsi_dispatch_cmd(Scsi_Cmnd * SCpnt)
+int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
 {
-#ifdef DEBUG_DELAY
-	unsigned long clock;
-#endif
-	struct Scsi_Host *host;
-	int rtn = 0;
+	struct Scsi_Host *host = cmd->device->host;
 	unsigned long flags = 0;
 	unsigned long timeout;
-
-#if DEBUG
-	unsigned long *ret = 0;
-#ifdef __mips__
-	__asm__ __volatile__("move\t%0,$31":"=r"(ret));
-#else
-	ret = __builtin_return_address(0);
-#endif
-#endif
-
-	host = SCpnt->device->host;
+	int rtn = 1;
 
 	/* Assign a unique nonzero serial_number. */
+	/* XXX(hch): this is racy */
 	if (++serial_number == 0)
 		serial_number = 1;
-	SCpnt->serial_number = serial_number;
-	SCpnt->pid = scsi_pid++;
+	cmd->serial_number = serial_number;
+	cmd->pid = scsi_pid++;
+
 	/* 
 	 * If SCSI-2 or lower, store the LUN value in cmnd.
 	 */
-	if (SCpnt->device->scsi_level <= SCSI_2)
-		SCpnt->cmnd[1] = (SCpnt->cmnd[1] & 0x1f) |
-			(SCpnt->device->lun << 5 & 0xe0);
+	if (cmd->device->scsi_level <= SCSI_2) {
+		cmd->cmnd[1] = (cmd->cmnd[1] & 0x1f) |
+			       (cmd->device->lun << 5 & 0xe0);
+	}
 
 	/*
 	 * We will wait MIN_RESET_DELAY clock ticks after the last reset so
@@ -481,65 +439,63 @@
 		host->resetting = 0;
 	}
 
-	scsi_add_timer(SCpnt, SCpnt->timeout_per_command, scsi_times_out);
+	scsi_add_timer(cmd, cmd->timeout_per_command, scsi_times_out);
 
 	/*
-	 * We will use a queued command if possible, otherwise we will emulate the
-	 * queuing and calling of completion function ourselves.
+	 * We will use a queued command if possible, otherwise we will
+	 * emulate the queuing and calling of completion function ourselves.
 	 */
-	SCSI_LOG_MLQUEUE(3, printk("scsi_dispatch_cmnd (host = %d, channel = %d, target = %d, "
-	       "command = %p, buffer = %p, \nbufflen = %d, done = %p)\n",
-	SCpnt->device->host->host_no, SCpnt->device->channel, SCpnt->device->id, SCpnt->cmnd,
-			    SCpnt->buffer, SCpnt->bufflen, SCpnt->done));
+	SCSI_LOG_MLQUEUE(3, printk("scsi_dispatch_cmnd (host = %d, "
+				"channel = %d, target = %d, command = %p, "
+				"buffer = %p, \nbufflen = %d, done = %p)\n",
+				host->host_no, cmd->device->channel,
+				cmd->device->id, cmd->cmnd, cmd->buffer,
+				cmd->bufflen, cmd->done));
+
+	cmd->state = SCSI_STATE_QUEUED;
+	cmd->owner = SCSI_OWNER_LOWLEVEL;
+
+	/*
+	 * Before we queue this command, check if the command
+	 * length exceeds what the host adapter can handle.
+	 */
+	if (CDB_SIZE(cmd) > cmd->device->host->max_cmd_len) {
+		SCSI_LOG_MLQUEUE(3,
+				printk("queuecommand : command too long.\n"));
+		cmd->result = (DID_ABORT << 16);
+
+		spin_lock_irqsave(host->host_lock, flags);
+		scsi_done(cmd);
+		spin_unlock_irqrestore(host->host_lock, flags);
+		goto out;
+	}
 
-	SCpnt->state = SCSI_STATE_QUEUED;
-	SCpnt->owner = SCSI_OWNER_LOWLEVEL;
 	if (host->can_queue) {
 		SCSI_LOG_MLQUEUE(3, printk("queuecommand : routine at %p\n",
 					   host->hostt->queuecommand));
-		/*
-		 * Before we queue this command, check if the command
-		 * length exceeds what the host adapter can handle.
-		 */
-		if (CDB_SIZE(SCpnt) <= SCpnt->device->host->max_cmd_len) {
-			spin_lock_irqsave(host->host_lock, flags);
-			rtn = host->hostt->queuecommand(SCpnt, scsi_done);
-			spin_unlock_irqrestore(host->host_lock, flags);
-			if (rtn != 0) {
-				scsi_queue_insert(SCpnt, rtn == SCSI_MLQUEUE_DEVICE_BUSY ? rtn : SCSI_MLQUEUE_HOST_BUSY);
-				SCSI_LOG_MLQUEUE(3,
-				   printk("queuecommand : request rejected\n"));                                
-			}
-		} else {
+
+		spin_lock_irqsave(host->host_lock, flags);
+		rtn = host->hostt->queuecommand(cmd, scsi_done);
+		spin_unlock_irqrestore(host->host_lock, flags);
+		if (rtn) {
+			scsi_queue_insert(cmd,
+				(rtn == SCSI_MLQUEUE_DEVICE_BUSY) ?
+					rtn : SCSI_MLQUEUE_HOST_BUSY);
 			SCSI_LOG_MLQUEUE(3,
-				printk("queuecommand : command too long.\n"));
-			SCpnt->result = (DID_ABORT << 16);
-			spin_lock_irqsave(host->host_lock, flags);
-			scsi_done(SCpnt);
-			spin_unlock_irqrestore(host->host_lock, flags);
-			rtn = 1;
+			    printk("queuecommand : request rejected\n"));
 		}
 	} else {
-		int temp;
+		SCSI_LOG_MLQUEUE(3, printk("command() :  routine at %p\n",
+					host->hostt->command));
 
-		SCSI_LOG_MLQUEUE(3, printk("command() :  routine at %p\n", host->hostt->command));
-                spin_lock_irqsave(host->host_lock, flags);
-		temp = host->hostt->command(SCpnt);
-		SCpnt->result = temp;
-#ifdef DEBUG_DELAY
-                spin_unlock_irqrestore(host->host_lock, flags);
-		clock = jiffies + 4 * HZ;
-		while (time_before(jiffies, clock)) {
-			barrier();
-			cpu_relax();
-		}
-		printk("done(host = %d, result = %04x) : routine at %p\n",
-		       host->host_no, temp, host->hostt->command);
-                spin_lock_irqsave(host->host_lock, flags);
-#endif
-		scsi_done(SCpnt);
-                spin_unlock_irqrestore(host->host_lock, flags);
+		spin_lock_irqsave(host->host_lock, flags);
+		cmd->result = host->hostt->command(cmd);
+		scsi_done(cmd);
+		spin_unlock_irqrestore(host->host_lock, flags);
+		rtn = 0;
 	}
+
+ out:
 	SCSI_LOG_MLQUEUE(3, printk("leaving scsi_dispatch_cmnd()\n"));
 	return rtn;
 }
@@ -548,10 +504,10 @@
  * Function:    scsi_init_cmd_from_req
  *
  * Purpose:     Queue a SCSI command
- * Purpose:     Initialize a Scsi_Cmnd from a Scsi_Request
+ * Purpose:     Initialize a struct scsi_cmnd from a struct scsi_request
  *
- * Arguments:   SCpnt     - command descriptor.
- *              SRpnt     - Request from the queue.
+ * Arguments:   cmd       - command descriptor.
+ *              sreq      - Request from the queue.
  *
  * Lock status: None needed.
  *
@@ -568,65 +524,61 @@
  *              The request structure is generally used by ioctls and character
  *              devices.
  */
-void scsi_init_cmd_from_req(Scsi_Cmnd * SCpnt, Scsi_Request * SRpnt)
+void scsi_init_cmd_from_req(struct scsi_cmnd *cmd, struct scsi_request *sreq)
 {
-	struct Scsi_Host *host = SCpnt->device->host;
+	sreq->sr_command = cmd;
 
-	SCpnt->owner = SCSI_OWNER_MIDLEVEL;
-	SRpnt->sr_command = SCpnt;
+	cmd->owner = SCSI_OWNER_MIDLEVEL;
+	cmd->cmd_len = sreq->sr_cmd_len;
+	cmd->use_sg = sreq->sr_use_sg;
 
-	if (!host) {
-		panic("Invalid or not present host.\n");
-	}
-
-	SCpnt->cmd_len = SRpnt->sr_cmd_len;
-	SCpnt->use_sg = SRpnt->sr_use_sg;
-
-        SCpnt->request = SRpnt->sr_request;
-	memcpy((void *) SCpnt->data_cmnd, (const void *) SRpnt->sr_cmnd, 
-	       sizeof(SCpnt->data_cmnd));
-	SCpnt->reset_chain = NULL;
-	SCpnt->serial_number = 0;
-	SCpnt->serial_number_at_timeout = 0;
-	SCpnt->bufflen = SRpnt->sr_bufflen;
-	SCpnt->buffer = SRpnt->sr_buffer;
-	SCpnt->flags = 0;
-	SCpnt->retries = 0;
-	SCpnt->allowed = SRpnt->sr_allowed;
-	SCpnt->done = SRpnt->sr_done;
-	SCpnt->timeout_per_command = SRpnt->sr_timeout_per_command;
-
-	SCpnt->sc_data_direction = SRpnt->sr_data_direction;
-
-	SCpnt->sglist_len = SRpnt->sr_sglist_len;
-	SCpnt->underflow = SRpnt->sr_underflow;
-
-	SCpnt->sc_request = SRpnt;
+	cmd->request = sreq->sr_request;
+	memcpy(cmd->data_cmnd, sreq->sr_cmnd, sizeof(cmd->data_cmnd));
+	cmd->reset_chain = NULL;
+	cmd->serial_number = 0;
+	cmd->serial_number_at_timeout = 0;
+	cmd->bufflen = sreq->sr_bufflen;
+	cmd->buffer = sreq->sr_buffer;
+	cmd->flags = 0;
+	cmd->retries = 0;
+	cmd->allowed = sreq->sr_allowed;
+	cmd->done = sreq->sr_done;
+	cmd->timeout_per_command = sreq->sr_timeout_per_command;
+	cmd->sc_data_direction = sreq->sr_data_direction;
+	cmd->sglist_len = sreq->sr_sglist_len;
+	cmd->underflow = sreq->sr_underflow;
+	cmd->sc_request = sreq;
+	memcpy(cmd->cmnd, sreq->sr_cmnd, sizeof(sreq->sr_cmnd));
 
-	memcpy((void *) SCpnt->cmnd, (const void *) SRpnt->sr_cmnd, 
-	       sizeof(SCpnt->cmnd));
-	/* Zero the sense buffer.  Some host adapters automatically request
+	/*
+	 * Zero the sense buffer.  Some host adapters automatically request
 	 * sense on error.  0 is not a valid sense code.
 	 */
-	memset((void *) SCpnt->sense_buffer, 0, sizeof SCpnt->sense_buffer);
-	SCpnt->request_buffer = SRpnt->sr_buffer;
-	SCpnt->request_bufflen = SRpnt->sr_bufflen;
-	SCpnt->old_use_sg = SCpnt->use_sg;
-	if (SCpnt->cmd_len == 0)
-		SCpnt->cmd_len = COMMAND_SIZE(SCpnt->cmnd[0]);
-	SCpnt->old_cmd_len = SCpnt->cmd_len;
-	SCpnt->sc_old_data_direction = SCpnt->sc_data_direction;
-	SCpnt->old_underflow = SCpnt->underflow;
-
-	/* Start the timer ticking.  */
-
-	SCpnt->internal_timeout = NORMAL_TIMEOUT;
-	SCpnt->abort_reason = 0;
-	SCpnt->result = 0;
+	memset(cmd->sense_buffer, 0, sizeof(sreq->sr_sense_buffer));
+	cmd->request_buffer = sreq->sr_buffer;
+	cmd->request_bufflen = sreq->sr_bufflen;
+	cmd->old_use_sg = cmd->use_sg;
+	if (cmd->cmd_len == 0)
+		cmd->cmd_len = COMMAND_SIZE(cmd->cmnd[0]);
+	cmd->old_cmd_len = cmd->cmd_len;
+	cmd->sc_old_data_direction = cmd->sc_data_direction;
+	cmd->old_underflow = cmd->underflow;
+
+	/*
+	 * Start the timer ticking.
+	 */
+	cmd->internal_timeout = NORMAL_TIMEOUT;
+	cmd->abort_reason = 0;
+	cmd->result = 0;
 
 	SCSI_LOG_MLQUEUE(3, printk("Leaving scsi_init_cmd_from_req()\n"));
 }
 
+/*
+ * Per-CPU I/O completion queue.
+ */
+static struct list_head done_q[NR_CPUS] __cacheline_aligned;
+
 /**
  * scsi_done - Enqueue the finished SCSI command into the done queue.
  * @cmd: The SCSI Command for which a low-level device driver (LLDD) gives
@@ -642,9 +594,8 @@
  */
 void scsi_done(struct scsi_cmnd *cmd)
 {
-	int cpu;
 	unsigned long flags;
-	struct list_head *pdone_q;
+	int cpu;
 
 	/*
 	 * We don't have to worry about this one timing out any more.
@@ -657,7 +608,9 @@
 	if (!scsi_delete_timer(cmd))
 		return;
 
-	/* Set the serial numbers back to zero */
+	/*
+	 * Set the serial numbers back to zero
+	 */
 	cmd->serial_number = 0;
 	cmd->serial_number_at_timeout = 0;
 	cmd->state = SCSI_STATE_BHQUEUE;
@@ -669,12 +622,9 @@
 	 * and need no spinlock.
 	 */
 	local_irq_save(flags);
-
 	cpu = smp_processor_id();
-	pdone_q = &done_q[cpu];
-	list_add_tail(&cmd->eh_entry, pdone_q);
+	list_add_tail(&cmd->eh_entry, &done_q[cpu]);
 	cpu_raise_softirq(cpu, SCSI_SOFTIRQ);
-
 	local_irq_restore(flags);
 }
 
@@ -762,17 +712,15 @@
 			/*
 			 * Dump the sense information too.
 			 */
-			if ((status_byte(cmd->result)&CHECK_CONDITION) != 0) {
+			if (status_byte(cmd->result) & CHECK_CONDITION)
 				SCSI_LOG_MLCOMPLETE(3, print_sense("bh", cmd));
-			}
 
-			if (!scsi_eh_scmd_add(cmd, 0)) {
-				/*
-				 * We only get here if the error
-				 * recovery thread has died.
-				 */
+			/*
+			 * We only fail here if the error recovery thread
+			 * has died.
+			 */
+			if (!scsi_eh_scmd_add(cmd, 0))
 				scsi_finish_command(cmd);
-			}
 		}
 	}
 }
@@ -787,20 +735,20 @@
  *              level drivers should not become re-entrant as a result of
  *              this.
  */
-int scsi_retry_command(Scsi_Cmnd * SCpnt)
+int scsi_retry_command(struct scsi_cmnd *cmd)
 {
 	/*
 	 * Restore the SCSI command state.
 	 */
-	scsi_setup_cmd_retry(SCpnt);
+	scsi_setup_cmd_retry(cmd);
 
         /*
          * Zero the sense information from the last time we tried
          * this command.
          */
-	memset((void *) SCpnt->sense_buffer, 0, sizeof SCpnt->sense_buffer);
+	memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
 
-	return scsi_dispatch_cmd(SCpnt);
+	return scsi_dispatch_cmd(cmd);
 }
 
 /*
@@ -810,68 +758,66 @@
  *              request, waking processes that are waiting on results,
  *              etc.
  */
-void scsi_finish_command(Scsi_Cmnd * SCpnt)
+void scsi_finish_command(struct scsi_cmnd *cmd)
 {
-	struct Scsi_Host *host;
-	Scsi_Device *device;
-	Scsi_Request * SRpnt;
+	struct scsi_device *sdev = cmd->device;
+	struct Scsi_Host *shost = sdev->host;
+	struct scsi_request *sreq;
 	unsigned long flags;
 
-	host = SCpnt->device->host;
-	device = SCpnt->device;
+	scsi_host_busy_dec_and_test(shost, sdev);
 
-        /*
-         * We need to protect the decrement, as otherwise a race condition
-         * would exist.  Fiddling with SCpnt isn't a problem as the
-         * design only allows a single SCpnt to be active in only
-         * one execution context, but the device and host structures are
-         * shared.
-         */
-	scsi_host_busy_dec_and_test(host, device);
-	spin_lock_irqsave(SCpnt->device->request_queue->queue_lock, flags);
-	SCpnt->device->device_busy--;
-	spin_unlock_irqrestore(SCpnt->device->request_queue->queue_lock, flags);
+	/*
+	 * XXX(hch): We really want a nice helper for this..
+	 */
+	spin_lock_irqsave(&sdev->sdev_lock, flags);
+	sdev->device_busy--;
+	spin_unlock_irqrestore(&sdev->sdev_lock, flags);
 
         /*
          * Clear the flags which say that the device/host is no longer
          * capable of accepting new commands.  These are set in scsi_queue.c
          * for both the queue full condition on a device, and for a
          * host full condition on the host.
+	 *
+	 * XXX(hch): What about locking?
          */
-        host->host_blocked = 0;
-        device->device_blocked = 0;
+        shost->host_blocked = 0;
+        sdev->device_blocked = 0;
 
 	/*
 	 * If we have valid sense information, then some kind of recovery
 	 * must have taken place.  Make a note of this.
 	 */
-	if (SCSI_SENSE_VALID(SCpnt)) {
-		SCpnt->result |= (DRIVER_SENSE << 24);
-	}
-	SCSI_LOG_MLCOMPLETE(3, printk("Notifying upper driver of completion for device %d %x\n",
-				      SCpnt->device->id, SCpnt->result));
+	if (SCSI_SENSE_VALID(cmd))
+		cmd->result |= (DRIVER_SENSE << 24);
+
+	SCSI_LOG_MLCOMPLETE(3, printk("Notifying upper driver of completion "
+				"for device %d %x\n", sdev->id, cmd->result));
 
-	SCpnt->owner = SCSI_OWNER_HIGHLEVEL;
-	SCpnt->state = SCSI_STATE_FINISHED;
+	cmd->owner = SCSI_OWNER_HIGHLEVEL;
+	cmd->state = SCSI_STATE_FINISHED;
+
+	/*
+	 * We can get here with use_sg=0, causing a panic in the upper level
+	 */
+	cmd->use_sg = cmd->old_use_sg;
 
-	/* We can get here with use_sg=0, causing a panic in the upper level (DB) */
-	SCpnt->use_sg = SCpnt->old_use_sg;
-
-       /*
-	* If there is an associated request structure, copy the data over before we call the
-	* completion function.
-	*/
-	SRpnt = SCpnt->sc_request;
-	if( SRpnt != NULL ) {
-	       SRpnt->sr_result = SRpnt->sr_command->result;
-	       if( SRpnt->sr_result != 0 ) {
-		       memcpy(SRpnt->sr_sense_buffer,
-			      SRpnt->sr_command->sense_buffer,
-			      sizeof(SRpnt->sr_sense_buffer));
+	/*
+	 * If there is an associated request structure, copy the data over
+	 * before we call the completion function.
+	 */
+	sreq = cmd->sc_request;
+	if (sreq) {
+	       sreq->sr_result = sreq->sr_command->result;
+	       if (sreq->sr_result) {
+		       memcpy(sreq->sr_sense_buffer,
+			      sreq->sr_command->sense_buffer,
+			      sizeof(sreq->sr_sense_buffer));
 	       }
 	}
 
-	SCpnt->done(SCpnt);
+	cmd->done(cmd);
 }
 
 /*
@@ -880,7 +826,7 @@
  * Purpose:	Allow low level drivers to tell us to change the queue depth
  * 		on a specific SCSI device
  *
- * Arguments:	SDpnt	- SCSI Device in question
+ * Arguments:	sdev	- SCSI Device in question
  * 		tagged	- Do we use tagged queueing (non-0) or do we treat
  * 			  this device as an untagged device (0)
  * 		tags	- Number of tags allowed if tagged queueing enabled,
@@ -895,8 +841,10 @@
  * 		the right thing depending on whether or not the device is
  * 		currently active and whether or not it even has the
  * 		command blocks built yet.
+ *
+ * XXX(hch):	What exactly is device_request_lock trying to protect?
  */
-void scsi_adjust_queue_depth(Scsi_Device *SDpnt, int tagged, int tags)
+void scsi_adjust_queue_depth(struct scsi_device *sdev, int tagged, int tags)
 {
 	static spinlock_t device_request_lock = SPIN_LOCK_UNLOCKED;
 	unsigned long flags;
@@ -904,35 +852,35 @@
 	/*
 	 * refuse to set tagged depth to an unworkable size
 	 */
-	if(tags <= 0)
+	if (tags <= 0)
 		return;
 	/*
 	 * Limit max queue depth on a single lun to 256 for now.  Remember,
 	 * we allocate a struct scsi_command for each of these and keep it
 	 * around forever.  Too deep of a depth just wastes memory.
 	 */
-	if(tags > 256)
+	if (tags > 256)
 		return;
 
 	spin_lock_irqsave(&device_request_lock, flags);
-	SDpnt->queue_depth = tags;
-	switch(tagged) {
+	sdev->queue_depth = tags;
+	switch (tagged) {
 		case MSG_ORDERED_TAG:
-			SDpnt->ordered_tags = 1;
-			SDpnt->simple_tags = 1;
+			sdev->ordered_tags = 1;
+			sdev->simple_tags = 1;
 			break;
 		case MSG_SIMPLE_TAG:
-			SDpnt->ordered_tags = 0;
-			SDpnt->simple_tags = 1;
+			sdev->ordered_tags = 0;
+			sdev->simple_tags = 1;
 			break;
 		default:
 			printk(KERN_WARNING "(scsi%d:%d:%d:%d) "
 				"scsi_adjust_queue_depth, bad queue type, "
-				"disabled\n", SDpnt->host->host_no,
-				SDpnt->channel, SDpnt->id, SDpnt->lun); 
+				"disabled\n", sdev->host->host_no,
+				sdev->channel, sdev->id, sdev->lun); 
 		case 0:
-			SDpnt->ordered_tags = SDpnt->simple_tags = 0;
-			SDpnt->queue_depth = tags;
+			sdev->ordered_tags = sdev->simple_tags = 0;
+			sdev->queue_depth = tags;
 			break;
 	}
 	spin_unlock_irqrestore(&device_request_lock, flags);
@@ -945,7 +893,7 @@
  * 		specific SCSI device to determine if and when there is a
  * 		need to adjust the queue depth on the device.
  *
- * Arguments:	SDpnt	- SCSI Device in question
+ * Arguments:	sdev	- SCSI Device in question
  * 		depth	- Current number of outstanding SCSI commands on
  * 			  this device, not counting the one returned as
  * 			  QUEUE_FULL.
@@ -960,33 +908,32 @@
  * Notes:	Low level drivers may call this at any time and we will do
  * 		"The Right Thing."  We are interrupt context safe.
  */
-int scsi_track_queue_full(Scsi_Device *SDptr, int depth)
+int scsi_track_queue_full(struct scsi_device *sdev, int depth)
 {
-	if((jiffies >> 4) != SDptr->last_queue_full_time) {
-		SDptr->last_queue_full_time = (jiffies >> 4);
-		if(SDptr->last_queue_full_depth == depth)
-			SDptr->last_queue_full_count++;
-		else {
-			SDptr->last_queue_full_count = 1;
-			SDptr->last_queue_full_depth = depth;
-		}
-		if(SDptr->last_queue_full_count > 10) {
-			if(SDptr->last_queue_full_depth < 8) {
-				/* Drop back to untagged */
-				scsi_adjust_queue_depth(SDptr, 0 /* untagged */,
-						SDptr->host->cmd_per_lun);
-				return -1;
-			}
-			if(SDptr->ordered_tags)
-				scsi_adjust_queue_depth(SDptr, MSG_ORDERED_TAG,
-						depth);
-			else
-				scsi_adjust_queue_depth(SDptr, MSG_SIMPLE_TAG,
-						depth);
-			return depth;
-		}
+	if ((jiffies >> 4) == sdev->last_queue_full_time)
+		return 0;
+
+	sdev->last_queue_full_time = (jiffies >> 4);
+	if (sdev->last_queue_full_depth != depth) {
+		sdev->last_queue_full_count = 1;
+		sdev->last_queue_full_depth = depth;
+	} else {
+		sdev->last_queue_full_count++;
 	}
-	return 0;
+
+	if (sdev->last_queue_full_count <= 10)
+		return 0;
+	if (sdev->last_queue_full_depth < 8) {
+		/* Drop back to untagged */
+		scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
+		return -1;
+	}
+	
+	if (sdev->ordered_tags)
+		scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, depth);
+	else
+		scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, depth);
+	return depth;
 }
 
 
@@ -1305,7 +1252,7 @@
 	struct list_head *lh, *lh_sf;
 	unsigned long flags;
 
-	sdev->online = FALSE;
+	sdev->online = 0;
 
 	spin_lock_irqsave(&sdev->list_lock, flags);
 	list_for_each_entry(scmd, &sdev->cmd_list, list) {
@@ -1315,9 +1262,8 @@
 			 * that the command has already timed out or
 			 * finished.
 			 */
-			if (!scsi_delete_timer(scmd)) {
+			if (!scsi_delete_timer(scmd))
 				continue;
-			}
 			list_add_tail(&scmd->eh_entry, &active_list);
 		}
 	}
@@ -1365,10 +1311,8 @@
 {
 	sdev->attached--;
 }
+
 /*
- * This entry point should be called by a loadable module if it is trying
- * add a high level scsi driver to the system.
- *
  * This entry point is called from the upper level module's module_init()
  * routine.  That implies that when this function is called, the
  * scsi_mod module is locked down because of upper module layering and
@@ -1383,7 +1327,7 @@
  */
 int scsi_register_device(struct Scsi_Device_Template *tpnt)
 {
-	Scsi_Device *SDpnt;
+	struct scsi_device *sdev;
 	struct Scsi_Host *shpnt;
 
 #ifdef CONFIG_KMOD
@@ -1402,15 +1346,15 @@
 
 	for (shpnt = scsi_host_get_next(NULL); shpnt;
 	     shpnt = scsi_host_get_next(shpnt)) 
-		list_for_each_entry (SDpnt, &shpnt->my_devices, siblings)
-			(*tpnt->attach) (SDpnt);
+		list_for_each_entry(sdev, &shpnt->my_devices, siblings)
+			(*tpnt->attach)(sdev);
 
 	return 0;
 }
 
 int scsi_unregister_device(struct Scsi_Device_Template *tpnt)
 {
-	Scsi_Device *SDpnt;
+	struct scsi_device *sdev;
 	struct Scsi_Host *shpnt;
 
 	/*
@@ -1418,8 +1362,8 @@
 	 */
 	for (shpnt = scsi_host_get_next(NULL); shpnt;
 	     shpnt = scsi_host_get_next(shpnt)) {
-		list_for_each_entry(SDpnt, &shpnt->my_devices, siblings)
-			(*tpnt->detach) (SDpnt);
+		list_for_each_entry(sdev, &shpnt->my_devices, siblings)
+			(*tpnt->detach)(sdev);
 	}
 
 	/*
@@ -1446,8 +1390,7 @@
 MODULE_LICENSE("GPL");
 
 #ifndef MODULE
-
-int __init setup_scsi_dev_flags(char *str)
+static int __init setup_scsi_dev_flags(char *str)
 {
 	scsi_dev_flags = str;
 	return 1;
@@ -1469,7 +1412,6 @@
 	}
 }
 __setup("scsi_default_dev_flags=", setup_scsi_default_dev_flags);
-
 #endif
 
 static int __init init_scsi(void)
diff -Nru a/drivers/scsi/scsi.h b/drivers/scsi/scsi.h
--- a/drivers/scsi/scsi.h	Wed Apr 30 22:28:06 2003
+++ b/drivers/scsi/scsi.h	Wed Apr 30 22:28:06 2003
@@ -87,21 +87,6 @@
 #endif
 
 /*
- * Used for debugging the new queueing code.  We want to make sure
- * that the lock state is consistent with design.  Only do this in
- * the user space simulator.
- */
-#define ASSERT_LOCK(_LOCK, _COUNT)
-
-#if defined(CONFIG_SMP) && defined(CONFIG_USER_DEBUG)
-#undef ASSERT_LOCK
-#define ASSERT_LOCK(_LOCK,_COUNT)       \
-        { if( (_LOCK)->lock != _COUNT )   \
-                panic("Lock count inconsistent %s %d\n", __FILE__, __LINE__); \
-                                                                                       }
-#endif
-
-/*
  *  Use these to separate status msg and our bytes
  *
  *  These are set by:
@@ -470,13 +455,9 @@
 
 extern void scsi_proc_host_add(struct Scsi_Host *);
 extern void scsi_proc_host_rm(struct Scsi_Host *);
-
-extern struct proc_dir_entry *proc_scsi;
-extern void proc_print_scsidevice(Scsi_Device * sdev, char *buffer, int *size, int len);
 #else
 static inline int scsi_init_procfs(void) { return 0; }
 static inline void scsi_exit_procfs(void) { ; }
-static inline void proc_print_scsidevice(Scsi_Device * sdev, char *buffer, int *size, int len) { ; }
 
 static inline void scsi_proc_host_add(struct Scsi_Host *);
 static inline void scsi_proc_host_rm(struct Scsi_Host *);
diff -Nru a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
--- a/drivers/scsi/scsi_debug.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/scsi/scsi_debug.c	Wed Apr 30 22:28:11 2003
@@ -183,7 +183,6 @@
 	.name 		= sdebug_proc_name,
 	.probe          = sdebug_driver_probe,
 	.remove         = sdebug_driver_remove,
-	.devclass 	= &shost_devclass,
 };
 
 static const int check_condition_result = 
diff -Nru a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
--- a/drivers/scsi/scsi_error.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/scsi/scsi_error.c	Wed Apr 30 22:28:03 2003
@@ -1334,10 +1334,6 @@
 {
 	struct scsi_request *sreq = scmd->sc_request;
 
-	scmd->sc_request = NULL;
-	sreq->sr_command = NULL;
-
-	scsi_put_command(scmd);
 	scsi_release_request(sreq);
 }
 
@@ -1401,7 +1397,6 @@
 static void scsi_restart_operations(struct Scsi_Host *shost)
 {
 	struct scsi_device *sdev;
-	unsigned long flags;
 
 	/*
 	 * If the door was locked, we need to insert a door lock request
@@ -1430,11 +1425,8 @@
 	 * now that error recovery is done, we will need to ensure that these
 	 * requests are started.
 	 */
-	list_for_each_entry(sdev, &shost->my_devices, siblings) {
-		spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
-		__blk_run_queue(sdev->request_queue);
-		spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
-	}
+	list_for_each_entry(sdev, &shost->my_devices, siblings)
+		blk_run_queue(sdev->request_queue);
 }
 
 /**
diff -Nru a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
--- a/drivers/scsi/scsi_lib.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/scsi/scsi_lib.c	Wed Apr 30 22:28:09 2003
@@ -328,7 +328,7 @@
 
 /*
  * Called for single_lun devices on IO completion. Clear starget_sdev_user,
- * and call __blk_run_queue for all the scsi_devices on the target -
+ * and call blk_run_queue for all the scsi_devices on the target -
  * including current_sdev first.
  *
  * Called with *no* scsi locks held.
@@ -336,7 +336,7 @@
 static void scsi_single_lun_run(struct scsi_device *current_sdev)
 {
 	struct scsi_device *sdev;
-	unsigned long flags, flags2;
+	unsigned long flags;
 
 	spin_lock_irqsave(current_sdev->host->host_lock, flags);
 	WARN_ON(!current_sdev->sdev_target->starget_sdev_user);
@@ -344,14 +344,12 @@
 	spin_unlock_irqrestore(current_sdev->host->host_lock, flags);
 
 	/*
-	 * Call __blk_run_queue for all LUNs on the target, starting with
+	 * Call blk_run_queue for all LUNs on the target, starting with
 	 * current_sdev. We race with others (to set starget_sdev_user),
 	 * but in most cases, we will be first. Ideally, each LU on the
 	 * target would get some limited time or requests on the target.
 	 */
-	spin_lock_irqsave(current_sdev->request_queue->queue_lock, flags2);
-	__blk_run_queue(current_sdev->request_queue);
-	spin_unlock_irqrestore(current_sdev->request_queue->queue_lock, flags2);
+	blk_run_queue(current_sdev->request_queue);
 
 	spin_lock_irqsave(current_sdev->host->host_lock, flags);
 	if (current_sdev->sdev_target->starget_sdev_user) {
@@ -366,11 +364,8 @@
 	spin_unlock_irqrestore(current_sdev->host->host_lock, flags);
 
 	list_for_each_entry(sdev, &current_sdev->same_target_siblings,
-			    same_target_siblings) {
-		spin_lock_irqsave(sdev->request_queue->queue_lock, flags2);
-		__blk_run_queue(sdev->request_queue);
-		spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags2);
-	}
+			    same_target_siblings)
+		blk_run_queue(sdev->request_queue);
 }
 
 /*
@@ -452,7 +447,7 @@
 		  (shost->host_busy >= shost->can_queue))) {
 		/*
 		 * As long as shost is accepting commands and we have
-		 * starved queues, call __blk_run_queue. scsi_request_fn
+		 * starved queues, call blk_run_queue. scsi_request_fn
 		 * drops the queue_lock and can add us back to the
 		 * starved_list.
 		 *
@@ -465,9 +460,7 @@
 		list_del_init(&sdev->starved_entry);
 		spin_unlock_irqrestore(shost->host_lock, flags);
 
-		spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
-		__blk_run_queue(sdev->request_queue);
-		spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
+		blk_run_queue(sdev->request_queue);
 
 		spin_lock_irqsave(shost->host_lock, flags);
 		if (unlikely(!list_empty(&sdev->starved_entry)))
@@ -480,9 +473,7 @@
 	}
 	spin_unlock_irqrestore(shost->host_lock, flags);
 
-	spin_lock_irqsave(q->queue_lock, flags);
-	__blk_run_queue(q);
-	spin_unlock_irqrestore(q->queue_lock, flags);
+	blk_run_queue(q);
 }
 
 /*
@@ -742,7 +733,7 @@
 	if (good_sectors >= 0) {
 		SCSI_LOG_HLCOMPLETE(1, printk("%ld sectors total, %d sectors done.\n",
 					      req->nr_sectors, good_sectors));
-		SCSI_LOG_HLCOMPLETE(1, printk("use_sg is %d\n ", cmd->use_sg));
+		SCSI_LOG_HLCOMPLETE(1, printk("use_sg is %d\n", cmd->use_sg));
 
 		if (clear_errors)
 			req->errors = 0;
diff -Nru a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
--- a/drivers/scsi/scsi_proc.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/scsi/scsi_proc.c	Wed Apr 30 22:28:04 2003
@@ -149,8 +149,8 @@
 		remove_proc_entry(shost->hostt->proc_name, proc_scsi);
 }
 
-/* XXX: this shouldn't really be exposed to drivers. */
-void proc_print_scsidevice(Scsi_Device * sdev, char *buffer, int *size, int len)
+static void proc_print_scsidevice(struct scsi_device* sdev, char *buffer,
+				  int *size, int len)
 {
 
 	int x, y = *size;
@@ -195,7 +195,6 @@
 	*size = y;
 	return;
 }
-EXPORT_SYMBOL(proc_print_scsidevice);
 
 /* 
  * proc_scsi_dev_info_read: dump the scsi_dev_info_list via
diff -Nru a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
--- a/drivers/scsi/scsi_scan.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/scsi/scsi_scan.c	Wed Apr 30 22:28:15 2003
@@ -376,15 +376,15 @@
 }
 
 /**
- * scsi_alloc_sdev - allocate and setup a Scsi_Device
+ * scsi_alloc_sdev - allocate and setup a scsi_Device
  *
  * Description:
- *     Allocate, initialize for io, and return a pointer to a Scsi_Device.
- *     Stores the @shost, @channel, @id, and @lun in the Scsi_Device, and
- *     adds Scsi_Device to the appropriate list.
+ *     Allocate, initialize for io, and return a pointer to a scsi_Device.
+ *     Stores the @shost, @channel, @id, and @lun in the scsi_Device, and
+ *     adds scsi_Device to the appropriate list.
  *
  * Return value:
- *     Scsi_Device pointer, or NULL on failure.
+ *     scsi_Device pointer, or NULL on failure.
  **/
 static struct scsi_device *scsi_alloc_sdev(struct Scsi_Host *shost,
 	       	uint channel, uint id, uint lun)
@@ -465,9 +465,7 @@
 	return sdev;
 
 out_free_queue:
-	if (sdev->request_queue)
-		scsi_free_queue(sdev->request_queue);
-
+	scsi_free_queue(sdev->request_queue);
 out_free_dev:
 	kfree(sdev);
 out:
@@ -476,8 +474,8 @@
 }
 
 /**
- * scsi_free_sdev - cleanup and free a Scsi_Device
- * @sdev:	cleanup and free this Scsi_Device
+ * scsi_free_sdev - cleanup and free a scsi_device
+ * @sdev:	cleanup and free this scsi_device
  *
  * Description:
  *     Undo the actions in scsi_alloc_sdev, including removing @sdev from
@@ -499,8 +497,7 @@
 	spin_lock_irqsave(sdev->host->host_lock, flags);
 	list_del(&sdev->starved_entry);
 	if (sdev->single_lun) {
-		sdev->sdev_target->starget_refcnt--;
-		if (sdev->sdev_target->starget_refcnt == 0)
+		if (--sdev->sdev_target->starget_refcnt == 0)
 			kfree(sdev->sdev_target);
 	}
 	spin_unlock_irqrestore(sdev->host->host_lock, flags);
@@ -509,481 +506,6 @@
 }
 
 /**
- * scsi_get_evpd_page - get a list of supported vpd pages
- * @sdev:	Scsi_Device to send an INQUIRY VPD
- * @sreq:	Scsi_Request associated with @sdev
- *
- * Description:
- *     Get SCSI INQUIRY Vital Product Data page 0 - a list of supported
- *     VPD pages.
- *
- * Return:
- *     A pointer to data containing the results on success, else NULL.
- **/
-unsigned char *scsi_get_evpd_page(Scsi_Device *sdev, Scsi_Request *sreq)
-{
-	unsigned char *evpd_page;
-	unsigned char scsi_cmd[MAX_COMMAND_SIZE];
-	int max_lgth = 255;
-
-retry:
-	evpd_page = kmalloc(max_lgth, GFP_ATOMIC |
-			      (sdev->host->unchecked_isa_dma) ?
-			      GFP_DMA : 0);
-	if (!evpd_page) {
-		printk(KERN_WARNING "scsi scan: Allocation failure identifying"
-		       " host %d channel %d id %d lun %d, device might be"
-		       " improperly identified.\n", sdev->host->host_no,
-		       sdev->channel, sdev->id, sdev->lun);
-		return NULL;
-	}
-
-	memset(scsi_cmd, 0, MAX_COMMAND_SIZE);
-	scsi_cmd[0] = INQUIRY;
-	scsi_cmd[1] = 0x01;
-	scsi_cmd[4] = max_lgth;
-	sreq->sr_cmd_len = 0;
-	sreq->sr_sense_buffer[0] = 0;
-	sreq->sr_sense_buffer[2] = 0;
-	sreq->sr_data_direction = SCSI_DATA_READ;
-	scsi_wait_req(sreq, (void *) scsi_cmd, (void *) evpd_page,
-			max_lgth, SCSI_TIMEOUT+4*HZ, 3);
-
-	if (sreq->sr_result) {
-		kfree(evpd_page);
-		return NULL;
-	}
-
-	/*
-	 * check to see if response was truncated
-	 */
-	if (evpd_page[3] > max_lgth) {
-		max_lgth = evpd_page[3] + 4;
-		kfree(evpd_page);
-		goto retry;
-	}
-
-	/*
-	 * Some ill behaved devices return the standard inquiry here
-	 * rather than the evpd data, snoop the data to verify.
-	 */
-	if (evpd_page[3] > 16) {
-		/*
-		 * If the vendor id appears in the evpd page assume the
-		 * page is invalid.
-		 */
-		if (!strncmp(&evpd_page[8], sdev->vendor, 8)) {
-			kfree(evpd_page);
-			return NULL;
-		}
-	}
-	return evpd_page;
-}
-
-
-/*
- * INQUIRY VPD page 0x83 identifier descriptor related values. Reference the
- * SCSI Primary Commands specification for details.
- *
- * XXX The following defines should be in scsi.h
- */
-
-/*
- * id type values of id descriptors. These are assumed to fit in 4 bits,
- * else the code using hex_str[id_type] needs modification.
- */
-#define SCSI_ID_VENDOR_SPECIFIC	0
-#define SCSI_ID_T10_VENDOR	1
-#define SCSI_ID_EUI_64		2
-#define SCSI_ID_NAA		3
-
-/*
- * Supported NAA values. These fit in 4 bits, so the don't care value
- * cannot conflict with real values.
- *
- */
-#define	SCSI_ID_NAA_DONT_CARE		0xff
-#define	SCSI_ID_NAA_IEEE_REG		5
-#define	SCSI_ID_NAA_IEEE_REG_EXTENDED	6
-
-/*
- * Supported Code Set values.
- */
-#define	SCSI_ID_BINARY	1
-#define	SCSI_ID_ASCII	2
-
-/*
- * Use a priority based list of id, naa, and binary/ascii for the
- * identifier descriptor in VPD page 0x83.
- *
- * Brute force search for a match starting with the first value in
- * id_search_list. This is not a performance issue, since there
- * is normally one or some small number of descriptors.
- */
-struct scsi_id_search_values {
-	int	id_type;
-	int	naa_type;
-	int	code_set;
-};
-
-static const struct scsi_id_search_values id_search_list[] = {
-	{ SCSI_ID_NAA,	SCSI_ID_NAA_IEEE_REG_EXTENDED,	SCSI_ID_BINARY },
-	{ SCSI_ID_NAA,	SCSI_ID_NAA_IEEE_REG_EXTENDED,	SCSI_ID_ASCII },
-	{ SCSI_ID_NAA,	SCSI_ID_NAA_IEEE_REG,	SCSI_ID_BINARY },
-	{ SCSI_ID_NAA,	SCSI_ID_NAA_IEEE_REG,	SCSI_ID_ASCII },
-	/*
-	 * Devices already exist using NAA values that are now marked
-	 * reserved. These should not conflict with other values, or it is
-	 * a bug in the device. As long as we find the IEEE extended one
-	 * first, we really don't care what other ones are used. Using
-	 * don't care here means that a device that returns multiple
-	 * non-IEEE descriptors in a random order will get different
-	 * names.
-	 */
-	{ SCSI_ID_NAA,	SCSI_ID_NAA_DONT_CARE,	SCSI_ID_BINARY },
-	{ SCSI_ID_NAA,	SCSI_ID_NAA_DONT_CARE,	SCSI_ID_ASCII },
-	{ SCSI_ID_EUI_64,	SCSI_ID_NAA_DONT_CARE,	SCSI_ID_BINARY },
-	{ SCSI_ID_EUI_64,	SCSI_ID_NAA_DONT_CARE,	SCSI_ID_ASCII },
-	{ SCSI_ID_T10_VENDOR,	SCSI_ID_NAA_DONT_CARE,	SCSI_ID_BINARY },
-	{ SCSI_ID_T10_VENDOR,	SCSI_ID_NAA_DONT_CARE,	SCSI_ID_ASCII },
-	{ SCSI_ID_VENDOR_SPECIFIC,	SCSI_ID_NAA_DONT_CARE,	SCSI_ID_BINARY },
-	{ SCSI_ID_VENDOR_SPECIFIC,	SCSI_ID_NAA_DONT_CARE,	SCSI_ID_ASCII },
-};
-
-/**
- * scsi_check_fill_deviceid - check the id and if OK fill it
- * @sdev:	device to use for error messages
- * @id_page:	id descriptor for INQUIRY VPD DEVICE ID, page 0x83
- * @name:	store the id in name (of size DEVICE_NAME_SIZE > 26)
- * @id_search:	store if the id_page matches these values
- *
- * Description:
- *     Check if @id_page matches the @id_search, if so store an id (uid)
- *     into name, that is all zero on entrance.
- *
- * Return:
- *     0: Success
- *     1: No match
- **/
-static int scsi_check_fill_deviceid(Scsi_Device *sdev, char *id_page,
-	char *name, const struct scsi_id_search_values *id_search)
-{
-	static const char hex_str[]="0123456789abcdef";
-	int i, j;
-
-	/*
-	 * ASSOCIATION must be with the device (value 0)
-	 */
-	if ((id_page[1] & 0x30) != 0)
-		return 1;
-
-	if ((id_page[1] & 0x0f) != id_search->id_type)
-		return 1;
-	/*
-	 * Possibly check NAA sub-type.
-	 */
-	if ((id_search->naa_type != SCSI_ID_NAA_DONT_CARE) &&
-	    (id_search->naa_type != (id_page[4] & 0xf0) >> 4)) {
-		return 1;
-	}
-
-	/*
-	 * Check for matching code set - ASCII or BINARY.
-	 */
-	if ((id_page[0] & 0x0f) != id_search->code_set)
-		return 1;
-
-	/*
-	 * All OK - store ID
-	 */
-	name[0] = hex_str[id_search->id_type];
-
-	/*
-	 * Prepend the vendor and model before the id, since the id
-	 * might not be unique across all vendors and models.
-	 * The same code is used below, with a different size.
-	 */
-	if (id_search->id_type == SCSI_ID_VENDOR_SPECIFIC) {
-		strncat(name, sdev->vendor, 8);
-		strncat(name, sdev->model, 16);
-	}
-
-	i = 4;
-	j = strlen(name);
-	if ((id_page[0] & 0x0f) == SCSI_ID_ASCII) {
-		/*
-		 * ASCII descriptor.
-		 */
-		while (i < 4 + id_page[3] && j < DEVICE_NAME_SIZE-1)
-			name[j++] = id_page[i++];
-	} else {
-		/*
-		 * Binary descriptor, convert to ASCII, using two bytes of
-		 * ASCII for each byte in the id_page.
-		 */
-		while (i < 4 + id_page[3] && j < DEVICE_NAME_SIZE-2) {
-			name[j++] = hex_str[(id_page[i] & 0xf0) >> 4];
-			name[j++] = hex_str[id_page[i] & 0x0f];
-			i++;
-		}
-	}
-	return 0;
-}
-
-/**
- * scsi_get_deviceid - get a device id using INQUIRY VPD page 0x83
- * @sdev:	get the identifer of this device
- * @sreq:	Scsi_Requeset associated with @sdev
- *
- * Description:
- *     Try to get an id (serial number) for device @sdev using a SCSI
- *     Vital Product Data page 0x83 (device id).
- *
- * Return:
- *     0: Failure
- *     1: Success
- **/
-static int scsi_get_deviceid(Scsi_Device *sdev, Scsi_Request *sreq)
-{
-	unsigned char *id_page;
-	unsigned char scsi_cmd[MAX_COMMAND_SIZE];
-	int id_idx, scnt, ret;
-	int max_lgth = 255;
-
-retry:
-	id_page = kmalloc(max_lgth, GFP_ATOMIC |
-			      (sdev->host->unchecked_isa_dma) ?
-			      GFP_DMA : 0);
-	if (!id_page) {
-		printk(KERN_WARNING "scsi scan: Allocation failure identifying"
-		       " host %d channel %d id %d lun %d, device might be"
-		       " improperly identified.\n", sdev->host->host_no,
-		       sdev->channel, sdev->id, sdev->lun);
-		return 0;
-	}
-
-	memset(scsi_cmd, 0, MAX_COMMAND_SIZE);
-	scsi_cmd[0] = INQUIRY;
-	scsi_cmd[1] = 0x01;
-	scsi_cmd[2] = 0x83;
-	scsi_cmd[4] = max_lgth;
-	sreq->sr_cmd_len = 0;
-	sreq->sr_sense_buffer[0] = 0;
-	sreq->sr_sense_buffer[2] = 0;
-	sreq->sr_data_direction = SCSI_DATA_READ;
-	scsi_wait_req(sreq, (void *) scsi_cmd, (void *) id_page,
-			max_lgth, SCSI_TIMEOUT+4*HZ, 3);
-	if (sreq->sr_result) {
-		ret = 0;
-		goto leave;
-	}
-
-	/*
-	 * check to see if response was truncated
-	 */
-	if (id_page[3] > max_lgth) {
-		max_lgth = id_page[3] + 4;
-		kfree(id_page);
-		goto retry;
-	}
-
-	/*
-	 * Search for a match in the prioritized id_search_list.
-	 */
-	for (id_idx = 0; id_idx < ARRAY_SIZE(id_search_list); id_idx++) {
-		/*
-		 * Examine each descriptor returned. There is normally only
-		 * one or a small number of descriptors.
-		 */
-		for (scnt = 4; scnt <= id_page[3] + 3;
-			scnt += id_page[scnt + 3] + 4) {
-			if ((scsi_check_fill_deviceid(sdev, &id_page[scnt],
-			     sdev->sdev_driverfs_dev.name,
-			     &id_search_list[id_idx])) == 0) {
-				SCSI_LOG_SCAN_BUS(4, printk(KERN_INFO
-				  "scsi scan: host %d channel %d id %d lun %d"
-				  " used id desc %d/%d/%d\n",
-				  sdev->host->host_no, sdev->channel,
-				  sdev->id, sdev->lun,
-				  id_search_list[id_idx].id_type,
-				  id_search_list[id_idx].naa_type,
-				  id_search_list[id_idx].code_set));
-				ret = 1;
-				goto leave;
-			} else {
-				SCSI_LOG_SCAN_BUS(4, printk(KERN_INFO
-				  "scsi scan: host %d channel %d id %d lun %d"
-				  " no match/error id desc %d/%d/%d\n",
-				  sdev->host->host_no, sdev->channel,
-				  sdev->id, sdev->lun,
-				  id_search_list[id_idx].id_type,
-				  id_search_list[id_idx].naa_type,
-				  id_search_list[id_idx].code_set));
-			}
-			/*
-			 * scsi_check_fill_deviceid can fill the first
-			 * byte of name with a non-zero value, reset it.
-			 */
-			sdev->sdev_driverfs_dev.name[0] = '\0';
-		}
-	}
-	ret = 0;
-
-  leave:
-	kfree(id_page);
-	return ret;
-}
-
-/**
- * scsi_get_serialnumber - get a serial number using INQUIRY page 0x80
- * @sdev:	get the serial number of this device
- * @sreq:	Scsi_Requeset associated with @sdev
- *
- * Description:
- *     Send a SCSI INQUIRY page 0x80 to @sdev to get a serial number.
- *
- * Return:
- *     0: Failure
- *     1: Success
- **/
-int scsi_get_serialnumber(Scsi_Device *sdev, Scsi_Request *sreq)
-{
-	unsigned char *serialnumber_page;
-	unsigned char scsi_cmd[MAX_COMMAND_SIZE];
-	const int max_lgth = 255;
-	int len;
-
-	serialnumber_page = kmalloc(max_lgth, GFP_ATOMIC |
-			      (sdev->host->unchecked_isa_dma) ? GFP_DMA : 0);
-	if (!serialnumber_page) {
-		printk(KERN_WARNING "scsi scan: Allocation failure identifying"
-		       " host %d channel %d id %d lun %d, device might be"
-		       " improperly identified.\n", sdev->host->host_no,
-		       sdev->channel, sdev->id, sdev->lun);
-		return 0;
-	}
-
-	memset(scsi_cmd, 0, MAX_COMMAND_SIZE);
-	scsi_cmd[0] = INQUIRY;
-	scsi_cmd[1] = 0x01;
-	scsi_cmd[2] = 0x80;
-	scsi_cmd[4] = max_lgth;
-	sreq->sr_cmd_len = 0;
-	sreq->sr_sense_buffer[0] = 0;
-	sreq->sr_sense_buffer[2] = 0;
-	sreq->sr_data_direction = SCSI_DATA_READ;
-	scsi_wait_req(sreq, (void *) scsi_cmd, (void *) serialnumber_page,
-			max_lgth, SCSI_TIMEOUT+4*HZ, 3);
-
-	if (sreq->sr_result)
-		goto leave;
-
-	/*
-	 * a check to see if response was truncated is superfluous,
-	 * since serialnumber_page[3] cannot be larger than 255
-	 */
-
-	sdev->sdev_driverfs_dev.name[0] = SCSI_UID_SER_NUM;
-	strncat(sdev->sdev_driverfs_dev.name, sdev->vendor, 8);
-	strncat(sdev->sdev_driverfs_dev.name, sdev->model, 16);
-	len = serialnumber_page[3];
-	if (len > DEVICE_NAME_SIZE-26)
-		len = DEVICE_NAME_SIZE-26;
-	strncat(sdev->sdev_driverfs_dev.name, &serialnumber_page[4], len);
-	kfree(serialnumber_page);
-	return 1;
- leave:
-	memset(sdev->sdev_driverfs_dev.name, 0, DEVICE_NAME_SIZE);
-	kfree(serialnumber_page);
-	return 0;
-}
-
-/**
- * scsi_get_default_name - get a default name
- * @sdev:	get a default name for this device
- *
- * Description:
- *     Set the name of @sdev (of size DEVICE_NAME_SIZE > 29) to the
- *     concatenation of the vendor, model, and revision found in @sdev.
- *
- * Return:
- *     1: Success
- **/
-int scsi_get_default_name(Scsi_Device *sdev)
-{
-	sdev->sdev_driverfs_dev.name[0] = SCSI_UID_UNKNOWN;
-	strncpy(&sdev->sdev_driverfs_dev.name[1], sdev->vendor, 8);
-	strncat(sdev->sdev_driverfs_dev.name, sdev->model, 16);
-	strncat(sdev->sdev_driverfs_dev.name, sdev->rev, 4);
-	return 1;
-}
-
-/**
- * scsi_load_identifier:
- * @sdev:	get an identifier (name) of this device
- * @sreq:	Scsi_Requeset associated with @sdev
- *
- * Description:
- *     Determine what INQUIRY pages are supported by @sdev, and try the
- *     different pages until we get an identifier, or no other pages are
- *     left. Start with page 0x83 (device id) and then try page 0x80
- *     (serial number). If neither of these pages gets an id, use the
- *     default naming convention.
- *
- *     The first character of sdev_driverfs_dev.name is SCSI_UID_SER_NUM
- *     (S) if we used page 0x80, SCSI_UID_UNKNOWN (Z) if we used the
- *     default name, otherwise it starts with the page 0x83 id type
- *     (see the SCSI Primary Commands specification for details).
- *
- * Notes:
- *     If a device returns the same serial number for different LUNs or
- *     even for different LUNs on different devices, special handling must
- *     be added to get an id, or a new black list flag must be added (so
- *     we use the default name, or add a way to prefix the id/name with
- *     SCSI_UID_UNKNOWN - and change the define to something meaningful
- *     like SCSI_UID_NOT_UNIQUE). Complete user level scanning would be
- *     nice for such devices, so we do not need device specific code in
- *     the kernel.
- **/
-static void scsi_load_identifier(Scsi_Device *sdev, Scsi_Request *sreq)
-{
-	unsigned char *evpd_page = NULL;
-	int cnt;
-
-	memset(sdev->sdev_driverfs_dev.name, 0, DEVICE_NAME_SIZE);
-	evpd_page = scsi_get_evpd_page(sdev, sreq);
-	if (evpd_page == NULL) {
-		/*
-		 * try to obtain serial number anyway
-		 */
-		(void)scsi_get_serialnumber(sdev, sreq);
-	} else {
-		/*
-		 * XXX search high to low, since the pages are lowest to
-		 * highest - page 0x83 will be after page 0x80.
-		 */
-		for (cnt = 4; cnt <= evpd_page[3] + 3; cnt++)
-			if (evpd_page[cnt] == 0x83)
-				if (scsi_get_deviceid(sdev, sreq))
-					goto leave;
-
-		for (cnt = 4; cnt <= evpd_page[3] + 3; cnt++)
-			if (evpd_page[cnt] == 0x80)
-				if (scsi_get_serialnumber(sdev, sreq))
-					goto leave;
-
-		if (sdev->sdev_driverfs_dev.name[0] == 0)
-			scsi_get_default_name(sdev);
-
-	}
-leave:
-	if (evpd_page) kfree(evpd_page);
-	SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: host %d channel %d"
-	    " id %d lun %d name/id: '%s'\n", sdev->host->host_no,
-	    sdev->channel, sdev->id, sdev->lun, sdev->sdev_driverfs_dev.name));
-}
-
-/**
  * scsi_probe_lun - probe a single LUN using a SCSI INQUIRY
  * @sreq:	used to send the INQUIRY
  * @inq_result:	area to store the INQUIRY result
@@ -1004,6 +526,8 @@
 	unsigned char scsi_cmd[MAX_COMMAND_SIZE];
 	int possible_inq_resp_len;
 
+	*bflags = 0;
+ repeat_inquiry:
 	SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: INQUIRY to host %d"
 			" channel %d id %d lun %d\n", sdev->host->host_no,
 			sdev->channel, sdev->id, sdev->lun));
@@ -1043,8 +567,7 @@
 	 * bit fields in Scsi_Device, so bflags need not be passed as an
 	 * argument.
 	 */
-	BUG_ON(bflags == NULL);
-	*bflags = scsi_get_device_flags(&inq_result[8], &inq_result[16]);
+	*bflags |= scsi_get_device_flags(&inq_result[8], &inq_result[16]);
 
 	possible_inq_resp_len = (unsigned char) inq_result[4] + 5;
 	if (BLIST_INQUIRY_36 & *bflags)
@@ -1070,8 +593,17 @@
 		SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: 2nd INQUIRY"
 				" %s with code 0x%x\n", sreq->sr_result ?
 				"failed" : "successful", sreq->sr_result));
-		if (sreq->sr_result)
-			return;
+		if (sreq->sr_result) {
+			/* if the longer inquiry has failed, flag the device
+			 * as only accepting 36 byte inquiries and retry the
+			 * 36 byte inquiry */
+			printk(KERN_INFO "scsi scan: %d byte inquiry failed"
+			       " with code %d.  Consider BLIST_INQUIRY_36 for"
+			       " this device\n", possible_inq_resp_len,
+			       sreq->sr_result);
+			*bflags = BLIST_INQUIRY_36;
+			goto repeat_inquiry;
+		}
 
 		/*
 		 * The INQUIRY can change, this means the length can change.
@@ -1119,11 +651,29 @@
 	return;
 }
 
+static void scsi_set_name(struct scsi_device *sdev, char *inq_result)
+{
+	int i;
+	char type[72];
+
+	i = inq_result[0] & 0x1f;
+	if (i < MAX_SCSI_DEVICE_CODE)
+		strcpy(type, scsi_device_types[i]);
+	else
+		strcpy(type, "Unknown");
+
+	i = strlen(type) - 1;
+	while (i >= 0 && type[i] == ' ')
+		type[i--] = '\0';
+
+	snprintf(sdev->sdev_driverfs_dev.name, DEVICE_NAME_SIZE, "SCSI %s",
+		 type);
+}
+
 /**
  * scsi_add_lun - allocate and fully initialze a Scsi_Device
  * @sdevscan:	holds information to be stored in the new Scsi_Device
  * @sdevnew:	store the address of the newly allocated Scsi_Device
- * @sreq:	scsi request used when getting an identifier
  * @inq_result:	holds the result of a previous INQUIRY to the LUN
  * @bflags:	black/white list flag
  *
@@ -1137,8 +687,7 @@
  *     SCSI_SCAN_NO_RESPONSE: could not allocate or setup a Scsi_Device
  *     SCSI_SCAN_LUN_PRESENT: a new Scsi_Device was allocated and initialized
  **/
-static int scsi_add_lun(Scsi_Device *sdev, Scsi_Request *sreq,
-		char *inq_result, int *bflags)
+static int scsi_add_lun(Scsi_Device *sdev, char *inq_result, int *bflags)
 {
 	struct scsi_device *sdev_sibling;
 	struct scsi_target *starget;
@@ -1197,6 +746,8 @@
 
 	sdev->random = (sdev->type == TYPE_TAPE) ? 0 : 1;
 
+	scsi_set_name(sdev, inq_result);
+
 	print_inquiry(inq_result);
 
 	/*
@@ -1233,15 +784,6 @@
 	if (inq_result[7] & 0x10)
 		sdev->sdtr = 1;
 
-	/*
-	 * XXX maybe move the identifier and driverfs/devfs setup to a new
-	 * function, and call them after this function is called.
-	 *
-	 * scsi_load_identifier is the only reason sreq is needed in this
-	 * function.
-	 */
-	scsi_load_identifier(sdev, sreq);
-	
 	scsi_device_register(sdev);
 
 	sprintf(sdev->devfs_name, "scsi/host%d/bus%d/target%d/lun%d",
@@ -1369,7 +911,7 @@
 		goto out_free_result;
 	}
 
-	res = scsi_add_lun(sdev, sreq, result, &bflags);
+	res = scsi_add_lun(sdev, result, &bflags);
 	if (res == SCSI_SCAN_LUN_PRESENT) {
 		if (bflags & BLIST_KEY) {
 			sdev->lockable = 0;
@@ -1482,25 +1024,25 @@
 
 #ifdef CONFIG_SCSI_REPORT_LUNS
 /**
- * scsilun_to_int: convert a ScsiLun to an int
- * @scsilun:	ScsiLun to be converted.
+ * scsilun_to_int: convert a scsi_lun to an int
+ * @scsilun:	struct scsi_lun to be converted.
  *
  * Description:
- *     Convert @scsilun from a ScsiLun to a four byte host byte-ordered
+ *     Convert @scsilun from a struct scsi_lun to a four byte host byte-ordered
  *     integer, and return the result. The caller must check for
  *     truncation before using this function.
  *
  * Notes:
- *     The ScsiLun is assumed to be four levels, with each level
+ *     The struct scsi_lun is assumed to be four levels, with each level
  *     effectively containing a SCSI byte-ordered (big endian) short; the
  *     addressing bits of each level are ignored (the highest two bits).
  *     For a description of the LUN format, post SCSI-3 see the SCSI
  *     Architecture Model, for SCSI-3 see the SCSI Controller Commands.
  *
- *     Given a ScsiLun of: 0a 04 0b 03 00 00 00 00, this function returns
+ *     Given a struct scsi_lun of: 0a 04 0b 03 00 00 00 00, this function returns
  *     the integer: 0x0b030a04
  **/
-static int scsilun_to_int(ScsiLun *scsilun)
+static int scsilun_to_int(struct scsi_lun *scsilun)
 {
 	int i;
 	unsigned int lun;
@@ -1511,7 +1053,6 @@
 			      scsilun->scsi_lun[i + 1]) << (i * 8));
 	return lun;
 }
-#endif
 
 /**
  * scsi_report_lun_scan - Scan using SCSI REPORT LUN results
@@ -1528,18 +1069,16 @@
  *     0: scan completed (or no memory, so further scanning is futile)
  *     1: no report lun scan, or not configured
  **/
-static int scsi_report_lun_scan(Scsi_Device *sdev, int bflags)
+static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags)
 {
-#ifdef CONFIG_SCSI_REPORT_LUNS
-
 	char devname[64];
 	unsigned char scsi_cmd[MAX_COMMAND_SIZE];
 	unsigned int length;
 	unsigned int lun;
 	unsigned int num_luns;
 	unsigned int retries;
-	ScsiLun *fcp_cur_lun, *lun_data;
-	Scsi_Request *sreq;
+	struct scsi_lun *lunp, *lun_data;
+	struct scsi_request *sreq;
 	char *data;
 
 	/*
@@ -1551,15 +1090,14 @@
 		return 0;
 
 	sreq = scsi_allocate_request(sdev);
-	if (sreq == NULL) {
-		printk(ALLOC_FAILURE_MSG, __FUNCTION__);
-		return 0;
-	}
+	if (!sreq)
+		goto out;
+
+	sprintf(devname, "host %d channel %d id %d",
+		sdev->host->host_no, sdev->channel, sdev->id);
 
-	sprintf(devname, "host %d channel %d id %d", sdev->host->host_no,
-		sdev->channel, sdev->id);
 	/*
-	 * Allocate enough to hold the header (the same size as one ScsiLun)
+	 * Allocate enough to hold the header (the same size as one scsi_lun)
 	 * plus the max number of luns we are requesting.
 	 *
 	 * Reallocating and trying again (with the exact amount we need)
@@ -1568,24 +1106,19 @@
 	 * kmalloc - we don't want a kmalloc() failure of a huge value to
 	 * prevent us from finding any LUNs on this target.
 	 */
-	length = (max_scsi_report_luns + 1) * sizeof(ScsiLun);
-	lun_data = (ScsiLun *) kmalloc(length, GFP_ATOMIC |
-					   (sdev->host->unchecked_isa_dma ?
-					    GFP_DMA : 0));
-	if (lun_data == NULL) {
-		printk(ALLOC_FAILURE_MSG, __FUNCTION__);
-		scsi_release_request(sreq);
-		/*
-		 * We are out of memory, don't try scanning any further.
-		 */
-		return 0;
-	}
+	length = (max_scsi_report_luns + 1) * sizeof(struct scsi_lun);
+	lun_data = kmalloc(length, GFP_ATOMIC |
+			   (sdev->host->unchecked_isa_dma ? __GFP_DMA : 0));
+	if (!lun_data)
+		goto out_release_request;
 
 	scsi_cmd[0] = REPORT_LUNS;
+
 	/*
 	 * bytes 1 - 5: reserved, set to zero.
 	 */
 	memset(&scsi_cmd[1], 0, 5);
+
 	/*
 	 * bytes 6 - 9: length of the command.
 	 */
@@ -1609,19 +1142,18 @@
 	 * should come through as a check condition, and will not generate
 	 * a retry.
 	 */
-	retries = 0;
-	while (retries++ < 3) {
+	for (retries = 0; retries < 3; retries++) {
 		SCSI_LOG_SCAN_BUS(3, printk (KERN_INFO "scsi scan: Sending"
 				" REPORT LUNS to %s (try %d)\n", devname,
 				retries));
-		scsi_wait_req(sreq, (void *) scsi_cmd, (void *) lun_data,
-			      length, SCSI_TIMEOUT + 4 * HZ, 3);
+		scsi_wait_req(sreq, scsi_cmd, lun_data, length,
+				SCSI_TIMEOUT + 4*HZ, 3);
 		SCSI_LOG_SCAN_BUS(3, printk (KERN_INFO "scsi scan: REPORT LUNS"
 				" %s (try %d) result 0x%x\n", sreq->sr_result
 				?  "failed" : "successful", retries,
 				sreq->sr_result));
-		if (sreq->sr_result == 0
-		    || sreq->sr_sense_buffer[2] != UNIT_ATTENTION)
+		if (sreq->sr_result == 0 ||
+		    sreq->sr_sense_buffer[2] != UNIT_ATTENTION)
 			break;
 	}
 
@@ -1629,7 +1161,7 @@
 		/*
 		 * The device probably does not support a REPORT LUN command
 		 */
-		kfree((char *) lun_data);
+		kfree(lun_data);
 		scsi_release_request(sreq);
 		return 1;
 	}
@@ -1641,31 +1173,32 @@
 	data = (char *) lun_data->scsi_lun;
 	length = ((data[0] << 24) | (data[1] << 16) |
 		  (data[2] << 8) | (data[3] << 0));
-	if ((length / sizeof(ScsiLun)) > max_scsi_report_luns) {
+
+	num_luns = (length / sizeof(struct scsi_lun));
+	if (num_luns > max_scsi_report_luns) {
 		printk(KERN_WARNING "scsi: On %s only %d (max_scsi_report_luns)"
 		       " of %d luns reported, try increasing"
 		       " max_scsi_report_luns.\n", devname,
-		       max_scsi_report_luns, length / sizeof(ScsiLun));
+		       max_scsi_report_luns, num_luns);
 		num_luns = max_scsi_report_luns;
-	} else
-		num_luns = (length / sizeof(ScsiLun));
+	}
 
 	SCSI_LOG_SCAN_BUS(3, printk (KERN_INFO "scsi scan: REPORT LUN scan of"
 			" host %d channel %d id %d\n", sdev->host->host_no,
 			sdev->channel, sdev->id));
+
 	/*
 	 * Scan the luns in lun_data. The entry at offset 0 is really
 	 * the header, so start at 1 and go up to and including num_luns.
 	 */
-	for (fcp_cur_lun = &lun_data[1];
-	     fcp_cur_lun <= &lun_data[num_luns]; fcp_cur_lun++) {
-		lun = scsilun_to_int(fcp_cur_lun);
+	for (lunp = &lun_data[1]; lunp <= &lun_data[num_luns]; lunp++) {
+		lun = scsilun_to_int(lunp);
+
 		/*
-		 * Check if the unused part of fcp_cur_lun is non-zero,
-		 * and so does not fit in lun.
+		 * Check if the unused part of lunp is non-zero, and so
+		 * does not fit in lun.
 		 */
-		if (memcmp(&fcp_cur_lun->scsi_lun[sizeof(lun)],
-			   "\0\0\0\0", 4) != 0) {
+		if (memcmp(&lunp->scsi_lun[sizeof(lun)], "\0\0\0\0", 4)) {
 			int i;
 
 			/*
@@ -1674,8 +1207,8 @@
 			 * integer LUN value.
 			 */
 			printk(KERN_WARNING "scsi: %s lun 0x", devname);
-			data = (char *) fcp_cur_lun->scsi_lun;
-			for (i = 0; i < sizeof(ScsiLun); i++)
+			data = (char *)lunp->scsi_lun;
+			for (i = 0; i < sizeof(struct scsi_lun); i++)
 				printk("%02x", data[i]);
 			printk(" has a LUN larger than currently supported.\n");
 		} else if (lun == 0) {
@@ -1703,15 +1236,22 @@
 		}
 	}
 
-	kfree((char *) lun_data);
+	kfree(lun_data);
 	return 0;
 
+ out_release_request:
+	scsi_release_request(sreq);
+ out:
+	/*
+	 * We are out of memory, don't try scanning any further.
+	 */
+	printk(ALLOC_FAILURE_MSG, __FUNCTION__);
+	return 0;
+}
 #else
-	return 1;
+# define scsi_report_lun_scan(sdev, blags)	(1)
 #endif	/* CONFIG_SCSI_REPORT_LUNS */
 
-}
-
 struct scsi_device *scsi_add_device(struct Scsi_Host *shost,
 				    uint channel, uint id, uint lun)
 {
@@ -1733,7 +1273,6 @@
 	if (sdev->attached)
 		return -EINVAL;
 
-	devfs_remove(sdev->devfs_name);
 	scsi_device_unregister(sdev);
 
 	scsi_free_sdev(sdev);
diff -Nru a/drivers/scsi/scsi_syms.c b/drivers/scsi/scsi_syms.c
--- a/drivers/scsi/scsi_syms.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/scsi/scsi_syms.c	Wed Apr 30 22:28:09 2003
@@ -92,7 +92,6 @@
 /*
  * These are here only while I debug the rest of the scsi stuff.
  */
-EXPORT_SYMBOL(scsi_host_get_next);
 EXPORT_SYMBOL(scsi_host_hn_get);
 EXPORT_SYMBOL(scsi_host_put);
 EXPORT_SYMBOL(scsi_device_types);
@@ -113,4 +112,4 @@
 /*
  * sysfs support
  */
-EXPORT_SYMBOL(shost_devclass);
+EXPORT_SYMBOL(shost_class);
diff -Nru a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
--- a/drivers/scsi/scsi_sysfs.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/scsi/scsi_sysfs.c	Wed Apr 30 22:28:05 2003
@@ -75,30 +75,8 @@
 
 DEVICE_ATTR(class_name, S_IRUGO, scsi_host_class_name_show, NULL);
 
-static int scsi_host_class_add_dev(struct device * dev)
-{
-	int i;
-
-	device_create_file(dev, &dev_attr_class_name);
-	for (i = 0; i < ARRAY_SIZE(shost_attrs); i++)
-		device_create_file(dev, shost_attrs[i]);
-
-	return 0;
-}
-
-static void scsi_host_class_rm_dev(struct device * dev)
-{
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(shost_attrs); i++)
-		device_remove_file(dev, shost_attrs[i]);
-	device_remove_file(dev, &dev_attr_class_name);
-}
-
-struct device_class shost_devclass = {
+struct class shost_class = {
 	.name		= "scsi-host",
-	.add_device	= scsi_host_class_add_dev,
-	.remove_device	= scsi_host_class_rm_dev,
 };
 
 /**
@@ -136,14 +114,14 @@
 int scsi_sysfs_register(void)
 {
 	bus_register(&scsi_bus_type);
-	devclass_register(&shost_devclass);
+	class_register(&shost_class);
 
 	return 0;
 }
 
 void scsi_sysfs_unregister(void)
 {
-	devclass_unregister(&shost_devclass);
+	class_unregister(&shost_class);
 	bus_unregister(&scsi_bus_type);
 }
 
diff -Nru a/drivers/scsi/seagate.c b/drivers/scsi/seagate.c
--- a/drivers/scsi/seagate.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/scsi/seagate.c	Wed Apr 30 22:28:08 2003
@@ -333,7 +333,7 @@
 
 static int hostno = -1;
 static void seagate_reconnect_intr (int, void *, struct pt_regs *);
-static void do_seagate_reconnect_intr (int, void *, struct pt_regs *);
+static irqreturn_t do_seagate_reconnect_intr (int, void *, struct pt_regs *);
 
 #ifdef FAST
 static int fast = 1;
@@ -621,7 +621,8 @@
  * asserting SEL.
  */
 
-static void do_seagate_reconnect_intr (int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t do_seagate_reconnect_intr(int irq, void *dev_id,
+						struct pt_regs *regs)
 {
 	unsigned long flags;
 	struct Scsi_Host *dev = dev_id;
@@ -629,6 +630,7 @@
 	spin_lock_irqsave (dev->host_lock, flags);
 	seagate_reconnect_intr (irq, dev_id, regs);
 	spin_unlock_irqrestore (dev->host_lock, flags);
+	return IRQ_HANDLED;
 }
 
 static void seagate_reconnect_intr (int irq, void *dev_id, struct pt_regs *regs)
diff -Nru a/drivers/scsi/sg.c b/drivers/scsi/sg.c
--- a/drivers/scsi/sg.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/scsi/sg.c	Wed Apr 30 22:28:08 2003
@@ -55,6 +55,7 @@
 #include <linux/vmalloc.h>
 #include <linux/smp_lock.h>
 #include <linux/moduleparam.h>
+#include <linux/devfs_fs_kernel.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -2771,6 +2772,10 @@
 	return (size < (begin + len - offset)) ?                \
 				size : begin + len - offset;    \
     } while(0)
+
+/* this should _really_ be private to the scsi midlayer.  But
+   /proc/scsi/sg is an established name, so.. */
+extern struct proc_dir_entry *proc_scsi;
 
 static int
 sg_proc_init()
diff -Nru a/drivers/scsi/sr.c b/drivers/scsi/sr.c
--- a/drivers/scsi/sr.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/scsi/sr.c	Wed Apr 30 22:28:06 2003
@@ -569,7 +569,8 @@
 	get_capabilities(cd);
 	sr_vendor_init(cd);
 
-	strcpy(disk->devfs_name, sdev->devfs_name);
+	snprintf(disk->devfs_name, sizeof(disk->devfs_name),
+			"%s/cd", sdev->devfs_name);
 	disk->driverfs_dev = &sdev->sdev_driverfs_dev;
 	register_cdrom(&cd->cdi);
 	set_capacity(disk, cd->capacity);
diff -Nru a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c
--- a/drivers/scsi/sun3_scsi.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/scsi/sun3_scsi.c	Wed Apr 30 22:28:04 2003
@@ -273,7 +273,7 @@
 #ifndef REAL_DMA
 		printk("scsi%d: IRQ%d not free, interrupts disabled\n",
 		       instance->host_no, instance->irq);
-		instance->irq = IRQ_NONE;
+		instance->irq = SCSI_IRQ_NONE;
 #else
 		printk("scsi%d: IRQ%d not free, bailing out\n",
 		       instance->host_no, instance->irq);
@@ -282,7 +282,7 @@
 	}
 	
 	printk("scsi%d: Sun3 5380 at port %lX irq", instance->host_no, instance->io_port);
-	if (instance->irq == IRQ_NONE)
+	if (instance->irq == SCSI_IRQ_NONE)
 		printk ("s disabled");
 	else
 		printk (" %d", instance->irq);
@@ -311,7 +311,7 @@
 #ifdef MODULE
 int sun3scsi_release (struct Scsi_Host *shpnt)
 {
-	if (shpnt->irq != IRQ_NONE)
+	if (shpnt->irq != SCSI_IRQ_NONE)
 		free_irq (shpnt->irq, NULL);
 
 	iounmap((void *)sun3_scsi_regp);
diff -Nru a/drivers/scsi/sun3_scsi_vme.c b/drivers/scsi/sun3_scsi_vme.c
--- a/drivers/scsi/sun3_scsi_vme.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/scsi/sun3_scsi_vme.c	Wed Apr 30 22:28:20 2003
@@ -235,7 +235,7 @@
 #ifndef REAL_DMA
 		printk("scsi%d: IRQ%d not free, interrupts disabled\n",
 		       instance->host_no, instance->irq);
-		instance->irq = IRQ_NONE;
+		instance->irq = SCSI_IRQ_NONE;
 #else
 		printk("scsi%d: IRQ%d not free, bailing out\n",
 		       instance->host_no, instance->irq);
@@ -244,7 +244,7 @@
 	}
 
 	printk("scsi%d: Sun3 5380 VME at port %lX irq", instance->host_no, instance->io_port);
-	if (instance->irq == IRQ_NONE)
+	if (instance->irq == SCSI_IRQ_NONE)
 		printk ("s disabled");
 	else
 		printk (" %d", instance->irq);
@@ -280,7 +280,7 @@
 #ifdef MODULE
 int sun3scsi_release (struct Scsi_Host *shpnt)
 {
-	if (shpnt->irq != IRQ_NONE)
+	if (shpnt->irq != SCSI_IRQ_NONE)
 		free_irq (shpnt->irq, NULL);
 
 	iounmap(sun3_scsi_regp);
diff -Nru a/drivers/scsi/sym53c416.c b/drivers/scsi/sym53c416.c
--- a/drivers/scsi/sym53c416.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/scsi/sym53c416.c	Wed Apr 30 22:28:05 2003
@@ -248,7 +248,7 @@
 	unsigned int orig_len = len;
 	unsigned long flags = 0;
 	unsigned int bytes_left;
-	int i;
+	unsigned long i;
 	int timeout = READ_TIMEOUT;
 
 	/* Do transfer */
@@ -290,7 +290,7 @@
 	unsigned int orig_len = len;
 	unsigned long flags = 0;
 	unsigned int bufferfree;
-	unsigned int i;
+	unsigned long i;
 	unsigned int timeout = WRITE_TIMEOUT;
 
 	/* Do transfer */
@@ -327,7 +327,8 @@
 	return orig_len - len;
 }
 
-static void sym53c416_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sym53c416_intr_handle(int irq, void *dev_id,
+					struct pt_regs *regs)
 {
 	struct Scsi_Host *dev = dev_id;
 	int base = 0;
@@ -348,7 +349,7 @@
 	if(!base)
 	{
 		printk(KERN_ERR "sym53c416: No host adapter defined for interrupt %d\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 	/* Now we have the base address and we can start handling the interrupt */
 
@@ -367,7 +368,7 @@
 		spin_lock_irqsave(dev->host_lock, flags);
 		current_command->scsi_done(current_command);
 		spin_unlock_irqrestore(dev->host_lock, flags);
-		return;
+		goto out;
 	}
 	if(int_reg & ILCMD)       /* Illegal Command */
 	{
@@ -377,7 +378,7 @@
 		spin_lock_irqsave(dev->host_lock, flags);
 		current_command->scsi_done(current_command);
 		spin_unlock_irqrestore(dev->host_lock, flags);
-		return;
+		goto out;
 	}
 	if(status_reg & GE)         /* Gross Error */
 	{
@@ -387,7 +388,7 @@
 		spin_lock_irqsave(dev->host_lock, flags);
 		current_command->scsi_done(current_command);
 		spin_unlock_irqrestore(dev->host_lock, flags);
-		return;
+		goto out;
 	}
 	if(status_reg & PE)         /* Parity Error */
 	{
@@ -397,7 +398,7 @@
 		spin_lock_irqsave(dev->host_lock, flags);
 		current_command->scsi_done(current_command);
 		spin_unlock_irqrestore(dev->host_lock, flags);
-		return;
+		goto out;
 	}
 	if(pio_int_reg & (CE | OUE))
 	{
@@ -407,7 +408,7 @@
 		spin_lock_irqsave(dev->host_lock, flags);
 		current_command->scsi_done(current_command);
 		spin_unlock_irqrestore(dev->host_lock, flags);
-		return;
+		goto out;
 	}
 	if(int_reg & DIS)           /* Disconnect */
 	{
@@ -419,7 +420,7 @@
 		spin_lock_irqsave(dev->host_lock, flags);
 		current_command->scsi_done(current_command);
 		spin_unlock_irqrestore(dev->host_lock, flags);
-		return;
+		goto out;
 	}
 	/* Now we handle SCSI phases         */
 
@@ -518,6 +519,8 @@
 			break;
 		}
 	}
+out:
+	return IRQ_HANDLED;
 }
 
 static void sym53c416_init(int base, int scsi_id)
@@ -537,7 +540,8 @@
 
 static int sym53c416_probeirq(int base, int scsi_id)
 {
-	int irq, irqs, i;
+	int irq, irqs;
+	unsigned long i;
 
 	/* Clear interrupt register */
 	inb(base + INT_REG);
diff -Nru a/drivers/scsi/sym53c8xx.c b/drivers/scsi/sym53c8xx.c
--- a/drivers/scsi/sym53c8xx.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/scsi/sym53c8xx.c	Wed Apr 30 22:28:12 2003
@@ -99,16 +99,16 @@
 **==========================================================
 */
 
-#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
+#include <linux/version.h>
 
 #include <linux/module.h>
 
 #include <asm/dma.h>
 #include <asm/io.h>
 #include <asm/system.h>
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,17)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,17)
 #include <linux/spinlock.h>
-#elif LINUX_VERSION_CODE >= LinuxVersionCode(2,1,93)
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
 #include <asm/spinlock.h>
 #endif
 #include <linux/delay.h>
@@ -123,10 +123,9 @@
 #include <linux/timer.h>
 #include <linux/stat.h>
 
-#include <linux/version.h>
 #include <linux/blk.h>
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,35)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,35)
 #include <linux/init.h>
 #endif
 
@@ -137,7 +136,7 @@
 #define	__initdata
 #endif
 
-#if LINUX_VERSION_CODE <= LinuxVersionCode(2,1,92)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,1,92)
 #include <linux/bios32.h>
 #endif
 
@@ -170,7 +169,7 @@
 **	Donnot compile integrity checking code for Linux-2.3.0 
 **	and above since SCSI data structures are not ready yet.
 */
-/* #if LINUX_VERSION_CODE < LinuxVersionCode(2,3,0) */
+/* #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */
 #if 0
 #define	SCSI_NCR_INTEGRITY_CHECKING
 #endif
@@ -183,7 +182,7 @@
 **	despite the fact that the PCI specifications are looking 
 **	so smart and simple! ;-)
 */
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,47)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,47)
 #define SCSI_NCR_DYNAMIC_DMA_MAPPING
 #endif
 
@@ -439,7 +438,7 @@
 **	code.
 */
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,2,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
 
 typedef struct pci_dev *pcidev_t;
 #define PCIDEV_NULL		(0)
@@ -454,7 +453,7 @@
 {
 	u_long base;
 
-#if LINUX_VERSION_CODE > LinuxVersionCode(2,3,12)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,12)
 	base = pdev->resource[index].start;
 #else
 	base = pdev->base_address[index];
@@ -574,13 +573,13 @@
 	return base;
 }
 
-#endif	/* LINUX_VERSION_CODE >= LinuxVersionCode(2,2,0) */
+#endif	/* LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) */
 
 /* Does not make sense in earlier kernels */
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,4,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
 #define pci_enable_device(pdev)		(0)
 #endif
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,4,4)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4)
 #define	scsi_set_pci_device(inst, pdev)	(0)
 #endif
 
@@ -630,7 +629,7 @@
 **	  wished (e.g.: threaded by controller).
 */
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,93)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
 
 spinlock_t sym53c8xx_lock = SPIN_LOCK_UNLOCKED;
 #define	NCR_LOCK_DRIVER(flags)     spin_lock_irqsave(&sym53c8xx_lock, flags)
@@ -670,7 +669,7 @@
 **	architecture.
 */
 
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,1,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)
 #define ioremap vremap
 #define iounmap vfree
 #endif
@@ -713,7 +712,7 @@
 **	inaccurate on Pentium processors.
 */
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,105)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,105)
 #define UDELAY udelay
 #define MDELAY mdelay
 #else
@@ -735,7 +734,7 @@
 **	real bus astraction, btw).
 */
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
 #define __GetFreePages(flags, order) __get_free_pages(flags, order)
 #else
 #define __GetFreePages(flags, order) __get_free_pages(flags, order, 0)
@@ -1282,7 +1281,7 @@
 /*
 **	/proc directory entry and proc_info function
 */
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,27)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,27)
 static struct proc_dir_entry proc_scsi_sym53c8xx = {
     PROC_SCSI_SYM53C8XX, 9, NAME53C8XX,
     S_IFDIR | S_IRUGO | S_IXUGO, 2
@@ -1307,7 +1306,7 @@
 	driver_safe_setup __initdata	= SCSI_NCR_DRIVER_SAFE_SETUP;
 # ifdef	MODULE
 char *sym53c8xx = 0;	/* command line passed by insmod */
-#  if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,30)
+#  if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,30)
 MODULE_PARM(sym53c8xx, "s");
 #  endif
 # endif
@@ -2026,7 +2025,7 @@
 					/*  when lcb is not allocated.	*/
 	Scsi_Cmnd	*done_list;	/* Commands waiting for done()  */
 					/* callback to be invoked.      */ 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,93)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
 	spinlock_t	smp_lock;	/* Lock for SMP threading       */
 #endif
 
@@ -5843,7 +5842,7 @@
 			((driver_setup.irqm & 0x20) ? 0 : SA_INTERRUPT),
 #else
 			((driver_setup.irqm & 0x10) ? 0 : SA_SHIRQ) |
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,2,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,0)
 			((driver_setup.irqm & 0x20) ? 0 : SA_INTERRUPT),
 #else
 			0,
@@ -5907,7 +5906,7 @@
 	instance->max_id	= np->maxwide ? 16 : 8;
 	instance->max_lun	= MAX_LUN;
 #ifndef SCSI_NCR_IOMAPPED
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,29)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,29)
 	instance->base		= (unsigned long) np->reg;
 #else
 	instance->base		= (char *) np->reg;
@@ -7406,7 +7405,7 @@
 		}
 	}
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,99)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,99)
 	/*
 	**	Move residual byte count to user structure.
 	*/
@@ -12774,7 +12773,7 @@
 	return 1;
 }
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,13)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,13)
 #ifndef MODULE
 __setup("sym53c8xx=", sym53c8xx_setup);
 #endif
@@ -12915,7 +12914,7 @@
 	**    Initialize driver general stuff.
 	*/
 #ifdef SCSI_NCR_PROC_INFO_SUPPORT
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,27)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,27)
      tpnt->proc_dir  = &proc_scsi_sym53c8xx;
 #else
      tpnt->proc_name = NAME53C8XX;
@@ -13244,7 +13243,7 @@
 		pci_write_config_word(pdev, PCI_COMMAND, command);
 	}
 
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,2,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,0)
 	if ( is_prep ) {
 		if (io_port >= 0x10000000) {
 			printk(NAME53C8XX ": reallocating io_port (Wacky IBM)");
@@ -13270,7 +13269,7 @@
 
 #if defined(__i386__) && !defined(MODULE)
 	if (!cache_line_size) {
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,1,75)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,75)
 		extern char x86;
 		switch(x86) {
 #else
@@ -14719,10 +14718,10 @@
 
 MODULE_LICENSE("GPL");
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 static
 #endif
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,0) || defined(MODULE)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) || defined(MODULE)
 Scsi_Host_Template driver_template = SYM53C8XX;
 #include "scsi_module.c"
 #endif
diff -Nru a/drivers/scsi/sym53c8xx_2/sym53c8xx.h b/drivers/scsi/sym53c8xx_2/sym53c8xx.h
--- a/drivers/scsi/sym53c8xx_2/sym53c8xx.h	Wed Apr 30 22:28:19 2003
+++ b/drivers/scsi/sym53c8xx_2/sym53c8xx.h	Wed Apr 30 22:28:19 2003
@@ -106,22 +106,22 @@
 #include <scsi/scsicam.h>
 
 #define SYM53C8XX {							\
-	name:			"sym53c8xx",				\
-	detect:			sym53c8xx_detect,			\
-	release:		sym53c8xx_release,			\
-	info:			sym53c8xx_info, 			\
-	queuecommand:		sym53c8xx_queue_command,		\
-	slave_configure:	sym53c8xx_slave_configure,		\
-	eh_abort_handler:	sym53c8xx_eh_abort_handler,		\
-	eh_device_reset_handler:sym53c8xx_eh_device_reset_handler,	\
-	eh_bus_reset_handler:	sym53c8xx_eh_bus_reset_handler,		\
-	eh_host_reset_handler:	sym53c8xx_eh_host_reset_handler,	\
-	can_queue:		0,					\
-	this_id:		7,					\
-	sg_tablesize:		0,					\
-	cmd_per_lun:		0,					\
-	use_clustering:		DISABLE_CLUSTERING,			\
-	highmem_io:		1}
+	.name			= "sym53c8xx",				\
+	.detect			= sym53c8xx_detect,			\
+	.release		= sym53c8xx_release,			\
+	.info			= sym53c8xx_info, 			\
+	.queuecommand		= sym53c8xx_queue_command,		\
+	.slave_configure	= sym53c8xx_slave_configure,		\
+	.eh_abort_handler	= sym53c8xx_eh_abort_handler,		\
+	.eh_device_reset_handler	= sym53c8xx_eh_device_reset_handler,\
+	.eh_bus_reset_handler	= sym53c8xx_eh_bus_reset_handler,	\
+	.eh_host_reset_handler	= sym53c8xx_eh_host_reset_handler,	\
+	.can_queue		= 0,					\
+	.this_id		= 7,					\
+	.sg_tablesize		= 0,					\
+	.cmd_per_lun		= 0,					\
+	.use_clustering		= DISABLE_CLUSTERING,			\
+	.highmem_io		= 1}
 
 #endif /* defined(HOSTS_C) || defined(MODULE) */ 
 
diff -Nru a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c	Wed Apr 30 22:28:20 2003
@@ -1009,7 +1009,7 @@
 /*
  *  Linux entry point of the interrupt handler.
  */
-static void sym53c8xx_intr(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t sym53c8xx_intr(int irq, void *dev_id, struct pt_regs * regs)
 {
 	unsigned long flags;
 	hcb_p np = (hcb_p) dev_id;
@@ -1029,6 +1029,8 @@
 	SYM_UNLOCK_HCB(np, flags);
 
 	if (DEBUG_FLAGS & DEBUG_TINY) printf_debug ("]\n");
+
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/drivers/scsi/t128.c b/drivers/scsi/t128.c
--- a/drivers/scsi/t128.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/scsi/t128.c	Wed Apr 30 22:28:16 2003
@@ -248,14 +248,14 @@
 	else 
 	    instance->irq = NCR5380_probe_irq(instance, T128_IRQS);
 
-	if (instance->irq != IRQ_NONE) 
+	if (instance->irq != SCSI_IRQ_NONE) 
 	    if (request_irq(instance->irq, t128_intr, SA_INTERRUPT, "t128", instance)) {
 		printk("scsi%d : IRQ%d not free, interrupts disabled\n", 
 		    instance->host_no, instance->irq);
-		instance->irq = IRQ_NONE;
+		instance->irq = SCSI_IRQ_NONE;
 	    } 
 
-	if (instance->irq == IRQ_NONE) {
+	if (instance->irq == SCSI_IRQ_NONE) {
 	    printk("scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
 	    printk("scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
 	}
@@ -265,7 +265,7 @@
 #endif
 
 	printk("scsi%d : at 0x%08lx", instance->host_no, instance->base);
-	if (instance->irq == IRQ_NONE)
+	if (instance->irq == SCSI_IRQ_NONE)
 	    printk (" interrupts disabled");
 	else 
 	    printk (" irq %d", instance->irq);
diff -Nru a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
--- a/drivers/scsi/tmscsim.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/scsi/tmscsim.c	Wed Apr 30 22:28:20 2003
@@ -3045,7 +3045,7 @@
     /* TO DO: We should check for outstanding commands first. */
     dc390_shutdown (host);
 
-    if (host->irq != IRQ_NONE)
+    if (host->irq != SCSI_IRQ_NONE)
     {
 	DEBUG0(printk(KERN_INFO "DC390: Free IRQ %i\n",host->irq);)
 	free_irq (host->irq, pACB);
diff -Nru a/drivers/scsi/tmscsim.h b/drivers/scsi/tmscsim.h
--- a/drivers/scsi/tmscsim.h	Wed Apr 30 22:28:16 2003
+++ b/drivers/scsi/tmscsim.h	Wed Apr 30 22:28:16 2003
@@ -11,7 +11,7 @@
 #include <linux/types.h>
 #include <linux/config.h>
 
-#define IRQ_NONE 255
+#define SCSI_IRQ_NONE 255
 
 #define MAX_ADAPTER_NUM 	4
 #define MAX_SG_LIST_BUF 	16	/* Not used */
diff -Nru a/drivers/scsi/u14-34f.c b/drivers/scsi/u14-34f.c
--- a/drivers/scsi/u14-34f.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/scsi/u14-34f.c	Wed Apr 30 22:28:07 2003
@@ -604,7 +604,7 @@
 #define H2DEV(x) cpu_to_le32(x)
 #define DEV2H(x) le32_to_cpu(x)
 
-static void do_interrupt_handler(int, void *, struct pt_regs *);
+static irqreturn_t do_interrupt_handler(int, void *, struct pt_regs *);
 static void flush_dev(Scsi_Device *, unsigned long, unsigned int, unsigned int);
 static int do_trace = FALSE;
 static int setup_done = FALSE;
@@ -1890,7 +1890,9 @@
    return;
 }
 
-static void do_interrupt_handler(int irq, void *shap, struct pt_regs *regs) {
+static irqreturn_t do_interrupt_handler(int irq, void *shap,
+					struct pt_regs *regs)
+{
    unsigned int j;
    unsigned long spin_flags;
 
@@ -1900,6 +1902,7 @@
    spin_lock_irqsave(sh[j]->host_lock, spin_flags);
    ihdlr(irq, j);
    spin_unlock_irqrestore(sh[j]->host_lock, spin_flags);
+   return IRQ_HANDLED;
 }
 
 static int u14_34f_release(struct Scsi_Host *shpnt) {
diff -Nru a/drivers/scsi/ultrastor.c b/drivers/scsi/ultrastor.c
--- a/drivers/scsi/ultrastor.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/scsi/ultrastor.c	Wed Apr 30 22:28:09 2003
@@ -288,7 +288,7 @@
 #endif
 
 static void ultrastor_interrupt(int, void *, struct pt_regs *);
-static void do_ultrastor_interrupt(int, void *, struct pt_regs *);
+static irqreturn_t do_ultrastor_interrupt(int, void *, struct pt_regs *);
 static inline void build_sg_list(struct mscp *, Scsi_Cmnd *SCpnt);
 
 
@@ -1160,7 +1160,8 @@
 #endif
 }
 
-static void do_ultrastor_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t do_ultrastor_interrupt(int irq, void *dev_id,
+						struct pt_regs *regs)
 {
     unsigned long flags;
     struct Scsi_Host *dev = dev_id;
@@ -1168,6 +1169,7 @@
     spin_lock_irqsave(dev->host_lock, flags);
     ultrastor_interrupt(irq, dev_id, regs);
     spin_unlock_irqrestore(dev->host_lock, flags);
+    return IRQ_HANDLED;
 }
 
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/scsi/wd7000.c b/drivers/scsi/wd7000.c
--- a/drivers/scsi/wd7000.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/scsi/wd7000.c	Wed Apr 30 22:28:19 2003
@@ -1121,7 +1121,8 @@
 	dprintk("wd7000_intr_handle: return from interrupt handler\n");
 }
 
-static void do_wd7000_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t do_wd7000_intr_handle(int irq, void *dev_id,
+					struct pt_regs *regs)
 {
 	unsigned long flags;
 	struct Scsi_Host *host = dev_id;
@@ -1129,6 +1130,7 @@
 	spin_lock_irqsave(host->host_lock, flags);
 	wd7000_intr_handle(irq, dev_id, regs);
 	spin_unlock_irqrestore(host->host_lock, flags);
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/drivers/serial/21285.c b/drivers/serial/21285.c
--- a/drivers/serial/21285.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/serial/21285.c	Wed Apr 30 22:28:14 2003
@@ -414,11 +414,6 @@
 	}
 }
 
-static kdev_t serial21285_console_device(struct console *c)
-{
-	return mk_kdev(SERIAL_21285_MAJOR, SERIAL_21285_MINOR);
-}
-
 static void __init
 serial21285_get_options(struct uart_port *port, int *baud,
 			int *parity, int *bits)
@@ -479,15 +474,17 @@
 	return uart_set_options(port, co, baud, parity, bits, flow);
 }
 
+extern struct uart_driver serial21285_reg;
 #ifdef CONFIG_SERIAL_21285_OLD
 static struct console serial21285_old_cons =
 {
 	.name		= SERIAL_21285_OLD_NAME,
 	.write		= serial21285_console_write,
-	.device		= serial21285_console_device,
+	.device		= uart_console_device,
 	.setup		= serial21285_console_setup,
 	.flags		= CON_PRINTBUFFER,
 	.index		= -1,
+	.data		= &serial21285_reg,
 };
 #endif
 
@@ -495,10 +492,11 @@
 {
 	.name		= SERIAL_21285_NAME,
 	.write		= serial21285_console_write,
-	.device		= serial21285_console_device,
+	.device		= uart_console_device,
 	.setup		= serial21285_console_setup,
 	.flags		= CON_PRINTBUFFER,
 	.index		= -1,
+	.data		= &serial21285_reg,
 };
 
 static int __init rs285_console_init(void)
@@ -517,7 +515,7 @@
 static struct uart_driver serial21285_reg = {
 	.owner			= THIS_MODULE,
 	.driver_name		= "ttyFB",
-	.dev_name		= "ttyFB%d",
+	.dev_name		= "ttyFB",
 	.major			= SERIAL_21285_MAJOR,
 	.minor			= SERIAL_21285_MINOR,
 	.nr			= 1,
diff -Nru a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c
--- a/drivers/serial/68328serial.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/serial/68328serial.c	Wed Apr 30 22:28:18 2003
@@ -151,20 +151,20 @@
 DECLARE_MUTEX(tmp_buf_sem);
 
 static inline int serial_paranoia_check(struct m68k_serial *info,
-					kdev_t device, const char *routine)
+					char *name, const char *routine)
 {
 #ifdef SERIAL_PARANOIA_CHECK
 	static const char *badmagic =
-		"Warning: bad magic number for serial struct (%d, %d) in %s\n";
+		"Warning: bad magic number for serial struct %s in %s\n";
 	static const char *badinfo =
-		"Warning: null m68k_serial for (%d, %d) in %s\n";
+		"Warning: null m68k_serial for %s in %s\n";
 
 	if (!info) {
-		printk(badinfo, major(device), minor(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (info->magic != SERIAL_MAGIC) {
-		printk(badmagic, major(device), minor(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -216,7 +216,7 @@
 	m68328_uart *uart = &uart_addr[info->line];
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_stop"))
+	if (serial_paranoia_check(info, tty->name, "rs_stop"))
 		return;
 	
 	save_flags(flags); cli();
@@ -246,7 +246,7 @@
 	m68328_uart *uart = &uart_addr[info->line];
 	unsigned long flags;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_start"))
+	if (serial_paranoia_check(info, tty->name, "rs_start"))
 		return;
 	
 	save_flags(flags); cli();
@@ -711,7 +711,7 @@
 {
 	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
 
-	if (serial_paranoia_check(info, tty->device, "rs_set_ldisc"))
+	if (serial_paranoia_check(info, tty->name, "rs_set_ldisc"))
 		return;
 
 	info->is_cons = (tty->termios->c_line == N_TTY);
@@ -725,7 +725,7 @@
 	m68328_uart *uart = &uart_addr[info->line];
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_flush_chars"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
 		return;
 #ifndef USE_INTS
 	for(;;) {
@@ -774,7 +774,7 @@
 	m68328_uart *uart = &uart_addr[info->line];
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_write"))
+	if (serial_paranoia_check(info, tty->name, "rs_write"))
 		return 0;
 
 	if (!tty || !info->xmit_buf)
@@ -838,7 +838,7 @@
 	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
 	int	ret;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_write_room"))
+	if (serial_paranoia_check(info, tty->name, "rs_write_room"))
 		return 0;
 	ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
 	if (ret < 0)
@@ -850,7 +850,7 @@
 {
 	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_chars_in_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
 		return 0;
 	return info->xmit_cnt;
 }
@@ -859,7 +859,7 @@
 {
 	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_flush_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
 		return;
 	cli();
 	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
@@ -882,7 +882,7 @@
 {
 	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
 
-	if (serial_paranoia_check(info, tty->device, "rs_throttle"))
+	if (serial_paranoia_check(info, tty->name, "rs_throttle"))
 		return;
 	
 	if (I_IXOFF(tty))
@@ -895,7 +895,7 @@
 {
 	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
 
-	if (serial_paranoia_check(info, tty->device, "rs_unthrottle"))
+	if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
 		return;
 	
 	if (I_IXOFF(tty)) {
@@ -1035,7 +1035,7 @@
 	struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
 	int retval;
 
-	if (serial_paranoia_check(info, tty->device, "rs_ioctl"))
+	if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
 		return -ENODEV;
 
 	if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
@@ -1140,7 +1140,7 @@
 	m68328_uart *uart = &uart_addr[info->line];
 	unsigned long flags;
 
-	if (!info || serial_paranoia_check(info, tty->device, "rs_close"))
+	if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
 		return;
 	
 	save_flags(flags); cli();
@@ -1198,8 +1198,8 @@
 	uart->ustcnt &= ~(USTCNT_RXEN | USTCNT_RX_INTR_MASK);
 
 	shutdown(info);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -1233,7 +1233,7 @@
 {
 	struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_hangup"))
+	if (serial_paranoia_check(info, tty->name, "rs_hangup"))
 		return;
 	
 	rs_flush_buffer(tty);
@@ -1277,7 +1277,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		if (info->flags & S_NORMAL_ACTIVE)
 			return -EBUSY;
 		if ((info->flags & S_CALLOUT_ACTIVE) &&
@@ -1374,14 +1374,14 @@
 	struct m68k_serial	*info;
 	int 			retval, line;
 
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	
 	if (line >= NR_PORTS || line < 0) /* we have exactly one */
 		return -ENODEV;
 
 	info = &m68k_soft[line];
 
-	if (serial_paranoia_check(info, tty->device, "rs_open"))
+	if (serial_paranoia_check(info, tty->name, "rs_open"))
 		return -ENODEV;
 
 	info->count++;
@@ -1401,7 +1401,7 @@
 	}
 
 	if ((info->count == 1) && (info->flags & S_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->normal_termios;
 		else 
 			*tty->termios = info->callout_termios;
@@ -1662,9 +1662,10 @@
 }
 
 
-static kdev_t m68328_console_device(struct console *c)
+static struct tty_driver *m68328_console_device(struct console *c, int *index)
 {
-	return mk_kdev(TTY_MAJOR, 64 + c->index);
+	*index = c->index;
+	return &serial_driver;
 }
 
 
diff -Nru a/drivers/serial/68360serial.c b/drivers/serial/68360serial.c
--- a/drivers/serial/68360serial.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/serial/68360serial.c	Wed Apr 30 22:28:18 2003
@@ -282,7 +282,7 @@
 static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout);
 
 static inline int serial_paranoia_check(ser_info_t *info,
-					kdev_t device, const char *routine)
+					char *name, const char *routine)
 {
 #ifdef SERIAL_PARANOIA_CHECK
 	static const char *badmagic =
@@ -291,11 +291,11 @@
 		"Warning: null async_struct for (%s) in %s\n";
 
 	if (!info) {
-		printk(badinfo, cdevname(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (info->magic != SERIAL_MAGIC) {
-		printk(badmagic, cdevname(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -339,7 +339,7 @@
  	volatile struct scc_regs *sccp;
  	volatile struct smc_regs *smcp;
 
-	if (serial_paranoia_check(info, tty->device, "rs_stop"))
+	if (serial_paranoia_check(info, tty->name, "rs_stop"))
 		return;
 	
 	local_irq_save(flags);
@@ -364,7 +364,7 @@
 	volatile struct scc_regs *sccp;
 	volatile struct smc_regs *smcp;
 
-	if (serial_paranoia_check(info, tty->device, "rs_stop"))
+	if (serial_paranoia_check(info, tty->name, "rs_stop"))
 		return;
 	
 	local_irq_save(flags);
@@ -1036,7 +1036,7 @@
 	ser_info_t *info = (ser_info_t *)tty->driver_data;
 	volatile QUICC_BD	*bdp;
 
-	if (serial_paranoia_check(info, tty->device, "rs_put_char"))
+	if (serial_paranoia_check(info, tty->name, "rs_put_char"))
 		return;
 
 	if (!tty)
@@ -1074,7 +1074,7 @@
 		return ret;
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_write"))
+	if (serial_paranoia_check(info, tty->name, "rs_write"))
 		return 0;
 
 	if (!tty) 
@@ -1127,7 +1127,7 @@
 	ser_info_t *info = (ser_info_t *)tty->driver_data;
 	int	ret;
 
-	if (serial_paranoia_check(info, tty->device, "rs_write_room"))
+	if (serial_paranoia_check(info, tty->name, "rs_write_room"))
 		return 0;
 
 	if ((info->tx_cur->status & BD_SC_READY) == 0) {
@@ -1147,7 +1147,7 @@
 {
 	ser_info_t *info = (ser_info_t *)tty->driver_data;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_chars_in_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
 		return 0;
 	return 0;
 }
@@ -1156,7 +1156,7 @@
 {
 	ser_info_t *info = (ser_info_t *)tty->driver_data;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_flush_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
 		return;
 
 	/* There is nothing to "flush", whatever we gave the CPM
@@ -1179,7 +1179,7 @@
 
 	ser_info_t *info = (ser_info_t *)tty->driver_data;
 
-	if (serial_paranoia_check(info, tty->device, "rs_send_char"))
+	if (serial_paranoia_check(info, tty->name, "rs_send_char"))
 		return;
 
 	bdp = info->tx_cur;
@@ -1218,7 +1218,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_throttle"))
+	if (serial_paranoia_check(info, tty->name, "rs_throttle"))
 		return;
 	
 	if (I_IXOFF(tty))
@@ -1244,7 +1244,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_unthrottle"))
+	if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
 		return;
 	
 	if (I_IXOFF(tty)) {
@@ -1458,7 +1458,7 @@
 	/* struct async_icount_24 cnow;*/ 	/* kernel counter temps */
 	struct serial_icounter_struct *p_cuser;	/* user space */
 
-	if (serial_paranoia_check(info, tty->device, "rs_ioctl"))
+	if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
 		return -ENODEV;
 
 	if ((cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) {
@@ -1671,7 +1671,7 @@
 	volatile struct smc_regs	*smcp;
 	volatile struct scc_regs	*sccp;
 
-	if (!info || serial_paranoia_check(info, tty->device, "rs_close"))
+	if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
 		return;
 
 	state = info->state;
@@ -1754,8 +1754,8 @@
 		rs_360_wait_until_sent(tty, info->timeout);
 	}
 	shutdown(info);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -1785,7 +1785,7 @@
 	/*int lsr;*/
 	volatile QUICC_BD *bdp;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_wait_until_sent"))
+	if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
 		return;
 
 #ifdef maybe
@@ -1852,7 +1852,7 @@
 	ser_info_t *info = (ser_info_t *)tty->driver_data;
 	struct serial_state *state = info->state;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_hangup"))
+	if (serial_paranoia_check(info, tty->name, "rs_hangup"))
 		return;
 
 	state = info->state;
@@ -1905,7 +1905,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		if (info->flags & ASYNC_NORMAL_ACTIVE)
 			return -EBUSY;
 		if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
@@ -2041,18 +2041,17 @@
 	ser_info_t	*info;
 	int 		retval, line;
 
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if ((line < 0) || (line >= NR_PORTS))
 		return -ENODEV;
 	retval = get_async_struct(line, &info);
 	if (retval)
 		return retval;
-	if (serial_paranoia_check(info, tty->device, "rs_open"))
+	if (serial_paranoia_check(info, tty->name, "rs_open"))
 		return -ENODEV;
 
 #ifdef SERIAL_DEBUG_OPEN
-	printk("rs_open %s%d, count = %d\n", tty->driver.name, info->line,
-	       info->state->count);
+	printk("rs_open %s, count = %d\n", tty->name, info->state->count);
 #endif
 	tty->driver_data = info;
 	info->tty = tty;
@@ -2077,7 +2076,7 @@
 
 	if ((info->state->count == 1) &&
 	    (info->flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->state->normal_termios;
 		else 
 			*tty->termios = info->state->callout_termios;
@@ -2088,7 +2087,7 @@
 	info->pgrp = current->pgrp;
 
 #ifdef SERIAL_DEBUG_OPEN
-	printk("rs_open ttys%d successful...", info->line);
+	printk("rs_open %s successful...", tty->name);
 #endif
 	return 0;
 }
@@ -2522,9 +2521,10 @@
 }
 #endif
 
-static kdev_t serial_console_device(struct console *c)
+static struct tty_struct *serial_console_device(struct console *c, int *index)
 {
-	return MKDEV(TTY_MAJOR, 64 + c->index);
+	*index = c->index;
+	return &serial_driver;
 }
 
 
diff -Nru a/drivers/serial/8250.c b/drivers/serial/8250.c
--- a/drivers/serial/8250.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/serial/8250.c	Wed Apr 30 22:28:04 2003
@@ -984,7 +984,7 @@
  * This means we need to loop through all ports. checking that they
  * don't have an interrupt pending.
  */
-static void serial8250_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t serial8250_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct irq_info *i = dev_id;
 	struct list_head *l, *end = NULL;
@@ -1024,6 +1024,8 @@
 	spin_unlock(&i->lock);
 
 	DEBUG_INTR("end.\n");
+	/* FIXME! Was it really ours? */
+	return IRQ_HANDLED;
 }
 
 /*
@@ -1828,7 +1830,7 @@
 	for (i = 0, up = serial8250_ports; i < ARRAY_SIZE(old_serial_port);
 	     i++, up++) {
 		up->port.iobase   = old_serial_port[i].port;
-		up->port.irq      = irq_cannonicalize(old_serial_port[i].irq);
+		up->port.irq      = irq_canonicalize(old_serial_port[i].irq);
 		up->port.uartclk  = old_serial_port[i].baud_base * 16;
 		up->port.flags    = old_serial_port[i].flags |
 				    UPF_RESOURCES;
@@ -1942,11 +1944,6 @@
 	serial_out(up, UART_IER, ier);
 }
 
-static kdev_t serial8250_console_device(struct console *co)
-{
-	return mk_kdev(TTY_MAJOR, 64 + co->index);
-}
-
 static int __init serial8250_console_setup(struct console *co, char *options)
 {
 	struct uart_port *port;
@@ -1975,13 +1972,15 @@
 	return uart_set_options(port, co, baud, parity, bits, flow);
 }
 
+extern struct uart_driver serial8250_reg;
 static struct console serial8250_console = {
 	.name		= "ttyS",
 	.write		= serial8250_console_write,
-	.device		= serial8250_console_device,
+	.device		= uart_console_device,
 	.setup		= serial8250_console_setup,
 	.flags		= CON_PRINTBUFFER,
 	.index		= -1,
+	.data		= &serial8250_reg,
 };
 
 static int __init serial8250_console_init(void)
@@ -2001,9 +2000,9 @@
 	.owner			= THIS_MODULE,
 	.driver_name		= "serial",
 #ifdef CONFIG_DEVFS_FS
-	.dev_name		= "tts/%d",
+	.dev_name		= "tts/",
 #else
-	.dev_name		= "ttyS%d",
+	.dev_name		= "ttyS",
 #endif
 	.major			= TTY_MAJOR,
 	.minor			= 64,
diff -Nru a/drivers/serial/8250_acorn.c b/drivers/serial/8250_acorn.c
--- a/drivers/serial/8250_acorn.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/serial/8250_acorn.c	Wed Apr 30 22:28:15 2003
@@ -129,7 +129,6 @@
 	.remove 	= __devexit_p(serial_card_remove),
 	.id_table	= serial_cids,
 	.drv = {
-		.devclass	= &tty_devclass,
 		.name		= "8250_acorn",
 	},
 };
diff -Nru a/drivers/serial/8250_cs.c b/drivers/serial/8250_cs.c
--- a/drivers/serial/8250_cs.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/serial/8250_cs.c	Wed Apr 30 22:28:09 2003
@@ -122,15 +122,6 @@
 
 static dev_link_t *dev_list = NULL;
 
-/*====================================================================*/
-
-static void
-cs_error(client_handle_t handle, int func, int ret)
-{
-	error_info_t err = { func, ret };
-	CardServices(ReportError, handle, &err);
-}
-
 /*======================================================================
 
     After a card is removed, do_serial_release() will unregister
diff -Nru a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
--- a/drivers/serial/8250_pci.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/serial/8250_pci.c	Wed Apr 30 22:28:14 2003
@@ -23,6 +23,7 @@
 #include <linux/tty.h>
 #include <linux/serial.h>
 #include <linux/serial_core.h>
+#include <linux/8250_pci.h>
 
 #include <asm/bitops.h>
 #include <asm/byteorder.h>
@@ -126,7 +127,7 @@
 			return -ENOMEM;
 
 		req->io_type = UPIO_MEM;
-		req->iomap_base = port;
+		req->iomap_base = port + offset;
 		req->iomem_base = priv->remapped_bar[bar] + offset;
 		req->iomem_reg_shift = regshift;
 	} else {
@@ -2043,9 +2044,6 @@
 	.suspend	= pciserial_suspend_one,
 	.resume		= pciserial_resume_one,
 	.id_table	= serial_pci_tbl,
-	.driver = {
-		.devclass = &tty_devclass,
-	},
 };
 
 static int __init serial8250_pci_init(void)
diff -Nru a/drivers/serial/Kconfig b/drivers/serial/Kconfig
--- a/drivers/serial/Kconfig	Wed Apr 30 22:28:17 2003
+++ b/drivers/serial/Kconfig	Wed Apr 30 22:28:17 2003
@@ -97,7 +97,7 @@
 	  Say Y here if you have dumb serial boards other than the four
 	  standard COM 1/2/3/4 ports. This may happen if you have an AST
 	  FourPort, Accent Async, Boca (read the Boca mini-HOWTO, available
-	  from <http://www.linuxdoc.org/docs.html#howto>), or other custom
+	  from <http://www.tldp.org/docs.html#howto>), or other custom
 	  serial port hardware which acts similar to standard serial port
 	  hardware. If you only use the standard COM 1/2/3/4 ports, you can
 	  say N here to save some memory. You can also say Y if you have an
diff -Nru a/drivers/serial/amba.c b/drivers/serial/amba.c
--- a/drivers/serial/amba.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/serial/amba.c	Wed Apr 30 22:28:04 2003
@@ -640,11 +640,6 @@
 	UART_PUT_CR(port, old_cr);
 }
 
-static kdev_t ambauart_console_device(struct console *co)
-{
-	return mk_kdev(SERIAL_AMBA_MAJOR, SERIAL_AMBA_MINOR + co->index);
-}
-
 static void __init
 ambauart_console_get_options(struct uart_port *port, int *baud,
 			     int *parity, int *bits)
@@ -696,13 +691,15 @@
 	return uart_set_options(port, co, baud, parity, bits, flow);
 }
 
+extern struct uart_driver amba_reg;
 static struct console amba_console = {
 	.name		= "ttyAM",
 	.write		= ambauart_console_write,
-	.device		= ambauart_console_device,
+	.device		= uart_console_device,
 	.setup		= ambauart_console_setup,
 	.flags		= CON_PRINTBUFFER,
 	.index		= -1,
+	.data		= &amba_reg,
 };
 
 static int __init ambauart_console_init(void)
@@ -720,7 +717,7 @@
 static struct uart_driver amba_reg = {
 	.owner			= THIS_MODULE,
 	.driver_name		= "ttyAM",
-	.dev_name		= "ttyAM%d",
+	.dev_name		= "ttyAM",
 	.major			= SERIAL_AMBA_MAJOR,
 	.minor			= SERIAL_AMBA_MINOR,
 	.nr			= UART_NR,
diff -Nru a/drivers/serial/anakin.c b/drivers/serial/anakin.c
--- a/drivers/serial/anakin.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/serial/anakin.c	Wed Apr 30 22:28:05 2003
@@ -444,12 +444,6 @@
 	}
 }
 
-static kdev_t
-anakin_console_device(struct console *co)
-{
-	return mk_kdev(SERIAL_ANAKIN_MAJOR, SERIAL_ANAKIN_MINOR + co->index);
-}
-
 /*
  * Read the current UART setup.
  */
@@ -493,10 +487,11 @@
 	return uart_set_options(port, co, baud, parity, bits);
 }
 
+extern struct uart_driver anakin_reg;
 static struct console anakin_console = {
 	.name		= SERIAL_ANAKIN_NAME,
 	.write		= anakin_console_write,
-	.device		= anakin_console_device,
+	.device		= uart_console_device,
 	.setup		= anakin_console_setup,
 	.flags		= CON_PRINTBUFFER,
 	.index		= -1,
@@ -514,7 +509,7 @@
 #define ANAKIN_CONSOLE		NULL
 #endif
 
-static struct uart_register anakin_reg = {
+static struct uart_driver anakin_reg = {
 	.driver_name		= SERIAL_ANAKIN_NAME,
 	.dev_name		= SERIAL_ANAKIN_NAME,
 	.major			= SERIAL_ANAKIN_MAJOR,
diff -Nru a/drivers/serial/clps711x.c b/drivers/serial/clps711x.c
--- a/drivers/serial/clps711x.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/serial/clps711x.c	Wed Apr 30 22:28:06 2003
@@ -503,11 +503,6 @@
 	clps_writel(syscon, SYSCON(port));
 }
 
-static kdev_t clps711xuart_console_device(struct console *co)
-{
-	return mk_kdev(SERIAL_CLPS711X_MAJOR, SERIAL_CLPS711X_MINOR + co->index);
-}
-
 static void __init
 clps711xuart_console_get_options(struct uart_port *port, int *baud,
 				 int *parity, int *bits)
@@ -558,13 +553,15 @@
 	return uart_set_options(port, co, baud, parity, bits, flow);
 }
 
+extern struct uart_driver clps711x_reg;
 static struct console clps711x_console = {
 	.name		= "ttyCL",
 	.write		= clps711xuart_console_write,
-	.device		= clps711xuart_console_device,
+	.device		= uart_console_device,
 	.setup		= clps711xuart_console_setup,
 	.flags		= CON_PRINTBUFFER,
 	.index		= -1,
+	.data		= &clps711x_reg,
 };
 
 static int __init clps711xuart_console_init(void)
@@ -581,7 +578,7 @@
 
 static struct uart_driver clps711x_reg = {
 	.driver_name		= "ttyCL",
-	.dev_name		= "ttyCL%d",
+	.dev_name		= "ttyCL",
 	.major			= SERIAL_CLPS711X_MAJOR,
 	.minor			= SERIAL_CLPS711X_MINOR,
 	.nr			= UART_NR,
diff -Nru a/drivers/serial/core.c b/drivers/serial/core.c
--- a/drivers/serial/core.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/serial/core.c	Wed Apr 30 22:28:06 2003
@@ -577,8 +577,7 @@
 	struct uart_port *port = state->port;
 	unsigned long flags;
 
-	DPRINTK("uart_flush_buffer(%d) called\n",
-	        minor(tty->device) - tty->driver.minor_start);
+	DPRINTK("uart_flush_buffer(%d) called\n", tty->index);
 
 	spin_lock_irqsave(&port->lock, flags);
 	uart_circ_clear(&state->info->xmit);
@@ -683,7 +682,7 @@
 	if (HIGH_BITS_OFFSET)
 		new_port += (unsigned long) new_serial.port_high << HIGH_BITS_OFFSET;
 
-	new_serial.irq = irq_cannonicalize(new_serial.irq);
+	new_serial.irq = irq_canonicalize(new_serial.irq);
 
 	/*
 	 * This semaphore protects state->count.  It is also
@@ -782,8 +781,12 @@
 		/*
 		 * Claim and map the new regions
 		 */
-		if (port->type != PORT_UNKNOWN)
+		if (port->type != PORT_UNKNOWN) {
 			retval = port->ops->request_port(port);
+		} else {
+			/* Always success - Jean II */
+			retval = 0;
+		}
 
 		/*
 		 * If we fail to request resources for the
@@ -835,7 +838,7 @@
 			 * need to rate-limit; it's CAP_SYS_ADMIN only. */
 			if (port->flags & UPF_SPD_MASK) {
 				printk(KERN_NOTICE "%s sets custom speed on %s%d. This is deprecated.\n",
-				       current->comm, state->info->tty->driver.name, 
+				       current->comm, state->info->tty->driver->name, 
 				       state->port->line);
 			}
 			uart_change_speed(state, NULL);
@@ -1229,8 +1232,8 @@
 		state->count = 1;
 	}
 	if (--state->count < 0) {
-		printk("rs_close: bad serial port count for %s%d: %d\n",
-		       tty->driver.name, port->line, state->count);
+		printk("rs_close: bad serial port count for %s: %d\n",
+		       tty->name, state->count);
 		state->count = 0;
 	}
 	if (state->count)
@@ -1550,20 +1553,20 @@
  */
 static int uart_open(struct tty_struct *tty, struct file *filp)
 {
-	struct uart_driver *drv = (struct uart_driver *)tty->driver.driver_state;
+	struct uart_driver *drv = (struct uart_driver *)tty->driver->driver_state;
 	struct uart_state *state;
-	int retval, line = minor(tty->device) - tty->driver.minor_start;
+	int retval, line = tty->index;
 
 	BUG_ON(!kernel_locked());
 	DPRINTK("uart_open(%d) called\n", line);
 
 	/*
-	 * tty->driver.num won't change, so we won't fail here with
+	 * tty->driver->num won't change, so we won't fail here with
 	 * tty->driver_data set to something non-NULL (and therefore
 	 * we won't get caught by uart_close()).
 	 */
 	retval = -ENODEV;
-	if (line >= tty->driver.num)
+	if (line >= tty->driver->num)
 		goto fail;
 
 	/*
@@ -1957,7 +1960,7 @@
 static inline void
 uart_report_port(struct uart_driver *drv, struct uart_port *port)
 {
-	printk(drv->dev_name, port->line);
+	printk("%s%d", drv->dev_name, port->line);
 	printk(" at ");
 	switch (port->iotype) {
 	case UPIO_PORT:
@@ -2184,13 +2187,21 @@
  */
 void uart_unregister_driver(struct uart_driver *drv)
 {
-	tty_unregister_driver(drv->tty_driver);
-
+	struct tty_driver *p = drv->tty_driver;
+	drv->tty_driver = NULL;
+	tty_unregister_driver(p);
 	kfree(drv->state);
 	kfree(drv->tty_driver->termios);
 	kfree(drv->tty_driver);
 }
 
+struct tty_driver *uart_console_device(struct console *co, int *index)
+{
+	struct uart_driver *p = co->data;
+	*index = co->index;
+	return p->tty_driver;
+}
+
 /**
  *	uart_add_one_port - attach a driver-defined port structure
  *	@drv: pointer to the uart low level driver structure for this port
@@ -2231,7 +2242,7 @@
 	 * Register the port whether it's detected or not.  This allows
 	 * setserial to be used to alter this ports parameters.
 	 */
-	tty_register_device(drv->tty_driver, drv->minor + port->line);
+	tty_register_device(drv->tty_driver, port->line);
 
  out:
 	up(&port_sem);
@@ -2263,7 +2274,7 @@
 	/*
 	 * Remove the devices from devfs
 	 */
-	tty_unregister_device(drv->tty_driver, drv->minor + port->line);
+	tty_unregister_device(drv->tty_driver, port->line);
 
 	uart_unconfigure_port(drv, state);
 	state->port = NULL;
@@ -2410,7 +2421,7 @@
 
 	if (line < 0 || line >= drv->nr) {
 		printk(KERN_ERR "Attempt to unregister ");
-		printk(drv->dev_name, line);
+		printk("%s%d", drv->dev_name, line);
 		printk("\n");
 		return;
 	}
diff -Nru a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c
--- a/drivers/serial/mcfserial.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/serial/mcfserial.c	Wed Apr 30 22:28:08 2003
@@ -148,20 +148,20 @@
 
 
 static inline int serial_paranoia_check(struct mcf_serial *info,
-					kdev_t device, const char *routine)
+					char *name, const char *routine)
 {
 #ifdef SERIAL_PARANOIA_CHECK
 	static const char *badmagic =
-		"MCFRS(warning): bad magic number for serial struct (%d, %d) in %s\n";
+		"MCFRS(warning): bad magic number for serial struct %s in %s\n";
 	static const char *badinfo =
-		"MCFRS(warning): null mcf_serial for (%d, %d) in %s\n";
+		"MCFRS(warning): null mcf_serial for %s in %s\n";
 
 	if (!info) {
-		printk(badinfo, MAJOR(device), MINOR(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (info->magic != SERIAL_MAGIC) {
-		printk(badmagic, MAJOR(device), MINOR(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -257,7 +257,7 @@
 	struct mcf_serial	*info = (struct mcf_serial *)tty->driver_data;
 	unsigned long		flags;
 
-	if (serial_paranoia_check(info, tty->device, "mcfrs_stop"))
+	if (serial_paranoia_check(info, tty->name, "mcfrs_stop"))
 		return;
 	
 	local_irq_save(flags);
@@ -273,7 +273,7 @@
 	struct mcf_serial	*info = (struct mcf_serial *)tty->driver_data;
 	unsigned long		flags;
 	
-	if (serial_paranoia_check(info, tty->device, "mcfrs_start"))
+	if (serial_paranoia_check(info, tty->name, "mcfrs_start"))
 		return;
 
 	local_irq_save(flags);
@@ -712,7 +712,7 @@
 	struct mcf_serial	*info = (struct mcf_serial *)tty->driver_data;
 	unsigned long		flags;
 
-	if (serial_paranoia_check(info, tty->device, "mcfrs_flush_chars"))
+	if (serial_paranoia_check(info, tty->name, "mcfrs_flush_chars"))
 		return;
 
 	if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
@@ -740,7 +740,7 @@
 		__FILE__, __LINE__, tty, from_user, buf, count);
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "mcfrs_write"))
+	if (serial_paranoia_check(info, tty->name, "mcfrs_write"))
 		return 0;
 
 	if (!tty || !info->xmit_buf)
@@ -792,7 +792,7 @@
 	struct mcf_serial *info = (struct mcf_serial *)tty->driver_data;
 	int	ret;
 				
-	if (serial_paranoia_check(info, tty->device, "mcfrs_write_room"))
+	if (serial_paranoia_check(info, tty->name, "mcfrs_write_room"))
 		return 0;
 	ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
 	if (ret < 0)
@@ -804,7 +804,7 @@
 {
 	struct mcf_serial *info = (struct mcf_serial *)tty->driver_data;
 				
-	if (serial_paranoia_check(info, tty->device, "mcfrs_chars_in_buffer"))
+	if (serial_paranoia_check(info, tty->name, "mcfrs_chars_in_buffer"))
 		return 0;
 	return info->xmit_cnt;
 }
@@ -814,7 +814,7 @@
 	struct mcf_serial	*info = (struct mcf_serial *)tty->driver_data;
 	unsigned long		flags;
 				
-	if (serial_paranoia_check(info, tty->device, "mcfrs_flush_buffer"))
+	if (serial_paranoia_check(info, tty->name, "mcfrs_flush_buffer"))
 		return;
 
 	local_irq_save(flags);
@@ -845,7 +845,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "mcfrs_throttle"))
+	if (serial_paranoia_check(info, tty->name, "mcfrs_throttle"))
 		return;
 	
 	if (I_IXOFF(tty))
@@ -864,7 +864,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "mcfrs_unthrottle"))
+	if (serial_paranoia_check(info, tty->name, "mcfrs_unthrottle"))
 		return;
 	
 	if (I_IXOFF(tty)) {
@@ -1002,7 +1002,7 @@
 	int retval, error;
 	int dtr, rts;
 
-	if (serial_paranoia_check(info, tty->device, "mcfrs_ioctl"))
+	if (serial_paranoia_check(info, tty->name, "mcfrs_ioctl"))
 		return -ENODEV;
 
 	if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
@@ -1159,7 +1159,7 @@
 	struct mcf_serial	*info = (struct mcf_serial *)tty->driver_data;
 	unsigned long		flags;
 
-	if (!info || serial_paranoia_check(info, tty->device, "mcfrs_close"))
+	if (!info || serial_paranoia_check(info, tty->name, "mcfrs_close"))
 		return;
 	
 	local_irq_save(flags);
@@ -1229,8 +1229,8 @@
 	} else
 #endif
 	shutdown(info);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -1264,7 +1264,7 @@
 {
 	struct mcf_serial * info = (struct mcf_serial *)tty->driver_data;
 	
-	if (serial_paranoia_check(info, tty->device, "mcfrs_hangup"))
+	if (serial_paranoia_check(info, tty->name, "mcfrs_hangup"))
 		return;
 	
 	mcfrs_flush_buffer(tty);
@@ -1308,7 +1308,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		if (info->flags & ASYNC_NORMAL_ACTIVE)
 			return -EBUSY;
 		if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
@@ -1416,15 +1416,14 @@
 	struct mcf_serial	*info;
 	int 			retval, line;
 
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if ((line < 0) || (line >= NR_PORTS))
 		return -ENODEV;
 	info = mcfrs_table + line;
-	if (serial_paranoia_check(info, tty->device, "mcfrs_open"))
+	if (serial_paranoia_check(info, tty->name, "mcfrs_open"))
 		return -ENODEV;
 #ifdef SERIAL_DEBUG_OPEN
-	printk("mcfrs_open %s%d, count = %d\n", tty->driver.name, info->line,
-	       info->count);
+	printk("mcfrs_open %s, count = %d\n", tty->name, info->count);
 #endif
 	info->count++;
 	tty->driver_data = info;
@@ -1447,7 +1446,7 @@
 	}
 
 	if ((info->count == 1) && (info->flags & ASYNC_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->normal_termios;
 		else 
 			*tty->termios = info->callout_termios;
@@ -1458,7 +1457,7 @@
 	info->pgrp = current->pgrp;
 
 #ifdef SERIAL_DEBUG_OPEN
-	printk("mcfrs_open ttyS%d successful...\n", info->line);
+	printk("mcfrs_open %s successful...\n", tty->name);
 #endif
 	return 0;
 }
@@ -1786,9 +1785,10 @@
 }
 
 
-static kdev_t mcfrs_console_device(struct console *c)
+static struct tty_driver *mcfrs_console_device(struct console *c, int *index)
 {
-	return mk_kdev(TTY_MAJOR, 64 + c->index);
+	*index = c->index;
+	return &mcfrs_serial_driver;
 }
 
 
diff -Nru a/drivers/serial/mux.c b/drivers/serial/mux.c
--- a/drivers/serial/mux.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/serial/mux.c	Wed Apr 30 22:28:14 2003
@@ -456,7 +456,7 @@
 
 		card->drv.owner = THIS_MODULE;
 		card->drv.driver_name = "ttyB";
-		card->drv.dev_name = "ttyB%d";
+		card->drv.dev_name = "ttyB";
 		card->drv.major = MUX_MAJOR;
 		card->drv.minor = port_cnt;
 		card->drv.nr = UART_NR;
diff -Nru a/drivers/serial/nb85e_uart.c b/drivers/serial/nb85e_uart.c
--- a/drivers/serial/nb85e_uart.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/serial/nb85e_uart.c	Wed Apr 30 22:28:15 2003
@@ -272,19 +272,16 @@
 	}
 }
 
-static kdev_t nb85e_uart_cons_device (struct console *c)
-{
-        return mk_kdev (TTY_MAJOR, NB85E_UART_MINOR_BASE + c->index);
-}
-
+extern struct uart_driver nb85e_uart_driver;
 static struct console nb85e_uart_cons =
 {
     .name	= "ttyS",
     .write	= nb85e_uart_cons_write,
-    .device	= nb85e_uart_cons_device,
+    .device	= uart_console_device,
     .flags	= CON_PRINTBUFFER,
     .cflag	= NB85E_UART_INIT_CFLAGS,
     .index	= -1,
+    .data	= &nb85e_uart_driver,
 };
 
 void nb85e_uart_cons_init (unsigned chan)
@@ -528,7 +525,7 @@
 	.owner			= THIS_MODULE,
 	.driver_name		= "nb85e_uart",
 #ifdef CONFIG_DEVFS_FS
-	.dev_name		= "tts/%d",
+	.dev_name		= "tts/",
 #else
 	.dev_name		= "ttyS",
 #endif
diff -Nru a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c
--- a/drivers/serial/sa1100.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/serial/sa1100.c	Wed Apr 30 22:28:05 2003
@@ -760,11 +760,6 @@
 	UART_PUT_UTCR3(sport, old_utcr3);
 }
 
-static kdev_t sa1100_console_device(struct console *co)
-{
-	return mk_kdev(SERIAL_SA1100_MAJOR, MINOR_START + co->index);
-}
-
 /*
  * If the port was already initialised (eg, by a boot loader),
  * try to determine the current setup.
@@ -827,13 +822,15 @@
 	return uart_set_options(&sport->port, co, baud, parity, bits, flow);
 }
 
+extern struct uart_driver sa1100_reg;
 static struct console sa1100_console = {
 	.name		= "ttySA",
 	.write		= sa1100_console_write,
-	.device		= sa1100_console_device,
+	.device		= uart_console_device,
 	.setup		= sa1100_console_setup,
 	.flags		= CON_PRINTBUFFER,
 	.index		= -1,
+	.data		= sa1100_reg,
 };
 
 static int __init sa1100_rs_console_init(void)
@@ -852,7 +849,7 @@
 static struct uart_driver sa1100_reg = {
 	.owner			= THIS_MODULE,
 	.driver_name		= "ttySA",
-	.dev_name		= "ttySA%d",
+	.dev_name		= "ttySA",
 	.major			= SERIAL_SA1100_MAJOR,
 	.minor			= MINOR_START,
 	.nr			= NR_PORTS,
@@ -882,7 +879,6 @@
 static struct device_driver sa11x0_serial_driver = {
 	.name		= "sa11x0_serial",
 	.bus		= &system_bus_type,
-	.devclass	= &tty_devclass,
 	.suspend	= sa1100_serial_suspend,
 	.resume		= sa1100_serial_resume,
 };
diff -Nru a/drivers/serial/serial98.c b/drivers/serial/serial98.c
--- a/drivers/serial/serial98.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/serial/serial98.c	Wed Apr 30 22:28:12 2003
@@ -136,16 +136,17 @@
 #ifdef CONFIG_SERIAL98_CONSOLE
 static void
 serial98_console_write(struct console *co, const char *s, unsigned int count);
-static kdev_t serial98_console_device(struct console *co);
 static int __init serial98_console_setup(struct console *co, char *options);
 
+extern struct uart_driver serial98_reg;
 static struct console serial98_console = {
 	.name		= "ttyS",
 	.write		= serial98_console_write,
-	.device		= serial98_console_device,
+	.device		= uart_console_device,
 	.setup		= serial98_console_setup,
 	.flags		= CON_PRINTBUFFER,
 	.index		= -1,
+	.data		= &serial98_reg,
 };
 
 #define SERIAL98_CONSOLE	&serial98_console
@@ -156,7 +157,7 @@
 static struct uart_driver serial98_reg = {
 	.owner			= THIS_MODULE,
 	.driver_name		= "serial98",
-	.dev_name		= "ttyS%d",
+	.dev_name		= "ttyS",
 	.major			= TTY_MAJOR,
 	.minor			= 64,
 	.nr			= SERIAL98_NR,
@@ -992,11 +993,6 @@
 
 	/* restore modem status interrupt */
 	outb(ier2, IER2_8251F);
-}
-
-static kdev_t serial98_console_device(struct console *co)
-{
-	return mk_kdev(TTY_MAJOR, 64 + co->index);
 }
 
 static int __init serial98_console_setup(struct console *co, char *options)
diff -Nru a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c
--- a/drivers/serial/sunsab.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/serial/sunsab.c	Wed Apr 30 22:28:08 2003
@@ -290,7 +290,7 @@
 	wake_up_interruptible(&up->port.info->delta_msr_wait);
 }
 
-static void sunsab_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sunsab_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct uart_sunsab_port *up = dev_id;
 	union sab82532_irq_status status;
@@ -339,6 +339,8 @@
 	}
 
 	spin_unlock_irqrestore(&up->port.lock, flags);
+
+	return IRQ_HANDLED;
 }
 
 /* port->lock is not held.  */
@@ -826,9 +828,9 @@
 	.owner			= THIS_MODULE,
 	.driver_name		= "serial",
 #ifdef CONFIG_DEVFS_FS
-	.dev_name		= "tts/%d",
+	.dev_name		= "tts/",
 #else
-	.dev_name		= "ttyS%d",
+	.dev_name		= "ttyS",
 #endif
 	.major			= TTY_MAJOR,
 };
@@ -861,11 +863,6 @@
 	sunsab_tec_wait(up);
 }
 
-static kdev_t sunsab_console_device(struct console *con)
-{
-	return mk_kdev(sunsab_reg.major, sunsab_reg.minor + con->index);
-}
-
 static int sunsab_console_setup(struct console *con, char *options)
 {
 	struct uart_sunsab_port *up = &sunsab_ports[con->index];
@@ -926,10 +923,11 @@
 static struct console sunsab_console = {
 	.name	=	"ttyS",
 	.write	=	sunsab_console_write,
-	.device	=	sunsab_console_device,
+	.device	=	uart_console_device,
 	.setup	=	sunsab_console_setup,
 	.flags	=	CON_PRINTBUFFER,
 	.index	=	-1,
+	.data	=	&sunsab_reg,
 };
 
 static void __init sunsab_console_init(void)
diff -Nru a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
--- a/drivers/serial/sunsu.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/serial/sunsu.c	Wed Apr 30 22:28:05 2003
@@ -458,7 +458,7 @@
 	wake_up_interruptible(&up->port.info->delta_msr_wait);
 }
 
-static void sunsu_serial_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sunsu_serial_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct uart_sunsu_port *up = dev_id;
 	unsigned long flags;
@@ -476,6 +476,8 @@
 	} while (!(serial_in(up, UART_IIR) & UART_IIR_NO_INT));
 
 	spin_unlock_irqrestore(&up->port.lock, flags);
+
+	return IRQ_HANDLED;
 }
 
 /* Separate interrupt handling path for keyboard/mouse ports.  */
@@ -548,7 +550,7 @@
 	} while (serial_in(up, UART_LSR) & UART_LSR_DR);
 }
 
-static void sunsu_kbd_ms_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sunsu_kbd_ms_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct uart_sunsu_port *up = dev_id;
 
@@ -559,6 +561,8 @@
 			receive_kbd_ms_chars(up, regs,
 					     (status & UART_LSR_BI) != 0);
 	}
+
+	return IRQ_HANDLED;
 }
 
 static unsigned int sunsu_tx_empty(struct uart_port *port)
@@ -1282,9 +1286,9 @@
 	.owner			= THIS_MODULE,
 	.driver_name		= "serial",
 #ifdef CONFIG_DEVFS_FS
-	.dev_name		= "tts/%d",
+	.dev_name		= "tts/",
 #else
-	.dev_name		= "ttyS%d",
+	.dev_name		= "ttyS",
 #endif
 	.major			= TTY_MAJOR,
 };
@@ -1418,11 +1422,6 @@
 	serial_out(up, UART_IER, ier);
 }
 
-static kdev_t sunsu_console_device(struct console *co)
-{
-	return mk_kdev(sunsu_reg.major, sunsu_reg.minor + co->index);
-}
-
 /*
  *	Setup initial baud/bits/parity. We do two things here:
  *	- construct a cflag setting for the first su_open()
@@ -1463,10 +1462,11 @@
 static struct console sunsu_cons = {
 	.name	=	"ttyS",
 	.write	=	sunsu_console_write,
-	.device	=	sunsu_console_device,
+	.device	=	uart_console_device,
 	.setup	=	sunsu_console_setup,
 	.flags	=	CON_PRINTBUFFER,
 	.index	=	-1,
+	.data	=	&sunsu_reg,
 };
 
 /*
diff -Nru a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c
--- a/drivers/serial/sunzilog.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/serial/sunzilog.c	Wed Apr 30 22:28:19 2003
@@ -539,7 +539,7 @@
 	ZS_WSYNC(channel);
 }
 
-static void sunzilog_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sunzilog_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct uart_sunzilog_port *up = dev_id;
 
@@ -587,6 +587,8 @@
 
 		up = up->next;
 	}
+
+	return IRQ_HANDLED;
 }
 
 /* A convenient way to quickly get R0 status.  The caller must _not_ hold the
@@ -1029,9 +1031,9 @@
 	.owner		=	THIS_MODULE,
 	.driver_name	=	"ttyS",
 #ifdef CONFIG_DEVFS_FS
-	.dev_name	=	"tts/%d",
+	.dev_name	=	"tts/",
 #else
-	.dev_name	=	"ttyS%d",
+	.dev_name	=	"ttyS",
 #endif
 	.major		=	TTY_MAJOR,
 };
@@ -1350,11 +1352,6 @@
 	spin_unlock_irqrestore(&up->port.lock, flags);
 }
 
-static kdev_t sunzilog_console_device(struct console *con)
-{
-	return mk_kdev(sunzilog_reg.major, sunzilog_reg.minor + con->index);
-}
-
 static int __init sunzilog_console_setup(struct console *con, char *options)
 {
 	struct uart_sunzilog_port *up = &sunzilog_port_table[con->index];
@@ -1400,10 +1397,11 @@
 static struct console sunzilog_console = {
 	.name	=	"ttyS",
 	.write	=	sunzilog_console_write,
-	.device	=	sunzilog_console_device,
+	.device	=	uart_console_device,
 	.setup	=	sunzilog_console_setup,
 	.flags	=	CON_PRINTBUFFER,
 	.index	=	-1,
+	.data   =	&sunzilog_reg,
 };
 
 static int __init sunzilog_console_init(void)
diff -Nru a/drivers/serial/uart00.c b/drivers/serial/uart00.c
--- a/drivers/serial/uart00.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/serial/uart00.c	Wed Apr 30 22:28:08 2003
@@ -576,11 +576,6 @@
 #endif
 }
 
-static kdev_t uart00_console_device(struct console *co)
-{
-	return mk_kdev(SERIAL_UART00_MAJOR, SERIAL_UART00_MINOR + co->index);
-}
-
 static void __init
 uart00_console_get_options(struct uart_port *port, int *baud,
 			   int *parity, int *bits)
@@ -636,13 +631,15 @@
 	return uart_set_options(port, co, baud, parity, bits, flow);
 }
 
+extern struct uart_driver uart00_reg;
 static struct console uart00_console = {
 	.name		= SERIAL_UART00_NAME,
 	.write		= uart00_console_write,
-	.device		= uart00_console_device,
+	.device		= uart_console_device,
 	.setup		= uart00_console_setup,
 	.flags		= CON_PRINTBUFFER,
 	.index		= 0,
+	.data		= &uart00_reg;
 };
 
 static int __init uart00_console_init(void)
diff -Nru a/drivers/sgi/char/sgiserial.c b/drivers/sgi/char/sgiserial.c
--- a/drivers/sgi/char/sgiserial.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/sgi/char/sgiserial.c	Wed Apr 30 22:28:06 2003
@@ -143,20 +143,20 @@
 static DECLARE_MUTEX(tmp_buf_sem);
 
 static inline int serial_paranoia_check(struct sgi_serial *info,
-					dev_t device, const char *routine)
+					char *name, const char *routine)
 {
 #ifdef SERIAL_PARANOIA_CHECK
 	static const char *badmagic = KERN_WARNING
-		"Warning: bad magic number for serial struct (%d, %d) in %s\n";
+		"Warning: bad magic number for serial struct %s in %s\n";
 	static const char *badinfo = KERN_WARNING
-		"Warning: null sgi_serial for (%d, %d) in %s\n";
+		"Warning: null sgi_serial for %s in %s\n";
 
 	if (!info) {
-		printk(badinfo, MAJOR(device), MINOR(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (info->magic != SERIAL_MAGIC) {
-		printk(badmagic, MAJOR(device), MINOR(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -293,7 +293,7 @@
 	struct sgi_serial *info = (struct sgi_serial *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_stop"))
+	if (serial_paranoia_check(info, tty->name, "rs_stop"))
 		return;
 	
 	save_flags(flags); cli();
@@ -310,7 +310,7 @@
 	struct sgi_serial *info = (struct sgi_serial *)tty->driver_data;
 	unsigned long flags;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_start"))
+	if (serial_paranoia_check(info, tty->name, "rs_start"))
 		return;
 	
 	save_flags(flags); cli();
@@ -1003,7 +1003,7 @@
 	struct sgi_serial *info = (struct sgi_serial *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_write"))
+	if (serial_paranoia_check(info, tty->name, "rs_write"))
 		return 0;
 
 	if (!tty || !info->xmit_buf)
@@ -1076,7 +1076,7 @@
 	struct sgi_serial *info = (struct sgi_serial *)tty->driver_data;
 	int	ret;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_write_room"))
+	if (serial_paranoia_check(info, tty->name, "rs_write_room"))
 		return 0;
 	ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
 	if (ret < 0)
@@ -1088,7 +1088,7 @@
 {
 	struct sgi_serial *info = (struct sgi_serial *)tty->driver_data;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_chars_in_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
 		return 0;
 	return info->xmit_cnt;
 }
@@ -1097,7 +1097,7 @@
 {
 	struct sgi_serial *info = (struct sgi_serial *)tty->driver_data;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_flush_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
 		return;
 	cli();
 	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
@@ -1113,7 +1113,7 @@
 	struct sgi_serial *info = (struct sgi_serial *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_flush_chars"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
 		return;
 
 	if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
@@ -1167,7 +1167,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_throttle"))
+	if (serial_paranoia_check(info, tty->name, "rs_throttle"))
 		return;
 	
 	if (I_IXOFF(tty))
@@ -1191,7 +1191,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_unthrottle"))
+	if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
 		return;
 	
 	if (I_IXOFF(tty)) {
@@ -1377,7 +1377,7 @@
 	struct sgi_serial * info = (struct sgi_serial *) tty->driver_data;
 	int retval;
 
-	if (serial_paranoia_check(info, tty->device, "zs_ioctl"))
+	if (serial_paranoia_check(info, tty->name, "zs_ioctl"))
 		return -ENODEV;
 
 	if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
@@ -1473,7 +1473,7 @@
 	struct sgi_serial * info = (struct sgi_serial *)tty->driver_data;
 	unsigned long flags;
 
-	if (!info || serial_paranoia_check(info, tty->device, "rs_close"))
+	if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
 		return;
 	
 	save_flags(flags); cli();
@@ -1539,8 +1539,8 @@
 	ZS_CLEARFIFO(info->zs_channel);
 
 	shutdown(info);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -1574,7 +1574,7 @@
 {
 	struct sgi_serial * info = (struct sgi_serial *)tty->driver_data;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_hangup"))
+	if (serial_paranoia_check(info, tty->name, "rs_hangup"))
 		return;
 	
 	rs_flush_buffer(tty);
@@ -1618,7 +1618,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		if (info->flags & ZILOG_NORMAL_ACTIVE)
 			return -EBUSY;
 		if ((info->flags & ZILOG_CALLOUT_ACTIVE) &&
@@ -1725,7 +1725,7 @@
 	struct sgi_serial	*info;
 	int 			retval, line;
 
-	line = MINOR(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	/* The zilog lines for the mouse/keyboard must be
 	 * opened using their respective drivers.
 	 */
@@ -1735,11 +1735,10 @@
 	/* Is the kgdb running over this line? */
 	if (info->kgdb_channel)
 		return -ENODEV;
-	if (serial_paranoia_check(info, tty->device, "rs_open"))
+	if (serial_paranoia_check(info, tty->name, "rs_open"))
 		return -ENODEV;
 #ifdef SERIAL_DEBUG_OPEN
-	printk("rs_open %s%d, count = %d\n", tty->driver.name, info->line,
-	       info->count);
+	printk("rs_open %s, count = %d\n", tty->name, info->count);
 #endif
 	info->count++;
 	tty->driver_data = info;
@@ -1762,7 +1761,7 @@
 	}
 
 	if ((info->count == 1) && (info->flags & ZILOG_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->normal_termios;
 		else 
 			*tty->termios = info->callout_termios;
@@ -1781,7 +1780,7 @@
 	info->pgrp = current->pgrp;
 
 #ifdef SERIAL_DEBUG_OPEN
-	printk("rs_open ttys%d successful...\n", info->line);
+	printk("rs_open %s successful...\n", tty->name);
 #endif
 	return 0;
 }
@@ -2110,9 +2109,10 @@
 	rs_fair_output();
 }
 
-static kdev_t zs_console_device(struct console *con)
+static struct tty_driver *zs_console_device(struct console *con, int *index)
 {
-	return MKDEV(TTY_MAJOR, 64 + con->index);
+	*index = con->index;
+	return &serial_driver;
 }
 
 
diff -Nru a/drivers/tc/zs.c b/drivers/tc/zs.c
--- a/drivers/tc/zs.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/tc/zs.c	Wed Apr 30 22:28:15 2003
@@ -235,20 +235,20 @@
 static DECLARE_MUTEX(tmp_buf_sem);
 
 static inline int serial_paranoia_check(struct dec_serial *info,
-					dev_t device, const char *routine)
+					char *name, const char *routine)
 {
 #ifdef SERIAL_PARANOIA_CHECK
 	static const char *badmagic =
-		"Warning: bad magic number for serial struct (%d, %d) in %s\n";
+		"Warning: bad magic number for serial struct %s in %s\n";
 	static const char *badinfo =
-		"Warning: null mac_serial for (%d, %d) in %s\n";
+		"Warning: null mac_serial for %s in %s\n";
 
 	if (!info) {
-		printk(badinfo, MAJOR(device), MINOR(device), routine);
+		printk(badinfo, name, routine);
 		return 1;
 	}
 	if (info->magic != SERIAL_MAGIC) {
-		printk(badmagic, MAJOR(device), MINOR(device), routine);
+		printk(badmagic, name, routine);
 		return 1;
 	}
 #endif
@@ -631,7 +631,7 @@
 	struct dec_serial *info = (struct dec_serial *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_stop"))
+	if (serial_paranoia_check(info, tty->name, "rs_stop"))
 		return;
 	
 #if 1
@@ -649,7 +649,7 @@
 	struct dec_serial *info = (struct dec_serial *)tty->driver_data;
 	unsigned long flags;
 	
-	if (serial_paranoia_check(info, tty->device, "rs_start"))
+	if (serial_paranoia_check(info, tty->name, "rs_start"))
 		return;
 	
 	save_flags(flags); cli();
@@ -928,7 +928,7 @@
 	struct dec_serial *info = (struct dec_serial *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_flush_chars"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
 		return;
 
 	if (info->xmit_cnt <= 0 || tty->stopped || info->tx_stopped ||
@@ -948,7 +948,7 @@
 	struct dec_serial *info = (struct dec_serial *)tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_write"))
+	if (serial_paranoia_check(info, tty->name, "rs_write"))
 		return 0;
 
 	if (!tty || !info->xmit_buf)
@@ -991,7 +991,7 @@
 	struct dec_serial *info = (struct dec_serial *)tty->driver_data;
 	int	ret;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_write_room"))
+	if (serial_paranoia_check(info, tty->name, "rs_write_room"))
 		return 0;
 	ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
 	if (ret < 0)
@@ -1003,7 +1003,7 @@
 {
 	struct dec_serial *info = (struct dec_serial *)tty->driver_data;
 			
-	if (serial_paranoia_check(info, tty->device, "rs_chars_in_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
 		return 0;
 	return info->xmit_cnt;
 }
@@ -1012,7 +1012,7 @@
 {
 	struct dec_serial *info = (struct dec_serial *)tty->driver_data;
 				
-	if (serial_paranoia_check(info, tty->device, "rs_flush_buffer"))
+	if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
 		return;
 	cli();
 	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
@@ -1043,7 +1043,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_throttle"))
+	if (serial_paranoia_check(info, tty->name, "rs_throttle"))
 		return;
 	
 	if (I_IXOFF(tty)) {
@@ -1071,7 +1071,7 @@
 	       tty->ldisc.chars_in_buffer(tty));
 #endif
 
-	if (serial_paranoia_check(info, tty->device, "rs_unthrottle"))
+	if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
 		return;
 	
 	if (I_IXOFF(tty)) {
@@ -1251,7 +1251,7 @@
 	struct dec_serial *info = (struct dec_serial *) tty->driver_data;
 	unsigned long flags;
 
-	if (serial_paranoia_check(info, tty->device, "rs_break"))
+	if (serial_paranoia_check(info, tty->name, "rs_break"))
 		return;
 	if (!info->port)
 		return;
@@ -1274,7 +1274,7 @@
 	if (info->hook)
 		return -ENODEV;
 
-	if (serial_paranoia_check(info, tty->device, "rs_ioctl"))
+	if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
 		return -ENODEV;
 
 	if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
@@ -1356,7 +1356,7 @@
 	struct dec_serial * info = (struct dec_serial *)tty->driver_data;
 	unsigned long flags;
 
-	if (!info || serial_paranoia_check(info, tty->device, "rs_close"))
+	if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
 		return;
 	
 	save_flags(flags); cli();
@@ -1424,8 +1424,8 @@
 	}
 
 	shutdown(info);
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 	tty->closing = 0;
@@ -1452,7 +1452,7 @@
 	struct dec_serial *info = (struct dec_serial *) tty->driver_data;
 	unsigned long orig_jiffies, char_time;
 
-	if (serial_paranoia_check(info, tty->device, "rs_wait_until_sent"))
+	if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
 		return;
 
 	orig_jiffies = jiffies;
@@ -1485,7 +1485,7 @@
 {
 	struct dec_serial * info = (struct dec_serial *)tty->driver_data;
 
-	if (serial_paranoia_check(info, tty->device, "rs_hangup"))
+	if (serial_paranoia_check(info, tty->name, "rs_hangup"))
 		return;
 
 	rs_flush_buffer(tty);
@@ -1527,7 +1527,7 @@
 	 * If this is a callout device, then just make sure the normal
 	 * device isn't being used.
 	 */
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		if (info->flags & ZILOG_NORMAL_ACTIVE)
 			return -EBUSY;
 		if ((info->flags & ZILOG_CALLOUT_ACTIVE) &&
@@ -1639,7 +1639,7 @@
 	struct dec_serial	*info;
 	int 			retval, line;
 
-	line = MINOR(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if ((line < 0) || (line >= zs_channels_found))
 		return -ENODEV;
 	info = zs_soft + line;
@@ -1647,11 +1647,10 @@
 	if (info->hook)
 		return -ENODEV;
 
-	if (serial_paranoia_check(info, tty->device, "rs_open"))
+	if (serial_paranoia_check(info, tty->name, "rs_open"))
 		return -ENODEV;
 #ifdef SERIAL_DEBUG_OPEN
-	printk("rs_open %s%d, count = %d\n", tty->driver.name, info->line,
-	       info->count);
+	printk("rs_open %s, count = %d\n", tty->name, info->count);
 #endif
 
 	info->count++;
@@ -1690,7 +1689,7 @@
 	}
 
 	if ((info->count == 1) && (info->flags & ZILOG_SPLIT_TERMIOS)) {
-		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
 			*tty->termios = info->normal_termios;
 		else 
 			*tty->termios = info->callout_termios;
@@ -1708,7 +1707,7 @@
 	info->pgrp = current->pgrp;
 
 #ifdef SERIAL_DEBUG_OPEN
-	printk("rs_open ttyS%02d successful...", info->line);
+	printk("rs_open %s successful...", tty->name);
 #endif
 /* tty->low_latency = 1; */
 	return 0;
@@ -1874,7 +1873,7 @@
 	memset(&serial_driver, 0, sizeof(struct tty_driver));
 	serial_driver.magic = TTY_DRIVER_MAGIC;
 #if (LINUX_VERSION_CODE > 0x2032D && defined(CONFIG_DEVFS_FS))
-	serial_driver.name = "tts/%d";
+	serial_driver.name = "tts/";
 #else
 	serial_driver.name = "ttyS";
 #endif
@@ -1916,7 +1915,7 @@
 	 */
 	callout_driver = serial_driver;
 #if (LINUX_VERSION_CODE > 0x2032D && defined(CONFIG_DEVFS_FS))
-	callout_driver.name = "cua/%d";
+	callout_driver.name = "cua/";
 #else
 	callout_driver.name = "cua";
 #endif
@@ -1971,10 +1970,8 @@
 		printk("ttyS%02d at 0x%08x (irq = %d)", info->line, 
 		       info->port, info->irq);
 		printk(" is a Z85C30 SCC\n");
-		tty_register_device(&serial_driver,
-				   serial_driver.minor_start + info->line);
-		tty_register_device(&callout_driver,
-				   callout_driver.minor_start + info->line);
+		tty_register_device(&serial_driver, info->line);
+		tty_register_device(&callout_driver, info->line);
 
 	}
 
@@ -2124,9 +2121,10 @@
 	}
 }
 
-static kdev_t serial_console_device(struct console *c)
+static struct tty_driver *serial_console_device(struct console *c, int *index)
 {
-	return MKDEV(TTY_MAJOR, 64 + c->index);
+	*index = c->index;
+	return &serial_driver;
 }
 
 /*
diff -Nru a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c
--- a/drivers/telephony/ixj_pcmcia.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/telephony/ixj_pcmcia.c	Wed Apr 30 22:28:16 2003
@@ -43,15 +43,6 @@
 static dev_info_t dev_info = "ixj_cs";
 static dev_link_t *dev_list = NULL;
 
-static void cs_error(client_handle_t handle, int func, int ret)
-{
-	error_info_t err =
-	{
-		func, ret
-	};
-	CardServices(ReportError, handle, &err);
-}
-
 static dev_link_t *ixj_attach(void)
 {
 	client_reg_t client_reg;
diff -Nru a/drivers/usb/Makefile b/drivers/usb/Makefile
--- a/drivers/usb/Makefile	Wed Apr 30 22:28:17 2003
+++ b/drivers/usb/Makefile	Wed Apr 30 22:28:17 2003
@@ -36,7 +36,6 @@
 obj-$(CONFIG_USB_VICAM)		+= media/
 
 obj-$(CONFIG_USB_CATC)		+= net/
-obj-$(CONFIG_USB_CDCETHER)	+= net/
 obj-$(CONFIG_USB_KAWETH)	+= net/
 obj-$(CONFIG_USB_PEGASUS)	+= net/
 obj-$(CONFIG_USB_RTL8150)	+= net/
diff -Nru a/drivers/usb/class/audio.c b/drivers/usb/class/audio.c
--- a/drivers/usb/class/audio.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/usb/class/audio.c	Wed Apr 30 22:28:18 2003
@@ -185,7 +185,6 @@
 #include <linux/soundcard.h>
 #include <linux/list.h>
 #include <linux/vmalloc.h>
-#include <linux/wrapper.h>
 #include <linux/init.h>
 #include <linux/poll.h>
 #include <linux/bitops.h>
@@ -450,7 +449,7 @@
 	for(nr = 0; nr < NRSGBUF; nr++) {
 		if (!(p = db->sgbuf[nr]))
 			continue;
-		mem_map_unreserve(virt_to_page(p));
+		ClearPageReserved(virt_to_page(p));
 		free_page((unsigned long)p);
 		db->sgbuf[nr] = NULL;
 	}
@@ -492,7 +491,7 @@
 			if (!p)
 				return -ENOMEM;
 			db->sgbuf[nr] = p;
-			mem_map_reserve(virt_to_page(p));
+			SetPageReserved(virt_to_page(p));
 		}
 		memset(db->sgbuf[nr], AFMT_ISUNSIGNED(db->format) ? 0x80 : 0, PAGE_SIZE);
 		if ((nr << PAGE_SHIFT) >= db->dmasize)
diff -Nru a/drivers/usb/class/bluetty.c b/drivers/usb/class/bluetty.c
--- a/drivers/usb/class/bluetty.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/usb/class/bluetty.c	Wed Apr 30 22:28:14 2003
@@ -276,9 +276,9 @@
 }
 
 
-static inline struct usb_bluetooth *get_bluetooth_by_minor (int minor)
+static inline struct usb_bluetooth *get_bluetooth_by_index (int index)
 {
-	return bluetooth_table[minor];
+	return bluetooth_table[index];
 }
 
 
@@ -357,7 +357,7 @@
 	tty->driver_data = NULL;
 
 	/* get the bluetooth object associated with this tty pointer */
-	bluetooth = get_bluetooth_by_minor (minor(tty->device));
+	bluetooth = get_bluetooth_by_index (tty->index);
 
 	if (bluetooth_paranoia_check (bluetooth, __FUNCTION__)) {
 		return -ENODEV;
@@ -1298,7 +1298,7 @@
 	.magic =		TTY_DRIVER_MAGIC,
 	.owner =		THIS_MODULE,
 	.driver_name =		"usb-bluetooth",
-	.name =			"usb/ttub/%d",
+	.name =			"usb/ttub/",
 	.major =		BLUETOOTH_TTY_MAJOR,
 	.minor_start =		0,
 	.num =			BLUETOOTH_TTY_MINORS,
diff -Nru a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
--- a/drivers/usb/class/cdc-acm.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/usb/class/cdc-acm.c	Wed Apr 30 22:28:11 2003
@@ -313,7 +313,7 @@
 
 static int acm_tty_open(struct tty_struct *tty, struct file *filp)
 {
-	struct acm *acm = acm_table[minor(tty->device)];
+	struct acm *acm = acm_table[tty->index];
 
 	if (!acm || !acm->dev) return -EINVAL;
 
@@ -432,43 +432,47 @@
 		dbg("send break failed");
 }
 
-static int acm_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
+static int acm_tty_tiocmget(struct tty_struct *tty, struct file *file)
 {
 	struct acm *acm = tty->driver_data;
-	unsigned int mask, newctrl;
 
-	if (!ACM_READY(acm)) return -EINVAL;
+	if (!ACM_READY(acm))
+		return -EINVAL;
+
+	return (acm->ctrlout & ACM_CTRL_DTR ? TIOCM_DTR : 0) |
+	       (acm->ctrlout & ACM_CTRL_RTS ? TIOCM_RTS : 0) |
+	       (acm->ctrlin  & ACM_CTRL_DSR ? TIOCM_DSR : 0) |
+	       (acm->ctrlin  & ACM_CTRL_RI  ? TIOCM_RI  : 0) |
+	       (acm->ctrlin  & ACM_CTRL_DCD ? TIOCM_CD  : 0) |
+	       TIOCM_CTS;
+}
 
-	switch (cmd) {
+static int acm_tty_tiocmset(struct tty_struct *tty, struct file *file,
+			    unsigned int set, unsigned int clear)
+{
+	struct acm *acm = tty->driver_data;
+	unsigned int newctrl;
 
-		case TIOCMGET:
+	if (!ACM_READY(acm))
+		return -EINVAL;
 
-			return put_user((acm->ctrlout & ACM_CTRL_DTR ? TIOCM_DTR : 0) |
-				(acm->ctrlout & ACM_CTRL_RTS ? TIOCM_RTS : 0) |
-				(acm->ctrlin  & ACM_CTRL_DSR ? TIOCM_DSR : 0) |
-				(acm->ctrlin  & ACM_CTRL_RI  ? TIOCM_RI  : 0) |
-				(acm->ctrlin  & ACM_CTRL_DCD ? TIOCM_CD  : 0) |
-				 TIOCM_CTS, (unsigned long *) arg);
-
-		case TIOCMSET:
-		case TIOCMBIS:
-		case TIOCMBIC:
-
-			if (get_user(mask, (unsigned long *) arg))
-				return -EFAULT;
-
-			newctrl = acm->ctrlout;
-			mask = (mask & TIOCM_DTR ? ACM_CTRL_DTR : 0) | (mask & TIOCM_RTS ? ACM_CTRL_RTS : 0);
-
-			switch (cmd) {
-				case TIOCMSET: newctrl  =  mask; break;
-				case TIOCMBIS: newctrl |=  mask; break;
-				case TIOCMBIC: newctrl &= ~mask; break;
-			}
+	newctrl = acm->ctrlout;
+	set = (set & TIOCM_DTR ? ACM_CTRL_DTR : 0) | (set & TIOCM_RTS ? ACM_CTRL_RTS : 0);
+	clear = (clear & TIOCM_DTR ? ACM_CTRL_DTR : 0) | (clear & TIOCM_RTS ? ACM_CTRL_RTS : 0);
 
-			if (acm->ctrlout == newctrl) return 0;
-			return acm_set_control(acm, acm->ctrlout = newctrl);
-	}
+	newctrl = (newctrl & ~clear) | set;
+
+	if (acm->ctrlout == newctrl)
+		return 0;
+	return acm_set_control(acm, acm->ctrlout = newctrl);
+}
+
+static int acm_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
+{
+	struct acm *acm = tty->driver_data;
+
+	if (!ACM_READY(acm))
+		return -EINVAL;
 
 	return -ENOIOCTLCMD;
 }
@@ -727,7 +731,7 @@
 	.magic =		TTY_DRIVER_MAGIC,
 	.owner =		THIS_MODULE,
 	.driver_name =		"acm",
-	.name =			"usb/acm/%d",
+	.name =			"usb/acm/",
 	.major =		ACM_TTY_MAJOR,
 	.minor_start =		0,
 	.num =			ACM_TTY_MINORS,
@@ -750,7 +754,9 @@
 	.unthrottle =		acm_tty_unthrottle,
 	.chars_in_buffer =	acm_tty_chars_in_buffer,
 	.break_ctl =		acm_tty_break_ctl,
-	.set_termios =		acm_tty_set_termios
+	.set_termios =		acm_tty_set_termios,
+	.tiocmget =		acm_tty_tiocmget,
+	.tiocmset =		acm_tty_tiocmset,
 };
 
 /*
diff -Nru a/drivers/usb/class/usb-midi.c b/drivers/usb/class/usb-midi.c
--- a/drivers/usb/class/usb-midi.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/usb/class/usb-midi.c	Wed Apr 30 22:28:03 2003
@@ -33,7 +33,6 @@
 #include <linux/sched.h>
 #include <linux/list.h>
 #include <linux/slab.h>
-#include <linux/wrapper.h>
 #include <linux/usb.h>
 #include <linux/poll.h>
 #include <linux/sound.h>
@@ -820,7 +819,7 @@
 	struct list_head      *devs, *mdevs;
 	struct usb_midi_state *s;
 	struct usb_mididev    *m;
-	int flags;
+	unsigned long flags;
 	int succeed = 0;
 
 #if 0
diff -Nru a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
--- a/drivers/usb/class/usblp.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/usb/class/usblp.c	Wed Apr 30 22:28:05 2003
@@ -130,7 +130,6 @@
 
 struct usblp {
 	struct usb_device 	*dev;			/* USB device */
-	devfs_handle_t		devfs;			/* devfs device */
 	struct semaphore	sem;			/* locks this struct, especially "dev" */
 	char			*writebuf;		/* write transfer_buffer */
 	char			*readbuf;		/* read transfer_buffer */
@@ -163,7 +162,6 @@
 
 	dbg("usblp=0x%p", usblp);
 	dbg("dev=0x%p", usblp->dev);
-	dbg("devfs=0x%p", usblp->devfs);
 	dbg("buf=0x%p", usblp->buf);
 	dbg("readcount=%d", usblp->readcount);
 	dbg("ifnum=%d", usblp->ifnum);
@@ -382,7 +380,7 @@
 
 static void usblp_cleanup (struct usblp *usblp)
 {
-	devfs_unregister (usblp->devfs);
+	devfs_remove ("usb/lp%d", usblp->minor);
 	usb_deregister_dev (1, usblp->minor);
 	info("usblp%d: removed", usblp->minor);
 
@@ -908,8 +906,7 @@
 
 	/* If we have devfs, create with perms=660. */
 	sprintf(name, "usb/lp%d", usblp->minor);
-	usblp->devfs = devfs_register(NULL, name,
-				      DEVFS_FL_DEFAULT, USB_MAJOR,
+	devfs_register(NULL, name, 0, USB_MAJOR,
 				      usblp->minor,
 				      S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP |
 				      S_IWGRP, &usblp_fops, NULL);
diff -Nru a/drivers/usb/core/file.c b/drivers/usb/core/file.c
--- a/drivers/usb/core/file.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/usb/core/file.c	Wed Apr 30 22:28:19 2003
@@ -28,8 +28,6 @@
 #endif
 #include <linux/usb.h>
 
-static devfs_handle_t usb_devfs_handle;	/* /dev/usb dir. */
-
 #define MAX_USB_MINORS	256
 static struct file_operations *usb_minors[MAX_USB_MINORS];
 static spinlock_t minor_lock = SPIN_LOCK_UNLOCKED;
@@ -75,14 +73,13 @@
 		return -EBUSY;
 	}
 
-	usb_devfs_handle = devfs_mk_dir("usb");
-
+	devfs_mk_dir("usb");
 	return 0;
 }
 
 void usb_major_cleanup(void)
 {
-	devfs_unregister(usb_devfs_handle);
+	devfs_remove("usb");
 	unregister_chrdev(USB_MAJOR, "usb");
 }
 
diff -Nru a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
--- a/drivers/usb/core/hcd-pci.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/usb/core/hcd-pci.c	Wed Apr 30 22:28:09 2003
@@ -17,11 +17,6 @@
  */
 
 #include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <asm/io.h>
-#include <asm/irq.h>
 
 #ifdef CONFIG_USB_DEBUG
 	#define DEBUG
@@ -29,6 +24,11 @@
 	#undef DEBUG
 #endif
 
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <asm/io.h>
+#include <asm/irq.h>
 #include <linux/usb.h>
 #include "hcd.h"
 
@@ -214,7 +214,7 @@
 	hub = hcd->self.root_hub;
 	hcd->state = USB_STATE_QUIESCING;
 
-	dev_dbg (*hcd->controller, "roothub graceful disconnect\n");
+	dev_dbg (hcd->controller, "roothub graceful disconnect\n");
 	usb_disconnect (&hub);
 
 	hcd->driver->stop (hcd);
@@ -326,7 +326,7 @@
 
 	retval = -EBUSY;
 	if (hcd->state != USB_STATE_SUSPENDED) {
-		dev_dbg (*hcd->controller, "can't resume, not suspended!\n");
+		dev_dbg (hcd->controller, "can't resume, not suspended!\n");
 		goto done;
 	}
 	hcd->state = USB_STATE_RESUMING;
@@ -336,7 +336,7 @@
 
 	retval = hcd->driver->resume (hcd);
 	if (!HCD_IS_RUNNING (hcd->state)) {
-		dev_dbg (*hcd->controller, "resume fail, retval %d\n", retval);
+		dev_dbg (hcd->controller, "resume fail, retval %d\n", retval);
 		usb_hc_died (hcd);
 // FIXME:  recover, reset etc.
 	} else {
diff -Nru a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
--- a/drivers/usb/core/hcd.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/usb/core/hcd.c	Wed Apr 30 22:28:10 2003
@@ -961,8 +961,8 @@
 	spin_lock_irqsave (&hcd_data_lock, flags);
 	list_del_init (&urb->urb_list);
 	dev = urb->dev;
-	usb_put_dev (dev);
 	spin_unlock_irqrestore (&hcd_data_lock, flags);
+	usb_put_dev (dev);
 }
 
 
@@ -1436,17 +1436,18 @@
  * to handle interrupts.  The PCI glue layer does so automatically; only
  * bus glue for non-PCI system busses will need to use this.
  */
-void usb_hcd_irq (int irq, void *__hcd, struct pt_regs * r)
+irqreturn_t usb_hcd_irq (int irq, void *__hcd, struct pt_regs * r)
 {
 	struct usb_hcd		*hcd = __hcd;
 	int			start = hcd->state;
 
 	if (unlikely (hcd->state == USB_STATE_HALT))	/* irq sharing? */
-		return;
+		return IRQ_NONE;
 
 	hcd->driver->irq (hcd, r);
 	if (hcd->state != start && hcd->state == USB_STATE_HALT)
 		usb_hc_died (hcd);
+	return IRQ_HANDLED;
 }
 EXPORT_SYMBOL (usb_hcd_irq);
 
diff -Nru a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
--- a/drivers/usb/core/hcd.h	Wed Apr 30 22:28:07 2003
+++ b/drivers/usb/core/hcd.h	Wed Apr 30 22:28:07 2003
@@ -239,7 +239,7 @@
 
 /* generic bus glue, needed for host controllers that don't use PCI */
 extern struct usb_operations usb_hcd_operations;
-extern void usb_hcd_irq (int irq, void *__hcd, struct pt_regs *r);
+extern irqreturn_t usb_hcd_irq (int irq, void *__hcd, struct pt_regs *r);
 extern void usb_hc_died (struct usb_hcd *hcd);
 
 /* -------------------------------------------------------------------------- */
diff -Nru a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
--- a/drivers/usb/core/inode.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/usb/core/inode.c	Wed Apr 30 22:28:04 2003
@@ -45,7 +45,6 @@
 static struct inode_operations usbfs_dir_inode_operations;
 static struct vfsmount *usbdevfs_mount;
 static struct vfsmount *usbfs_mount;
-static spinlock_t mount_lock = SPIN_LOCK_UNLOCKED;
 static int usbdevfs_mount_count;	/* = 0 */
 static int usbfs_mount_count;	/* = 0 */
 
@@ -514,69 +513,20 @@
 };
 
 /* --------------------------------------------------------------------- */
-static int get_mount (struct file_system_type *fs_type, struct vfsmount **mount, int *mount_count)
-{
-	struct vfsmount *mnt;
-
-	spin_lock (&mount_lock);
-	if (*mount) {
-		mntget(*mount);
-		++(*mount_count);
-		spin_unlock (&mount_lock);
-		goto go_ahead;
-	}
-
-	spin_unlock (&mount_lock);
-	mnt = kern_mount (fs_type);
-	if (IS_ERR(mnt)) {
-		err ("could not mount the fs...erroring out!\n");
-		return -ENODEV;
-	}
-	spin_lock (&mount_lock);
-	if (!*mount) {
-		*mount = mnt;
-		++(*mount_count);
-		spin_unlock (&mount_lock);
-		goto go_ahead;
-	}
-	mntget(*mount);
-	++(*mount_count);
-	spin_unlock (&mount_lock);
-	mntput(mnt);
-
-go_ahead:
-	dbg("mount_count = %d", *mount_count);
-	return 0;
-}
-
-static void put_mount (struct vfsmount **mount, int *mount_count)
-{
-	struct vfsmount *mnt;
-
-	spin_lock (&mount_lock);
-	mnt = *mount;
-	--(*mount_count);
-	if (!(*mount_count))
-		*mount = NULL;
-
-	spin_unlock (&mount_lock);
-	mntput(mnt);
-	dbg("mount_count = %d", *mount_count);
-}
 
 static int create_special_files (void)
 {
 	struct dentry *parent;
-	int retval = 0;
+	int retval;
 
 	/* create the devices special file */
-	retval = get_mount (&usbdevice_fs_type, &usbdevfs_mount, &usbdevfs_mount_count);
+	retval = simple_pin_fs("usbdevfs", &usbdevfs_mount, &usbdevfs_mount_count);
 	if (retval) {
 		err ("Unable to get usbdevfs mount");
 		goto exit;
 	}
 
-	retval = get_mount (&usb_fs_type, &usbfs_mount, &usbfs_mount_count);
+	retval = simple_pin_fs("usbfs", &usbfs_mount, &usbfs_mount_count);
 	if (retval) {
 		err ("Unable to get usbfs mount");
 		goto error_clean_usbdevfs_mount;
@@ -611,10 +561,10 @@
 	devices_usbfs_dentry = NULL;
 
 error_clean_mounts:
-	put_mount (&usbfs_mount, &usbfs_mount_count);
+	simple_release_fs(&usbfs_mount, &usbfs_mount_count);
 
 error_clean_usbdevfs_mount:
-	put_mount (&usbdevfs_mount, &usbdevfs_mount_count);
+	simple_release_fs(&usbdevfs_mount, &usbdevfs_mount_count);
 
 exit:
 	return retval;
@@ -628,8 +578,8 @@
 		fs_remove_file (devices_usbfs_dentry);
 	devices_usbdevfs_dentry = NULL;
 	devices_usbfs_dentry = NULL;
-	put_mount (&usbdevfs_mount, &usbdevfs_mount_count);
-	put_mount (&usbfs_mount, &usbfs_mount_count);
+	simple_release_fs(&usbdevfs_mount, &usbdevfs_mount_count);
+	simple_release_fs(&usbfs_mount, &usbfs_mount_count);
 }
 
 void usbfs_update_special (void)
diff -Nru a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
--- a/drivers/usb/core/urb.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/usb/core/urb.c	Wed Apr 30 22:28:10 2003
@@ -14,6 +14,29 @@
 #include "hcd.h"
 
 /**
+ * usb_init_urb - initializes a urb so that it can be used by a USB driver
+ * @urb: pointer to the urb to initialize
+ *
+ * Initializes a urb so that the USB subsystem can use it properly.
+ *
+ * If a urb is created with a call to usb_alloc_urb() it is not
+ * necessary to call this function.  Only use this if you allocate the
+ * space for a struct urb on your own.  If you call this function, be
+ * careful when freeing the memory for your urb that it is no longer in
+ * use by the USB core.
+ *
+ * Only use this function if you _really_ understand what you are doing.
+ */
+void usb_init_urb(struct urb *urb)
+{
+	if (urb) {
+		memset(urb, 0, sizeof(*urb));
+		urb->count = (atomic_t)ATOMIC_INIT(1);
+		spin_lock_init(&urb->lock);
+	}
+}
+
+/**
  * usb_alloc_urb - creates a new urb for a USB driver to use
  * @iso_packets: number of iso packets for this urb
  * @mem_flags: the type of memory to allocate, see kmalloc() for a list of
@@ -40,11 +63,7 @@
 		err("alloc_urb: kmalloc failed");
 		return NULL;
 	}
-
-	memset(urb, 0, sizeof(*urb));
-	urb->count = (atomic_t)ATOMIC_INIT(1);
-	spin_lock_init(&urb->lock);
-
+	usb_init_urb(urb);
 	return urb;
 }
 
@@ -387,7 +406,7 @@
 		return -ENODEV;
 }
 
-// asynchronous request completion model
+EXPORT_SYMBOL(usb_init_urb);
 EXPORT_SYMBOL(usb_alloc_urb);
 EXPORT_SYMBOL(usb_free_urb);
 EXPORT_SYMBOL(usb_get_urb);
diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
--- a/drivers/usb/core/usb.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/usb/core/usb.c	Wed Apr 30 22:28:09 2003
@@ -791,14 +791,22 @@
 void usb_disconnect(struct usb_device **pdev)
 {
 	struct usb_device	*dev = *pdev;
-	struct usb_bus		*bus = dev->bus;
-	struct usb_operations	*ops = bus->op;
+	struct usb_bus		*bus;
+	struct usb_operations	*ops;
 	int			i;
 
 	might_sleep ();
 
-	if (!dev)
+	if (!dev) {
+		pr_debug ("%s nodev\n", __FUNCTION__);
 		return;
+	}
+	bus = dev->bus;
+	if (!bus) {
+		pr_debug ("%s nobus\n", __FUNCTION__);
+		return;
+	}
+	ops = bus->op;
 
 	*pdev = NULL;
 
diff -Nru a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
--- a/drivers/usb/host/uhci-hcd.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/usb/host/uhci-hcd.c	Wed Apr 30 22:28:16 2003
@@ -1283,7 +1283,8 @@
 	}
 
 	if (last_urb) {
-		*end = (last_urb->start_frame + last_urb->number_of_packets) & 1023;
+		*end = (last_urb->start_frame + last_urb->number_of_packets *
+				last_urb->interval) & (UHCI_NUMFRAMES-1);
 		ret = 0;
 	} else
 		ret = -1;	/* no previous urb found */
@@ -1933,9 +1934,10 @@
 
 	dbg("%x: suspend_hc", io_addr);
 
-	outw(USBCMD_EGSM, io_addr + USBCMD);
-
 	uhci->is_suspended = 1;
+	smp_wmb();
+
+	outw(USBCMD_EGSM, io_addr + USBCMD);
 }
 
 static void wakeup_hc(struct uhci_hcd *uhci)
@@ -1945,6 +1947,9 @@
 
 	dbg("%x: wakeup_hc", io_addr);
 
+	/* Global resume for 20ms */
+	outw(USBCMD_FGR | USBCMD_EGSM, io_addr + USBCMD);
+	wait_ms(20);
 	outw(0, io_addr + USBCMD);
 	
 	/* wait for EOP to be sent */
@@ -1965,7 +1970,7 @@
 	int i;
 
 	for (i = 0; i < uhci->rh_numports; i++)
-		connection |= (inw(io_addr + USBPORTSC1 + i * 2) & 0x1);
+		connection |= (inw(io_addr + USBPORTSC1 + i * 2) & USBPORTSC_CCS);
 
 	return connection;
 }
diff -Nru a/drivers/usb/image/scanner.c b/drivers/usb/image/scanner.c
--- a/drivers/usb/image/scanner.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/usb/image/scanner.c	Wed Apr 30 22:28:06 2003
@@ -397,6 +397,7 @@
  */
 
 
+#include <linux/devfs_fs_kernel.h>
 #include <asm/byteorder.h>
 
 /* 
@@ -843,7 +844,7 @@
 	kfree(scn->obuf);
 
 	dbg("%s: De-allocating minor:%d", __FUNCTION__, scn->scn_minor);
-	devfs_unregister(scn->devfs);
+	devfs_remove("usb/scanner%d", scn->scn_minor - SCN_BASE_MNR);
 	usb_deregister_dev(1, scn->scn_minor);
 	usb_free_urb(scn->scn_irq);
 	usb_put_dev(scn->scn_dev);
@@ -1105,13 +1106,11 @@
 
 	sprintf(name, "usb/scanner%d", scn->scn_minor - SCN_BASE_MNR);
 	
-	scn->devfs = devfs_register(NULL, name,
+	devfs_register(NULL, name,
 				    DEVFS_FL_DEFAULT, USB_MAJOR,
 				    scn->scn_minor,
 				    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP |
 				    S_IWGRP | S_IROTH | S_IWOTH, &usb_scanner_fops, NULL);
-	if (scn->devfs == NULL)
-		dbg("scanner%d: device node registration failed", scn_minor);
 
 	info ("USB scanner device (0x%04x/0x%04x) now attached to %s",
 	      dev->descriptor.idVendor, dev->descriptor.idProduct, name);
diff -Nru a/drivers/usb/image/scanner.h b/drivers/usb/image/scanner.h
--- a/drivers/usb/image/scanner.h	Wed Apr 30 22:28:08 2003
+++ b/drivers/usb/image/scanner.h	Wed Apr 30 22:28:08 2003
@@ -40,7 +40,6 @@
 #include <linux/ioctl.h>
 #include <linux/sched.h>
 #include <linux/smp_lock.h>
-#include <linux/devfs_fs_kernel.h>
 
 // #define DEBUG
 
@@ -336,7 +335,6 @@
 
 struct scn_usb_data {
 	struct usb_device *scn_dev;
-	devfs_handle_t devfs;	/* devfs device */
 	struct urb *scn_irq;
 	unsigned int ifnum;	/* Interface number of the USB device */
 	int scn_minor;		/* Scanner minor - used in disconnect() */
diff -Nru a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
--- a/drivers/usb/input/hid-core.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/usb/input/hid-core.c	Wed Apr 30 22:28:10 2003
@@ -1664,9 +1664,6 @@
 	.probe =	hid_probe,
 	.disconnect =	hid_disconnect,
 	.id_table =	hid_usb_ids,
-	.driver	= {
-		.devclass = &input_devclass,
-	},
 };
 
 static int __init hid_init(void)
diff -Nru a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c
--- a/drivers/usb/input/hiddev.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/usb/input/hiddev.c	Wed Apr 30 22:28:08 2003
@@ -35,6 +35,7 @@
 #include <linux/usb.h>
 #include "hid.h"
 #include <linux/hiddev.h>
+#include <linux/devfs_fs_kernel.h>
 
 #ifdef CONFIG_USB_DYNAMIC_MINORS
 #define HIDDEV_MINOR_BASE	0
@@ -50,7 +51,6 @@
 	int open;
 	int minor;
 	wait_queue_head_t wait;
-	devfs_handle_t devfs;
 	struct hid_device *hid;
 	struct hiddev_list *list;
 };
@@ -66,7 +66,6 @@
 };
 
 static struct hiddev *hiddev_table[HIDDEV_MINORS];
-static devfs_handle_t hiddev_devfs_handle;
 
 /* forward reference to make our lives easier */
 extern struct usb_driver hiddev_driver;
@@ -229,7 +228,7 @@
  */
 static void hiddev_cleanup(struct hiddev *hiddev)
 {
-	devfs_unregister(hiddev->devfs);
+	devfs_remove("usb/hid/hiddev%d", hiddev->minor);
 	usb_deregister_dev(1, hiddev->minor);
 	hiddev_table[hiddev->minor] = NULL;
 	kfree(hiddev);
@@ -716,8 +715,8 @@
 	hiddev->exist = 1;
 
 	sprintf(devfs_name, "usb/hid/hiddev%d", minor);
-	hiddev->devfs = devfs_register(NULL, devfs_name,
-		DEVFS_FL_DEFAULT, USB_MAJOR, minor + HIDDEV_MINOR_BASE,
+	devfs_register(NULL, devfs_name, 0,
+		USB_MAJOR, minor + HIDDEV_MINOR_BASE,
 		S_IFCHR | S_IRUGO | S_IWUSR, &hiddev_fops, NULL);
 	hid->minor = minor;
 	hid->hiddev = hiddev;
@@ -774,7 +773,7 @@
 
 int __init hiddev_init(void)
 {
-	hiddev_devfs_handle = devfs_mk_dir("usb/hid");
+	devfs_mk_dir("usb/hid");
 	usb_register(&hiddev_driver);
 	return 0;
 }
diff -Nru a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c
--- a/drivers/usb/input/usbkbd.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/usb/input/usbkbd.c	Wed Apr 30 22:28:18 2003
@@ -359,9 +359,6 @@
 	.probe =	usb_kbd_probe,
 	.disconnect =	usb_kbd_disconnect,
 	.id_table =	usb_kbd_id_table,
-	.driver	= {
-		.devclass = &input_devclass,
-	},
 };
 
 static int __init usb_kbd_init(void)
diff -Nru a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c
--- a/drivers/usb/input/usbmouse.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/usb/input/usbmouse.c	Wed Apr 30 22:28:17 2003
@@ -242,9 +242,6 @@
 	.probe		= usb_mouse_probe,
 	.disconnect	= usb_mouse_disconnect,
 	.id_table	= usb_mouse_id_table,
-	.driver	= {
-		.devclass = &input_devclass,
-	},
 };
 
 static int __init usb_mouse_init(void)
diff -Nru a/drivers/usb/media/ibmcam.c b/drivers/usb/media/ibmcam.c
--- a/drivers/usb/media/ibmcam.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/usb/media/ibmcam.c	Wed Apr 30 22:28:06 2003
@@ -28,7 +28,6 @@
 
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/wrapper.h>
 #include <linux/module.h>
 #include <linux/init.h>
 
diff -Nru a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c
--- a/drivers/usb/media/ov511.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/usb/media/ov511.c	Wed Apr 30 22:28:07 2003
@@ -47,7 +47,6 @@
 #include <asm/io.h>
 #include <asm/semaphore.h>
 #include <asm/processor.h>
-#include <linux/wrapper.h>
 #include <linux/mm.h>
 
 #if defined (__i386__)
@@ -357,7 +356,7 @@
 	memset(mem, 0, size); /* Clear the ram out, no junk to the user */
 	adr = (unsigned long) mem;
 	while (size > 0) {
-		mem_map_reserve(vmalloc_to_page((void *)adr));
+		SetPageReserved(vmalloc_to_page((void *)adr));
 		adr += PAGE_SIZE;
 		size -= PAGE_SIZE;
 	}
@@ -375,7 +374,7 @@
 
 	adr = (unsigned long) mem;
 	while ((long) size > 0) {
-		mem_map_unreserve(vmalloc_to_page((void *)adr));
+		ClearPageReserved(vmalloc_to_page((void *)adr));
 		adr += PAGE_SIZE;
 		size -= PAGE_SIZE;
 	}
diff -Nru a/drivers/usb/media/pwc-if.c b/drivers/usb/media/pwc-if.c
--- a/drivers/usb/media/pwc-if.c	Wed Apr 30 22:28:14 2003
+++ b/drivers/usb/media/pwc-if.c	Wed Apr 30 22:28:14 2003
@@ -55,7 +55,6 @@
 #include <linux/poll.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
-#include <linux/wrapper.h>
 #include <asm/io.h>
 
 #include "pwc.h"
@@ -211,7 +210,7 @@
 	        adr=(unsigned long) mem;
 		while (size > 0) 
                 {
-			mem_map_reserve(vmalloc_to_page((void *)adr));
+			SetPageReserved(vmalloc_to_page((void *)adr));
 			adr+=PAGE_SIZE;
 			size-=PAGE_SIZE;
 		}
@@ -228,7 +227,7 @@
 	        adr=(unsigned long) mem;
 		while ((long) size > 0) 
                 {
-			mem_map_unreserve(vmalloc_to_page((void *)adr));
+			ClearPageReserved(vmalloc_to_page((void *)adr));
 			adr+=PAGE_SIZE;
 			size-=PAGE_SIZE;
 		}
diff -Nru a/drivers/usb/media/se401.c b/drivers/usb/media/se401.c
--- a/drivers/usb/media/se401.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/usb/media/se401.c	Wed Apr 30 22:28:07 2003
@@ -38,7 +38,6 @@
 #include <linux/usb.h>
 #include <asm/io.h>
 #include <asm/semaphore.h>
-#include <linux/wrapper.h>
 #include <linux/mm.h>
 
 #include "se401.h"
@@ -99,7 +98,7 @@
 	memset(mem, 0, size); /* Clear the ram out, no junk to the user */
 	adr = (unsigned long) mem;
 	while (size > 0) {
-		mem_map_reserve(vmalloc_to_page((void *)adr));
+		SetPageReserved(vmalloc_to_page((void *)adr));
 		adr += PAGE_SIZE;
 		size -= PAGE_SIZE;
 	}
@@ -116,7 +115,7 @@
 
 	adr = (unsigned long) mem;
 	while ((long) size > 0) {
-		mem_map_unreserve(vmalloc_to_page((void *)adr));
+		ClearPageReserved(vmalloc_to_page((void *)adr));
 		adr += PAGE_SIZE;
 		size -= PAGE_SIZE;
 	}
diff -Nru a/drivers/usb/media/stv680.c b/drivers/usb/media/stv680.c
--- a/drivers/usb/media/stv680.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/usb/media/stv680.c	Wed Apr 30 22:28:12 2003
@@ -66,7 +66,6 @@
 #include <linux/slab.h>
 #include <linux/proc_fs.h>
 #include <linux/pagemap.h>
-#include <linux/wrapper.h>
 #include <linux/smp_lock.h>
 #include <linux/sched.h>
 #include <linux/signal.h>
@@ -151,7 +150,7 @@
 	memset (mem, 0, size);	/* Clear the ram out, no junk to the user */
 	adr = (unsigned long) mem;
 	while (size > 0) {
-		mem_map_reserve(vmalloc_to_page((void *)adr));
+		SetPageReserved(vmalloc_to_page((void *)adr));
 		adr += PAGE_SIZE;
 		size -= PAGE_SIZE;
 	}
@@ -167,7 +166,7 @@
 
 	adr = (unsigned long) mem;
 	while ((long) size > 0) {
-		mem_map_unreserve(vmalloc_to_page((void *)adr));
+		ClearPageReserved(vmalloc_to_page((void *)adr));
 		adr += PAGE_SIZE;
 		size -= PAGE_SIZE;
 	}
diff -Nru a/drivers/usb/media/ultracam.c b/drivers/usb/media/ultracam.c
--- a/drivers/usb/media/ultracam.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/usb/media/ultracam.c	Wed Apr 30 22:28:05 2003
@@ -7,7 +7,6 @@
 
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/wrapper.h>
 #include <linux/module.h>
 #include <linux/init.h>
 
diff -Nru a/drivers/usb/media/usbvideo.c b/drivers/usb/media/usbvideo.c
--- a/drivers/usb/media/usbvideo.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/usb/media/usbvideo.c	Wed Apr 30 22:28:20 2003
@@ -22,7 +22,6 @@
 #include <linux/mm.h>
 #include <linux/smp_lock.h>
 #include <linux/vmalloc.h>
-#include <linux/wrapper.h>
 #include <linux/init.h>
 #include <linux/spinlock.h>
 #include <linux/mm.h>
@@ -103,7 +102,7 @@
 	memset(mem, 0, size); /* Clear the ram out, no junk to the user */
 	adr = (unsigned long) mem;
 	while (size > 0) {
-		mem_map_reserve(vmalloc_to_page((void *)adr));
+		SetPageReserved(vmalloc_to_page((void *)adr));
 		adr += PAGE_SIZE;
 		size -= PAGE_SIZE;
 	}
@@ -120,7 +119,7 @@
 
 	adr = (unsigned long) mem;
 	while ((long) size > 0) {
-		mem_map_unreserve(vmalloc_to_page((void *)adr));
+		ClearPageReserved(vmalloc_to_page((void *)adr));
 		adr += PAGE_SIZE;
 		size -= PAGE_SIZE;
 	}
diff -Nru a/drivers/usb/media/vicam.c b/drivers/usb/media/vicam.c
--- a/drivers/usb/media/vicam.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/usb/media/vicam.c	Wed Apr 30 22:28:07 2003
@@ -1,7 +1,10 @@
 /*
  * USB ViCam WebCam driver
  * Copyright (c) 2002 Joe Burks (jburks@wavicle.org),
- *                    John Tyner (jtyner@cs.ucr.edu)
+ *                    Christopher L Cheney (ccheney@cheney.cx),
+ *                    Pavel Machek (pavel@suse.cz),
+ *                    John Tyner (jtyner@cs.ucr.edu),
+ *                    Monroe Williams (monroe@pobox.com)
  *
  * Supports 3COM HomeConnect PC Digital WebCam
  *
@@ -32,7 +35,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/wrapper.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/videodev.h>
@@ -379,7 +381,7 @@
 	memset(mem, 0, size); /* Clear the ram out, no junk to the user */
 	adr = (unsigned long) mem;
 	while (size > 0) {
-		mem_map_reserve(vmalloc_to_page((void *)adr));
+		SetPageReserved(vmalloc_to_page((void *)adr));
 		adr += PAGE_SIZE;
 		size -= PAGE_SIZE;
 	}
@@ -396,7 +398,7 @@
 
 	adr = (unsigned long) mem;
 	while ((long) size > 0) {
-		mem_map_unreserve(vmalloc_to_page((void *)adr));
+		ClearPageReserved(vmalloc_to_page((void *)adr));
 		adr += PAGE_SIZE;
 		size -= PAGE_SIZE;
 	}
diff -Nru a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
--- a/drivers/usb/misc/auerswald.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/usb/misc/auerswald.c	Wed Apr 30 22:28:08 2003
@@ -242,7 +242,6 @@
 	struct semaphore 	mutex;         	    /* protection in user context */
 	char 			name[20];	    /* name of the /dev/usb entry */
 	unsigned int		dtindex;	    /* index in the device table */
-	devfs_handle_t 		devfs;	 	    /* devfs device node */
 	struct usb_device *	usbdev;      	    /* USB device handle */
 	int			open_count;	    /* count the number of open character channels */
         char 			dev_desc[AUSI_DLEN];/* for storing a textual description */
@@ -1972,7 +1971,7 @@
 	up (&dev_table_mutex);
 
 	/* initialize the devfs node for this device and register it */
-	cp->devfs = devfs_register(NULL, cp->name, 0, USB_MAJOR,
+	devfs_register(NULL, cp->name, 0, USB_MAJOR,
 				    AUER_MINOR_BASE + dtindex,
 				    S_IFCHR | S_IRUGO | S_IWUGO,
 				    &auerswald_fops, NULL);
@@ -2092,7 +2091,7 @@
 
 	/* remove our devfs node */
 	/* Nobody can see this device any more */
-	devfs_unregister (cp->devfs);
+	devfs_remove(cp->name);
 
 	/* give back our USB minor number */
 	usb_deregister_dev (1, cp->dtindex);
diff -Nru a/drivers/usb/misc/brlvger.c b/drivers/usb/misc/brlvger.c
--- a/drivers/usb/misc/brlvger.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/usb/misc/brlvger.c	Wed Apr 30 22:28:09 2003
@@ -156,7 +156,6 @@
 	struct usb_device   *dev; /* USB device handle */
 	struct usb_endpoint_descriptor *in_interrupt;
 	struct urb *intr_urb;
-	devfs_handle_t devfs;
 
 	int subminor; /* which minor dev #? */
 
@@ -374,16 +373,11 @@
 	dbg("Display length: %d", priv->plength);
 
 	sprintf(devfs_name, "usb/brlvger%d", priv->subminor);
-	priv->devfs = devfs_register(NULL, devfs_name,
+	devfs_register(NULL, devfs_name,
 				     DEVFS_FL_DEFAULT, USB_MAJOR,
 				     BRLVGER_MINOR+priv->subminor,
 				     S_IFCHR |S_IRUSR|S_IWUSR |S_IRGRP|S_IWGRP,
 				     &brlvger_fops, NULL);
-	if (!priv->devfs) {
-#ifdef CONFIG_DEVFS_FS
-		err("devfs node registration failed");
-#endif
-	}
 
 	display_table[i] = priv;
 
@@ -420,7 +414,7 @@
 	if(priv){
 		info("Display %d disconnecting", priv->subminor);
 
-		devfs_unregister(priv->devfs);
+		devfs_remove("usb/brlvger%d", priv->subminor);
 		usb_deregister_dev(1, priv->subminor);
 
 		down(&disconnect_sem);
diff -Nru a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c
--- a/drivers/usb/misc/rio500.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/usb/misc/rio500.c	Wed Apr 30 22:28:11 2003
@@ -65,7 +65,6 @@
 
 struct rio_usb_data {
         struct usb_device *rio_dev;     /* init: probe_rio */
-        devfs_handle_t devfs;           /* devfs device */
         unsigned int ifnum;             /* Interface number of the USB device */
         int isopen;                     /* nz if open */
         int present;                    /* Device is present on the bus */
@@ -476,13 +475,11 @@
 	}
 	dbg("probe_rio: ibuf address:%p", rio->ibuf);
 
-	rio->devfs = devfs_register(NULL, "usb/rio500",
+	devfs_register(NULL, "usb/rio500",
 				    DEVFS_FL_DEFAULT, USB_MAJOR,
 				    RIO_MINOR,
 				    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP |
 				    S_IWGRP, &usb_rio_fops, NULL);
-	if (rio->devfs == NULL)
-		dbg("probe_rio: device node registration failed");
 
 	init_MUTEX(&(rio->lock));
 
@@ -496,7 +493,7 @@
 
 	usb_set_intfdata (intf, NULL);
 	if (rio) {
-		devfs_unregister(rio->devfs);
+		devfs_remove("usb/rio500");
 		usb_deregister_dev(1, rio->minor);
 
 		down(&(rio->lock));
diff -Nru a/drivers/usb/misc/speedtch.c b/drivers/usb/misc/speedtch.c
--- a/drivers/usb/misc/speedtch.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/usb/misc/speedtch.c	Wed Apr 30 22:28:20 2003
@@ -20,7 +20,19 @@
  ******************************************************************************/
 
 /*
- *  Written by Johan Verrept (Johan.Verrept@advalvas.be)
+ *  Written by Johan Verrept, maintained by Duncan Sands (duncan.sands@wanadoo.fr)
+ *
+ *  1.6:	- No longer opens a connection if the firmware is not loaded
+ *  		- Added support for the speedtouch 330
+ *  		- Removed the limit on the number of devices
+ *  		- Module now autoloads on device plugin
+ *  		- Merged relevant parts of sarlib
+ *  		- Replaced the kernel thread with a tasklet
+ *  		- New packet transmission code
+ *  		- Changed proc file contents
+ *  		- Fixed all known SMP races
+ *  		- Many fixes and cleanups
+ *  		- Various fixes by Oliver Neukum (oliver@neukum.name)
  *
  *  1.5A:	- Version for inclusion in 2.5 series kernel
  *		- Modifications by Richard Purdie (rpurdie@rpsys.net)
@@ -28,6 +40,7 @@
  *		udsl_usb_send_data_context->urb to a pointer and adding code
  *		to alloc and free it
  *		- remove_wait_queue() added to udsl_atm_processqueue_thread()
+ *		- Duncan Sands (duncan.sands@wanadoo.fr) is the new maintainer
  *
  *  1.5:	- fixed memory leak when atmsar_decode_aal5 returned NULL.
  *		(reported by stephen.robinson@zen.co.uk)
@@ -77,9 +90,9 @@
 #define PACKETDEBUG(arg...)
 #endif
 
-#define DRIVER_AUTHOR	"Johan Verrept, Johan.Verrept@advalvas.be"
-#define DRIVER_DESC	"Driver for the Alcatel SpeedTouch USB ADSL modem"
-#define DRIVER_VERSION	"1.5A"
+#define DRIVER_AUTHOR	"Johan Verrept, Duncan Sands <duncan.sands@wanadoo.fr>"
+#define DRIVER_DESC	"Alcatel SpeedTouch USB driver"
+#define DRIVER_VERSION	"1.6"
 
 #define SPEEDTOUCH_VENDORID		0x06b9
 #define SPEEDTOUCH_PRODUCTID		0x4061
@@ -393,11 +406,12 @@
 **  encode  **
 *************/
 
+static const unsigned char zeros[ATM_CELL_PAYLOAD];
+
 static void udsl_groom_skb (struct atm_vcc *vcc, struct sk_buff *skb)
 {
 	struct udsl_control *ctrl = UDSL_SKB (skb);
-	unsigned int i, zero_padding;
-	unsigned char zero = 0;
+	unsigned int zero_padding;
 	u32 crc;
 
 	ctrl->atm_data.vcc = vcc;
@@ -423,8 +437,7 @@
 	ctrl->aal5_trailer [3] = skb->len;
 
 	crc = crc32_be (~0, skb->data, skb->len);
-	for (i = 0; i < zero_padding; i++)
-		crc = crc32_be (crc, &zero, 1);
+	crc = crc32_be (crc, zeros, zero_padding);
 	crc = crc32_be (crc, ctrl->aal5_trailer, 4);
 	crc = ~crc;
 
@@ -566,8 +579,7 @@
 						atmsar_vcc->vcc->push (atmsar_vcc->vcc, new);
 					} else {
 						dbg
-						    ("dropping incoming packet : rx_inuse = %d, vcc->sk->rcvbuf = %d, skb->true_size = %d",
-						     atomic_read (&atmsar_vcc->vcc->rx_inuse),
+						    ("dropping incoming packet : vcc->sk->rcvbuf = %d, skb->true_size = %d",
 						     atmsar_vcc->vcc->sk->rcvbuf, new->truesize);
 						dev_kfree_skb (new);
 					}
diff -Nru a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig
--- a/drivers/usb/net/Kconfig	Wed Apr 30 22:28:13 2003
+++ b/drivers/usb/net/Kconfig	Wed Apr 30 22:28:13 2003
@@ -28,30 +28,6 @@
 	  The module will be called catc. If you want to compile it as a
 	  module, say M here and read <file:Documentation/modules.txt>.
 
-config USB_CDCETHER
-	tristate "USB CDC Ethernet support (EXPERIMENTAL)"
-	depends on USB && NET && EXPERIMENTAL
-	---help---
-	  This driver supports devices conforming to the Communication Device
-	  Class Ethernet Control Model.  This is used in some cable modems.
-	  For more details on the specification, get the Communication Device
-	  Class specification from <http://www.usb.org/>.
-
-	  This driver should work with the following devices:
-	  * Ericsson PipeRider (all variants)
-	  * Motorola (DM100 and SB4100)
-	  * Broadcom Cable Modem (reference design)
-	  * Toshiba PCX1100U and possibly other cable modems
-
-	  The device creates a network device (ethX, where X depends on what
-	  other networking devices you have in use), as for a normal PCI
-	  or ISA based ethernet network card.
-
-	  This code is also available as a module ( = code which can be
-	  inserted in and removed from the running kernel whenever you want).
-	  The module will be called cdc-ether.  If you want to compile it 
-	  as a module, say M here and read <file:Documentation/modules.txt>.
-
 config USB_KAWETH
 	tristate "USB KLSI KL5USB101-based ethernet device support"
 	depends on USB && NET
@@ -124,26 +100,147 @@
 	  module, say M here and read <file:Documentation/modules.txt>.
 
 config USB_USBNET
-	tristate "USB-to-USB Networking for cables, PDAs and other devices"
+	tristate "Host-to-Host Networking for Cables and Smart Devices"
 	depends on USB && NET
 	---help---
-	  This driver supports network links over USB with USB "Network"
-	  or "data transfer" cables, often used to network laptops to PCs.
-	  Such cables have chips from suppliers such as Belkin/eTEK, GeneSys
-	  (GeneLink), NetChip and Prolific.  Some motherboards with USB PC2PC
-	  support include such chips.
-	  
-	  Intelligent USB devices, such as PDAs running Linux (like Yopy
-	  and Zaurus, or iPaqs after upgrading to Linux) can use the same
-	  approach to provide Internet access.
-
-	  These links will have names like "usb0", "usb1", etc.  They act
-	  like two-node Ethernets, so you can use 802.1d Ethernet Bridging
-	  (CONFIG_BRIDGE) to simplify your network routing.  For more
-	  information see <http://www.linux-usb.org/usbnet/>.
+	  This driver supports several kinds of network links over USB,
+	  with "minidrivers" built around a common network driver core
+	  that supports deep queues for efficient transfers.
+
+	  Typically, these links involves only two network hosts.  The
+	  host runs "usbnet", and the other end of the link might be:
+
+	  - Another USB host, when using USB "network" or "data transfer"
+	    cables.  These are often used to network laptops to PCs, like
+	    "Laplink" parallel cables or some motherboards.  These rely
+	    on specialized chips from many suppliers.
+
+	  - An intelligent USB gadget, perhaps embedding a Linux system.
+	    These include PDAs running Linux (iPaq, Yopy, Zaurus, and
+	    others), and devices that interoperate using the standard
+	    CDC-Ethernet specification (including many cable modems).
+
+	  The link will appear with a name like "usb0", when the link is
+	  a two-node link, or "eth0" for most CDC-Ethernet devices.  Those
+	  two-node links are most easily managed with Ethernet Bridging
+	  (CONFIG_BRIDGE) instead of routing.
+
+	  For more information see <http://www.linux-usb.org/usbnet/>.
 
 	  This code is also available as a kernel module (code which can be
 	  inserted in and removed from the running kernel whenever you want).
 	  The module will be called usbnet. If you want to compile it as a
 	  module, say M here and read <file:Documentation/modules.txt>.
+
+comment "USB Host-to-Host Cables"
+	depends on USB_USBNET
+
+config USB_AN2720
+	boolean "AnchorChips 2720 based cables (Xircom PGUNET, ...)"
+	depends on USB_USBNET
+	default y
+	help
+	  Choose this option if you're using a host-to-host cable
+	  based on this design.  Note that AnchorChips is now a
+	  Cypress brand.
+
+config USB_BELKIN
+	boolean "eTEK based host-to-host cables (Advance, Belkin, ...)"
+	depends on USB_USBNET
+	default y
+	help
+	  Choose this option if you're using a host-to-host cable
+	  based on this design:  two NetChip 2890 chips and an Atmel
+	  microcontroller, with LEDs that indicate traffic.
+
+config USB_GENESYS
+	boolean "GeneSys GL620USB-A based cables"
+	default y
+	depends on USB_USBNET
+	help
+	  Choose this option if you're using a host-to-host cable,
+	  or PC2PC motherboard, with this chip.
+
+	  Note that the half-duplex "GL620USB" is not supported.
+
+config USB_NET1080
+	boolean "NetChip 1080 based cables (Laplink, ...)"
+	default y
+	depends on USB_USBNET
+	help
+	  Choose this option if you're using a host-to-host cable based
+	  on this design:  one NetChip 1080 chips and supporting logic,
+	  supporting LEDs that indicate traffic
+
+config USB_PL2301
+	boolean "Prolific PL-2301/2302 based cables"
+	default y
+	# handshake/init/reset problems, from original 'plusb' driver
+	depends on USB_USBNET && EXPERIMENTAL
+	help
+	  Choose this option if you're using a host-to-host cable
+	  with one of these chips.
+
+comment "Intelligent USB Devices/Gadgets"
+	depends on USB_USBNET
+
+config USB_ARMLINUX
+	boolean "Embedded ARM Linux links (iPaq, ...)"
+	depends on USB_USBNET
+	default y
+	help
+	  Choose this option to support the "usb-eth" networking driver
+	  used by most of the ARM Linux community with device controllers
+	  such as the SA-11x0 and PXA-25x UDCs.
+
+	  Although the ROMs shipped with Sharp Zaurus products use a
+	  different link level framing protocol, you can have them use
+	  this simpler protocol by installing a different kernel.
+
+config USB_EPSON2888
+	boolean "Epson 2888 based firmware (DEVELOPMENT)"
+	depends on USB_USBNET
+	default y
+	help
+	  Choose this option to support the usb networking links used
+	  by some sample firmware from Epson.
+
+config USB_ZAURUS
+	boolean "Sharp Zaurus (stock ROMs)"
+	depends on USB_USBNET
+	default y
+	help
+	  Choose this option to support the usb networking links used by
+	  Zaurus models like the SL-5000D, SL-5500, SL-5600, A-300, B-500.
+
+	  If you install an alternate ROM image, you may no longer need
+	  to support this protocol.  Only the "eth-fd" driver really needs
+	  this non-conformant variant of CDC Ethernet protocol.
+
+config USB_CDCETHER
+	boolean "CDC Ethernet support (smart devices such as cable modems)"
+	# experimental primarily because cdc-ether was.
+	# make it non-experimental after more interop testing
+	depends on USB_USBNET && EXPERIMENTAL
+	default y
+	help
+	  This option supports devices conforming to the Communication Device
+	  Class (CDC) Ethernet Control Model, a specification that's easy to
+	  implement in device firmware.  The CDC specifications are available
+	  from <http://www.usb.org/>.
+	  
+	  CDC Ethernet is an implementation option for DOCSIS cable modems
+	  that support USB connectivity, used for non-Microsoft USB hosts.
+ 	  This driver should work with at least the following devices:
+
+ 	    * Ericsson PipeRider (all variants)
+ 	    * Motorola (DM100 and SB4100)
+ 	    * Broadcom Cable Modem (reference design)
+ 	    * Toshiba PCX1100U
+	    * ...
+
+	  This driver creates an interface named "ethX", where X depends on
+	  what other networking devices you have in use.  However, if the
+	  IEEE 802 "local assignment" bit is set in the address, a "usbX"
+	  name is used instead.
 
diff -Nru a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile
--- a/drivers/usb/net/Makefile	Wed Apr 30 22:28:03 2003
+++ b/drivers/usb/net/Makefile	Wed Apr 30 22:28:03 2003
@@ -3,7 +3,6 @@
 #
 
 obj-$(CONFIG_USB_CATC)		+= catc.o
-obj-$(CONFIG_USB_CDCETHER)	+= cdc-ether.o
 obj-$(CONFIG_USB_KAWETH)	+= kaweth.o
 obj-$(CONFIG_USB_PEGASUS)	+= pegasus.o
 obj-$(CONFIG_USB_RTL8150)	+= rtl8150.o
diff -Nru a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c
--- a/drivers/usb/net/kaweth.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/usb/net/kaweth.c	Wed Apr 30 22:28:13 2003
@@ -744,7 +744,7 @@
 		}
 	}
 
-	private_header = __skb_push(skb, 2);
+	private_header = (u16 *)__skb_push(skb, 2);
 	*private_header = cpu_to_le16(skb->len-2);
 	kaweth->tx_skb = skb;
 
diff -Nru a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
--- a/drivers/usb/net/usbnet.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/usb/net/usbnet.c	Wed Apr 30 22:28:10 2003
@@ -157,20 +157,7 @@
 #include <linux/dma-mapping.h>
 
 
-/* minidrivers _could_ be individually configured */
-#define	CONFIG_USB_AN2720
-#define	CONFIG_USB_BELKIN
-#undef	CONFIG_USB_CDCETHER
-//#define	CONFIG_USB_CDCETHER		/* NYET */
-#define	CONFIG_USB_EPSON2888
-#define	CONFIG_USB_GENESYS
-#define	CONFIG_USB_NET1080
-#define	CONFIG_USB_PL2301
-#define	CONFIG_USB_ARMLINUX
-#define	CONFIG_USB_ZAURUS
-
-
-#define DRIVER_VERSION		"31-Mar-2003"
+#define DRIVER_VERSION		"25-Apr-2003"
 
 /*-------------------------------------------------------------------------*/
 
@@ -256,6 +243,7 @@
 #define FLAG_FRAMING_Z	0x0004		/* zaurus adds a trailer */
 
 #define FLAG_NO_SETINT	0x0010		/* device can't set_interface() */
+#define FLAG_ETHER	0x0020		/* maybe use "eth%d" names */
 
 	/* init device ... can sleep, or cause probe() failure */
 	int	(*bind)(struct usbnet *, struct usb_interface *);
@@ -315,19 +303,19 @@
 
 #ifdef DEBUG
 #define devdbg(usbnet, fmt, arg...) \
-	printk(KERN_DEBUG "%s: " fmt "\n" , (usbnet)->net.name, ## arg)
+	printk(KERN_DEBUG "%s: " fmt "\n" , (usbnet)->net.name , ## arg)
 #else
 #define devdbg(usbnet, fmt, arg...) do {} while(0)
 #endif
 
 #define deverr(usbnet, fmt, arg...) \
-	printk(KERN_ERR "%s: " fmt "\n" , (usbnet)->net.name, ## arg)
+	printk(KERN_ERR "%s: " fmt "\n" , (usbnet)->net.name , ## arg)
 #define devwarn(usbnet, fmt, arg...) \
-	printk(KERN_WARNING "%s: " fmt "\n" , (usbnet)->net.name, ## arg)
+	printk(KERN_WARNING "%s: " fmt "\n" , (usbnet)->net.name , ## arg)
 
 #define devinfo(usbnet, fmt, arg...) \
 	do { if ((usbnet)->msg_level >= 1) \
-	printk(KERN_INFO "%s: " fmt "\n" , (usbnet)->net.name, ## arg); \
+	printk(KERN_INFO "%s: " fmt "\n" , (usbnet)->net.name , ## arg); \
 	} while (0)
 
 /*-------------------------------------------------------------------------*/
@@ -392,6 +380,7 @@
 
 
 #ifdef	CONFIG_USB_AN2720
+#define	HAVE_HARDWARE
 
 /*-------------------------------------------------------------------------
  *
@@ -417,6 +406,7 @@
 
 
 #ifdef	CONFIG_USB_BELKIN
+#define	HAVE_HARDWARE
 
 /*-------------------------------------------------------------------------
  *
@@ -443,7 +433,11 @@
  * Takes two interfaces.  The DATA interface is inactive till an altsetting
  * is selected.  Configuration data includes class descriptors.
  *
- * Zaurus uses nonstandard framing, but is otherwise CDC Ether.
+ * Zaurus uses nonstandard framing, and doesn't uniquify its Ethernet
+ * addresses, but is otherwise CDC Ether.
+ *
+ * This should interop with whatever the 2.4 "CDCEther.c" driver
+ * (by Brad Hards) talked with.
  *
  *-------------------------------------------------------------------------*/
 
@@ -585,9 +579,17 @@
 	if (!info->header || !info ->u || !info->ether)
 		goto bad_desc;
 
-	status = get_ethernet_addr (dev, info->ether);
-	if (status < 0)
-		return status;
+#ifdef CONFIG_USB_ZAURUS
+	/* Zaurus ethernet addresses aren't unique ... */
+	if ((dev->driver_info->flags & FLAG_FRAMING_Z) != 0)
+		/* ignore */ ;
+	else
+#endif
+	{
+		status = get_ethernet_addr (dev, info->ether);
+		if (status < 0)
+			return status;
+	}
 
 	/* claim data interface and set it up ... with side effects.
 	 * network traffic can't flow until an altsetting is enabled.
@@ -605,8 +607,6 @@
 
 	dev->net.mtu = cpu_to_le16p (&info->ether->wMaxSegmentSize)
 		- ETH_HLEN;
-	if ((dev->driver_info->flags & FLAG_FRAMING_Z) == 0)
-		strcpy (dev->net.name, "eth%d");
 	return 0;
 
 bad_desc:
@@ -636,9 +636,11 @@
 
 
 #ifdef	CONFIG_USB_CDCETHER
+#define	HAVE_HARDWARE
 
 static const struct driver_info	cdc_info = {
 	.description =	"CDC Ethernet Device",
+	.flags =	FLAG_ETHER,
 	// .check_connect = cdc_check_connect,
 	.bind =		cdc_bind,
 	.unbind =	cdc_unbind,
@@ -649,6 +651,7 @@
 
 
 #ifdef	CONFIG_USB_EPSON2888
+#define	HAVE_HARDWARE
 
 /*-------------------------------------------------------------------------
  *
@@ -659,6 +662,8 @@
  * implements this interface.  Product developers can reuse or modify that
  * code, such as by using their own product and vendor codes.
  *
+ * Support was from Juro Bystricky <bystricky.juro@erd.epson.com>
+ *
  *-------------------------------------------------------------------------*/
 
 static const struct driver_info	epson2888_info = {
@@ -672,6 +677,7 @@
 
 
 #ifdef CONFIG_USB_GENESYS
+#define	HAVE_HARDWARE
 
 /*-------------------------------------------------------------------------
  *
@@ -689,6 +695,9 @@
  *    the transfer direction.  (That's disabled here, partially coded.)
  *    A control URB would block until other side writes an interrupt.
  *
+ * Original code from Jiun-Jie Huang <huangjj@genesyslogic.com.tw>
+ * and merged into "usbnet" by Stanislav Brabec <utx@penguin.cz>.
+ *
  *-------------------------------------------------------------------------*/
 
 // control msg write command
@@ -1007,6 +1016,7 @@
 
 
 #ifdef	CONFIG_USB_NET1080
+#define	HAVE_HARDWARE
 
 /*-------------------------------------------------------------------------
  *
@@ -1522,11 +1532,15 @@
 
 
 #ifdef CONFIG_USB_PL2301
+#define	HAVE_HARDWARE
 
 /*-------------------------------------------------------------------------
  *
  * Prolific PL-2301/PL-2302 driver ... http://www.prolifictech.com
  *
+ * The protocol and handshaking used here should be bug-compatible
+ * with the Linux 2.2 "plusb" driver, by Deti Fliegl.
+ *
  *-------------------------------------------------------------------------*/
 
 /*
@@ -1586,6 +1600,7 @@
 
 
 #ifdef	CONFIG_USB_ARMLINUX
+#define	HAVE_HARDWARE
 
 /*-------------------------------------------------------------------------
  *
@@ -1618,6 +1633,7 @@
 
 
 #ifdef CONFIG_USB_ZAURUS
+#define	HAVE_HARDWARE
 
 #include <linux/crc32.h>
 
@@ -1732,7 +1748,9 @@
 
 /*-------------------------------------------------------------------------*/
 
-/* urb completions may be in_irq; avoid doing real work then. */
+/* some LK 2.4 HCDs oopsed if we freed or resubmitted urbs from
+ * completion callbacks.  2.5 should have fixed those bugs...
+ */
 
 static void defer_bh (struct usbnet *dev, struct sk_buff *skb)
 {
@@ -2498,6 +2516,10 @@
 	int				status;
 
 	info = (struct driver_info *) prod->driver_info;
+	if (!info) {
+		dev_dbg (&udev->dev, "blacklisted by %s\n", driver_name);
+		return -ENODEV;
+	}
 	xdev = interface_to_usbdev (udev);
 	interface = &udev->altsetting [udev->act_altsetting];
 
@@ -2549,9 +2571,15 @@
 
 	// allow device-specific bind/init procedures
 	// NOTE net->name still not usable ...
-	if (info->bind)
+	if (info->bind) {
 		status = info->bind (dev, udev);
-	else if (!info->in || info->out)
+		// heuristic:  "usb%d" for links we know are two-host,
+		// else "eth%d" when there's reasonable doubt.  userspace
+		// can rename the link if it knows better.
+		if ((dev->driver_info->flags & FLAG_ETHER) != 0
+				&& (net->dev_addr [0] & 0x02) == 0)
+			strcpy (net->name, "eth%d");
+	} else if (!info->in || info->out)
 		status = get_endpoints (dev, udev);
 	else {
 		dev->in = usb_rcvbulkpipe (xdev, info->in);
@@ -2588,6 +2616,10 @@
 
 /*-------------------------------------------------------------------------*/
 
+#ifndef	HAVE_HARDWARE
+#error You need to configure some hardware for this driver
+#endif
+
 /*
  * chip vendor names won't normally be on the cables, and
  * may not be on the device.
@@ -2712,6 +2744,22 @@
 #endif
 
 #ifdef	CONFIG_USB_CDCETHER
+
+#ifndef	CONFIG_USB_ZAURUS
+	/* if we couldn't whitelist Zaurus, we must blacklist it */
+{
+	.match_flags	=   USB_DEVICE_ID_MATCH_INT_INFO
+			  | USB_DEVICE_ID_MATCH_DEVICE, 
+	.idVendor		= 0x04DD,
+	.idProduct		= 0x8004,
+	/* match the master interface */
+	.bInterfaceClass	= USB_CLASS_COMM,
+	.bInterfaceSubClass	= 6 /* Ethernet model */,
+	.bInterfaceProtocol	= 0,
+	.driver_info 		= 0, /* BLACKLIST */
+},
+#endif
+
 {
 	/* CDC Ether uses two interfaces, not necessarily consecutive.
 	 * We match the main interface, ignoring the optional device
@@ -2721,10 +2769,7 @@
 	 * NOTE:  this match must come AFTER entries working around
 	 * bugs/quirks in a given product (like Zaurus, above).
 	 */
-	.match_flags		= USB_DEVICE_ID_MATCH_INT_INFO,
-	.bInterfaceClass	= USB_CLASS_COMM,
-	.bInterfaceSubClass	= 6 /* Ethernet model */,
-	.bInterfaceProtocol	= 0,
+	USB_INTERFACE_INFO (USB_CLASS_COMM, 6 /* Ethernet model */, 0),
 	.driver_info = (unsigned long) &cdc_info,
 },
 #endif
diff -Nru a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
--- a/drivers/usb/serial/belkin_sa.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/usb/serial/belkin_sa.c	Wed Apr 30 22:28:10 2003
@@ -101,6 +101,8 @@
 static void belkin_sa_set_termios	(struct usb_serial_port *port, struct termios * old);
 static int  belkin_sa_ioctl		(struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
 static void belkin_sa_break_ctl		(struct usb_serial_port *port, int break_state );
+static int  belkin_sa_tiocmget		(struct usb_serial_port *port, struct file *file);
+static int  belkin_sa_tiocmset		(struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
 
 
 static struct usb_device_id id_table_combined [] = {
@@ -138,6 +140,8 @@
 	.ioctl =		belkin_sa_ioctl,
 	.set_termios =		belkin_sa_set_termios,
 	.break_ctl =		belkin_sa_break_ctl,
+	.tiocmget =		belkin_sa_tiocmget,
+	.tiocmset =		belkin_sa_tiocmset,
 	.attach =		belkin_sa_startup,
 	.shutdown =		belkin_sa_shutdown,
 };
@@ -502,65 +506,77 @@
 }
 
 
-static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
+static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file)
+{
+	struct belkin_sa_private *priv = usb_get_serial_port_data(port);
+	unsigned long control_state;
+	unsigned long flags;
+	
+	dbg("%s", __FUNCTION__);
+
+	spin_lock_irqsave(&priv->lock, flags);
+	control_state = priv->control_state;
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	return control_state;
+}
+
+
+static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file,
+			       unsigned int set, unsigned int clear)
 {
 	struct usb_serial *serial = port->serial;
-	__u16 urb_value; /* Will hold the new flags */
 	struct belkin_sa_private *priv = usb_get_serial_port_data(port);
-	int ret = 0;
-	int mask;
 	unsigned long control_state;
 	unsigned long flags;
+	int retval;
+	int rts = 0;
+	int dtr = 0;
 	
+	dbg("%s", __FUNCTION__);
+
 	spin_lock_irqsave(&priv->lock, flags);
 	control_state = priv->control_state;
+
+	if (set & TIOCM_RTS) {
+		control_state |= TIOCM_RTS;
+		rts = 1;
+	}
+	if (set & TIOCM_DTR) {
+		control_state |= TIOCM_DTR;
+		dtr = 1;
+	}
+	if (clear & TIOCM_RTS) {
+		control_state &= ~TIOCM_RTS;
+		rts = 0;
+	}
+	if (clear & TIOCM_DTR) {
+		control_state &= ~TIOCM_DTR;
+		dtr = 0;
+	}
+
+	priv->control_state = control_state;
 	spin_unlock_irqrestore(&priv->lock, flags);
 
-	/* Based on code from acm.c and others */
-	switch (cmd) {
-	case TIOCMGET:
-		return put_user(control_state, (unsigned long *) arg);
-		break;
+	retval = BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, rts);
+	if (retval < 0) {
+		err("Set RTS error %d", retval);
+		goto exit;
+	}
 
-	case TIOCMSET: /* Turns on and off the lines as specified by the mask */
-	case TIOCMBIS: /* turns on (Sets) the lines as specified by the mask */
-	case TIOCMBIC: /* turns off (Clears) the lines as specified by the mask */
-		if (get_user(mask, (unsigned long *) arg))
-			return -EFAULT;
-
-		if ((cmd == TIOCMSET) || (mask & TIOCM_RTS)) {
-			/* RTS needs set */
-			urb_value = ((cmd == TIOCMSET) && (mask & TIOCM_RTS)) || (cmd == TIOCMBIS) ? 1 : 0;
-			if (urb_value)
-				control_state |= TIOCM_RTS;
-			else
-				control_state &= ~TIOCM_RTS;
-
-			if ((ret = BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, urb_value)) < 0) {
-				err("Set RTS error %d", ret);
-				goto cmerror;
-			}
-		}
+	retval = BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, dtr);
+	if (retval < 0) {
+		err("Set DTR error %d", retval);
+		goto exit;
+	}
+exit:
+	return retval;
+}
 
-		if ((cmd == TIOCMSET) || (mask & TIOCM_DTR)) {
-			/* DTR needs set */
-			urb_value = ((cmd == TIOCMSET) && (mask & TIOCM_DTR)) || (cmd == TIOCMBIS) ? 1 : 0;
-			if (urb_value)
-				control_state |= TIOCM_DTR;
-			else
-				control_state &= ~TIOCM_DTR;
-			if ((ret = BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, urb_value)) < 0) {
-				err("Set DTR error %d", ret);
-				goto cmerror;
-			}
-		}
-cmerror:
-		spin_lock_irqsave(&priv->lock, flags);
-		priv->control_state = control_state;
-		spin_unlock_irqrestore(&priv->lock, flags);
-		return ret;
-		break;
-					
+
+static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
+{
+	switch (cmd) {
 	case TIOCMIWAIT:
 		/* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
 		/* TODO */
diff -Nru a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
--- a/drivers/usb/serial/bus.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/usb/serial/bus.c	Wed Apr 30 22:28:20 2003
@@ -142,7 +142,6 @@
 	device->driver.bus = &usb_serial_bus_type;
 	device->driver.probe = usb_serial_device_probe;
 	device->driver.remove = usb_serial_device_remove;
-	device->driver.devclass = &tty_devclass;
 
 	retval = driver_register(&device->driver);
 
diff -Nru a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
--- a/drivers/usb/serial/digi_acceleport.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/usb/serial/digi_acceleport.c	Wed Apr 30 22:28:09 2003
@@ -460,6 +460,9 @@
 static void digi_break_ctl( struct usb_serial_port *port, int break_state );
 static int digi_ioctl( struct usb_serial_port *port, struct file *file,
 	unsigned int cmd, unsigned long arg );
+static int digi_tiocmget( struct usb_serial_port *port, struct file *file );
+static int digi_tiocmset( struct usb_serial_port *port, struct file *file,
+	unsigned int set, unsigned int clear );
 static int digi_write( struct usb_serial_port *port, int from_user,
 	const unsigned char *buf, int count );
 static void digi_write_bulk_callback( struct urb *urb, struct pt_regs *regs );
@@ -526,6 +529,8 @@
 	.ioctl =			digi_ioctl,
 	.set_termios =			digi_set_termios,
 	.break_ctl =			digi_break_ctl,
+	.tiocmget =			digi_tiocmget,
+	.tiocmset =			digi_tiocmset,
 	.attach =			digi_startup,
 	.shutdown =			digi_shutdown,
 };
@@ -551,6 +556,8 @@
 	.ioctl =			digi_ioctl,
 	.set_termios =			digi_set_termios,
 	.break_ctl =			digi_break_ctl,
+	.tiocmget =			digi_tiocmget,
+	.tiocmset =			digi_tiocmset,
 	.attach =			digi_startup,
 	.shutdown =			digi_shutdown,
 };
@@ -1211,39 +1218,46 @@
 }
 
 
-static int digi_ioctl( struct usb_serial_port *port, struct file *file,
-	unsigned int cmd, unsigned long arg )
+static int digi_tiocmget( struct usb_serial_port *port, struct file *file )
 {
+	struct digi_port *priv = usb_get_serial_port_data(port);
+	unsigned int val;
+	unsigned long flags;
+
+	dbg("%s: TOP: port=%d", __FUNCTION__, priv->dp_port_num);
+
+	spin_lock_irqsave( &priv->dp_port_lock, flags );
+	val = priv->dp_modem_signals;
+	spin_unlock_irqrestore( &priv->dp_port_lock, flags );
+	return val;
+}
 
+
+static int digi_tiocmset( struct usb_serial_port *port, struct file *file,
+	unsigned int set, unsigned int clear )
+{
 	struct digi_port *priv = usb_get_serial_port_data(port);
 	unsigned int val;
-	unsigned long flags = 0;
+	unsigned long flags;
 
+	dbg("%s: TOP: port=%d", __FUNCTION__, priv->dp_port_num);
 
-dbg( "digi_ioctl: TOP: port=%d, cmd=0x%x", priv->dp_port_num, cmd );
+	spin_lock_irqsave( &priv->dp_port_lock, flags );
+	val = (priv->dp_modem_signals & ~clear) | set;
+	spin_unlock_irqrestore( &priv->dp_port_lock, flags );
+	return digi_set_modem_signals( port, val, 1 );
+}
 
-	switch (cmd) {
 
-	case TIOCMGET:
-		spin_lock_irqsave( &priv->dp_port_lock, flags );
-		val = priv->dp_modem_signals;
-		spin_unlock_irqrestore( &priv->dp_port_lock, flags );
-		if( copy_to_user((unsigned int *)arg, &val, sizeof(int)) )
-			return( -EFAULT );
-		return( 0 );
+static int digi_ioctl( struct usb_serial_port *port, struct file *file,
+	unsigned int cmd, unsigned long arg )
+{
 
-	case TIOCMSET:
-	case TIOCMBIS:
-	case TIOCMBIC:
-		if( copy_from_user(&val, (unsigned int *)arg, sizeof(int)) )
-			return( -EFAULT );
-		spin_lock_irqsave( &priv->dp_port_lock, flags );
-		if( cmd == TIOCMBIS )
-			val = priv->dp_modem_signals | val;
-		else if( cmd == TIOCMBIC )
-			val = priv->dp_modem_signals & ~val;
-		spin_unlock_irqrestore( &priv->dp_port_lock, flags );
-		return( digi_set_modem_signals( port, val, 1 ) );
+	struct digi_port *priv = usb_get_serial_port_data(port);
+
+dbg( "digi_ioctl: TOP: port=%d, cmd=0x%x", priv->dp_port_num, cmd );
+
+	switch (cmd) {
 
 	case TIOCMIWAIT:
 		/* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
@@ -1565,8 +1579,8 @@
 	}
 
 	/* flush driver and line discipline buffers */
-	if( tty->driver.flush_buffer )
-		tty->driver.flush_buffer( tty );
+	if( tty->driver->flush_buffer )
+		tty->driver->flush_buffer( tty );
 	if( tty->ldisc.flush_buffer )
 		tty->ldisc.flush_buffer( tty );
 
diff -Nru a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
--- a/drivers/usb/serial/empeg.c	Wed Apr 30 22:28:19 2003
+++ b/drivers/usb/serial/empeg.c	Wed Apr 30 22:28:19 2003
@@ -222,8 +222,6 @@
 
 	dbg("%s - port %d", __FUNCTION__, port->number);
 
-	usb_serial_debug_data (__FILE__, __FUNCTION__, count, buf);
-
 	while (count > 0) {
 
 		/* try to find a free urb in our list of them */
@@ -263,6 +261,8 @@
 		} else {
 			memcpy (urb->transfer_buffer, current_position, transfer_size);
 		}
+
+		usb_serial_debug_data (__FILE__, __FUNCTION__, transfer_size, urb->transfer_buffer);
 
 		/* build up our urb */
 		usb_fill_bulk_urb (
diff -Nru a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
--- a/drivers/usb/serial/ftdi_sio.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/usb/serial/ftdi_sio.c	Wed Apr 30 22:28:15 2003
@@ -175,6 +175,8 @@
 static void ftdi_sio_write_bulk_callback (struct urb *urb, struct pt_regs *regs);
 static void ftdi_sio_read_bulk_callback	(struct urb *urb, struct pt_regs *regs);
 static void ftdi_sio_set_termios	(struct usb_serial_port *port, struct termios * old);
+static int  ftdi_sio_tiocmget		(struct usb_serial_port *port, struct file *file);
+static int  ftdi_sio_tiocmset		(struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
 static int  ftdi_sio_ioctl		(struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
 static void ftdi_sio_break_ctl		(struct usb_serial_port *port, int break_state );
 
@@ -198,6 +200,8 @@
 	.ioctl =		ftdi_sio_ioctl,
 	.set_termios =		ftdi_sio_set_termios,
 	.break_ctl =		ftdi_sio_break_ctl,
+	.tiocmget =		ftdi_sio_tiocmget,
+	.tiocmset =		ftdi_sio_tiocmset,
 	.attach =		ftdi_sio_startup,
         .shutdown =             ftdi_sio_shutdown,
 };
@@ -219,6 +223,8 @@
 	.ioctl =		ftdi_sio_ioctl,
 	.set_termios =		ftdi_sio_set_termios,
 	.break_ctl =		ftdi_sio_break_ctl,
+	.tiocmget =		ftdi_sio_tiocmget,
+	.tiocmset =		ftdi_sio_tiocmset,
 	.attach =		ftdi_8U232AM_startup,
         .shutdown =             ftdi_sio_shutdown,
 };
@@ -823,125 +829,100 @@
 	return;
 } /* ftdi_sio_set_termios */
 
-static int ftdi_sio_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
+static int ftdi_sio_tiocmget (struct usb_serial_port *port, struct file *file)
 {
 	struct usb_serial *serial = port->serial;
 	struct ftdi_private *priv = usb_get_serial_port_data(port);
-	__u16 urb_value=0; /* Will hold the new flags */
-	char buf[2];
-	int  ret, mask;
+	char *buf = NULL;
+	int ret = -EINVAL;
+	int size;
 	
-	dbg("%s cmd 0x%04x", __FUNCTION__, cmd);
+	dbg("%s", __FUNCTION__);
 
-	/* Based on code from acm.c and others */
-	switch (cmd) {
+	buf = kmalloc(2, GFP_KERNEL);
+	if (!buf)
+		goto exit;
 
-	case TIOCMGET:
-		dbg("%s TIOCMGET", __FUNCTION__);
-		if (priv->ftdi_type == sio){
-			/* Request the status from the device */
-			if ((ret = usb_control_msg(serial->dev, 
-						   usb_rcvctrlpipe(serial->dev, 0),
-						   FTDI_SIO_GET_MODEM_STATUS_REQUEST, 
-						   FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
-						   0, 0, 
-						   buf, 1, WDR_TIMEOUT)) < 0 ) {
-				err("%s Could not get modem status of device - err: %d", __FUNCTION__,
-				    ret);
-				return(ret);
-			}
-		} else {
-			/* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same 
-			   format as the data returned from the in point */
-			if ((ret = usb_control_msg(serial->dev, 
-						   usb_rcvctrlpipe(serial->dev, 0),
-						   FTDI_SIO_GET_MODEM_STATUS_REQUEST, 
-						   FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
-						   0, 0, 
-						   buf, 2, WDR_TIMEOUT)) < 0 ) {
-				err("%s Could not get modem status of device - err: %d", __FUNCTION__,
-				    ret);
-				return(ret);
-			}
-		}
+	if (priv->ftdi_type == sio) {
+		size = 1;
+	} else {
+		/* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same 
+		   format as the data returned from the in point */
+		size = 2;
+	}
+	ret = usb_control_msg(serial->dev,
+			      usb_rcvctrlpipe(serial->dev, 0),
+			      FTDI_SIO_GET_MODEM_STATUS_REQUEST,
+			      FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
+			      0, 0, buf, size, WDR_TIMEOUT);
+	if (ret < 0) {
+		err("%s Could not get modem status of device - err: %d",
+		    __FUNCTION__, ret);
+		goto exit;
+	}
+
+	ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) |
+		(buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) |
+		(buf[0]  & FTDI_SIO_RI_MASK  ? TIOCM_RI  : 0) |
+		(buf[0]  & FTDI_SIO_RLSD_MASK ? TIOCM_CD  : 0);
+
+exit:
+	kfree(buf);
+	return ret;
+}
 
-		return put_user((buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) |
-				(buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) |
-				(buf[0]  & FTDI_SIO_RI_MASK  ? TIOCM_RI  : 0) |
-				(buf[0]  & FTDI_SIO_RLSD_MASK ? TIOCM_CD  : 0),
-				(unsigned long *) arg);
-		break;
-
-	case TIOCMSET: /* Turns on and off the lines as specified by the mask */
-		dbg("%s TIOCMSET", __FUNCTION__);
-		if (get_user(mask, (unsigned long *) arg))
-			return -EFAULT;
-		urb_value = ((mask & TIOCM_DTR) ? HIGH : LOW);
-		if (set_dtr(serial->dev, usb_sndctrlpipe(serial->dev, 0),urb_value) < 0){
-			err("Error from DTR set urb (TIOCMSET)");
-		}
-		urb_value = ((mask & TIOCM_RTS) ? HIGH : LOW);
-		if (set_rts(serial->dev, usb_sndctrlpipe(serial->dev, 0),urb_value) < 0){
-			err("Error from RTS set urb (TIOCMSET)");
-		}	
-		break;
-					
-	case TIOCMBIS: /* turns on (Sets) the lines as specified by the mask */
-		dbg("%s TIOCMBIS", __FUNCTION__);
- 	        if (get_user(mask, (unsigned long *) arg))
-			return -EFAULT;
-  	        if (mask & TIOCM_DTR){
-			if ((ret = set_dtr(serial->dev, 
-					   usb_sndctrlpipe(serial->dev, 0),
-					   HIGH)) < 0) {
-				err("Urb to set DTR failed");
-				return(ret);
-			}
-		}
-		if (mask & TIOCM_RTS) {
-			if ((ret = set_rts(serial->dev, 
-					   usb_sndctrlpipe(serial->dev, 0),
-					   HIGH)) < 0){
-				err("Urb to set RTS failed");
-				return(ret);
-			}
-		}
-					break;
+static int ftdi_sio_tiocmset (struct usb_serial_port *port, struct file *file,
+			      unsigned int set, unsigned int clear)
+{
+	struct usb_serial *serial = port->serial;
+	int ret = 0;
+	
+	dbg("%s", __FUNCTION__);
 
-	case TIOCMBIC: /* turns off (Clears) the lines as specified by the mask */
-		dbg("%s TIOCMBIC", __FUNCTION__);
- 	        if (get_user(mask, (unsigned long *) arg))
-			return -EFAULT;
-  	        if (mask & TIOCM_DTR){
-			if ((ret = set_dtr(serial->dev, 
-					   usb_sndctrlpipe(serial->dev, 0),
-					   LOW)) < 0){
-				err("Urb to unset DTR failed");
-				return(ret);
-			}
-		}	
-		if (mask & TIOCM_RTS) {
-			if ((ret = set_rts(serial->dev, 
-					   usb_sndctrlpipe(serial->dev, 0),
-					   LOW)) < 0){
-				err("Urb to unset RTS failed");
-				return(ret);
-			}
+	if (set & TIOCM_RTS)
+		if ((ret = set_rts(serial->dev, 
+				   usb_sndctrlpipe(serial->dev, 0),
+				   HIGH)) < 0) {
+			err("Urb to set RTS failed");
+			goto exit;
+		}
+
+	if (set & TIOCM_DTR)
+		if ((ret = set_dtr(serial->dev, 
+				   usb_sndctrlpipe(serial->dev, 0),
+				   HIGH)) < 0) {
+			err("Urb to set DTR failed");
+			goto exit;
+		}
+
+	if (clear & TIOCM_RTS)
+		if ((ret = set_rts(serial->dev, 
+				   usb_sndctrlpipe(serial->dev, 0),
+				   LOW)) < 0) {
+			err("Urb to unset RTS failed");
+			goto exit;
+		}
+
+	if (clear & TIOCM_DTR)
+		if ((ret = set_dtr(serial->dev, 
+				   usb_sndctrlpipe(serial->dev, 0),
+				   LOW)) < 0) {
+			err("Urb to unset DTR failed");
+			goto exit;
 		}
-		break;
 
-		/*
-		 * I had originally implemented TCSET{A,S}{,F,W} and
-		 * TCGET{A,S} here separately, however when testing I
-		 * found that the higher layers actually do the termios
-		 * conversions themselves and pass the call onto
-		 * ftdi_sio_set_termios. 
-		 *
-		 */
+exit:
+	return ret;
+}
 
+static int ftdi_sio_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
+{
+	dbg("%s cmd 0x%04x", __FUNCTION__, cmd);
+
+	switch (cmd) {
 	default:
 	  /* This is not an error - turns out the higher layers will do 
-	   *  some ioctls itself (see comment above)
+	   *  some ioctls itself
  	   */
 		dbg("%s arg not supported - it was 0x%04x", __FUNCTION__,cmd);
 		return(-ENOIOCTLCMD);
diff -Nru a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
--- a/drivers/usb/serial/io_edgeport.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/usb/serial/io_edgeport.c	Wed Apr 30 22:28:04 2003
@@ -455,6 +455,8 @@
 static void edge_set_termios		(struct usb_serial_port *port, struct termios *old_termios);
 static int  edge_ioctl			(struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg);
 static void edge_break			(struct usb_serial_port *port, int break_state);
+static int  edge_tiocmget		(struct usb_serial_port *port, struct file *file);
+static int  edge_tiocmset		(struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
 static int  edge_startup		(struct usb_serial *serial);
 static void edge_shutdown		(struct usb_serial *serial);
 
@@ -1354,6 +1356,7 @@
 	} else {
 		memcpy(&fifo->fifo[fifo->head], data, firsthalf);
 	}  
+	usb_serial_debug_data (__FILE__, __FUNCTION__, firsthalf, &fifo->fifo[fifo->head]);
 
 	// update the index and size
 	fifo->head  += firsthalf;
@@ -1374,16 +1377,13 @@
 		} else {
 			memcpy(&fifo->fifo[fifo->head], &data[firsthalf], secondhalf);
 		}
+		usb_serial_debug_data (__FILE__, __FUNCTION__, secondhalf, &fifo->fifo[fifo->head]);
 		// update the index and size
 		fifo->count += secondhalf;
 		fifo->head  += secondhalf;
 		// No need to check for wrap since we can not get to end of fifo in this part
 	}
 
-	if (copySize) {
-		usb_serial_debug_data (__FILE__, __FUNCTION__, copySize, data);
-	}
-
 	send_more_port_data((struct edgeport_serial *)usb_get_serial_data(port->serial), edge_port);
 
 	dbg("%s wrote %d byte(s) TxCredits %d, Fifo %d", __FUNCTION__, copySize, edge_port->txCredits, fifo->count);
@@ -1762,42 +1762,27 @@
 	return -ENOIOCTLCMD;
 }
 
-static int set_modem_info(struct edgeport_port *edge_port, unsigned int cmd, unsigned int *value)
+static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear)
 {
-	unsigned int mcr = edge_port->shadowMCR;
-	unsigned int arg;
-
-	if (copy_from_user(&arg, value, sizeof(int)))
-		return -EFAULT;
+        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
+	unsigned int mcr;
 
-	switch (cmd) {
-		case TIOCMBIS:
-			if (arg & TIOCM_RTS)
-				mcr |= MCR_RTS;
-			if (arg & TIOCM_DTR)
-				mcr |= MCR_RTS;
-			if (arg & TIOCM_LOOP)
-				mcr |= MCR_LOOPBACK;
-			break;
+	dbg("%s - port %d", __FUNCTION__, port->number);
 
-		case TIOCMBIC:
-			if (arg & TIOCM_RTS)
-				mcr &= ~MCR_RTS;
-			if (arg & TIOCM_DTR)
-				mcr &= ~MCR_RTS;
-			if (arg & TIOCM_LOOP)
-				mcr &= ~MCR_LOOPBACK;
-			break;
-
-		case TIOCMSET:
-			/* turn off the RTS and DTR and LOOPBACK 
-			 * and then only turn on what was asked to */
-			mcr &=  ~(MCR_RTS | MCR_DTR | MCR_LOOPBACK);
-			mcr |= ((arg & TIOCM_RTS) ? MCR_RTS : 0);
-			mcr |= ((arg & TIOCM_DTR) ? MCR_DTR : 0);
-			mcr |= ((arg & TIOCM_LOOP) ? MCR_LOOPBACK : 0);
-			break;
-	}
+	mcr = edge_port->shadowMCR;
+	if (set & TIOCM_RTS)
+		mcr |= MCR_RTS;
+	if (set & TIOCM_DTR)
+		mcr |= MCR_DTR;
+	if (set & TIOCM_LOOP)
+		mcr |= MCR_LOOPBACK;
+
+	if (clear & TIOCM_RTS)
+		mcr &= ~MCR_RTS;
+	if (clear & TIOCM_DTR)
+		mcr &= ~MCR_DTR;
+	if (clear & TIOCM_LOOP)
+		mcr &= ~MCR_LOOPBACK;
 
 	edge_port->shadowMCR = mcr;
 
@@ -1806,12 +1791,17 @@
 	return 0;
 }
 
-static int get_modem_info(struct edgeport_port *edge_port, unsigned int *value)
+static int edge_tiocmget(struct usb_serial_port *port, struct file *file)
 {
+        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
 	unsigned int result = 0;
-	unsigned int msr = edge_port->shadowMSR;
-	unsigned int mcr = edge_port->shadowMCR;
+	unsigned int msr;
+	unsigned int mcr;
 
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	msr = edge_port->shadowMSR;
+	mcr = edge_port->shadowMCR;
 	result = ((mcr & MCR_DTR)	? TIOCM_DTR: 0)	  /* 0x002 */
 		  | ((mcr & MCR_RTS)	? TIOCM_RTS: 0)   /* 0x004 */
 		  | ((msr & MSR_CTS)	? TIOCM_CTS: 0)   /* 0x020 */
@@ -1822,13 +1812,9 @@
 
 	dbg("%s -- %x", __FUNCTION__, result);
 
-	if (copy_to_user(value, &result, sizeof(int)))
-		return -EFAULT;
-	return 0;
+	return result;
 }
 
-
-
 static int get_serial_info(struct edgeport_port *edge_port, struct serial_struct * retinfo)
 {
 	struct serial_struct tmp;
@@ -1884,16 +1870,6 @@
 			dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__,  port->number);
 			return get_lsr_info(edge_port, (unsigned int *) arg);
 			return 0;
-
-		case TIOCMBIS:
-		case TIOCMBIC:
-		case TIOCMSET:
-			dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__,  port->number);
-			return set_modem_info(edge_port, cmd, (unsigned int *) arg);
-
-		case TIOCMGET:  
-			dbg("%s (%d) TIOCMGET", __FUNCTION__,  port->number);
-			return get_modem_info(edge_port, (unsigned int *) arg);
 
 		case TIOCGSERIAL:
 			dbg("%s (%d) TIOCGSERIAL", __FUNCTION__,  port->number);
diff -Nru a/drivers/usb/serial/io_tables.h b/drivers/usb/serial/io_tables.h
--- a/drivers/usb/serial/io_tables.h	Wed Apr 30 22:28:11 2003
+++ b/drivers/usb/serial/io_tables.h	Wed Apr 30 22:28:11 2003
@@ -114,6 +114,8 @@
 	.shutdown		= edge_shutdown,
 	.ioctl			= edge_ioctl,
 	.set_termios		= edge_set_termios,
+	.tiocmget		= edge_tiocmget,
+	.tiocmset		= edge_tiocmset,
 	.write			= edge_write,
 	.write_room		= edge_write_room,
 	.chars_in_buffer	= edge_chars_in_buffer,
@@ -137,6 +139,8 @@
 	.shutdown		= edge_shutdown,
 	.ioctl			= edge_ioctl,
 	.set_termios		= edge_set_termios,
+	.tiocmget		= edge_tiocmget,
+	.tiocmset		= edge_tiocmset,
 	.write			= edge_write,
 	.write_room		= edge_write_room,
 	.chars_in_buffer	= edge_chars_in_buffer,
@@ -160,6 +164,8 @@
 	.shutdown		= edge_shutdown,
 	.ioctl			= edge_ioctl,
 	.set_termios		= edge_set_termios,
+	.tiocmget		= edge_tiocmget,
+	.tiocmset		= edge_tiocmset,
 	.write			= edge_write,
 	.write_room		= edge_write_room,
 	.chars_in_buffer	= edge_chars_in_buffer,
@@ -183,6 +189,8 @@
 	.shutdown		= edge_shutdown,
 	.ioctl			= edge_ioctl,
 	.set_termios		= edge_set_termios,
+	.tiocmget		= edge_tiocmget,
+	.tiocmset		= edge_tiocmset,
 	.write			= edge_write,
 	.write_room		= edge_write_room,
 	.chars_in_buffer	= edge_chars_in_buffer,
diff -Nru a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
--- a/drivers/usb/serial/io_ti.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/usb/serial/io_ti.c	Wed Apr 30 22:28:18 2003
@@ -2403,42 +2403,27 @@
 	return;
 }
 
-static int set_modem_info (struct edgeport_port *edge_port, unsigned int cmd, unsigned int *value)
+static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear)
 {
-	unsigned int mcr = edge_port->shadow_mcr;
-	unsigned int arg;
+        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
+	unsigned int mcr;
 
-	if (copy_from_user(&arg, value, sizeof(int)))
-		return -EFAULT;
-
-	switch (cmd) {
-		case TIOCMBIS:
-			if (arg & TIOCM_RTS)
-				mcr |= MCR_RTS;
-			if (arg & TIOCM_DTR)
-				mcr |= MCR_RTS;
-			if (arg & TIOCM_LOOP)
-				mcr |= MCR_LOOPBACK;
-			break;
+	dbg("%s - port %d", __FUNCTION__, port->number);
 
-		case TIOCMBIC:
-			if (arg & TIOCM_RTS)
-				mcr &= ~MCR_RTS;
-			if (arg & TIOCM_DTR)
-				mcr &= ~MCR_RTS;
-			if (arg & TIOCM_LOOP)
-				mcr &= ~MCR_LOOPBACK;
-			break;
-
-		case TIOCMSET:
-			/* turn off the RTS and DTR and LOOPBACK 
-			 * and then only turn on what was asked to */
-			mcr &=  ~(MCR_RTS | MCR_DTR | MCR_LOOPBACK);
-			mcr |= ((arg & TIOCM_RTS) ? MCR_RTS : 0);
-			mcr |= ((arg & TIOCM_DTR) ? MCR_DTR : 0);
-			mcr |= ((arg & TIOCM_LOOP) ? MCR_LOOPBACK : 0);
-			break;
-	}
+	mcr = edge_port->shadow_mcr;
+	if (set & TIOCM_RTS)
+		mcr |= MCR_RTS;
+	if (set & TIOCM_DTR)
+		mcr |= MCR_DTR;
+	if (set & TIOCM_LOOP)
+		mcr |= MCR_LOOPBACK;
+
+	if (clear & TIOCM_RTS)
+		mcr &= ~MCR_RTS;
+	if (clear & TIOCM_DTR)
+		mcr &= ~MCR_DTR;
+	if (clear & TIOCM_LOOP)
+		mcr &= ~MCR_LOOPBACK;
 
 	edge_port->shadow_mcr = mcr;
 
@@ -2447,12 +2432,17 @@
 	return 0;
 }
 
-static int get_modem_info (struct edgeport_port *edge_port, unsigned int *value)
+static int edge_tiocmget(struct usb_serial_port *port, struct file *file)
 {
+        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
 	unsigned int result = 0;
-	unsigned int msr = edge_port->shadow_msr;
-	unsigned int mcr = edge_port->shadow_mcr;
+	unsigned int msr;
+	unsigned int mcr;
 
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	msr = edge_port->shadow_msr;
+	mcr = edge_port->shadow_mcr;
 	result = ((mcr & MCR_DTR)	? TIOCM_DTR: 0)	  /* 0x002 */
 		  | ((mcr & MCR_RTS)	? TIOCM_RTS: 0)   /* 0x004 */
 		  | ((msr & MSR_CTS)	? TIOCM_CTS: 0)   /* 0x020 */
@@ -2463,9 +2453,7 @@
 
 	dbg("%s -- %x", __FUNCTION__, result);
 
-	if (copy_to_user(value, &result, sizeof(int)))
-		return -EFAULT;
-	return 0;
+	return result;
 }
 
 static int get_serial_info (struct edgeport_port *edge_port, struct serial_struct * retinfo)
@@ -2515,18 +2503,6 @@
 //			return get_lsr_info(edge_port, (unsigned int *) arg);
 			break;
 
-		case TIOCMBIS:
-		case TIOCMBIC:
-		case TIOCMSET:
-			dbg("%s - (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__, port->number);
-			return set_modem_info(edge_port, cmd, (unsigned int *) arg);
-			break;
-
-		case TIOCMGET:  
-			dbg("%s - (%d) TIOCMGET", __FUNCTION__, port->number);
-			return get_modem_info(edge_port, (unsigned int *) arg);
-			break;
-
 		case TIOCGSERIAL:
 			dbg("%s - (%d) TIOCGSERIAL", __FUNCTION__, port->number);
 			return get_serial_info(edge_port, (struct serial_struct *) arg);
@@ -2665,6 +2641,8 @@
 	.shutdown		= edge_shutdown,
 	.ioctl			= edge_ioctl,
 	.set_termios		= edge_set_termios,
+	.tiocmget		= edge_tiocmget,
+	.tiocmset		= edge_tiocmset,
 	.write			= edge_write,
 	.write_room		= edge_write_room,
 	.chars_in_buffer	= edge_chars_in_buffer,
@@ -2688,6 +2666,8 @@
 	.shutdown		= edge_shutdown,
 	.ioctl			= edge_ioctl,
 	.set_termios		= edge_set_termios,
+	.tiocmget		= edge_tiocmget,
+	.tiocmset		= edge_tiocmset,
 	.write			= edge_write,
 	.write_room		= edge_write_room,
 	.chars_in_buffer	= edge_chars_in_buffer,
diff -Nru a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
--- a/drivers/usb/serial/ipaq.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/usb/serial/ipaq.c	Wed Apr 30 22:28:15 2003
@@ -370,8 +370,6 @@
 
 	dbg("%s - port %d", __FUNCTION__, port->number);
 
-	usb_serial_debug_data(__FILE__, __FUNCTION__, count, buf);
-	
 	while (count > 0) {
 		transfer_size = min(count, PACKET_SIZE);
 		if (ipaq_write_bulk(port, from_user, current_position, transfer_size)) {
diff -Nru a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
--- a/drivers/usb/serial/keyspan.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/usb/serial/keyspan.c	Wed Apr 30 22:28:04 2003
@@ -282,48 +282,46 @@
 	keyspan_send_setup(port, 0);
 }
 
-static int keyspan_ioctl(struct usb_serial_port *port, struct file *file,
-			     unsigned int cmd, unsigned long arg)
+static int keyspan_tiocmget(struct usb_serial_port *port, struct file *file)
 {
-	unsigned int			value, set;
+	unsigned int			value;
 	struct keyspan_port_private 	*p_priv;
 
 	p_priv = usb_get_serial_port_data(port);
 	
-	switch (cmd) {
-	case TIOCMGET:
-		value = ((p_priv->rts_state) ? TIOCM_RTS : 0) |
-			((p_priv->dtr_state) ? TIOCM_DTR : 0) |
-			((p_priv->cts_state) ? TIOCM_CTS : 0) |
-			((p_priv->dsr_state) ? TIOCM_DSR : 0) |
-			((p_priv->dcd_state) ? TIOCM_CAR : 0) |
-			((p_priv->ri_state) ? TIOCM_RNG : 0); 
-
-		if (put_user(value, (unsigned int *) arg))
-			return -EFAULT;
-		return 0;
+	value = ((p_priv->rts_state) ? TIOCM_RTS : 0) |
+		((p_priv->dtr_state) ? TIOCM_DTR : 0) |
+		((p_priv->cts_state) ? TIOCM_CTS : 0) |
+		((p_priv->dsr_state) ? TIOCM_DSR : 0) |
+		((p_priv->dcd_state) ? TIOCM_CAR : 0) |
+		((p_priv->ri_state) ? TIOCM_RNG : 0); 
+
+	return value;
+}
+
+static int keyspan_tiocmset(struct usb_serial_port *port, struct file *file,
+			    unsigned int set, unsigned int clear)
+{
+	struct keyspan_port_private 	*p_priv;
+
+	p_priv = usb_get_serial_port_data(port);
 	
-	case TIOCMSET:
-		if (get_user(value, (unsigned int *) arg))
-			return -EFAULT;
-		p_priv->rts_state = ((value & TIOCM_RTS) ? 1 : 0);
-		p_priv->dtr_state = ((value & TIOCM_DTR) ? 1 : 0);
-		keyspan_send_setup(port, 0);
-		return 0;
-
-	case TIOCMBIS:
-	case TIOCMBIC:
-		if (get_user(value, (unsigned int *) arg))
-			return -EFAULT;
-		set = (cmd == TIOCMBIS);
-		if (value & TIOCM_RTS)
-			p_priv->rts_state = set;
-		if (value & TIOCM_DTR)
-			p_priv->dtr_state = set;
-		keyspan_send_setup(port, 0);
-		return 0;
-	}
+	if (set & TIOCM_RTS)
+		p_priv->rts_state = 1;
+	if (set & TIOCM_DTR)
+		p_priv->dtr_state = 1;
+
+	if (clear & TIOCM_RTS)
+		p_priv->rts_state = 0;
+	if (clear & TIOCM_DTR)
+		p_priv->dtr_state = 0;
+	keyspan_send_setup(port, 0);
+	return 0;
+}
 
+static int keyspan_ioctl(struct usb_serial_port *port, struct file *file,
+			     unsigned int cmd, unsigned long arg)
+{
 	return -ENOIOCTLCMD;
 }
 
@@ -342,8 +340,8 @@
 	p_priv = usb_get_serial_port_data(port);
 	d_details = p_priv->device_details;
 
-	dbg("%s - for port %d (%d chars [%x]), flip=%d",
-	    __FUNCTION__, port->number, count, buf[0], p_priv->out_flip);
+	dbg("%s - for port %d (%d chars), flip=%d",
+	    __FUNCTION__, port->number, count, p_priv->out_flip);
 
 	for (left = count; left > 0; left -= todo) {
 		todo = left;
diff -Nru a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h
--- a/drivers/usb/serial/keyspan.h	Wed Apr 30 22:28:12 2003
+++ b/drivers/usb/serial/keyspan.h	Wed Apr 30 22:28:12 2003
@@ -63,6 +63,11 @@
 					 struct termios *old);
 static void keyspan_break_ctl		(struct usb_serial_port *port,
 					 int break_state);
+static int  keyspan_tiocmget		(struct usb_serial_port *port,
+					 struct file *file);
+static int  keyspan_tiocmset		(struct usb_serial_port *port,
+					 struct file *file, unsigned int set,
+					 unsigned int clear);
 static int  keyspan_fake_startup	(struct usb_serial *serial);
 
 static int  keyspan_usa19_calc_baud	(u32 baud_rate, u32 baudclk, 
@@ -551,6 +556,8 @@
 	.ioctl			= keyspan_ioctl,
 	.set_termios		= keyspan_set_termios,
 	.break_ctl		= keyspan_break_ctl,
+	.tiocmget		= keyspan_tiocmget,
+	.tiocmset		= keyspan_tiocmset,
 	.attach			= keyspan_startup,
 	.shutdown		= keyspan_shutdown,
 };
@@ -574,6 +581,8 @@
 	.ioctl			= keyspan_ioctl,
 	.set_termios		= keyspan_set_termios,
 	.break_ctl		= keyspan_break_ctl,
+	.tiocmget		= keyspan_tiocmget,
+	.tiocmset		= keyspan_tiocmset,
 	.attach			= keyspan_startup,
 	.shutdown		= keyspan_shutdown,
 };
@@ -597,6 +606,8 @@
 	.ioctl			= keyspan_ioctl,
 	.set_termios		= keyspan_set_termios,
 	.break_ctl		= keyspan_break_ctl,
+	.tiocmget		= keyspan_tiocmget,
+	.tiocmset		= keyspan_tiocmset,
 	.attach			= keyspan_startup,
 	.shutdown		= keyspan_shutdown,
 };
diff -Nru a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
--- a/drivers/usb/serial/keyspan_pda.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/usb/serial/keyspan_pda.c	Wed Apr 30 22:28:11 2003
@@ -457,62 +457,54 @@
 	return rc;
 }
 
+static int keyspan_pda_tiocmget(struct usb_serial_port *port, struct file *file)
+{
+	struct usb_serial *serial = port->serial;
+	int rc;
+	unsigned char status;
+	int value;
 
-static int keyspan_pda_ioctl(struct usb_serial_port *port, struct file *file,
-			     unsigned int cmd, unsigned long arg)
+	rc = keyspan_pda_get_modem_info(serial, &status);
+	if (rc < 0)
+		return rc;
+	value =
+		((status & (1<<7)) ? TIOCM_DTR : 0) |
+		((status & (1<<6)) ? TIOCM_CAR : 0) |
+		((status & (1<<5)) ? TIOCM_RNG : 0) |
+		((status & (1<<4)) ? TIOCM_DSR : 0) |
+		((status & (1<<3)) ? TIOCM_CTS : 0) |
+		((status & (1<<2)) ? TIOCM_RTS : 0);
+	return value;
+}
+
+static int keyspan_pda_tiocmset(struct usb_serial_port *port, struct file *file,
+				unsigned int set, unsigned int clear)
 {
 	struct usb_serial *serial = port->serial;
 	int rc;
-	unsigned int value;
-	unsigned char status, mask;
+	unsigned char status;
 
+	rc = keyspan_pda_get_modem_info(serial, &status);
+	if (rc < 0)
+		return rc;
+
+	if (set & TIOCM_RTS)
+		status |= (1<<2);
+	if (set & TIOCM_DTR)
+		status |= (1<<7);
+
+	if (clear & TIOCM_RTS)
+		status &= ~(1<<2);
+	if (clear & TIOCM_DTR)
+		status &= ~(1<<7);
+	rc = keyspan_pda_set_modem_info(serial, status);
+	return rc;
+}
+
+static int keyspan_pda_ioctl(struct usb_serial_port *port, struct file *file,
+			     unsigned int cmd, unsigned long arg)
+{
 	switch (cmd) {
-	case TIOCMGET: /* get modem pins state */
-		rc = keyspan_pda_get_modem_info(serial, &status);
-		if (rc < 0)
-			return rc;
-		value =
-			((status & (1<<7)) ? TIOCM_DTR : 0) |
-			((status & (1<<6)) ? TIOCM_CAR : 0) |
-			((status & (1<<5)) ? TIOCM_RNG : 0) |
-			((status & (1<<4)) ? TIOCM_DSR : 0) |
-			((status & (1<<3)) ? TIOCM_CTS : 0) |
-			((status & (1<<2)) ? TIOCM_RTS : 0);
-		if (copy_to_user((unsigned int *)arg, &value, sizeof(int)))
-			return -EFAULT;
-		return 0;
-	case TIOCMSET: /* set a state as returned by MGET */
-		if (copy_from_user(&value, (unsigned int *)arg, sizeof(int)))
-			return -EFAULT;
-		status =
-			((value & TIOCM_DTR) ? (1<<7) : 0) |
-			((value & TIOCM_CAR) ? (1<<6) : 0) |
-			((value & TIOCM_RNG) ? (1<<5) : 0) |
-			((value & TIOCM_DSR) ? (1<<4) : 0) |
-			((value & TIOCM_CTS) ? (1<<3) : 0) |
-			((value & TIOCM_RTS) ? (1<<2) : 0);
-		rc = keyspan_pda_set_modem_info(serial, status);
-		if (rc < 0)
-			return rc;
-		return 0;
-	case TIOCMBIS: /* set bits in bitmask <arg> */
-	case TIOCMBIC: /* clear bits from bitmask <arg> */
-		if (copy_from_user(&value, (unsigned int *)arg, sizeof(int)))
-			return -EFAULT;
-		rc = keyspan_pda_get_modem_info(serial, &status);
-		if (rc < 0)
-			return rc;
-		mask =
-			((value & TIOCM_RTS) ? (1<<2) : 0) |
-			((value & TIOCM_DTR) ? (1<<7) : 0);
-		if (cmd == TIOCMBIS)
-			status |= mask;
-		else
-			status &= ~mask;
-		rc = keyspan_pda_set_modem_info(serial, status);
-		if (rc < 0)
-			return rc;
-		return 0;
 	case TIOCMIWAIT:
 		/* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
 		/* TODO */
@@ -874,6 +866,8 @@
 	.ioctl =		keyspan_pda_ioctl,
 	.set_termios =		keyspan_pda_set_termios,
 	.break_ctl =		keyspan_pda_break_ctl,
+	.tiocmget =		keyspan_pda_tiocmget,
+	.tiocmset =		keyspan_pda_tiocmset,
 	.attach =		keyspan_pda_startup,
 	.shutdown =		keyspan_pda_shutdown,
 };
diff -Nru a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
--- a/drivers/usb/serial/kl5kusb105.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/usb/serial/kl5kusb105.c	Wed Apr 30 22:28:10 2003
@@ -105,6 +105,11 @@
 static void klsi_105_break_ctl	         (struct usb_serial_port *port,
 					  int break_state );
  */
+static int  klsi_105_tiocmget	         (struct usb_serial_port *port,
+					  struct file *file);
+static int  klsi_105_tiocmset	         (struct usb_serial_port *port,
+					  struct file *file, unsigned int set,
+					  unsigned int clear);
 
 /*
  * All of the device info needed for the KLSI converters.
@@ -143,6 +148,8 @@
 	.ioctl =	     klsi_105_ioctl,
 	.set_termios =	     klsi_105_set_termios,
 	/*.break_ctl =	     klsi_105_break_ctl,*/
+	.tiocmget =          klsi_105_tiocmget,
+	.tiocmset =          klsi_105_tiocmset,
 	.attach =	     klsi_105_startup,
 	.shutdown =	     klsi_105_shutdown,
 	.throttle =	     klsi_105_throttle,
@@ -879,68 +886,67 @@
 } /* mct_u232_break_ctl */
 #endif
 
-static int klsi_105_ioctl (struct usb_serial_port *port, struct file * file,
-			   unsigned int cmd, unsigned long arg)
+static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file)
 {
 	struct usb_serial *serial = port->serial;
 	struct klsi_105_private *priv = usb_get_serial_port_data(port);
-	int mask;
 	unsigned long flags;
+	int rc;
+	unsigned long line_state;
+	dbg("%s - request, just guessing", __FUNCTION__);
+
+	rc = klsi_105_get_line_state(serial, &line_state);
+	if (rc < 0) {
+		err("Reading line control failed (error = %d)", rc);
+		/* better return value? EAGAIN? */
+		return rc;
+	}
+
+	spin_lock_irqsave (&priv->lock, flags);
+	priv->line_state = line_state;
+	spin_unlock_irqrestore (&priv->lock, flags);
+	dbg("%s - read line state 0x%lx", __FUNCTION__, line_state);
+	return (int)line_state;
+}
+
+static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file,
+			      unsigned int set, unsigned int clear)
+{
+	int retval = -EINVAL;
+	
+	dbg("%s", __FUNCTION__);
+
+/* if this ever gets implemented, it should be done something like this:
+	struct usb_serial *serial = port->serial;
+	struct klsi_105_private *priv = usb_get_serial_port_data(port);
+	unsigned long flags;
+	int control;
+
+	spin_lock_irqsave (&priv->lock, flags);
+	if (set & TIOCM_RTS)
+		priv->control_state |= TIOCM_RTS;
+	if (set & TIOCM_DTR)
+		priv->control_state |= TIOCM_DTR;
+	if (clear & TIOCM_RTS)
+		priv->control_state &= ~TIOCM_RTS;
+	if (clear & TIOCM_DTR)
+		priv->control_state &= ~TIOCM_DTR;
+	control = priv->control_state;
+	spin_unlock_irqrestore (&priv->lock, flags);
+	retval = mct_u232_set_modem_ctrl(serial, control);
+*/
+	return retval;
+}
+					
+static int klsi_105_ioctl (struct usb_serial_port *port, struct file * file,
+			   unsigned int cmd, unsigned long arg)
+{
+	struct klsi_105_private *priv = usb_get_serial_port_data(port);
 	
 	dbg("%scmd=0x%x", __FUNCTION__, cmd);
 
 	/* Based on code from acm.c and others */
 	switch (cmd) {
-	case TIOCMGET: {
-		int rc;
-		unsigned long line_state;
-		dbg("%s - TIOCMGET request, just guessing", __FUNCTION__);
-
-		rc = klsi_105_get_line_state(serial, &line_state);
-		if (rc < 0) {
-			err("Reading line control failed (error = %d)", rc);
-			/* better return value? EAGAIN? */
-			return -ENOIOCTLCMD;
-		}
-		spin_lock_irqsave (&priv->lock, flags);
-		priv->line_state = line_state;
-		spin_unlock_irqrestore (&priv->lock, flags);
-		dbg("%s - read line state 0x%lx", __FUNCTION__, line_state);
-		return put_user(line_state, (unsigned long *) arg); 
-	       };
-
-	case TIOCMSET: /* Turns on and off the lines as specified by the mask */
-	case TIOCMBIS: /* turns on (Sets) the lines as specified by the mask */
-	case TIOCMBIC: /* turns off (Clears) the lines as specified by the mask */
-		if (get_user(mask, (unsigned long *) arg))
-			return -EFAULT;
-
-		if ((cmd == TIOCMSET) || (mask & TIOCM_RTS)) {
-			/* RTS needs set */
-			if( ((cmd == TIOCMSET) && (mask & TIOCM_RTS)) ||
-			    (cmd == TIOCMBIS) )
-				dbg("%s - set RTS not handled", __FUNCTION__);
-				/* priv->control_state |=  TIOCM_RTS; */
-			else
-				dbg("%s - clear RTS not handled", __FUNCTION__);
-				/* priv->control_state &= ~TIOCM_RTS; */
-		}
-
-		if ((cmd == TIOCMSET) || (mask & TIOCM_DTR)) {
-			/* DTR needs set */
-			if( ((cmd == TIOCMSET) && (mask & TIOCM_DTR)) ||
-			    (cmd == TIOCMBIS) )
-				dbg("%s - set DTR not handled", __FUNCTION__);
-			/*	priv->control_state |=  TIOCM_DTR; */
-			else
-				dbg("%s - clear DTR not handled", __FUNCTION__);
-				/* priv->control_state &= ~TIOCM_DTR; */
-		}
-		/*
-		mct_u232_set_modem_ctrl(serial, priv->control_state);
-		*/
-		break;
-					
 	case TIOCMIWAIT:
 		/* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
 		/* TODO */
diff -Nru a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
--- a/drivers/usb/serial/kobil_sct.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/usb/serial/kobil_sct.c	Wed Apr 30 22:28:16 2003
@@ -81,6 +81,9 @@
 static int  kobil_write_room(struct usb_serial_port *port);
 static int  kobil_ioctl(struct usb_serial_port *port, struct file *file,
 			unsigned int cmd, unsigned long arg);
+static int  kobil_tiocmget(struct usb_serial_port *port, struct file *file);
+static int  kobil_tiocmset(struct usb_serial_port *port, struct file *file,
+			   unsigned int set, unsigned int clear);
 static void kobil_read_int_callback( struct urb *urb, struct pt_regs *regs );
 static void kobil_write_callback( struct urb *purb, struct pt_regs *regs );
 
@@ -106,6 +109,8 @@
 	.attach =		kobil_startup,
 	.shutdown =		kobil_shutdown,
 	.ioctl =		kobil_ioctl,
+	.tiocmget =		kobil_tiocmget,
+	.tiocmset =		kobil_tiocmset,
 	.open =			kobil_open,
 	.close =		kobil_close,
 	.write =		kobil_write,
@@ -490,11 +495,120 @@
 }
 
 
+static int kobil_tiocmget(struct usb_serial_port *port, struct file *file)
+{
+	struct kobil_private * priv;
+	int result;
+	unsigned char *transfer_buffer;
+	int transfer_buffer_length = 8;
+
+	priv = usb_get_serial_port_data(port);
+	if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) {
+		// This device doesn't support ioctl calls
+		return -EINVAL;
+	}
+
+	// allocate memory for transfer buffer
+	transfer_buffer = (unsigned char *) kmalloc(transfer_buffer_length, GFP_KERNEL);  
+	if (!transfer_buffer) {
+		return -ENOMEM;
+	}
+	memset(transfer_buffer, 0, transfer_buffer_length);
+
+	result = usb_control_msg( port->serial->dev, 
+				  usb_rcvctrlpipe(port->serial->dev, 0 ), 
+				  SUSBCRequest_GetStatusLineState,
+				  USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN,
+				  0,
+				  0,
+				  transfer_buffer,
+				  transfer_buffer_length,
+				  KOBIL_TIMEOUT);
+
+	dbg("%s - port %d Send get_status_line_state URB returns: %i. Statusline: %02x", 
+	    __FUNCTION__, port->number, result, transfer_buffer[0]);
+
+	if ((transfer_buffer[0] & SUSBCR_GSL_DSR) != 0) {
+		priv->line_state |= TIOCM_DSR;
+	} else {
+		priv->line_state &= ~TIOCM_DSR; 
+	}
+
+	kfree(transfer_buffer);
+	return priv->line_state;
+}
+
+static int  kobil_tiocmset(struct usb_serial_port *port, struct file *file,
+			   unsigned int set, unsigned int clear)
+{
+	struct kobil_private * priv;
+	int result;
+	int dtr = 0;
+	int rts = 0;
+	unsigned char *transfer_buffer;
+	int transfer_buffer_length = 8;
+
+	priv = usb_get_serial_port_data(port);
+	if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) {
+		// This device doesn't support ioctl calls
+		return -EINVAL;
+	}
+
+	// allocate memory for transfer buffer
+	transfer_buffer = (unsigned char *) kmalloc(transfer_buffer_length, GFP_KERNEL);
+	if (! transfer_buffer) {
+		return -ENOMEM;
+	}
+	memset(transfer_buffer, 0, transfer_buffer_length);
+
+	if (set & TIOCM_RTS)
+		rts = 1;
+	if (set & TIOCM_DTR)
+		dtr = 1;
+	if (clear & TIOCM_RTS)
+		rts = 0;
+	if (clear & TIOCM_DTR)
+		dtr = 0;
+
+	if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) {
+		if (dtr != 0)
+			dbg("%s - port %d Setting DTR", __FUNCTION__, port->number);
+		else
+			dbg("%s - port %d Clearing DTR", __FUNCTION__, port->number);
+		result = usb_control_msg( port->serial->dev, 
+					  usb_rcvctrlpipe(port->serial->dev, 0 ), 
+					  SUSBCRequest_SetStatusLinesOrQueues,
+					  USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
+					  ((dtr != 0) ? SUSBCR_SSL_SETDTR : SUSBCR_SSL_CLRDTR),
+					  0,
+					  transfer_buffer,
+					  0,
+					  KOBIL_TIMEOUT);
+	} else {
+		if (rts != 0)
+			dbg("%s - port %d Setting RTS", __FUNCTION__, port->number);
+		else
+			dbg("%s - port %d Clearing RTS", __FUNCTION__, port->number);
+		result = usb_control_msg( port->serial->dev, 
+					  usb_rcvctrlpipe(port->serial->dev, 0 ), 
+					  SUSBCRequest_SetStatusLinesOrQueues,
+					  USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
+					  ((rts != 0) ? SUSBCR_SSL_SETRTS : SUSBCR_SSL_CLRRTS),
+					  0,
+					  transfer_buffer,
+					  0,
+					  KOBIL_TIMEOUT);
+	}
+	dbg("%s - port %d Send set_status_line URB returns: %i", __FUNCTION__, port->number, result);
+	kfree(transfer_buffer);
+	return (result < 0) ? result : 0;
+}
+
+
 static int  kobil_ioctl(struct usb_serial_port *port, struct file *file,
 			unsigned int cmd, unsigned long arg)
 {
 	struct kobil_private * priv;
-	int mask;
 	int result;
 	unsigned short urb_val = 0;
 	unsigned char *transfer_buffer;
@@ -605,90 +719,8 @@
 		kfree(transfer_buffer);
 		return ((result < 0) ? -EFAULT : 0);
 
-	case TIOCMGET: // 0x5415
-		// allocate memory for transfer buffer
-		transfer_buffer = (unsigned char *) kmalloc(transfer_buffer_length, GFP_KERNEL);  
-		if (! transfer_buffer) {
-			return -ENOBUFS;
-		} else {
-			memset(transfer_buffer, 0, transfer_buffer_length);
-		}
-
-		result = usb_control_msg( port->serial->dev, 
-					  usb_rcvctrlpipe(port->serial->dev, 0 ), 
-					  SUSBCRequest_GetStatusLineState,
-					  USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN,
-					  0,
-					  0,
-					  transfer_buffer,
-					  transfer_buffer_length,
-					  KOBIL_TIMEOUT
-			);
-
-		dbg("%s - port %d Send get_status_line_state (TIOCMGET) URB returns: %i. Statusline: %02x", 
-		    __FUNCTION__, port->number, result, transfer_buffer[0]);
-
-		if ((transfer_buffer[0] & SUSBCR_GSL_DSR) != 0) {
-			priv->line_state |= TIOCM_DSR;
-		} else {
-			priv->line_state &= ~TIOCM_DSR; 
-		}
-
-		kfree(transfer_buffer);
-		return put_user(priv->line_state, (unsigned long *) arg);
-
-	case TIOCMSET: // 0x5418
-		if (get_user(mask, (unsigned long *) arg)){
-			return -EFAULT;
-		}
-		// allocate memory for transfer buffer
-		transfer_buffer = (unsigned char *) kmalloc(transfer_buffer_length, GFP_KERNEL);
-		if (! transfer_buffer) {
-			return -ENOBUFS;
-		} else {
-			memset(transfer_buffer, 0, transfer_buffer_length);
-		}
-
-		if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) {
-			if ((mask & TIOCM_DTR) != 0){
-				dbg("%s - port %d Setting DTR", __FUNCTION__, port->number);
-			} else {
-				dbg("%s - port %d Clearing DTR", __FUNCTION__, port->number);
-			} 
-			result = usb_control_msg( port->serial->dev, 
-						  usb_rcvctrlpipe(port->serial->dev, 0 ), 
-						  SUSBCRequest_SetStatusLinesOrQueues,
-						  USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
-						  ( ((mask & TIOCM_DTR) != 0) ? SUSBCR_SSL_SETDTR : SUSBCR_SSL_CLRDTR),
-						  0,
-						  transfer_buffer,
-						  0,
-						  KOBIL_TIMEOUT
-				);
-			
-		} else {
-			if ((mask & TIOCM_RTS) != 0){
-				dbg("%s - port %d Setting RTS", __FUNCTION__, port->number);
-			} else {
-				dbg("%s - port %d Clearing RTS", __FUNCTION__, port->number);
-			}
-			result = usb_control_msg( port->serial->dev, 
-						  usb_rcvctrlpipe(port->serial->dev, 0 ), 
-						  SUSBCRequest_SetStatusLinesOrQueues,
-						  USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
-						  (((mask & TIOCM_RTS) != 0) ? SUSBCR_SSL_SETRTS : SUSBCR_SSL_CLRRTS),
-						  0,
-						  transfer_buffer,
-						  0,
-						  KOBIL_TIMEOUT
-				);
-		}
-		dbg("%s - port %d Send set_status_line (TIOCMSET) URB returns: %i", __FUNCTION__, port->number, result);
-
-		kfree(transfer_buffer);
-		return ((result < 0) ? -EFAULT : 0);
 	}
-	return 0;
+	return -ENOIOCTLCMD;
 }
 
 
diff -Nru a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
--- a/drivers/usb/serial/mct_u232.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/usb/serial/mct_u232.c	Wed Apr 30 22:28:11 2003
@@ -125,7 +125,11 @@
 					  unsigned long arg);
 static void mct_u232_break_ctl	         (struct usb_serial_port *port,
 					  int break_state );
-
+static int  mct_u232_tiocmget		 (struct usb_serial_port *port,
+					  struct file *file);
+static int  mct_u232_tiocmset		 (struct usb_serial_port *port,
+					  struct file *file, unsigned int set,
+					  unsigned int clear);
 /*
  * All of the device info needed for the MCT USB-RS232 converter.
  */
@@ -165,6 +169,8 @@
 	.ioctl =	     mct_u232_ioctl,
 	.set_termios =	     mct_u232_set_termios,
 	.break_ctl =	     mct_u232_break_ctl,
+	.tiocmget =	     mct_u232_tiocmget,
+	.tiocmset =	     mct_u232_tiocmset,
 	.attach =	     mct_u232_startup,
 	.shutdown =	     mct_u232_shutdown,
 };
@@ -773,57 +779,55 @@
 } /* mct_u232_break_ctl */
 
 
-static int mct_u232_ioctl (struct usb_serial_port *port, struct file * file,
-			   unsigned int cmd, unsigned long arg)
+static int mct_u232_tiocmget (struct usb_serial_port *port, struct file *file)
+{
+	struct mct_u232_private *priv = usb_get_serial_port_data(port);
+	unsigned long control_state;
+	unsigned long flags;
+	
+	dbg("%s", __FUNCTION__);
+
+	spin_lock_irqsave(&priv->lock, flags);
+	control_state = priv->control_state;
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	return control_state;
+}
+
+static int mct_u232_tiocmset (struct usb_serial_port *port, struct file *file,
+			      unsigned int set, unsigned int clear)
 {
 	struct usb_serial *serial = port->serial;
 	struct mct_u232_private *priv = usb_get_serial_port_data(port);
-	int mask;
 	unsigned long control_state;
 	unsigned long flags;
 	
-	dbg("%scmd=0x%x", __FUNCTION__, cmd);
+	dbg("%s", __FUNCTION__);
 
 	spin_lock_irqsave(&priv->lock, flags);
 	control_state = priv->control_state;
+
+	if (set & TIOCM_RTS)
+		control_state |= TIOCM_RTS;
+	if (set & TIOCM_DTR)
+		control_state |= TIOCM_DTR;
+	if (clear & TIOCM_RTS)
+		control_state &= ~TIOCM_RTS;
+	if (clear & TIOCM_DTR)
+		control_state &= ~TIOCM_DTR;
+
+	priv->control_state = control_state;
 	spin_unlock_irqrestore(&priv->lock, flags);
+	return mct_u232_set_modem_ctrl(serial, control_state);
+}
+
+static int mct_u232_ioctl (struct usb_serial_port *port, struct file * file,
+			   unsigned int cmd, unsigned long arg)
+{
+	dbg("%scmd=0x%x", __FUNCTION__, cmd);
 
 	/* Based on code from acm.c and others */
 	switch (cmd) {
-	case TIOCMGET:
-		return put_user(control_state, (unsigned long *) arg);
-		break;
-
-	case TIOCMSET: /* Turns on and off the lines as specified by the mask */
-	case TIOCMBIS: /* turns on (Sets) the lines as specified by the mask */
-	case TIOCMBIC: /* turns off (Clears) the lines as specified by the mask */
-		if (get_user(mask, (unsigned long *) arg))
-			return -EFAULT;
-
-		if ((cmd == TIOCMSET) || (mask & TIOCM_RTS)) {
-			/* RTS needs set */
-			if( ((cmd == TIOCMSET) && (mask & TIOCM_RTS)) ||
-			    (cmd == TIOCMBIS) )
-				control_state |=  TIOCM_RTS;
-			else
-				control_state &= ~TIOCM_RTS;
-		}
-
-		if ((cmd == TIOCMSET) || (mask & TIOCM_DTR)) {
-			/* DTR needs set */
-			if( ((cmd == TIOCMSET) && (mask & TIOCM_DTR)) ||
-			    (cmd == TIOCMBIS) )
-				control_state |=  TIOCM_DTR;
-			else
-				control_state &= ~TIOCM_DTR;
-		}
-		mct_u232_set_modem_ctrl(serial, control_state);
-
-		spin_lock_irqsave(&priv->lock, flags);
-		priv->control_state = control_state;
-		spin_unlock_irqrestore(&priv->lock, flags);
-		break;
-					
 	case TIOCMIWAIT:
 		/* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
 		/* TODO */
diff -Nru a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
--- a/drivers/usb/serial/pl2303.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/usb/serial/pl2303.c	Wed Apr 30 22:28:09 2003
@@ -1,7 +1,8 @@
 /*
  * Prolific PL2303 USB to serial adaptor driver
  *
- * Copyright (C) 2001-2002 Greg Kroah-Hartman (greg@kroah.com)
+ * Copyright (C) 2001-2003 Greg Kroah-Hartman (greg@kroah.com)
+ * Copyright (C) 2003 IBM Corp.
  *
  * Original driver for 2.2.x by anonymous
  *
@@ -111,6 +112,16 @@
 #define VENDOR_READ_REQUEST_TYPE	0xc0
 #define VENDOR_READ_REQUEST		0x01
 
+#define UART_STATE			0x08
+#define UART_DCD			0x01
+#define UART_DSR			0x02
+#define UART_BREAK_ERROR		0x04
+#define UART_RING			0x08
+#define UART_FRAME_ERROR		0x10
+#define UART_PARITY_ERROR		0x20
+#define UART_OVERRUN_ERROR		0x40
+#define UART_CTS			0x80
+
 /* function prototypes for a PL2303 serial converter */
 static int pl2303_open (struct usb_serial_port *port, struct file *filp);
 static void pl2303_close (struct usb_serial_port *port, struct file *filp);
@@ -124,6 +135,9 @@
 static int pl2303_write (struct usb_serial_port *port, int from_user,
 			 const unsigned char *buf, int count);
 static void pl2303_break_ctl(struct usb_serial_port *port,int break_state);
+static int pl2303_tiocmget (struct usb_serial_port *port, struct file *file);
+static int pl2303_tiocmset (struct usb_serial_port *port, struct file *file,
+			    unsigned int set, unsigned int clear);
 static int pl2303_startup (struct usb_serial *serial);
 static void pl2303_shutdown (struct usb_serial *serial);
 
@@ -143,6 +157,8 @@
 	.ioctl =		pl2303_ioctl,
 	.break_ctl =		pl2303_break_ctl,
 	.set_termios =		pl2303_set_termios,
+	.tiocmget =		pl2303_tiocmget,
+	.tiocmset =		pl2303_tiocmset,
 	.read_bulk_callback =	pl2303_read_bulk_callback,
 	.read_int_callback =	pl2303_read_int_callback,
 	.write_bulk_callback =	pl2303_write_bulk_callback,
@@ -153,6 +169,7 @@
 struct pl2303_private {
 	spinlock_t lock;
 	u8 line_control;
+	u8 line_status;
 	u8 termios_initialized;
 };
 
@@ -222,6 +239,7 @@
 {
 	struct usb_serial *serial = port->serial;
 	struct pl2303_private *priv = usb_get_serial_port_data(port);
+	unsigned long flags;
 	unsigned int cflag;
 	unsigned char *buf;
 	int baud;
@@ -234,13 +252,13 @@
 		return;
 	}
 
-	spin_lock(&priv->lock);
+	spin_lock_irqsave(&priv->lock, flags);
 	if (!priv->termios_initialized) {
 		*(port->tty->termios) = tty_std_termios;
 		port->tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
 		priv->termios_initialized = 1;
 	}
-	spin_unlock(&priv->lock);
+	spin_unlock_irqrestore(&priv->lock, flags);
 
 	cflag = port->tty->termios->c_cflag;
 	/* check that they really want us to change something */
@@ -350,13 +368,13 @@
 	if (cflag && CBAUD) {
 		u8 control;
 
-		spin_lock (&priv->lock);
+		spin_lock_irqsave(&priv->lock, flags);
 		if ((cflag && CBAUD) == B0)
 			priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS);
 		else
 			priv->line_control |= (CONTROL_DTR | CONTROL_RTS);
 		control = priv->line_control;
-		spin_unlock (&priv->lock);
+		spin_unlock_irqrestore(&priv->lock, flags);
 		set_control_lines (serial->dev, control);
 	}
 	
@@ -445,6 +463,7 @@
 {
 	struct usb_serial *serial;
 	struct pl2303_private *priv;
+	unsigned long flags;
 	unsigned int c_cflag;
 	int result;
 
@@ -481,72 +500,56 @@
 		if (c_cflag & HUPCL) {
 			/* drop DTR and RTS */
 			priv = usb_get_serial_port_data(port);
-			spin_lock (&priv->lock);
+			spin_lock_irqsave(&priv->lock, flags);
 			priv->line_control = 0;
-			spin_unlock (&priv->lock);
+			spin_unlock_irqrestore (&priv->lock, flags);
 			set_control_lines (port->serial->dev, 0);
 		}
 	}
 
 }
 
-static int set_modem_info (struct usb_serial_port *port, unsigned int cmd, unsigned int *value)
+static int pl2303_tiocmset (struct usb_serial_port *port, struct file *file,
+			    unsigned int set, unsigned int clear)
 {
 	struct pl2303_private *priv = usb_get_serial_port_data(port);
-	unsigned int arg;
+	unsigned long flags;
 	u8 control;
 
-	if (copy_from_user(&arg, value, sizeof(int)))
-		return -EFAULT;
-
-	spin_lock (&priv->lock);
-	switch (cmd) {
-		case TIOCMBIS:
-			if (arg & TIOCM_RTS)
-				priv->line_control |= CONTROL_RTS;
-			if (arg & TIOCM_DTR)
-				priv->line_control |= CONTROL_DTR;
-			break;
-
-		case TIOCMBIC:
-			if (arg & TIOCM_RTS)
-				priv->line_control &= ~CONTROL_RTS;
-			if (arg & TIOCM_DTR)
-				priv->line_control &= ~CONTROL_DTR;
-			break;
-
-		case TIOCMSET:
-			/* turn off RTS and DTR and then only turn
-			   on what was asked to */
-			priv->line_control &= ~(CONTROL_RTS | CONTROL_DTR);
-			priv->line_control |= ((arg & TIOCM_RTS) ? CONTROL_RTS : 0);
-			priv->line_control |= ((arg & TIOCM_DTR) ? CONTROL_DTR : 0);
-			break;
-	}
+	spin_lock_irqsave (&priv->lock, flags);
+	if (set & TIOCM_RTS)
+		priv->line_control |= CONTROL_RTS;
+	if (set & TIOCM_DTR)
+		priv->line_control |= CONTROL_DTR;
+	if (clear & TIOCM_RTS)
+		priv->line_control &= ~CONTROL_RTS;
+	if (clear & TIOCM_DTR)
+		priv->line_control &= ~CONTROL_DTR;
 	control = priv->line_control;
-	spin_unlock (&priv->lock);
+	spin_unlock_irqrestore (&priv->lock, flags);
 
 	return set_control_lines (port->serial->dev, control);
 }
 
-static int get_modem_info (struct usb_serial_port *port, unsigned int *value)
+static int pl2303_tiocmget (struct usb_serial_port *port, struct file *file)
 {
 	struct pl2303_private *priv = usb_get_serial_port_data(port);
+	unsigned long flags;
 	unsigned int mcr;
 	unsigned int result;
 
-	spin_lock (&priv->lock);
+	dbg("%s (%d)", __FUNCTION__, port->number);
+
+	spin_lock_irqsave (&priv->lock, flags);
 	mcr = priv->line_control;
-	spin_unlock (&priv->lock);
+	spin_unlock_irqrestore (&priv->lock, flags);
 
 	result = ((mcr & CONTROL_DTR)		? TIOCM_DTR : 0)
 		  | ((mcr & CONTROL_RTS)	? TIOCM_RTS : 0);
 
 	dbg("%s - result = %x", __FUNCTION__, result);
 
-	if (copy_to_user(value, &result, sizeof(int)))
-		return -EFAULT;
-	return 0;
+	return result;
 }
 
 static int pl2303_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg)
@@ -554,17 +557,6 @@
 	dbg("%s (%d) cmd = 0x%04x", __FUNCTION__, port->number, cmd);
 
 	switch (cmd) {
-		
-		case TIOCMGET:
-			dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number);
-			return get_modem_info (port, (unsigned int *)arg);
-
-		case TIOCMBIS:
-		case TIOCMBIC:
-		case TIOCMSET:
-			dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__,  port->number);
-			return set_modem_info(port, cmd, (unsigned int *) arg);
-
 		default:
 			dbg("%s not supported = 0x%04x", __FUNCTION__, cmd);
 			break;
@@ -573,7 +565,6 @@
 	return -ENOIOCTLCMD;
 }
 
-
 static void pl2303_break_ctl (struct usb_serial_port *port, int break_state)
 {
 	struct usb_serial *serial = port->serial;
@@ -613,9 +604,13 @@
 {
 	struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
 	struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
-	//unsigned char *data = urb->transfer_buffer;
+	struct pl2303_private *priv = usb_get_serial_port_data(port);
+	unsigned char *data = urb->transfer_buffer;
+	unsigned long flags;
 	int status;
 
+	dbg("%s (%d)", __FUNCTION__, port->number);
+
 	switch (urb->status) {
 	case 0:
 		/* success */
@@ -637,8 +632,14 @@
 
 	usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, urb->transfer_buffer);
 
-	//FIXME need to update state of terminal lines variable
+	if (urb->actual_length > UART_STATE)
+		goto exit;
 
+	/* Save off the uart status for others to look at */
+	spin_lock_irqsave(&priv->lock, flags);
+	priv->line_status = data[UART_STATE];
+	spin_unlock_irqrestore(&priv->lock, flags);
+		
 exit:
 	status = usb_submit_urb (urb, GFP_ATOMIC);
 	if (status)
@@ -651,10 +652,14 @@
 {
 	struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
 	struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
+	struct pl2303_private *priv = usb_get_serial_port_data(port);
 	struct tty_struct *tty;
 	unsigned char *data = urb->transfer_buffer;
+	unsigned long flags;
 	int i;
 	int result;
+	u8 status;
+	char tty_flag;
 
 	if (port_paranoia_check (port, __FUNCTION__))
 		return;
@@ -688,13 +693,34 @@
 
 	usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, data);
 
+	/* get tty_flag from status */
+	tty_flag = TTY_NORMAL;
+
+	spin_lock_irqsave(&priv->lock, flags);
+	status = priv->line_status;
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	/* break takes precedence over parity, */
+	/* which takes precedence over framing errors */
+	if (status & UART_BREAK_ERROR )
+		tty_flag = TTY_BREAK;
+	else if (status & UART_PARITY_ERROR)
+		tty_flag = TTY_PARITY;
+	else if (status & UART_FRAME_ERROR)
+		tty_flag = TTY_FRAME;
+	dbg("%s - tty_flag = %d", __FUNCTION__, tty_flag);
+
 	tty = port->tty;
 	if (tty && urb->actual_length) {
+		/* overrun is special, not associated with a char */
+		if (status & UART_OVERRUN_ERROR)
+			tty_insert_flip_char(tty, 0, TTY_OVERRUN);
+
 		for (i = 0; i < urb->actual_length; ++i) {
 			if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
 				tty_flip_buffer_push(tty);
 			}
-			tty_insert_flip_char (tty, data[i], 0);
+			tty_insert_flip_char (tty, data[i], tty_flag);
 		}
 		tty_flip_buffer_push (tty);
 	}
diff -Nru a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
--- a/drivers/usb/serial/usb-serial.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/usb/serial/usb-serial.c	Wed Apr 30 22:28:08 2003
@@ -389,9 +389,9 @@
 static LIST_HEAD(usb_serial_driver_list);
 
 
-struct usb_serial *usb_serial_get_by_minor (unsigned int minor)
+struct usb_serial *usb_serial_get_by_index(unsigned index)
 {
-	struct usb_serial *serial = serial_table[minor];
+	struct usb_serial *serial = serial_table[index];
 
 	if (serial)
 		kobject_get (&serial->kobj);
@@ -462,13 +462,13 @@
 	tty->driver_data = NULL;
 
 	/* get the serial object associated with this tty pointer */
-	serial = usb_serial_get_by_minor (minor(tty->device));
+	serial = usb_serial_get_by_index(tty->index);
 
 	if (serial_paranoia_check (serial, __FUNCTION__))
 		return -ENODEV;
 
 	/* set up our port structure making the tty driver remember our port object, and us it */
-	portNumber = minor(tty->device) - serial->minor;
+	portNumber = tty->index - serial->minor;
 	port = &serial->port[portNumber];
 	tty->driver_data = port;
 
@@ -753,7 +753,7 @@
 	dbg("%s", __FUNCTION__);
 	length += sprintf (page, "usbserinfo:1.0 driver:%s\n", DRIVER_VERSION);
 	for (i = 0; i < SERIAL_TTY_MINORS && length < PAGE_SIZE; ++i) {
-		serial = usb_serial_get_by_minor(i);
+		serial = usb_serial_get_by_index(i);
 		if (serial == NULL)
 			continue;
 
@@ -785,6 +785,51 @@
 	return ((count < begin+length-off) ? count : begin+length-off);
 }
 
+static int serial_tiocmget (struct tty_struct *tty, struct file *file)
+{
+	struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
+	struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
+
+	if (!serial)
+		goto exit;
+
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	if (!port->open_count) {
+		dbg("%s - port not open", __FUNCTION__);
+		goto exit;
+	}
+
+	if (serial->type->tiocmget)
+		return serial->type->tiocmget(port, file);
+
+exit:
+	return -EINVAL;
+}
+
+static int serial_tiocmset (struct tty_struct *tty, struct file *file,
+			    unsigned int set, unsigned int clear)
+{
+	struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
+	struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
+
+	if (!serial)
+		goto exit;
+
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	if (!port->open_count) {
+		dbg("%s - port not open", __FUNCTION__);
+		goto exit;
+	}
+
+	if (serial->type->tiocmset)
+		return serial->type->tiocmset(port, file, set, clear);
+
+exit:
+	return -EINVAL;
+}
+
 void usb_serial_port_softint(void *private)
 {
 	struct usb_serial_port *port = (struct usb_serial_port *)private;
@@ -1261,7 +1306,7 @@
 #ifndef CONFIG_DEVFS_FS
 	.name =			"ttyUSB",
 #else
-	.name =			"usb/tts/%d",
+	.name =			"usb/tts/",
 #endif
 	.major =		SERIAL_TTY_MAJOR,
 	.minor_start =		0,
@@ -1286,6 +1331,8 @@
 	.break_ctl =		serial_break,
 	.chars_in_buffer =	serial_chars_in_buffer,
 	.read_proc =		serial_read_proc,
+	.tiocmget =		serial_tiocmget,
+	.tiocmset =		serial_tiocmset,
 };
 
 
diff -Nru a/drivers/usb/serial/usb-serial.h b/drivers/usb/serial/usb-serial.h
--- a/drivers/usb/serial/usb-serial.h	Wed Apr 30 22:28:20 2003
+++ b/drivers/usb/serial/usb-serial.h	Wed Apr 30 22:28:20 2003
@@ -251,6 +251,8 @@
 	int  (*chars_in_buffer)	(struct usb_serial_port *port);
 	void (*throttle)	(struct usb_serial_port *port);
 	void (*unthrottle)	(struct usb_serial_port *port);
+	int  (*tiocmget)	(struct usb_serial_port *port, struct file *file);
+	int  (*tiocmset)	(struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
 
 	void (*read_int_callback)(struct urb *urb, struct pt_regs *regs);
 	void (*read_bulk_callback)(struct urb *urb, struct pt_regs *regs);
@@ -368,7 +370,7 @@
 
 /* Use our own dbg macro */
 #undef dbg
-#define dbg(format, arg...) do { if (debug) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0)
+#define dbg(format, arg...) do { if (debug) printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , ## arg); } while (0)
 
 
 
diff -Nru a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
--- a/drivers/usb/serial/whiteheat.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/usb/serial/whiteheat.c	Wed Apr 30 22:28:07 2003
@@ -146,6 +146,8 @@
 static int  whiteheat_write_room	(struct usb_serial_port *port);
 static int  whiteheat_ioctl		(struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
 static void whiteheat_set_termios	(struct usb_serial_port *port, struct termios * old);
+static int  whiteheat_tiocmget		(struct usb_serial_port *port, struct file *file);
+static int  whiteheat_tiocmset		(struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
 static void whiteheat_break_ctl		(struct usb_serial_port *port, int break_state);
 static int  whiteheat_chars_in_buffer	(struct usb_serial_port *port);
 static void whiteheat_throttle		(struct usb_serial_port *port);
@@ -184,6 +186,8 @@
 	.ioctl =		whiteheat_ioctl,
 	.set_termios =		whiteheat_set_termios,
 	.break_ctl =		whiteheat_break_ctl,
+	.tiocmget =		whiteheat_tiocmget,
+	.tiocmset =		whiteheat_tiocmset,
 	.chars_in_buffer =	whiteheat_chars_in_buffer,
 	.throttle =		whiteheat_throttle,
 	.unthrottle =		whiteheat_unthrottle,
@@ -646,8 +650,8 @@
 	}
 */
 
-	if (port->tty->driver.flush_buffer)
-		port->tty->driver.flush_buffer(port->tty);
+	if (port->tty->driver->flush_buffer)
+		port->tty->driver->flush_buffer(port->tty);
 	if (port->tty->ldisc.flush_buffer)
 		port->tty->ldisc.flush_buffer(port->tty);
 
@@ -767,73 +771,53 @@
 }
 
 
-static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
+static int whiteheat_tiocmget (struct usb_serial_port *port, struct file *file)
 {
 	struct whiteheat_private *info = usb_get_serial_port_data(port);
 	unsigned int modem_signals = 0;
-	struct serial_struct serstruct;
-
-	dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd);
 
-	switch (cmd) {
-		case TIOCMGET:
-			firm_get_dtr_rts(port);
-			if (info->mcr & UART_MCR_DTR)
-				modem_signals |= TIOCM_DTR;
-			if (info->mcr & UART_MCR_RTS)
-				modem_signals |= TIOCM_RTS;
-			
-			if (copy_to_user((unsigned int *)arg, &modem_signals, sizeof(unsigned int)))
-				return -EFAULT;
-
-			break;
-
-		case TIOCMSET:
-			if (copy_from_user(&modem_signals, (unsigned int *)arg, sizeof(unsigned int)))
-				return -EFAULT;
-
-			if (modem_signals & TIOCM_DTR)
-				info->mcr |= UART_MCR_DTR;
-			else
-				info->mcr &= ~UART_MCR_DTR;
-			if (modem_signals & TIOCM_RTS)
-				info->mcr |= UART_MCR_RTS;
-			else
-				info->mcr &= ~UART_MCR_RTS;
+	dbg("%s - port %d", __FUNCTION__, port->number);
 
-			firm_set_dtr(port, info->mcr & UART_MCR_DTR);
-			firm_set_rts(port, info->mcr & UART_MCR_RTS);
+	firm_get_dtr_rts(port);
+	if (info->mcr & UART_MCR_DTR)
+		modem_signals |= TIOCM_DTR;
+	if (info->mcr & UART_MCR_RTS)
+		modem_signals |= TIOCM_RTS;
 
-			break;
+	return modem_signals;
+}
 
-		case TIOCMBIS:
-			if (copy_from_user(&modem_signals, (unsigned int *)arg, sizeof(unsigned int)))
-				return -EFAULT;
 
-			if (modem_signals & TIOCM_DTR)
-				info->mcr |= UART_MCR_DTR;
-			if (modem_signals & TIOCM_RTS)
-				info->mcr |= UART_MCR_RTS;
+static int whiteheat_tiocmset (struct usb_serial_port *port, struct file *file,
+			       unsigned int set, unsigned int clear)
+{
+	struct whiteheat_private *info = usb_get_serial_port_data(port);
 
-			firm_set_dtr(port, info->mcr & UART_MCR_DTR);
-			firm_set_rts(port, info->mcr & UART_MCR_RTS);
+	dbg("%s - port %d", __FUNCTION__, port->number);
 
-			break;
+	if (set & TIOCM_RTS)
+		info->mcr |= UART_MCR_RTS;
+	if (set & TIOCM_DTR)
+		info->mcr |= UART_MCR_DTR;
+
+	if (clear & TIOCM_RTS)
+		info->mcr &= ~UART_MCR_RTS;
+	if (clear & TIOCM_DTR)
+		info->mcr &= ~UART_MCR_DTR;
 
-		case TIOCMBIC:
-			if (copy_from_user(&modem_signals, (unsigned int *)arg, sizeof(unsigned int)))
-				return -EFAULT;
+	firm_set_dtr(port, info->mcr & UART_MCR_DTR);
+	firm_set_rts(port, info->mcr & UART_MCR_RTS);
+	return 0;
+}
 
-			if (modem_signals & TIOCM_DTR)
-				info->mcr &= ~UART_MCR_DTR;
-			if (modem_signals & TIOCM_RTS)
-				info->mcr &= ~UART_MCR_RTS;
 
-			firm_set_dtr(port, info->mcr & UART_MCR_DTR);
-			firm_set_rts(port, info->mcr & UART_MCR_RTS);
+static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
+{
+	struct serial_struct serstruct;
 
-			break;
+	dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd);
 
+	switch (cmd) {
 		case TIOCGSERIAL:
 			memset(&serstruct, 0, sizeof(serstruct));
 			serstruct.type = PORT_16654;
@@ -864,10 +848,10 @@
 			break;
 
 		default:
-			return -ENOIOCTLCMD;
+			break;
 	}
 
-	return 0;
+	return -ENOIOCTLCMD;
 }
 
 
diff -Nru a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
--- a/drivers/usb/storage/unusual_devs.h	Wed Apr 30 22:28:14 2003
+++ b/drivers/usb/storage/unusual_devs.h	Wed Apr 30 22:28:14 2003
@@ -35,6 +35,14 @@
 
 /* If you edit this file, please try to keep it sorted first by VendorID,
  * then by ProductID.
+ *
+ * If you want to add an entry for this file, please send the following
+ * to greg@kroah.com:
+ *	- patch that adds the entry for your device which includes your
+ *	  email address right above the entry.
+ *	- a copy of /proc/bus/usb/devices with your device plugged in
+ *	  running with this patch.
+ *
  */
 
 UNUSUAL_DEV(  0x03ee, 0x0000, 0x0000, 0x0245, 
@@ -229,10 +237,18 @@
 		US_SC_8070, US_PR_BULK, NULL,
 		US_FL_FIX_INQUIRY | US_FL_START_STOP ),
 
+/* Submitted by Lars Gemeinhardt <linux-usb@gemeinhardt.info>
+ * Needed for START_STOP flag */
+UNUSUAL_DEV(  0x0547, 0x2810, 0x0001, 0x0001,
+                "Mello",
+                "MP3 Player",
+		US_SC_SCSI, US_PR_BULK, NULL,
+		US_FL_START_STOP),
+
 /* This entry is needed because the device reports Sub=ff */
-UNUSUAL_DEV(  0x054c, 0x0010, 0x0106, 0x0440, 
+UNUSUAL_DEV(  0x054c, 0x0010, 0x0106, 0x0450, 
 		"Sony",
-		"DSC-S30/S70/S75/505V/F505/F707/F717", 
+		"DSC-S30/S70/S75/505V/F505/F707/F717/P8", 
 		US_SC_SCSI, US_PR_CB, NULL,
 		US_FL_SINGLE_LUN | US_FL_START_STOP | US_FL_MODE_XLATE ),
 
@@ -285,6 +301,19 @@
 		"LaCie",
 		"USB Hard Disk",
 		US_SC_RBC, US_PR_CB, NULL, 0 ), 
+
+/* This Pentax still camera is not conformant
+ * to the USB storage specification: -
+ * - It does not like the INQUIRY command. So we must handle this command
+ *   of the SCSI layer ourselves.
+ * Tested on Rev. 10.00 (0x1000)
+ * Submitted by James Courtier-Dutton <James@superbug.demon.co.uk>
+ */
+UNUSUAL_DEV( 0x0a17, 0x0004, 0x1000, 0x1000,
+                "ASAHI PENTAX",
+                "PENTAX OPTIO 430",
+                US_SC_8070, US_PR_CBI, NULL,
+                US_FL_FIX_INQUIRY ),
 
 /* This Pentax still camera is not conformant
  * to the USB storage specification: -
diff -Nru a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
--- a/drivers/usb/usb-skeleton.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/usb/usb-skeleton.c	Wed Apr 30 22:28:09 2003
@@ -98,7 +98,6 @@
 struct usb_skel {
 	struct usb_device *	udev;			/* save off the usb device pointer */
 	struct usb_interface *	interface;		/* the interface for this device */
-	devfs_handle_t		devfs;			/* devfs device node */
 	unsigned char		minor;			/* the starting minor number for this device */
 	unsigned char		num_ports;		/* the number of ports this device has */
 	char			num_interrupt_in;	/* number of interrupt in endpoints we have */
@@ -610,7 +609,7 @@
 	/* initialize the devfs node for this device and register it */
 	sprintf(name, "usb/skel%d", dev->minor);
 
-	dev->devfs = devfs_register(NULL, name,
+	devfs = devfs_register(NULL, name,
 				     DEVFS_FL_DEFAULT, USB_MAJOR,
 				     dev->minor,
 				     S_IFCHR | S_IRUSR | S_IWUSR |
@@ -674,7 +673,7 @@
 	minor = dev->minor;
 
 	/* remove our devfs node */
-	devfs_unregister (dev->devfs);
+	devfs_remove("usb/skel%d", dev->minor);
 
 	/* give back our dynamic minor */
 	usb_deregister_dev (1, minor);
diff -Nru a/drivers/video/S3triofb.c b/drivers/video/S3triofb.c
--- a/drivers/video/S3triofb.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/video/S3triofb.c	Wed Apr 30 22:28:18 2003
@@ -520,7 +520,6 @@
 
     strcpy(fb_info.modename, "Trio64 ");
     strncat(fb_info.modename, dp->full_name, sizeof(fb_info.modename));
-    fb_info.node = NODEV;
     fb_info.currcon = -1;
     fb_info.fbops = &s3trio_ops;
     fb_info.screen_base = s3trio_base;	
@@ -542,7 +541,7 @@
 	return;
 
     printk("fb%d: S3 Trio frame buffer device on %s\n",
-	   minor(fb_info.node), dp->full_name);
+	   fb_info.node, dp->full_name);
 }
 
 
diff -Nru a/drivers/video/acornfb.c b/drivers/video/acornfb.c
--- a/drivers/video/acornfb.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/video/acornfb.c	Wed Apr 30 22:28:18 2003
@@ -979,7 +979,6 @@
 		return;
 	first = 0;
 
-	fb_info.node		= NODEV;
 	fb_info.fbops		= &acornfb_ops;
 	fb_info.flags		= FBINFO_FLAG_DEFAULT;
 
diff -Nru a/drivers/video/amifb.c b/drivers/video/amifb.c
--- a/drivers/video/amifb.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/video/amifb.c	Wed Apr 30 22:28:16 2003
@@ -1143,7 +1143,7 @@
 	 */
 
 static int flash_cursor(void);
-static void amifb_interrupt(int irq, void *dev_id, struct pt_regs *fp);
+static irqreturn_t amifb_interrupt(int irq, void *dev_id, struct pt_regs *fp);
 static u_long chipalloc(u_long size);
 static void chipfree(void);
 
@@ -2385,7 +2385,6 @@
 	    fb_info.monspecs.vfmax = 90;
 	}
 
-	fb_info.node = NODEV;
 	fb_info.fbops = &amifb_ops;
 	fb_info.par = &currentpar;
 	fb_info.flags = FBINFO_FLAG_DEFAULT;
@@ -2453,7 +2452,7 @@
 	}
 
 	printk("fb%d: %s frame buffer device, using %dK of video memory\n",
-	       minor(fb_info.node), fb_info.fix.id, fb_info.fix.smem_len>>10);
+	       fb_info.node, fb_info.fix.id, fb_info.fix.smem_len>>10);
 
 	return 0;
 
@@ -2504,7 +2503,7 @@
 	 * VBlank Display Interrupt
 	 */
 
-static void amifb_interrupt(int irq, void *dev_id, struct pt_regs *fp)
+static irqreturn_t amifb_interrupt(int irq, void *dev_id, struct pt_regs *fp)
 {
 	if (do_vmode_pan || do_vmode_full)
 		ami_update_display();
@@ -2534,6 +2533,7 @@
 		ami_reinit_copper();
 		do_vmode_full = 0;
 	}
+	return IRQ_HANDLED;
 }
 
 /* --------------------------- Hardware routines --------------------------- */
diff -Nru a/drivers/video/anakinfb.c b/drivers/video/anakinfb.c
--- a/drivers/video/anakinfb.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/video/anakinfb.c	Wed Apr 30 22:28:10 2003
@@ -73,7 +73,6 @@
 {
 	memset(&fb_info, 0, sizeof(struct fb_info));
 
-	fb_info.node = NODEV;
 	fb_info.flags = FBINFO_FLAG_DEFAULT;
 	fb_info.fbops = &anakinfb_ops;
 	fb_info.var = anakinfb_var;
diff -Nru a/drivers/video/atafb.c b/drivers/video/atafb.c
--- a/drivers/video/atafb.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/video/atafb.c	Wed Apr 30 22:28:04 2003
@@ -1522,7 +1522,7 @@
 }
 
 
-static void falcon_vbl_switcher( int irq, void *dummy, struct pt_regs *fp )
+static irqreturn_t falcon_vbl_switcher( int irq, void *dummy, struct pt_regs *fp )
 {
 	struct falcon_hw *hw = &f_new_mode;
 
@@ -1579,6 +1579,7 @@
 		videl.xoffset = current_par.hw.falcon.xoffset;
 		shifter_f030.off_next = current_par.hw.falcon.line_offset;
 	}
+	return IRQ_HANDLED;
 }
 
 
@@ -2792,7 +2793,6 @@
 
 	strcpy(fb_info.modename, "Atari Builtin ");
 	fb_info.changevar = NULL;
-	fb_info.node = NODEV;
 	fb_info.fbops = &atafb_ops;
 	fb_info.disp = &disp;
 	fb_info.currcon = -1;
@@ -2816,7 +2816,7 @@
 	   printk("   virtual %dx%d\n",
 			  disp.var.xres_virtual, disp.var.yres_virtual);
 	printk("fb%d: %s frame buffer device, using %dK of video memory\n",
-	       minor(fb_info.node), fb_info.modename, screen_len>>10);
+	       fb_info.node, fb_info.modename, screen_len>>10);
 
 	/* TODO: This driver cannot be unloaded yet */
 	MOD_INC_USE_COUNT;
diff -Nru a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
--- a/drivers/video/aty/aty128fb.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/video/aty/aty128fb.c	Wed Apr 30 22:28:09 2003
@@ -1534,7 +1534,6 @@
 	par->chip_gen = ent->driver_data;
 
 	/* fill in info */
-	info->node  = NODEV;
 	info->fbops = &aty128fb_ops;
 	info->flags = FBINFO_FLAG_DEFAULT;
 
@@ -1635,7 +1634,7 @@
 #endif
 
 	printk(KERN_INFO "fb%d: %s frame buffer device on %s\n",
-	       minor(info->node), info->fix.id, video_card);
+	       info->node, info->fix.id, video_card);
 
 	return 1;	/* success! */
 }
diff -Nru a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
--- a/drivers/video/aty/atyfb_base.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/video/aty/atyfb_base.c	Wed Apr 30 22:28:12 2003
@@ -1747,7 +1747,6 @@
 	fb_memset((void *) info->screen_base, 0,
 		  info->fix.smem_len);
 
-	info->node = NODEV;
 	info->fbops = &atyfb_ops;
 	info->pseudo_palette = pseudo_palette;
 	info->flags = FBINFO_FLAG_DEFAULT;
@@ -1861,7 +1860,7 @@
 	fb_list = info;
 
 	printk("fb%d: %s frame buffer device on %s\n",
-	       minor(info->node), info->fix.id, name);
+	       info->node, info->fix.id, name);
 	return 1;
 }
 
diff -Nru a/drivers/video/aty/mach64_gx.c b/drivers/video/aty/mach64_gx.c
--- a/drivers/video/aty/mach64_gx.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/video/aty/mach64_gx.c	Wed Apr 30 22:28:05 2003
@@ -119,7 +119,7 @@
 }
 
 static int aty_var_to_pll_514(const struct fb_info *info, u32 vclk_per,
-			      u32 bpp, u32 width, union aty_pll *pll)
+			      u8 bpp, union aty_pll *pll)
 {
 	/*
 	 *  FIXME: use real calculations instead of using fixed values from the old
@@ -338,7 +338,7 @@
      */
 
 static int aty_var_to_pll_18818(const struct fb_info *info, u32 vclk_per,
-				u32 bpp, u32 width, union aty_pll *pll)
+				u8 bpp, union aty_pll *pll)
 {
 	u32 MHz100;		/* in 0.01 MHz */
 	u32 program_bits;
@@ -494,7 +494,7 @@
      */
 
 static int aty_var_to_pll_1703(const struct fb_info *info, u32 vclk_per,
-			       u32 bpp, u32 width, union aty_pll *pll)
+			       u32 vclk_per, u8 bpp, union aty_pll *pll)
 {
 	u32 mhz100;		/* in 0.01 MHz */
 	u32 program_bits;
@@ -610,7 +610,7 @@
      */
 
 static int aty_var_to_pll_8398(const struct fb_info *info, u32 vclk_per,
-			       u32 bpp, u32 width, union aty_pll *pll)
+			       u32 vclk_per, u8 bpp, union aty_pll *pll)
 {
 	u32 tempA, tempB, fOut, longMHz100, diff, preDiff;
 
@@ -734,7 +734,7 @@
      */
 
 static int aty_var_to_pll_408(const struct fb_info *info, u32 vclk_per,
-			      u32 bpp, u32 width, union aty_pll *pll)
+			      u8 bpp, union aty_pll *pll)
 {
 	u32 mhz100;		/* in 0.01 MHz */
 	u32 program_bits;
diff -Nru a/drivers/video/bw2.c b/drivers/video/bw2.c
--- a/drivers/video/bw2.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/video/bw2.c	Wed Apr 30 22:28:10 2003
@@ -346,7 +346,6 @@
 
 	all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres);
 
-	all->info.node = NODEV;
 	all->info.flags = FBINFO_FLAG_DEFAULT;
 	all->info.fbops = &bw2_ops;
 #if defined(CONFIG_SPARC32)
diff -Nru a/drivers/video/cg14.c b/drivers/video/cg14.c
--- a/drivers/video/cg14.c	Wed Apr 30 22:28:17 2003
+++ b/drivers/video/cg14.c	Wed Apr 30 22:28:17 2003
@@ -473,7 +473,6 @@
 	all->par.mode = MDI_8_PIX;
 	all->par.ramsize = (is_8mb ? 0x800000 : 0x400000);
 
-	all->info.node = NODEV;
 	all->info.flags = FBINFO_FLAG_DEFAULT;
 	all->info.fbops = &cg14_ops;
 	all->info.currcon = -1;
diff -Nru a/drivers/video/cg3.c b/drivers/video/cg3.c
--- a/drivers/video/cg3.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/video/cg3.c	Wed Apr 30 22:28:11 2003
@@ -395,7 +395,6 @@
 		sbus_ioremap(&sdev->resource[0], CG3_REGS_OFFSET,
 			     sizeof(struct cg3_regs), "cg3 regs");
 
-	all->info.node = NODEV;
 	all->info.flags = FBINFO_FLAG_DEFAULT;
 	all->info.fbops = &cg3_ops;
 #ifdef CONFIG_SPARC32
diff -Nru a/drivers/video/cg6.c b/drivers/video/cg6.c
--- a/drivers/video/cg6.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/video/cg6.c	Wed Apr 30 22:28:06 2003
@@ -680,7 +680,6 @@
 		sbus_ioremap(&sdev->resource[0], CG6_FHC_OFFSET,
 			     sizeof(u32), "cgsix fhc");
 
-	all->info.node = NODEV;
 	all->info.flags = FBINFO_FLAG_DEFAULT;
 	all->info.fbops = &cg6_ops;
 #ifdef CONFIG_SPARC32
diff -Nru a/drivers/video/chipsfb.c b/drivers/video/chipsfb.c
--- a/drivers/video/chipsfb.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/video/chipsfb.c	Wed Apr 30 22:28:09 2003
@@ -361,7 +361,6 @@
 
 	p->var = chipsfb_var;
 
-	p->node = NODEV;
 	p->fbops = &chipsfb_ops;
 	p->flags = FBINFO_FLAG_DEFAULT;
 
@@ -373,7 +372,7 @@
 	}
 
 	printk(KERN_INFO "fb%d: Chips 65550 frame buffer (%dK RAM detected)\n",
-		minor(p->node), p->fix.smem_len / 1024);
+		p->node, p->fix.smem_len / 1024);
 
 	chips_hw_init();
 }
diff -Nru a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c
--- a/drivers/video/cirrusfb.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/video/cirrusfb.c	Wed Apr 30 22:28:16 2003
@@ -2781,7 +2781,6 @@
 		 sizeof (fb_info->gen.info.modename));
 	fb_info->gen.info.modename [sizeof (fb_info->gen.info.modename) - 1] = 0;
 
-	fb_info->gen.info.node = NODEV;
 	fb_info->gen.info.fbops = &clgenfb_ops;
 	fb_info->gen.info.disp = &disp;
 	fb_info->gen.info.currcon = -1;
diff -Nru a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
--- a/drivers/video/console/fbcon.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/video/console/fbcon.c	Wed Apr 30 22:28:12 2003
@@ -138,7 +138,6 @@
 #define DEFAULT_CURSOR_BLINK_RATE	(20)
 
 static int vbl_cursor_cnt;
-static int cursor_blink_rate;
 
 #define divides(a, b)	((!(a) || (b)%(a)) ? 0 : 1)
 
@@ -185,7 +184,7 @@
  */
 static int vbl_detected;
 
-static void fb_vbl_detect(int irq, void *dummy, struct pt_regs *fp)
+static irqreturn_t fb_vbl_detect(int irq, void *dummy, struct pt_regs *fp)
 {
 	vbl_detected++;
 }
@@ -202,7 +201,9 @@
 	info->fbops->fb_cursor(info, &info->cursor);
 }
 
-static void fb_vbl_handler(int irq, void *dev_id, struct pt_regs *fp)
+#if (defined(__arm__) && defined(IRQ_VSYNCPULSE)) || defined(CONFIG_ATARI) || defined(CONFIG_MAC)
+static int cursor_blink_rate;
+static irqreturn_t fb_vbl_handler(int irq, void *dev_id, struct pt_regs *fp)
 {
 	struct fb_info *info = dev_id;
 
@@ -210,7 +211,9 @@
 		schedule_work(&info->queue);	
 		vbl_cursor_cnt = cursor_blink_rate; 
 	}
+	return IRQ_HANDLED;
 }
+#endif
 	
 static void cursor_timer_handler(unsigned long dev_addr);
 
@@ -527,8 +530,9 @@
 	struct fb_info *info;
 	struct vc_data *vc;
 	static int done = 0;
-	int irqres = 1;
+	int irqres;
 
+	irqres = 1;
 	/*
 	 *  If num_registered_fb is zero, this is a call for the dummy part.
 	 *  The frame buffer devices weren't initialized yet.
diff -Nru a/drivers/video/controlfb.c b/drivers/video/controlfb.c
--- a/drivers/video/controlfb.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/video/controlfb.c	Wed Apr 30 22:28:05 2003
@@ -483,7 +483,7 @@
 	if (register_framebuffer(&p->info) < 0)
 		return -ENXIO;
 	
-	printk(KERN_INFO "fb%d: control display adapter\n", minor(p->info.node));	
+	printk(KERN_INFO "fb%d: control display adapter\n", p->info.node);	
 
 	return 0;
 }
@@ -1008,7 +1008,6 @@
 {
 	/* Fill fb_info */
 	info->par = &p->par;
-	info->node = NODEV;
 	info->fbops = &controlfb_ops;
 	info->pseudo_palette = p->pseudo_palette;
         info->flags = FBINFO_FLAG_DEFAULT;
diff -Nru a/drivers/video/cyber2000fb.c b/drivers/video/cyber2000fb.c
--- a/drivers/video/cyber2000fb.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/video/cyber2000fb.c	Wed Apr 30 22:28:05 2003
@@ -55,6 +55,10 @@
 #include <asm/system.h>
 #include <asm/uaccess.h>
 
+#ifdef __arm__
+#include <asm/mach-types.h>
+#endif
+
 #include "cyber2000fb.h"
 
 struct cfb_info {
@@ -1281,7 +1285,6 @@
 
 	cfb->fb.fbops		= &cyber2000fb_ops;
 	cfb->fb.flags		= FBINFO_FLAG_DEFAULT;
-	cfb->fb.node		= NODEV;
 	cfb->fb.pseudo_palette	= (void *)(cfb + 1);
 
 	fb_alloc_cmap(&cfb->fb.cmap, NR_PALETTE, 0);
diff -Nru a/drivers/video/cyberfb.c b/drivers/video/cyberfb.c
--- a/drivers/video/cyberfb.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/video/cyberfb.c	Wed Apr 30 22:28:04 2003
@@ -1033,7 +1033,6 @@
 
 	    strcpy(fb_info.modename, cyberfb_name);
 	    fb_info.changevar = NULL;
-	    fb_info.node = NODEV;
 	    fb_info.fbops = &cyberfb_ops;
 	    fb_info.screen_base = (unsigned char *)CyberMem;
 	    fb_info.disp = &disp;
@@ -1063,7 +1062,7 @@
 	    }
 
 	    printk("fb%d: %s frame buffer device, using %ldK of video memory\n",
-		   minor(fb_info.node), fb_info.modename, CyberSize>>10);
+		   fb_info.node, fb_info.modename, CyberSize>>10);
 
 	    /* TODO: This driver cannot be unloaded yet */
 	    MOD_INC_USE_COUNT;
diff -Nru a/drivers/video/dnfb.c b/drivers/video/dnfb.c
--- a/drivers/video/dnfb.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/video/dnfb.c	Wed Apr 30 22:28:15 2003
@@ -229,7 +229,6 @@
 {
 	int err;
 
-	fb_info.node = NODEV;
 	fb_info.fbops = &dn_fb_ops;
 	fb_info.fix = dnfb_fix;
 	fb_info.var = dnfb_var;
diff -Nru a/drivers/video/epson1355fb.c b/drivers/video/epson1355fb.c
--- a/drivers/video/epson1355fb.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/video/epson1355fb.c	Wed Apr 30 22:28:04 2003
@@ -500,7 +500,6 @@
 	fb_info.gen.fbhw->detect();
 	strcpy(fb_info.gen.info.modename, "SED1355");
 	fb_info.gen.info.changevar = NULL;
-	fb_info.gen.info.node = NODEV;
 	fb_info.gen.info.fbops = &e1355fb_ops;
 	fb_info.gen.info.screen_base = (void *)E1355_FB_BASE;
 	fb_info.gen.currcon = -1;
@@ -517,7 +516,7 @@
 		do_install_cmap(0, &fb_info.gen);
 	if (register_framebuffer(&fb_info.gen.info) < 0)
 		return -EINVAL;
-	printk(KERN_INFO "fb%d: %s frame buffer device\n", minor(fb_info.gen.info.node),
+	printk(KERN_INFO "fb%d: %s frame buffer device\n", fb_info.gen.info.node,
 	       fb_info.gen.info.modename);
 
 	return 0;
diff -Nru a/drivers/video/fbmem.c b/drivers/video/fbmem.c
--- a/drivers/video/fbmem.c	Wed Apr 30 22:28:02 2003
+++ b/drivers/video/fbmem.c	Wed Apr 30 22:28:02 2003
@@ -25,6 +25,7 @@
 #include <linux/mman.h>
 #include <linux/tty.h>
 #include <linux/init.h>
+#include <linux/linux_logo.h>
 #include <linux/proc_fs.h>
 #ifdef CONFIG_KMOD
 #include <linux/kmod.h>
@@ -655,7 +656,7 @@
 	}
 
 	/* Return if no suitable logo was found */
-	fb_logo.logo = find_logo(info->var.bits_per_pixel);
+	fb_logo.logo = fb_find_logo(info->var.bits_per_pixel);
 	
 	if (!fb_logo.logo || fb_logo.logo->height > info->var.yres) {
 		fb_logo.logo = NULL;
@@ -752,7 +753,7 @@
 	for (fi = registered_fb; fi < &registered_fb[FB_MAX] && len < 4000; fi++)
 		if (*fi)
 			clen += sprintf(buf + clen, "%d %s\n",
-				        minor((*fi)->node),
+				        (*fi)->node,
 				        (*fi)->fix.id);
 	*start = buf + offset;
 	if (clen > offset)
@@ -1222,7 +1223,7 @@
 	for (i = 0 ; i < FB_MAX; i++)
 		if (!registered_fb[i])
 			break;
-	fb_info->node = mk_kdev(FB_MAJOR, i);
+	fb_info->node = i;
 	
 	if (fb_info->pixmap.addr == NULL) {
 		fb_info->pixmap.addr = kmalloc(FBPIXMAPSIZE, GFP_KERNEL);
@@ -1264,7 +1265,7 @@
 {
 	int i;
 
-	i = minor(fb_info->node);
+	i = fb_info->node;
 	if (!registered_fb[i])
 		return -EINVAL;
 	devfs_remove("fb/%d", i);
diff -Nru a/drivers/video/ffb.c b/drivers/video/ffb.c
--- a/drivers/video/ffb.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/video/ffb.c	Wed Apr 30 22:28:20 2003
@@ -895,7 +895,6 @@
 	all->par.prom_node = node;
 	all->par.prom_parent_node = parent;
 
-	all->info.node = NODEV;
 	all->info.flags = FBINFO_FLAG_DEFAULT;
 	all->info.fbops = &ffb_ops;
 	all->info.screen_base = (char *) all->par.physbase + FFB_DFB24_POFF;
diff -Nru a/drivers/video/fm2fb.c b/drivers/video/fm2fb.c
--- a/drivers/video/fm2fb.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/video/fm2fb.c	Wed Apr 30 22:28:08 2003
@@ -259,7 +259,6 @@
 		if (fm2fb_mode == -1)
 			fm2fb_mode = FM2FB_MODE_PAL;
 
-		fb_info.node = NODEV;
 		fb_info.fbops = &fm2fb_ops;
 		fb_info.var = fb_var_modes[fm2fb_mode];
 		fb_info.screen_base = (char *)fb_fix.smem_start;
@@ -273,7 +272,7 @@
 		if (register_framebuffer(&fb_info) < 0)
 			return -EINVAL;
 
-		printk("fb%d: %s frame buffer device\n", minor(fb_info.node), fb_fix.id);
+		printk("fb%d: %s frame buffer device\n", fb_info.node, fb_fix.id);
 		return 0;
 	}
 	return -ENXIO;
diff -Nru a/drivers/video/g364fb.c b/drivers/video/g364fb.c
--- a/drivers/video/g364fb.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/video/g364fb.c	Wed Apr 30 22:28:04 2003
@@ -237,7 +237,6 @@
 	fb_fix.smem_len = (1 << (mem * 2)) * 512 * 1024;
 	fb_var.yres_virtual = fb_fix.smem_len / fb_var.xres;
 
-	fb_info.node = NODEV;
 	fb_info.fbops = &g364fb_ops;
 	fb_info.screen_base = (char *) G364_MEM_BASE;	/* virtual kernel address */
 	fb_info.var = fb_var;
diff -Nru a/drivers/video/hgafb.c b/drivers/video/hgafb.c
--- a/drivers/video/hgafb.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/video/hgafb.c	Wed Apr 30 22:28:15 2003
@@ -549,7 +549,6 @@
 	hga_fix.smem_start = VGA_MAP_MEM(hga_vram_base);
 	hga_fix.smem_len = hga_vram_len;
 
-	fb_info.node = NODEV;
 	fb_info.flags = FBINFO_FLAG_DEFAULT;
 	fb_info.var = hga_default_var;
 	fb_info.fix = hga_fix;
@@ -565,7 +564,7 @@
                 return -EINVAL;
 
         printk(KERN_INFO "fb%d: %s frame buffer device\n",
-               minor(fb_info.node), fb_info.fix.id);
+               fb_info.node, fb_info.fix.id);
 	return 0;
 }
 
diff -Nru a/drivers/video/hitfb.c b/drivers/video/hitfb.c
--- a/drivers/video/hitfb.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/video/hitfb.c	Wed Apr 30 22:28:04 2003
@@ -153,7 +153,6 @@
 	}
 	hitfb_var.yres = ldvntr+1;
 
-	fb_info.node		= NODEV;
 	fb_info.fbops 		= &hitfb_ops;
 	fb_info.var 		= hitfb_var;
 	fb_info.fix 		= hitfb_fix;
@@ -169,7 +168,7 @@
 		return -EINVAL;
     
 	printk(KERN_INFO "fb%d: %s frame buffer device\n",
-			minor(fb_info.node), fb_info.fix.id);
+			fb_info.node, fb_info.fix.id);
 	return 0;
 }
 
diff -Nru a/drivers/video/hpfb.c b/drivers/video/hpfb.c
--- a/drivers/video/hpfb.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/video/hpfb.c	Wed Apr 30 22:28:10 2003
@@ -150,7 +150,6 @@
 	/*
 	 *	Let there be consoles..
 	 */
-	fb_info.node  = NODEV;
 	fb_info.fbops = &hpfb_ops;
 	fb_info.flags = FBINFO_FLAG_DEFAULT;
 	fb_info.var   = hpfb_defined;
diff -Nru a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
--- a/drivers/video/i810/i810_main.c	Wed Apr 30 22:28:07 2003
+++ b/drivers/video/i810/i810_main.c	Wed Apr 30 22:28:07 2003
@@ -1828,7 +1828,6 @@
 	i810_init_device(par);        
 
 	info->screen_base = par->fb.virtual;
-	info->node = NODEV;
 	info->fbops = &par->i810fb_ops;
 	info->pseudo_palette = par->pseudo_palette;
 	info->flags = FBINFO_FLAG_DEFAULT;
@@ -1861,7 +1860,7 @@
       	       "I810FB: Video RAM   : %dK\n" 
 	       "I810FB: Monitor     : H: %d-%d KHz V: %d-%d Hz\n"
 	       "I810FB: Mode        : %dx%d-%dbpp@%dHz\n",
-	       minor(info->node),
+	       info->node,
 	       i810_pci_list[entry->driver_data],
 	       VERSION_MAJOR, VERSION_MINOR, VERSION_TEENIE, BRANCH_VERSION,
 	       (int) par->fb.size>>10, info->monspecs.hfmin/1000,
diff -Nru a/drivers/video/igafb.c b/drivers/video/igafb.c
--- a/drivers/video/igafb.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/video/igafb.c	Wed Apr 30 22:28:10 2003
@@ -356,7 +356,6 @@
         else 
                 video_cmap_len = 256;
 
-	info->node  = NODEV;
 	info->fbops = &igafb_ops;
 	info->flags = FBINFO_FLAG_DEFAULT;
 
@@ -366,7 +365,7 @@
 		return 0;
 
 	printk("fb%d: %s frame buffer device at 0x%08lx [%dMB VRAM]\n",
-	       minor(info->node), info->fix.id, 
+	       info->node, info->fix.id, 
 	       par->frame_buffer_phys, info->fix.smem_len >> 20);
 
 	iga_blank_border(par); 
diff -Nru a/drivers/video/imsttfb.c b/drivers/video/imsttfb.c
--- a/drivers/video/imsttfb.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/video/imsttfb.c	Wed Apr 30 22:28:09 2003
@@ -1440,7 +1440,6 @@
 
 	info->var.pixclock = 1000000 / getclkMHz(par);
 
-	info->node = NODEV;
 	info->fbops = &imsttfb_ops;
 	info->flags = FBINFO_FLAG_DEFAULT;
 
@@ -1453,7 +1452,7 @@
 
 	tmp = (read_reg_le32(par->dc_regs, SSTATUS) & 0x0f00) >> 8;
 	printk("fb%u: %s frame buffer; %uMB vram; chip version %u\n",
-		minor(info->node), info->fix.id, info->fix.smem_len >> 20, tmp);
+		info->node, info->fix.id, info->fix.smem_len >> 20, tmp);
 }
 
 static int __devinit
diff -Nru a/drivers/video/leo.c b/drivers/video/leo.c
--- a/drivers/video/leo.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/video/leo.c	Wed Apr 30 22:28:16 2003
@@ -510,7 +510,6 @@
 		sbus_ioremap(&sdev->resource[0], LEO_OFF_LX_CURSOR,
 			     sizeof(struct leo_cursor), "leolx cursor");
 
-	all->info.node = NODEV;
 	all->info.flags = FBINFO_FLAG_DEFAULT;
 	all->info.fbops = &leo_ops;
 	all->info.currcon = -1;
diff -Nru a/drivers/video/logo/logo.c b/drivers/video/logo/logo.c
--- a/drivers/video/logo/logo.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/video/logo/logo.c	Wed Apr 30 22:28:10 2003
@@ -33,7 +33,7 @@
 extern const struct linux_logo logo_superh_clut224;
 
 
-const struct linux_logo * __init find_logo(int depth)
+const struct linux_logo *fb_find_logo(int depth)
 {
 	const struct linux_logo *logo = 0;
 
diff -Nru a/drivers/video/macfb.c b/drivers/video/macfb.c
--- a/drivers/video/macfb.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/video/macfb.c	Wed Apr 30 22:28:04 2003
@@ -943,7 +943,6 @@
 			break;
 		}
 
-	fb_info.node		= NODEV;
 	fb_info.fbops		= &macfb_ops;
 	fb_info.var		= macfb_defined;
 	fb_info.fix		= macfb_fix;
@@ -956,7 +955,7 @@
 		return;
 
 	printk("fb%d: %s frame buffer device\n",
-	       minor(fb_info.node), fb_info.fix.id);
+	       fb_info.node, fb_info.fix.id);
 }
 
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/video/matrox/i2c-matroxfb.c b/drivers/video/matrox/i2c-matroxfb.c
--- a/drivers/video/matrox/i2c-matroxfb.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/video/matrox/i2c-matroxfb.c	Wed Apr 30 22:28:09 2003
@@ -112,7 +112,7 @@
 	b->mask.clock = clock;
 	b->adapter = matrox_i2c_adapter_template;
 	snprintf(b->adapter.dev.name, DEVICE_NAME_SIZE, name,
-		minor(minfo->fbcon.node));
+		minfo->fbcon.node);
 	b->adapter.data = b;
 	b->adapter.algo_data = &b->bac;
 	b->bac = matrox_i2c_algo_template;
diff -Nru a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c
--- a/drivers/video/matrox/matroxfb_base.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/video/matrox/matroxfb_base.c	Wed Apr 30 22:28:12 2003
@@ -1752,7 +1752,6 @@
 
 	strcpy(ACCESS_FBINFO(fbcon.modename), "MATROX VGA");
 	ACCESS_FBINFO(fbcon.changevar) = NULL;
-	ACCESS_FBINFO(fbcon.node) = NODEV;
 	ACCESS_FBINFO(fbcon.fbops) = &matroxfb_ops;
 	ACCESS_FBINFO(fbcon.disp) = d;
 	ACCESS_FBINFO(fbcon.switch_con) = &matroxfb_switch;
@@ -1872,12 +1871,12 @@
 		goto failVideoIO;
 	}
 	printk("fb%d: %s frame buffer device\n",
-	       minor(ACCESS_FBINFO(fbcon.node)), ACCESS_FBINFO(fbcon.modename));
+	       ACCESS_FBINFO(fbcon.node), ACCESS_FBINFO(fbcon.modename));
 	if (ACCESS_FBINFO(fbcon.currcon) < 0) {
 		/* there is no console on this fb... but we have to initialize hardware
 		 * until someone tells me what is proper thing to do */
 		printk(KERN_INFO "fb%d: initializing hardware\n",
-			minor(ACCESS_FBINFO(fbcon.node)));
+			ACCESS_FBINFO(fbcon.node));
 		matroxfb_set_var(&vesafb_defined, -1, &ACCESS_FBINFO(fbcon));
 	}
 	return 0;
diff -Nru a/drivers/video/matrox/matroxfb_crtc2.c b/drivers/video/matrox/matroxfb_crtc2.c
--- a/drivers/video/matrox/matroxfb_crtc2.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/video/matrox/matroxfb_crtc2.c	Wed Apr 30 22:28:15 2003
@@ -747,7 +747,6 @@
 
 	strcpy(m2info->fbcon.modename, "MATROX CRTC2");
 	m2info->fbcon.changevar = NULL;
-	m2info->fbcon.node = NODEV;
 	m2info->fbcon.fbops = &matroxfb_dh_ops;
 	m2info->fbcon.disp = d;
 	m2info->fbcon.switch_con = &matroxfb_dh_switch;
@@ -816,7 +815,7 @@
 		return -1;
 	}
 	printk(KERN_INFO "matroxfb_crtc2: secondary head of fb%u was registered as fb%u\n",
-		minor(ACCESS_FBINFO(fbcon.node)), minor(m2info->fbcon.node));
+		ACCESS_FBINFO(fbcon.node), m2info->fbcon.node);
 	m2info->fbcon_registered = 1;
 	return 0;
 #undef minfo
@@ -839,7 +838,7 @@
 			printk(KERN_ERR "matroxfb_crtc2: Expect kernel crash after module unload.\n");
 			return;
 		}
-		id = minor(m2info->fbcon.node);
+		id = m2info->fbcon.node;
 		unregister_framebuffer(&m2info->fbcon);
 		kfree(m2info->fbcon.disp);
 		/* return memory back to primary head */
diff -Nru a/drivers/video/maxinefb.c b/drivers/video/maxinefb.c
--- a/drivers/video/maxinefb.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/video/maxinefb.c	Wed Apr 30 22:28:06 2003
@@ -155,7 +155,6 @@
 		 */
 	}
 
-	fb_info.node = NODEV;
 	fb_info.fbops = &maxinefb_ops;
 	fb_info.screen_base = (char *) maxinefb_fix.smem_start;
 	fb_info.var = maxinefb_defined;
diff -Nru a/drivers/video/neofb.c b/drivers/video/neofb.c
--- a/drivers/video/neofb.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/video/neofb.c	Wed Apr 30 22:28:11 2003
@@ -2021,7 +2021,7 @@
 		goto failed;
 
 	printk(KERN_INFO "fb%d: %s frame buffer device\n",
-	       minor(info->node), info->fix.id);
+	       info->node, info->fix.id);
 
 	/*
 	 * Our driver data
diff -Nru a/drivers/video/offb.c b/drivers/video/offb.c
--- a/drivers/video/offb.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/video/offb.c	Wed Apr 30 22:28:18 2003
@@ -523,7 +523,6 @@
 	var->sync = 0;
 	var->vmode = FB_VMODE_NONINTERLACED;
 
-	info->node = NODEV;
 	info->fbops = &offb_ops;
 	info->screen_base = ioremap(address, fix->smem_len);
 	info->par = par;
@@ -539,7 +538,7 @@
 	}
 
 	printk(KERN_INFO "fb%d: Open Firmware frame buffer device on %s\n",
-	       minor(info->node), full_name);
+	       info->node, full_name);
 }
 
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/video/p9100.c b/drivers/video/p9100.c
--- a/drivers/video/p9100.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/video/p9100.c	Wed Apr 30 22:28:13 2003
@@ -298,7 +298,6 @@
 		sbus_ioremap(&sdev->resource[0], 0,
 			     sizeof(struct p9100_regs), "p9100 regs");
 
-	all->info.node = NODEV;
 	all->info.flags = FBINFO_FLAG_DEFAULT;
 	all->info.fbops = &p9100_ops;
 #ifdef CONFIG_SPARC32
diff -Nru a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c
--- a/drivers/video/platinumfb.c	Wed Apr 30 22:28:08 2003
+++ b/drivers/video/platinumfb.c	Wed Apr 30 22:28:08 2003
@@ -327,7 +327,6 @@
 {
 	/* Fill fb_info */
 	info->par = &p->par;
-	info->node = NODEV;
 	info->fbops = &platinumfb_ops;
 	info->pseudo_palette = p->pseudo_palette;
         info->flags = FBINFO_FLAG_DEFAULT;
@@ -409,7 +408,7 @@
 		return 0;
 
 	printk(KERN_INFO "fb%d: platinum frame buffer device\n",
-	       minor(p->info.node));
+	       p->info.node);
 
 	return 1;
 }
diff -Nru a/drivers/video/pm2fb.c b/drivers/video/pm2fb.c
--- a/drivers/video/pm2fb.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/video/pm2fb.c	Wed Apr 30 22:28:20 2003
@@ -2269,7 +2269,6 @@
 	fb_info.gen.parsize=sizeof(struct pm2fb_par);
 	fb_info.gen.fbhw=&pm2fb_hwswitch;
 	strcpy(fb_info.gen.info.modename, permedia2_name);
-	fb_info.gen.info.node = NODEV;
 	fb_info.gen.info.flags=FBINFO_FLAG_DEFAULT;
 	fb_info.gen.info.fbops=&pm2fb_ops;
 	fb_info.gen.info.disp=&fb_info.disp;
@@ -2288,7 +2287,7 @@
 		return -EINVAL;
 	}
 	printk(KERN_INFO "fb%d: %s (%s), using %uK of video memory.\n",
-				minor(fb_info.gen.info.node),
+				fb_info.gen.info.node,
 				board_table[fb_info.board].name,
 				permedia2_name,
 				(u32 )(fb_info.regions.fb_size>>10));
diff -Nru a/drivers/video/pm3fb.c b/drivers/video/pm3fb.c
--- a/drivers/video/pm3fb.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/video/pm3fb.c	Wed Apr 30 22:28:06 2003
@@ -1602,7 +1602,6 @@
 	disp[l_fb_info->board_num].scrollmode = 0;	/* SCROLL_YNOMOVE; *//* 0 means "let fbcon choose" */
 	l_fb_info->gen.parsize = sizeof(struct pm3fb_par);
 	l_fb_info->gen.info.changevar = NULL;
-	l_fb_info->gen.info.node = B_FREE;
 	l_fb_info->gen.info.fbops = &pm3fb_ops;
 	l_fb_info->gen.info.disp = &(disp[l_fb_info->board_num]);
 	if (fontn[l_fb_info->board_num][0])
@@ -1646,7 +1645,7 @@
 	pm3fb_write_mode(l_fb_info);
 	
 	printk("fb%d: %s, using %uK of video memory (%s)\n",
-	       minor(l_fb_info->gen.info.node),
+	       l_fb_info->gen.info.node,
 	       permedia3_name, (u32) (l_fb_info->fb_size >> 10),
 	       cardbase[l_fb_info->board_type].cardname);
 }
diff -Nru a/drivers/video/pmag-ba-fb.c b/drivers/video/pmag-ba-fb.c
--- a/drivers/video/pmag-ba-fb.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/video/pmag-ba-fb.c	Wed Apr 30 22:28:18 2003
@@ -138,7 +138,6 @@
 	/*
 	 *      Let there be consoles..
 	 */
-	info->node = NODEV;
 	info->fbops = &pmagbafb_ops;
 	info->var = pmagbafb_defined;
 	info->fix = pmagbafb_fix; 
diff -Nru a/drivers/video/pmagb-b-fb.c b/drivers/video/pmagb-b-fb.c
--- a/drivers/video/pmagb-b-fb.c	Wed Apr 30 22:28:10 2003
+++ b/drivers/video/pmagb-b-fb.c	Wed Apr 30 22:28:10 2003
@@ -141,7 +141,6 @@
 	/*
 	 *      Let there be consoles..
 	 */
-	info->node = NODEV;
 	info->fbops = &pmagbbfb_ops;
 	info->var = pmagbbfb_defined;
 	info->fix = pmagbbfb_fix;
diff -Nru a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
--- a/drivers/video/pvr2fb.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/video/pvr2fb.c	Wed Apr 30 22:28:04 2003
@@ -246,7 +246,7 @@
 static void pvr2_update_display(void);
 static void pvr2_init_display(void);
 static void pvr2_do_blank(void);
-static void pvr2fb_interrupt(int irq, void *dev_id, struct pt_regs *fp);
+static irqreturn_t pvr2fb_interrupt(int irq, void *dev_id, struct pt_regs *fp);
 static int pvr2_init_cable(void);
 static int pvr2_get_param(const struct pvr2_params *p, const char *s,
                             int val, int size);
@@ -939,7 +939,7 @@
 	is_blanked = do_blank > 0 ? do_blank : 0;
 }
 
-static void pvr2fb_interrupt(int irq, void *dev_id, struct pt_regs *fp)
+static irqreturn_t pvr2fb_interrupt(int irq, void *dev_id, struct pt_regs *fp)
 {
 	if (do_vmode_pan || do_vmode_full)
 		pvr2_update_display();
@@ -958,6 +958,7 @@
 	if (do_vmode_full) {
 		do_vmode_full = 0;
 	}
+	return IRQ_HANDLED;
 }
 
 /*
@@ -1020,7 +1021,6 @@
 	
 	strcpy(fb_info.modename, pvr2fb_name);
 	fb_info.changevar = NULL;
-	fb_info.node = NODEV;
 	fb_info.fbops = &pvr2fb_ops;
 	fb_info.screen_base = (char *) videomemory;
 	fb_info.disp = &disp;
@@ -1059,10 +1059,10 @@
 	modememused = get_line_length(var.xres_virtual, var.bits_per_pixel);
 	modememused *= var.yres_virtual;
 	printk("fb%d: %s frame buffer device, using %ldk/%ldk of video memory\n",
-	       minor(fb_info.node), fb_info.modename, modememused>>10,
+	       fb_info.node, fb_info.modename, modememused>>10,
 	       videomemorysize>>10);
 	printk("fb%d: Mode %dx%d-%d pitch = %ld cable: %s video output: %s\n", 
-	       minor(fb_info.node), var.xres, var.yres, var.bits_per_pixel, 
+	       fb_info.node, var.xres, var.yres, var.bits_per_pixel, 
 	       get_line_length(var.xres, var.bits_per_pixel),
 	       (char *)pvr2_get_param(cables, NULL, cable_type, 3),
 	       (char *)pvr2_get_param(outputs, NULL, video_output, 3));
diff -Nru a/drivers/video/q40fb.c b/drivers/video/q40fb.c
--- a/drivers/video/q40fb.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/video/q40fb.c	Wed Apr 30 22:28:06 2003
@@ -105,7 +105,6 @@
 	
 	fb_info.var = q40fb_var;
 	fb_info.fix = q40fb_fix;
-	fb_info.node = NODEV;
 	fb_info.fbops = &q40fb_ops;
 	fb_info.flags = FBINFO_FLAG_DEFAULT;  /* not as module for now */
 	fb_info.pseudo_palette = pseudo_palette;	
@@ -121,7 +120,7 @@
 	}
 
         printk(KERN_INFO "fb%d: Q40 frame buffer alive and kicking !\n",
-	       minor(fb_info.node));
+	       fb_info.node);
 	return 0;
 }
 
diff -Nru a/drivers/video/radeonfb.c b/drivers/video/radeonfb.c
--- a/drivers/video/radeonfb.c	Wed Apr 30 22:28:18 2003
+++ b/drivers/video/radeonfb.c	Wed Apr 30 22:28:18 2003
@@ -2237,7 +2237,6 @@
 	info->currcon = -1;
 	info->par = rinfo;
 	info->pseudo_palette = rinfo->pseudo_palette;
-        info->node = NODEV;
         info->flags = FBINFO_FLAG_DEFAULT;
         info->fbops = &radeonfb_ops;
         info->display_fg = NULL;
diff -Nru a/drivers/video/retz3fb.c b/drivers/video/retz3fb.c
--- a/drivers/video/retz3fb.c	Wed Apr 30 22:28:16 2003
+++ b/drivers/video/retz3fb.c	Wed Apr 30 22:28:16 2003
@@ -1403,7 +1403,6 @@
 
 		strcpy(fb_info->modename, retz3fb_name);
 		fb_info->changevar = NULL;
-		fb_info->node = NODEV;
 		fb_info->fbops = &retz3fb_ops;
 		fb_info->screen_base = zinfo->fbmem;
 		fb_info->disp = &zinfo->disp;
@@ -1430,7 +1429,7 @@
 			return -EINVAL;
 
 		printk(KERN_INFO "fb%d: %s frame buffer device, using %ldK of "
-		       "video memory\n", minor(fb_info->node),
+		       "video memory\n", fb_info->node,
 		       fb_info->modename, zinfo->fbsize>>10);
 
 		/* FIXME: This driver cannot be unloaded yet */
diff -Nru a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c
--- a/drivers/video/riva/fbdev.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/video/riva/fbdev.c	Wed Apr 30 22:28:13 2003
@@ -1581,7 +1581,6 @@
 	struct riva_par *par = (struct riva_par *) info->par;
 	unsigned int cmap_len;
 
-	info->node = NODEV;
 	info->flags = FBINFO_FLAG_DEFAULT;
 	info->var = rivafb_default_var;
 	info->fix = rivafb_fix;
diff -Nru a/drivers/video/sa1100fb.c b/drivers/video/sa1100fb.c
--- a/drivers/video/sa1100fb.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/video/sa1100fb.c	Wed Apr 30 22:28:06 2003
@@ -1395,7 +1395,7 @@
 /*
  *  sa1100fb_handle_irq: Handle 'LCD DONE' interrupts.
  */
-static void sa1100fb_handle_irq(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sa1100fb_handle_irq(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct sa1100fb_info *fbi = dev_id;
 	unsigned int lcsr = LCSR;
@@ -1406,6 +1406,7 @@
 	}
 
 	LCSR = lcsr;
+	return IRQ_HANDLED;
 }
 
 /*
@@ -1700,7 +1701,6 @@
 
 	fbi->fb.fbops		= &sa1100fb_ops;
 	fbi->fb.flags		= FBINFO_FLAG_DEFAULT;
-	fbi->fb.node		= NODEV;
 	fbi->fb.monspecs	= monspecs;
 	fbi->fb.currcon		= -1;
 	fbi->fb.pseudo_palette	= (fbi + 1);
diff -Nru a/drivers/video/sgivwfb.c b/drivers/video/sgivwfb.c
--- a/drivers/video/sgivwfb.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/video/sgivwfb.c	Wed Apr 30 22:28:09 2003
@@ -773,7 +773,6 @@
 	sgivwfb_fix.ywrapstep = ywrap;
 	sgivwfb_fix.ypanstep = ypan;
 
-	fb_info.node = NODEV;
 	fb_info.fix = sgivwfb_fix;
 
 	switch (flatpanel_id) {
@@ -807,7 +806,7 @@
 	}
 
 	printk(KERN_INFO "fb%d: SGI DBE frame buffer device, using %ldK of video memory at %#lx\n",      
-		minor(fb_info.node), sgivwfb_mem_size >> 10, sgivwfb_mem_phys);
+		fb_info.node, sgivwfb_mem_size >> 10, sgivwfb_mem_phys);
 	return 0;
 
 fail_register_framebuffer:
diff -Nru a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c
--- a/drivers/video/sis/sis_main.c	Wed Apr 30 22:28:12 2003
+++ b/drivers/video/sis/sis_main.c	Wed Apr 30 22:28:12 2003
@@ -4524,7 +4524,6 @@
 #endif
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)		/* ---- 2.5 series init ---- */
-		sis_fb_info.node = NODEV;
 		sis_fb_info.flags = FBINFO_FLAG_DEFAULT;
 		sis_fb_info.var = default_var;
 		sis_fb_info.fix = sisfb_fix;
@@ -4571,7 +4570,7 @@
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
 		printk(KERN_INFO "fb%d: %s frame buffer device, Version %d.%d.%02d\n",
-	       		minor(sis_fb_info.node), myid, VER_MAJOR, VER_MINOR, VER_LEVEL);			     
+	       		sis_fb_info.node, myid, VER_MAJOR, VER_MINOR, VER_LEVEL);			     
 #endif
 
 	}	/* TW: if mode = "none" */
diff -Nru a/drivers/video/skeletonfb.c b/drivers/video/skeletonfb.c
--- a/drivers/video/skeletonfb.c	Wed Apr 30 22:28:05 2003
+++ b/drivers/video/skeletonfb.c	Wed Apr 30 22:28:05 2003
@@ -536,7 +536,6 @@
      * space via ioremap. Consult ioport.h. 
      */
     info.screen_base = framebuffer_virtual_memory;	
-    info.node = NODEV;
     info.fbops = &xxxfb_ops;
     info.fix = xxxfb_fix;
     info.pseudo_palette = pseudo_palette;
@@ -566,7 +565,7 @@
 	
     if (register_framebuffer(&info) < 0)
 	return -EINVAL;
-    printk(KERN_INFO "fb%d: %s frame buffer device\n", minor(info.node),
+    printk(KERN_INFO "fb%d: %s frame buffer device\n", info.node,
 	   info.fix.id);
     return 0;
 }
diff -Nru a/drivers/video/sstfb.c b/drivers/video/sstfb.c
--- a/drivers/video/sstfb.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/video/sstfb.c	Wed Apr 30 22:28:11 2003
@@ -1474,7 +1474,6 @@
 	f_ddprintk("membase_phys: %#lx\n", fix->smem_start);
 	f_ddprintk("fbbase_virt: %p\n", info->screen_base);
 
-	info->node	= NODEV;
 	info->flags	= FBINFO_FLAG_DEFAULT;
 	info->fbops	= &sstfb_ops;
 	info->currcon	= -1;
@@ -1520,7 +1519,7 @@
 		sstfb_drawdebugimage(info);
 
 	printk(KERN_INFO "fb%d: %s frame buffer device at 0x%p\n",
-	       minor(info->node), fix->id, info->screen_base);
+	       info->node, fix->id, info->screen_base);
 
 	return 0;
 
diff -Nru a/drivers/video/stifb.c b/drivers/video/stifb.c
--- a/drivers/video/stifb.c	Wed Apr 30 22:28:20 2003
+++ b/drivers/video/stifb.c	Wed Apr 30 22:28:20 2003
@@ -1277,7 +1277,6 @@
 	var->bits_per_pixel = bpp;
 
 	strcpy(fix->id, "stifb");
-	info->node = NODEV;
 	info->fbops = &stifb_ops;
 	info->screen_base = (void*) REGION_BASE(fb,1);
 	info->flags = FBINFO_FLAG_DEFAULT;
@@ -1306,7 +1305,7 @@
 
 	printk(KERN_INFO 
 	    "fb%d: %s %dx%d-%d frame buffer device, id: %04x, mmio: 0x%04lx\n",
-		minor(fb->info.node), 
+		fb->info.node, 
 		fix->id,
 		var->xres, 
 		var->yres,
diff -Nru a/drivers/video/sun3fb.c b/drivers/video/sun3fb.c
--- a/drivers/video/sun3fb.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/video/sun3fb.c	Wed Apr 30 22:28:06 2003
@@ -569,7 +569,6 @@
 	fix->type = FB_TYPE_PACKED_PIXELS;
 	fix->visual = FB_VISUAL_PSEUDOCOLOR;
 	
-	fb->info.node = NODEV;
 	fb->info.fbops = &sun3fb_ops;
 	fb->info.disp = disp;
 	fb->info.currcon = -1;
@@ -646,7 +645,7 @@
 		kfree(fb);
 		return -EINVAL;
 	}
-	printk("fb%d: %s\n", minor(fb->info.node), p);
+	printk("fb%d: %s\n", fb->info.node, p);
 
 	return 0;
 }
diff -Nru a/drivers/video/tcx.c b/drivers/video/tcx.c
--- a/drivers/video/tcx.c	Wed Apr 30 22:28:03 2003
+++ b/drivers/video/tcx.c	Wed Apr 30 22:28:03 2003
@@ -374,7 +374,6 @@
 		all->par.mmap_map[i].poff = sdev->reg_addrs[j].phys_addr;
 	}
 
-	all->info.node = NODEV;
 	all->info.flags = FBINFO_FLAG_DEFAULT;
 	all->info.fbops = &tcx_ops;
 #ifdef CONFIG_SPARC32
diff -Nru a/drivers/video/tdfxfb.c b/drivers/video/tdfxfb.c
--- a/drivers/video/tdfxfb.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/video/tdfxfb.c	Wed Apr 30 22:28:06 2003
@@ -1218,7 +1218,6 @@
 	tdfx_fix.ypanstep	= nopan ? 0 : 1;
 	tdfx_fix.ywrapstep	= nowrap ? 0 : 1;
    
-	info->node		= NODEV;
 	info->fbops		= &tdfxfb_ops;
 	info->fix		= tdfx_fix; 	
 	info->par		= default_par;
diff -Nru a/drivers/video/tgafb.c b/drivers/video/tgafb.c
--- a/drivers/video/tgafb.c	Wed Apr 30 22:28:13 2003
+++ b/drivers/video/tgafb.c	Wed Apr 30 22:28:13 2003
@@ -1425,7 +1425,6 @@
 	pci_read_config_byte(pdev, PCI_REVISION_ID, &all->par.tga_chip_rev);
 
 	/* Setup framebuffer.  */
-	all->info.node = NODEV;
 	all->info.flags = FBINFO_FLAG_DEFAULT;
 	all->info.fbops = &tgafb_ops;
 	all->info.screen_base = (char *) all->par.tga_fb_base;
@@ -1465,7 +1464,7 @@
 	       pdev->bus->number, PCI_SLOT(pdev->devfn),
 	       PCI_FUNC(pdev->devfn));
 	printk(KERN_INFO "fb%d: %s frame buffer device at 0x%lx\n",
-	       minor(all->info.node), all->info.fix.id, bar0_start);
+	       all->info.node, all->info.fix.id, bar0_start);
 
 	return 0;
 
diff -Nru a/drivers/video/tridentfb.c b/drivers/video/tridentfb.c
--- a/drivers/video/tridentfb.c	Wed Apr 30 22:28:09 2003
+++ b/drivers/video/tridentfb.c	Wed Apr 30 22:28:09 2003
@@ -1140,7 +1140,6 @@
 		nativex = get_nativex();
 
 	fb_info.fix = tridentfb_fix;
-	fb_info.node = NODEV;
 	fb_info.fbops = &tridentfb_ops;
 
 
@@ -1161,7 +1160,7 @@
 		return -EINVAL;
 	}
 	output("fb%d: %s frame buffer device %dx%d-%dbpp\n",
-	   minor(fb_info.node), fb_info.fix.id,default_var.xres,
+	   fb_info.node, fb_info.fix.id,default_var.xres,
 	   default_var.yres,default_var.bits_per_pixel);
 	return 0;
 }
diff -Nru a/drivers/video/tx3912fb.c b/drivers/video/tx3912fb.c
--- a/drivers/video/tx3912fb.c	Wed Apr 30 22:28:11 2003
+++ b/drivers/video/tx3912fb.c	Wed Apr 30 22:28:11 2003
@@ -292,7 +292,6 @@
 	if ((tx3912fb_fix.line_length * tx3912fb_var.yres_virtual) > tx3912fb_fix.smem_len)
 		return -ENOMEM;
 
-	fb_info.node = NODEV;
 	fb_info.fbops = &tx3912fb_ops;
 	fb_info.var = tx3912fb_var;
 	fb_info.fix = tx3912fb_fix;
@@ -309,7 +308,7 @@
 		return -1;
 
 	printk(KERN_INFO "fb%d: TX3912 frame buffer using %uKB.\n",
-	       minor(fb_info.node), (u_int) (fb_info.fix.smem_len >> 10));
+	       fb_info.node, (u_int) (fb_info.fix.smem_len >> 10));
 	return 0;
 }
 
diff -Nru a/drivers/video/valkyriefb.c b/drivers/video/valkyriefb.c
--- a/drivers/video/valkyriefb.c	Wed Apr 30 22:28:15 2003
+++ b/drivers/video/valkyriefb.c	Wed Apr 30 22:28:15 2003
@@ -447,7 +447,7 @@
 		return;
 	}
 	
-	printk(KERN_INFO "fb%d: valkyrie frame buffer device\n", GET_FB_IDX(p->info.node));	
+	printk(KERN_INFO "fb%d: valkyrie frame buffer device\n", p->info.node);	
 }
 
 static void valkyrie_set_par(const struct fb_par_valkyrie *par,
@@ -715,7 +715,6 @@
 static void __init valkyrie_init_info(struct fb_info *info, struct fb_info_valkyrie *p)
 {
 	strcpy(info->modename, p->fix.id);
-	info->node = NODEV;
 	info->fbops = &valkyriefb_ops;
 	info->screen_base = (char *) p->frame_buffer + 0x1000;
 	info->disp = &p->disp;
diff -Nru a/drivers/video/vesafb.c b/drivers/video/vesafb.c
--- a/drivers/video/vesafb.c	Wed Apr 30 22:28:04 2003
+++ b/drivers/video/vesafb.c	Wed Apr 30 22:28:04 2003
@@ -359,7 +359,6 @@
 		}
 	}
 	
-	fb_info.node = NODEV;
 	fb_info.fbops = &vesafb_ops;
 	fb_info.var = vesafb_defined;
 	fb_info.fix = vesafb_fix;
@@ -372,7 +371,7 @@
 		return -EINVAL;
 
 	printk(KERN_INFO "fb%d: %s frame buffer device\n",
-	       minor(fb_info.node), fb_info.fix.id);
+	       fb_info.node, fb_info.fix.id);
 	return 0;
 }
 
diff -Nru a/drivers/video/vfb.c b/drivers/video/vfb.c
--- a/drivers/video/vfb.c	Wed Apr 30 22:28:02 2003
+++ b/drivers/video/vfb.c	Wed Apr 30 22:28:02 2003
@@ -426,7 +426,6 @@
 	memset(videomemory, 0, videomemorysize);
 
 	fb_info.screen_base = videomemory;
-	fb_info.node = NODEV;
 	fb_info.fbops = &vfb_ops;
 
 	retval = fb_find_mode(&fb_info.var, &fb_info, NULL,
@@ -447,7 +446,7 @@
 
 	printk(KERN_INFO
 	       "fb%d: Virtual frame buffer device, using %ldK of video memory\n",
-	       minor(fb_info.node), videomemorysize >> 10);
+	       fb_info.node, videomemorysize >> 10);
 	return 0;
 }
 
diff -Nru a/drivers/video/vga16fb.c b/drivers/video/vga16fb.c
--- a/drivers/video/vga16fb.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/video/vga16fb.c	Wed Apr 30 22:28:06 2003
@@ -1364,7 +1364,6 @@
 	vga16fb_defined.blue.length  = i;	
 
 	/* name should not depend on EGA/VGA */
-	vga16fb.node = NODEV;
 	vga16fb.fbops = &vga16fb_ops;
 	vga16fb.var = vga16fb_defined;
 	vga16fb.fix = vga16fb_fix;
@@ -1385,7 +1384,7 @@
 	}
 
 	printk(KERN_INFO "fb%d: %s frame buffer device\n",
-	       minor(vga16fb.node), vga16fb.fix.id);
+	       vga16fb.node, vga16fb.fix.id);
 
 	return 0;
 }
diff -Nru a/drivers/video/virgefb.c b/drivers/video/virgefb.c
--- a/drivers/video/virgefb.c	Wed Apr 30 22:28:06 2003
+++ b/drivers/video/virgefb.c	Wed Apr 30 22:28:06 2003
@@ -1783,7 +1783,6 @@
 	fbhw = &virgefb_hw_switch;
 	strcpy(fb_info.modename, virgefb_name);
 	fb_info.changevar = NULL;
-	fb_info.node = NODEV;
 	fb_info.fbops = &virgefb_ops;
 	fb_info.disp = &disp;
 	fb_info.currcon = -1;
@@ -1806,7 +1805,7 @@
 	}
 
 	printk(KERN_INFO "fb%d: %s frame buffer device, using %ldK of video memory\n",
-	       minor(fb_info.node), fb_info.modename, v_ram_size>>10);
+	       fb_info.node, fb_info.modename, v_ram_size>>10);
 
 	/* TODO: This driver cannot be unloaded yet */
 
diff -Nru a/fs/Kconfig b/fs/Kconfig
--- a/fs/Kconfig	Wed Apr 30 22:28:10 2003
+++ b/fs/Kconfig	Wed Apr 30 22:28:10 2003
@@ -26,7 +26,7 @@
 	  by about 44 KB.
 
 	  The Ext2fs-Undeletion mini-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, gives information about
+	  <http://www.tldp.org/docs.html#howto>, gives information about
 	  how to retrieve deleted files on ext2fs file systems.
 
 	  To change the behavior of ext2 file systems, you can use the tune2fs
@@ -135,7 +135,7 @@
 # CONFIG_JBD could be its own option (even modular), but until there are
 # other users than ext3, we will simply make it be the same as CONFIG_EXT3_FS
 # dep_tristate '  Journal Block Device support (JBD for ext3)' CONFIG_JBD $CONFIG_EXT3_FS
-	bool
+	tristate
 	default EXT3_FS
 	help
 	  This is a generic journaling layer for block devices.  It is
@@ -386,7 +386,7 @@
 	  in order to use quota support (you can download sources from
 	  <http://www.sf.net/projects/linuxquota/>). For further details, read
 	  the Quota mini-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. Probably the quota
+	  <http://www.tldp.org/docs.html#howto>. Probably the quota
 	  support is only useful for multi user systems. If unsure, say N.
 
 config QFMT_V1
@@ -469,7 +469,7 @@
 	  driver.  If you have a CD-ROM drive and want to do more with it than
 	  just listen to audio CDs and watch its LEDs, say Y (and read
 	  <file:Documentation/filesystems/isofs.txt> and the CD-ROM-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>), thereby
+	  available from <http://www.tldp.org/docs.html#howto>), thereby
 	  enlarging your kernel by about 27 KB; otherwise say N.
 
 	  If you want to compile this as a module ( = code which can be
@@ -576,7 +576,7 @@
 	  they are compressed; to access compressed MSDOS partitions under
 	  Linux, you can either use the DOS emulator DOSEMU, described in the
 	  DOSEMU-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, or try dmsdosfs in
+	  <http://www.tldp.org/docs.html#howto>, or try dmsdosfs in
 	  <ftp://ibiblio.org/pub/Linux/system/filesystems/dosfs/>. If you
 	  intend to use dosemu with a non-compressed MSDOS partition, say Y
 	  here) and MSDOS floppies. This means that file access becomes
@@ -1233,7 +1233,7 @@
 	  programs nfsd and mountd (but does not need to have NFS file system
 	  support enabled in its kernel). NFS is explained in the Network
 	  Administrator's Guide, available from
-	  <http://www.linuxdoc.org/docs.html#guide>, on its man page: "man
+	  <http://www.tldp.org/docs.html#guide>, on its man page: "man
 	  nfs", and in the NFS-HOWTO.
 
 	  A superior but less widely used alternative to NFS is provided by
@@ -1298,7 +1298,7 @@
 	  as well.
 
 	  Please read the NFS-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  The NFS server is also available as a module ( = code which can be
 	  inserted in and removed from the running kernel whenever you want).
@@ -1398,7 +1398,7 @@
 	  works only if the Windows machines use TCP/IP as the underlying
 	  transport protocol, and not NetBEUI.  For details, read
 	  <file:Documentation/filesystems/smbfs.txt> and the SMB-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>.
+	  available from <http://www.tldp.org/docs.html#howto>.
 
 	  Note: if you just want your box to act as an SMB *server* and make
 	  files and printing services available to Windows clients (which need
@@ -1475,7 +1475,7 @@
 	  to mount NetWare file server volumes and to access them just like
 	  any other Unix directory.  For details, please read the file
 	  <file:Documentation/filesystems/ncpfs.txt> in the kernel source and
-	  the IPX-HOWTO from <http://www.linuxdoc.org/docs.html#howto>.
+	  the IPX-HOWTO from <http://www.tldp.org/docs.html#howto>.
 
 	  You do not have to say Y here if you want your Linux box to act as a
 	  file *server* for Novell NetWare clients.
diff -Nru a/fs/aio.c b/fs/aio.c
--- a/fs/aio.c	Wed Apr 30 22:28:08 2003
+++ b/fs/aio.c	Wed Apr 30 22:28:08 2003
@@ -148,7 +148,7 @@
 
 	dprintk("mmap address: 0x%08lx\n", info->mmap_base);
 	info->nr_pages = get_user_pages(current, ctx->mm,
-					info->mmap_base, info->mmap_size, 
+					info->mmap_base, nr_pages, 
 					1, 0, info->ring_pages, NULL);
 	up_write(&ctx->mm->mmap_sem);
 
diff -Nru a/fs/binfmt_misc.c b/fs/binfmt_misc.c
--- a/fs/binfmt_misc.c	Wed Apr 30 22:28:07 2003
+++ b/fs/binfmt_misc.c	Wed Apr 30 22:28:07 2003
@@ -53,7 +53,7 @@
 
 static rwlock_t entries_lock __attribute__((unused)) = RW_LOCK_UNLOCKED;
 static struct vfsmount *bm_mnt;
-static int entry_count = 0;
+static int entry_count;
 
 /* 
  * Check if we support the binfmt
@@ -399,19 +399,7 @@
 
 static void bm_clear_inode(struct inode *inode)
 {
-	Node *e = inode->u.generic_ip;
-
-	if (e) {
-		struct vfsmount *mnt;
-		write_lock(&entries_lock);
-		list_del(&e->list);
-		mnt = bm_mnt;
-		if (!--entry_count)
-			bm_mnt = NULL;
-		write_unlock(&entries_lock);
-		kfree(e);
-		mntput(mnt);
-	}
+	kfree(inode->u.generic_ip);
 }
 
 static void kill_node(Node *e)
@@ -430,6 +418,7 @@
 		dentry->d_inode->i_nlink--;
 		d_drop(dentry);
 		dput(dentry);
+		simple_release_fs(&bm_mnt, &entry_count);
 	}
 }
 
@@ -498,8 +487,6 @@
 	.write		= bm_entry_write,
 };
 
-static struct file_system_type bm_fs_type;
-
 /* /register */
 
 static ssize_t bm_register_write(struct file *file, const char *buffer,
@@ -507,7 +494,6 @@
 {
 	Node *e;
 	struct inode *inode;
-	struct vfsmount *mnt = NULL;
 	struct dentry *root, *dentry;
 	struct super_block *sb = file->f_vfsmnt->mnt_sb;
 	int err = 0;
@@ -534,32 +520,22 @@
 	if (!inode)
 		goto out2;
 
-	write_lock(&entries_lock);
-	if (!bm_mnt) {
-		write_unlock(&entries_lock);
-		mnt = kern_mount(&bm_fs_type);
-		if (IS_ERR(mnt)) {
-			err = PTR_ERR(mnt);
-			iput(inode);
-			inode = NULL;
-			goto out2;
-		}
-		write_lock(&entries_lock);
-		if (!bm_mnt)
-			bm_mnt = mnt;
+	err = simple_pin_fs("binfmt_misc", &bm_mnt, &entry_count);
+	if (err) {
+		iput(inode);
+		inode = NULL;
+		goto out2;
 	}
-	mntget(bm_mnt);
-	entry_count++;
 
 	e->dentry = dget(dentry);
 	inode->u.generic_ip = e;
 	inode->i_fop = &bm_entry_operations;
-	d_instantiate(dentry, inode);
 
+	write_lock(&entries_lock);
+	d_instantiate(dentry, inode);
 	list_add(&e->list, &entries);
 	write_unlock(&entries_lock);
 
-	mntput(mnt);
 	err = 0;
 out2:
 	dput(dentry);
@@ -630,64 +606,20 @@
 
 static struct super_operations s_ops = {
 	.statfs		= simple_statfs,
-	.drop_inode	= generic_delete_inode,
 	.clear_inode	= bm_clear_inode,
 };
 
 static int bm_fill_super(struct super_block * sb, void * data, int silent)
 {
-	struct qstr names[2] = {{.name = "status"}, {.name = "register"}};
-	struct inode * inode;
-	struct dentry * dentry[3];
-	int i;
-
-	for (i=0; i<sizeof(names)/sizeof(names[0]); i++) {
-		names[i].len = strlen(names[i].name);
-		names[i].hash = full_name_hash(names[i].name, names[i].len);
-	}
-
-	sb->s_blocksize = PAGE_CACHE_SIZE;
-	sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
-	sb->s_magic = 0x42494e4d;
-	sb->s_op = &s_ops;
-
-	inode = bm_get_inode(sb, S_IFDIR | 0755);
-	if (!inode)
-		return -ENOMEM;
-	inode->i_op = &simple_dir_inode_operations;
-	inode->i_fop = &simple_dir_operations;
-	dentry[0] = d_alloc_root(inode);
-	if (!dentry[0]) {
-		iput(inode);
-		return -ENOMEM;
-	}
-	dentry[1] = d_alloc(dentry[0], &names[0]);
-	if (!dentry[1])
-		goto out1;
-	dentry[2] = d_alloc(dentry[0], &names[1]);
-	if (!dentry[2])
-		goto out2;
-	inode = bm_get_inode(sb, S_IFREG | 0644);
-	if (!inode)
-		goto out3;
-	inode->i_fop = &bm_status_operations;
-	d_add(dentry[1], inode);
-	inode = bm_get_inode(sb, S_IFREG | 0400);
-	if (!inode)
-		goto out3;
-	inode->i_fop = &bm_register_operations;
-	d_add(dentry[2], inode);
-
-	sb->s_root = dentry[0];
-	return 0;
-
-out3:
-	dput(dentry[2]);
-out2:
-	dput(dentry[1]);
-out1:
-	dput(dentry[0]);
-	return -ENOMEM;
+	static struct tree_descr bm_files[] = {
+		[1] = {"status", &bm_status_operations, S_IWUSR|S_IRUGO},
+		[2] = {"register", &bm_register_operations, S_IWUSR},
+		/* last one */ {""}
+	};
+	int err = simple_fill_super(sb, 0x42494e4d, bm_files);
+	if (!err)
+		sb->s_op = &s_ops;
+	return err;
 }
 
 static struct super_block *bm_get_sb(struct file_system_type *fs_type,
diff -Nru a/fs/bio.c b/fs/bio.c
--- a/fs/bio.c	Wed Apr 30 22:28:10 2003
+++ b/fs/bio.c	Wed Apr 30 22:28:10 2003
@@ -434,19 +434,9 @@
 	return len;
 }
 
-/**
- *	bio_map_user	-	map user address into bio
- *	@bdev: destination block device
- *	@uaddr: start of user address
- *	@len: length in bytes
- *	@write_to_vm: bool indicating writing to pages or not
- *
- *	Map the user space address into a bio suitable for io to a block
- *	device. Caller should check the size of the returned bio, we might
- *	not have mapped the entire range specified.
- */
-struct bio *bio_map_user(struct block_device *bdev, unsigned long uaddr,
-			 unsigned int len, int write_to_vm)
+static struct bio *__bio_map_user(struct block_device *bdev,
+				  unsigned long uaddr, unsigned int len,
+				  int write_to_vm)
 {
 	unsigned long end = (uaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
 	unsigned long start = uaddr >> PAGE_SHIFT;
@@ -510,8 +500,11 @@
 	kfree(pages);
 
 	/*
-	 * check if the mapped pages need bouncing for an isa host.
+	 * set data direction, and check if mapped pages need bouncing
 	 */
+	if (!write_to_vm)
+		bio->bi_rw |= (1 << BIO_RW);
+
 	blk_queue_bounce(q, &bio);
 	return bio;
 out:
@@ -521,17 +514,42 @@
 }
 
 /**
- *	bio_unmap_user	-	unmap a bio
- *	@bio:		the bio being unmapped
- *	@write_to_vm:	bool indicating whether pages were written to
- *
- *	Unmap a bio previously mapped by bio_map_user(). The @write_to_vm
- *	must be the same as passed into bio_map_user(). Must be called with
- *	a process context.
+ *	bio_map_user	-	map user address into bio
+ *	@bdev: destination block device
+ *	@uaddr: start of user address
+ *	@len: length in bytes
+ *	@write_to_vm: bool indicating writing to pages or not
  *
- *	bio_unmap_user() may sleep.
+ *	Map the user space address into a bio suitable for io to a block
+ *	device.
  */
-void bio_unmap_user(struct bio *bio, int write_to_vm)
+struct bio *bio_map_user(struct block_device *bdev, unsigned long uaddr,
+			 unsigned int len, int write_to_vm)
+{
+	struct bio *bio;
+
+	bio = __bio_map_user(bdev, uaddr, len, write_to_vm);
+
+	if (bio) {
+		if (bio->bi_size < len) {
+			bio_endio(bio, bio->bi_size, 0);
+			bio_unmap_user(bio, 0);
+			return NULL;
+		}
+
+		/*
+		 * subtle -- if __bio_map_user() ended up bouncing a bio,
+		 * it would normally disappear when its bi_end_io is run.
+		 * however, we need it for the unmap, so grab an extra
+		 * reference to it
+		 */
+		bio_get(bio);
+	}
+
+	return bio;
+}
+
+static void __bio_unmap_user(struct bio *bio, int write_to_vm)
 {
 	struct bio_vec *bvec;
 	int i;
@@ -558,6 +576,23 @@
 		page_cache_release(bvec->bv_page);
 	}
 
+	bio_put(bio);
+}
+
+/**
+ *	bio_unmap_user	-	unmap a bio
+ *	@bio:		the bio being unmapped
+ *	@write_to_vm:	bool indicating whether pages were written to
+ *
+ *	Unmap a bio previously mapped by bio_map_user(). The @write_to_vm
+ *	must be the same as passed into bio_map_user(). Must be called with
+ *	a process context.
+ *
+ *	bio_unmap_user() may sleep.
+ */
+void bio_unmap_user(struct bio *bio, int write_to_vm)
+{
+	__bio_unmap_user(bio, write_to_vm);
 	bio_put(bio);
 }
 
diff -Nru a/fs/block_dev.c b/fs/block_dev.c
--- a/fs/block_dev.c	Wed Apr 30 22:28:20 2003
+++ b/fs/block_dev.c	Wed Apr 30 22:28:20 2003
@@ -437,6 +437,23 @@
 }
 
 /*
+ * Tries to open block device by device number.  Use it ONLY if you
+ * really do not have anything better - i.e. when you are behind a
+ * truly sucky interface and all you are given is a device number.  _Never_
+ * to be used for internal purposes.  If you ever need it - reconsider
+ * your API.
+ */
+struct block_device *open_by_devnum(dev_t dev, unsigned mode, int kind)
+{
+	struct block_device *bdev = bdget(dev);
+	int err = -ENOMEM;
+	int flags = mode & FMODE_WRITE ? O_RDWR : O_RDONLY;
+	if (bdev)
+		err = blkdev_get(bdev, mode, flags, kind);
+	return err ? ERR_PTR(err) : bdev;
+}
+
+/*
  * This routine checks whether a removable media has been changed,
  * and invalidates all buffer-cache-entries in that case. This
  * is a relatively slow routine, so we have to try to minimize using
@@ -449,14 +466,13 @@
 {
 	struct gendisk *disk = bdev->bd_disk;
 	struct block_device_operations * bdops = disk->fops;
-	kdev_t dev = to_kdev_t(bdev->bd_dev);
 
 	if (!bdops->media_changed)
 		return 0;
 	if (!bdops->media_changed(bdev->bd_disk))
 		return 0;
 
-	if (invalidate_device(dev, 0))
+	if (__invalidate_device(bdev, 0))
 		printk("VFS: busy inodes on changed media.\n");
 
 	if (bdops->revalidate_disk)
@@ -466,36 +482,6 @@
 	return 1;
 }
 
-int full_check_disk_change(struct block_device *bdev)
-{
-	int res = 0;
-	if (bdev->bd_contains != bdev)
-		BUG();
-	down(&bdev->bd_sem);
-	if (check_disk_change(bdev) && bdev->bd_invalidated) {
-		rescan_partitions(bdev->bd_disk, bdev);
-		res = 1;
-	}
-	up(&bdev->bd_sem);
-	return res;
-}
-
-/*
- * Will die as soon as two remaining callers get converted.
- */
-int __check_disk_change(dev_t dev)
-{
-	struct block_device *bdev = bdget(dev);
-	int res;
-	if (!bdev)
-		return 0;
-	if (blkdev_get(bdev, FMODE_READ, 0, BDEV_RAW) < 0)
-		return 0;
-	res = full_check_disk_change(bdev);
-	blkdev_put(bdev, BDEV_RAW);
-	return res;
-}
-
 static void bd_set_size(struct block_device *bdev, loff_t size)
 {
 	unsigned bsize = bdev_hardsect_size(bdev);
@@ -549,7 +535,7 @@
 		} else {
 			struct hd_struct *p;
 			struct block_device *whole;
-			whole = bdget(MKDEV(disk->major, disk->first_minor));
+			whole = bdget_disk(disk, 0);
 			ret = -ENOMEM;
 			if (!whole)
 				goto out_first;
@@ -559,10 +545,10 @@
 			bdev->bd_contains = whole;
 			down(&whole->bd_sem);
 			whole->bd_part_count++;
-			p = disk->part + part - 1;
+			p = disk->part[part - 1];
 			bdev->bd_inode->i_data.backing_dev_info =
 			   whole->bd_inode->i_data.backing_dev_info;
-			if (!(disk->flags & GENHD_FL_UP) || !p->nr_sects) {
+			if (!(disk->flags & GENHD_FL_UP) || !p || !p->nr_sects) {
 				whole->bd_part_count--;
 				up(&whole->bd_sem);
 				ret = -ENXIO;
@@ -703,6 +689,15 @@
 	return generic_file_write_nolock(file, &local_iov, 1, ppos);
 }
 
+static ssize_t blkdev_file_aio_write(struct kiocb *iocb, const char *buf,
+				   size_t count, loff_t pos)
+{
+	struct iovec local_iov = { .iov_base = (void *)buf, .iov_len = count };
+
+	return generic_file_aio_write_nolock(iocb, &local_iov, 1, &iocb->ki_pos);
+}
+
+
 struct address_space_operations def_blk_aops = {
 	.readpage	= blkdev_readpage,
 	.writepage	= blkdev_writepage,
@@ -719,6 +714,8 @@
 	.llseek		= block_llseek,
 	.read		= generic_file_read,
 	.write		= blkdev_file_write,
+  	.aio_read	= generic_file_aio_read,
+  	.aio_write	= blkdev_file_aio_write, 
 	.mmap		= generic_file_mmap,
 	.fsync		= block_fsync,
 	.ioctl		= blkdev_ioctl,
diff -Nru a/fs/buffer.c b/fs/buffer.c
--- a/fs/buffer.c	Wed Apr 30 22:28:10 2003
+++ b/fs/buffer.c	Wed Apr 30 22:28:10 2003
@@ -447,15 +447,6 @@
 	invalidate_inode_pages(bdev->bd_inode->i_mapping);
 }
 
-void __invalidate_buffers(kdev_t dev, int destroy_dirty_buffers)
-{
-	struct block_device *bdev = bdget(kdev_t_to_nr(dev));
-	if (bdev) {
-		invalidate_bdev(bdev, destroy_dirty_buffers);
-		bdput(bdev);
-	}
-}
-
 /*
  * Kick pdflush then try to free up some ZONE_NORMAL memory.
  */
@@ -776,6 +767,85 @@
 EXPORT_SYMBOL(mark_buffer_dirty_inode);
 
 /*
+ * Add a page to the dirty page list.
+ *
+ * It is a sad fact of life that this function is called from several places
+ * deeply under spinlocking.  It may not sleep.
+ *
+ * If the page has buffers, the uptodate buffers are set dirty, to preserve
+ * dirty-state coherency between the page and the buffers.  It the page does
+ * not have buffers then when they are later attached they will all be set
+ * dirty.
+ *
+ * The buffers are dirtied before the page is dirtied.  There's a small race
+ * window in which a writepage caller may see the page cleanness but not the
+ * buffer dirtiness.  That's fine.  If this code were to set the page dirty
+ * before the buffers, a concurrent writepage caller could clear the page dirty
+ * bit, see a bunch of clean buffers and we'd end up with dirty buffers/clean
+ * page on the dirty page list.
+ *
+ * There is also a small window where the page is dirty, and not on dirty_pages.
+ * Also a possibility that by the time the page is added to dirty_pages, it has
+ * been set clean.  The page lists are somewhat approximate in this regard.
+ * It's better to have clean pages accidentally attached to dirty_pages than to
+ * leave dirty pages attached to clean_pages.
+ *
+ * We use private_lock to lock against try_to_free_buffers while using the
+ * page's buffer list.  Also use this to protect against clean buffers being
+ * added to the page after it was set dirty.
+ *
+ * FIXME: may need to call ->reservepage here as well.  That's rather up to the
+ * address_space though.
+ *
+ * For now, we treat swapper_space specially.  It doesn't use the normal
+ * block a_ops.
+ */
+int __set_page_dirty_buffers(struct page *page)
+{
+	struct address_space * const mapping = page->mapping;
+	int ret = 0;
+
+	if (mapping == NULL) {
+		SetPageDirty(page);
+		goto out;
+	}
+
+	if (!PageUptodate(page))
+		buffer_error();
+
+	spin_lock(&mapping->private_lock);
+	if (page_has_buffers(page)) {
+		struct buffer_head *head = page_buffers(page);
+		struct buffer_head *bh = head;
+
+		do {
+			if (buffer_uptodate(bh))
+				set_buffer_dirty(bh);
+			else
+				buffer_error();
+			bh = bh->b_this_page;
+		} while (bh != head);
+	}
+	spin_unlock(&mapping->private_lock);
+
+	if (!TestSetPageDirty(page)) {
+		spin_lock(&mapping->page_lock);
+		if (page->mapping) {	/* Race with truncate? */
+			if (!mapping->backing_dev_info->memory_backed)
+				inc_page_state(nr_dirty);
+			list_del(&page->list);
+			list_add(&page->list, &mapping->dirty_pages);
+		}
+		spin_unlock(&mapping->page_lock);
+		__mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
+	}
+	
+out:
+	return ret;
+}
+EXPORT_SYMBOL(__set_page_dirty_buffers);
+
+/*
  * Write out and wait upon a list of buffers.
  *
  * We have conflicting pressures: we want to make sure that all
@@ -916,7 +986,7 @@
 	head = NULL;
 	offset = PAGE_SIZE;
 	while ((offset -= size) >= 0) {
-		bh = alloc_buffer_head();
+		bh = alloc_buffer_head(GFP_NOFS);
 		if (!bh)
 			goto no_grow;
 
@@ -1949,7 +2019,7 @@
 	struct inode *inode = page->mapping->host;
 	sector_t iblock, lblock;
 	struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE];
-	unsigned int blocksize, blocks;
+	unsigned int blocksize;
 	int nr, i;
 	int fully_mapped = 1;
 
@@ -1962,7 +2032,6 @@
 		create_empty_buffers(page, blocksize, 0);
 	head = page_buffers(page);
 
-	blocks = PAGE_CACHE_SIZE >> inode->i_blkbits;
 	iblock = (sector_t)page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits);
 	lblock = (inode->i_size+blocksize-1) >> inode->i_blkbits;
 	bh = head;
@@ -2267,7 +2336,7 @@
 		if (buffer_uptodate(&map_bh))
 			continue;	/* reiserfs does this */
 		if (block_start < from || block_end > to) {
-			struct buffer_head *bh = alloc_buffer_head();
+			struct buffer_head *bh = alloc_buffer_head(GFP_NOFS);
 
 			if (!bh) {
 				ret = -ENOMEM;
@@ -2826,9 +2895,9 @@
 	buffer_heads_over_limit = (tot > max_buffer_heads);
 }
 	
-struct buffer_head *alloc_buffer_head(void)
+struct buffer_head *alloc_buffer_head(int gfp_flags)
 {
-	struct buffer_head *ret = kmem_cache_alloc(bh_cachep, GFP_NOFS);
+	struct buffer_head *ret = kmem_cache_alloc(bh_cachep, gfp_flags);
 	if (ret) {
 		preempt_disable();
 		__get_cpu_var(bh_accounting).nr++;
diff -Nru a/fs/cifs/CHANGES b/fs/cifs/CHANGES
--- a/fs/cifs/CHANGES	Wed Apr 30 22:28:16 2003
+++ b/fs/cifs/CHANGES	Wed Apr 30 22:28:16 2003
@@ -1,3 +1,33 @@
+Version 0.75
+------------
+Fix delete of readonly file to Windows servers.  Reflect
+presence or absence of read only dos attribute in mode
+bits for servers that do not support CIFS Unix extensions.
+Fix shortened results on readdir of large directories to
+servers supporting CIFS Unix extensions (caused by
+incorrect resume key).
+
+Version 0.74
+------------
+Fix truncate bug (set file size) that could cause hangs e.g. running fsx
+
+Version 0.73
+------------
+unload nls if mount fails.
+
+Version 0.72
+------------
+Add resume key support to search (readdir) code to workaround
+Windows bug.  Add /proc/fs/cifs/LookupCacheEnable which
+allows disabling caching of attribute information for
+lookups.
+
+Version 0.71
+------------
+Add more oplock handling (distributed caching code).  Remove
+dead code.  Remove excessive stack space utilization from
+symlink routines.
+
 Version 0.70
 ------------
 Fix oops in get dfs referral (triggered when null path sent in to
diff -Nru a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
--- a/fs/cifs/cifs_debug.c	Wed Apr 30 22:28:09 2003
+++ b/fs/cifs/cifs_debug.c	Wed Apr 30 22:28:09 2003
@@ -185,6 +185,8 @@
 static write_proc_t cifsFYI_write;
 static read_proc_t oplockEnabled_read;
 static write_proc_t oplockEnabled_write;
+static read_proc_t lookupFlag_read;
+static write_proc_t lookupFlag_write;
 static read_proc_t traceSMB_read;
 static write_proc_t traceSMB_write;
 static read_proc_t multiuser_mount_read;
@@ -244,6 +246,12 @@
 		pde->write_proc = extended_security_write;
 
 	pde =
+	create_proc_read_entry("LookupCacheEnable", 0, proc_fs_cifs,
+		lookupFlag_read, 0);
+	if (pde)
+		pde->write_proc = lookupFlag_write;
+
+	pde =
 	    create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs,
 				   ntlmv2_enabled_read, 0);
 	if (pde)
@@ -353,6 +361,44 @@
 	return count;
 }
 
+static int
+lookupFlag_read(char *page, char **start, off_t off,
+		   int count, int *eof, void *data)
+{
+	int len;
+
+	len = sprintf(page, "%d\n", lookupCacheEnabled);
+
+	len -= off;
+	*start = page + off;
+
+	if (len > count)
+		len = count;
+	else
+		*eof = 1;
+
+	if (len < 0)
+		len = 0;
+
+	return len;
+}
+static int
+lookupFlag_write(struct file *file, const char *buffer,
+		    unsigned long count, void *data)
+{
+	char c;
+	int rc;
+
+	rc = get_user(c, buffer);
+	if (rc)
+		return rc;
+	if (c == '0' || c == 'n' || c == 'N')
+		lookupCacheEnabled = 0;
+	else if (c == '1' || c == 'y' || c == 'Y')
+		lookupCacheEnabled = 1;
+
+	return count;
+}
 static int
 traceSMB_read(char *page, char **start, off_t off, int count,
 	      int *eof, void *data)
diff -Nru a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
--- a/fs/cifs/cifsfs.c	Wed Apr 30 22:28:10 2003
+++ b/fs/cifs/cifsfs.c	Wed Apr 30 22:28:10 2003
@@ -48,11 +48,13 @@
 int cifsERROR = 1;
 int traceSMB = 0;
 unsigned int oplockEnabled = 0;
+unsigned int lookupCacheEnabled = 1;
 unsigned int multiuser_mount = 0;
 unsigned int extended_security = 0;
 unsigned int ntlmv2_support = 0;
 unsigned int sign_CIFS_PDUs = 0;
 unsigned int CIFSMaximumBufferSize = CIFS_MAX_MSGSIZE;
+struct task_struct * oplockThread = NULL;
 
 extern int cifs_mount(struct super_block *, struct cifs_sb_info *, char *,
 			char *);
@@ -107,6 +109,8 @@
 		iput(inode);
 
 out_mount_failed:
+	if(cifs_sb->local_nls)
+		unload_nls(cifs_sb->local_nls);	
 	if(cifs_sb)
 		kfree(cifs_sb);
 	return -EINVAL;
@@ -175,6 +179,7 @@
 static kmem_cache_t *cifs_inode_cachep;
 kmem_cache_t *cifs_req_cachep;
 kmem_cache_t *cifs_mid_cachep;
+kmem_cache_t *cifs_oplock_cachep;
 
 static struct inode *
 cifs_alloc_inode(struct super_block *sb)
@@ -390,10 +395,17 @@
 cifs_init_mids(void)
 {
 	cifs_mid_cachep = kmem_cache_create("cifs_mpx_ids",
-					    sizeof (struct mid_q_entry), 0,
-					    SLAB_HWCACHE_ALIGN, NULL, NULL);
+				sizeof (struct mid_q_entry), 0,
+				SLAB_HWCACHE_ALIGN, NULL, NULL);
 	if (cifs_mid_cachep == NULL)
 		return -ENOMEM;
+	cifs_oplock_cachep = kmem_cache_create("cifs_oplock_structs",
+				sizeof (struct oplock_q_entry), 0,
+				SLAB_HWCACHE_ALIGN, NULL, NULL);
+	if (cifs_oplock_cachep == NULL) {
+		kmem_cache_destroy(cifs_mid_cachep);
+		return -ENOMEM;
+	}
 
 	return 0;
 }
@@ -404,6 +416,49 @@
 	if (kmem_cache_destroy(cifs_mid_cachep))
 		printk(KERN_WARNING
 		       "cifs_destroy_mids: error not all structures were freed\n");
+	if (kmem_cache_destroy(cifs_oplock_cachep))
+		printk(KERN_WARNING
+		       "error not all oplock structures were freed\n");}
+
+static int cifs_oplock_thread(void * dummyarg)
+{
+	struct list_head * tmp;
+	struct oplock_q_entry * oplock_item;
+	struct file * pfile;
+	struct cifsTconInfo *pTcon;
+	int rc;
+
+	daemonize("cifsoplockd");
+	allow_signal(SIGKILL);
+
+	oplockThread = current;
+	while (1) {
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(100*HZ);
+		/* BB add missing code */
+		cFYI(1,("oplock thread woken up - flush inode")); /* BB remove */
+		write_lock(&GlobalMid_Lock); 
+		list_for_each(tmp, &GlobalOplock_Q) {
+			oplock_item = list_entry(tmp, struct
+							       oplock_q_entry,
+							       qhead);
+			if(oplock_item) {
+				pTcon = oplock_item->tcon;
+				pfile = oplock_item->file_to_flush;
+				cFYI(1,("process item on queue"));/* BB remove */
+				DeleteOplockQEntry(oplock_item);
+				write_unlock(&GlobalMid_Lock);
+				rc = filemap_fdatawrite(pfile->f_dentry->d_inode->i_mapping);
+				cFYI(1,("Oplock flush file %p rc %d",pfile,rc));
+				/* send oplock break */
+				write_lock(&GlobalMid_Lock);
+			} else
+				break;
+			cFYI(1,("next time through list")); /* BB remove */
+		}
+		write_unlock(&GlobalMid_Lock);
+		cFYI(1,("next time through while loop")); /* BB remove */
+	}
 }
 
 static int __init
@@ -416,7 +471,7 @@
 	INIT_LIST_HEAD(&GlobalServerList);	/* BB not implemented yet */
 	INIT_LIST_HEAD(&GlobalSMBSessionList);
 	INIT_LIST_HEAD(&GlobalTreeConnectionList);
-
+	INIT_LIST_HEAD(&GlobalOplock_Q);
 /*
  *  Initialize Global counters
  */
@@ -437,9 +492,11 @@
 			rc = cifs_init_request_bufs();
 			if (!rc) {
 				rc = register_filesystem(&cifs_fs_type);
-				if (!rc)
-					return rc;	/* Success */
-				else
+				if (!rc) {                
+					kernel_thread(cifs_oplock_thread, NULL, 
+						CLONE_FS | CLONE_FILES | CLONE_VM);
+					return rc; /* Success */
+				} else
 					cifs_destroy_request_bufs();
 			}
 			cifs_destroy_mids();
@@ -459,10 +516,12 @@
 #if CONFIG_PROC_FS
 	cifs_proc_clean();
 #endif
-    	unregister_filesystem(&cifs_fs_type);
+	unregister_filesystem(&cifs_fs_type);
 	cifs_destroy_inodecache();
 	cifs_destroy_mids();
 	cifs_destroy_request_bufs();
+	if(oplockThread)
+		send_sig(SIGKILL, oplockThread, 1);
 }
 
 MODULE_AUTHOR("Steve French <sfrench@us.ibm.com>");
diff -Nru a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
--- a/fs/cifs/cifsglob.h	Wed Apr 30 22:28:05 2003
+++ b/fs/cifs/cifsglob.h	Wed Apr 30 22:28:05 2003
@@ -199,14 +199,18 @@
 struct cifsFileInfo {
 	struct list_head tlist;	/* pointer to next fid owned by tcon */
 	struct list_head flist;	/* next fid (file instance) for this inode */
-	unsigned int uid;	/* allows you to find which FileInfo structure */
+	unsigned int uid;	/* allows finding which FileInfo structure */
 	__u32 pid;		/* process id who opened file */
 	__u16 netfid;		/* file id from remote */
 	/* BB add lock scope info here if needed */ ;
 	/* lock scope id (0 if none) */
-    struct file * pfile; /* needed for writepage */
+    	struct file * pfile; /* needed for writepage */
 	int endOfSearch:1;	/* we have reached end of search */
 	int closePend:1;	/* file is marked to close */
+	int emptyDir:1;
+	char * search_resume_name;
+	unsigned int resume_name_length;
+	__u32 resume_key;
 };
 
 /*
@@ -221,7 +225,8 @@
 	atomic_t inUse;	 /* num concurrent users (local openers cifs) of file*/
 	unsigned long time;	/* jiffies of last update/check of inode */
 	int clientCanCacheRead:1; /* read oplock */
-    int clientCanCacheAll:1;  /* read and writebehind oplock */
+	int clientCanCacheAll:1;  /* read and writebehind oplock */
+	int oplockPending:1;
 	struct inode vfs_inode;
 };
 
@@ -251,14 +256,20 @@
 	int midState;	/* wish this were enum but can not pass to wait_event */
 };
 
+struct oplock_q_entry {
+	struct list_head qhead;
+	struct file * file_to_flush;
+	struct cifsTconInfo * tcon; 
+};
+
 #define   MID_FREE 0
 #define   MID_REQUEST_ALLOCATED 1
 #define   MID_REQUEST_SUBMITTED 2
 #define   MID_RESPONSE_RECEIVED 4
 
-struct servers_not_supported {	/* @z4a */
-	struct servers_not_supported *next1;	/* @z4a */
-	char server_Name[SERVER_NAME_LEN_WITH_NULL];	/* @z4a */
+struct servers_not_supported { /* @z4a */
+	struct servers_not_supported *next1;  /* @z4a */
+	char server_Name[SERVER_NAME_LEN_WITH_NULL]; /* @z4a */
 	/* Server Names in SMB protocol are 15 chars + X'20'  */
 	/*   in 16th byte...                      @z4a        */
 };
@@ -301,6 +312,8 @@
 GLOBAL_EXTERN struct list_head GlobalTreeConnectionList;
 GLOBAL_EXTERN rwlock_t GlobalSMBSeslock;  /* protects list inserts on 3 above */
 
+GLOBAL_EXTERN struct list_head GlobalOplock_Q;
+
 /*
  * Global transaction id (XID) information
  */
@@ -327,6 +340,7 @@
 				have the uid/password or Kerberos credential 
 				or equivalent for current user */
 GLOBAL_EXTERN unsigned int oplockEnabled;
+GLOBAL_EXTERN unsigned int lookupCacheEnabled;
 GLOBAL_EXTERN unsigned int extended_security;	/* if on, session setup sent 
 				with more secure ntlmssp2 challenge/resp */
 GLOBAL_EXTERN unsigned int ntlmv2_support;  /* better optional password hash */
diff -Nru a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h
--- a/fs/cifs/cifspdu.h	Wed Apr 30 22:28:15 2003
+++ b/fs/cifs/cifspdu.h	Wed Apr 30 22:28:15 2003
@@ -38,6 +38,7 @@
 #define SMB_COM_WRITE_ANDX            0x2F
 #define SMB_COM_TRANSACTION2	      0x32
 #define SMB_COM_TRANSACTION2_SECONDARY 0x33
+#define SMB_COM_FIND_CLOSE2           0x34
 #define SMB_COM_TREE_DISCONNECT       0x71
 #define SMB_COM_NEGOTIATE             0x72
 #define SMB_COM_SESSION_SETUP_ANDX    0x73
@@ -584,7 +585,7 @@
 
 typedef struct smb_com_close_req {
 	struct smb_hdr hdr;	/* wct = 3 */
-	__u16 FileID;		/* target file attributes */
+	__u16 FileID;
 	__u32 LastWriteTime;	/* should be zero */
 	__u16 ByteCount;	/* 0 */
 } CLOSE_REQ;
@@ -594,6 +595,12 @@
 	__u16 ByteCount;	/* bct = 0 */
 } CLOSE_RSP;
 
+typedef struct smb_com_findclose_req {
+	struct smb_hdr hdr; /* wct = 1 */
+	__u16 FileID;
+	__u16 ByteCount;    /* 0 */
+} FINDCLOSE_REQ;
+
 /* OpenFlags */
 #define REQ_OPLOCK         0x00000002
 #define REQ_BATCHOPLOCK    0x00000004
@@ -1152,7 +1159,7 @@
 	__u16 InformationLevel;
 	__u32 ResumeKey;
 	__u16 SearchFlags;
-	char ResumeFileName[1];	/* will be null string actually since we set bit 3 - resume from previous ending place */
+	char ResumeFileName[1];
 } TRANSACTION2_FNEXT_REQ;
 
 typedef struct smb_com_transaction2_fnext_rsp {
@@ -1509,7 +1516,7 @@
 	__u32 ExtFileAttributes;
 	__u32 FileNameLength;
 	char FileName[1];
-} FILE_DIRECTORY_INFO;		/* level 257 FF response data area */
+} FILE_DIRECTORY_INFO;   /* level 257 FF response data area */
 
 struct gea {
 	unsigned char cbName;
diff -Nru a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
--- a/fs/cifs/cifsproto.h	Wed Apr 30 22:28:03 2003
+++ b/fs/cifs/cifsproto.h	Wed Apr 30 22:28:03 2003
@@ -57,6 +57,8 @@
 			const struct cifsTconInfo *, int
 			/* length of fixed section (word count) in two byte units  */
 			);
+struct oplock_q_entry * AllocOplockQEntry(struct file *,struct cifsTconInfo *);
+void DeleteOplockQEntry(struct oplock_q_entry *);
 extern struct timespec cifs_NTtimeToUnix(u64 /* utc nanoseconds since 1601 */ );
 extern u64 cifs_UnixTimeToNT(struct timespec);
 extern void RevUcode_to_Ucode(char *revUnicode, char *UnicodeName);
@@ -104,8 +106,12 @@
 extern int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
 			FILE_DIRECTORY_INFO * findData,
 			T2_FNEXT_RSP_PARMS * findParms,
-			const __u16 searchHandle, const __u32 resumeKey,
+			const __u16 searchHandle, char * resume_name,
+			int name_length, __u32 resume_key,
 			int *UnicodeFlag, int *pUnixFlag);
+
+extern int CIFSFindClose(const int, struct cifsTconInfo *tcon,
+			const __u16 search_handle);
 
 extern int CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
 			const unsigned char *searchName,
diff -Nru a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
--- a/fs/cifs/cifssmb.c	Wed Apr 30 22:28:05 2003
+++ b/fs/cifs/cifssmb.c	Wed Apr 30 22:28:05 2003
@@ -1449,7 +1449,7 @@
 	    cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM |
 			ATTR_DIRECTORY);
 	pSMB->SearchCount = cpu_to_le16(CIFS_MAX_MSGSIZE / sizeof (FILE_DIRECTORY_INFO));	/* should this be shrunk even more ? */
-	pSMB->SearchFlags = cpu_to_le16(CIFS_SEARCH_CLOSE_AT_END);
+	pSMB->SearchFlags = cpu_to_le16(CIFS_SEARCH_CLOSE_AT_END | CIFS_SEARCH_RETURN_RESUME);
 
 	/* test for Unix extensions */
 	if (tcon->ses->capabilities & CAP_UNIX) {
@@ -1496,9 +1496,9 @@
 
 int
 CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
-	     FILE_DIRECTORY_INFO * findData,
-	     T2_FNEXT_RSP_PARMS * findParms, const __u16 searchHandle,
-	     __u32 resumeKey, int *pUnicodeFlag, int *pUnixFlag)
+		FILE_DIRECTORY_INFO * findData, T2_FNEXT_RSP_PARMS * findParms,
+		const __u16 searchHandle, char * resume_file_name, int name_len,
+		__u32 resume_key, int *pUnicodeFlag, int *pUnixFlag)
 {
 /* level 257 SMB_ */
 	TRANSACTION2_FNEXT_REQ *pSMB = NULL;
@@ -1508,6 +1508,9 @@
 	int bytes_returned;
 
 	cFYI(1, ("In FindNext"));
+	if(resume_file_name == NULL) {
+		return -EIO;
+	}
 	rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
 		      (void **) &pSMBr);
 	if (rc)
@@ -1530,9 +1533,6 @@
 	pSMB->SetupCount = 1;
 	pSMB->Reserved3 = 0;
 	pSMB->SubCommand = cpu_to_le16(TRANS2_FIND_NEXT);
-	pSMB->ByteCount = pSMB->TotalParameterCount + 1 /* pad */ ;
-	pSMB->TotalParameterCount = cpu_to_le16(pSMB->TotalParameterCount);
-	pSMB->ParameterCount = pSMB->TotalParameterCount;
 	pSMB->SearchHandle = searchHandle;	/* always kept as le */
 	findParms->SearchCount = 0;	/* set to zero in case of error */
 	pSMB->SearchCount =
@@ -1546,10 +1546,19 @@
 		    cpu_to_le16(SMB_FIND_FILE_DIRECTORY_INFO);
 		*pUnixFlag = FALSE;
 	}
-	pSMB->ResumeKey = resumeKey;	/* always kept as le */
+	pSMB->ResumeKey = resume_key;
 	pSMB->SearchFlags =
-	    cpu_to_le16(CIFS_SEARCH_CLOSE_AT_END |
-			CIFS_SEARCH_CONTINUE_FROM_LAST);
+	    cpu_to_le16(CIFS_SEARCH_CLOSE_AT_END | CIFS_SEARCH_RETURN_RESUME);
+	/* BB add check to make sure we do not cross end of smb */
+	if(name_len < CIFS_MAX_MSGSIZE) {
+		memcpy(pSMB->ResumeFileName, resume_file_name, name_len);
+		pSMB->ByteCount += name_len;
+	}
+	pSMB->TotalParameterCount += name_len;
+	pSMB->ByteCount = pSMB->TotalParameterCount + 1 /* pad */ ;
+	pSMB->TotalParameterCount = cpu_to_le16(pSMB->TotalParameterCount);
+	pSMB->ParameterCount = pSMB->TotalParameterCount;
+	/* BB improve error handling here */
 	pSMB->hdr.smb_buf_length += pSMB->ByteCount;
 	pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount);
 
@@ -1586,6 +1595,33 @@
 }
 
 int
+CIFSFindClose(const int xid, struct cifsTconInfo *tcon, const __u16 searchHandle)
+{
+	int rc = 0;
+	FINDCLOSE_REQ *pSMB = NULL;
+	CLOSE_RSP *pSMBr = NULL;
+	int bytes_returned;
+	cFYI(1, ("In CIFSSMBFindClose"));
+
+	rc = smb_init(SMB_COM_FIND_CLOSE2, 1, tcon, (void **) &pSMB,
+		      (void **) &pSMBr);
+	if (rc)
+		return rc;
+
+	pSMB->FileID = searchHandle;
+	pSMB->ByteCount = 0;
+	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
+			 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
+	if (rc) {
+		cERROR(1, ("Send error in FindClose = %d", rc));
+	}
+	if (pSMB)
+		buf_release(pSMB);
+
+	return rc;
+}
+
+int
 CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses,
 		const unsigned char *searchName,
 		unsigned char **targetUNCs,
@@ -1984,21 +2020,21 @@
 	pSMB->ParameterOffset = offsetof(struct smb_com_transaction2_spi_req,
                                      InformationLevel) - 4;
 	pSMB->DataOffset = pSMB->ParameterOffset + pSMB->ParameterCount;
-    if(SetAllocation) {
-        if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU)
-            pSMB->InformationLevel =
-                cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO2);
-        else
-            pSMB->InformationLevel =
-                cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO);
-    } else /* Set File Size */  {    
+	if(SetAllocation) {
+        	if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU)
+	            pSMB->InformationLevel =
+                	cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO2);
+        	else
+	            pSMB->InformationLevel =
+        	        cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO);
+	} else /* Set File Size */  {    
 	    if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU)
 		    pSMB->InformationLevel =
 		        cpu_to_le16(SMB_SET_FILE_END_OF_FILE_INFO2);
 	    else
 		    pSMB->InformationLevel =
 		        cpu_to_le16(SMB_SET_FILE_END_OF_FILE_INFO);
-    }
+	}
 
 	parm_data =
 	    (struct file_end_of_file_info *) (((char *) &pSMB->hdr.Protocol) +
@@ -2035,10 +2071,10 @@
 	struct smb_com_transaction2_sfi_req *pSMB  = NULL;
 	struct smb_com_transaction2_sfi_rsp *pSMBr = NULL;
 	char *data_offset;
-    struct file_end_of_file_info *parm_data;
+	struct file_end_of_file_info *parm_data;
 	int rc = 0;
 	int bytes_returned = 0;
-    __u32 tmp;
+	__u32 tmp;
 
 	cFYI(1, ("SetFileSize (via SetFileInfo)"));
 
@@ -2079,25 +2115,25 @@
 	pSMB->ParameterOffset = cpu_to_le16(pSMB->ParameterOffset);
 	pSMB->DataOffset = cpu_to_le16(pSMB->DataOffset);
 	parm_data =
-	    (struct file_end_of_file_info *) (((char *) &pSMB->hdr.Protocol) +
-				       pSMB->DataOffset);
-    parm_data->FileSize = size;
-    pSMB->Fid = fid;
-    if(SetAllocation) {
-        if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU)
-            pSMB->InformationLevel =
-                cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO2);
-        else
-            pSMB->InformationLevel =
-                cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO);
-    } else /* Set File Size */  {    
+		(struct file_end_of_file_info *) (((char *) &pSMB->hdr.Protocol) +
+			pSMB->DataOffset);
+	parm_data->FileSize = size;
+	pSMB->Fid = fid;
+	if(SetAllocation) {
+		if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU)
+			pSMB->InformationLevel =
+				cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO2);
+		else
+			pSMB->InformationLevel =
+				cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO);
+	} else /* Set File Size */  {    
 	    if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU)
 		    pSMB->InformationLevel =
 		        cpu_to_le16(SMB_SET_FILE_END_OF_FILE_INFO2);
 	    else
 		    pSMB->InformationLevel =
 		        cpu_to_le16(SMB_SET_FILE_END_OF_FILE_INFO);
-    }
+	}
 	pSMB->Reserved4 = 0;
 	pSMB->hdr.smb_buf_length += pSMB->ByteCount;
 	pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount);
diff -Nru a/fs/cifs/connect.c b/fs/cifs/connect.c
--- a/fs/cifs/connect.c	Wed Apr 30 22:28:16 2003
+++ b/fs/cifs/connect.c	Wed Apr 30 22:28:16 2003
@@ -850,8 +850,7 @@
 			init_waitqueue_head(&srvTcp->response_q);
 			INIT_LIST_HEAD(&srvTcp->pending_mid_q);
 			srvTcp->tcpStatus = CifsGood;
-			kernel_thread((void *) (void *)
-				      cifs_demultiplex_thread, srvTcp,
+			kernel_thread((void *)(void *)cifs_demultiplex_thread, srvTcp,
 				      CLONE_FS | CLONE_FILES | CLONE_VM);
 		}
 	}
diff -Nru a/fs/cifs/file.c b/fs/cifs/file.c
--- a/fs/cifs/file.c	Wed Apr 30 22:28:03 2003
+++ b/fs/cifs/file.c	Wed Apr 30 22:28:03 2003
@@ -152,28 +152,31 @@
 {
 	int rc = 0;
 	struct cifsFileInfo *open_file = NULL;
+    struct file * file = NULL;
 	struct list_head *tmp;
 
 /* list all files open on tree connection */
 	list_for_each(tmp, &pTcon->openFileList) {            
 		open_file = list_entry(tmp,struct cifsFileInfo, flist);
-		if(open_file)
-			if(open_file->pfile) {
-				if(open_file->pfile->private_data) {
-					kfree(open_file->pfile->private_data);
-				}
-				rc = cifs_open(open_file->pfile->f_dentry->d_inode,
-						  open_file->pfile);
+		if(open_file) {
+			if(open_file->search_resume_name) {
+				kfree(open_file->search_resume_name);
+			}
+			file = open_file->pfile;
+			kfree(open_file);
+			if(file) {                
+				file->private_data = NULL;
+				rc = cifs_open(file->f_dentry->d_inode,file);
 				if(rc) {
 					cFYI(1,("reconnecting file %s failed with %d",
-							open_file->pfile->f_dentry->d_name.name,rc));
+						file->f_dentry->d_name.name,rc));
 				} else {
 					cFYI(1,("reconnection of %s succeeded",
-							open_file->pfile->f_dentry->d_name.name));
+						file->f_dentry->d_name.name));
 				}
-			}
+			} 
+		}
 	}
-
 	return rc;
 }
 
@@ -196,6 +199,8 @@
 			list_del(&pSMBFile->flist);
 		list_del(&pSMBFile->tlist);
 		rc = CIFSSMBClose(xid, pTcon, pSMBFile->netfid);
+		if(pSMBFile->search_resume_name)
+			kfree(pSMBFile->search_resume_name);
 		kfree(file->private_data);
 		file->private_data = NULL;
 	} else
@@ -874,6 +879,9 @@
 	} else {
 		*pobject_type = DT_REG;
 		tmp_inode->i_mode |= S_IFREG;
+		if(pfindData->ExtFileAttributes & ATTR_READONLY)
+			tmp_inode->i_mode &= ~(S_IWUGO);
+
 	}/* could add code here - to validate if device or weird share type? */
 
 	/* can not fill in nlink here as in qpathinfo version and Unx search */
@@ -1055,6 +1063,7 @@
 	int xid, i;
 	int Unicode = FALSE;
 	int UnixSearch = FALSE;
+	unsigned int bufsize;
 	__u16 searchHandle;
 	struct cifs_sb_info *cifs_sb;
 	struct cifsTconInfo *pTcon;
@@ -1065,14 +1074,19 @@
 	T2_FFIRST_RSP_PARMS findParms;
 	T2_FNEXT_RSP_PARMS findNextParms;
 	FILE_DIRECTORY_INFO *pfindData;
+	FILE_DIRECTORY_INFO *lastFindData;
 	FILE_UNIX_INFO *pfindDataUnix;
 
 	xid = GetXid();
 
 	cifs_sb = CIFS_SB(file->f_dentry->d_sb);
 	pTcon = cifs_sb->tcon;
-	data = kmalloc(pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE,
-			GFP_KERNEL);
+	bufsize = pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE;
+	if(bufsize > CIFS_MAX_MSGSIZE) {
+		FreeXid(xid);
+		return -EIO;
+	}
+	data = kmalloc(bufsize, GFP_KERNEL);
 	pfindData = (FILE_DIRECTORY_INFO *) data;
 
 	full_path = build_wildcard_path_from_dentry(file->f_dentry);
@@ -1081,8 +1095,7 @@
 
 	switch ((int) file->f_pos) {
 	case 0:
-		if (filldir
-		    (direntry, ".", 1, file->f_pos,
+		if (filldir(direntry, ".", 1, file->f_pos,
 		     file->f_dentry->d_inode->i_ino, DT_DIR) < 0) {
 			cERROR(1, ("Filldir for current dir failed "));
 			break;
@@ -1090,8 +1103,7 @@
 		file->f_pos++;
 		/* fallthrough */
 	case 1:
-		if (filldir
-		    (direntry, "..", 2, file->f_pos,
+		if (filldir(direntry, "..", 2, file->f_pos,
 		     file->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) {
 			cERROR(1, ("Filldir for parent dir failed "));
 			break;
@@ -1099,44 +1111,107 @@
 		file->f_pos++;
 		/* fallthrough */
 	case 2:
-		/* do not reallocate search handle if rewind */
-		if(file->private_data == NULL) {
-			rc = CIFSFindFirst(xid, pTcon, full_path, pfindData,
-				   &findParms, cifs_sb->local_nls,
-				   &Unicode, &UnixSearch);
-			cFYI(1,
-			     ("Count: %d  End: %d ", findParms.SearchCount,
-			      findParms.EndofSearch));
-		} else {
-			cFYI(1,("Search rewinding on %s",full_path));
-			goto readdir_rewind;
+		if (file->private_data != NULL) {
+			cifsFile =
+				(struct cifsFileInfo *) file->private_data;
+			if (cifsFile->endOfSearch) {
+				if(cifsFile->emptyDir) {
+					cFYI(1, ("End of search, empty dir"));
+					rc = 0;
+					break;
+				}
+			} else
+				CIFSFindClose(xid, pTcon, cifsFile->netfid);
+			if(cifsFile->search_resume_name) {
+				kfree(cifsFile->search_resume_name);
+				cifsFile->search_resume_name = NULL;
+			}
 		}
-
+		rc = CIFSFindFirst(xid, pTcon, full_path, pfindData,
+				&findParms, cifs_sb->local_nls,
+				&Unicode, &UnixSearch);
+		cFYI(1, ("Count: %d  End: %d ", findParms.SearchCount,
+			findParms.EndofSearch));
+ 
 		if (rc == 0) {
 			searchHandle = findParms.SearchHandle;
 			if(file->private_data == NULL)
 				file->private_data =
 				    kmalloc(sizeof(struct cifsFileInfo),
-					 GFP_KERNEL);
-			else {
-				/* BB close search handle */
-				cFYI(1,("Search rewinding on %s",full_path));
-			}
+					  GFP_KERNEL);
 			if (file->private_data) {
 				memset(file->private_data, 0,
 				       sizeof (struct cifsFileInfo));
 				cifsFile =
 				    (struct cifsFileInfo *) file->private_data;
 				cifsFile->netfid = searchHandle;
+			} else {
+				rc = -ENOMEM;
+				break;
 			}
 
 			renew_parental_timestamps(file->f_dentry);
-
+			lastFindData = 
+				(FILE_DIRECTORY_INFO *) ((char *) pfindData + 
+					le32_to_cpu(findParms.LastNameOffset));
+			if((char *)lastFindData > (char *)pfindData + bufsize) {
+				cFYI(1,("last search entry past end of packet"));
+				rc = -EIO;
+				break;
+			}
+			/* Offset of resume key same for levels 257 and 514 */
+			cifsFile->resume_key = lastFindData->FileIndex;
+			if(UnixSearch == FALSE) {
+				cifsFile->resume_name_length = 
+					le32_to_cpu(lastFindData->FileNameLength);
+				if(cifsFile->resume_name_length > bufsize - 64) {
+					cFYI(1,("Illegal resume file name length %d",
+						cifsFile->resume_name_length));
+					rc = -ENOMEM;
+					break;
+				}
+				cifsFile->search_resume_name = 
+					kmalloc(cifsFile->resume_name_length, GFP_KERNEL);
+				cFYI(1,("Last file: %s with name %d bytes long",
+					lastFindData->FileName,
+					cifsFile->resume_name_length));
+				memcpy(cifsFile->search_resume_name,
+					lastFindData->FileName, 
+					cifsFile->resume_name_length);
+			} else {
+				pfindDataUnix = (FILE_UNIX_INFO *)lastFindData;
+				if (Unicode == TRUE) {
+					for(i=0;(pfindDataUnix->FileName[i] 
+						    | pfindDataUnix->FileName[i+1]);
+						i+=2) {
+						if(i > bufsize-64)
+							break;
+					}
+					cifsFile->resume_name_length = i + 2;
+				} else {
+					cifsFile->resume_name_length = 
+						strnlen(pfindDataUnix->FileName,
+							bufsize-63);
+				}
+				if(cifsFile->resume_name_length > bufsize - 64) {
+					cFYI(1,("Illegal resume file name length %d",
+						cifsFile->resume_name_length));
+					rc = -ENOMEM;
+					break;
+				}
+				cifsFile->search_resume_name = 
+					kmalloc(cifsFile->resume_name_length, GFP_KERNEL);
+				cFYI(1,("Last file: %s with name %d bytes long",
+					pfindDataUnix->FileName,
+					cifsFile->resume_name_length));
+				memcpy(cifsFile->search_resume_name,
+					pfindDataUnix->FileName, 
+					cifsFile->resume_name_length);
+			}
 			for (i = 2; i < findParms.SearchCount + 2; i++) {
 				if (UnixSearch == FALSE) {
 					pfindData->FileNameLength =
-					    le32_to_cpu(pfindData->
-							FileNameLength);
+					  le32_to_cpu(pfindData->FileNameLength);
 					if (Unicode == TRUE)
 						pfindData->FileNameLength =
 						    cifs_strfromUCS_le
@@ -1165,18 +1240,17 @@
 					    (FILE_UNIX_INFO *) pfindData;
 					if (Unicode == TRUE)
 						qstring.len =
-						    cifs_strfromUCS_le
-						    (pfindDataUnix->
-						     FileName, (wchar_t *)
-						     pfindDataUnix->
-						     FileName,
-						     MAX_PATHCONF,
-						     cifs_sb->local_nls);
+							cifs_strfromUCS_le
+							(pfindDataUnix->FileName,
+							(wchar_t *)
+							pfindDataUnix->FileName,
+							MAX_PATHCONF,
+							cifs_sb->local_nls);
 					else
 						qstring.len =
-						    strnlen(pfindDataUnix->
-							    FileName,
-							    MAX_PATHCONF);
+							strnlen(pfindDataUnix->
+							  FileName,
+							  MAX_PATHCONF);
 					if (((qstring.len != 1)
 					     || (pfindDataUnix->
 						 FileName[0] != '.'))
@@ -1193,21 +1267,26 @@
 						file->f_pos++;
 					}
 				}
-				pfindData = (FILE_DIRECTORY_INFO *) ((char *) pfindData + le32_to_cpu(pfindData->NextEntryOffset));	/* works also for Unix find struct since this is the first field of both */
+				/* works also for Unix ff struct since first field of both */
+				pfindData = 
+					(FILE_DIRECTORY_INFO *) ((char *) pfindData
+						 + le32_to_cpu(pfindData->NextEntryOffset));
 				/* BB also should check to make sure that pointer is not beyond the end of the SMB */
+				/* if(pfindData > lastFindData) rc = -EIO; break; */
 			}	/* end for loop */
 			if ((findParms.EndofSearch != 0) && cifsFile) {
 				cifsFile->endOfSearch = TRUE;
+				if(findParms.SearchCount == 2)
+					cifsFile->emptyDir = TRUE;
 			}
 		} else {
 			if (cifsFile)
 				cifsFile->endOfSearch = TRUE;
-			rc = 0;	/* unless parent directory disappeared - do not return error here (eg Access Denied or no more files) */
+			/* unless parent directory gone do not return error */
+			rc = 0;
 		}
 		break;
-readdir_rewind:
 	default:
-		/* BB rewrite eventually to better handle rewind */
 		if (file->private_data == NULL) {
 			rc = -EBADF;
 			cFYI(1,
@@ -1222,43 +1301,96 @@
 			}
 			searchHandle = cifsFile->netfid;
 			rc = CIFSFindNext(xid, pTcon, pfindData,
-					  &findNextParms, searchHandle, 0,
-					  &Unicode, &UnixSearch);
-			cFYI(1,
-			     ("Count: %d  End: %d ",
+				&findNextParms, searchHandle, 
+				cifsFile->search_resume_name,
+				cifsFile->resume_name_length,
+				cifsFile->resume_key,
+				&Unicode, &UnixSearch);
+			cFYI(1,("Count: %d  End: %d ",
 			      findNextParms.SearchCount,
 			      findNextParms.EndofSearch));
 			if ((rc == 0) && (findNextParms.SearchCount != 0)) {
+			/* BB save off resume key, key name and name length  */
+				lastFindData = 
+					(FILE_DIRECTORY_INFO *) ((char *) pfindData 
+						+ le32_to_cpu(findNextParms.LastNameOffset));
+				if((char *)lastFindData > (char *)pfindData + bufsize) {
+					cFYI(1,("last search entry past end of packet"));
+					rc = -EIO;
+					break;
+				}
+				/* Offset of resume key same for levels 257 and 514 */
+				cifsFile->resume_key = lastFindData->FileIndex;
+
+				if(UnixSearch == FALSE) {
+					cifsFile->resume_name_length = 
+						le32_to_cpu(lastFindData->FileNameLength);
+					if(cifsFile->resume_name_length > bufsize - 64) {
+						cFYI(1,("Illegal resume file name length %d",
+							cifsFile->resume_name_length));
+						rc = -ENOMEM;
+						break;
+					}
+					cifsFile->search_resume_name = 
+						kmalloc(cifsFile->resume_name_length, GFP_KERNEL);
+					cFYI(1,("Last file: %s with name %d bytes long",
+						lastFindData->FileName,
+						cifsFile->resume_name_length));
+					memcpy(cifsFile->search_resume_name,
+						lastFindData->FileName, 
+						cifsFile->resume_name_length);
+				} else {
+					pfindDataUnix = (FILE_UNIX_INFO *)lastFindData;
+					if (Unicode == TRUE) {
+						for(i=0;(pfindDataUnix->FileName[i] 
+								| pfindDataUnix->FileName[i+1]);
+							i+=2) {
+							if(i > bufsize-64)
+								break;
+						}
+						cifsFile->resume_name_length = i + 2;
+					} else {
+						cifsFile->resume_name_length = 
+							strnlen(pfindDataUnix->
+							 FileName,
+							 MAX_PATHCONF);
+					}
+					if(cifsFile->resume_name_length > bufsize - 64) {
+						cFYI(1,("Illegal resume file name length %d",
+								cifsFile->resume_name_length));
+						rc = -ENOMEM;
+						break;
+					}
+					cifsFile->search_resume_name = 
+						kmalloc(cifsFile->resume_name_length, GFP_KERNEL);
+					cFYI(1,("fnext last file: %s with name %d bytes long",
+						lastFindData->FileName,
+						cifsFile->resume_name_length));
+					memcpy(cifsFile->search_resume_name,
+						lastFindData->FileName, 
+						cifsFile->resume_name_length);
+				}
+
 				for (i = 0; i < findNextParms.SearchCount; i++) {
 					pfindData->FileNameLength =
 					    le32_to_cpu(pfindData->
 							FileNameLength);
 					if (UnixSearch == FALSE) {
 						if (Unicode == TRUE)
-							pfindData->
-							    FileNameLength
-							    =
-							    cifs_strfromUCS_le
-							    (pfindData->
-							     FileName,
-							     (wchar_t *)
-							     pfindData->
-							     FileName,
-							     (pfindData->
-							      FileNameLength)
-							     / 2,
-							     cifs_sb->
-							     local_nls);
-						qstring.len =
-						    pfindData->FileNameLength;
+							pfindData->FileNameLength =
+							  cifs_strfromUCS_le
+							  (pfindData->FileName,
+							  (wchar_t *)
+							  pfindData->FileName,
+							  (pfindData->FileNameLength)/ 2,
+							  cifs_sb->local_nls);
+						qstring.len = 
+							pfindData->FileNameLength;
 						if (((qstring.len != 1)
-						     || (pfindData->
-							 FileName[0] != '.'))
+						    || (pfindData->FileName[0] != '.'))
 						    && ((qstring.len != 2)
-							|| (pfindData->
-							    FileName[0] != '.')
-							|| (pfindData->
-							    FileName[1] !=
+							|| (pfindData->FileName[0] != '.')
+							|| (pfindData->FileName[1] !=
 							    '.'))) {
 							cifs_filldir
 							    (&qstring,
@@ -1273,22 +1405,18 @@
 						    pfindData;
 						if (Unicode == TRUE)
 							qstring.len =
-							    cifs_strfromUCS_le
-							    (pfindDataUnix->
-							     FileName,
-							     (wchar_t *)
-							     pfindDataUnix->
-							     FileName,
-							     MAX_PATHCONF,
-							     cifs_sb->
-							     local_nls);
+							  cifs_strfromUCS_le
+							  (pfindDataUnix->FileName,
+							  (wchar_t *)
+							  pfindDataUnix->FileName,
+							  MAX_PATHCONF,
+							  cifs_sb->local_nls);
 						else
 							qstring.len =
-							    strnlen
-							    (pfindDataUnix->
-							     FileName,
-							     MAX_PATHCONF);
-
+							  strnlen
+							  (pfindDataUnix->
+							  FileName,
+							  MAX_PATHCONF);
 						if (((qstring.len != 1)
 						     || (pfindDataUnix->
 							 FileName[0] != '.'))
@@ -1308,8 +1436,7 @@
 					}
 					pfindData = (FILE_DIRECTORY_INFO *) ((char *) pfindData + le32_to_cpu(pfindData->NextEntryOffset));	/* works also for Unix find struct since this is the first field of both */
 					/* BB also should check to make sure that pointer is not beyond the end of the SMB */
-
-				}	/* end for loop */
+				} /* end for loop */
 				if (findNextParms.EndofSearch != 0) {
 					cifsFile->endOfSearch = TRUE;
 				}
@@ -1318,8 +1445,7 @@
 				rc = 0;	/* unless parent directory disappeared - do not return error here (eg Access Denied or no more files) */
 			}
 		}
-	}			/* end switch */
-
+	} /* end switch */
 	if (data)
 		kfree(data);
 	if (full_path)
@@ -1335,7 +1461,8 @@
 	.writepage = cifs_writepage,
 	.prepare_write = simple_prepare_write,
 	.commit_write = cifs_commit_write,
-	.sync_page = cifs_sync_page, 
+	.sync_page = cifs_sync_page,
+	/*.direct_IO = */
 };
 
 struct address_space_operations cifs_addr_ops_writethrough = {
@@ -1345,6 +1472,7 @@
 	.prepare_write = simple_prepare_write,
 	.commit_write = cifs_commit_write,
 	.sync_page = cifs_sync_page,
+	/*.direct_IO = 	 */
 };
 
 struct address_space_operations cifs_addr_ops_nocache = {
@@ -1354,5 +1482,6 @@
 	.prepare_write = simple_prepare_write,
 	.commit_write = cifs_commit_write,
 	.sync_page = cifs_sync_page,
+	/*.direct_IO = */
 };
 
diff -Nru a/fs/cifs/inode.c b/fs/cifs/inode.c
--- a/fs/cifs/inode.c	Wed Apr 30 22:28:03 2003
+++ b/fs/cifs/inode.c	Wed Apr 30 22:28:03 2003
@@ -21,6 +21,7 @@
 #include <linux/fs.h>
 #include <linux/buffer_head.h>
 #include <linux/stat.h>
+#include <linux/pagemap.h>
 #include <asm/div64.h>
 #include "cifsfs.h"
 #include "cifspdu.h"
@@ -232,8 +233,6 @@
 		    cifs_NTtimeToUnix(le64_to_cpu(findData.LastWriteTime));
 		inode->i_ctime =
 		    cifs_NTtimeToUnix(le64_to_cpu(findData.ChangeTime));
-/* inode->i_mode = S_IRWXUGO;  *//* 777 perms */
-		/* should we treat the dos attribute of read-only as read-only mode bit e.g. 555 */
 		inode->i_mode = S_IALLUGO & ~(S_ISUID | S_IXGRP);	/* 2767 perms indicate mandatory locking - will override for dirs later */
 		cFYI(0,
 		     (" Attributes came in as 0x%x ", findData.Attributes));
@@ -246,6 +245,9 @@
             inode->i_mode |= S_IFDIR;
 		} else {
 			inode->i_mode |= S_IFREG;
+			/* treat the dos attribute of read-only as read-only mode e.g. 555 */
+			if(cifsInfo->cifsAttrs & ATTR_READONLY)
+				inode->i_mode &= ~(S_IWUGO);
    /* BB add code here - validate if device or weird share or device type? */
 		}
 		inode->i_size = le64_to_cpu(findData.EndOfFile);
@@ -303,6 +305,7 @@
 	struct cifsTconInfo *pTcon;
 	char *full_path = NULL;
 	struct cifsInodeInfo *cifsInode;
+	FILE_BASIC_INFO * pinfo_buf;
 
 	cFYI(1, (" cifs_unlink, inode = 0x%p with ", inode));
 
@@ -329,6 +332,22 @@
 			/* BB In the future chain close with the NTCreateX to narrow window */
 			direntry->d_inode->i_nlink--;
 		}
+	} else if (rc == -EACCES) {
+		/* try only if r/o attribute set in local lookup data? */
+		pinfo_buf = (FILE_BASIC_INFO *)kmalloc(sizeof(FILE_BASIC_INFO),GFP_KERNEL);
+		if(pinfo_buf) {
+			memset(pinfo_buf,0,sizeof(FILE_BASIC_INFO));        
+		/* ATTRS set to normal clears r/o bit */
+			pinfo_buf->Attributes = cpu_to_le32(ATTR_NORMAL);
+			rc = CIFSSMBSetTimes(xid, pTcon, full_path, pinfo_buf,
+				cifs_sb->local_nls);
+			kfree(pinfo_buf);
+		}
+		if(rc==0) {
+			rc = CIFSSMBDelFile(xid, pTcon, full_path, cifs_sb->local_nls);
+			if (!rc)
+				direntry->d_inode->i_nlink--;
+		}
 	}
 	cifsInode = CIFS_I(direntry->d_inode);
 	cifsInode->time = 0;	/* will force revalidate to get info when needed */
@@ -377,15 +396,14 @@
 		direntry->d_op = &cifs_dentry_ops;
 		d_instantiate(direntry, newinode);
 		direntry->d_inode->i_nlink = 2;
-        if (cifs_sb->tcon->ses->capabilities & CAP_UNIX)                
-            CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode,
-                        0xFFFFFFFFFFFFFFFF,  
-                        0xFFFFFFFFFFFFFFFF,
-                        cifs_sb->local_nls);
-        else { /* BB to be implemented via Windows secrty descriptors*/
-        /* eg CIFSSMBWinSetPerms(xid,pTcon,full_path,mode,-1,-1,local_nls);*/
-        }
-
+		if (cifs_sb->tcon->ses->capabilities & CAP_UNIX)                
+			CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode,
+				0xFFFFFFFFFFFFFFFF,  
+				0xFFFFFFFFFFFFFFFF,
+				cifs_sb->local_nls);
+		else { /* BB to be implemented via Windows secrty descriptors*/
+		/* eg CIFSSMBWinSetPerms(xid,pTcon,full_path,mode,-1,-1,local_nls);*/
+		}
 	}
 	if (full_path)
 		kfree(full_path);
@@ -450,10 +468,10 @@
 	cifs_sb_source = CIFS_SB(source_inode->i_sb);
 	pTcon = cifs_sb_source->tcon;
 
-	if (pTcon != cifs_sb_target->tcon) {    
+	if (pTcon != cifs_sb_target->tcon) {
+		FreeXid(xid);    
 		return -EXDEV;	/* BB actually could be allowed if same server, but
                      different share. Might eventually add support for this */
-        	FreeXid(xid);
 	}
 
 	fromName = build_path_from_dentry(source_direntry);
@@ -471,7 +489,7 @@
 	if (toName)
 		kfree(toName);
 
-    FreeXid(xid);
+	FreeXid(xid);
 	return rc;
 }
 
@@ -500,15 +518,15 @@
 
 	if (time_before(jiffies, cifsInode->time + HZ)) {
 	    if((S_ISREG(direntry->d_inode->i_mode) == 0) || 
-              (direntry->d_inode->i_nlink == 1)) {
-		    if (full_path)
-			    kfree(full_path);
-		    FreeXid(xid);
-		    return rc;
-        } else {
-            cFYI(1,("Have to revalidate file due to hardlinks"));
-        }
-            
+			(direntry->d_inode->i_nlink == 1) || 
+			(lookupCacheEnabled == 0)) {
+			if (full_path)
+				kfree(full_path);
+			FreeXid(xid);
+			return rc;
+		} else {
+			cFYI(1,("Have to revalidate file due to hardlinks"));
+		}            
 	}
 
 	if (cifs_sb->tcon->ses->capabilities & CAP_UNIX)
@@ -587,6 +605,28 @@
 	return;
 }
 
+static int cifs_trunc_page(struct address_space *mapping, loff_t from)
+{
+        pgoff_t index = from >> PAGE_CACHE_SHIFT;
+        unsigned offset = from & (PAGE_CACHE_SIZE-1);
+        struct page *page;
+        char *kaddr;
+        int rc = 0;
+
+        page = grab_cache_page(mapping, index);
+        if (!page)
+                return -ENOMEM;
+
+        kaddr = kmap_atomic(page, KM_USER0);
+        memset(kaddr + offset, 0, PAGE_CACHE_SIZE - offset);
+        flush_dcache_page(page);
+        kunmap_atomic(kaddr, KM_USER0);
+        set_page_dirty(page);
+        unlock_page(page);
+        page_cache_release(page);
+        return rc;
+}
+
 int
 cifs_setattr(struct dentry *direntry, struct iattr *attrs)
 {
@@ -639,7 +679,8 @@
 	/*	CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size, TRUE, cifs_sb->local_nls);*/
 		if (rc == 0) {
 			rc = vmtruncate(direntry->d_inode, attrs->ia_size);
-			nobh_truncate_page(direntry->d_inode->i_mapping, direntry->d_inode->i_size);
+			cifs_trunc_page(direntry->d_inode->i_mapping, direntry->d_inode->i_size); 
+
 /*          cFYI(1,("truncate_page to 0x%lx \n",direntry->d_inode->i_size)); */
 		}
 	}
@@ -653,17 +694,29 @@
 		gid = attrs->ia_gid;
 		/*      entry->gid = cpu_to_le16(attr->ia_gid); */
 	}
+
+	time_buf.Attributes = 0;
 	if (attrs->ia_valid & ATTR_MODE) {
 		cFYI(1, (" CIFS - Mode changed to 0x%x", attrs->ia_mode));
 		mode = attrs->ia_mode;
-		/*      entry->mode = cpu_to_le16(attr->ia_mode); */
+		/* entry->mode = cpu_to_le16(attr->ia_mode); */
 	}
 
 	if ((cifs_sb->tcon->ses->capabilities & CAP_UNIX)
 	    && (attrs->ia_valid & (ATTR_MODE | ATTR_GID | ATTR_UID)))
 		rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, uid, gid,
 				    cifs_sb->local_nls);
-	else {			/* BB to be implemented - via Windows security descriptors */
+	else if (attrs->ia_valid & ATTR_MODE) {
+		if((mode & S_IWUGO) == 0) /* not writeable */ {
+			if((cifsInode->cifsAttrs & ATTR_READONLY) == 0)
+				time_buf.Attributes = 
+					cpu_to_le32(cifsInode->cifsAttrs | ATTR_READONLY);
+		} else if((mode & S_IWUGO) == S_IWUGO) {
+			if(cifsInode->cifsAttrs & ATTR_READONLY)
+				time_buf.Attributes = 
+					cpu_to_le32(cifsInode->cifsAttrs & (~ATTR_READONLY));
+		}
+		/* BB to be implemented - via Windows security descriptors or streams */
 		/* CIFSSMBWinSetPerms(xid,pTcon,full_path,mode,uid,gid,cifs_sb->local_nls);*/
 	}
 
@@ -689,14 +742,12 @@
 	} else
 		time_buf.ChangeTime = 0;
 
-	if (set_time) {		
-        /* BB handle errors better if one attribute not set 
-            (such as size) but time setting works */
+	if (set_time | time_buf.Attributes) {
+		/* BB what if setting one attribute fails  
+			(such as size) but time setting works */
 		time_buf.CreationTime = 0;	/* do not change */
-		time_buf.Attributes = 0;	/* BB is this ignored by server?  
-                        or do I have to query and reset anyway BB */
 		rc = CIFSSMBSetTimes(xid, pTcon, full_path, &time_buf,
-				     cifs_sb->local_nls);
+				cifs_sb->local_nls);
 	}
 
 	/* do not  need local check to inode_check_ok since the server does that */
diff -Nru a/fs/cifs/link.c b/fs/cifs/link.c
--- a/fs/cifs/link.c	Wed Apr 30 22:28:07 2003
+++ b/fs/cifs/link.c	Wed Apr 30 22:28:07 2003
@@ -82,7 +82,7 @@
 	int rc = -EACCES;
 	int xid;
 	char *full_path = NULL;
-	char target_path[257];
+	char * target_path;
 	struct cifs_sb_info *cifs_sb;
 	struct cifsTconInfo *pTcon;
 
@@ -91,7 +91,11 @@
 	cFYI(1, ("Full path: %s inode = 0x%p", full_path, inode));
 	cifs_sb = CIFS_SB(inode->i_sb);
 	pTcon = cifs_sb->tcon;
-
+	target_path = kmalloc(PATH_MAX, GFP_KERNEL);
+	if(target_path == NULL) {
+		FreeXid(xid);
+		return -ENOMEM;
+	}
 	/* can not call the following line due to EFAULT in vfs_readlink which is presumably expecting a user space buffer */
 	/* length = cifs_readlink(direntry,target_path, sizeof(target_path) - 1);    */
 
@@ -99,7 +103,7 @@
 	if (pTcon->ses->capabilities & CAP_UNIX)
 		rc = CIFSSMBUnixQuerySymLink(xid, pTcon, full_path,
 					     target_path,
-					     sizeof (target_path) - 1,
+					     PATH_MAX-1,
 					     cifs_sb->local_nls);
 	else {
 		/* rc = CIFSSMBQueryReparseLinkInfo */
@@ -109,11 +113,13 @@
 	/* BB Should we be using page symlink ops here? */
 
 	if (rc == 0) {
-		target_path[256] = 0;
+		target_path[PATH_MAX-1] = 0;
 		rc = vfs_follow_link(nd, target_path);
 	}
 	/* else EACCESS */
 
+	if (target_path)
+		kfree(target_path);
 	if (full_path)
 		kfree(full_path);
 	FreeXid(xid);
@@ -180,7 +186,8 @@
 	struct cifs_sb_info *cifs_sb;
 	struct cifsTconInfo *pTcon;
 	char *full_path = NULL;
-	char tmpbuffer[256];
+	char * tmpbuffer;
+	int len;
 	__u16 fid;
 
 	xid = GetXid();
@@ -190,20 +197,28 @@
 	cFYI(1,
 	     ("Full path: %s inode = 0x%p pBuffer = 0x%p buflen = %d",
 	      full_path, inode, pBuffer, buflen));
-
+	if(buflen > PATH_MAX)
+		len = PATH_MAX;
+	else
+		len = buflen;
+	tmpbuffer = kmalloc(len,GFP_KERNEL);   
+	if(tmpbuffer == NULL) {
+		FreeXid(xid);
+		return -ENOMEM;
+	}
 /* BB add read reparse point symlink code and Unix extensions symlink code here BB */
 	if (cifs_sb->tcon->ses->capabilities & CAP_UNIX)
 		rc = CIFSSMBUnixQuerySymLink(xid, pTcon, full_path,
-					tmpbuffer,
-					sizeof (tmpbuffer) - 1,
-					cifs_sb->local_nls);
+				tmpbuffer,
+				len - 1,
+				cifs_sb->local_nls);
 	else {
 		rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, GENERIC_READ,
 				OPEN_REPARSE_POINT,&fid, &oplock, cifs_sb->local_nls);
 		if(!rc) {
 			rc = CIFSSMBQueryReparseLinkInfo(xid, pTcon, full_path,
 				tmpbuffer,
-				sizeof(tmpbuffer) - 1, 
+				len - 1, 
 				fid,
 				cifs_sb->local_nls);
 			if(CIFSSMBClose(xid, pTcon, fid)) {
@@ -216,15 +231,15 @@
 	/* BB Should we be using page ops here? */
 
 	/* BB null terminate returned string in pBuffer? BB */
-	if (buflen > sizeof (tmpbuffer))
-		buflen = sizeof (tmpbuffer);
 	if (rc == 0) {
-		rc = vfs_readlink(direntry, pBuffer, buflen, tmpbuffer);
+		rc = vfs_readlink(direntry, pBuffer, len, tmpbuffer);
 		cFYI(1,
 		     ("vfs_readlink called from cifs_readlink returned %d",
 		      rc));
 	}
 
+	if (tmpbuffer)
+		kfree(tmpbuffer);
 	if (full_path)
 		kfree(full_path);
 	FreeXid(xid);
diff -Nru a/fs/cifs/misc.c b/fs/cifs/misc.c
--- a/fs/cifs/misc.c	Wed Apr 30 22:28:18 2003
+++ b/fs/cifs/misc.c	Wed Apr 30 22:28:18 2003
@@ -27,6 +27,7 @@
 #include "cifs_debug.h"
 
 extern kmem_cache_t *cifs_req_cachep;
+extern struct task_struct * oplockThread;
 
 __u16 GlobalMid;		/* multiplex id - rotating counter */
 
@@ -336,6 +337,7 @@
 			list_for_each(tmp1,&tcon->openFileList){
 				netfile = list_entry(tmp1,struct cifsFileInfo,tlist);
 				if(pSMB->Fid == netfile->netfid) {
+					struct cifsInodeInfo *pCifsInode;
 			/* BB Add following logic: 
 			  2) look up inode from tcon->openFileList->file->f_dentry->d_inode
 			  3) flush dirty pages and cached byte range locks and mark inode
@@ -345,6 +347,15 @@
 			  6) send oplock break response to server */
 					read_unlock(&GlobalSMBSeslock);
 					cFYI(1,("Matching file id, processing oplock break"));
+					pCifsInode = 
+						CIFS_I(netfile->pfile->f_dentry->d_inode);
+					pCifsInode->clientCanCacheAll = FALSE;
+					if(pSMB->OplockLevel == 0)
+						pCifsInode->clientCanCacheRead = FALSE;
+					pCifsInode->oplockPending = TRUE;
+					AllocOplockQEntry(netfile->pfile, tcon);
+                    cFYI(1,("about to wake up oplock thd"));
+					wake_up_process(oplockThread);               
 					return TRUE;
 				}
 			}
diff -Nru a/fs/cifs/transport.c b/fs/cifs/transport.c
--- a/fs/cifs/transport.c	Wed Apr 30 22:28:06 2003
+++ b/fs/cifs/transport.c	Wed Apr 30 22:28:06 2003
@@ -32,6 +32,7 @@
 #include "cifs_debug.h"
 
 extern kmem_cache_t *cifs_mid_cachep;
+extern kmem_cache_t *cifs_oplock_cachep;
 
 struct mid_q_entry *
 AllocMidQEntry(struct smb_hdr *smb_buffer, struct cifsSesInfo *ses)
@@ -93,6 +94,39 @@
 	write_unlock(&GlobalMid_Lock);
 	buf_release(midEntry->resp_buf);
 	kmem_cache_free(cifs_mid_cachep, midEntry);
+}
+
+struct oplock_q_entry *
+AllocOplockQEntry(struct file * file, struct cifsTconInfo * tcon)
+{
+	struct oplock_q_entry *temp;
+	if ((file == NULL) || (tcon == NULL)) {
+		cERROR(1, ("Null parms passed to AllocOplockQEntry"));
+		return NULL;
+	}
+	temp = (struct oplock_q_entry *) kmem_cache_alloc(cifs_oplock_cachep,
+						       SLAB_KERNEL);
+	if (temp == NULL)
+		return temp;
+	else {
+		temp->file_to_flush = file;
+		temp->tcon = tcon;
+		write_lock(&GlobalMid_Lock);
+		list_add_tail(&temp->qhead, &GlobalOplock_Q);
+		write_unlock(&GlobalMid_Lock);
+	}
+    return temp;
+
+}
+
+void DeleteOplockQEntry(struct oplock_q_entry * oplockEntry)
+{
+	/* BB add spinlock to protect midq for each session BB */
+	write_lock(&GlobalMid_Lock); 
+    /* should we check if list empty first? */
+	list_del(&oplockEntry->qhead);
+	write_unlock(&GlobalMid_Lock);
+	kmem_cache_free(cifs_oplock_cachep, oplockEntry);
 }
 
 int
diff -Nru a/fs/compat.c b/fs/compat.c
--- a/fs/compat.c	Wed Apr 30 22:28:09 2003
+++ b/fs/compat.c	Wed Apr 30 22:28:09 2003
@@ -4,7 +4,11 @@
  *  Kernel compatibililty routines for e.g. 32 bit syscall support
  *  on 64 bit kernels.
  *
- *  Copyright (C) 2002 Stephen Rothwell, IBM Corporation
+ *  Copyright (C) 2002       Stephen Rothwell, IBM Corporation
+ *  Copyright (C) 1997-2000  Jakub Jelinek  (jakub@redhat.com)
+ *  Copyright (C) 1998       Eddie C. Dost  (ecd@skynet.be)
+ *  Copyright (C) 2001,2002  Andi Kleen, SuSE Labs 
+ *  Copyright (C) 2003       Pavel Machek (pavel@suse.cz)
  *
  *  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
@@ -20,6 +24,13 @@
 #include <linux/namei.h>
 #include <linux/file.h>
 #include <linux/vfs.h>
+#include <linux/ioctl32.h>
+#include <linux/init.h>
+#include <linux/sockios.h>	/* for SIOCDEVPRIVATE */
+#include <linux/fs.h>
+#include <linux/smp_lock.h>
+#include <linux/ctype.h>
+#include <linux/module.h>
 
 #include <asm/uaccess.h>
 
@@ -127,6 +138,217 @@
 		error = -EFAULT;
 	fput(file);
 out:
+	return error;
+}
+
+
+/* ioctl32 stuff, used by sparc64, parisc, s390x, ppc64, x86_64 */
+
+#define IOCTL_HASHSIZE 256
+struct ioctl_trans *ioctl32_hash_table[IOCTL_HASHSIZE];
+
+extern struct ioctl_trans ioctl_start[], ioctl_end[]; 
+
+static inline unsigned long ioctl32_hash(unsigned long cmd)
+{
+	return (((cmd >> 6) ^ (cmd >> 4) ^ cmd)) % IOCTL_HASHSIZE;
+}
+
+static void ioctl32_insert_translation(struct ioctl_trans *trans)
+{
+	unsigned long hash;
+	struct ioctl_trans *t;
+
+	hash = ioctl32_hash (trans->cmd);
+	if (!ioctl32_hash_table[hash])
+		ioctl32_hash_table[hash] = trans;
+	else {
+		t = ioctl32_hash_table[hash];
+		while (t->next)
+			t = t->next;
+		trans->next = 0;
+		t->next = trans;
+	}
+}
+
+static int __init init_sys32_ioctl(void)
+{
+	int i;
+
+	for (i = 0; &ioctl_start[i] < &ioctl_end[0]; i++) {
+		if (ioctl_start[i].next != 0) { 
+			printk("ioctl translation %d bad\n",i); 
+			return -1;
+		}
+
+		ioctl32_insert_translation(&ioctl_start[i]);
+	}
+	return 0;
+}
+
+__initcall(init_sys32_ioctl);
+
+static struct ioctl_trans *ioctl_free_list;
+
+/* Never free them really. This avoids SMP races. With a Read-Copy-Update
+   enabled kernel we could just use the RCU infrastructure for this. */
+static void free_ioctl(struct ioctl_trans *t) 
+{ 
+	t->cmd = 0; 
+	mb();
+	t->next = ioctl_free_list;
+	ioctl_free_list = t;
+} 
+
+int register_ioctl32_conversion(unsigned int cmd, int (*handler)(unsigned int, unsigned int, unsigned long, struct file *))
+{
+	struct ioctl_trans *t;
+	unsigned long hash = ioctl32_hash(cmd);
+
+	lock_kernel(); 
+	for (t = (struct ioctl_trans *)ioctl32_hash_table[hash];
+	     t;
+	     t = t->next) { 
+		if (t->cmd == cmd) {
+			printk("Trying to register duplicated ioctl32 handler %x\n", cmd);
+			unlock_kernel();
+			return -EINVAL; 
+		}
+	} 
+
+	if (ioctl_free_list) { 
+		t = ioctl_free_list; 
+		ioctl_free_list = t->next; 
+	} else { 
+		t = kmalloc(sizeof(struct ioctl_trans), GFP_KERNEL); 
+		if (!t) { 
+			unlock_kernel();
+			return -ENOMEM;
+		}
+	}
+	
+	t->next = NULL;
+	t->cmd = cmd;
+	t->handler = handler; 
+	ioctl32_insert_translation(t);
+
+	unlock_kernel();
+	return 0;
+}
+
+static inline int builtin_ioctl(struct ioctl_trans *t)
+{ 
+	return t >= (struct ioctl_trans *)ioctl_start &&
+	       t < (struct ioctl_trans *)ioctl_end; 
+} 
+
+/* Problem: 
+   This function cannot unregister duplicate ioctls, because they are not
+   unique.
+   When they happen we need to extend the prototype to pass the handler too. */
+
+int unregister_ioctl32_conversion(unsigned int cmd)
+{
+	unsigned long hash = ioctl32_hash(cmd);
+	struct ioctl_trans *t, *t1;
+
+	lock_kernel(); 
+
+	t = (struct ioctl_trans *)ioctl32_hash_table[hash];
+	if (!t) { 
+		unlock_kernel();
+		return -EINVAL;
+	} 
+
+	if (t->cmd == cmd) { 
+		if (builtin_ioctl(t)) {
+			printk("%p tried to unregister builtin ioctl %x\n",
+			       __builtin_return_address(0), cmd);
+		} else { 
+		ioctl32_hash_table[hash] = t->next;
+			free_ioctl(t); 
+			unlock_kernel();
+		return 0;
+		}
+	} 
+	while (t->next) {
+		t1 = (struct ioctl_trans *)(long)t->next;
+		if (t1->cmd == cmd) { 
+			if (builtin_ioctl(t1)) {
+				printk("%p tried to unregister builtin ioctl %x\n",
+				       __builtin_return_address(0), cmd);
+				goto out;
+			} else { 
+			t->next = t1->next;
+				free_ioctl(t1); 
+				unlock_kernel();
+			return 0;
+			}
+		}
+		t = t1;
+	}
+	printk(KERN_ERR "Trying to free unknown 32bit ioctl handler %x\n", cmd);
+ out:
+	unlock_kernel();
+	return -EINVAL;
+}
+
+EXPORT_SYMBOL(register_ioctl32_conversion); 
+EXPORT_SYMBOL(unregister_ioctl32_conversion); 
+
+asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
+{
+	struct file * filp;
+	int error = -EBADF;
+	int (*handler)(unsigned int, unsigned int, unsigned long, struct file * filp);
+	struct ioctl_trans *t;
+
+	filp = fget(fd);
+	if(!filp)
+		goto out2;
+
+	if (!filp->f_op || !filp->f_op->ioctl) {
+		error = sys_ioctl (fd, cmd, arg);
+		goto out;
+	}
+
+	t = (struct ioctl_trans *)ioctl32_hash_table [ioctl32_hash (cmd)];
+
+	while (t && t->cmd != cmd)
+		t = (struct ioctl_trans *)t->next;
+	if (t) {
+		handler = t->handler;
+		error = handler(fd, cmd, arg, filp);
+	} else if (cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) {
+		error = siocdevprivate_ioctl(fd, cmd, arg);
+	} else {
+		static int count;
+		if (++count <= 50) { 
+			char buf[10];
+			char *path = (char *)__get_free_page(GFP_KERNEL), *fn = "?"; 
+
+			/* find the name of the device. */
+			if (path) {
+		       		fn = d_path(filp->f_dentry, filp->f_vfsmnt, 
+					    path, PAGE_SIZE);
+			}
+
+			sprintf(buf,"'%c'", (cmd>>24) & 0x3f); 
+			if (!isprint(buf[1]))
+			    sprintf(buf, "%02x", buf[1]);
+			printk("ioctl32(%s:%d): Unknown cmd fd(%d) "
+			       "cmd(%08x){%s} arg(%08x) on %s\n",
+			       current->comm, current->pid,
+			       (int)fd, (unsigned int)cmd, buf, (unsigned int)arg,
+			       fn);
+			if (path) 
+				free_page((unsigned long)path); 
+		}
+		error = -EINVAL;
+	}
+out:
+	fput(filp);
+out2:
 	return error;
 }
 
diff -Nru a/fs/dcache.c b/fs/dcache.c
--- a/fs/dcache.c	Wed Apr 30 22:28:05 2003
+++ b/fs/dcache.c	Wed Apr 30 22:28:05 2003
@@ -155,12 +155,11 @@
  	if (d_unhashed(dentry))
 		goto kill_it;
   	if (list_empty(&dentry->d_lru)) {
-  		dentry->d_vfs_flags &= ~DCACHE_REFERENCED;
+  		dentry->d_vfs_flags |= DCACHE_REFERENCED;
   		list_add(&dentry->d_lru, &dentry_unused);
   		dentry_stat.nr_unused++;
   	}
  	spin_unlock(&dentry->d_lock);
-	dentry->d_vfs_flags |= DCACHE_REFERENCED;
 	spin_unlock(&dcache_lock);
 	return;
 
@@ -250,7 +249,6 @@
 static inline struct dentry * __dget_locked(struct dentry *dentry)
 {
 	atomic_inc(&dentry->d_count);
-	dentry->d_vfs_flags |= DCACHE_REFERENCED;
 	if (atomic_read(&dentry->d_count) == 1) {
 		dentry_stat.nr_unused--;
 		list_del_init(&dentry->d_lru);
@@ -379,17 +377,16 @@
 		dentry = list_entry(tmp, struct dentry, d_lru);
 
  		spin_lock(&dentry->d_lock);
+		/* leave inuse dentries */
+ 		if (atomic_read(&dentry->d_count)) {
+ 			spin_unlock(&dentry->d_lock);
+			continue;
+		}
 		/* If the dentry was recently referenced, don't free it. */
 		if (dentry->d_vfs_flags & DCACHE_REFERENCED) {
 			dentry->d_vfs_flags &= ~DCACHE_REFERENCED;
-
-			/* don't add non zero d_count dentries 
-			 * back to d_lru list
-			 */
- 			if (!atomic_read(&dentry->d_count)) {
- 				list_add(&dentry->d_lru, &dentry_unused);
- 				dentry_stat.nr_unused++;
- 			}
+ 			list_add(&dentry->d_lru, &dentry_unused);
+ 			dentry_stat.nr_unused++;
  			spin_unlock(&dentry->d_lock);
 			continue;
 		}
@@ -538,13 +535,18 @@
 		struct list_head *tmp = next;
 		struct dentry *dentry = list_entry(tmp, struct dentry, d_child);
 		next = tmp->next;
-		list_del_init(&dentry->d_lru);
 
-		/* don't add non zero d_count dentries 
-		 * back to d_lru list
+		if (!list_empty(&dentry->d_lru)) {
+			dentry_stat.nr_unused--;
+			list_del_init(&dentry->d_lru);
+		}
+		/* 
+		 * move only zero ref count dentries to the end 
+		 * of the unused list for prune_dcache
 		 */
 		if (!atomic_read(&dentry->d_count)) {
 			list_add(&dentry->d_lru, dentry_unused.prev);
+			dentry_stat.nr_unused++;
 			found++;
 		}
 		/*
@@ -609,13 +611,18 @@
 		spin_lock(&dcache_lock);
 		hlist_for_each(lp, head) {
 			struct dentry *this = hlist_entry(lp, struct dentry, d_hash);
-			list_del(&this->d_lru);
+			if (!list_empty(&this->d_lru)) {
+				dentry_stat.nr_unused--;
+				list_del(&this->d_lru);
+			}
 
-			/* don't add non zero d_count dentries 
-			 * back to d_lru list
+			/* 
+			 * move only zero ref count dentries to the end 
+			 * of the unused list for prune_dcache
 			 */
 			if (!atomic_read(&this->d_count)) {
 				list_add_tail(&this->d_lru, &dentry_unused);
+				dentry_stat.nr_unused++;
 				found++;
 			}
 		}
@@ -1017,7 +1024,6 @@
 		if (likely(move_count == dentry->d_move_count)) {
 			if (!d_unhashed(dentry)) {
 				atomic_inc(&dentry->d_count);
-				dentry->d_vfs_flags |= DCACHE_REFERENCED;
 				found = dentry;
 			}
 		}
diff -Nru a/fs/devfs/base.c b/fs/devfs/base.c
--- a/fs/devfs/base.c	Wed Apr 30 22:28:05 2003
+++ b/fs/devfs/base.c	Wed Apr 30 22:28:05 2003
@@ -763,7 +763,6 @@
 
 struct bdev_type
 {
-    struct block_device_operations *ops;
     dev_t dev;
 };
 
@@ -1442,7 +1441,6 @@
  *		this to whatever you like, and change it once the file is opened (the next
  *		file opened will not see this change).
  *
- *	Returns a handle which may later be used in a call to devfs_unregister().
  *	On failure %NULL is returned.
  */
 
@@ -1457,6 +1455,8 @@
 
     /* we don't accept any flags anymore.  prototype will change soon. */
     WARN_ON(flags);
+    WARN_ON(dir);
+    WARN_ON(!S_ISCHR(mode));
 
     if (name == NULL)
     {
@@ -1491,7 +1491,6 @@
     } else if (S_ISBLK (mode)) {
 	de->u.bdev.dev = dev;
 	de->u.cdev.autogen = devnum != 0;
-	de->u.bdev.ops = ops;
     } else {
 	PRINTK ("(%s): illegal mode: %x\n", name, mode);
 	devfs_put (de);
@@ -1517,6 +1516,52 @@
 }   /*  End Function devfs_register  */
 
 
+int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...)
+{
+	struct devfs_entry *dir = NULL, *de;
+	char buf[64];
+	va_list args;
+	int error, n;
+
+	if (!S_ISBLK(mode)) {
+		printk(KERN_WARNING "%s: invalide mode (%u) for %s\n",
+				__FUNCTION__, mode, buf);
+		return -EINVAL;
+	}
+
+	va_start(args, fmt);
+	n = vsnprintf(buf, 64, fmt, args);
+	if (n >= 64 || !buf[0]) {
+		printk(KERN_WARNING "%s: invalid format string\n",
+				__FUNCTION__);
+		return -EINVAL;
+	}
+
+	de = _devfs_prepare_leaf(&dir, buf, mode);
+	if (!de) {
+		printk(KERN_WARNING "%s: could not prepare leaf for %s\n",
+				__FUNCTION__, buf);
+		return -ENOMEM;		/* could be more accurate... */
+	}
+
+	de->u.bdev.dev = dev;
+
+	error = _devfs_append_entry(dir, de, NULL);
+	if (error) {
+		printk(KERN_WARNING "%s: could not append to parent for %s\n",
+				__FUNCTION__, buf);
+		goto out;
+	}
+
+	devfsd_notify(de, DEVFSD_NOTIFY_REGISTERED);
+ out:
+	devfs_put(dir);
+	return error;
+}
+
+EXPORT_SYMBOL(devfs_mk_bdev);
+
+
 /**
  *	_devfs_unhook - Unhook a device entry from its parents list
  *	@de: The entry to unhook.
@@ -1578,24 +1623,6 @@
     }
 }   /*  End Function _devfs_unregister  */
 
-
-/**
- *	devfs_unregister - Unregister a device entry.
- *	@de: A handle previously created by devfs_register() or returned from
- *		devfs_get_handle(). If this is %NULL the routine does nothing.
- */
-
-void devfs_unregister (devfs_handle_t de)
-{
-    VERIFY_ENTRY (de);
-    if ( (de == NULL) || (de->parent == NULL) ) return;
-    DPRINTK (DEBUG_UNREGISTER, "(%s): de: %p  refcount: %d\n",
-	     de->name, de, atomic_read (&de->refcount) );
-    write_lock (&de->parent->u.dir.lock);
-    _devfs_unregister (de->parent, de);
-    devfs_put (de);
-}   /*  End Function devfs_unregister  */
-
 static int devfs_do_symlink (devfs_handle_t dir, const char *name,
 			     const char *link, devfs_handle_t *handle)
 {
@@ -1678,45 +1705,42 @@
  *	Use of this function is optional. The devfs_register() function
  *	will automatically create intermediate directories as needed. This function
  *	is provided for efficiency reasons, as it provides a handle to a directory.
- *	Returns a handle which may later be used in a call to devfs_unregister().
  *	On failure %NULL is returned.
  */
 
-devfs_handle_t devfs_mk_dir(const char *fmt, ...)
+int devfs_mk_dir(const char *fmt, ...)
 {
 	struct devfs_entry *dir = NULL, *de = NULL, *old;
 	char buf[64];
 	va_list args;
-	int n;
+	int error, n;
 
 	va_start(args, fmt);
 	n = vsnprintf(buf, 64, fmt, args);
 	if (n >= 64 || !buf[0]) {
 		printk(KERN_WARNING "%s: invalid argument.", __FUNCTION__);
-		return NULL;
+		return -EINVAL;
 	}
 
 	de = _devfs_prepare_leaf(&dir, buf, MODE_DIR);
 	if (!de) {
 		PRINTK("(%s): could not prepare leaf\n", buf);
-		return NULL;
+		return -EINVAL;
 	}
 
-	de->info = NULL;
-	if (_devfs_append_entry(dir, de, &old)) {
+	error = _devfs_append_entry(dir, de, &old);
+	if (error) {
 		PRINTK("(%s): could not append to dir: %p \"%s\"\n",
 				buf, dir, dir->name);
 		devfs_put(old);
 		goto out_put;
 	}
 	
-	DPRINTK(DEBUG_REGISTER, "(%s): de: %p dir: %p \"%s\"\n",
-			buf, de, dir, dir->name);
 	devfsd_notify(de, DEVFSD_NOTIFY_REGISTERED);
 
  out_put:
 	devfs_put(dir);
-	return de;
+	return error;
 }
 
 
@@ -1730,7 +1754,10 @@
 	n = vsnprintf(buf, 64, fmt, args);
 	if (n < 64 && buf[0]) {
 		devfs_handle_t de = _devfs_find_entry(NULL, buf, 0);
-		devfs_unregister(de);
+
+		write_lock(&de->parent->u.dir.lock);
+		_devfs_unregister(de->parent, de);
+		devfs_put(de);
 		devfs_put(de);
 	}
 }
@@ -1863,7 +1890,6 @@
 
 EXPORT_SYMBOL(devfs_put);
 EXPORT_SYMBOL(devfs_register);
-EXPORT_SYMBOL(devfs_unregister);
 EXPORT_SYMBOL(devfs_mk_symlink);
 EXPORT_SYMBOL(devfs_mk_dir);
 EXPORT_SYMBOL(devfs_remove);
diff -Nru a/fs/devfs/util.c b/fs/devfs/util.c
--- a/fs/devfs/util.c	Wed Apr 30 22:28:10 2003
+++ b/fs/devfs/util.c	Wed Apr 30 22:28:10 2003
@@ -74,8 +74,6 @@
 #include <asm/bitops.h>
 #include "internal.h"
 
-#define PRINTK(format, args...) \
-   {printk (KERN_ERR "%s" format, __FUNCTION__ , ## args);}
 
 int devfs_register_tape(const char *name)
 {
@@ -255,162 +253,4 @@
 		}
 	}
 	up(&device_list_mutex);
-}
-
-struct unique_numspace
-{
-    spinlock_t init_lock;
-    unsigned char sem_initialised;
-    unsigned int num_free;          /*  Num free in bits       */
-    unsigned int length;            /*  Array length in bytes  */
-    unsigned long *bits;
-    struct semaphore semaphore;
-};
-
-#define UNIQUE_NUMBERSPACE_INITIALISER {SPIN_LOCK_UNLOCKED, 0, 0, 0, NULL}
-
-
-/**
- *	devfs_alloc_unique_number - Allocate a unique (positive) number.
- *	@space: The number space to allocate from.
- *
- *	Returns the allocated unique number, else a negative error code.
- *	This routine is thread safe and may block.
- */
-
-int devfs_alloc_unique_number (struct unique_numspace *space)
-{
-    int number;
-    unsigned int length;
-
-    /*  Get around stupid lack of semaphore initialiser  */
-    spin_lock (&space->init_lock);
-    if (!space->sem_initialised)
-    {
-	sema_init (&space->semaphore, 1);
-	space->sem_initialised = 1;
-    }
-    spin_unlock (&space->init_lock);
-    down (&space->semaphore);
-    if (space->num_free < 1)
-    {
-	void *bits;
-
-	if (space->length < 16) length = 16;
-	else length = space->length << 1;
-	if ( ( bits = vmalloc (length) ) == NULL )
-	{
-	    up (&space->semaphore);
-	    return -ENOMEM;
-	}
-	if (space->bits != NULL)
-	{
-	    memcpy (bits, space->bits, space->length);
-	    vfree (space->bits);
-	}
-	space->num_free = (length - space->length) << 3;
-	space->bits = bits;
-	memset (bits + space->length, 0, length - space->length);
-	space->length = length;
-    }
-    number = find_first_zero_bit (space->bits, space->length << 3);
-    --space->num_free;
-    __set_bit (number, space->bits);
-    up (&space->semaphore);
-    return number;
-}   /*  End Function devfs_alloc_unique_number  */
-EXPORT_SYMBOL(devfs_alloc_unique_number);
-
-
-/**
- *	devfs_dealloc_unique_number - Deallocate a unique (positive) number.
- *	@space: The number space to deallocate from.
- *	@number: The number to deallocate.
- *
- *	This routine is thread safe and may block.
- */
-
-void devfs_dealloc_unique_number (struct unique_numspace *space, int number)
-{
-    int was_set;
-
-    if (number < 0) return;
-    down (&space->semaphore);
-    was_set = __test_and_clear_bit (number, space->bits);
-    if (was_set) ++space->num_free;
-    up (&space->semaphore);
-    if (!was_set) PRINTK ("(): number %d was already free\n", number);
-}   /*  End Function devfs_dealloc_unique_number  */
-EXPORT_SYMBOL(devfs_dealloc_unique_number);
-
-static struct unique_numspace disc_numspace = UNIQUE_NUMBERSPACE_INITIALISER;
-static struct unique_numspace cdrom_numspace = UNIQUE_NUMBERSPACE_INITIALISER;
-
-void devfs_create_partitions(struct gendisk *disk)
-{
-	char dirname[64], diskname[64], symlink[16];
-
-	if (!disk->devfs_name)
-		sprintf(disk->devfs_name, "%s/disc%d", disk->disk_name,
-				disk->first_minor >> disk->minor_shift);
-
-	devfs_mk_dir(disk->devfs_name);
-	disk->number = devfs_alloc_unique_number(&disc_numspace);
-
-	sprintf(diskname, "%s/disc", disk->devfs_name);
-	devfs_register(NULL, diskname, 0,
-			disk->major, disk->first_minor,
-			S_IFBLK | S_IRUSR | S_IWUSR,
-			disk->fops, NULL);
-
-	sprintf(symlink, "discs/disc%d", disk->number);
-	sprintf(dirname, "../%s", disk->devfs_name);
-	devfs_mk_symlink(symlink, dirname);
-
-}
-
-void devfs_create_cdrom(struct gendisk *disk)
-{
-	char dirname[64], cdname[64], symlink[16];
-
-	if (!disk->devfs_name)
-		strcat(disk->devfs_name, disk->disk_name);
-
-	devfs_mk_dir(disk->devfs_name);
-	disk->number = devfs_alloc_unique_number(&cdrom_numspace);
-
-	sprintf(cdname, "%s/cd", disk->devfs_name);
-	devfs_register(NULL, cdname, 0,
-			disk->major, disk->first_minor,
-			S_IFBLK | S_IRUGO | S_IWUGO,
-			disk->fops, NULL);
-
-	sprintf(symlink, "cdroms/cdrom%d", disk->number);
-	sprintf(dirname, "../%s", disk->devfs_name);
-	devfs_mk_symlink(symlink, dirname);
-}
-
-void devfs_register_partition(struct gendisk *dev, int part)
-{
-	char devname[64];
-
-	sprintf(devname, "%s/part%d", dev->devfs_name, part);
-	devfs_register(NULL, devname, 0,
-			dev->major, dev->first_minor + part,
-			S_IFBLK | S_IRUSR | S_IWUSR,
-			dev->fops, NULL);
-}
-
-void devfs_remove_partitions(struct gendisk *disk)
-{
-	devfs_remove("discs/disc%d", disk->number);
-	devfs_remove(disk->devfs_name);
-	devfs_dealloc_unique_number(&disc_numspace, disk->number);
-}
-
-void devfs_remove_cdrom(struct gendisk *disk)
-{
-	devfs_remove("cdroms/cdrom%d", disk->number);
-	devfs_remove(disk->devfs_name);
-	devfs_dealloc_unique_number(&cdrom_numspace, disk->number);
 }
diff -Nru a/fs/dquot.c b/fs/dquot.c
--- a/fs/dquot.c	Wed Apr 30 22:28:12 2003
+++ b/fs/dquot.c	Wed Apr 30 22:28:12 2003
@@ -345,50 +345,6 @@
 	return 0;
 }
 
-static struct super_block *get_super_to_sync(int type)
-{
-	struct list_head *head;
-	int cnt, dirty;
-
-restart:
-	spin_lock(&sb_lock);
-	list_for_each(head, &super_blocks) {
-		struct super_block *sb = list_entry(head, struct super_block, s_list);
-
-		for (cnt = 0, dirty = 0; cnt < MAXQUOTAS; cnt++)
-			if ((type == cnt || type == -1) && sb_has_quota_enabled(sb, cnt)
-			    && info_any_dquot_dirty(&sb_dqopt(sb)->info[cnt]))
-				dirty = 1;
-		if (!dirty)
-			continue;
-		sb->s_count++;
-		spin_unlock(&sb_lock);
-		down_read(&sb->s_umount);
-		if (!sb->s_root) {
-			drop_super(sb);
-			goto restart;
-		}
-		return sb;
-	}
-	spin_unlock(&sb_lock);
-	return NULL;
-}
-
-void sync_dquots(struct super_block *sb, int type)
-{
-	if (sb) {
-		if (sb->s_qcop->quota_sync)
-			sb->s_qcop->quota_sync(sb, type);
-	}
-	else {
-		while ((sb = get_super_to_sync(type))) {
-			if (sb->s_qcop->quota_sync)
-				sb->s_qcop->quota_sync(sb, type);
-			drop_super(sb);
-		}
-	}
-}
-
 /* Free unused dquots from cache */
 static void prune_dqcache(int count)
 {
diff -Nru a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
--- a/fs/exportfs/expfs.c	Wed Apr 30 22:28:15 2003
+++ b/fs/exportfs/expfs.c	Wed Apr 30 22:28:15 2003
@@ -91,7 +91,6 @@
 			if (dentry != result &&
 			    acceptable(context, dentry)) {
 				dput(result);
-				dentry->d_vfs_flags |= DCACHE_REFERENCED;
 				return dentry;
 			}
 			spin_lock(&dcache_lock);
@@ -271,7 +270,6 @@
 		if (dentry != result &&
 		    acceptable(context, dentry)) {
 			dput(result);
-			dentry->d_vfs_flags |= DCACHE_REFERENCED;
 			return dentry;
 		}
 		spin_lock(&dcache_lock);
@@ -434,7 +432,6 @@
 		iput(inode);
 		return ERR_PTR(-ENOMEM);
 	}
-	result->d_vfs_flags |= DCACHE_REFERENCED;
 	return result;
 }
 
diff -Nru a/fs/ext3/super.c b/fs/ext3/super.c
--- a/fs/ext3/super.c	Wed Apr 30 22:28:16 2003
+++ b/fs/ext3/super.c	Wed Apr 30 22:28:16 2003
@@ -384,20 +384,16 @@
 static struct block_device *ext3_blkdev_get(dev_t dev)
 {
 	struct block_device *bdev;
-	int err = -ENODEV;
 	char b[BDEVNAME_SIZE];
 
-	bdev = bdget(dev);
-	if (bdev == NULL)
-		goto fail;
-	err = blkdev_get(bdev, FMODE_READ|FMODE_WRITE, 0, BDEV_FS);
-	if (err < 0)
+	bdev = open_by_devnum(dev, FMODE_READ|FMODE_WRITE, BDEV_FS);
+	if (IS_ERR(bdev))
 		goto fail;
 	return bdev;
 
 fail:
-	printk(KERN_ERR "EXT3: failed to open journal device %s: %d\n",
-			__bdevname(dev, b), err);
+	printk(KERN_ERR "EXT3: failed to open journal device %s: %ld\n",
+			__bdevname(dev, b), PTR_ERR(bdev));
 	return NULL;
 }
 
@@ -982,12 +978,6 @@
 		return;
 	}
 
-	if (s_flags & MS_RDONLY) {
-		printk(KERN_INFO "EXT3-fs: %s: orphan cleanup on readonly fs\n",
-		       sb->s_id);
-		sb->s_flags &= ~MS_RDONLY;
-	}
-
 	if (EXT3_SB(sb)->s_mount_state & EXT3_ERROR_FS) {
 		if (es->s_last_orphan)
 			jbd_debug(1, "Errors on filesystem, "
@@ -995,6 +985,12 @@
 		es->s_last_orphan = 0;
 		jbd_debug(1, "Skipping orphan recovery on fs with errors.\n");
 		return;
+	}
+
+	if (s_flags & MS_RDONLY) {
+		printk(KERN_INFO "EXT3-fs: %s: orphan cleanup on readonly fs\n",
+		       sb->s_id);
+		sb->s_flags &= ~MS_RDONLY;
 	}
 
 	while (es->s_last_orphan) {
diff -Nru a/fs/fat/inode.c b/fs/fat/inode.c
--- a/fs/fat/inode.c	Wed Apr 30 22:28:08 2003
+++ b/fs/fat/inode.c	Wed Apr 30 22:28:08 2003
@@ -608,7 +608,6 @@
 		return ERR_PTR(-ENOMEM);
 	}
 	result->d_op = sb->s_root->d_op;
-	result->d_vfs_flags |= DCACHE_REFERENCED;
 	return result;
 }
 
diff -Nru a/fs/filesystems.c b/fs/filesystems.c
--- a/fs/filesystems.c	Wed Apr 30 22:28:15 2003
+++ b/fs/filesystems.c	Wed Apr 30 22:28:15 2003
@@ -32,17 +32,7 @@
 /* WARNING: This can be used only if we _already_ own a reference */
 void get_filesystem(struct file_system_type *fs)
 {
-	if (!try_module_get(fs->owner)) {
-#ifdef CONFIG_MODULE_UNLOAD
-		unsigned int cpu = get_cpu();
-		local_inc(&fs->owner->ref[cpu].count);
-		put_cpu();
-#else
-		/* Getting filesystem while it's starting up?  We're
-                   already supposed to have a reference. */
-		BUG();
-#endif
-	}
+	__module_get(fs->owner);
 }
 
 void put_filesystem(struct file_system_type *fs)
diff -Nru a/fs/inode.c b/fs/inode.c
--- a/fs/inode.c	Wed Apr 30 22:28:19 2003
+++ b/fs/inode.c	Wed Apr 30 22:28:19 2003
@@ -340,15 +340,11 @@
 	return busy;
 }
  
-int invalidate_device(kdev_t dev, int do_sync)
+int __invalidate_device(struct block_device *bdev, int do_sync)
 {
 	struct super_block *sb;
-	struct block_device *bdev = bdget(kdev_t_to_nr(dev));
 	int res;
 
-	if (!bdev)
-		return 0;
-
 	if (do_sync)
 		fsync_bdev(bdev);
 
@@ -366,7 +362,6 @@
 		drop_super(sb);
 	}
 	invalidate_bdev(bdev, 0);
-	bdput(bdev);
 	return res;
 }
 
diff -Nru a/fs/isofs/rock.c b/fs/isofs/rock.c
--- a/fs/isofs/rock.c	Wed Apr 30 22:28:10 2003
+++ b/fs/isofs/rock.c	Wed Apr 30 22:28:10 2003
@@ -84,76 +84,6 @@
     printk("Unable to read rock-ridge attributes\n");    \
   }}
 
-/* This is the inner layer of the get filename routine, and is called
-   for each system area and continuation record related to the file */
-
-int find_rock_ridge_relocation(struct iso_directory_record * de, 
-			       struct inode * inode) {
-  int flag;
-  int len;
-  int retval;
-  unsigned char * chr;
-  CONTINUE_DECLS;
-  flag = 0;
-  
-  /* If this is a '..' then we are looking for the parent, otherwise we
-     are looking for the child */
-  
-  if (de->name[0]==1 && de->name_len[0]==1) flag = 1;
-  /* Return value if we do not find appropriate record. */
-  retval = isonum_733 (de->extent);
-  
-  if (!ISOFS_SB(inode->i_sb)->s_rock) return retval;
-
-  SETUP_ROCK_RIDGE(de, chr, len);
- repeat:
-  {
-    int rrflag, sig;
-    struct rock_ridge * rr;
-    
-    while (len > 1){ /* There may be one byte for padding somewhere */
-      rr = (struct rock_ridge *) chr;
-      if (rr->len == 0) goto out; /* Something got screwed up here */
-      sig = isonum_721(chr);
-      chr += rr->len; 
-      len -= rr->len;
-
-      switch(sig){
-      case SIG('R','R'):
-	rrflag = rr->u.RR.flags[0];
-	if (flag && !(rrflag & RR_PL)) goto out;
-	if (!flag && !(rrflag & RR_CL)) goto out;
-	break;
-      case SIG('S','P'):
-	CHECK_SP(goto out);
-	break;
-      case SIG('C','L'):
-	if (flag == 0) {
-	  retval = isonum_733(rr->u.CL.location);
-	  goto out;
-	}
-	break;
-      case SIG('P','L'):
-	if (flag != 0) {
-	  retval = isonum_733(rr->u.PL.location);
-	  goto out;
-	}
-	break;
-      case SIG('C','E'):
-	CHECK_CE; /* This tells is if there is a continuation record */
-	break;
-      default:
-	break;
-      }
-    }
-  }
-  MAYBE_CONTINUE(repeat, inode);
-  return retval;
- out:
-  if(buffer) kfree(buffer);
-  return retval;
-}
-
 /* return length of name field; 0: not found, -1: to be ignored */
 int get_rock_ridge_filename(struct iso_directory_record * de,
 			    char * retname, struct inode * inode)
diff -Nru a/fs/jbd/journal.c b/fs/jbd/journal.c
--- a/fs/jbd/journal.c	Wed Apr 30 22:28:05 2003
+++ b/fs/jbd/journal.c	Wed Apr 30 22:28:05 2003
@@ -457,14 +457,8 @@
 	/*
 	 * Right, time to make up the new buffer_head.
 	 */
-	do {
-		new_bh = alloc_buffer_head();
-		if (!new_bh) {
-			printk (KERN_NOTICE "%s: ENOMEM at alloc_buffer_head, "
-				"trying again.\n", __FUNCTION__);
-			yield();
-		}
-	} while (!new_bh);
+	new_bh = alloc_buffer_head(GFP_NOFS|__GFP_NOFAIL);
+
 	/* keep subsequent assertions sane */
 	new_bh->b_state = 0;
 	init_buffer(new_bh, NULL, NULL);
@@ -1613,28 +1607,7 @@
  */
 void * __jbd_kmalloc (const char *where, size_t size, int flags, int retry)
 {
-	void *p;
-	static unsigned long last_warning;
-	
-	while (1) {
-		p = kmalloc(size, flags);
-		if (p)
-			return p;
-		if (!retry)
-			return NULL;
-		/* Log every retry for debugging.  Also log them to the
-		 * syslog, but do rate-limiting on the non-debugging
-		 * messages. */
-		jbd_debug(1, "ENOMEM in %s, retrying.\n", where);
-
-		if (time_after(jiffies, last_warning + 5*HZ)) {
-			printk(KERN_NOTICE
-			       "ENOMEM in %s, retrying.\n", where);
-			last_warning = jiffies;
-		}
-		
-		yield();
-	}
+	return kmalloc(size, flags | (retry ? __GFP_NOFAIL : 0));	
 }
 
 /*
diff -Nru a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
--- a/fs/jfs/jfs_logmgr.c	Wed Apr 30 22:28:09 2003
+++ b/fs/jfs/jfs_logmgr.c	Wed Apr 30 22:28:09 2003
@@ -1105,13 +1105,10 @@
 	 */
       externalLog:
 
-	if (!(bdev = bdget(JFS_SBI(sb)->logdev))) {
-		rc = ENODEV;
-		goto free;
-	}
-
-	if ((rc = blkdev_get(bdev, FMODE_READ|FMODE_WRITE, 0, BDEV_FS))) {
-		rc = -rc;
+	bdev = open_by_devnum(JFS_SBI(sb)->logdev,
+					FMODE_READ|FMODE_WRITE, BDEV_FS);
+	if (IS_ERR(bdev)) {
+		rc = -PTR_ERR(bdev);
 		goto free;
 	}
 
diff -Nru a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c
--- a/fs/jfs/jfs_txnmgr.c	Wed Apr 30 22:28:10 2003
+++ b/fs/jfs/jfs_txnmgr.c	Wed Apr 30 22:28:10 2003
@@ -1240,8 +1240,21 @@
 	 * Ensure that inode isn't reused before
 	 * lazy commit thread finishes processing
 	 */
-	if (tblk->xflag & (COMMIT_CREATE | COMMIT_DELETE))
+	if (tblk->xflag & (COMMIT_CREATE | COMMIT_DELETE)) {
 		atomic_inc(&tblk->ip->i_count);
+		/*
+		 * Avoid a rare deadlock
+		 *
+		 * If the inode is locked, we may be blocked in
+		 * jfs_commit_inode.  If so, we don't want the
+		 * lazy_commit thread doing the last iput() on the inode
+		 * since that may block on the locked inode.  Instead,
+		 * commit the transaction synchronously, so the last iput
+		 * will be done by the calling thread (or later)
+		 */
+		if (tblk->ip->i_state & I_LOCK)
+			tblk->xflag &= ~COMMIT_LAZY;
+	}
 
 	ASSERT((!(tblk->xflag & COMMIT_DELETE)) ||
 	       ((tblk->ip->i_nlink == 0) &&
diff -Nru a/fs/libfs.c b/fs/libfs.c
--- a/fs/libfs.c	Wed Apr 30 22:28:03 2003
+++ b/fs/libfs.c	Wed Apr 30 22:28:03 2003
@@ -4,8 +4,11 @@
  */
 
 #include <linux/pagemap.h>
+#include <linux/mount.h>
 #include <linux/vfs.h>
 
+extern struct vfsmount *do_kern_mount(const char *, int, char *, void *);
+
 int simple_getattr(struct vfsmount *mnt, struct dentry *dentry,
 		   struct kstat *stat)
 {
@@ -331,4 +334,95 @@
 		inode->i_size = pos;
 	set_page_dirty(page);
 	return 0;
+}
+
+int simple_fill_super(struct super_block *s, int magic, struct tree_descr *files)
+{
+	static struct super_operations s_ops = {statfs:simple_statfs};
+	struct inode *inode;
+	struct dentry *root;
+	struct dentry *dentry;
+	int i;
+
+	s->s_blocksize = PAGE_CACHE_SIZE;
+	s->s_blocksize_bits = PAGE_CACHE_SHIFT;
+	s->s_magic = magic;
+	s->s_op = &s_ops;
+
+	inode = new_inode(s);
+	if (!inode)
+		return -ENOMEM;
+	inode->i_mode = S_IFDIR | 0755;
+	inode->i_uid = inode->i_gid = 0;
+	inode->i_blksize = PAGE_CACHE_SIZE;
+	inode->i_blocks = 0;
+	inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+	inode->i_op = &simple_dir_inode_operations;
+	inode->i_fop = &simple_dir_operations;
+	root = d_alloc_root(inode);
+	if (!root) {
+		iput(inode);
+		return -ENOMEM;
+	}
+	for (i = 0; !files->name || files->name[0]; i++, files++) {
+		struct qstr name;
+		if (!files->name)
+			continue;
+		name.name = files->name;
+		name.len = strlen(name.name);
+		name.hash = full_name_hash(name.name, name.len);
+		dentry = d_alloc(root, &name);
+		if (!dentry)
+			goto out;
+		inode = new_inode(s);
+		if (!inode)
+			goto out;
+		inode->i_mode = S_IFREG | files->mode;
+		inode->i_uid = inode->i_gid = 0;
+		inode->i_blksize = PAGE_CACHE_SIZE;
+		inode->i_blocks = 0;
+		inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+		inode->i_fop = files->ops;
+		inode->i_ino = i;
+		d_add(dentry, inode);
+	}
+	s->s_root = root;
+	return 0;
+out:
+	d_genocide(root);
+	dput(root);
+	return -ENOMEM;
+}
+
+static spinlock_t pin_fs_lock = SPIN_LOCK_UNLOCKED;
+
+int simple_pin_fs(char *name, struct vfsmount **mount, int *count)
+{
+	struct vfsmount *mnt = NULL;
+	spin_lock(&pin_fs_lock);
+	if (unlikely(!*mount)) {
+		spin_unlock(&pin_fs_lock);
+		mnt = do_kern_mount(name, 0, name, NULL);
+		if (IS_ERR(mnt))
+			return PTR_ERR(mnt);
+		spin_lock(&pin_fs_lock);
+		if (!*mount)
+			*mount = mnt;
+	}
+	mntget(*mount);
+	++*count;
+	spin_unlock(&pin_fs_lock);
+	mntput(mnt);
+	return 0;
+}
+
+void simple_release_fs(struct vfsmount **mount, int *count)
+{
+	struct vfsmount *mnt;
+	spin_lock(&pin_fs_lock);
+	mnt = *mount;
+	if (!--*count)
+		*mount = NULL;
+	spin_unlock(&pin_fs_lock);
+	mntput(mnt);
 }
diff -Nru a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
--- a/fs/nfs/nfs4proc.c	Wed Apr 30 22:28:14 2003
+++ b/fs/nfs/nfs4proc.c	Wed Apr 30 22:28:14 2003
@@ -572,10 +572,10 @@
 	u32                     f_bmres[2];
 	u32                     d_bmres[2];
 	struct nfs_fattr        d_attr = {
-		.valid          0,
+		.valid          = 0,
 	};
 	struct nfs_fattr        f_attr = {
-		.valid          0,
+		.valid          = 0,
 	};
 	struct nfs4_getattr     f_getattr = {
 		.gt_bmval       = nfs4_fattr_bitmap,
diff -Nru a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
--- a/fs/nfsd/nfsctl.c	Wed Apr 30 22:28:05 2003
+++ b/fs/nfsd/nfsctl.c	Wed Apr 30 22:28:05 2003
@@ -48,7 +48,6 @@
 	NFSD_List,
 	NFSD_Fh,
 	NFSD_Threads,
-	NFSD_END
 };
 
 /*
@@ -204,22 +203,6 @@
 	.release	= exports_release,
 };
 
-/*
- *	Description of fs contents.
- */
-static struct { char *name; struct file_operations *ops; int mode; } files[] = {
-	[NFSD_Svc] = {".svc", &transaction_ops, S_IWUSR},
-	[NFSD_Add] = {".add", &transaction_ops, S_IWUSR},
-	[NFSD_Del] = {".del", &transaction_ops, S_IWUSR},
-	[NFSD_Export] = {".export", &transaction_ops, S_IWUSR},
-	[NFSD_Unexport] = {".unexport", &transaction_ops, S_IWUSR},
-	[NFSD_Getfd] = {".getfd", &transaction_ops, S_IWUSR|S_IRUSR},
-	[NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR},
-	[NFSD_List] = {"exports", &exports_operations, S_IRUGO},
-	[NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR},
-	[NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR},
-};
-
 /*----------------------------------------------------------------------------*/
 /*
  * payload - write methods
@@ -431,64 +414,22 @@
  *	populating the filesystem.
  */
 
-static struct super_operations s_ops = {
-	.statfs		= simple_statfs,
-};
-
 static int nfsd_fill_super(struct super_block * sb, void * data, int silent)
 {
-	struct inode *inode;
-	struct dentry *root;
-	struct dentry *dentry;
-	int i;
-
-	sb->s_blocksize = PAGE_CACHE_SIZE;
-	sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
-	sb->s_magic = 0x6e667364;
-	sb->s_op = &s_ops;
-
-	inode = new_inode(sb);
-	if (!inode)
-		return -ENOMEM;
-	inode->i_mode = S_IFDIR | 0755;
-	inode->i_uid = inode->i_gid = 0;
-	inode->i_blksize = PAGE_CACHE_SIZE;
-	inode->i_blocks = 0;
-	inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
-	inode->i_op = &simple_dir_inode_operations;
-	inode->i_fop = &simple_dir_operations;
-	root = d_alloc_root(inode);
-	if (!root) {
-		iput(inode);
-		return -ENOMEM;
-	}
-	for (i = NFSD_Svc; i < NFSD_END; i++) {
-		struct qstr name;
-		name.name = files[i].name;
-		name.len = strlen(name.name);
-		name.hash = full_name_hash(name.name, name.len);
-		dentry = d_alloc(root, &name);
-		if (!dentry)
-			goto out;
-		inode = new_inode(sb);
-		if (!inode)
-			goto out;
-		inode->i_mode = S_IFREG | files[i].mode;
-		inode->i_uid = inode->i_gid = 0;
-		inode->i_blksize = PAGE_CACHE_SIZE;
-		inode->i_blocks = 0;
-		inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
-		inode->i_fop = files[i].ops;
-		inode->i_ino = i;
-		d_add(dentry, inode);
-	}
-	sb->s_root = root;
-	return 0;
-
-out:
-	d_genocide(root);
-	dput(root);
-	return -ENOMEM;
+	static struct tree_descr nfsd_files[] = {
+		[NFSD_Svc] = {".svc", &transaction_ops, S_IWUSR},
+		[NFSD_Add] = {".add", &transaction_ops, S_IWUSR},
+		[NFSD_Del] = {".del", &transaction_ops, S_IWUSR},
+		[NFSD_Export] = {".export", &transaction_ops, S_IWUSR},
+		[NFSD_Unexport] = {".unexport", &transaction_ops, S_IWUSR},
+		[NFSD_Getfd] = {".getfd", &transaction_ops, S_IWUSR|S_IRUSR},
+		[NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR},
+		[NFSD_List] = {"exports", &exports_operations, S_IRUGO},
+		[NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR},
+		[NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR},
+		/* last one */ {""}
+	};
+	return simple_fill_super(sb, 0x6e667364, nfsd_files);
 }
 
 static struct super_block *nfsd_get_sb(struct file_system_type *fs_type,
diff -Nru a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog
--- a/fs/ntfs/ChangeLog	Wed Apr 30 22:28:06 2003
+++ b/fs/ntfs/ChangeLog	Wed Apr 30 22:28:06 2003
@@ -20,6 +20,31 @@
 	  sufficient for synchronisation here. We then just need to make sure
 	  ntfs_readpage/writepage/truncate interoperate properly with us.
 
+2.1.4 - Reduce compiler requirements.
+
+	- Remove all uses of unnamed structs and unions in the driver to make
+	  old and newer gcc versions happy. Makes it a bit uglier IMO but at
+	  least people will stop hassling me about it.
+
+2.1.3 - Important bug fixes in corner cases.
+
+	- super.c::parse_ntfs_boot_sector(): Correct the check for 64-bit
+	  clusters. (Philipp Thomas)
+	- attrib.c::load_attribute_list(): Fix bug when initialized_size is a
+	  multiple of the block_size but not the cluster size. (Szabolcs
+	  Szakacsits <szaka@sienet.hu>)
+
+2.1.2 - Important bug fixes aleviating the hangs in statfs.
+
+	- Fix buggy free cluster and free inode determination logic.
+
+2.1.1 - Minor updates.
+
+	- Add handling for initialized_size != data_size in compressed files.
+	- Reduce function local stack usage from 0x3d4 bytes to just noise in
+	  fs/ntfs/upcase.c. (Randy Dunlap <rddunlap@osdl.ord>)
+	- Remove compiler warnings for newer gcc.
+
 2.1.0 - First steps towards write support: implement file overwrite.
 
 	- Add configuration option for developmental write support with an
diff -Nru a/fs/ntfs/Makefile b/fs/ntfs/Makefile
--- a/fs/ntfs/Makefile	Wed Apr 30 22:28:10 2003
+++ b/fs/ntfs/Makefile	Wed Apr 30 22:28:10 2003
@@ -5,7 +5,7 @@
 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.1.0\"
+EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.4\"
 
 ifeq ($(CONFIG_NTFS_DEBUG),y)
 EXTRA_CFLAGS += -DDEBUG
diff -Nru a/fs/ntfs/aops.c b/fs/ntfs/aops.c
--- a/fs/ntfs/aops.c	Wed Apr 30 22:28:14 2003
+++ b/fs/ntfs/aops.c	Wed Apr 30 22:28:14 2003
@@ -2,8 +2,8 @@
  * aops.c - NTFS kernel address space operations and page cache handling.
  * 	    Part of the Linux-NTFS project.
  *
- * Copyright (c) 2001,2002 Anton Altaparmakov.
- * Copyright (c) 2002 Richard Russon.
+ * Copyright (c) 2001-2003 Anton Altaparmakov
+ * Copyright (c) 2002 Richard Russon
  *
  * This program/include file is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
@@ -111,7 +111,7 @@
 		unsigned int i, recs, nr_err;
 		u32 rec_size;
 
-		rec_size = ni->_IDM(index_block_size);
+		rec_size = ni->itype.index.block_size;
 		recs = PAGE_CACHE_SIZE / rec_size;
 		addr = kmap_atomic(page, KM_BIO_SRC_IRQ);
 		for (i = nr_err = 0; i < recs; i++) {
@@ -124,7 +124,7 @@
 					ni->mft_no ? "index" : "mft",
 					(long long)(((s64)page->index <<
 					PAGE_CACHE_SHIFT >>
-					ni->_IDM(index_block_size_bits)) + i));
+					ni->itype.index.block_size_bits) + i));
 		}
 		flush_dcache_page(page);
 		kunmap_atomic(addr, KM_BIO_SRC_IRQ);
@@ -383,7 +383,7 @@
 	if (!NInoAttr(ni))
 		base_ni = ni;
 	else
-		base_ni = ni->_INE(base_ntfs_ino);
+		base_ni = ni->ext.base_ntfs_ino;
 
 	/* Map, pin, and lock the mft record. */
 	mrec = map_mft_record(base_ni);
@@ -406,7 +406,7 @@
 	attr_pos = page->index << PAGE_CACHE_SHIFT;
 
 	/* The total length of the attribute value. */
-	attr_len = le32_to_cpu(ctx->attr->_ARA(value_length));
+	attr_len = le32_to_cpu(ctx->attr->data.resident.value_length);
 
 	addr = kmap(page);
 	/* Copy over in bounds data, zeroing the remainder of the page. */
@@ -418,8 +418,8 @@
 			memset(addr + bytes, 0, PAGE_CACHE_SIZE - bytes);
 		/* Copy the data to the page. */
 		memcpy(addr, attr_pos + (char*)ctx->attr +
-				le16_to_cpu(ctx->attr->_ARA(value_offset)),
-				bytes);
+				le16_to_cpu(
+				ctx->attr->data.resident.value_offset), bytes);
 	} else
 		memset(addr, 0, PAGE_CACHE_SIZE);
 	flush_dcache_page(page);
@@ -892,7 +892,7 @@
 	if (!NInoAttr(ni))
 		base_ni = ni;
 	else
-		base_ni = ni->_INE(base_ntfs_ino);
+		base_ni = ni->ext.base_ntfs_ino;
 
 	/* Map, pin, and lock the mft record. */
 	m = map_mft_record(base_ni);
@@ -917,7 +917,7 @@
 	attr_pos = page->index << PAGE_CACHE_SHIFT;
 
 	/* The total length of the attribute value. */
-	attr_len = le32_to_cpu(ctx->attr->_ARA(value_length));
+	attr_len = le32_to_cpu(ctx->attr->data.resident.value_length);
 
 	if (unlikely(vi->i_size != attr_len)) {
 		ntfs_error(vi->i_sb, "BUG()! i_size (0x%Lx) doesn't match "
@@ -956,8 +956,9 @@
 
 	kaddr = kmap_atomic(page, KM_USER0);
 	/* Copy the data from the page to the mft record. */
-	memcpy((u8*)ctx->attr + le16_to_cpu(ctx->attr->_ARA(value_offset)) +
-			attr_pos, kaddr, bytes);
+	memcpy((u8*)ctx->attr + le16_to_cpu(
+			ctx->attr->data.resident.value_offset) + attr_pos,
+			kaddr, bytes);
 	flush_dcache_mft_record_page(ctx->ntfs_ino);
 #if 0
 	/* Zero out of bounds area. */
@@ -1656,7 +1657,7 @@
 	if (!NInoAttr(ni))
 		base_ni = ni;
 	else
-		base_ni = ni->_INE(base_ntfs_ino);
+		base_ni = ni->ext.base_ntfs_ino;
 
 	/* Map, pin, and lock the mft record. */
 	m = map_mft_record(base_ni);
@@ -1681,7 +1682,7 @@
 	attr_pos = page->index << PAGE_CACHE_SHIFT;
 
 	/* The total length of the attribute value. */
-	attr_len = le32_to_cpu(ctx->attr->_ARA(value_length));
+	attr_len = le32_to_cpu(ctx->attr->data.resident.value_length);
 
 	if (unlikely(vi->i_size != attr_len)) {
 		ntfs_error(vi->i_sb, "BUG()! i_size (0x%Lx) doesn't match "
@@ -1705,8 +1706,8 @@
 	 * Calculate the address of the attribute value corresponding to the
 	 * beginning of the current data @page.
 	 */
-	kattr = (u8*)ctx->attr + le16_to_cpu(ctx->attr->_ARA(value_offset)) +
-			attr_pos;
+	kattr = (u8*)ctx->attr + le16_to_cpu(
+			ctx->attr->data.resident.value_offset) + attr_pos;
 
 	kaddr = kmap_atomic(page, KM_USER0);
 
diff -Nru a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
--- a/fs/ntfs/attrib.c	Wed Apr 30 22:28:20 2003
+++ b/fs/ntfs/attrib.c	Wed Apr 30 22:28:20 2003
@@ -1,8 +1,8 @@
 /**
  * attrib.c - NTFS attribute operations. Part of the Linux-NTFS project.
  *
- * Copyright (c) 2001,2002 Anton Altaparmakov.
- * Copyright (C) 2002 Richard Russon.
+ * Copyright (c) 2001-2003 Anton Altaparmakov
+ * Copyright (c) 2002 Richard Russon
  *
  * This program/include file is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
@@ -731,17 +731,18 @@
 
 #ifdef DEBUG
 	/* Make sure attr exists and is non-resident. */
-	if (!attr || !attr->non_resident ||
-			sle64_to_cpu(attr->_ANR(lowest_vcn)) < (VCN)0) {
+	if (!attr || !attr->non_resident || sle64_to_cpu(
+			attr->data.non_resident.lowest_vcn) < (VCN)0) {
 		ntfs_error(vol->sb, "Invalid arguments.");
 		return ERR_PTR(-EINVAL);
 	}
 #endif
 	/* Start at vcn = lowest_vcn and lcn 0. */
-	vcn = sle64_to_cpu(attr->_ANR(lowest_vcn));
+	vcn = sle64_to_cpu(attr->data.non_resident.lowest_vcn);
 	lcn = 0;
 	/* Get start of the mapping pairs array. */
-	buf = (u8*)attr + le16_to_cpu(attr->_ANR(mapping_pairs_offset));
+	buf = (u8*)attr + le16_to_cpu(
+			attr->data.non_resident.mapping_pairs_offset);
 	attr_end = (u8*)attr + le32_to_cpu(attr->length);
 	if (unlikely(buf < (u8*)attr || buf > attr_end)) {
 		ntfs_error(vol->sb, "Corrupt attribute.");
@@ -867,7 +868,7 @@
 	 * If there is a highest_vcn specified, it must be equal to the final
 	 * vcn in the run list - 1, or something has gone badly wrong.
 	 */
-	deltaxcn = sle64_to_cpu(attr->_ANR(highest_vcn));
+	deltaxcn = sle64_to_cpu(attr->data.non_resident.highest_vcn);
 	if (unlikely(deltaxcn && vcn - 1 != deltaxcn)) {
 mpa_err:
 		ntfs_error(vol->sb, "Corrupt mapping pairs array in "
@@ -875,10 +876,11 @@
 		goto err_out;
 	}
 	/* Setup not mapped run list element if this is the base extent. */
-	if (!attr->_ANR(lowest_vcn)) {
+	if (!attr->data.non_resident.lowest_vcn) {
 		VCN max_cluster;
 
-		max_cluster = (sle64_to_cpu(attr->_ANR(allocated_size)) +
+		max_cluster = (sle64_to_cpu(
+				attr->data.non_resident.allocated_size) +
 				vol->cluster_size - 1) >>
 				vol->cluster_size_bits;
 		/*
@@ -951,7 +953,7 @@
 	if (!NInoAttr(ni))
 		base_ni = ni;
 	else
-		base_ni = ni->_INE(base_ntfs_ino);
+		base_ni = ni->ext.base_ntfs_ino;
 
 	mrec = map_mft_record(base_ni);
 	if (IS_ERR(mrec))
@@ -1180,19 +1182,23 @@
 			return TRUE;
 		/* @val is present; compare values. */
 		else {
+			u32 vl;
 			register int rc;
-			
+
+			vl = le32_to_cpu(a->data.resident.value_length);
+			if (vl > val_len)
+				vl = val_len;
+
 			rc = memcmp(val, (u8*)a + le16_to_cpu(
-					a->_ARA(value_offset)), 
-				    	min_t(const u32, val_len,
-					le32_to_cpu(a->_ARA(value_length))));
+					a->data.resident.value_offset), vl);
 			/*
 			 * If @val collates before the current attribute's
 			 * value, there is no matching attribute.
 			 */
 			if (!rc) {
 				register u32 avl;
-				avl = le32_to_cpu(a->_ARA(value_length));
+				avl = le32_to_cpu(
+						a->data.resident.value_length);
 				if (val_len == avl)
 					return TRUE;
 				if (val_len < avl)
@@ -1235,11 +1241,9 @@
 	unsigned char block_size_bits = sb->s_blocksize_bits;
 
 	ntfs_debug("Entering.");
-#ifdef DEBUG
 	if (!vol || !run_list || !al || size <= 0 || initialized_size < 0 ||
 			initialized_size > size)
 		return -EINVAL;
-#endif
 	if (!initialized_size) {
 		memset(al, 0, size);
 		return 0;
@@ -1270,8 +1274,8 @@
 						"read attribute list.");
 				goto err_out;
 			}
-			if (al + block_size > al_end)
-				goto do_partial;
+			if (al + block_size >= al_end)
+				goto do_final;
 			memcpy(al, bh->b_data, block_size);
 			brelse(bh);
 			al += block_size;
@@ -1285,7 +1289,7 @@
 done:
 	up_read(&run_list->lock);
 	return err;
-do_partial:
+do_final:
 	if (al < al_end) {
 		/* Partial block. */
 		memcpy(al, bh->b_data, al_end - al);
@@ -1546,9 +1550,11 @@
 		 * If no @val specified or @val specified and it matches, we
 		 * have found it!
 		 */
-		if (!val || (!a->non_resident && le32_to_cpu(a->_ARA(value_length))
-				== val_len && !memcmp((u8*)a +
-				le16_to_cpu(a->_ARA(value_offset)), val, val_len))) {
+		if (!val || (!a->non_resident && le32_to_cpu(
+				a->data.resident.value_length) == val_len &&
+				!memcmp((u8*)a +
+				le16_to_cpu(a->data.resident.value_offset),
+				val, val_len))) {
 			ntfs_debug("Done, found.");
 			return TRUE;
 		}
diff -Nru a/fs/ntfs/attrib.h b/fs/ntfs/attrib.h
--- a/fs/ntfs/attrib.h	Wed Apr 30 22:28:08 2003
+++ b/fs/ntfs/attrib.h	Wed Apr 30 22:28:08 2003
@@ -2,8 +2,8 @@
  * attrib.h - Defines for attribute handling in NTFS Linux kernel driver.
  *	      Part of the Linux-NTFS project.
  *
- * Copyright (c) 2001,2002 Anton Altaparmakov.
- * Copyright (C) 2002 Richard Russon.
+ * Copyright (c) 2001-2003 Anton Altaparmakov
+ * Copyright (c) 2002 Richard Russon
  *
  * This program/include file is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
@@ -93,8 +93,8 @@
 static inline s64 attribute_value_length(const ATTR_RECORD *a)
 {
 	if (!a->non_resident)
-		return (s64)le32_to_cpu(a->_ARA(value_length));
-	return sle64_to_cpu(a->_ANR(data_size));
+		return (s64)le32_to_cpu(a->data.resident.value_length);
+	return sle64_to_cpu(a->data.non_resident.data_size);
 }
 
 extern void reinit_attr_search_ctx(attr_search_context *ctx);
diff -Nru a/fs/ntfs/compress.c b/fs/ntfs/compress.c
--- a/fs/ntfs/compress.c	Wed Apr 30 22:28:09 2003
+++ b/fs/ntfs/compress.c	Wed Apr 30 22:28:09 2003
@@ -2,8 +2,8 @@
  * compress.c - NTFS kernel compressed attributes handling.
  *		Part of the Linux-NTFS project.
  *
- * Copyright (c) 2001,2002 Anton Altaparmakov.
- * Copyright (C) 2002 Richard Russon.
+ * Copyright (c) 2001-2003 Anton Altaparmakov
+ * Copyright (c) 2002 Richard Russon
  *
  * This program/include file is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
@@ -44,7 +44,7 @@
 	 * The maximum compression block size is by definition 16 * the cluster
 	 * size, with the maximum supported cluster size being 4kiB. Thus the
 	 * maximum compression buffer size is 64kiB, so we use this when
-	 * initializing the per-CPU buffers.
+	 * initializing the compression buffer.
 	 */
 	NTFS_MAX_CB_SIZE	= 64 * 1024,
 } ntfs_compression_constants;
@@ -89,6 +89,40 @@
 }
 
 /**
+ * zero_partial_compressed_page - zero out of bounds compressed page region
+ */
+static void zero_partial_compressed_page(ntfs_inode *ni, struct page *page)
+{
+	u8 *kp = page_address(page);
+	unsigned int kp_ofs;
+
+	ntfs_debug("Zeroing page region outside initialized size.");
+	if (((s64)page->index << PAGE_CACHE_SHIFT) >= ni->initialized_size) {
+		/*
+		 * FIXME: Using clear_page() will become wrong when we get
+		 * PAGE_CACHE_SIZE != PAGE_SIZE but for now there is no problem.
+		 */
+		clear_page(kp);
+		return;
+	}
+	kp_ofs = ni->initialized_size & ~PAGE_CACHE_MASK;
+	memset(kp + kp_ofs, 0, PAGE_CACHE_SIZE - kp_ofs);
+	return;
+}
+
+/**
+ * handle_bounds_compressed_page - test for&handle out of bounds compressed page
+ */
+static inline void handle_bounds_compressed_page(ntfs_inode *ni,
+		struct page *page)
+{
+	if ((page->index >= (ni->initialized_size >> PAGE_CACHE_SHIFT)) &&
+			(ni->initialized_size < VFS_I(ni)->i_size))
+		zero_partial_compressed_page(ni, page);
+	return;
+}
+
+/**
  * ntfs_decompress - decompress a compression block into an array of pages
  * @dest_pages:		destination array of pages
  * @dest_index:		current index into @dest_pages (IN/OUT)
@@ -164,7 +198,7 @@
 			cb - cb_start);
 
 	/* Have we reached the end of the compression block? */
-	if (cb == cb_end || !le16_to_cpup(cb)) {
+	if (cb == cb_end || !le16_to_cpup((u16*)cb)) {
 		int i;
 
 		ntfs_debug("Completed. Returning success (0).");
@@ -173,19 +207,29 @@
 		/* We can sleep from now on, so we drop lock. */
 		spin_unlock(&ntfs_cb_lock);
 		/* Second stage: finalize completed pages. */
-		for (i = 0; i < nr_completed_pages; i++) {
-			int di = completed_pages[i];
+		if (nr_completed_pages > 0) {
+			struct page *page = dest_pages[completed_pages[0]];
+			ntfs_inode *ni = NTFS_I(page->mapping->host);
 
-			dp = dest_pages[di];
-			flush_dcache_page(dp);
-			kunmap(dp);
-			SetPageUptodate(dp);
-			unlock_page(dp);
-			if (di == xpage)
-				*xpage_done = 1;
-			else
-				page_cache_release(dp);
-			dest_pages[di] = NULL;
+			for (i = 0; i < nr_completed_pages; i++) {
+				int di = completed_pages[i];
+
+				dp = dest_pages[di];
+				/*
+				 * If we are outside the initialized size, zero
+				 * the out of bounds page range.
+				 */
+				handle_bounds_compressed_page(ni, dp);
+				flush_dcache_page(dp);
+				kunmap(dp);
+				SetPageUptodate(dp);
+				unlock_page(dp);
+				if (di == xpage)
+					*xpage_done = 1;
+				else
+					page_cache_release(dp);
+				dest_pages[di] = NULL;
+			}
 		}
 		return err;
 	}
@@ -204,7 +248,8 @@
 
 	/* Setup the current sub-block source pointers and validate range. */
 	cb_sb_start = cb;
-	cb_sb_end = cb_sb_start + (le16_to_cpup(cb) & NTFS_SB_SIZE_MASK) + 3;
+	cb_sb_end = cb_sb_start + (le16_to_cpup((u16*)cb) & NTFS_SB_SIZE_MASK)
+			+ 3;
 	if (cb_sb_end > cb_end)
 		goto return_overflow;
 
@@ -225,7 +270,7 @@
 	dp_addr = (u8*)page_address(dp) + do_sb_start;
 
 	/* Now, we are ready to process the current sub-block (sb). */
-	if (!(le16_to_cpup(cb) & NTFS_SB_IS_COMPRESSED)) {
+	if (!(le16_to_cpup((u16*)cb) & NTFS_SB_IS_COMPRESSED)) {
 		ntfs_debug("Found uncompressed sub-block.");
 		/* This sb is not compressed, just copy it into destination. */
 
@@ -330,7 +375,7 @@
 			lg++;
 
 		/* Get the phrase token into i. */
-		pt = le16_to_cpup(cb);
+		pt = le16_to_cpup((u16*)cb);
 
 		/*
 		 * Calculate starting position of the byte sequence in
@@ -432,7 +477,7 @@
 	u8 *cb, *cb_pos, *cb_end;
 	struct buffer_head **bhs;
 	unsigned long offset, index = page->index;
-	u32 cb_size = ni->_ICF(compression_block_size);
+	u32 cb_size = ni->itype.compressed.block_size;
 	u64 cb_size_mask = cb_size - 1UL;
 	VCN vcn;
 	LCN lcn;
@@ -447,7 +492,7 @@
 			& ~cb_size_mask) >> vol->cluster_size_bits;
 	/* Number of compression blocks (cbs) in the wanted vcn range. */
 	unsigned int nr_cbs = (end_vcn - start_vcn) << vol->cluster_size_bits
-			>> ni->_ICF(compression_block_size_bits);
+			>> ni->itype.compressed.block_size_bits;
 	/*
 	 * Number of pages required to store the uncompressed data from all
 	 * compression blocks (cbs) overlapping @page. Due to alignment
@@ -528,7 +573,7 @@
 	 */
 	cur_page = 0;
 	cur_ofs = 0;
-	cb_clusters = ni->_ICF(compression_block_clusters);
+	cb_clusters = ni->itype.compressed.block_clusters;
 do_next_cb:
 	nr_cbs--;
 	nr_bhs = 0;
@@ -763,6 +808,11 @@
 		for (; cur2_page < cb_max_page; cur2_page++) {
 			page = pages[cur2_page];
 			if (page) {
+				/*
+				 * If we are outside the initialized size, zero
+				 * the out of bounds page range.
+				 */
+				handle_bounds_compressed_page(ni, page);
 				flush_dcache_page(page);
 				kunmap(page);
 				SetPageUptodate(page);
diff -Nru a/fs/ntfs/dir.c b/fs/ntfs/dir.c
--- a/fs/ntfs/dir.c	Wed Apr 30 22:28:07 2003
+++ b/fs/ntfs/dir.c	Wed Apr 30 22:28:07 2003
@@ -1,8 +1,8 @@
 /**
  * dir.c - NTFS kernel directory operations. Part of the Linux-NTFS project.
  *
- * Copyright (c) 2001,2002 Anton Altaparmakov.
- * Copyright (c) 2002 Richard Russon.
+ * Copyright (c) 2001-2003 Anton Altaparmakov
+ * Copyright (c) 2002 Richard Russon
  *
  * This program/include file is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
@@ -105,7 +105,7 @@
 	}
 	/* Get to the index root value (it's been verified in read_inode). */
 	ir = (INDEX_ROOT*)((u8*)ctx->attr +
-			le16_to_cpu(ctx->attr->_ARA(value_offset)));
+			le16_to_cpu(ctx->attr->data.resident.value_offset));
 	index_end = (u8*)&ir->index + le32_to_cpu(ir->index.index_length);
 	/* The first index entry. */
 	ie = (INDEX_ENTRY*)((u8*)&ir->index +
@@ -114,18 +114,18 @@
 	 * Loop until we exceed valid memory (corruption case) or until we
 	 * reach the last entry.
 	 */
-	for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->_IEH(length)))) {
+	for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->length))) {
 		/* Bounds checks. */
 		if ((u8*)ie < (u8*)ctx->mrec || (u8*)ie +
 				sizeof(INDEX_ENTRY_HEADER) > index_end ||
-				(u8*)ie + le16_to_cpu(ie->_IEH(key_length)) >
+				(u8*)ie + le16_to_cpu(ie->key_length) >
 				index_end)
 			goto dir_err_out;
 		/*
 		 * The last entry cannot contain a name. It can however contain
 		 * a pointer to a child node in the B+tree so we just break out.
 		 */
-		if (ie->_IEH(flags) & INDEX_ENTRY_END)
+		if (ie->flags & INDEX_ENTRY_END)
 			break;
 		/*
 		 * We perform a case sensitive comparison and if that matches
@@ -159,7 +159,7 @@
 					}
 				}
 				name->mref = le64_to_cpu(
-						ie->_IIF(indexed_file));
+						ie->data.dir.indexed_file);
 				name->type = FILE_NAME_DOS;
 				name->len = 0;
 				*res = name;
@@ -168,7 +168,7 @@
 					kfree(name);
 				*res = NULL;
 			}
-			mref = le64_to_cpu(ie->_IIF(indexed_file));
+			mref = le64_to_cpu(ie->data.dir.indexed_file);
 			put_attr_search_ctx(ctx);
 			unmap_mft_record(dir_ni);
 			return mref;
@@ -211,7 +211,7 @@
 				err = -ENOMEM;
 				goto err_out;
 			}
-			name->mref = le64_to_cpu(ie->_IIF(indexed_file));
+			name->mref = le64_to_cpu(ie->data.dir.indexed_file);
 			name->type = type;
 			if (type != FILE_NAME_DOS) {
 				name->len = len;
@@ -265,7 +265,7 @@
 	 * we have got a matching name cached in name in which case return the
 	 * mft reference associated with it.
 	 */
-	if (!(ie->_IEH(flags) & INDEX_ENTRY_NODE)) {
+	if (!(ie->flags & INDEX_ENTRY_NODE)) {
 		if (name) {
 			put_attr_search_ctx(ctx);
 			unmap_mft_record(dir_ni);
@@ -284,7 +284,7 @@
 		goto err_out;
 	}
 	/* Get the starting vcn of the index_block holding the child node. */
-	vcn = sle64_to_cpup((u8*)ie + le16_to_cpu(ie->_IEH(length)) - 8);
+	vcn = sle64_to_cpup((u8*)ie + le16_to_cpu(ie->length) - 8);
 	ia_mapping = VFS_I(dir_ni)->i_mapping;
 	/*
 	 * We are done with the index root and the mft record. Release them,
@@ -301,7 +301,7 @@
 	 * disk if necessary.
 	 */
 	page = ntfs_map_page(ia_mapping, vcn <<
-			dir_ni->_IDM(index_vcn_size_bits) >> PAGE_CACHE_SHIFT);
+			dir_ni->itype.index.vcn_size_bits >> PAGE_CACHE_SHIFT);
 	if (IS_ERR(page)) {
 		ntfs_error(sb, "Failed to map directory index page, error %ld.",
 				-PTR_ERR(page));
@@ -312,7 +312,7 @@
 fast_descend_into_child_node:
 	/* Get to the index allocation block. */
 	ia = (INDEX_ALLOCATION*)(kaddr + ((vcn <<
-			dir_ni->_IDM(index_vcn_size_bits)) & ~PAGE_CACHE_MASK));
+			dir_ni->itype.index.vcn_size_bits) & ~PAGE_CACHE_MASK));
 	/* Bounds checks. */
 	if ((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE) {
 		ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
@@ -331,18 +331,18 @@
 		goto unm_err_out;
 	}
 	if (le32_to_cpu(ia->index.allocated_size) + 0x18 !=
-			dir_ni->_IDM(index_block_size)) {
+			dir_ni->itype.index.block_size) {
 		ntfs_error(sb, "Index buffer (VCN 0x%Lx) of directory inode "
 				"0x%lx has a size (%u) differing from the "
 				"directory specified size (%u). Directory "
 				"inode is corrupt or driver bug.",
 				(long long)vcn, dir_ni->mft_no,
 				le32_to_cpu(ia->index.allocated_size) + 0x18,
-				dir_ni->_IDM(index_block_size));
+				dir_ni->itype.index.block_size);
 		err = -EIO;
 		goto unm_err_out;
 	}
-	index_end = (u8*)ia + dir_ni->_IDM(index_block_size);
+	index_end = (u8*)ia + dir_ni->itype.index.block_size;
 	if (index_end > kaddr + PAGE_CACHE_SIZE) {
 		ntfs_error(sb, "Index buffer (VCN 0x%Lx) of directory inode "
 				"0x%lx crosses page boundary. Impossible! "
@@ -352,7 +352,7 @@
 		goto unm_err_out;
 	}
 	index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length);
-	if (index_end > (u8*)ia + dir_ni->_IDM(index_block_size)) {
+	if (index_end > (u8*)ia + dir_ni->itype.index.block_size) {
 		ntfs_error(sb, "Size of index buffer (VCN 0x%Lx) of directory "
 				"inode 0x%lx exceeds maximum size.",
 				(long long)vcn, dir_ni->mft_no);
@@ -367,11 +367,11 @@
 	 * loop until we exceed valid memory (corruption case) or until we
 	 * reach the last entry.
 	 */
-	for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->_IEH(length)))) {
+	for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->length))) {
 		/* Bounds check. */
 		if ((u8*)ie < (u8*)ia || (u8*)ie +
 				sizeof(INDEX_ENTRY_HEADER) > index_end ||
-				(u8*)ie + le16_to_cpu(ie->_IEH(key_length)) >
+				(u8*)ie + le16_to_cpu(ie->key_length) >
 				index_end) {
 			ntfs_error(sb, "Index entry out of bounds in "
 					"directory inode 0x%lx.",
@@ -383,7 +383,7 @@
 		 * The last entry cannot contain a name. It can however contain
 		 * a pointer to a child node in the B+tree so we just break out.
 		 */
-		if (ie->_IEH(flags) & INDEX_ENTRY_END)
+		if (ie->flags & INDEX_ENTRY_END)
 			break;
 		/*
 		 * We perform a case sensitive comparison and if that matches
@@ -417,7 +417,7 @@
 					}
 				}
 				name->mref = le64_to_cpu(
-						ie->_IIF(indexed_file));
+						ie->data.dir.indexed_file);
 				name->type = FILE_NAME_DOS;
 				name->len = 0;
 				*res = name;
@@ -426,7 +426,7 @@
 					kfree(name);
 				*res = NULL;
 			}
-			mref = le64_to_cpu(ie->_IIF(indexed_file));
+			mref = le64_to_cpu(ie->data.dir.indexed_file);
 			ntfs_unmap_page(page);
 			return mref;
 		}
@@ -469,7 +469,7 @@
 				err = -ENOMEM;
 				goto unm_err_out;
 			}
-			name->mref = le64_to_cpu(ie->_IIF(indexed_file));
+			name->mref = le64_to_cpu(ie->data.dir.indexed_file);
 			name->type = type;
 			if (type != FILE_NAME_DOS) {
 				name->len = len;
@@ -521,7 +521,7 @@
 	 * We have finished with this index buffer without success. Check for
 	 * the presence of a child node.
 	 */
-	if (ie->_IEH(flags) & INDEX_ENTRY_NODE) {
+	if (ie->flags & INDEX_ENTRY_NODE) {
 		if ((ia->index.flags & NODE_MASK) == LEAF_NODE) {
 			ntfs_error(sb, "Index entry with child node found in "
 					"a leaf node in directory inode 0x%lx.",
@@ -531,8 +531,7 @@
 		}
 		/* Child node present, descend into it. */
 		old_vcn = vcn;
-		vcn = sle64_to_cpup((u8*)ie +
-				le16_to_cpu(ie->_IEH(length)) - 8);
+		vcn = sle64_to_cpup((u8*)ie + le16_to_cpu(ie->length) - 8);
 		if (vcn >= 0) {
 			/* If vcn is in the same page cache page as old_vcn we
 			 * recycle the mapped page. */
@@ -646,7 +645,7 @@
 	}
 	/* Get to the index root value (it's been verified in read_inode). */
 	ir = (INDEX_ROOT*)((u8*)ctx->attr +
-			le16_to_cpu(ctx->attr->_ARA(value_offset)));
+			le16_to_cpu(ctx->attr->data.resident.value_offset));
 	index_end = (u8*)&ir->index + le32_to_cpu(ir->index.index_length);
 	/* The first index entry. */
 	ie = (INDEX_ENTRY*)((u8*)&ir->index +
@@ -655,18 +654,18 @@
 	 * Loop until we exceed valid memory (corruption case) or until we
 	 * reach the last entry.
 	 */
-	for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->_IEH(length)))) {
+	for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->length))) {
 		/* Bounds checks. */
 		if ((u8*)ie < (u8*)ctx->mrec || (u8*)ie +
 				sizeof(INDEX_ENTRY_HEADER) > index_end ||
-				(u8*)ie + le16_to_cpu(ie->_IEH(key_length)) >
+				(u8*)ie + le16_to_cpu(ie->key_length) >
 				index_end)
 			goto dir_err_out;
 		/*
 		 * The last entry cannot contain a name. It can however contain
 		 * a pointer to a child node in the B+tree so we just break out.
 		 */
-		if (ie->_IEH(flags) & INDEX_ENTRY_END)
+		if (ie->flags & INDEX_ENTRY_END)
 			break;
 		/*
 		 * If the current entry has a name type of POSIX, the name is
@@ -691,7 +690,7 @@
 				ie->key.file_name.file_name_length, ic,
 				vol->upcase, vol->upcase_len)) {
 found_it:
-			mref = le64_to_cpu(ie->_IIF(indexed_file));
+			mref = le64_to_cpu(ie->data.dir.indexed_file);
 			put_attr_search_ctx(ctx);
 			unmap_mft_record(dir_ni);
 			return mref;
@@ -738,7 +737,7 @@
 	 * We have finished with this index without success. Check for the
 	 * presence of a child node.
 	 */
-	if (!(ie->_IEH(flags) & INDEX_ENTRY_NODE)) {
+	if (!(ie->flags & INDEX_ENTRY_NODE)) {
 		/* No child node, return -ENOENT. */
 		err = -ENOENT;
 		goto err_out;
@@ -752,7 +751,7 @@
 		goto err_out;
 	}
 	/* Get the starting vcn of the index_block holding the child node. */
-	vcn = sle64_to_cpup((u8*)ie + le16_to_cpu(ie->_IEH(length)) - 8);
+	vcn = sle64_to_cpup((u8*)ie + le16_to_cpu(ie->length) - 8);
 	ia_mapping = VFS_I(dir_ni)->i_mapping;
 	/*
 	 * We are done with the index root and the mft record. Release them,
@@ -769,7 +768,7 @@
 	 * disk if necessary.
 	 */
 	page = ntfs_map_page(ia_mapping, vcn <<
-			dir_ni->_IDM(index_vcn_size_bits) >> PAGE_CACHE_SHIFT);
+			dir_ni->itype.index.vcn_size_bits >> PAGE_CACHE_SHIFT);
 	if (IS_ERR(page)) {
 		ntfs_error(sb, "Failed to map directory index page, error %ld.",
 				-PTR_ERR(page));
@@ -780,7 +779,7 @@
 fast_descend_into_child_node:
 	/* Get to the index allocation block. */
 	ia = (INDEX_ALLOCATION*)(kaddr + ((vcn <<
-			dir_ni->_IDM(index_vcn_size_bits)) & ~PAGE_CACHE_MASK));
+			dir_ni->itype.index.vcn_size_bits) & ~PAGE_CACHE_MASK));
 	/* Bounds checks. */
 	if ((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE) {
 		ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
@@ -799,18 +798,18 @@
 		goto unm_err_out;
 	}
 	if (le32_to_cpu(ia->index.allocated_size) + 0x18 !=
-			dir_ni->_IDM(index_block_size)) {
+			dir_ni->itype.index.block_size) {
 		ntfs_error(sb, "Index buffer (VCN 0x%Lx) of directory inode "
 				"0x%lx has a size (%u) differing from the "
 				"directory specified size (%u). Directory "
 				"inode is corrupt or driver bug.",
 				(long long)vcn, dir_ni->mft_no,
 				le32_to_cpu(ia->index.allocated_size) + 0x18,
-				dir_ni->_IDM(index_block_size));
+				dir_ni->itype.index.block_size);
 		err = -EIO;
 		goto unm_err_out;
 	}
-	index_end = (u8*)ia + dir_ni->_IDM(index_block_size);
+	index_end = (u8*)ia + dir_ni->itype.index.block_size;
 	if (index_end > kaddr + PAGE_CACHE_SIZE) {
 		ntfs_error(sb, "Index buffer (VCN 0x%Lx) of directory inode "
 				"0x%lx crosses page boundary. Impossible! "
@@ -820,7 +819,7 @@
 		goto unm_err_out;
 	}
 	index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length);
-	if (index_end > (u8*)ia + dir_ni->_IDM(index_block_size)) {
+	if (index_end > (u8*)ia + dir_ni->itype.index.block_size) {
 		ntfs_error(sb, "Size of index buffer (VCN 0x%Lx) of directory "
 				"inode 0x%lx exceeds maximum size.",
 				(long long)vcn, dir_ni->mft_no);
@@ -835,11 +834,11 @@
 	 * loop until we exceed valid memory (corruption case) or until we
 	 * reach the last entry.
 	 */
-	for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->_IEH(length)))) {
+	for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->length))) {
 		/* Bounds check. */
 		if ((u8*)ie < (u8*)ia || (u8*)ie +
 				sizeof(INDEX_ENTRY_HEADER) > index_end ||
-				(u8*)ie + le16_to_cpu(ie->_IEH(key_length)) >
+				(u8*)ie + le16_to_cpu(ie->key_length) >
 				index_end) {
 			ntfs_error(sb, "Index entry out of bounds in "
 					"directory inode 0x%lx.",
@@ -851,7 +850,7 @@
 		 * The last entry cannot contain a name. It can however contain
 		 * a pointer to a child node in the B+tree so we just break out.
 		 */
-		if (ie->_IEH(flags) & INDEX_ENTRY_END)
+		if (ie->flags & INDEX_ENTRY_END)
 			break;
 		/*
 		 * If the current entry has a name type of POSIX, the name is
@@ -876,7 +875,7 @@
 				ie->key.file_name.file_name_length, ic,
 				vol->upcase, vol->upcase_len)) {
 found_it2:
-			mref = le64_to_cpu(ie->_IIF(indexed_file));
+			mref = le64_to_cpu(ie->data.dir.indexed_file);
 			ntfs_unmap_page(page);
 			return mref;
 		}
@@ -922,7 +921,7 @@
 	 * We have finished with this index buffer without success. Check for
 	 * the presence of a child node.
 	 */
-	if (ie->_IEH(flags) & INDEX_ENTRY_NODE) {
+	if (ie->flags & INDEX_ENTRY_NODE) {
 		if ((ia->index.flags & NODE_MASK) == LEAF_NODE) {
 			ntfs_error(sb, "Index entry with child node found in "
 					"a leaf node in directory inode 0x%lx.",
@@ -932,8 +931,7 @@
 		}
 		/* Child node present, descend into it. */
 		old_vcn = vcn;
-		vcn = sle64_to_cpup((u8*)ie +
-				le16_to_cpu(ie->_IEH(length)) - 8);
+		vcn = sle64_to_cpup((u8*)ie + le16_to_cpu(ie->length) - 8);
 		if (vcn >= 0) {
 			/* If vcn is in the same page cache page as old_vcn we
 			 * recycle the mapped page. */
@@ -1007,7 +1005,7 @@
 	if (index_type == INDEX_TYPE_ALLOCATION)
 		*fpos = (u8*)ie - (u8*)iu.ia +
 				(sle64_to_cpu(iu.ia->index_block_vcn) <<
-				ndir->_IDM(index_vcn_size_bits)) +
+				ndir->itype.index.vcn_size_bits) +
 				vol->mft_record_size;
 	else /* if (index_type == INDEX_TYPE_ROOT) */
 		*fpos = (u8*)ie - (u8*)iu.ir;
@@ -1016,11 +1014,11 @@
 		ntfs_debug("Skipping DOS name space entry.");
 		return 0;
 	}
-	if (MREF_LE(ie->_IIF(indexed_file)) == FILE_root) {
+	if (MREF_LE(ie->data.dir.indexed_file) == FILE_root) {
 		ntfs_debug("Skipping root directory self reference entry.");
 		return 0;
 	}
-	if (MREF_LE(ie->_IIF(indexed_file)) < FILE_first_user &&
+	if (MREF_LE(ie->data.dir.indexed_file) < FILE_first_user &&
 			!NVolShowSystemFiles(vol)) {
 		ntfs_debug("Skipping system file.");
 		return 0;
@@ -1039,10 +1037,10 @@
 		dt_type = DT_REG;
 	ntfs_debug("Calling filldir for %s with len %i, fpos 0x%Lx, inode "
 			"0x%lx, DT_%s.", name, name_len, *fpos,
-			MREF_LE(ie->_IIF(indexed_file)),
+			MREF_LE(ie->data.dir.indexed_file),
 			dt_type == DT_DIR ? "DIR" : "REG");
 	return filldir(dirent, name, name_len, *fpos,
-			MREF_LE(ie->_IIF(indexed_file)), dt_type);
+			MREF_LE(ie->data.dir.indexed_file), dt_type);
 }
 
 /*
@@ -1139,7 +1137,7 @@
 	}
 	/* Get to the index root value (it's been verified in read_inode). */
 	ir = (INDEX_ROOT*)((u8*)ctx->attr +
-			le16_to_cpu(ctx->attr->_ARA(value_offset)));
+			le16_to_cpu(ctx->attr->data.resident.value_offset));
 	index_end = (u8*)&ir->index + le32_to_cpu(ir->index.index_length);
 	/* The first index entry. */
 	ie = (INDEX_ENTRY*)((u8*)&ir->index +
@@ -1149,16 +1147,16 @@
 	 * reach the last entry or until filldir tells us it has had enough
 	 * or signals an error (both covered by the rc test).
 	 */
-	for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->_IEH(length)))) {
+	for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->length))) {
 		ntfs_debug("In index root, offset 0x%x.", (u8*)ie - (u8*)ir);
 		/* Bounds checks. */
 		if (unlikely((u8*)ie < (u8*)ctx->mrec || (u8*)ie +
 				sizeof(INDEX_ENTRY_HEADER) > index_end ||
-				(u8*)ie + le16_to_cpu(ie->_IEH(key_length)) >
+				(u8*)ie + le16_to_cpu(ie->key_length) >
 				index_end))
 			goto err_out;
 		/* The last entry cannot contain a name. */
-		if (ie->_IEH(flags) & INDEX_ENTRY_END)
+		if (ie->flags & INDEX_ENTRY_END)
 			break;
 		/* Skip index root entry if continuing previous readdir. */
 		if (ir_pos > (u8*)ie - (u8*)ir)
@@ -1192,7 +1190,7 @@
 	/* Get the offset into the index allocation attribute. */
 	ia_pos = (s64)fpos - vol->mft_record_size;
 	ia_mapping = vdir->i_mapping;
-	bmp_vi = ndir->_IDM(bmp_ino);
+	bmp_vi = ndir->itype.index.bmp_ino;
 	if (unlikely(!bmp_vi)) {
 		ntfs_debug("Inode %lu, regetting index bitmap.", vdir->i_ino);
 		bmp_vi = ntfs_attr_iget(vdir, AT_BITMAP, I30, 4);
@@ -1201,11 +1199,11 @@
 			err = PTR_ERR(bmp_vi);
 			goto err_out;
 		}
-		ndir->_IDM(bmp_ino) = bmp_vi;
+		ndir->itype.index.bmp_ino = bmp_vi;
 	}
 	bmp_mapping = bmp_vi->i_mapping;
 	/* Get the starting bitmap bit position and sanity check it. */
-	bmp_pos = ia_pos >> ndir->_IDM(index_block_size_bits);
+	bmp_pos = ia_pos >> ndir->itype.index.block_size_bits;
 	if (unlikely(bmp_pos >> 3 >= bmp_vi->i_size)) {
 		ntfs_error(sb, "Current index allocation position exceeds "
 				"index bitmap size.");
@@ -1245,7 +1243,7 @@
 		if (unlikely(((bmp_pos + cur_bmp_pos) >> 3) >= vdir->i_size))
 			goto unm_EOD;
 		ia_pos = (bmp_pos + cur_bmp_pos) <<
-				ndir->_IDM(index_block_size_bits);
+				ndir->itype.index.block_size_bits;
 	}
 	ntfs_debug("Handling index buffer 0x%Lx.",
 			(long long)bmp_pos + cur_bmp_pos);
@@ -1269,7 +1267,7 @@
 	}
 	/* Get the current index buffer. */
 	ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
-			~(s64)(ndir->_IDM(index_block_size) - 1)));
+			~(s64)(ndir->itype.index.block_size - 1)));
 	/* Bounds checks. */
 	if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
 		ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
@@ -1277,45 +1275,45 @@
 		goto err_out;
 	}
 	if (unlikely(sle64_to_cpu(ia->index_block_vcn) != (ia_pos &
-			~(s64)(ndir->_IDM(index_block_size) - 1)) >>
-			ndir->_IDM(index_vcn_size_bits))) {
+			~(s64)(ndir->itype.index.block_size - 1)) >>
+			ndir->itype.index.vcn_size_bits)) {
 		ntfs_error(sb, "Actual VCN (0x%Lx) of index buffer is "
 				"different from expected VCN (0x%Lx). "
 				"Directory inode 0x%lx is corrupt or driver "
 				"bug. ",
 				(long long)sle64_to_cpu(ia->index_block_vcn),
 				(long long)ia_pos >>
-				ndir->_IDM(index_vcn_size_bits), vdir->i_ino);
+				ndir->itype.index.vcn_size_bits, vdir->i_ino);
 		goto err_out;
 	}
 	if (unlikely(le32_to_cpu(ia->index.allocated_size) + 0x18 !=
-			ndir->_IDM(index_block_size))) {
+			ndir->itype.index.block_size)) {
 		ntfs_error(sb, "Index buffer (VCN 0x%Lx) of directory inode "
 				"0x%lx has a size (%u) differing from the "
 				"directory specified size (%u). Directory "
 				"inode is corrupt or driver bug.",
 				(long long)ia_pos >>
-				ndir->_IDM(index_vcn_size_bits), vdir->i_ino,
+				ndir->itype.index.vcn_size_bits, vdir->i_ino,
 				le32_to_cpu(ia->index.allocated_size) + 0x18,
-				ndir->_IDM(index_block_size));
+				ndir->itype.index.block_size);
 		goto err_out;
 	}
-	index_end = (u8*)ia + ndir->_IDM(index_block_size);
+	index_end = (u8*)ia + ndir->itype.index.block_size;
 	if (unlikely(index_end > kaddr + PAGE_CACHE_SIZE)) {
 		ntfs_error(sb, "Index buffer (VCN 0x%Lx) of directory inode "
 				"0x%lx crosses page boundary. Impossible! "
 				"Cannot access! This is probably a bug in the "
 				"driver.", (long long)ia_pos >>
-				ndir->_IDM(index_vcn_size_bits), vdir->i_ino);
+				ndir->itype.index.vcn_size_bits, vdir->i_ino);
 		goto err_out;
 	}
-	ia_start = ia_pos & ~(s64)(ndir->_IDM(index_block_size) - 1);
+	ia_start = ia_pos & ~(s64)(ndir->itype.index.block_size - 1);
 	index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length);
-	if (unlikely(index_end > (u8*)ia + ndir->_IDM(index_block_size))) {
+	if (unlikely(index_end > (u8*)ia + ndir->itype.index.block_size)) {
 		ntfs_error(sb, "Size of index buffer (VCN 0x%Lx) of directory "
 				"inode 0x%lx exceeds maximum size.",
 				(long long)ia_pos >>
-				ndir->_IDM(index_vcn_size_bits), vdir->i_ino);
+				ndir->itype.index.vcn_size_bits, vdir->i_ino);
 		goto err_out;
 	}
 	/* The first index entry in this index buffer. */
@@ -1326,17 +1324,17 @@
 	 * reach the last entry or until filldir tells us it has had enough
 	 * or signals an error (both covered by the rc test).
 	 */
-	for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->_IEH(length)))) {
+	for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->length))) {
 		ntfs_debug("In index allocation, offset 0x%Lx.",
 				(long long)ia_start + ((u8*)ie - (u8*)ia));
 		/* Bounds checks. */
 		if (unlikely((u8*)ie < (u8*)ia || (u8*)ie +
 				sizeof(INDEX_ENTRY_HEADER) > index_end ||
-				(u8*)ie + le16_to_cpu(ie->_IEH(key_length)) >
+				(u8*)ie + le16_to_cpu(ie->key_length) >
 				index_end))
 			goto err_out;
 		/* The last entry cannot contain a name. */
-		if (ie->_IEH(flags) & INDEX_ENTRY_END)
+		if (ie->flags & INDEX_ENTRY_END)
 			break;
 		/* Skip index block entry if continuing previous readdir. */
 		if (ia_pos - ia_start > (u8*)ie - (u8*)ia)
diff -Nru a/fs/ntfs/inode.c b/fs/ntfs/inode.c
--- a/fs/ntfs/inode.c	Wed Apr 30 22:28:16 2003
+++ b/fs/ntfs/inode.c	Wed Apr 30 22:28:16 2003
@@ -1,7 +1,7 @@
 /**
  * inode.c - NTFS kernel inode handling. Part of the Linux-NTFS project.
  *
- * Copyright (c) 2001,2002 Anton Altaparmakov.
+ * Copyright (c) 2001-2003 Anton Altaparmakov
  *
  * This program/include file is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
@@ -336,14 +336,14 @@
 	ni->attr_list_size = 0;
 	ni->attr_list = NULL;
 	init_run_list(&ni->attr_list_rl);
-	ni->_IDM(bmp_ino) = NULL;
-	ni->_IDM(index_block_size) = 0;
-	ni->_IDM(index_vcn_size) = 0;
-	ni->_IDM(index_block_size_bits) = 0;
-	ni->_IDM(index_vcn_size_bits) = 0;
+	ni->itype.index.bmp_ino = NULL;
+	ni->itype.index.block_size = 0;
+	ni->itype.index.vcn_size = 0;
+	ni->itype.index.block_size_bits = 0;
+	ni->itype.index.vcn_size_bits = 0;
 	init_MUTEX(&ni->extent_lock);
 	ni->nr_extents = 0;
-	ni->_INE(base_ntfs_ino) = NULL;
+	ni->ext.base_ntfs_ino = NULL;
 	return;
 }
 
@@ -426,14 +426,14 @@
 					"chkdsk.");
 			return -EIO;
 		}
-		if (!(attr->_ARA(resident_flags) & RESIDENT_ATTR_IS_INDEXED)) {
+		if (!(attr->data.resident.flags & RESIDENT_ATTR_IS_INDEXED)) {
 			ntfs_error(ctx->ntfs_ino->vol->sb, "Unindexed file "
 					"name. You should run chkdsk.");
 			return -EIO;
 		}
 		file_name_attr = (FILE_NAME_ATTR*)((u8*)attr +
-				le16_to_cpu(attr->_ARA(value_offset)));
-		p2 = (u8*)attr + le32_to_cpu(attr->_ARA(value_length));
+				le16_to_cpu(attr->data.resident.value_offset));
+		p2 = (u8*)attr + le32_to_cpu(attr->data.resident.value_length);
 		if (p2 < (u8*)attr || p2 > p)
 			goto err_corrupt_attr;
 		/* This attribute is ok, but is it in the $Extend directory? */
@@ -578,7 +578,7 @@
 	}
 	/* Get the standard information attribute value. */
 	si = (STANDARD_INFORMATION*)((char*)ctx->attr +
-			le16_to_cpu(ctx->attr->_ARA(value_offset)));
+			le16_to_cpu(ctx->attr->data.resident.value_offset));
 
 	/* Transfer information from the standard information into vfs_ino. */
 	/*
@@ -633,7 +633,7 @@
 		}
 		if (ctx->attr->non_resident) {
 			NInoSetAttrListNonResident(ni);
-			if (ctx->attr->_ANR(lowest_vcn)) {
+			if (ctx->attr->data.non_resident.lowest_vcn) {
 				ntfs_error(vi->i_sb, "Attribute list has non "
 						"zero lowest_vcn. Inode is "
 						"corrupt. You should run "
@@ -659,17 +659,17 @@
 			/* Now load the attribute list. */
 			if ((err = load_attribute_list(vol, &ni->attr_list_rl,
 					ni->attr_list, ni->attr_list_size,
-					sle64_to_cpu(
-					ctx->attr->_ANR(initialized_size))))) {
+					sle64_to_cpu(ctx->attr->data.
+					non_resident.initialized_size)))) {
 				ntfs_error(vi->i_sb, "Failed to load "
 						"attribute list attribute.");
 				goto unm_err_out;
 			}
 		} else /* if (!ctx.attr->non_resident) */ {
 			if ((u8*)ctx->attr + le16_to_cpu(
-					ctx->attr->_ARA(value_offset)) +
+					ctx->attr->data.resident.value_offset) +
 					le32_to_cpu(
-					ctx->attr->_ARA(value_length)) >
+					ctx->attr->data.resident.value_length) >
 					(u8*)ctx->mrec + vol->mft_record_size) {
 				ntfs_error(vi->i_sb, "Corrupt attribute list "
 						"in inode.");
@@ -677,9 +677,9 @@
 			}
 			/* Now copy the attribute list. */
 			memcpy(ni->attr_list, (u8*)ctx->attr + le16_to_cpu(
-					ctx->attr->_ARA(value_offset)),
+					ctx->attr->data.resident.value_offset),
 					le32_to_cpu(
-					ctx->attr->_ARA(value_length)));
+					ctx->attr->data.resident.value_length));
 		}
 	}
 skip_attr_list_load:
@@ -728,9 +728,10 @@
 		}
 		if (ctx->attr->flags & ATTR_IS_SPARSE)
 			NInoSetSparse(ni);
-		ir = (INDEX_ROOT*)((char*)ctx->attr +
-				le16_to_cpu(ctx->attr->_ARA(value_offset)));
-		ir_end = (char*)ir + le32_to_cpu(ctx->attr->_ARA(value_length));
+		ir = (INDEX_ROOT*)((char*)ctx->attr + le16_to_cpu(
+				ctx->attr->data.resident.value_offset));
+		ir_end = (char*)ir + le32_to_cpu(
+				ctx->attr->data.resident.value_length);
 		if (ir_end > (char*)ctx->mrec + vol->mft_record_size) {
 			ntfs_error(vi->i_sb, "$INDEX_ROOT attribute is "
 					"corrupt.");
@@ -752,41 +753,41 @@
 					"COLLATION_FILE_NAME. Not allowed.");
 			goto unm_err_out;
 		}
-		ni->_IDM(index_block_size) = le32_to_cpu(ir->index_block_size);
-		if (ni->_IDM(index_block_size) &
-				(ni->_IDM(index_block_size) - 1)) {
+		ni->itype.index.block_size = le32_to_cpu(ir->index_block_size);
+		if (ni->itype.index.block_size &
+				(ni->itype.index.block_size - 1)) {
 			ntfs_error(vi->i_sb, "Index block size (%u) is not a "
 					"power of two.",
-					ni->_IDM(index_block_size));
+					ni->itype.index.block_size);
 			goto unm_err_out;
 		}
-		if (ni->_IDM(index_block_size) > PAGE_CACHE_SIZE) {
+		if (ni->itype.index.block_size > PAGE_CACHE_SIZE) {
 			ntfs_error(vi->i_sb, "Index block size (%u) > "
 					"PAGE_CACHE_SIZE (%ld) is not "
 					"supported. Sorry.",
-					ni->_IDM(index_block_size),
+					ni->itype.index.block_size,
 					PAGE_CACHE_SIZE);
 			err = -EOPNOTSUPP;
 			goto unm_err_out;
 		}
-		if (ni->_IDM(index_block_size) < NTFS_BLOCK_SIZE) {
+		if (ni->itype.index.block_size < NTFS_BLOCK_SIZE) {
 			ntfs_error(vi->i_sb, "Index block size (%u) < "
 					"NTFS_BLOCK_SIZE (%i) is not "
 					"supported. Sorry.",
-					ni->_IDM(index_block_size),
+					ni->itype.index.block_size,
 					NTFS_BLOCK_SIZE);
 			err = -EOPNOTSUPP;
 			goto unm_err_out;
 		}
-		ni->_IDM(index_block_size_bits) =
-				ffs(ni->_IDM(index_block_size)) - 1;
+		ni->itype.index.block_size_bits =
+				ffs(ni->itype.index.block_size) - 1;
 		/* Determine the size of a vcn in the directory index. */
-		if (vol->cluster_size <= ni->_IDM(index_block_size)) {
-			ni->_IDM(index_vcn_size) = vol->cluster_size;
-			ni->_IDM(index_vcn_size_bits) = vol->cluster_size_bits;
+		if (vol->cluster_size <= ni->itype.index.block_size) {
+			ni->itype.index.vcn_size = vol->cluster_size;
+			ni->itype.index.vcn_size_bits = vol->cluster_size_bits;
 		} else {
-			ni->_IDM(index_vcn_size) = vol->sector_size;
-			ni->_IDM(index_vcn_size_bits) = vol->sector_size_bits;
+			ni->itype.index.vcn_size = vol->sector_size;
+			ni->itype.index.vcn_size_bits = vol->sector_size_bits;
 		}
 
 		/* Setup the index allocation attribute, even if not present. */
@@ -836,18 +837,19 @@
 					"is compressed.");
 			goto unm_err_out;
 		}
-		if (ctx->attr->_ANR(lowest_vcn)) {
+		if (ctx->attr->data.non_resident.lowest_vcn) {
 			ntfs_error(vi->i_sb, "First extent of "
 					"$INDEX_ALLOCATION attribute has non "
 					"zero lowest_vcn. Inode is corrupt. "
 					"You should run chkdsk.");
 			goto unm_err_out;
 		}
-		vi->i_size = sle64_to_cpu(ctx->attr->_ANR(data_size));
+		vi->i_size = sle64_to_cpu(
+				ctx->attr->data.non_resident.data_size);
 		ni->initialized_size = sle64_to_cpu(
-				ctx->attr->_ANR(initialized_size));
+				ctx->attr->data.non_resident.initialized_size);
 		ni->allocated_size = sle64_to_cpu(
-				ctx->attr->_ANR(allocated_size));
+				ctx->attr->data.non_resident.allocated_size);
 		/*
 		 * We are done with the mft record, so we release it. Otherwise
 		 * we would deadlock in ntfs_attr_iget().
@@ -863,7 +865,7 @@
 			err = PTR_ERR(bvi);
 			goto unm_err_out;
 		}
-		ni->_IDM(bmp_ino) = bvi;
+		ni->itype.index.bmp_ino = bvi;
 		bni = NTFS_I(bvi);
 		if (NInoCompressed(bni) || NInoEncrypted(bni) ||
 				NInoSparse(bni)) {
@@ -873,7 +875,7 @@
 		}
 		/* Consistency check bitmap size vs. index allocation size. */
 		if ((bvi->i_size << 3) < (vi->i_size >>
-				ni->_IDM(index_block_size_bits))) {
+				ni->itype.index.block_size_bits)) {
 			ntfs_error(vi->i_sb, "Index bitmap too small (0x%Lx) "
 					"for index allocation (0x%Lx).",
 					bvi->i_size << 3, vi->i_size);
@@ -950,25 +952,28 @@
 						"corrupt file.");
 					goto unm_err_out;
 				}
-				ni->_ICF(compression_block_clusters) = 1U <<
-					ctx->attr->_ANR(compression_unit);
-				if (ctx->attr->_ANR(compression_unit) != 4) {
+				ni->itype.compressed.block_clusters = 1U <<
+						ctx->attr->data.non_resident.
+						compression_unit;
+				if (ctx->attr->data.non_resident.
+						compression_unit != 4) {
 					ntfs_error(vi->i_sb, "Found "
 						"nonstandard compression unit "
 						"(%u instead of 4). Cannot "
 						"handle this. This might "
 						"indicate corruption so you "
 						"should run chkdsk.",
-					     ctx->attr->_ANR(compression_unit));
+						ctx->attr->data.non_resident.
+						compression_unit);
 					err = -EOPNOTSUPP;
 					goto unm_err_out;
 				}
-				ni->_ICF(compression_block_size) = 1U << (
-						ctx->attr->_ANR(
-						compression_unit) +
+				ni->itype.compressed.block_size = 1U << (
+						ctx->attr->data.non_resident.
+						compression_unit +
 						vol->cluster_size_bits);
-				ni->_ICF(compression_block_size_bits) = ffs(
-					ni->_ICF(compression_block_size)) - 1;
+				ni->itype.compressed.block_size_bits = ffs(
+					ni->itype.compressed.block_size) - 1;
 			}
 			if (ctx->attr->flags & ATTR_IS_ENCRYPTED) {
 				if (ctx->attr->flags & ATTR_COMPRESSION_MASK) {
@@ -980,7 +985,7 @@
 			}
 			if (ctx->attr->flags & ATTR_IS_SPARSE)
 				NInoSetSparse(ni);
-			if (ctx->attr->_ANR(lowest_vcn)) {
+			if (ctx->attr->data.non_resident.lowest_vcn) {
 				ntfs_error(vi->i_sb, "First extent of $DATA "
 						"attribute has non zero "
 						"lowest_vcn. Inode is corrupt. "
@@ -988,24 +993,18 @@
 				goto unm_err_out;
 			}
 			/* Setup all the sizes. */
-			vi->i_size = sle64_to_cpu(ctx->attr->_ANR(data_size));
+			vi->i_size = sle64_to_cpu(
+					ctx->attr->data.non_resident.data_size);
 			ni->initialized_size = sle64_to_cpu(
-					ctx->attr->_ANR(initialized_size));
+					ctx->attr->data.non_resident.
+					initialized_size);
 			ni->allocated_size = sle64_to_cpu(
-					ctx->attr->_ANR(allocated_size));
+					ctx->attr->data.non_resident.
+					allocated_size);
 			if (NInoCompressed(ni)) {
-				ni->_ICF(compressed_size) = sle64_to_cpu(
-					ctx->attr->_ANR(compressed_size));
-				if (vi->i_size != ni->initialized_size)
-					ntfs_warning(vi->i_sb, "BUG: Found "
-						"compressed file with "
-						"data_size not equal to "
-						"initialized_size. This will "
-						"probably cause problems when "
-						"trying to access the file. "
-						"Please notify linux-ntfs-dev@"
-						"lists.sf.net that you saw "
-						"this message. Thanks!");
+				ni->itype.compressed.size = sle64_to_cpu(
+						ctx->attr->data.non_resident.
+						compressed_size);
 			}
 		} else { /* Resident attribute. */
 			/*
@@ -1015,7 +1014,8 @@
 			 * path. (Probably only affects truncate().)
 			 */
 			vi->i_size = ni->initialized_size = ni->allocated_size =
-				le32_to_cpu(ctx->attr->_ARA(value_length));
+					le32_to_cpu(
+					ctx->attr->data.resident.value_length);
 		}
 no_data_attr_special_case:
 		/* We are done with the mft record, so we release it. */
@@ -1049,7 +1049,7 @@
 	if (!NInoCompressed(ni))
 		vi->i_blocks = ni->allocated_size >> 9;
 	else
-		vi->i_blocks = ni->_ICF(compressed_size) >> 9;
+		vi->i_blocks = ni->itype.compressed.size >> 9;
 
 	ntfs_debug("Done.");
 	return 0;
@@ -1146,7 +1146,7 @@
 		 * read code paths.
 		 */
 		vi->i_size = ni->initialized_size = ni->allocated_size =
-			le32_to_cpu(ctx->attr->_ARA(value_length));
+			le32_to_cpu(ctx->attr->data.resident.value_length);
 	} else {
 		NInoSetNonResident(ni);
 		if (ctx->attr->flags & ATTR_COMPRESSION_MASK) {
@@ -1189,25 +1189,27 @@
 						"corrupt file.");
 				goto unm_err_out;
 			}
-			ni->_ICF(compression_block_clusters) = 1U <<
-					ctx->attr->_ANR(compression_unit);
-			if (ctx->attr->_ANR(compression_unit) != 4) {
+			ni->itype.compressed.block_clusters = 1U <<
+					ctx->attr->data.non_resident.
+					compression_unit;
+			if (ctx->attr->data.non_resident.compression_unit != 4) {
 				ntfs_error(vi->i_sb, "Found "
 					"nonstandard compression unit "
 					"(%u instead of 4). Cannot "
 					"handle this. This might "
 					"indicate corruption so you "
 					"should run chkdsk.",
-				     ctx->attr->_ANR(compression_unit));
+					ctx->attr->data.non_resident.
+					compression_unit);
 				err = -EOPNOTSUPP;
 				goto unm_err_out;
 			}
-			ni->_ICF(compression_block_size) = 1U << (
-					ctx->attr->_ANR(
-					compression_unit) +
+			ni->itype.compressed.block_size = 1U << (
+					ctx->attr->data.non_resident.
+					compression_unit +
 					vol->cluster_size_bits);
-			ni->_ICF(compression_block_size_bits) = ffs(
-				ni->_ICF(compression_block_size)) - 1;
+			ni->itype.compressed.block_size_bits = ffs(
+				ni->itype.compressed.block_size) - 1;
 		}
 		if (ctx->attr->flags & ATTR_IS_ENCRYPTED) {
 			if (ctx->attr->flags & ATTR_COMPRESSION_MASK) {
@@ -1242,30 +1244,23 @@
 			}
 			NInoSetSparse(ni);
 		}
-		if (ctx->attr->_ANR(lowest_vcn)) {
+		if (ctx->attr->data.non_resident.lowest_vcn) {
 			ntfs_error(vi->i_sb, "First extent of attribute has "
 					"non-zero lowest_vcn. Inode is "
 					"corrupt. You should run chkdsk.");
 			goto unm_err_out;
 		}
 		/* Setup all the sizes. */
-		vi->i_size = sle64_to_cpu(ctx->attr->_ANR(data_size));
+		vi->i_size = sle64_to_cpu(
+				ctx->attr->data.non_resident.data_size);
 		ni->initialized_size = sle64_to_cpu(
-				ctx->attr->_ANR(initialized_size));
+				ctx->attr->data.non_resident.initialized_size);
 		ni->allocated_size = sle64_to_cpu(
-				ctx->attr->_ANR(allocated_size));
+				ctx->attr->data.non_resident.allocated_size);
 		if (NInoCompressed(ni)) {
-			ni->_ICF(compressed_size) = sle64_to_cpu(
-				ctx->attr->_ANR(compressed_size));
-			if (vi->i_size != ni->initialized_size)
-				ntfs_warning(vi->i_sb, "Compressed attribute "
-						"with data_size unequal to "
-						"initialized size found. This "
-						"will probably cause problems "
-						"when trying to access the "
-						"file. Please notify "
-						"linux-ntfs-dev@lists.sf.net "
-						"that you saw this message.");
+			ni->itype.compressed.size = sle64_to_cpu(
+					ctx->attr->data.non_resident.
+					compressed_size);
 		}
 	}
 
@@ -1277,14 +1272,14 @@
 	if (!NInoCompressed(ni))
 		vi->i_blocks = ni->allocated_size >> 9;
 	else
-		vi->i_blocks = ni->_ICF(compressed_size) >> 9;
+		vi->i_blocks = ni->itype.compressed.size >> 9;
 
 	/*
 	 * Make sure the base inode doesn't go away and attach it to the
 	 * attribute inode.
 	 */
 	igrab(base_vi);
-	ni->_INE(base_ntfs_ino) = base_ni;
+	ni->ext.base_ntfs_ino = base_ni;
 	ni->nr_extents = -1;
 
 	put_attr_search_ctx(ctx);
@@ -1371,8 +1366,8 @@
 	 * This sets up our little cheat allowing us to reuse the async io
 	 * completion handler for directories.
 	 */
-	ni->_IDM(index_block_size) = vol->mft_record_size;
-	ni->_IDM(index_block_size_bits) = vol->mft_record_size_bits;
+	ni->itype.index.block_size = vol->mft_record_size;
+	ni->itype.index.block_size_bits = vol->mft_record_size_bits;
 
 	/* Very important! Needed to be able to call map_mft_record*(). */
 	vol->mft_ino = vi;
@@ -1456,7 +1451,7 @@
 		}
 		if (ctx->attr->non_resident) {
 			NInoSetAttrListNonResident(ni);
-			if (ctx->attr->_ANR(lowest_vcn)) {
+			if (ctx->attr->data.non_resident.lowest_vcn) {
 				ntfs_error(sb, "Attribute list has non zero "
 						"lowest_vcn. $MFT is corrupt. "
 						"You should run chkdsk.");
@@ -1476,8 +1471,8 @@
 			/* Now load the attribute list. */
 			if ((err = load_attribute_list(vol, &ni->attr_list_rl,
 					ni->attr_list, ni->attr_list_size,
-					sle64_to_cpu(
-					ctx->attr->_ANR(initialized_size))))) {
+					sle64_to_cpu(ctx->attr->data.
+					non_resident.initialized_size)))) {
 				ntfs_error(sb, "Failed to load attribute list "
 						"attribute with error code %i.",
 						-err);
@@ -1485,9 +1480,9 @@
 			}
 		} else /* if (!ctx.attr->non_resident) */ {
 			if ((u8*)ctx->attr + le16_to_cpu(
-					ctx->attr->_ARA(value_offset)) +
+					ctx->attr->data.resident.value_offset) +
 					le32_to_cpu(
-					ctx->attr->_ARA(value_length)) >
+					ctx->attr->data.resident.value_length) >
 					(u8*)ctx->mrec + vol->mft_record_size) {
 				ntfs_error(sb, "Corrupt attribute list "
 						"attribute.");
@@ -1495,9 +1490,9 @@
 			}
 			/* Now copy the attribute list. */
 			memcpy(ni->attr_list, (u8*)ctx->attr + le16_to_cpu(
-					ctx->attr->_ARA(value_offset)),
+					ctx->attr->data.resident.value_offset),
 					le32_to_cpu(
-					ctx->attr->_ARA(value_length)));
+					ctx->attr->data.resident.value_length));
 		}
 		/* The attribute list is now setup in memory. */
 		/*
@@ -1606,7 +1601,7 @@
 		if (!next_vcn) {
 			u64 ll;
 
-			if (attr->_ANR(lowest_vcn)) {
+			if (attr->data.non_resident.lowest_vcn) {
 				ntfs_error(sb, "First extent of $DATA "
 						"attribute has non zero "
 						"lowest_vcn. $MFT is corrupt. "
@@ -1614,14 +1609,16 @@
 				goto put_err_out;
 			}
 			/* Get the last vcn in the $DATA attribute. */
-			last_vcn = sle64_to_cpu(attr->_ANR(allocated_size)) >>
-					vol->cluster_size_bits;
+			last_vcn = sle64_to_cpu(
+					attr->data.non_resident.allocated_size)
+					>> vol->cluster_size_bits;
 			/* Fill in the inode size. */
-			vi->i_size = sle64_to_cpu(attr->_ANR(data_size));
-			ni->initialized_size = sle64_to_cpu(
-					attr->_ANR(initialized_size));
+			vi->i_size = sle64_to_cpu(
+					attr->data.non_resident.data_size);
+			ni->initialized_size = sle64_to_cpu(attr->data.
+					non_resident.initialized_size);
 			ni->allocated_size = sle64_to_cpu(
-					attr->_ANR(allocated_size));
+					attr->data.non_resident.allocated_size);
 			/* Set the number of mft records. */
 			ll = vi->i_size >> vol->mft_record_size_bits;
 			/*
@@ -1687,7 +1684,7 @@
 		}
 
 		/* Get the lowest vcn for the next extent. */
-		highest_vcn = sle64_to_cpu(attr->_ANR(highest_vcn));
+		highest_vcn = sle64_to_cpu(attr->data.non_resident.highest_vcn);
 		next_vcn = highest_vcn + 1;
 
 		/* Only one extent or error, which we catch below. */
@@ -1695,7 +1692,8 @@
 			break;
 
 		/* Avoid endless loops due to corruption. */
-		if (next_vcn < sle64_to_cpu(attr->_ANR(lowest_vcn))) {
+		if (next_vcn < sle64_to_cpu(
+				attr->data.non_resident.lowest_vcn)) {
 			ntfs_error(sb, "$MFT has corrupt attribute list "
 					"attribute. Run chkdsk.");
 			goto put_err_out;
@@ -1796,9 +1794,9 @@
 		ntfs_inode *ni;
 
 		ni = NTFS_I(vi);
-		if (NInoIndexAllocPresent(ni) && ni->_IDM(bmp_ino)) {
-			iput(ni->_IDM(bmp_ino));
-			ni->_IDM(bmp_ino) = NULL;
+		if (NInoIndexAllocPresent(ni) && ni->itype.index.bmp_ino) {
+			iput(ni->itype.index.bmp_ino);
+			ni->itype.index.bmp_ino = NULL;
 		}
 	}
 	return;
@@ -1831,8 +1829,8 @@
 
 		// FIXME: Handle dirty case for each extent inode!
 		for (i = 0; i < ni->nr_extents; i++)
-			ntfs_clear_extent_inode(ni->_INE(extent_ntfs_inos)[i]);
-		kfree(ni->_INE(extent_ntfs_inos));
+			ntfs_clear_extent_inode(ni->ext.extent_ntfs_inos[i]);
+		kfree(ni->ext.extent_ntfs_inos);
 	}
 	/* Free all alocated memory. */
 	down_write(&ni->run_list.lock);
@@ -1888,9 +1886,9 @@
 	if (NInoAttr(ni)) {
 		/* Release the base inode if we are holding it. */
 		if (ni->nr_extents == -1) {
-			iput(VFS_I(ni->_INE(base_ntfs_ino)));
+			iput(VFS_I(ni->ext.base_ntfs_ino));
 			ni->nr_extents = 0;
-			ni->_INE(base_ntfs_ino) = NULL;
+			ni->ext.base_ntfs_ino = NULL;
 		}
 	}
 	return;
diff -Nru a/fs/ntfs/inode.h b/fs/ntfs/inode.h
--- a/fs/ntfs/inode.h	Wed Apr 30 22:28:14 2003
+++ b/fs/ntfs/inode.h	Wed Apr 30 22:28:14 2003
@@ -2,8 +2,8 @@
  * inode.h - Defines for inode structures NTFS Linux kernel driver. Part of
  *	     the Linux-NTFS project.
  *
- * Copyright (c) 2001,2002 Anton Altaparmakov.
- * Copyright (c) 2002 Richard Russon.
+ * Copyright (c) 2001-2003 Anton Altaparmakov
+ * Copyright (c) 2002 Richard Russon
  *
  * This program/include file is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
@@ -93,23 +93,21 @@
 		struct { /* It is a directory or $MFT. */
 			struct inode *bmp_ino;	/* Attribute inode for the
 						   directory index $BITMAP. */
-			u32 index_block_size;	/* Size of an index block. */
-			u32 index_vcn_size;	/* Size of a vcn in this
+			u32 block_size;		/* Size of an index block. */
+			u32 vcn_size;		/* Size of a vcn in this
 						   directory index. */
-			u8 index_block_size_bits; /* Log2 of the above. */
-			u8 index_vcn_size_bits;	/* Log2 of the above. */
-		} SN(idm);
+			u8 block_size_bits; 	/* Log2 of the above. */
+			u8 vcn_size_bits;	/* Log2 of the above. */
+		} index;
 		struct { /* It is a compressed file or fake inode. */
-			s64 compressed_size;		/* Copy from $DATA. */
-			u32 compression_block_size;     /* Size of a compression
-						           block (cb). */
-			u8 compression_block_size_bits; /* Log2 of the size of
-							   a cb. */
-			u8 compression_block_clusters;  /* Number of clusters
-							   per compression
-							   block. */
-		} SN(icf);
-	} SN(idc);
+			s64 size;		/* Copy of compressed_size from
+						   $DATA. */
+			u32 block_size;		/* Size of a compression block
+						   (cb). */
+			u8 block_size_bits;	/* Log2 of the size of a cb. */
+			u8 block_clusters;	/* Number of clusters per cb. */
+		} compressed;
+	} itype;
 	struct semaphore extent_lock;	/* Lock for accessing/modifying the
 					   below . */
 	s32 nr_extents;	/* For a base mft record, the number of attached extent
@@ -126,12 +124,8 @@
 						   record. For fake inodes, the
 						   real (base) inode to which
 						   the attribute belongs. */
-	} SN(ine);
+	} ext;
 };
-
-#define _IDM(X)  SC(idc.idm,X)
-#define _ICF(X)  SC(idc.icf,X)
-#define _INE(X)  SC(ine,X)
 
 /*
  * Defined bits for the state field in the ntfs_inode structure.
diff -Nru a/fs/ntfs/layout.h b/fs/ntfs/layout.h
--- a/fs/ntfs/layout.h	Wed Apr 30 22:28:10 2003
+++ b/fs/ntfs/layout.h	Wed Apr 30 22:28:10 2003
@@ -2,8 +2,8 @@
  * layout.h - All NTFS associated on-disk structures. Part of the Linux-NTFS
  *	      project.
  *
- * Copyright (c) 2001,2002 Anton Altaparmakov.
- * Copyright (C) 2002 Richard Russon.
+ * Copyright (c) 2001-2003 Anton Altaparmakov
+ * Copyright (c) 2002 Richard Russon
  *
  * This program/include file is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
@@ -296,7 +296,11 @@
  */
 typedef struct {
 /*Ofs*/
-/*  0*/	NTFS_RECORD SN(mnr);	/* Usually the magic is "FILE". */
+/*  0	NTFS_RECORD; -- Unfolded here as gcc doesn't like unnamed structs. */
+	NTFS_RECORD_TYPES magic;/* Usually the magic is "FILE". */
+	u16 usa_ofs;		/* See NTFS_RECORD definition above. */
+	u16 usa_count;		/* See NTFS_RECORD definition above. */
+
 /*  8*/	u64 lsn;		/* $LogFile sequence number for this record.
 				   Changed every time the record is modified. */
 /* 16*/	u16 sequence_number;	/* Number of times this mft record has been
@@ -360,8 +364,6 @@
  */
 } __attribute__ ((__packed__)) MFT_RECORD;
 
-#define _MNR(X)  SC(mnr,X)
-
 /*
  * System defined attributes (32-bit). Each attribute type has a corresponding
  * attribute name (Unicode string of maximum 64 character length) as described
@@ -612,10 +614,10 @@
 					     have a name present as this might
 					     not have a length of a multiple
 					     of 8-bytes. */
-/* 22 */		RESIDENT_ATTR_FLAGS resident_flags; /* See above. */
-/* 23 */		s8 reservedR;	  /* Reserved/alignment to 8-byte
+/* 22 */		RESIDENT_ATTR_FLAGS flags; /* See above. */
+/* 23 */		s8 reserved;	  /* Reserved/alignment to 8-byte
 					     boundary. */
-		} SN(ara) __attribute__ ((__packed__));
+		} __attribute__ ((__packed__)) resident;
 		/* Non-resident attributes. */
 		struct {
 /* 16*/			VCN lowest_vcn;	/* Lowest valid virtual cluster number
@@ -641,7 +643,7 @@
 				compressed. (This effectively limits the
 				compression unit size to be a power of two
 				clusters.) WinNT4 only uses a value of 4. */
-/* 35*/			u8 reserved1[5];	/* Align to 8-byte boundary. */
+/* 35*/			u8 reserved[5];		/* Align to 8-byte boundary. */
 /* The sizes below are only used when lowest_vcn is zero, as otherwise it would
    be difficult to keep them up-to-date.*/
 /* 40*/			s64 allocated_size;	/* Byte size of disk space
@@ -665,13 +667,10 @@
 				cluster size. Represents the actual amount of
 				disk space being used on the disk. */
 /* sizeof(compressed attr) = 72*/
-		} SN(anr) __attribute__ ((__packed__));
-	} SN(aua) __attribute__ ((__packed__));
+		} __attribute__ ((__packed__)) non_resident;
+	} __attribute__ ((__packed__)) data;
 } __attribute__ ((__packed__)) ATTR_RECORD;
 
-#define _ARA(X)  SC(aua.ara,X)
-#define _ANR(X)  SC(aua.anr,X)
-
 typedef ATTR_RECORD ATTR_REC;
 
 /*
@@ -763,11 +762,13 @@
 					   disabled altogether for speed. */
 /* 32*/	FILE_ATTR_FLAGS file_attributes; /* Flags describing the file. */
 /* 36*/	union {
-		/* NTFS 1.2 (and previous, presumably) */
-/* 36 */	u8 reserved12[12];	/* Reserved/alignment to 8-byte
-					   boundary. */
-/* sizeof() = 48 bytes */
-		/* NTFS 3.0 */
+	/* NTFS 1.2 */
+		struct {
+		/* 36*/	u8 reserved12[12];	/* Reserved/alignment to 8-byte
+						   boundary. */
+		} __attribute__ ((__packed__)) v1;
+	/* sizeof() = 48 bytes */
+	/* NTFS 3.x */
 		struct {
 /*
  * If a volume has been upgraded from a previous NTFS version, then these
@@ -777,12 +778,12 @@
  * the fields are present. Maybe just check like this:
  * 	if (resident.ValueLength < sizeof(STANDARD_INFORMATION)) {
  * 		Assume NTFS 1.2- format.
- * 		If (volume version is 3.0+)
- * 			Upgrade attribute to NTFS 3.0 format.
+ * 		If (volume version is 3.x)
+ * 			Upgrade attribute to NTFS 3.x format.
  * 		else
  * 			Use NTFS 1.2- format for access.
  * 	} else
- * 		Use NTFS 3.0 format for access.
+ * 		Use NTFS 3.x format for access.
  * Only problem is that it might be legal to set the length of the value to
  * arbitrarily large values thus spoiling this check. - But chkdsk probably
  * views that as a corruption, assuming that it behaves like this for all
@@ -818,13 +819,11 @@
 				partition. This, in contrast to disabling the
 				journal is a very fast process, so the user
 				won't even notice it. */
-		} SN(svs);
-	} SN(sei);
-/* sizeof() = 72 bytes (NTFS 3.0) */
+		} __attribute__ ((__packed__)) v3;
+	/* sizeof() = 72 bytes (NTFS 3.x) */
+	} __attribute__ ((__packed__)) ver;
 } __attribute__ ((__packed__)) STANDARD_INFORMATION;
 
-#define _SVS(X)  SC(sei.svs,X)
-
 /*
  * Attribute: Attribute list (0x20).
  *
@@ -956,21 +955,20 @@
 						   pack the extended attributes
 						   (EAs), if such are present.*/
 		/* 3e*/	u16 reserved;		/* Reserved for alignment. */
-		} SN(fea) __attribute__ ((__packed__));
-	/* 3c*/	u32 reparse_point_tag;		/* Type of reparse point,
+		} __attribute__ ((__packed__)) ea;
+	/* 3c*/	struct {
+		/* 3c*/	u32 reparse_point_tag;	/* Type of reparse point,
 						   present only in reparse
 						   points and only if there are
 						   no EAs. */
-	} SN(fer) __attribute__ ((__packed__));
+		} __attribute__ ((__packed__)) rp;
+	} __attribute__ ((__packed__)) type;
 /* 40*/	u8 file_name_length;			/* Length of file name in
 						   (Unicode) characters. */
 /* 41*/	FILE_NAME_TYPE_FLAGS file_name_type;	/* Namespace of the file name.*/
 /* 42*/	uchar_t file_name[0];			/* File name in Unicode. */
 } __attribute__ ((__packed__)) FILE_NAME_ATTR;
 
-#define _FEA(X)  SC(fer.fea,X)
-#define _FER(X)  SC(fer,X)
-
 /*
  * GUID structures store globally unique identifiers (GUID). A GUID is a 
  * 128-bit value consisting of one group of eight hexadecimal digits, followed
@@ -1008,9 +1006,9 @@
 			GUID birth_volume_id;
 			GUID birth_object_id;
 			GUID domain_id;
-		} SN(obv) __attribute__ ((__packed__));
+		} __attribute__ ((__packed__)) origin;
 		u8 extended_info[48];
-	} SN(oei) __attribute__ ((__packed__));
+	} __attribute__ ((__packed__)) opt;
 } __attribute__ ((__packed__)) OBJ_ID_INDEX_DATA;
 
 /*
@@ -1032,13 +1030,11 @@
 			GUID birth_object_id;	/* Unique id of file when it was
 						   first created. */
 			GUID domain_id;		/* Reserved, zero. */
-		} SN(obv) __attribute__ ((__packed__));
+		} __attribute__ ((__packed__)) origin;
 		u8 extended_info[48];
-	} SN(oei) __attribute__ ((__packed__));
+	} __attribute__ ((__packed__)) opt;
 } __attribute__ ((__packed__)) OBJECT_ID_ATTR;
 
-#define _OBV(X)  SC(oei.obv,X)
-
 /*
  * The pre-defined IDENTIFIER_AUTHORITIES used as SID_IDENTIFIER_AUTHORITY in
  * the SID structure (see below).
@@ -1174,14 +1170,12 @@
  */
 typedef union {
 	struct {
-		u32 low_part;         /* Low 32-bits. */
-		u16 high_part;        /* High 16-bits. */
-	} SN(sia) __attribute__ ((__packed__));
+		u32 low;         /* Low 32-bits. */
+		u16 high;        /* High 16-bits. */
+	} __attribute__ ((__packed__)) parts;
 	u8 value[6];			/* Value as individual bytes. */
 } __attribute__ ((__packed__)) SID_IDENTIFIER_AUTHORITY;
 
-#define _SIA(X)  SC(sia,X)
-
 /*
  * The SID structure is a variable-length structure used to uniquely identify
  * users or groups. SID stands for security identifier.
@@ -1287,9 +1281,10 @@
  * data depends on the ACE type.
  */
 typedef struct {
-	ACE_TYPES type;		/* Type of the ACE. */
-	ACE_FLAGS flags;	/* Flags describing the ACE. */
-	u16 size;		/* Size in bytes of the ACE. */
+/*Ofs*/
+/*  0*/	ACE_TYPES type;		/* Type of the ACE. */
+/*  1*/	ACE_FLAGS flags;	/* Flags describing the ACE. */
+/*  2*/	u16 size;		/* Size in bytes of the ACE. */
 } __attribute__ ((__packed__)) ACE_HEADER;
 
 /*
@@ -1446,12 +1441,15 @@
  * ACCESS_ALLOWED_ACE, ACCESS_DENIED_ACE, SYSTEM_AUDIT_ACE, SYSTEM_ALARM_ACE
  */
 typedef struct {
-	ACE_HEADER SN(aah);		/* The ACE header. */
-	ACCESS_MASK mask;	/* Access mask associated with the ACE. */
-	SID sid;		/* The SID associated with the ACE. */
+/*  0	ACE_HEADER; -- Unfolded here as gcc doesn't like unnamed structs. */
+	ACE_TYPES type;		/* Type of the ACE. */
+	ACE_FLAGS flags;	/* Flags describing the ACE. */
+	u16 size;		/* Size in bytes of the ACE. */
+/*  4*/	ACCESS_MASK mask;	/* Access mask associated with the ACE. */
+
+/*  8*/	SID sid;		/* The SID associated with the ACE. */
 } __attribute__ ((__packed__)) ACCESS_ALLOWED_ACE, ACCESS_DENIED_ACE,
 			       SYSTEM_AUDIT_ACE, SYSTEM_ALARM_ACE;
-#define _AAH(X)  SC(aah,X)
 
 /*
  * The object ACE flags (32-bit).
@@ -1462,12 +1460,17 @@
 } OBJECT_ACE_FLAGS;
 
 typedef struct {
-	ACE_HEADER SN(aah);	/* The ACE_HEADER. */
-	ACCESS_MASK mask;	/* Access mask associated with the ACE. */
-	OBJECT_ACE_FLAGS flags;	/* Flags describing the object ACE. */
-	GUID object_type;
-	GUID inherited_object_type;
-	SID sid;		/* The SID associated with the ACE. */
+/*  0	ACE_HEADER; -- Unfolded here as gcc doesn't like unnamed structs. */
+	ACE_TYPES type;		/* Type of the ACE. */
+	ACE_FLAGS flags;	/* Flags describing the ACE. */
+	u16 size;		/* Size in bytes of the ACE. */
+/*  4*/	ACCESS_MASK mask;	/* Access mask associated with the ACE. */
+
+/*  8*/	OBJECT_ACE_FLAGS object_flags;	/* Flags describing the object ACE. */
+/* 12*/	GUID object_type;
+/* 28*/	GUID inherited_object_type;
+
+/* 44*/	SID sid;		/* The SID associated with the ACE. */
 } __attribute__ ((__packed__)) ACCESS_ALLOWED_OBJECT_ACE,
 			       ACCESS_DENIED_OBJECT_ACE,
 			       SYSTEM_AUDIT_OBJECT_ACE,
@@ -1711,13 +1714,17 @@
  * $SDS data stream and the second copy will be at offset 0x451d0.
  */
 typedef struct {
-	SECURITY_DESCRIPTOR_HEADER SN(sdh);	  /* The security descriptor header. */
-	SECURITY_DESCRIPTOR_RELATIVE sid; /* The self-relative security
+/*Ofs*/
+/*  0	SECURITY_DESCRIPTOR_HEADER; -- Unfolded here as gcc doesn't like
+				       unnamed structs. */
+	u32 hash;	   /* Hash of the security descriptor. */
+	u32 security_id;   /* The security_id assigned to the descriptor. */
+	u64 offset;	   /* Byte offset of this entry in the $SDS stream. */
+	u32 length;	   /* Size in bytes of this entry in $SDS stream. */
+/* 20*/	SECURITY_DESCRIPTOR_RELATIVE sid; /* The self-relative security
 					     descriptor. */
 } __attribute__ ((__packed__)) SDS_ENTRY;
 
-#define _SDH(X)  SC(sdh,X)
-
 /*
  * The index entry key used in the $SII index. The collation type is
  * COLLATION_NTOFS_ULONG. 
@@ -1888,7 +1895,11 @@
  * index entries (INDEX_ENTRY structures), as described by the INDEX_HEADER.
  */
 typedef struct {
-/*  0*/	NTFS_RECORD SN(inr);	/* Magic is "INDX". */
+/*  0	NTFS_RECORD; -- Unfolded here as gcc doesn't like unnamed structs. */
+	NTFS_RECORD_TYPES magic;/* Magic is "INDX". */
+	u16 usa_ofs;		/* See NTFS_RECORD definition. */
+	u16 usa_count;		/* See NTFS_RECORD definition. */
+
 /*  8*/	s64 lsn;		/* $LogFile sequence number of the last
 				   modification of this index block. */
 /* 16*/	VCN index_block_vcn;	/* Virtual cluster number of the index block.
@@ -1909,8 +1920,6 @@
  */
 } __attribute__ ((__packed__)) INDEX_BLOCK;
 
-#define _INR(X)  SC(inr,X)
-
 typedef INDEX_BLOCK INDEX_ALLOCATION;
 
 /*
@@ -2014,19 +2023,21 @@
  * This the index entry header (see below).
  */
 typedef struct {
-/*  0*/	union {		/* Only valid when INDEX_ENTRY_END is not set. */
-		MFT_REF indexed_file;		/* The mft reference of the file
+/*  0*/	union {
+		struct { /* Only valid when INDEX_ENTRY_END is not set. */
+			MFT_REF indexed_file;	/* The mft reference of the file
 						   described by this index
 						   entry. Used for directory
 						   indexes. */
+		} __attribute__ ((__packed__)) dir;
 		struct { /* Used for views/indexes to find the entry's data. */
 			u16 data_offset;	/* Data byte offset from this
 						   INDEX_ENTRY. Follows the
 						   index key. */
 			u16 data_length;	/* Data length in bytes. */
 			u32 reservedV;		/* Reserved (zero). */
-		} SN(iev) __attribute__ ((__packed__));
-	} SN(iif) __attribute__ ((__packed__));
+		} __attribute__ ((__packed__)) vi;
+	} __attribute__ ((__packed__)) data;
 /*  8*/	u16 length;		 /* Byte size of this index entry, multiple of
 				    8-bytes. */
 /* 10*/	u16 key_length;		 /* Byte size of the key value, which is in the
@@ -2037,9 +2048,6 @@
 /* sizeof() = 16 bytes */
 } __attribute__ ((__packed__)) INDEX_ENTRY_HEADER;
 
-#define _IIF(X)  SC(ieh.iif,X)
-#define _IEV(X)  SC(iif.iev,X)
-
 /*
  * This is an index entry. A sequence of such entries follows each INDEX_HEADER
  * structure. Together they make up a complete index. The index follows either
@@ -2048,7 +2056,31 @@
  * NOTE: Before NTFS 3.0 only filename attributes were indexed.
  */
 typedef struct {
-/*  0*/ INDEX_ENTRY_HEADER SN(ieh);	/* The index entry header (see above). */
+/*Ofs*/
+/*  0	INDEX_ENTRY_HEADER; -- Unfolded here as gcc dislikes unnamed structs. */
+	union {
+		struct { /* Only valid when INDEX_ENTRY_END is not set. */
+			MFT_REF indexed_file;	/* The mft reference of the file
+						   described by this index
+						   entry. Used for directory
+						   indexes. */
+		} __attribute__ ((__packed__)) dir;
+		struct { /* Used for views/indexes to find the entry's data. */
+			u16 data_offset;	/* Data byte offset from this
+						   INDEX_ENTRY. Follows the
+						   index key. */
+			u16 data_length;	/* Data length in bytes. */
+			u32 reservedV;		/* Reserved (zero). */
+		} __attribute__ ((__packed__)) vi;
+	} __attribute__ ((__packed__)) data;
+	u16 length;		 /* Byte size of this index entry, multiple of
+				    8-bytes. */
+	u16 key_length;		 /* Byte size of the key value, which is in the
+				    index entry. It follows field reserved. Not
+				    multiple of 8-bytes. */
+	INDEX_ENTRY_FLAGS flags; /* Bit field of INDEX_ENTRY_* flags. */
+	u16 reserved;		 /* Reserved/align to 8-byte boundary. */
+
 /* 16*/	union {		/* The key of the indexed attribute. NOTE: Only present
 			   if INDEX_ENTRY_END bit in flags is not set. NOTE: On
 			   NTFS versions before 3.0 the only valid key is the
@@ -2060,7 +2092,8 @@
 		GUID object_id;		/* $O index in FILE_Extend/$ObjId: The
 					   object_id of the mft record found in
 					   the data part of the index. */
-		REPARSE_INDEX_KEY SN(iri);	/* $R index in FILE_Extend/$Reparse. */
+		REPARSE_INDEX_KEY reparse;	/* $R index in
+						   FILE_Extend/$Reparse. */
 		SID sid;		/* $O index in FILE_Extend/$Quota:
 					   SID of the owner of the user_id. */
 		u32 owner_id;		/* $Q index in FILE_Extend/$Quota:
@@ -2082,9 +2115,6 @@
 	//		   (char*)ie + le16_to_cpu(ie*)->length) - sizeof(VCN),
 	//		   where sizeof(VCN) can be hardcoded as 8 if wanted. */
 } __attribute__ ((__packed__)) INDEX_ENTRY;
-
-#define _IEH(X)  SC(ieh,X)
-#define _IRI(X)  SC(key.iri,X)
 
 /*
  * Attribute: Bitmap (0xb0).
diff -Nru a/fs/ntfs/mft.c b/fs/ntfs/mft.c
--- a/fs/ntfs/mft.c	Wed Apr 30 22:28:12 2003
+++ b/fs/ntfs/mft.c	Wed Apr 30 22:28:12 2003
@@ -1,8 +1,8 @@
 /**
  * mft.c - NTFS kernel mft record operations. Part of the Linux-NTFS project.
  *
- * Copyright (c) 2001,2002 Anton Altaparmakov.
- * Copyright (c) 2002 Richard Russon.
+ * Copyright (c) 2001-2003 Anton Altaparmakov
+ * Copyright (c) 2002 Richard Russon
  *
  * This program/include file is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
@@ -39,18 +39,18 @@
 	ATTR_RECORD *a;
 
 	memset(m, 0, size);
-	m->_MNR(magic) = magic_FILE;
+	m->magic = magic_FILE;
 	/* Aligned to 2-byte boundary. */
-	m->_MNR(usa_ofs) = cpu_to_le16((sizeof(MFT_RECORD) + 1) & ~1);
-	m->_MNR(usa_count) = cpu_to_le16(size / NTFS_BLOCK_SIZE + 1);
+	m->usa_ofs = cpu_to_le16((sizeof(MFT_RECORD) + 1) & ~1);
+	m->usa_count = cpu_to_le16(size / NTFS_BLOCK_SIZE + 1);
 	/* Set the update sequence number to 1. */
 	*(u16*)((char*)m + ((sizeof(MFT_RECORD) + 1) & ~1)) = cpu_to_le16(1);
 	m->lsn = cpu_to_le64(0LL);
 	m->sequence_number = cpu_to_le16(1);
 	m->link_count = cpu_to_le16(0);
 	/* Aligned to 8-byte boundary. */
-	m->attrs_offset = cpu_to_le16((le16_to_cpu(m->_MNR(usa_ofs)) +
-			(le16_to_cpu(m->_MNR(usa_count)) << 1) + 7) & ~7);
+	m->attrs_offset = cpu_to_le16((le16_to_cpu(m->usa_ofs) +
+			(le16_to_cpu(m->usa_count) << 1) + 7) & ~7);
 	m->flags = cpu_to_le16(0);
 	/*
 	 * Using attrs_offset plus eight bytes (for the termination attribute),
@@ -329,7 +329,7 @@
 	 */
 	down(&base_ni->extent_lock);
 	if (base_ni->nr_extents > 0) {
-		extent_nis = base_ni->_INE(extent_ntfs_inos);
+		extent_nis = base_ni->ext.extent_ntfs_inos;
 		for (i = 0; i < base_ni->nr_extents; i++) {
 			if (mft_no != extent_nis[i]->mft_no)
 				continue;
@@ -374,7 +374,7 @@
 	ni->vol = base_ni->vol;
 	ni->seq_no = seq_no;
 	ni->nr_extents = -1;
-	ni->_INE(base_ntfs_ino) = base_ni;
+	ni->ext.base_ntfs_ino = base_ni;
 	/* Now map the record. */
 	m = map_mft_record(ni);
 	if (unlikely(IS_ERR(m))) {
@@ -404,14 +404,14 @@
 			m = ERR_PTR(-ENOMEM);
 			goto unm_err_out;
 		}
-		if (base_ni->_INE(extent_ntfs_inos)) {
-			memcpy(tmp, base_ni->_INE(extent_ntfs_inos), new_size -
+		if (base_ni->ext.extent_ntfs_inos) {
+			memcpy(tmp, base_ni->ext.extent_ntfs_inos, new_size -
 					4 * sizeof(ntfs_inode *));
-			kfree(base_ni->_INE(extent_ntfs_inos));
+			kfree(base_ni->ext.extent_ntfs_inos);
 		}
-		base_ni->_INE(extent_ntfs_inos) = tmp;
+		base_ni->ext.extent_ntfs_inos = tmp;
 	}
-	base_ni->_INE(extent_ntfs_inos)[base_ni->nr_extents++] = ni;
+	base_ni->ext.extent_ntfs_inos[base_ni->nr_extents++] = ni;
 	up(&base_ni->extent_lock);
 	atomic_dec(&base_ni->count);
 	ntfs_debug("Done 2.");
diff -Nru a/fs/ntfs/namei.c b/fs/ntfs/namei.c
--- a/fs/ntfs/namei.c	Wed Apr 30 22:28:14 2003
+++ b/fs/ntfs/namei.c	Wed Apr 30 22:28:14 2003
@@ -2,7 +2,7 @@
  * namei.c - NTFS kernel directory inode operations. Part of the Linux-NTFS
  * 	     project.
  *
- * Copyright (c) 2001,2002 Anton Altaparmakov.
+ * Copyright (c) 2001-2003 Anton Altaparmakov
  *
  * This program/include file is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
@@ -210,12 +210,12 @@
 			a = ctx->attr;
 			if (a->non_resident || a->flags)
 				goto eio_err_out;
-			val_len = le32_to_cpu(a->_ARA(value_length));
-			if (le16_to_cpu(a->_ARA(value_offset)) + val_len >
-					le32_to_cpu(a->length))
+			val_len = le32_to_cpu(a->data.resident.value_length);
+			if (le16_to_cpu(a->data.resident.value_offset) +
+					val_len > le32_to_cpu(a->length))
 				goto eio_err_out;
 			fn = (FILE_NAME_ATTR*)((u8*)ctx->attr + le16_to_cpu(
-					ctx->attr->_ARA(value_offset)));
+					ctx->attr->data.resident.value_offset));
 			if ((u32)(fn->file_name_length * sizeof(uchar_t) +
 					sizeof(FILE_NAME_ATTR)) > val_len)
 				goto eio_err_out;
diff -Nru a/fs/ntfs/super.c b/fs/ntfs/super.c
--- a/fs/ntfs/super.c	Wed Apr 30 22:28:12 2003
+++ b/fs/ntfs/super.c	Wed Apr 30 22:28:12 2003
@@ -1,8 +1,8 @@
 /*
  * super.c - NTFS kernel super block handling. Part of the Linux-NTFS project.
  *
- * Copyright (c) 2001,2002 Anton Altaparmakov.
- * Copyright (c) 2001,2002 Richard Russon.
+ * Copyright (c) 2001-2003 Anton Altaparmakov
+ * Copyright (c) 2001,2002 Richard Russon
  *
  * This program/include file is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
@@ -619,9 +619,8 @@
 	 * the same as it is much faster on 32-bit CPUs.
 	 */
 	ll = sle64_to_cpu(b->number_of_sectors) >> sectors_per_cluster_bits;
-	if ((u64)ll >= 1ULL << (sizeof(unsigned long) * 8)) {
-		ntfs_error(vol->sb, "Cannot handle %i-bit clusters. Sorry.",
-				sizeof(unsigned long) * 4);
+	if ((u64)ll >= 1ULL << 32) {
+		ntfs_error(vol->sb, "Cannot handle 64-bit clusters. Sorry.");
 		return FALSE;
 	}
 	vol->nr_clusters = ll;
@@ -884,10 +883,10 @@
 		goto iput_volume_failed;
 	}
 	vi = (VOLUME_INFORMATION*)((char*)ctx->attr +
-			le16_to_cpu(ctx->attr->_ARA(value_offset)));
+			le16_to_cpu(ctx->attr->data.resident.value_offset));
 	/* Some bounds checks. */
 	if ((u8*)vi < (u8*)ctx->attr || (u8*)vi +
-			le32_to_cpu(ctx->attr->_ARA(value_length)) >
+			le32_to_cpu(ctx->attr->data.resident.value_length) >
 			(u8*)ctx->attr + le32_to_cpu(ctx->attr->length))
 		goto err_put_vol;
 	/* Setup volume flags and version. */
@@ -1060,78 +1059,93 @@
  * get_nr_free_clusters - return the number of free clusters on a volume
  * @vol:	ntfs volume for which to obtain free cluster count
  *
- * Calculate the number of free clusters on the mounted NTFS volume @vol.
- *
- * Errors are ignored and we just return the number of free clusters we have
- * found. This means we return an underestimate on error.
+ * Calculate the number of free clusters on the mounted NTFS volume @vol. We
+ * actually calculate the number of clusters in use instead because this
+ * allows us to not care about partial pages as these will be just zero filled
+ * and hence not be counted as allocated clusters.
+ *
+ * The only particularity is that clusters beyond the end of the logical ntfs
+ * volume will be marked as allocated to prevent errors which means we have to
+ * discount those at the end. This is important as the cluster bitmap always
+ * has a size in multiples of 8 bytes, i.e. up to 63 clusters could be outside
+ * the logical volume and marked in use when they are not as they do not exist.
+ *
+ * If any pages cannot be read we assume all clusters in the erroring pages are
+ * in use. This means we return an underestimate on errors which is better than
+ * an overestimate.
  */
 static s64 get_nr_free_clusters(ntfs_volume *vol)
 {
+	s64 nr_free = vol->nr_clusters;
+	u32 *kaddr;
 	struct address_space *mapping = vol->lcnbmp_ino->i_mapping;
 	filler_t *readpage = (filler_t*)mapping->a_ops->readpage;
 	struct page *page;
 	unsigned long index, max_index;
-	unsigned int max_size, i;
-	s64 nr_free = 0LL;
-	u32 *b;
+	unsigned int max_size;
 
 	ntfs_debug("Entering.");
 	/* Serialize accesses to the cluster bitmap. */
 	down_read(&vol->lcnbmp_lock);
 	/*
 	 * Convert the number of bits into bytes rounded up, then convert into
-	 * multiples of PAGE_CACHE_SIZE.
+	 * multiples of PAGE_CACHE_SIZE, rounding up so that if we have one
+	 * full and one partial page max_index = 2.
 	 */
-	max_index = (vol->nr_clusters + 7) >> (3 + PAGE_CACHE_SHIFT);
+	max_index = (((vol->nr_clusters + 7) >> 3) + PAGE_CACHE_SIZE - 1) >>
+			PAGE_CACHE_SHIFT;
 	/* Use multiples of 4 bytes. */
 	max_size = PAGE_CACHE_SIZE >> 2;
-	ntfs_debug("Reading $BITMAP, max_index = 0x%lx, max_size = 0x%x.",
+	ntfs_debug("Reading $Bitmap, max_index = 0x%lx, max_size = 0x%x.",
 			max_index, max_size);
-	for (index = 0UL; index < max_index;) {
-handle_partial_page:
+	for (index = 0UL; index < max_index; index++) {
+		unsigned int i;
 		/*
 		 * Read the page from page cache, getting it from backing store
 		 * if necessary, and increment the use count.
 		 */
-		page = read_cache_page(mapping, index++, (filler_t*)readpage,
+		page = read_cache_page(mapping, index, (filler_t*)readpage,
 				NULL);
 		/* Ignore pages which errored synchronously. */
 		if (IS_ERR(page)) {
 			ntfs_debug("Sync read_cache_page() error. Skipping "
-					"page (index 0x%lx).", index - 1);
+					"page (index 0x%lx).", index);
+			nr_free -= PAGE_CACHE_SIZE * 8;
 			continue;
 		}
 		wait_on_page_locked(page);
+		/* Ignore pages which errored asynchronously. */
 		if (!PageUptodate(page)) {
 			ntfs_debug("Async read_cache_page() error. Skipping "
-					"page (index 0x%lx).", index - 1);
-			/* Ignore pages which errored asynchronously. */
+					"page (index 0x%lx).", index);
 			page_cache_release(page);
+			nr_free -= PAGE_CACHE_SIZE * 8;
 			continue;
 		}
-		b = (u32*)kmap(page);
-		/* For each 4 bytes, add up the number zero bits. */
-	  	for (i = 0; i < max_size; i++)
-			nr_free += (s64)(32 - hweight32(b[i]));
-		kunmap(page);
-		page_cache_release(page);
-	}
-	if (max_size == PAGE_CACHE_SIZE >> 2) {
+		kaddr = (u32*)kmap_atomic(page, KM_USER0);
 		/*
-		 * Get the multiples of 4 bytes in use in the final partial
-		 * page.
+		 * For each 4 bytes, subtract the number of set bits. If this
+		 * is the last page and it is partial we don't really care as
+		 * it just means we do a little extra work but it won't affect
+		 * the result as all out of range bytes are set to zero by
+		 * ntfs_readpage().
 		 */
-		max_size = ((((vol->nr_clusters + 7) >> 3) & ~PAGE_CACHE_MASK)
-				+ 3) >> 2;
-		/* If there is a partial page go back and do it. */
-		if (max_size) {
-			ntfs_debug("Handling partial page, max_size = 0x%x.",
-					max_size);
-			goto handle_partial_page;
-		}
+	  	for (i = 0; i < max_size; i++)
+			nr_free -= (s64)hweight32(kaddr[i]);
+		kunmap_atomic(kaddr, KM_USER0);
+		page_cache_release(page);
 	}
-	ntfs_debug("Finished reading $BITMAP, last index = 0x%lx", index - 1);
+	ntfs_debug("Finished reading $Bitmap, last index = 0x%lx.", index - 1);
+	/*
+	 * Fixup for eventual bits outside logical ntfs volume (see function
+	 * description above).
+	 */
+	if (vol->nr_clusters & 63)
+		nr_free += 64 - (vol->nr_clusters & 63);
 	up_read(&vol->lcnbmp_lock);
+	/* If errors occured we may well have gone below zero, fix this. */
+	if (nr_free < 0)
+		nr_free = 0;
 	ntfs_debug("Exiting.");
 	return nr_free;
 }
@@ -1141,64 +1155,81 @@
  * @vol:	ntfs volume for which to obtain free inode count
  *
  * Calculate the number of free mft records (inodes) on the mounted NTFS
- * volume @vol.
- *
- * Errors are ignored and we just return the number of free inodes we have
- * found. This means we return an underestimate on error.
+ * volume @vol. We actually calculate the number of mft records in use instead
+ * because this allows us to not care about partial pages as these will be just
+ * zero filled and hence not be counted as allocated mft record.
+ *
+ * If any pages cannot be read we assume all mft records in the erroring pages
+ * are in use. This means we return an underestimate on errors which is better
+ * than an overestimate.
  *
  * NOTE: Caller must hold mftbmp_lock rw_semaphore for reading or writing.
  */
 static unsigned long __get_nr_free_mft_records(ntfs_volume *vol)
 {
-	struct address_space *mapping;
+	s64 nr_free = vol->nr_mft_records;
+	u32 *kaddr;
+	struct address_space *mapping = vol->mftbmp_ino->i_mapping;
+	filler_t *readpage = (filler_t*)mapping->a_ops->readpage;
 	struct page *page;
-	unsigned long index, max_index, nr_free = 0;
-	unsigned int max_size, i;
-	u32 *b;
+	unsigned long index, max_index;
+	unsigned int max_size;
 
-	mapping = vol->mftbmp_ino->i_mapping;
+	ntfs_debug("Entering.");
 	/*
-	 * Convert the number of bits into bytes rounded up to a multiple of 8
-	 * bytes, then convert into multiples of PAGE_CACHE_SIZE.
+	 * Convert the number of bits into bytes rounded up, then convert into
+	 * multiples of PAGE_CACHE_SIZE, rounding up so that if we have one
+	 * full and one partial page max_index = 2.
 	 */
-	max_index = (((vol->nr_mft_records + 7) >> 3) + 7) >> PAGE_CACHE_SHIFT;
+	max_index = (((vol->nr_mft_records + 7) >> 3) + PAGE_CACHE_SIZE - 1) >>
+			PAGE_CACHE_SHIFT;
 	/* Use multiples of 4 bytes. */
 	max_size = PAGE_CACHE_SIZE >> 2;
 	ntfs_debug("Reading $MFT/$BITMAP, max_index = 0x%lx, max_size = "
 			"0x%x.", max_index, max_size);
-	for (index = 0UL; index < max_index;) {
-handle_partial_page:
-		page = ntfs_map_page(mapping, index++);
+	for (index = 0UL; index < max_index; index++) {
+		unsigned int i;
+		/*
+		 * Read the page from page cache, getting it from backing store
+		 * if necessary, and increment the use count.
+		 */
+		page = read_cache_page(mapping, index, (filler_t*)readpage,
+				NULL);
+		/* Ignore pages which errored synchronously. */
 		if (IS_ERR(page)) {
-			ntfs_debug("ntfs_map_page() error. Skipping page "
-					"(index 0x%lx).", index - 1);
+			ntfs_debug("Sync read_cache_page() error. Skipping "
+					"page (index 0x%lx).", index);
+			nr_free -= PAGE_CACHE_SIZE * 8;
 			continue;
 		}
-		b = (u32*)page_address(page);
-		/* For each 4 bytes, add up the number of zero bits. */
-		for (i = 0; i < max_size; i++)
-			nr_free += 32 - hweight32(b[i]);
-		ntfs_unmap_page(page);
-	}
-	if (index == max_index) {
+		wait_on_page_locked(page);
+		/* Ignore pages which errored asynchronously. */
+		if (!PageUptodate(page)) {
+			ntfs_debug("Async read_cache_page() error. Skipping "
+					"page (index 0x%lx).", index);
+			page_cache_release(page);
+			nr_free -= PAGE_CACHE_SIZE * 8;
+			continue;
+		}
+		kaddr = (u32*)kmap_atomic(page, KM_USER0);
 		/*
-		 * Get the multiples of 4 bytes in use in the final partial
-		 * page.
+		 * For each 4 bytes, subtract the number of set bits. If this
+		 * is the last page and it is partial we don't really care as
+		 * it just means we do a little extra work but it won't affect
+		 * the result as all out of range bytes are set to zero by
+		 * ntfs_readpage().
 		 */
-		max_size = ((((((vol->nr_mft_records + 7) >> 3) + 7) & ~7) &
-				~PAGE_CACHE_MASK) + 3) >> 2;
-		/* If there is a partial page go back and do it. */
-		if (max_size) {
-			/* Compensate for out of bounds zero bits. */
-			if ((i = vol->nr_mft_records & 31))
-				nr_free -= 32 - i;
-			ntfs_debug("Handling partial page, max_size = 0x%x",
-					max_size);
-			goto handle_partial_page;
-		}
+	  	for (i = 0; i < max_size; i++)
+			nr_free -= (s64)hweight32(kaddr[i]);
+		kunmap_atomic(kaddr, KM_USER0);
+		page_cache_release(page);
 	}
-	ntfs_debug("Finished reading $MFT/$BITMAP, last index = 0x%lx",
+	ntfs_debug("Finished reading $MFT/$BITMAP, last index = 0x%lx.",
 			index - 1);
+	/* If errors occured we may well have gone below zero, fix this. */
+	if (nr_free < 0)
+		nr_free = 0;
+	ntfs_debug("Exiting.");
 	return nr_free;
 }
 
@@ -1761,7 +1792,7 @@
 }
 
 MODULE_AUTHOR("Anton Altaparmakov <aia21@cantab.net>");
-MODULE_DESCRIPTION("NTFS 1.2/3.x driver - Copyright (c) 2001-2002 Anton Altaparmakov");
+MODULE_DESCRIPTION("NTFS 1.2/3.x driver - Copyright (c) 2001-2003 Anton Altaparmakov");
 MODULE_LICENSE("GPL");
 #ifdef DEBUG
 MODULE_PARM(debug_msgs, "i");
diff -Nru a/fs/ntfs/unistr.c b/fs/ntfs/unistr.c
--- a/fs/ntfs/unistr.c	Wed Apr 30 22:28:12 2003
+++ b/fs/ntfs/unistr.c	Wed Apr 30 22:28:12 2003
@@ -1,7 +1,7 @@
 /*
  * unistr.c - NTFS Unicode string handling. Part of the Linux-NTFS project.
  *
- * Copyright (c) 2001 Anton Altaparmakov.
+ * Copyright (c) 2001-2003 Anton Altaparmakov
  *
  * This program/include file is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
@@ -96,10 +96,12 @@
 		const int err_val, const IGNORE_CASE_BOOL ic,
 		const uchar_t *upcase, const u32 upcase_len)
 {
-	u32 cnt;
-	const u32 min_len = min_t(const u32, name1_len, name2_len);
+	u32 cnt, min_len;
 	uchar_t c1, c2;
 
+	min_len = name1_len;
+	if (name1_len > name2_len)
+		min_len = name2_len;
 	for (cnt = 0; cnt < min_len; ++cnt) {
 		c1 = le16_to_cpu(*name1++);
 		c2 = le16_to_cpu(*name2++);
diff -Nru a/fs/ntfs/upcase.c b/fs/ntfs/upcase.c
--- a/fs/ntfs/upcase.c	Wed Apr 30 22:28:03 2003
+++ b/fs/ntfs/upcase.c	Wed Apr 30 22:28:03 2003
@@ -2,8 +2,8 @@
  * upcase.c - Generate the full NTFS Unicode upcase table in little endian.
  *	      Part of the Linux-NTFS project.
  *
- * Copyright (C) 2001 Richard Russon <ntfs@flatcap.org>
- * Copyright (c) 2001,2002 Anton Altaparmakov
+ * Copyright (c) 2001 Richard Russon <ntfs@flatcap.org>
+ * Copyright (c) 2001-2003 Anton Altaparmakov
  *
  * Modified for mkntfs inclusion 9 June 2001 by Anton Altaparmakov.
  * Modified for kernel inclusion 10 September 2001 by Anton Altparmakov.
@@ -28,7 +28,7 @@
 
 uchar_t *generate_default_upcase(void)
 {
-	const int uc_run_table[][3] = { /* Start, End, Add */
+	static const int uc_run_table[][3] = { /* Start, End, Add */
 	{0x0061, 0x007B,  -32}, {0x0451, 0x045D, -80}, {0x1F70, 0x1F72,  74},
 	{0x00E0, 0x00F7,  -32}, {0x045E, 0x0460, -80}, {0x1F72, 0x1F76,  86},
 	{0x00F8, 0x00FF,  -32}, {0x0561, 0x0587, -48}, {0x1F76, 0x1F78, 100},
@@ -45,7 +45,7 @@
 	{0}
 	};
 
-	const int uc_dup_table[][2] = { /* Start, End */
+	static const int uc_dup_table[][2] = { /* Start, End */
 	{0x0100, 0x012F}, {0x01A0, 0x01A6}, {0x03E2, 0x03EF}, {0x04CB, 0x04CC},
 	{0x0132, 0x0137}, {0x01B3, 0x01B7}, {0x0460, 0x0481}, {0x04D0, 0x04EB},
 	{0x0139, 0x0149}, {0x01CD, 0x01DD}, {0x0490, 0x04BF}, {0x04EE, 0x04F5},
@@ -55,7 +55,7 @@
 	{0}
 	};
 
-	const int uc_word_table[][2] = { /* Offset, Value */
+	static const int uc_word_table[][2] = { /* Offset, Value */
 	{0x00FF, 0x0178}, {0x01AD, 0x01AC}, {0x01F3, 0x01F1}, {0x0269, 0x0196},
 	{0x0183, 0x0182}, {0x01B0, 0x01AF}, {0x0253, 0x0181}, {0x026F, 0x019C},
 	{0x0185, 0x0184}, {0x01B9, 0x01B8}, {0x0254, 0x0186}, {0x0272, 0x019D},
diff -Nru a/fs/partitions/Makefile b/fs/partitions/Makefile
--- a/fs/partitions/Makefile	Wed Apr 30 22:28:08 2003
+++ b/fs/partitions/Makefile	Wed Apr 30 22:28:08 2003
@@ -4,6 +4,7 @@
 
 obj-y := check.o
 
+obj-$(CONFIG_DEVFS_FS) += devfs.o
 obj-$(CONFIG_ACORN_PARTITION) += acorn.o
 obj-$(CONFIG_AMIGA_PARTITION) += amiga.o
 obj-$(CONFIG_ATARI_PARTITION) += atari.o
diff -Nru a/fs/partitions/check.c b/fs/partitions/check.c
--- a/fs/partitions/check.c	Wed Apr 30 22:28:17 2003
+++ b/fs/partitions/check.c	Wed Apr 30 22:28:17 2003
@@ -19,8 +19,10 @@
 #include <linux/blk.h>
 #include <linux/kmod.h>
 #include <linux/ctype.h>
+#include <linux/devfs_fs_kernel.h>
 
 #include "check.h"
+#include "devfs.h"
 
 #include "acorn.h"
 #include "amiga.h"
@@ -94,29 +96,35 @@
 
 char *disk_name(struct gendisk *hd, int part, char *buf)
 {
-	if (!part) {
 #ifdef CONFIG_DEVFS_FS
-		if (hd->devfs_name)
-			sprintf(buf, "%s/%s", hd->devfs_name,
-				(hd->flags & GENHD_FL_CD) ? "cd" : "disc");
+	if (hd->devfs_name[0] != '\0') {
+		if (part)
+			snprintf(buf, BDEVNAME_SIZE, "%s/part%d",
+					hd->devfs_name, part);
+		else if (hd->minors != 1)
+			snprintf(buf, BDEVNAME_SIZE, "%s/disc", hd->devfs_name);
 		else
-#endif
-			sprintf(buf, "%s", hd->disk_name);
-	} else {
-#ifdef CONFIG_DEVFS_FS
-		if (hd->devfs_name)
-			sprintf(buf, "%s/part%d", hd->devfs_name, part);
-		else
-#endif
-		if (isdigit(hd->disk_name[strlen(hd->disk_name)-1]))
-			sprintf(buf, "%sp%d", hd->disk_name, part);
-		else
-			sprintf(buf, "%s%d", hd->disk_name, part);
+			snprintf(buf, BDEVNAME_SIZE, "%s", hd->devfs_name);
+		return buf;
 	}
+#endif
+
+	if (!part)
+		snprintf(buf, BDEVNAME_SIZE, "%s", hd->disk_name);
+	else if (isdigit(hd->disk_name[strlen(hd->disk_name)-1]))
+		snprintf(buf, BDEVNAME_SIZE, "%sp%d", hd->disk_name, part);
+	else
+		snprintf(buf, BDEVNAME_SIZE, "%s%d", hd->disk_name, part);
 
 	return buf;
 }
 
+const char *bdevname(struct block_device *bdev, char *buf)
+{
+	int part = MINOR(bdev->bd_dev) - bdev->bd_disk->first_minor;
+	return disk_name(bdev->bd_disk, part, buf);
+}
+
 static struct parsed_partitions *
 check_partition(struct gendisk *hd, struct block_device *bdev)
 {
@@ -128,7 +136,7 @@
 		return NULL;
 
 #ifdef CONFIG_DEVFS_FS
-	if (hd->devfs_name) {
+	if (hd->devfs_name[0] != '\0') {
 		printk(KERN_INFO " /dev/%s:", hd->devfs_name);
 		sprintf(state->name, "p");
 	}
@@ -182,7 +190,7 @@
 static ssize_t part_dev_read(struct hd_struct * p, char *page)
 {
 	struct gendisk *disk = container_of(p->kobj.parent,struct gendisk,kobj);
-	int part = p - disk->part + 1;
+	int part = p->partno;
 	dev_t base = MKDEV(disk->major, disk->first_minor); 
 	return sprintf(page, "%04x\n", (unsigned)(base + part));
 }
@@ -234,7 +242,9 @@
 
 void delete_partition(struct gendisk *disk, int part)
 {
-	struct hd_struct *p = disk->part + part - 1;
+	struct hd_struct *p = disk->part[part-1];
+	if (!p)
+		return;
 	if (!p->nr_sects)
 		return;
 	p->start_sect = 0;
@@ -242,15 +252,28 @@
 	p->reads = p->writes = p->read_sectors = p->write_sectors = 0;
 	devfs_remove("%s/part%d", disk->devfs_name, part);
 	kobject_unregister(&p->kobj);
+	disk->part[part-1] = NULL;
+	kfree(p);
 }
 
 void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len)
 {
-	struct hd_struct *p = disk->part + part - 1;
+	struct hd_struct *p;
 
+	p = kmalloc(sizeof(*p), GFP_KERNEL);
+	if (!p)
+		return;
+	
+	memset(p, 0, sizeof(*p));
 	p->start_sect = start;
 	p->nr_sects = len;
-	devfs_register_partition(disk, part);
+	p->partno = part;
+	disk->part[part-1] = p;
+
+	devfs_mk_bdev(MKDEV(disk->major, disk->first_minor + part),
+			S_IFBLK|S_IRUSR|S_IWUSR,
+			"%s/part%d", disk->devfs_name, part);
+
 	snprintf(p->kobj.name,KOBJ_NAME_LEN,"%s%d",disk->kobj.name,part);
 	p->kobj.parent = &disk->kobj;
 	p->kobj.ktype = &ktype_part;
@@ -284,22 +307,22 @@
 		return;
 	disk_sysfs_symlinks(disk);
 
-	if (disk->flags & GENHD_FL_CD)
-		devfs_create_cdrom(disk);
-
 	/* No minors to use for partitions */
-	if (disk->minors == 1)
+	if (disk->minors == 1) {
+		if (disk->devfs_name[0] != '\0')
+			devfs_add_disk(disk);
 		return;
+	}
 
 	/* No such device (e.g., media were just removed) */
 	if (!get_capacity(disk))
 		return;
 
-	bdev = bdget(MKDEV(disk->major, disk->first_minor));
+	bdev = bdget_disk(disk, 0);
 	if (blkdev_get(bdev, FMODE_READ, 0, BDEV_RAW) < 0)
 		return;
 	state = check_partition(disk, bdev);
-	devfs_create_partitions(disk);
+	devfs_add_partitioned(disk);
 	if (state) {
 		for (j = 1; j < state->limit; j++) {
 			sector_t size = state->parts[j].size;
@@ -320,13 +343,12 @@
 
 int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
 {
-	kdev_t dev = to_kdev_t(bdev->bd_dev);
 	struct parsed_partitions *state;
 	int p, res;
 
 	if (bdev->bd_part_count)
 		return -EBUSY;
-	res = invalidate_device(dev, 1);
+	res = invalidate_partition(disk, 0);
 	if (res)
 		return res;
 	bdev->bd_invalidated = 0;
@@ -375,27 +397,22 @@
 
 void del_gendisk(struct gendisk *disk)
 {
-	int max_p = disk->minors;
-	kdev_t devp;
 	int p;
 
 	/* invalidate stuff */
-	for (p = max_p - 1; p > 0; p--) {
-		devp = mk_kdev(disk->major,disk->first_minor + p);
-		invalidate_device(devp, 1);
+	for (p = disk->minors - 1; p > 0; p--) {
+		invalidate_partition(disk, p);
 		delete_partition(disk, p);
 	}
-	devp = mk_kdev(disk->major,disk->first_minor);
-	invalidate_device(devp, 1);
+	invalidate_partition(disk, 0);
 	disk->capacity = 0;
 	disk->flags &= ~GENHD_FL_UP;
 	unlink_gendisk(disk);
 	disk_stat_set_all(disk, 0);
 	disk->stamp = disk->stamp_idle = 0;
-	if (disk->flags & GENHD_FL_CD)
-		devfs_remove_cdrom(disk);
-	else
-		devfs_remove_partitions(disk);
+
+	devfs_remove_disk(disk);
+
 	if (disk->driverfs_dev) {
 		sysfs_remove_link(&disk->kobj, "device");
 		sysfs_remove_link(&disk->driverfs_dev->kobj, "block");
@@ -407,7 +424,7 @@
 struct dev_name {
 	struct list_head list;
 	dev_t dev;
-	char namebuf[64];
+	char namebuf[BDEVNAME_SIZE];
 	char *name;
 };
 
diff -Nru a/fs/partitions/check.h b/fs/partitions/check.h
--- a/fs/partitions/check.h	Wed Apr 30 22:28:08 2003
+++ b/fs/partitions/check.h	Wed Apr 30 22:28:08 2003
@@ -8,7 +8,7 @@
 enum { MAX_PART = 256 };
 
 struct parsed_partitions {
-	char name[40];
+	char name[BDEVNAME_SIZE];
 	struct {
 		sector_t from;
 		sector_t size;
@@ -29,3 +29,8 @@
 }
 
 extern int warn_no_part;
+
+extern void parse_bsd(struct parsed_partitions *state,
+			struct block_device *bdev, u32 offset, u32 size,
+			int origin, char *flavour, int max_partitions);
+
diff -Nru a/fs/partitions/devfs.c b/fs/partitions/devfs.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/fs/partitions/devfs.c	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,130 @@
+/*
+ * This tries to keep block devices away from devfs as much as possible.
+ */
+#include <linux/fs.h>
+#include <linux/devfs_fs_kernel.h>
+#include <linux/vmalloc.h>
+#include <linux/genhd.h>
+#include <asm/bitops.h>
+#include <asm/semaphore.h>
+
+
+struct unique_numspace {
+	u32		  num_free;          /*  Num free in bits       */
+	u32		  length;            /*  Array length in bytes  */
+	unsigned long	  *bits;
+	struct semaphore  mutex;
+};
+
+static DECLARE_MUTEX(numspace_mutex);
+
+static int expand_numspace(struct unique_numspace *s)
+{
+	u32 length;
+	void *bits;
+
+	if (s->length < 16)
+		length = 16;
+	else
+		length = s->length << 1;
+
+	bits = vmalloc(length);
+	if (!bits)
+		return -ENOMEM;
+	if (s->bits) {
+		memcpy(bits, s->bits, s->length);
+		vfree(s->bits);
+	}
+		
+	s->num_free = (length - s->length) << 3;
+	s->bits = bits;
+	memset(bits + s->length, 0, length - s->length);
+	s->length = length;
+
+	return 0;
+}
+
+static int alloc_unique_number(struct unique_numspace *s)
+{
+	int rval = 0;
+
+	down(&numspace_mutex);
+	if (s->num_free < 1)
+		rval = expand_numspace(s);
+	if (!rval) {
+		rval = find_first_zero_bit(s->bits, s->length << 3);
+		--s->num_free;
+		__set_bit(rval, s->bits);
+	}
+	up(&numspace_mutex);
+
+	return rval;
+}
+
+static void dealloc_unique_number(struct unique_numspace *s, int number)
+{
+	int old_val;
+
+	if (number >= 0) {
+		down(&numspace_mutex);
+		old_val = __test_and_clear_bit(number, s->bits);
+		if (old_val)
+			++s->num_free;
+		up(&numspace_mutex);
+	}
+}
+
+static struct unique_numspace disc_numspace;
+static struct unique_numspace cdrom_numspace;
+
+void devfs_add_partitioned(struct gendisk *disk)
+{
+	char dirname[64], symlink[16];
+
+	devfs_mk_dir(disk->devfs_name);
+	devfs_mk_bdev(MKDEV(disk->major, disk->first_minor),
+			S_IFBLK|S_IRUSR|S_IWUSR,
+			"%s/disc", disk->devfs_name);
+
+	disk->number = alloc_unique_number(&disc_numspace);
+
+	sprintf(symlink, "discs/disc%d", disk->number);
+	sprintf(dirname, "../%s", disk->devfs_name);
+	devfs_mk_symlink(symlink, dirname);
+
+}
+
+void devfs_add_disk(struct gendisk *disk)
+{
+	devfs_mk_bdev(MKDEV(disk->major, disk->first_minor),
+			(disk->flags & GENHD_FL_CD) ?
+				S_IFBLK|S_IRUGO|S_IWUGO :
+				S_IFBLK|S_IRUSR|S_IWUSR,
+			"%s", disk->devfs_name);
+
+	if (disk->flags & GENHD_FL_CD) {
+		char dirname[64], symlink[16];
+
+		disk->number = alloc_unique_number(&cdrom_numspace);
+
+		sprintf(symlink, "cdroms/cdrom%d", disk->number);
+		sprintf(dirname, "../%s", disk->devfs_name);
+		devfs_mk_symlink(symlink, dirname);
+	}
+}
+
+void devfs_remove_disk(struct gendisk *disk)
+{
+	if (disk->minors != 1) {
+		devfs_remove("discs/disc%d", disk->number);
+		dealloc_unique_number(&disc_numspace, disk->number);
+		devfs_remove("%s/disc", disk->devfs_name);
+	}
+	if (disk->flags & GENHD_FL_CD) {
+		devfs_remove("cdroms/cdrom%d", disk->number);
+		dealloc_unique_number(&cdrom_numspace, disk->number);
+	}
+	devfs_remove(disk->devfs_name);
+}
+
+
diff -Nru a/fs/partitions/devfs.h b/fs/partitions/devfs.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/fs/partitions/devfs.h	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,10 @@
+
+#ifdef CONFIG_DEVFS_FS
+void devfs_add_disk(struct gendisk *dev);
+void devfs_add_partitioned(struct gendisk *dev);
+void devfs_remove_disk(struct gendisk *dev);
+#else
+# define devfs_add_disk(disk)			do { } while (0)
+# define devfs_add_partitioned(disk)		do { } while (0)
+# define devfs_remove_disk(disk)		do { } while (0)
+#endif
diff -Nru a/fs/partitions/mac.c b/fs/partitions/mac.c
--- a/fs/partitions/mac.c	Wed Apr 30 22:28:05 2003
+++ b/fs/partitions/mac.c	Wed Apr 30 22:28:05 2003
@@ -12,7 +12,7 @@
 #include "mac.h"
 
 #ifdef CONFIG_ALL_PPC
-extern void note_bootable_part(kdev_t dev, int part, int goodness);
+extern void note_bootable_part(dev_t dev, int part, int goodness);
 #endif
 
 /*
@@ -121,8 +121,7 @@
 	}
 #ifdef CONFIG_ALL_PPC
 	if (found_root_goodness)
-		note_bootable_part(to_kdev_t(bdev->bd_dev),
-					found_root, found_root_goodness);
+		note_bootable_part(bdev->bd_dev, found_root, found_root_goodness);
 #endif
 
 	put_dev_sector(sect);
diff -Nru a/fs/partitions/msdos.c b/fs/partitions/msdos.c
--- a/fs/partitions/msdos.c	Wed Apr 30 22:28:11 2003
+++ b/fs/partitions/msdos.c	Wed Apr 30 22:28:11 2003
@@ -214,12 +214,12 @@
 #endif
 }
 
-#ifdef CONFIG_BSD_DISKLABEL
+#if defined(CONFIG_BSD_DISKLABEL) || defined(CONFIG_NEC98_PARTITION)
 /* 
  * Create devices for BSD partitions listed in a disklabel, under a
  * dos-like partition. See parse_extended() for more information.
  */
-static void
+void
 parse_bsd(struct parsed_partitions *state, struct block_device *bdev,
 		u32 offset, u32 size, int origin, char *flavour,
 		int max_partitions)
diff -Nru a/fs/partitions/nec98.c b/fs/partitions/nec98.c
--- a/fs/partitions/nec98.c	Wed Apr 30 22:28:04 2003
+++ b/fs/partitions/nec98.c	Wed Apr 30 22:28:04 2003
@@ -66,13 +66,6 @@
 	return valid;
 }
 
-#ifdef CONFIG_BSD_DISKLABEL
-extern void parse_bsd(struct parsed_partitions *state,
-			struct block_device *bdev,
-			u32 offset, u32 size, int origin, char *flavour,
-			int max_partitions);
-#endif
-
 int nec98_partition(struct parsed_partitions *state, struct block_device *bdev)
 {
 	unsigned int nr;
diff -Nru a/fs/proc/array.c b/fs/proc/array.c
--- a/fs/proc/array.c	Wed Apr 30 22:28:10 2003
+++ b/fs/proc/array.c	Wed Apr 30 22:28:10 2003
@@ -303,7 +303,7 @@
 		atomic_inc(&mm->mm_users);
 	if (task->tty) {
 		tty_pgrp = task->tty->pgrp;
-		tty_nr = kdev_t_to_nr(task->tty->device);
+		tty_nr = task->tty->device;
 	}
 	task_unlock(task);
 	if (mm) {
diff -Nru a/fs/proc/generic.c b/fs/proc/generic.c
--- a/fs/proc/generic.c	Wed Apr 30 22:28:19 2003
+++ b/fs/proc/generic.c	Wed Apr 30 22:28:19 2003
@@ -136,11 +136,11 @@
 				       "proc_file_read: Apparent buffer overflow!\n");
 				n = PAGE_SIZE;
 			}
-			if (n > count)
-				n = count;
 			n -= *ppos;
 			if (n <= 0)
 				break;
+			if (n > count)
+				n = count;
 			start = page + *ppos;
 		} else if (start < page) {
 			if (n > PAGE_SIZE) {
diff -Nru a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
--- a/fs/proc/proc_misc.c	Wed Apr 30 22:28:05 2003
+++ b/fs/proc/proc_misc.c	Wed Apr 30 22:28:05 2003
@@ -333,6 +333,18 @@
 	.release	= seq_release,
 };
 
+extern struct seq_operations diskstats_op;
+static int diskstats_open(struct inode *inode, struct file *file)
+{
+	return seq_open(file, &diskstats_op);
+}
+static struct file_operations proc_diskstats_operations = {
+	.open		= diskstats_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= seq_release,
+};
+
 #ifdef CONFIG_MODULES
 extern struct seq_operations modules_op;
 static int modules_open(struct inode *inode, struct file *file)
@@ -644,6 +656,7 @@
 	create_seq_entry("slabinfo",S_IWUSR|S_IRUGO,&proc_slabinfo_operations);
 	create_seq_entry("buddyinfo",S_IRUGO, &fragmentation_file_operations);
 	create_seq_entry("vmstat",S_IRUGO, &proc_vmstat_file_operations);
+	create_seq_entry("diskstats", 0, &proc_diskstats_operations);
 #ifdef CONFIG_MODULES
 	create_seq_entry("modules", 0, &proc_modules_operations);
 #endif
diff -Nru a/fs/proc/proc_tty.c b/fs/proc/proc_tty.c
--- a/fs/proc/proc_tty.c	Wed Apr 30 22:28:08 2003
+++ b/fs/proc/proc_tty.c	Wed Apr 30 22:28:08 2003
@@ -12,13 +12,12 @@
 #include <linux/proc_fs.h>
 #include <linux/stat.h>
 #include <linux/tty.h>
+#include <linux/seq_file.h>
 #include <asm/bitops.h>
 
 extern struct tty_ldisc ldiscs[];
 
 
-static int tty_drivers_read_proc(char *page, char **start, off_t off,
-				 int count, int *eof, void *data);
 static int tty_ldiscs_read_proc(char *page, char **start, off_t off,
 				int count, int *eof, void *data);
 
@@ -30,72 +29,129 @@
 /*
  * This is the handler for /proc/tty/drivers
  */
-static int tty_drivers_read_proc(char *page, char **start, off_t off,
-				 int count, int *eof, void *data)
+static void show_tty_range(struct seq_file *m, struct tty_driver *p,
+	dev_t from, int num)
 {
-	int	len = 0;
-	off_t	begin = 0;
-	struct tty_driver *p;
-	char	range[20], deftype[20];
-	char	*type;
-
-	list_for_each_entry(p, &tty_drivers, tty_drivers) {
-		if (p->num > 1)
-			sprintf(range, "%d-%d", p->minor_start,
-				p->minor_start + p->num - 1);
+	seq_printf(m, "%-20s ", p->driver_name ? p->driver_name : "unknown");
+	seq_printf(m, "/dev/%-8s ", p->name);
+	if (p->num > 1) {
+		char	range[20];
+		sprintf(range, "%d-%d", MINOR(from),
+			MINOR(from) + num - 1);
+		seq_printf(m, "%3d %7s ", MAJOR(from), range);
+	} else {
+		seq_printf(m, "%3d %7d ", MAJOR(from), MINOR(from));
+	}
+	switch (p->type) {
+	case TTY_DRIVER_TYPE_SYSTEM:
+		seq_printf(m, "system");
+		if (p->subtype == SYSTEM_TYPE_TTY)
+			seq_printf(m, ":/dev/tty");
+		else if (p->subtype == SYSTEM_TYPE_SYSCONS)
+			seq_printf(m, ":console");
+		else if (p->subtype == SYSTEM_TYPE_CONSOLE)
+			seq_printf(m, ":vtmaster");
+		break;
+	case TTY_DRIVER_TYPE_CONSOLE:
+		seq_printf(m, "console");
+		break;
+	case TTY_DRIVER_TYPE_SERIAL:
+		seq_printf(m, "serial");
+		if (p->subtype == 2)
+			seq_printf(m, ":callout");
+		break;
+	case TTY_DRIVER_TYPE_PTY:
+		if (p->subtype == PTY_TYPE_MASTER)
+			seq_printf(m, "pty:master");
+		else if (p->subtype == PTY_TYPE_SLAVE)
+			seq_printf(m, "pty:slave");
 		else
-			sprintf(range, "%d", p->minor_start);
-		switch (p->type) {
-		case TTY_DRIVER_TYPE_SYSTEM:
-			if (p->subtype == SYSTEM_TYPE_TTY)
-				type = "system:/dev/tty";
-			else if (p->subtype == SYSTEM_TYPE_SYSCONS)
-				type = "system:console";
-			else if (p->subtype == SYSTEM_TYPE_CONSOLE)
-				type = "system:vtmaster";
-			else
-				type = "system";
-			break;
-		case TTY_DRIVER_TYPE_CONSOLE:
-			type = "console";
-			break;
-		case TTY_DRIVER_TYPE_SERIAL:
-			if (p->subtype == 2)
-				type = "serial:callout";
-			else
-				type = "serial";
-			break;
-		case TTY_DRIVER_TYPE_PTY:
-			if (p->subtype == PTY_TYPE_MASTER)
-				type = "pty:master";
-			else if (p->subtype == PTY_TYPE_SLAVE)
-				type = "pty:slave";
-			else
-				type = "pty";
-			break;
-		default:
-			sprintf(deftype, "type:%d.%d", p->type, p->subtype);
-			type = deftype;
-			break;
-		}
-		len += sprintf(page+len, "%-20s /dev/%-8s %3d %7s %s\n",
-			       p->driver_name ? p->driver_name : "unknown",
-			       p->name, p->major, range, type);
-		if (len+begin > off+count)
-			break;
-		if (len+begin < off) {
-			begin += len;
-			len = 0;
-		}
+			seq_printf(m, "pty");
+		break;
+	default:
+		seq_printf(m, "type:%d.%d", p->type, p->subtype);
 	}
-	if (!p)
-		*eof = 1;
-	if (off >= len+begin)
-		return 0;
-	*start = page + (off-begin);
-	return ((count < begin+len-off) ? count : begin+len-off);
+	seq_putc(m, '\n');
 }
 
+static int show_tty_driver(struct seq_file *m, void *v)
+{
+	struct tty_driver *p = v;
+	dev_t from = MKDEV(p->major, p->minor_start);
+	dev_t to = from + p->num;
+
+	if (&p->tty_drivers == tty_drivers.next) {
+		/* pseudo-drivers first */
+		seq_printf(m, "%-20s /dev/%-8s ", "/dev/tty", "tty");
+		seq_printf(m, "%3d %7d ", TTYAUX_MAJOR, 0);
+		seq_printf(m, "system:/dev/tty\n");
+		seq_printf(m, "%-20s /dev/%-8s ", "/dev/console", "console");
+		seq_printf(m, "%3d %7d ", TTYAUX_MAJOR, 1);
+		seq_printf(m, "system:console\n");
+#ifdef CONFIG_UNIX98_PTYS
+		seq_printf(m, "%-20s /dev/%-8s ", "/dev/ptmx", "ptmx");
+		seq_printf(m, "%3d %7d ", TTYAUX_MAJOR, 2);
+		seq_printf(m, "system\n");
+#endif
+#ifdef CONFIG_VT
+		seq_printf(m, "%-20s /dev/%-8s ", "/dev/vc/0", "vc/0");
+		seq_printf(m, "%3d %7d ", TTY_MAJOR, 0);
+		seq_printf(m, "system:vtmaster\n");
+#endif
+	}
+
+	while (MAJOR(from) < MAJOR(to)) {
+		dev_t next = MKDEV(MAJOR(from)+1, 0);
+		show_tty_range(m, p, from, next - from);
+		from = next;
+	}
+	if (from != to)
+		show_tty_range(m, p, from, to - from);
+	return 0;
+}
+
+/* iterator */
+static void *t_start(struct seq_file *m, loff_t *pos)
+{
+	struct list_head *p;
+	loff_t l = *pos;
+	list_for_each(p, &tty_drivers)
+		if (!l--)
+			return list_entry(p, struct tty_driver, tty_drivers);
+	return NULL;
+}
+
+static void *t_next(struct seq_file *m, void *v, loff_t *pos)
+{
+	struct list_head *p = ((struct tty_driver *)v)->tty_drivers.next;
+	(*pos)++;
+	return p==&tty_drivers ? NULL :
+			list_entry(p, struct tty_driver, tty_drivers);
+}
+
+static void t_stop(struct seq_file *m, void *v)
+{
+}
+
+static struct seq_operations tty_drivers_op = {
+	.start	= t_start,
+	.next	= t_next,
+	.stop	= t_stop,
+	.show	= show_tty_driver
+};
+
+static int tty_drivers_open(struct inode *inode, struct file *file)
+{
+	return seq_open(file, &tty_drivers_op);
+}
+
+static struct file_operations proc_tty_drivers_operations = {
+	.open		= tty_drivers_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= seq_release,
+};
+
 /*
  * This is the handler for /proc/tty/ldiscs
  */
@@ -170,11 +226,14 @@
  */
 void __init proc_tty_init(void)
 {
+	struct proc_dir_entry *entry;
 	if (!proc_mkdir("tty", 0))
 		return;
 	proc_tty_ldisc = proc_mkdir("tty/ldisc", 0);
 	proc_tty_driver = proc_mkdir("tty/driver", 0);
 
 	create_proc_read_entry("tty/ldiscs", 0, 0, tty_ldiscs_read_proc,NULL);
-	create_proc_read_entry("tty/drivers", 0, 0, tty_drivers_read_proc,NULL);
+	entry = create_proc_entry("tty/drivers", 0, NULL);
+	if (entry)
+		entry->proc_fops = &proc_tty_drivers_operations;
 }
diff -Nru a/fs/quota.c b/fs/quota.c
--- a/fs/quota.c	Wed Apr 30 22:28:18 2003
+++ b/fs/quota.c	Wed Apr 30 22:28:18 2003
@@ -19,8 +19,10 @@
 {
 	if (type >= MAXQUOTAS)
 		return -EINVAL;
+	if (!sb && cmd != Q_SYNC)
+		return -ENODEV;
 	/* Is operation supported? */
-	if (!sb->s_qcop)
+	if (sb && !sb->s_qcop)
 		return -ENOSYS;
 
 	switch (cmd) {
@@ -51,7 +53,7 @@
 				return -ENOSYS;
 			break;
 		case Q_SYNC:
-			if (!sb->s_qcop->quota_sync)
+			if (sb && !sb->s_qcop->quota_sync)
 				return -ENOSYS;
 			break;
 		case Q_XQUOTAON:
@@ -102,6 +104,50 @@
 	return security_quotactl (cmd, type, id, sb);
 }
 
+static struct super_block *get_super_to_sync(int type)
+{
+	struct list_head *head;
+	int cnt, dirty;
+
+restart:
+	spin_lock(&sb_lock);
+	list_for_each(head, &super_blocks) {
+		struct super_block *sb = list_entry(head, struct super_block, s_list);
+
+		for (cnt = 0, dirty = 0; cnt < MAXQUOTAS; cnt++)
+			if ((type == cnt || type == -1) && sb_has_quota_enabled(sb, cnt)
+			    && info_any_dquot_dirty(&sb_dqopt(sb)->info[cnt]))
+				dirty = 1;
+		if (!dirty)
+			continue;
+		sb->s_count++;
+		spin_unlock(&sb_lock);
+		down_read(&sb->s_umount);
+		if (!sb->s_root) {
+			drop_super(sb);
+			goto restart;
+		}
+		return sb;
+	}
+	spin_unlock(&sb_lock);
+	return NULL;
+}
+
+void sync_dquots(struct super_block *sb, int type)
+{
+	if (sb) {
+		if (sb->s_qcop->quota_sync)
+			sb->s_qcop->quota_sync(sb, type);
+	}
+	else {
+		while ((sb = get_super_to_sync(type))) {
+			if (sb->s_qcop->quota_sync)
+				sb->s_qcop->quota_sync(sb, type);
+			drop_super(sb);
+		}
+	}
+}
+
 /* Copy parameters and call proper function */
 static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, caddr_t addr)
 {
@@ -167,7 +213,8 @@
 			return sb->s_qcop->set_dqblk(sb, type, id, &idq);
 		}
 		case Q_SYNC:
-			return sb->s_qcop->quota_sync(sb, type);
+			sync_dquots(sb, type);
+			return 0;
 
 		case Q_XQUOTAON:
 		case Q_XQUOTAOFF:
@@ -222,27 +269,30 @@
 	struct super_block *sb = NULL;
 	struct block_device *bdev;
 	char *tmp;
-	int ret = -ENODEV;
+	int ret;
 
 	cmds = cmd >> SUBCMDSHIFT;
 	type = cmd & SUBCMDMASK;
 
-	tmp = getname(special);
-	if (IS_ERR(tmp))
-		return PTR_ERR(tmp);
-	bdev = lookup_bdev(tmp);
-	putname(tmp);
-	if (IS_ERR(bdev))
-		return PTR_ERR(bdev);
-	sb = get_super(bdev);
-	bdput(bdev);
+	if (cmds != Q_SYNC || special) {
+		tmp = getname(special);
+		if (IS_ERR(tmp))
+			return PTR_ERR(tmp);
+		bdev = lookup_bdev(tmp);
+		putname(tmp);
+		if (IS_ERR(bdev))
+			return PTR_ERR(bdev);
+		sb = get_super(bdev);
+		bdput(bdev);
+		if (!sb)
+			return -ENODEV;
+	}
 
-	if (sb) {
-		ret = check_quotactl_valid(sb, type, cmds, id);
-		if (ret >= 0)
-			ret = do_quotactl(sb, type, cmds, id, addr);
+	ret = check_quotactl_valid(sb, type, cmds, id);
+	if (ret >= 0)
+		ret = do_quotactl(sb, type, cmds, id, addr);
+	if (sb)
 		drop_super(sb);
-	}
 
 	return ret;
 }
diff -Nru a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
--- a/fs/reiserfs/inode.c	Wed Apr 30 22:28:07 2003
+++ b/fs/reiserfs/inode.c	Wed Apr 30 22:28:07 2003
@@ -1260,7 +1260,6 @@
 	    iput(inode);
 	    return ERR_PTR(-ENOMEM);
     }
-    result->d_vfs_flags |= DCACHE_REFERENCED;
     return result;
 }
 
diff -Nru a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
--- a/fs/reiserfs/journal.c	Wed Apr 30 22:28:11 2003
+++ b/fs/reiserfs/journal.c	Wed Apr 30 22:28:11 2003
@@ -1911,21 +1911,16 @@
 
 	/* there is no "jdev" option and journal is on separate device */
 	if( ( !jdev_name || !jdev_name[ 0 ] ) ) {
-		journal -> j_dev_bd = bdget(jdev);
-		if( journal -> j_dev_bd )
-			result = blkdev_get( journal -> j_dev_bd, 
-					     blkdev_mode, 0, 
-					     BDEV_FS );
-		else
-			result = -ENOMEM;
-		if( result != 0 )
+		journal->j_dev_bd = open_by_devnum(jdev, blkdev_mode, BDEV_FS);
+		if (IS_ERR(journal->j_dev_bd)) {
+			result = PTR_ERR(journal->j_dev_bd);
+			journal->j_dev_bd = NULL;
 			printk( "sh-458: journal_init_dev: cannot init journal device\n '%s': %i", 
-				bdevname(journal->j_dev_bd, b), result );
-
-		else if (jdev != super->s_dev) {
+				__bdevname(jdev, b), result );
+			return result;
+		} else if (jdev != super->s_dev)
 			set_blocksize(journal->j_dev_bd, super->s_blocksize);
-		}
-		return result;
+		return 0;
 	}
 
 	journal -> j_dev_file = filp_open( jdev_name, 0, 0 );
diff -Nru a/fs/smbfs/proc.c b/fs/smbfs/proc.c
--- a/fs/smbfs/proc.c	Wed Apr 30 22:28:05 2003
+++ b/fs/smbfs/proc.c	Wed Apr 30 22:28:05 2003
@@ -2085,7 +2085,6 @@
 void smb_decode_unix_basic(struct smb_fattr *fattr, char *p)
 {
 	/* FIXME: verify nls support. all is sent as utf8? */
-	__u64 devmajor, devminor;
 
 	fattr->f_unix = 1;
 	fattr->f_mode = 0;
@@ -2112,9 +2111,10 @@
 	fattr->f_mode |= smb_filetype_to_mode(WVAL(p, 56));
 
 	if (S_ISBLK(fattr->f_mode) || S_ISCHR(fattr->f_mode)) {
-		devmajor = LVAL(p, 60);
-		devminor = LVAL(p, 68);
-		fattr->f_rdev = ((devmajor & 0xFF) << 8) | (devminor & 0xFF);
+		__u64 major = LVAL(p, 60);
+		__u64 minor = LVAL(p, 68);
+
+		fattr->f_rdev = MKDEV(major & 0xffffffff, minor & 0xffffffff);
 	}
 	fattr->f_mode |= LVAL(p, 84);
 }
@@ -3008,7 +3008,7 @@
  */
 int
 smb_proc_setattr_unix(struct dentry *d, struct iattr *attr,
-		      int major, int minor)
+		      unsigned int major, unsigned int minor)
 {
 	struct smb_sb_info *server = server_from_dentry(d);
 	u64 nttime;
diff -Nru a/fs/smbfs/proto.h b/fs/smbfs/proto.h
--- a/fs/smbfs/proto.h	Wed Apr 30 22:28:11 2003
+++ b/fs/smbfs/proto.h	Wed Apr 30 22:28:11 2003
@@ -27,7 +27,7 @@
 extern void smb_decode_unix_basic(struct smb_fattr *fattr, char *p);
 extern int smb_proc_getattr(struct dentry *dir, struct smb_fattr *fattr);
 extern int smb_proc_setattr(struct dentry *dir, struct smb_fattr *fattr);
-extern int smb_proc_setattr_unix(struct dentry *d, struct iattr *attr, int major, int minor);
+extern int smb_proc_setattr_unix(struct dentry *d, struct iattr *attr, unsigned int major, unsigned int minor);
 extern int smb_proc_settime(struct dentry *dentry, struct smb_fattr *fattr);
 extern int smb_proc_dskattr(struct super_block *sb, struct statfs *attr);
 extern int smb_proc_read_link(struct smb_sb_info *server, struct dentry *d, char *buffer, int len);
diff -Nru a/fs/xfs/linux/xfs_super.c b/fs/xfs/linux/xfs_super.c
--- a/fs/xfs/linux/xfs_super.c	Wed Apr 30 22:28:17 2003
+++ b/fs/xfs/linux/xfs_super.c	Wed Apr 30 22:28:17 2003
@@ -741,7 +741,6 @@
 		iput(inode);
 		return ERR_PTR(-ENOMEM);
 	}
-	result->d_vfs_flags |= DCACHE_REFERENCED;
 	return result;
 }
 
diff -Nru a/fs/xfs/pagebuf/page_buf.c b/fs/xfs/pagebuf/page_buf.c
--- a/fs/xfs/pagebuf/page_buf.c	Wed Apr 30 22:28:03 2003
+++ b/fs/xfs/pagebuf/page_buf.c	Wed Apr 30 22:28:03 2003
@@ -554,7 +554,8 @@
 		} else if (flags & PBF_MAPPED) {
 			if (as_list_len > 64)
 				purge_addresses();
-			pb->pb_addr = vmap(pb->pb_pages, page_count);
+			pb->pb_addr = vmap(pb->pb_pages, page_count,
+					VM_MAP, PAGE_KERNEL);
 			if (pb->pb_addr == NULL)
 				return -ENOMEM;
 			pb->pb_addr += pb->pb_offset;
diff -Nru a/include/acpi/acconfig.h b/include/acpi/acconfig.h
--- a/include/acpi/acconfig.h	Wed Apr 30 22:28:14 2003
+++ b/include/acpi/acconfig.h	Wed Apr 30 22:28:14 2003
@@ -47,7 +47,7 @@
 
 /******************************************************************************
  *
- * Compile-time options
+ * Configuration options
  *
  *****************************************************************************/
 
@@ -62,21 +62,9 @@
  *
  */
 
-
-/******************************************************************************
- *
- * Subsystem Constants
- *
- *****************************************************************************/
-
-
 /* Version string */
 
-#define ACPI_CA_VERSION                 0x20030328
-
-/* Version of ACPI supported */
-
-#define ACPI_CA_SUPPORT_LEVEL           2
+#define ACPI_CA_VERSION                 0x20030418
 
 /* Maximum objects in the various object caches */
 
@@ -86,6 +74,23 @@
 #define ACPI_MAX_OBJECT_CACHE_DEPTH     64          /* Interpreter operand objects */
 #define ACPI_MAX_WALK_CACHE_DEPTH       4           /* Objects for parse tree walks */
 
+/*
+ * Should the subystem abort the loading of an ACPI table if the
+ * table checksum is incorrect?
+ */
+#define ACPI_CHECKSUM_ABORT             FALSE
+
+
+/******************************************************************************
+ *
+ * Subsystem Constants
+ *
+ *****************************************************************************/
+
+/* Version of ACPI supported */
+
+#define ACPI_CA_SUPPORT_LEVEL           2
+
 /* String size constants */
 
 #define ACPI_MAX_STRING_LENGTH          512
@@ -106,20 +111,6 @@
 
 /******************************************************************************
  *
- * Configuration of subsystem behavior
- *
- *****************************************************************************/
-
-
-/*
- * Should the subystem abort the loading of an ACPI table if the
- * table checksum is incorrect?
- */
-#define ACPI_CHECKSUM_ABORT             FALSE
-
-
-/******************************************************************************
- *
  * ACPI Specification constants (Do not change unless the specification changes)
  *
  *****************************************************************************/
@@ -195,7 +186,6 @@
  * ACPI AML Debugger
  *
  *****************************************************************************/
-
 
 #define ACPI_DEBUGGER_MAX_ARGS          8  /* Must be max method args + 1 */
 
diff -Nru a/include/acpi/acinterp.h b/include/acpi/acinterp.h
--- a/include/acpi/acinterp.h	Wed Apr 30 22:28:16 2003
+++ b/include/acpi/acinterp.h	Wed Apr 30 22:28:16 2003
@@ -164,15 +164,17 @@
 acpi_ex_get_buffer_datum(
 	acpi_integer                    *datum,
 	void                            *buffer,
+	u32                             buffer_length,
 	u32                             byte_granularity,
-	u32                             offset);
+	u32                             buffer_offset);
 
 void
 acpi_ex_set_buffer_datum (
 	acpi_integer                    merged_datum,
 	void                            *buffer,
+	u32                             buffer_length,
 	u32                             byte_granularity,
-	u32                             offset);
+	u32                             buffer_offset);
 
 acpi_status
 acpi_ex_read_data_from_field (
diff -Nru a/include/acpi/aclocal.h b/include/acpi/aclocal.h
--- a/include/acpi/aclocal.h	Wed Apr 30 22:28:11 2003
+++ b/include/acpi/aclocal.h	Wed Apr 30 22:28:11 2003
@@ -196,7 +196,7 @@
 
 
 	union acpi_operand_object           *object;        /* Pointer to attached ACPI object (optional) */
-	struct acpi_namespace_node          *child;         /* first child */
+	struct acpi_namespace_node          *child;         /* First child */
 	struct acpi_namespace_node          *peer;          /* Next peer*/
 	u16                                 reference_count; /* Current count of references and children */
 	u8                                  flags;
@@ -476,10 +476,10 @@
 struct acpi_pscope_state
 {
 	ACPI_STATE_COMMON
-	union acpi_parse_object             *op;                    /* current op being parsed */
-	u8                                  *arg_end;               /* current argument end */
-	u8                                  *pkg_end;               /* current package end */
-	u32                                 arg_list;               /* next argument to parse */
+	union acpi_parse_object             *op;                    /* Current op being parsed */
+	u8                                  *arg_end;               /* Current argument end */
+	u8                                  *pkg_end;               /* Current package end */
+	u32                                 arg_list;               /* Next argument to parse */
 	u32                                 arg_count;              /* Number of fixed arguments */
 };
 
@@ -585,11 +585,8 @@
 
 union acpi_parse_value
 {
-	acpi_integer                        integer;        /* integer constant (Up to 64 bits) */
+	acpi_integer                        integer;        /* Integer constant (Up to 64 bits) */
 	struct uint64_struct                integer64;      /* Structure overlay for 2 32-bit Dwords */
-	u32                                 integer32;      /* integer constant, 32 bits only */
-	u16                                 integer16;      /* integer constant, 16 bits only */
-	u8                                  integer8;       /* integer constant, 8 bits only */
 	u32                                 size;           /* bytelist or field size */
 	char                                *string;        /* NULL terminated string */
 	u8                                  *buffer;        /* buffer or string */
@@ -602,15 +599,15 @@
 	u8                                  data_type;      /* To differentiate various internal objs */\
 	u8                                  flags;          /* Type of Op */\
 	u16                                 aml_opcode;     /* AML opcode */\
-	u32                                 aml_offset;     /* offset of declaration in AML */\
-	union acpi_parse_object             *parent;        /* parent op */\
-	union acpi_parse_object             *next;          /* next op */\
+	u32                                 aml_offset;     /* Offset of declaration in AML */\
+	union acpi_parse_object             *parent;        /* Parent op */\
+	union acpi_parse_object             *next;          /* Next op */\
 	ACPI_DISASM_ONLY_MEMBERS (\
 	u8                                  disasm_flags;   /* Used during AML disassembly */\
 	u8                                  disasm_opcode;  /* Subtype used for disassembly */\
-	char                                aml_op_name[16]) /* op name (debug only) */\
+	char                                aml_op_name[16]) /* Op name (debug only) */\
 			   /* NON-DEBUG members below: */\
-	struct acpi_namespace_node          *node;          /* for use by interpreter */\
+	struct acpi_namespace_node          *node;          /* For use by interpreter */\
 	union acpi_parse_value              value;          /* Value or args associated with the opcode */\
 
 
@@ -691,14 +688,14 @@
 struct acpi_parse_state
 {
 	u32                                 aml_size;
-	u8                                  *aml_start;     /* first AML byte */
-	u8                                  *aml;           /* next AML byte */
+	u8                                  *aml_start;     /* First AML byte */
+	u8                                  *aml;           /* Next AML byte */
 	u8                                  *aml_end;       /* (last + 1) AML byte */
-	u8                                  *pkg_start;     /* current package begin */
-	u8                                  *pkg_end;       /* current package end */
-	union acpi_parse_object             *start_op;      /* root of parse tree */
+	u8                                  *pkg_start;     /* Current package begin */
+	u8                                  *pkg_end;       /* Current package end */
+	union acpi_parse_object             *start_op;      /* Root of parse tree */
 	struct acpi_namespace_node          *start_node;
-	union acpi_generic_state            *scope;         /* current scope */
+	union acpi_generic_state            *scope;         /* Current scope */
 	union acpi_parse_object             *start_scope;
 };
 
diff -Nru a/include/acpi/acmacros.h b/include/acpi/acmacros.h
--- a/include/acpi/acmacros.h	Wed Apr 30 22:28:10 2003
+++ b/include/acpi/acmacros.h	Wed Apr 30 22:28:10 2003
@@ -116,7 +116,7 @@
 #define ACPI_CAST_INDIRECT_PTR(t, p)    ((t **)(void *)(p))
 
 #if ACPI_MACHINE_WIDTH == 16
-#define ACPI_STORE_POINTER(d,s)         ACPI_MOVE_UNALIGNED32_TO_32(d,s)
+#define ACPI_STORE_POINTER(d,s)         ACPI_MOVE_32_TO_32(d,s)
 #define ACPI_PHYSADDR_TO_PTR(i)         (void *)(i)
 #define ACPI_PTR_TO_PHYSADDR(i)         (u32) (char *)(i)
 #else
@@ -130,41 +130,169 @@
  * Otherwise, we have to move one byte at a time.
  */
 
-#ifdef _HW_ALIGNMENT_SUPPORT
+#ifdef ACPI_BIG_ENDIAN
+/*
+ * Macros for big-endian machines
+ */
+
+/* This macro sets a buffer index, starting from the end of the buffer */
+
+#define ACPI_BUFFER_INDEX(buf_len,buf_offset,byte_gran) ((buf_len) - (((buf_offset)+1) * (byte_gran)))
+
+/* These macros reverse the bytes during the move, converting little-endian to big endian */
+
+	 /* Big Endian      <==        Little Endian */
+	 /*  Hi...Lo                     Lo...Hi     */
+/* 16-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_16_TO_16(d,s)         {((  u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[1];\
+			  ((  u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[0];}
+
+#define ACPI_MOVE_16_TO_32(d,s)         {(*(u32 *)(void *)(d))=0;\
+					  ((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\
+					  ((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];}
+
+#define ACPI_MOVE_16_TO_64(d,s)         {(*(u64 *)(void *)(d))=0;\
+							   ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\
+							   ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];}
+
+/* 32-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_32_TO_16(d,s)         ACPI_MOVE_16_TO_16(d,s)    /* Truncate to 16 */
+
+#define ACPI_MOVE_32_TO_32(d,s)         {((  u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[3];\
+									  ((  u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[2];\
+									  ((  u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\
+									  ((  u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];}
+
+#define ACPI_MOVE_32_TO_64(d,s)         {(*(u64 *)(void *)(d))=0;\
+										   ((u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3];\
+										   ((u8 *)(void *)(d))[5] = ((u8 *)(void *)(s))[2];\
+										   ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\
+										   ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];}
+
+/* 64-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_64_TO_16(d,s)         ACPI_MOVE_16_TO_16(d,s)    /* Truncate to 16 */
+
+#define ACPI_MOVE_64_TO_32(d,s)         ACPI_MOVE_32_TO_32(d,s)    /* Truncate to 32 */
+
+#define ACPI_MOVE_64_TO_64(d,s)         {((  u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[7];\
+										 ((  u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[6];\
+										 ((  u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[5];\
+										 ((  u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[4];\
+										 ((  u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3];\
+										 ((  u8 *)(void *)(d))[5] = ((u8 *)(void *)(s))[2];\
+										 ((  u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\
+										 ((  u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];}
+#else
+/*
+ * Macros for little-endian machines
+ */
+
+/* This macro sets a buffer index, starting from the beginning of the buffer */
+
+#define ACPI_BUFFER_INDEX(buf_len,buf_offset,byte_gran) (buf_offset)
+
+#ifdef ACPI_MISALIGNED_TRANSFERS
+
+/* The hardware supports unaligned transfers, just do the little-endian move */
+
+#if ACPI_MACHINE_WIDTH == 16
+
+/* No 64-bit integers */
+/* 16-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_16_TO_16(d,s)         *(u16 *)(void *)(d) = *(u16 *)(void *)(s)
+#define ACPI_MOVE_16_TO_32(d,s)         *(u32 *)(void *)(d) = *(u16 *)(void *)(s)
+#define ACPI_MOVE_16_TO_64(d,s)         ACPI_MOVE_16_TO_32(d,s)
+
+/* 32-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_32_TO_16(d,s)         ACPI_MOVE_16_TO_16(d,s)    /* Truncate to 16 */
+#define ACPI_MOVE_32_TO_32(d,s)         *(u32 *)(void *)(d) = *(u32 *)(void *)(s)
+#define ACPI_MOVE_32_TO_64(d,s)         ACPI_MOVE_32_TO_32(d,s)
+
+/* 64-bit source, 16/32/64 destination */
 
-/* The hardware supports unaligned transfers, just do the move */
+#define ACPI_MOVE_64_TO_16(d,s)         ACPI_MOVE_16_TO_16(d,s)    /* Truncate to 16 */
+#define ACPI_MOVE_64_TO_32(d,s)         ACPI_MOVE_32_TO_32(d,s)    /* Truncate to 32 */
+#define ACPI_MOVE_64_TO_64(d,s)         ACPI_MOVE_32_TO_32(d,s)
 
-#define ACPI_MOVE_UNALIGNED16_TO_16(d,s)    *(u16 *)(void *)(d) = *(u16 *)(void *)(s)
-#define ACPI_MOVE_UNALIGNED32_TO_32(d,s)    *(u32 *)(void *)(d) = *(u32 *)(void *)(s)
-#define ACPI_MOVE_UNALIGNED16_TO_32(d,s)    *(u32 *)(void *)(d) = *(u16 *)(void *)(s)
-#define ACPI_MOVE_UNALIGNED64_TO_64(d,s)    *(u64 *)(void *)(d) = *(u64 *)(void *)(s)
+#else
+/* 16-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_16_TO_16(d,s)         *(u16 *)(void *)(d) = *(u16 *)(void *)(s)
+#define ACPI_MOVE_16_TO_32(d,s)         *(u32 *)(void *)(d) = *(u16 *)(void *)(s)
+#define ACPI_MOVE_16_TO_64(d,s)         *(u64 *)(void *)(d) = *(u16 *)(void *)(s)
+
+/* 32-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_32_TO_16(d,s)         ACPI_MOVE_16_TO_16(d,s)    /* Truncate to 16 */
+#define ACPI_MOVE_32_TO_32(d,s)         *(u32 *)(void *)(d) = *(u32 *)(void *)(s)
+#define ACPI_MOVE_32_TO_64(d,s)         *(u64 *)(void *)(d) = *(u32 *)(void *)(s)
+
+/* 64-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_64_TO_16(d,s)         ACPI_MOVE_16_TO_16(d,s)    /* Truncate to 16 */
+#define ACPI_MOVE_64_TO_32(d,s)         ACPI_MOVE_32_TO_32(d,s)    /* Truncate to 32 */
+#define ACPI_MOVE_64_TO_64(d,s)         *(u64 *)(void *)(d) = *(u64 *)(void *)(s)
+#endif
 
 #else
 /*
  * The hardware does not support unaligned transfers.  We must move the
  * data one byte at a time.  These macros work whether the source or
- * the destination (or both) is/are unaligned.
+ * the destination (or both) is/are unaligned.  (Little-endian move)
  */
 
-#define ACPI_MOVE_UNALIGNED16_TO_16(d,s)    {((u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
-	  ((u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];}
+/* 16-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_16_TO_16(d,s)         {((  u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
+										 ((  u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];}
+
+#define ACPI_MOVE_16_TO_32(d,s)         {(*(u32 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d,s);}
+#define ACPI_MOVE_16_TO_64(d,s)         {(*(u64 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d,s);}
+
+/* 32-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_32_TO_16(d,s)         ACPI_MOVE_16_TO_16(d,s)    /* Truncate to 16 */
+
+#define ACPI_MOVE_32_TO_32(d,s)         {((  u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
+										 ((  u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\
+										 ((  u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[2];\
+										 ((  u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[3];}
+
+#define ACPI_MOVE_32_TO_64(d,s)         {(*(u64 *)(void *)(d)) = 0; ACPI_MOVE_32_TO_32(d,s);}
+
+/* 64-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_64_TO_16(d,s)         ACPI_MOVE_16_TO_16(d,s)    /* Truncate to 16 */
+#define ACPI_MOVE_64_TO_32(d,s)         ACPI_MOVE_32_TO_32(d,s)    /* Truncate to 32 */
+#define ACPI_MOVE_64_TO_64(d,s)         {((  u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
+										 ((  u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\
+										 ((  u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[2];\
+										 ((  u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[3];\
+										 ((  u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[4];\
+										 ((  u8 *)(void *)(d))[5] = ((u8 *)(void *)(s))[5];\
+										 ((  u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[6];\
+										 ((  u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[7];}
+#endif
+#endif
+
+/* Macros based on machine integer width */
+
+#if ACPI_MACHINE_WIDTH == 16
+#define ACPI_MOVE_SIZE_TO_16(d,s)       ACPI_MOVE_16_TO_16(d,s)
 
-#define ACPI_MOVE_UNALIGNED32_TO_32(d,s)    {((u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
-			   ((u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\
-			   ((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[2];\
-			   ((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[3];}
-
-#define ACPI_MOVE_UNALIGNED16_TO_32(d,s)    {(*(u32*)(void *)(d)) = 0; ACPI_MOVE_UNALIGNED16_TO_16(d,s);}
-
-#define ACPI_MOVE_UNALIGNED64_TO_64(d,s)    {((u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
-					 ((u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\
-					 ((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[2];\
-					 ((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[3];\
-					 ((u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[4];\
-					 ((u8 *)(void *)(d))[5] = ((u8 *)(void *)(s))[5];\
-					 ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[6];\
-					 ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[7];}
+#elif ACPI_MACHINE_WIDTH == 32
+#define ACPI_MOVE_SIZE_TO_16(d,s)       ACPI_MOVE_32_TO_16(d,s)
 
+#elif ACPI_MACHINE_WIDTH == 64
+#define ACPI_MOVE_SIZE_TO_16(d,s)       ACPI_MOVE_64_TO_16(d,s)
+
+#else
+#error unknown ACPI_MACHINE_WIDTH
 #endif
 
 
@@ -232,21 +360,6 @@
 
 #if ACPI_MACHINE_WIDTH != 16
 
-#define ACPI_PCI_DEVICE_MASK            (u64) 0x0000FFFF00000000
-#define ACPI_PCI_FUNCTION_MASK          (u64) 0x00000000FFFF0000
-#define ACPI_PCI_REGISTER_MASK          (u64) 0x000000000000FFFF
-
-/*
- * Obsolete
- */
-
-/*
-#define ACPI_PCI_FUNCTION(a)            (u16) ((((u64)((u64)(a) & ACPI_PCI_FUNCTION_MASK)) >> 16))
-#define ACPI_PCI_DEVICE(a)              (u16) ((((u64)((u64)(a) & ACPI_PCI_DEVICE_MASK)) >> 32))
-#define ACPI_PCI_REGISTER(a)            (u16) (((u64)((u64)(a) & ACPI_PCI_REGISTER_MASK)))
-*/
-
-
 #define ACPI_PCI_DEVICE(a)              (u16) ((ACPI_HIDWORD ((a))) & 0x0000FFFF)
 #define ACPI_PCI_FUNCTION(a)            (u16) ((ACPI_LODWORD ((a))) >> 16)
 #define ACPI_PCI_REGISTER(a)            (u16) ((ACPI_LODWORD ((a))) & 0x0000FFFF)
@@ -337,10 +450,10 @@
  * 5) Expand address to 64 bits
  */
 #define ASL_BUILD_GAS_FROM_ENTRY(a,b,c,d)   do {a.address_space_id = (u8) d;\
-							  a.register_bit_width = (u8) ACPI_MUL_8 (b);\
-							  a.register_bit_offset = 0;\
-							  a.reserved = 0;\
-							  ACPI_STORE_ADDRESS (a.address,(acpi_physical_address) c);} while (0)
+												a.register_bit_width = (u8) ACPI_MUL_8 (b);\
+												a.register_bit_offset = 0;\
+												a.reserved = 0;\
+												ACPI_STORE_ADDRESS (a.address,(acpi_physical_address) c);} while (0)
 
 /* ACPI V1.0 entries -- address space is always I/O */
 
@@ -351,7 +464,7 @@
  * Reporting macros that are never compiled out
  */
 
-#define ACPI_PARAM_LIST(pl)                  pl
+#define ACPI_PARAM_LIST(pl)                 pl
 
 /*
  * Error reporting.  These versions add callers module and line#.  Since
@@ -362,9 +475,9 @@
 #ifdef ACPI_DEBUG_OUTPUT
 
 #define ACPI_REPORT_INFO(fp)                {acpi_ut_report_info(_THIS_MODULE,__LINE__,_COMPONENT); \
-									   acpi_os_printf ACPI_PARAM_LIST(fp);}
+												acpi_os_printf ACPI_PARAM_LIST(fp);}
 #define ACPI_REPORT_ERROR(fp)               {acpi_ut_report_error(_THIS_MODULE,__LINE__,_COMPONENT); \
-											 acpi_os_printf ACPI_PARAM_LIST(fp);}
+												acpi_os_printf ACPI_PARAM_LIST(fp);}
 #define ACPI_REPORT_WARNING(fp)             {acpi_ut_report_warning(_THIS_MODULE,__LINE__,_COMPONENT); \
 												acpi_os_printf ACPI_PARAM_LIST(fp);}
 #define ACPI_REPORT_NSERROR(s,e)            acpi_ns_report_error(_THIS_MODULE,__LINE__,_COMPONENT, s, e);
@@ -408,21 +521,21 @@
  * as a local string ("_proc_name) so that it can be also used by the function exit macros below.
  */
 
-#define ACPI_FUNCTION_NAME(a)           struct acpi_debug_print_info _dbg;     \
-										_dbg.component_id = _COMPONENT; \
-										_dbg.proc_name   = a;           \
-										_dbg.module_name = _THIS_MODULE;
-
-#define ACPI_FUNCTION_TRACE(a)          ACPI_FUNCTION_NAME(a)\
-											acpi_ut_trace(__LINE__,&_dbg)
-#define ACPI_FUNCTION_TRACE_PTR(a,b)    ACPI_FUNCTION_NAME(a)\
-											acpi_ut_trace_ptr(__LINE__,&_dbg,(void *)b)
-#define ACPI_FUNCTION_TRACE_U32(a,b)    ACPI_FUNCTION_NAME(a)\
-											acpi_ut_trace_u32(__LINE__,&_dbg,(u32)b)
-#define ACPI_FUNCTION_TRACE_STR(a,b)    ACPI_FUNCTION_NAME(a)\
-											acpi_ut_trace_str(__LINE__,&_dbg,(char *)b)
+#define ACPI_FUNCTION_NAME(a)               struct acpi_debug_print_info _dbg; \
+												_dbg.component_id = _COMPONENT; \
+												_dbg.proc_name   = a; \
+												_dbg.module_name = _THIS_MODULE;
+
+#define ACPI_FUNCTION_TRACE(a)              ACPI_FUNCTION_NAME(a) \
+												acpi_ut_trace(__LINE__,&_dbg)
+#define ACPI_FUNCTION_TRACE_PTR(a,b)        ACPI_FUNCTION_NAME(a) \
+												acpi_ut_trace_ptr(__LINE__,&_dbg,(void *)b)
+#define ACPI_FUNCTION_TRACE_U32(a,b)        ACPI_FUNCTION_NAME(a) \
+												acpi_ut_trace_u32(__LINE__,&_dbg,(u32)b)
+#define ACPI_FUNCTION_TRACE_STR(a,b)        ACPI_FUNCTION_NAME(a) \
+												acpi_ut_trace_str(__LINE__,&_dbg,(char *)b)
 
-#define ACPI_FUNCTION_ENTRY()           acpi_ut_track_stack_ptr()
+#define ACPI_FUNCTION_ENTRY()               acpi_ut_track_stack_ptr()
 
 /*
  * Function exit tracing.
diff -Nru a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h
--- a/include/acpi/acpiosxf.h	Wed Apr 30 22:28:03 2003
+++ b/include/acpi/acpiosxf.h	Wed Apr 30 22:28:03 2003
@@ -229,13 +229,13 @@
 acpi_status
 acpi_os_read_port (
 	acpi_io_address                 address,
-	void                            *value,
+	u32                             *value,
 	u32                             width);
 
 acpi_status
 acpi_os_write_port (
 	acpi_io_address                 address,
-	acpi_integer                    value,
+	u32                             value,
 	u32                             width);
 
 
@@ -246,13 +246,13 @@
 acpi_status
 acpi_os_read_memory (
 	acpi_physical_address           address,
-	void                            *value,
+	u32                             *value,
 	u32                             width);
 
 acpi_status
 acpi_os_write_memory (
 	acpi_physical_address           address,
-	acpi_integer                    value,
+	u32                             value,
 	u32                             width);
 
 
diff -Nru a/include/acpi/actbl.h b/include/acpi/actbl.h
--- a/include/acpi/actbl.h	Wed Apr 30 22:28:09 2003
+++ b/include/acpi/actbl.h	Wed Apr 30 22:28:09 2003
@@ -181,7 +181,15 @@
 	u32                             critical_level;
 };
 
-
+struct hpet_description_table
+{
+	struct acpi_table_header        header;
+	u32                             hardware_id;
+	u32                             base_address[3];
+	u8                              hpet_number;
+	u16                             clock_tick;
+	u8                              attributes;
+};
 #pragma pack()
 
 
diff -Nru a/include/acpi/actypes.h b/include/acpi/actypes.h
--- a/include/acpi/actypes.h	Wed Apr 30 22:28:10 2003
+++ b/include/acpi/actypes.h	Wed Apr 30 22:28:10 2003
@@ -154,7 +154,7 @@
 typedef u16                                     acpi_size;
 
 #define ALIGNED_ADDRESS_BOUNDARY        0x00000002
-#define _HW_ALIGNMENT_SUPPORT
+#define ACPI_MISALIGNED_TRANSFERS
 #define ACPI_USE_NATIVE_DIVIDE                          /* No 64-bit integers, ok to use native divide */
 #define ACPI_MAX_PTR                    ACPI_UINT16_MAX
 #define ACPI_SIZE_MAX                   ACPI_UINT16_MAX
@@ -192,7 +192,7 @@
 typedef u32                                     acpi_size;
 
 #define ALIGNED_ADDRESS_BOUNDARY        0x00000004
-#define _HW_ALIGNMENT_SUPPORT
+#define ACPI_MISALIGNED_TRANSFERS
 #define ACPI_MAX_PTR                    ACPI_UINT32_MAX
 #define ACPI_SIZE_MAX                   ACPI_UINT32_MAX
 
@@ -1194,7 +1194,7 @@
 
 #define ACPI_NEXT_RESOURCE(res)             (struct acpi_resource *)((u8 *) res + res->length)
 
-#ifdef _HW_ALIGNMENT_SUPPORT
+#ifdef ACPI_MISALIGNED_TRANSFERS
 #define ACPI_ALIGN_RESOURCE_SIZE(length)    (length)
 #else
 #define ACPI_ALIGN_RESOURCE_SIZE(length)    ACPI_ROUND_UP_TO_NATIVE_WORD(length)
diff -Nru a/include/asm-alpha/irq.h b/include/asm-alpha/irq.h
--- a/include/asm-alpha/irq.h	Wed Apr 30 22:28:19 2003
+++ b/include/asm-alpha/irq.h	Wed Apr 30 22:28:19 2003
@@ -64,7 +64,7 @@
 # define NR_IRQS	16
 #endif
 
-static __inline__ int irq_cannonicalize(int irq)
+static __inline__ int irq_canonicalize(int irq)
 {
 	/*
 	 * XXX is this true for all Alpha's?  The old serial driver
diff -Nru a/include/asm-alpha/pgalloc.h b/include/asm-alpha/pgalloc.h
--- a/include/asm-alpha/pgalloc.h	Wed Apr 30 22:28:03 2003
+++ b/include/asm-alpha/pgalloc.h	Wed Apr 30 22:28:03 2003
@@ -40,7 +40,7 @@
 static inline pmd_t *
 pmd_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	pmd_t *ret = (pmd_t *)__get_free_page(GFP_KERNEL);
+	pmd_t *ret = (pmd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (ret)
 		clear_page(ret);
 	return ret;
diff -Nru a/include/asm-arm/arch-adifcc/time.h b/include/asm-arm/arch-adifcc/time.h
--- a/include/asm-arm/arch-adifcc/time.h	Wed Apr 30 22:28:19 2003
+++ b/include/asm-arm/arch-adifcc/time.h	Wed Apr 30 22:28:19 2003
@@ -4,6 +4,6 @@
  */
 
 /*
- * No on board timer, implemenation @ arch/arm/kernel/xscale-time.c
+ * No on board timer, implementation @ arch/arm/kernel/xscale-time.c
  */
 
diff -Nru a/include/asm-arm/arch-arc/irqs.h b/include/asm-arm/arch-arc/irqs.h
--- a/include/asm-arm/arch-arc/irqs.h	Wed Apr 30 22:28:09 2003
+++ b/include/asm-arm/arch-arc/irqs.h	Wed Apr 30 22:28:09 2003
@@ -57,4 +57,4 @@
  */
 #define FIQ_START		64
 
-#define irq_cannonicalize(i)	(i)
+#define irq_canonicalize(i)	(i)
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	Wed Apr 30 22:28:03 2003
+++ b/include/asm-arm/arch-clps711x/memory.h	Wed Apr 30 22:28:03 2003
@@ -95,7 +95,7 @@
  * Because of the wide memory address space between physical RAM banks on the 
  * SA1100, it's much more convenient to use Linux's NUMA support to implement
  * our memory map representation.  Assuming all memory nodes have equal access 
- * characteristics, we then have generic discontigous memory support.
+ * characteristics, we then have generic discontiguous memory support.
  *
  * Of course, all this isn't mandatory for SA1100 implementations with only
  * one used memory bank.  For those, simply undefine CONFIG_DISCONTIGMEM.
diff -Nru a/include/asm-arm/arch-ebsa285/irqs.h b/include/asm-arm/arch-ebsa285/irqs.h
--- a/include/asm-arm/arch-ebsa285/irqs.h	Wed Apr 30 22:28:06 2003
+++ b/include/asm-arm/arch-ebsa285/irqs.h	Wed Apr 30 22:28:06 2003
@@ -95,4 +95,4 @@
 #define AUX_IRQ		(machine_is_netwinder() ? IRQ_NETWINDER_PS2MOUSE : IRQ_ISA_PS2MOUSE)
 #define IRQ_FLOPPYDISK	IRQ_ISA_FLOPPY
 
-#define irq_cannonicalize(_i)	(((_i) == IRQ_ISA_CASCADE) ? IRQ_ISA_2 : _i)
+#define irq_canonicalize(_i)	(((_i) == IRQ_ISA_CASCADE) ? IRQ_ISA_2 : _i)
diff -Nru a/include/asm-arm/arch-epxa10db/ether00.h b/include/asm-arm/arch-epxa10db/ether00.h
--- a/include/asm-arm/arch-epxa10db/ether00.h	Wed Apr 30 22:28:15 2003
+++ b/include/asm-arm/arch-epxa10db/ether00.h	Wed Apr 30 22:28:15 2003
@@ -55,7 +55,7 @@
 #define ETHER_ARC_SIZE         (21)
 
 /*
-*	Regsiter definitions and masks
+*	Register definitions and masks
 */
 #define ETHER_DMA_CTL(base)							(ETHER00_TYPE (base + 0x100))
 #define ETHER_DMA_CTL_DMBURST_OFST				(2)
diff -Nru a/include/asm-arm/arch-epxa10db/pld_conf00.h b/include/asm-arm/arch-epxa10db/pld_conf00.h
--- a/include/asm-arm/arch-epxa10db/pld_conf00.h	Wed Apr 30 22:28:03 2003
+++ b/include/asm-arm/arch-epxa10db/pld_conf00.h	Wed Apr 30 22:28:03 2003
@@ -8,7 +8,7 @@
 /*
  *  
  *  This file contains the register definitions for the Excalibur
- *  Interrupnt controller INT_CTRL00.
+ *  Interrupt controller INT_CTRL00.
  *
  *  Copyright (C) 2001 Altera Corporation
  *
diff -Nru a/include/asm-arm/arch-integrator/bits.h b/include/asm-arm/arch-integrator/bits.h
--- a/include/asm-arm/arch-integrator/bits.h	Wed Apr 30 22:28:15 2003
+++ b/include/asm-arm/arch-integrator/bits.h	Wed Apr 30 22:28:15 2003
@@ -16,7 +16,7 @@
 /* DO NOT EDIT!! - this file automatically generated
  *                 from .s file by awk -f s2h.awk
  */
-/*  Bit field defintions
+/*  Bit field definitions
  *  Copyright (C) ARM Limited 1998. All rights reserved.
  */
 
diff -Nru a/include/asm-arm/arch-iop3xx/iop310-irqs.h b/include/asm-arm/arch-iop3xx/iop310-irqs.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/include/asm-arm/arch-iop3xx/iop310-irqs.h	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,80 @@
+/*
+ * linux/include/asm-arm/arch-iop310/irqs.h
+ *
+ * Author:	Nicolas Pitre
+ * Copyright:	(C) 2001 MontaVista Software Inc.
+ *
+ * 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.
+ *
+ * 06/13/01: Added 80310 on-chip interrupt sources <dsaxena@mvista.com>
+ *
+ */
+#include <linux/config.h>
+
+/*
+ * XS80200 specific IRQs
+ */
+#define IRQ_XS80200_BCU		0	/* Bus Control Unit */
+#define IRQ_XS80200_PMU		1	/* Performance Monitoring Unit */
+#define IRQ_XS80200_EXTIRQ	2	/* external IRQ signal */
+#define IRQ_XS80200_EXTFIQ	3	/* external IRQ signal */
+
+#define NR_XS80200_IRQS		4
+
+#define XSCALE_PMU_IRQ		IRQ_XS80200_PMU
+
+/*
+ * IOP80310 chipset interrupts
+ */
+#define IOP310_IRQ_OFS		NR_XS80200_IRQS
+#define IOP310_IRQ(x)		(IOP310_IRQ_OFS + (x))
+
+/*
+ * On FIQ1ISR register
+ */
+#define IRQ_IOP310_DMA0		IOP310_IRQ(0)	/* DMA Channel 0 */
+#define IRQ_IOP310_DMA1		IOP310_IRQ(1)	/* DMA Channel 1 */
+#define IRQ_IOP310_DMA2		IOP310_IRQ(2)	/* DMA Channel 2 */
+#define IRQ_IOP310_PMON		IOP310_IRQ(3)	/* Bus performance Unit */
+#define IRQ_IOP310_AAU		IOP310_IRQ(4)	/* Application Accelator Unit */
+
+/*
+ * On FIQ2ISR register
+ */
+#define IRQ_IOP310_I2C		IOP310_IRQ(5)	/* I2C unit */
+#define IRQ_IOP310_MU		IOP310_IRQ(6)	/* messaging unit */
+
+#define NR_IOP310_IRQS		(IOP310_IRQ(6) + 1)
+
+#define NR_IRQS			NR_IOP310_IRQS
+
+
+/*
+ * Interrupts available on the Cyclone IQ80310 board
+ */
+#ifdef CONFIG_ARCH_IQ80310
+
+#define IQ80310_IRQ_OFS		NR_IOP310_IRQS
+#define IQ80310_IRQ(y)		((IQ80310_IRQ_OFS) + (y))
+
+#define IRQ_IQ80310_TIMER	IQ80310_IRQ(0)	/* Timer Interrupt */
+#define IRQ_IQ80310_I82559	IQ80310_IRQ(1)	/* I82559 Ethernet Interrupt */
+#define IRQ_IQ80310_UART1	IQ80310_IRQ(2)	/* UART1 Interrupt */
+#define IRQ_IQ80310_UART2	IQ80310_IRQ(3)	/* UART2 Interrupt */
+#define IRQ_IQ80310_INTD	IQ80310_IRQ(4)	/* PCI INTD */
+
+
+/*
+ * ONLY AVAILABLE ON REV F OR NEWER BOARDS!
+ */
+#define	IRQ_IQ80310_INTA	IQ80310_IRQ(5)	/* PCI INTA */
+#define	IRQ_IQ80310_INTB	IQ80310_IRQ(6)	/* PCI INTB */
+#define	IRQ_IQ80310_INTC	IQ80310_IRQ(7)	/* PCI INTC */
+
+#undef	NR_IRQS
+#define NR_IRQS			(IQ80310_IRQ(7) + 1)
+
+#endif // CONFIG_ARCH_IQ80310
+
diff -Nru a/include/asm-arm/arch-iop3xx/iop310.h b/include/asm-arm/arch-iop3xx/iop310.h
--- a/include/asm-arm/arch-iop3xx/iop310.h	Wed Apr 30 22:28:09 2003
+++ b/include/asm-arm/arch-iop3xx/iop310.h	Wed Apr 30 22:28:09 2003
@@ -1,7 +1,7 @@
 /*
  * linux/include/asm/arch-iop3xx/iop310.h
  *
- * Intel IOP310 Compainion Chip definitions
+ * Intel IOP310 Companion Chip definitions
  *
  * 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
diff -Nru a/include/asm-arm/arch-iop3xx/iop321.h b/include/asm-arm/arch-iop3xx/iop321.h
--- a/include/asm-arm/arch-iop3xx/iop321.h	Wed Apr 30 22:28:20 2003
+++ b/include/asm-arm/arch-iop3xx/iop321.h	Wed Apr 30 22:28:20 2003
@@ -17,12 +17,10 @@
 /*
  * IOP321 I/O and Mem space regions for PCI autoconfiguration
  */
-#define	IOP321_PCI_LOWER_IO		0x90000000
-#define	IOP321_PCI_UPPER_IO		0x9000ffff
-#define IOP321_PCI_LOWER_MEM		0x80000000
-#define IOP321_PCI_UPPER_MEM		0x83ffffff
-
-#define IOP321_PCI_WINDOW_SIZE		64 * 0x100000
+#define	IOP321_PCI_IO_BASE		0x90000000
+#define	IOP321_PCI_IO_SIZE		0x00010000
+#define IOP321_PCI_MEM_BASE		0x40000000
+#define IOP321_PCI_MEM_SIZE		0x40000000
 
 /*
  * IOP321 chipset registers
diff -Nru a/include/asm-arm/arch-nexuspci/irqs.h b/include/asm-arm/arch-nexuspci/irqs.h
--- a/include/asm-arm/arch-nexuspci/irqs.h	Wed Apr 30 22:28:07 2003
+++ b/include/asm-arm/arch-nexuspci/irqs.h	Wed Apr 30 22:28:07 2003
@@ -31,4 +31,4 @@
 /* timer is part of the DUART */
 #define IRQ_TIMER		IRQ_DUART
 
-#define irq_cannonicalize(i)	(i)
+#define irq_canonicalize(i)	(i)
diff -Nru a/include/asm-arm/arch-pxa/pxa-regs.h b/include/asm-arm/arch-pxa/pxa-regs.h
--- a/include/asm-arm/arch-pxa/pxa-regs.h	Wed Apr 30 22:28:11 2003
+++ b/include/asm-arm/arch-pxa/pxa-regs.h	Wed Apr 30 22:28:11 2003
@@ -690,9 +690,9 @@
 #define ICSR0		__REG(0x40800014)  /* ICP Status Register 0 */
 #define ICSR1		__REG(0x40800018)  /* ICP Status Register 1 */
 
-#define ICCR0_AME       (1 << 7)           /* Adress match enable */
+#define ICCR0_AME       (1 << 7)           /* Address match enable */
 #define ICCR0_TIE       (1 << 6)           /* Transmit FIFO interrupt enable */
-#define ICCR0_RIE       (1 << 5)           /* Recieve FIFO interrupt enable */
+#define ICCR0_RIE       (1 << 5)           /* Receive FIFO interrupt enable */
 #define ICCR0_RXE       (1 << 4)           /* Receive enable */
 #define ICCR0_TXE       (1 << 3)           /* Transmit enable */
 #define ICCR0_TUS       (1 << 2)           /* Transmit FIFO underrun select */
diff -Nru a/include/asm-arm/arch-sa1100/graphicsclient.h b/include/asm-arm/arch-sa1100/graphicsclient.h
--- a/include/asm-arm/arch-sa1100/graphicsclient.h	Wed Apr 30 22:28:19 2003
+++ b/include/asm-arm/arch-sa1100/graphicsclient.h	Wed Apr 30 22:28:19 2003
@@ -63,7 +63,7 @@
 #define _ADS_UARTC		0x10140000	/* UART C */
 #define _ADS_UARTD		0x10160000	/* UART D */
 
-/* UART controll lines GPIOs */
+/* UART control lines GPIOs */
 #define GPIO_GC_UART0_RTS       GPIO_GPIO15
 #define GPIO_GC_UART1_RTS	    GPIO_GPIO17
 #define GPIO_GC_UART2_RTS	    GPIO_GPIO19
@@ -71,7 +71,7 @@
 #define GPIO_GC_UART1_CTS       GPIO_GPIO16
 #define GPIO_GC_UART2_CTS       GPIO_GPIO17
 
-/* UART controll lines IRQs */
+/* UART control lines IRQs */
 #define IRQ_GC_UART0_CTS       IRQ_GPIO14
 #define IRQ_GC_UART1_CTS       IRQ_GPIO16
 #define IRQ_GC_UART2_CTS       IRQ_GPIO17
diff -Nru a/include/asm-arm/arch-sa1100/h3600_gpio.h b/include/asm-arm/arch-sa1100/h3600_gpio.h
--- a/include/asm-arm/arch-sa1100/h3600_gpio.h	Wed Apr 30 22:28:03 2003
+++ b/include/asm-arm/arch-sa1100/h3600_gpio.h	Wed Apr 30 22:28:03 2003
@@ -480,7 +480,7 @@
 #define _H3800_ASIC1_GPIO_State         0x40    /* R   See masks below  (default 0)         */
 #define _H3800_ASIC1_GPIO_Reset         0x42    /* R/W See masks below  (default 0x04)      */
 #define _H3800_ASIC1_GPIO_SleepMask     0x44    /* R/W 0:don't mask, 1:mask trigger in sleep mode  */
-#define _H3800_ASIC1_GPIO_SleepDir      0x46    /* R/W direction 0:input, 1:ouput in sleep mode    */
+#define _H3800_ASIC1_GPIO_SleepDir      0x46    /* R/W direction 0:input, 1:output in sleep mode    */
 #define _H3800_ASIC1_GPIO_SleepOut      0x48    /* R/W level 0:low, 1:high in sleep mode           */
 #define _H3800_ASIC1_GPIO_Status        0x4A    /* R   Pin status                                  */
 #define _H3800_ASIC1_GPIO_BattFaultDir  0x4C    /* R/W direction 0:input, 1:output in batt_fault   */
diff -Nru a/include/asm-arm/arch-sa1100/memory.h b/include/asm-arm/arch-sa1100/memory.h
--- a/include/asm-arm/arch-sa1100/memory.h	Wed Apr 30 22:28:03 2003
+++ b/include/asm-arm/arch-sa1100/memory.h	Wed Apr 30 22:28:03 2003
@@ -60,7 +60,7 @@
  * Because of the wide memory address space between physical RAM banks on the 
  * SA1100, it's much convenient to use Linux's NUMA support to implement our 
  * memory map representation.  Assuming all memory nodes have equal access 
- * characteristics, we then have generic discontigous memory support.
+ * characteristics, we then have generic discontiguous memory support.
  *
  * Of course, all this isn't mandatory for SA1100 implementations with only
  * one used memory bank.  For those, simply undefine CONFIG_DISCONTIGMEM.
diff -Nru a/include/asm-arm/arch-sa1100/uncompress.h b/include/asm-arm/arch-sa1100/uncompress.h
--- a/include/asm-arm/arch-sa1100/uncompress.h	Wed Apr 30 22:28:09 2003
+++ b/include/asm-arm/arch-sa1100/uncompress.h	Wed Apr 30 22:28:09 2003
@@ -32,7 +32,7 @@
 	} while (0);
 
 	for (; *s; s++) {
-		/* wait for space in the UART's transmiter */
+		/* wait for space in the UART's transmitter */
 		while (!(UART(UTSR1) & UTSR1_TNF));
 
 		/* send the character out. */
diff -Nru a/include/asm-arm/arch-tbox/irqs.h b/include/asm-arm/arch-tbox/irqs.h
--- a/include/asm-arm/arch-tbox/irqs.h	Wed Apr 30 22:28:18 2003
+++ b/include/asm-arm/arch-tbox/irqs.h	Wed Apr 30 22:28:18 2003
@@ -26,4 +26,4 @@
 #define IRQ_EXPMODCS0		12
 #define IRQ_EXPMODCS1		13
 
-#define irq_cannonicalize(i)	(i)
+#define irq_canonicalize(i)	(i)
diff -Nru a/include/asm-arm/bugs.h b/include/asm-arm/bugs.h
--- a/include/asm-arm/bugs.h	Wed Apr 30 22:28:14 2003
+++ b/include/asm-arm/bugs.h	Wed Apr 30 22:28:14 2003
@@ -1,7 +1,7 @@
 /*
  *  linux/include/asm-arm/bugs.h
  *
- *  Copyright (C) 1995  Russell King
+ *  Copyright (C) 1995-2003 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
@@ -12,6 +12,6 @@
 
 #include <asm/proc-fns.h>
 
-#define check_bugs() cpu_check_bugs()
+#define check_bugs() do { } while (0)
 
 #endif
diff -Nru a/include/asm-arm/cpu-multi26.h b/include/asm-arm/cpu-multi26.h
--- a/include/asm-arm/cpu-multi26.h	Wed Apr 30 22:28:14 2003
+++ b/include/asm-arm/cpu-multi26.h	Wed Apr 30 22:28:14 2003
@@ -19,14 +19,12 @@
  * relies on it.
  */
 extern struct processor {
-	/* check for any bugs */
-	void (*_check_bugs)(void);
 	/* Set up any processor specifics */
 	void (*_proc_init)(void);
 	/* Disable any processor specifics */
 	void (*_proc_fin)(void);
 	/* set the MEMC hardware mappings */
-	void (*_set_pgd)(pgd_t *pgd);
+	void (*_switch_mm)(pgd_t *pgd);
 	/* XCHG */
 	unsigned long (*_xchg_1)(unsigned long x, volatile void *ptr);
 	unsigned long (*_xchg_4)(unsigned long x, volatile void *ptr);
@@ -36,11 +34,10 @@
 extern const struct processor arm250_processor_functions;
 extern const struct processor arm3_processor_functions;
 
-#define cpu_check_bugs()			processor._check_bugs()
 #define cpu_proc_init()				processor._proc_init()
 #define cpu_proc_fin()				processor._proc_fin()
 #define cpu_do_idle()				do { } while (0)
-#define cpu_switch_mm(pgd,mm)			processor._set_pgd(pgd)
+#define cpu_switch_mm(pgd,mm)			processor._switch_mm(pgd)
 #define cpu_xchg_1(x,ptr)			processor._xchg_1(x,ptr)
 #define cpu_xchg_4(x,ptr)			processor._xchg_4(x,ptr)
 
diff -Nru a/include/asm-arm/cpu-multi32.h b/include/asm-arm/cpu-multi32.h
--- a/include/asm-arm/cpu-multi32.h	Wed Apr 30 22:28:04 2003
+++ b/include/asm-arm/cpu-multi32.h	Wed Apr 30 22:28:04 2003
@@ -24,10 +24,6 @@
 	 */
 	void (*_data_abort)(unsigned long pc);
 	/*
-	 * check for any bugs
-	 */
-	void (*_check_bugs)(void);
-	/*
 	 * Set up any processor specifics
 	 */
 	void (*_proc_init)(void);
@@ -46,96 +42,36 @@
 	/*
 	 * Processor architecture specific
 	 */
-	struct {	/* CACHE */
-		/*
-		 * flush all caches
-		 */
-		void (*clean_invalidate_all)(void);
-		/*
-		 * flush a specific page or pages
-		 */
-		void (*clean_invalidate_range)(unsigned long address, unsigned long end, int flags);
-	} cache;
-
-	struct {	/* D-cache */
-		/*
-		 * invalidate the specified data range
-		 */
-		void (*invalidate_range)(unsigned long start, unsigned long end);
-		/*
-		 * clean specified data range
-		 */
-		void (*clean_range)(unsigned long start, unsigned long end);
-		/*
-		 * obsolete flush cache entry
-		 */
-		void (*clean_page)(void *virt_page);
-		/*
-		 * clean a virtual address range from the
-		 * D-cache without flushing the cache.
-		 */
-		void (*clean_entry)(unsigned long start);
-	} dcache;
-
-	struct {	/* I-cache */
-		/*
-		 * invalidate the I-cache for the specified range
-		 */
-		void (*invalidate_range)(unsigned long start, unsigned long end);
-		/*
-		 * invalidate the I-cache for the specified virtual page
-		 */
-		void (*invalidate_page)(void *virt_page);
-	} icache;
+	/*
+	 * clean a virtual address range from the
+	 * D-cache without flushing the cache.
+	 */
+	void (*dcache_clean_area)(void *addr, int size);
 
-	struct {	/* PageTable */
-		/*
-		 * Set the page table
-		 */
-		void (*set_pgd)(unsigned long pgd_phys, struct mm_struct *mm);
-		/*
-		 * Set a PMD (handling IMP bit 4)
-		 */
-		void (*flush_pmd)(pmd_t *pmdp);
-		/*
-		 * Set a PTE
-		 */
-		void (*set_pte)(pte_t *ptep, pte_t pte);
-	} pgtable;
+	/*
+	 * Set the page table
+	 */
+	void (*switch_mm)(unsigned long pgd_phys, struct mm_struct *mm);
+	/*
+	 * Set a PTE
+	 */
+	void (*set_pte)(pte_t *ptep, pte_t pte);
 } processor;
 
-extern const struct processor arm6_processor_functions;
-extern const struct processor arm7_processor_functions;
-extern const struct processor sa110_processor_functions;
-
-#define cpu_check_bugs()			processor._check_bugs()
-#define cpu_proc_init()				processor._proc_init()
-#define cpu_proc_fin()				processor._proc_fin()
-#define cpu_reset(addr)				processor.reset(addr)
-#define cpu_do_idle()				processor._do_idle()
-
-#define cpu_cache_clean_invalidate_all()	processor.cache.clean_invalidate_all()
-#define cpu_cache_clean_invalidate_range(s,e,f)	processor.cache.clean_invalidate_range(s,e,f)
-
-#define cpu_dcache_clean_page(vp)		processor.dcache.clean_page(vp)
-#define cpu_dcache_clean_entry(addr)		processor.dcache.clean_entry(addr)
-#define cpu_dcache_clean_range(s,e)		processor.dcache.clean_range(s,e)
-#define cpu_dcache_invalidate_range(s,e)	processor.dcache.invalidate_range(s,e)
-
-#define cpu_icache_invalidate_range(s,e)	processor.icache.invalidate_range(s,e)
-#define cpu_icache_invalidate_page(vp)		processor.icache.invalidate_page(vp)
-
-#define cpu_set_pgd(pgd,mm)			processor.pgtable.set_pgd(pgd,mm)
-#define cpu_flush_pmd(pmdp)			processor.pgtable.flush_pmd(pmdp)
-#define cpu_set_pte(ptep, pte)			processor.pgtable.set_pte(ptep, pte)
+#define cpu_proc_init()			processor._proc_init()
+#define cpu_proc_fin()			processor._proc_fin()
+#define cpu_reset(addr)			processor.reset(addr)
+#define cpu_do_idle()			processor._do_idle()
+#define cpu_dcache_clean_area(addr,sz)	processor.dcache_clean_area(addr,sz)
+#define cpu_set_pte(ptep, pte)		processor.set_pte(ptep, pte)
 
-#define cpu_switch_mm(pgd,mm)			cpu_set_pgd(__virt_to_phys((unsigned long)(pgd)),mm)
+#define cpu_switch_mm(pgd,mm)	processor.switch_mm(__virt_to_phys((unsigned long)(pgd)),mm)
 
 #define cpu_get_pgd()	\
 	({						\
 		unsigned long pg;			\
-		__asm__("mrc p15, 0, %0, c2, c0, 0"	\
-			 : "=r" (pg));			\
+		__asm__("mrc	p15, 0, %0, c2, c0, 0"	\
+			 : "=r" (pg) : : "cc");		\
 		pg &= ~0x3fff;				\
 		(pgd_t *)phys_to_virt(pg);		\
 	})
diff -Nru a/include/asm-arm/cpu-single.h b/include/asm-arm/cpu-single.h
--- a/include/asm-arm/cpu-single.h	Wed Apr 30 22:28:03 2003
+++ b/include/asm-arm/cpu-single.h	Wed Apr 30 22:28:03 2003
@@ -22,21 +22,12 @@
  * function pointers for this lot.  Otherwise, we can optimise the
  * table away.
  */
-#define cpu_check_bugs			__cpu_fn(CPU_NAME,_check_bugs)
 #define cpu_proc_init			__cpu_fn(CPU_NAME,_proc_init)
 #define cpu_proc_fin			__cpu_fn(CPU_NAME,_proc_fin)
 #define cpu_reset			__cpu_fn(CPU_NAME,_reset)
 #define cpu_do_idle			__cpu_fn(CPU_NAME,_do_idle)
-#define cpu_cache_clean_invalidate_all	__cpu_fn(CPU_NAME,_cache_clean_invalidate_all)
-#define cpu_cache_clean_invalidate_range __cpu_fn(CPU_NAME,_cache_clean_invalidate_range)
-#define cpu_dcache_invalidate_range	__cpu_fn(CPU_NAME,_dcache_invalidate_range)
-#define cpu_dcache_clean_range		__cpu_fn(CPU_NAME,_dcache_clean_range)
-#define cpu_dcache_clean_page		__cpu_fn(CPU_NAME,_dcache_clean_page)
-#define cpu_dcache_clean_entry		__cpu_fn(CPU_NAME,_dcache_clean_entry)
-#define cpu_icache_invalidate_range	__cpu_fn(CPU_NAME,_icache_invalidate_range)
-#define cpu_icache_invalidate_page	__cpu_fn(CPU_NAME,_icache_invalidate_page)
-#define cpu_set_pgd			__cpu_fn(CPU_NAME,_set_pgd)
-#define cpu_flush_pmd			__cpu_fn(CPU_NAME,_flush_pmd)
+#define cpu_dcache_clean_area		__cpu_fn(CPU_NAME,_dcache_clean_area)
+#define cpu__switch_mm			__cpu_fn(CPU_NAME,_switch_mm)
 #define cpu_set_pte			__cpu_fn(CPU_NAME,_set_pte)
 
 #ifndef __ASSEMBLY__
@@ -47,36 +38,22 @@
 struct mm_struct;
 
 /* declare all the functions as extern */
-extern void cpu_data_abort(unsigned long pc);
-extern void cpu_check_bugs(void);
 extern void cpu_proc_init(void);
 extern void cpu_proc_fin(void);
 extern int cpu_do_idle(void);
-
-extern void cpu_cache_clean_invalidate_all(void);
-extern void cpu_cache_clean_invalidate_range(unsigned long address, unsigned long end, int flags);
-
-extern void cpu_dcache_invalidate_range(unsigned long start, unsigned long end);
-extern void cpu_dcache_clean_range(unsigned long start, unsigned long end);
-extern void cpu_dcache_clean_page(void *virt_page);
-extern void cpu_dcache_clean_entry(unsigned long address);
-
-extern void cpu_icache_invalidate_range(unsigned long start, unsigned long end);
-extern void cpu_icache_invalidate_page(void *virt_page);
-
-extern void cpu_set_pgd(unsigned long pgd_phys, struct mm_struct *mm);
-extern void cpu_flush_pmd(pmd_t *pmdp);
+extern void cpu_dcache_clean_area(void *, int);
+extern void cpu__switch_mm(unsigned long pgd_phys, struct mm_struct *mm);
 extern void cpu_set_pte(pte_t *ptep, pte_t pte);
 
 extern volatile void cpu_reset(unsigned long addr);
 
-#define cpu_switch_mm(pgd,mm) cpu_set_pgd(__virt_to_phys((unsigned long)(pgd)),mm)
+#define cpu_switch_mm(pgd,mm) cpu__switch_mm(__virt_to_phys((unsigned long)(pgd)),mm)
 
 #define cpu_get_pgd()	\
 	({						\
 		unsigned long pg;			\
-		__asm__("mrc p15, 0, %0, c2, c0, 0"	\
-			 : "=r" (pg));			\
+		__asm__("mrc	p15, 0, %0, c2, c0, 0"	\
+			 : "=r" (pg) : : "cc");		\
 		pg &= ~0x3fff;				\
 		(pgd_t *)phys_to_virt(pg);		\
 	})
diff -Nru a/include/asm-arm/dma-mapping.h b/include/asm-arm/dma-mapping.h
--- a/include/asm-arm/dma-mapping.h	Wed Apr 30 22:28:03 2003
+++ b/include/asm-arm/dma-mapping.h	Wed Apr 30 22:28:03 2003
@@ -182,7 +182,7 @@
  * @dir: DMA transfer direction
  *
  * Map a set of buffers described by scatterlist in streaming
- * mode for DMA.  This is the scather-gather version of the
+ * mode for DMA.  This is the scatter-gather version of the
  * above pci_map_single interface.  Here the scatter gather list
  * elements are each tagged with the appropriate dma address
  * and length.  They are obtained via sg_dma_{address,length}(SG).
diff -Nru a/include/asm-arm/elf.h b/include/asm-arm/elf.h
--- a/include/asm-arm/elf.h	Wed Apr 30 22:28:16 2003
+++ b/include/asm-arm/elf.h	Wed Apr 30 22:28:16 2003
@@ -6,6 +6,7 @@
  */
 
 #include <asm/ptrace.h>
+#include <asm/user.h>
 #include <asm/proc/elf.h>
 #include <asm/procinfo.h>
 
@@ -18,7 +19,7 @@
 #define ELF_NGREG (sizeof (struct pt_regs) / sizeof(elf_greg_t))
 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
-typedef struct { void *null; } elf_fpregset_t;
+typedef struct user_fp elf_fpregset_t;
 
 /*
  * This is used to ensure we don't load something for the wrong architecture.
diff -Nru a/include/asm-arm/hardirq.h b/include/asm-arm/hardirq.h
--- a/include/asm-arm/hardirq.h	Wed Apr 30 22:28:10 2003
+++ b/include/asm-arm/hardirq.h	Wed Apr 30 22:28:10 2003
@@ -77,11 +77,14 @@
 #endif
 
 #ifndef CONFIG_SMP
+/*
+ * Some compilers get the use of "%?" wrong in the asm below.
+ */
 #define irq_exit()							\
 	do {								\
 		preempt_count() -= IRQ_EXIT_OFFSET;			\
 		if (!in_interrupt() && softirq_pending(smp_processor_id())) \
-			__asm__("bl%? __do_softirq": : : "lr");/* out of line */\
+			__asm__("bl	__do_softirq": : : "lr", "cc");/* out of line */\
 		preempt_enable_no_resched();				\
 	} while (0)
 
diff -Nru a/include/asm-arm/irq.h b/include/asm-arm/irq.h
--- a/include/asm-arm/irq.h	Wed Apr 30 22:28:20 2003
+++ b/include/asm-arm/irq.h	Wed Apr 30 22:28:20 2003
@@ -3,8 +3,8 @@
 
 #include <asm/arch/irqs.h>
 
-#ifndef irq_cannonicalize
-#define irq_cannonicalize(i)	(i)
+#ifndef irq_canonicalize
+#define irq_canonicalize(i)	(i)
 #endif
 
 #ifndef NR_IRQS
diff -Nru a/include/asm-arm/proc-armo/pgalloc.h b/include/asm-arm/proc-armo/pgalloc.h
--- a/include/asm-arm/proc-armo/pgalloc.h	Wed Apr 30 22:28:15 2003
+++ b/include/asm-arm/proc-armo/pgalloc.h	Wed Apr 30 22:28:15 2003
@@ -37,7 +37,7 @@
 
 /*
  * We use the old 2.5.5-rmk1 hack for this.
- * This is not truely correct, but should be functional.
+ * This is not truly correct, but should be functional.
  */
 #define pte_alloc_one(mm,addr)	((struct page *)pte_alloc_one_kernel(mm,addr))
 #define pte_free(pte)		pte_free_kernel((pte_t *)pte)
diff -Nru a/include/asm-arm/proc-armv/cache.h b/include/asm-arm/proc-armv/cache.h
--- a/include/asm-arm/proc-armv/cache.h	Wed Apr 30 22:28:08 2003
+++ b/include/asm-arm/proc-armv/cache.h	Wed Apr 30 22:28:08 2003
@@ -11,64 +11,236 @@
 #include <asm/glue.h>
 
 /*
+ *	Cache Model
+ *	===========
+ */
+#undef _CACHE
+#undef MULTI_CACHE
+
+#if defined(CONFIG_CPU_ARM610) || defined(CONFIG_CPU_ARM710)
+# ifdef _CACHE
+#  define MULTI_CACHE 1
+# else
+#  define _CACHE v3
+# endif
+#endif
+
+#if defined(CONFIG_CPU_ARM720T)
+# ifdef _CACHE
+#  define MULTI_CACHE 1
+# else
+#  define _CACHE v4
+# endif
+#endif
+
+#if defined(CONFIG_CPU_ARM920T) || defined(CONFIG_CPU_ARM922T) || \
+    defined(CONFIG_CPU_ARM1020)
+# define MULTI_CACHE 1
+#endif
+
+#if defined(CONFIG_CPU_ARM926T)
+# ifdef _CACHE
+#  define MULTI_CACHE 1
+# else
+#  define _CACHE arm926
+# endif
+#endif
+
+#if defined(CONFIG_CPU_SA110) || defined(CONFIG_CPU_SA1100)
+# ifdef _CACHE
+#  define MULTI_CACHE 1
+# else
+#  define _CACHE v4wb
+# endif
+#endif
+
+#if defined(CONFIG_CPU_XSCALE)
+# ifdef _CACHE
+#  define MULTI_CACHE 1
+# else
+#  define _CACHE xscale
+# endif
+#endif
+
+#if !defined(_CACHE) && !defined(MULTI_CACHE)
+#error Unknown cache maintainence model
+#endif
+
+/*
  * This flag is used to indicate that the page pointed to by a pte
  * is dirty and requires cleaning before returning it to the user.
  */
 #define PG_dcache_dirty PG_arch_1
 
 /*
- * Cache handling for 32-bit ARM processors.
+ *	MM Cache Management
+ *	===================
+ *
+ *	The arch/arm/mm/cache-*.S and arch/arm/mm/proc-*.S files
+ *	implement these methods.
+ *
+ *	Start addresses are inclusive and end addresses are exclusive;
+ *	start addresses should be rounded down, end addresses up.
+ *
+ *	See linux/Documentation/cachetlb.txt for more information.
+ *	Please note that the implementation of these, and the required
+ *	effects are cache-type (VIVT/VIPT/PIPT) specific.
+ *
+ *	flush_cache_kern_all()
+ *
+ *		Unconditionally clean and invalidate the entire cache.
+ *
+ *	flush_cache_user_mm(mm)
+ *
+ *		Clean and invalidate all user space cache entries
+ *		before a change of page tables.
  *
- * Note that on ARM, we have a more accurate specification than that
- * Linux's "flush".  We therefore do not use "flush" here, but instead
- * use:
+ *	flush_cache_user_range(start, end, flags)
  *
- * clean:      the act of pushing dirty cache entries out to memory.
- * invalidate: the act of discarding data held within the cache,
- *             whether it is dirty or not.
+ *		Clean and invalidate a range of cache entries in the
+ *		specified address space before a change of page tables.
+ *		- start - user start address (inclusive, page aligned)
+ *		- end   - user end address   (exclusive, page aligned)
+ *		- flags - vma->vm_flags field
+ *
+ *	coherent_kern_range(start, end)
+ *
+ *		Ensure coherency between the Icache and the Dcache in the
+ *		region described by start, end.  If you have non-snooping
+ *		Harvard caches, you need to implement this function.
+ *		- start  - virtual start address
+ *		- end    - virtual end address
+ *
+ *	DMA Cache Coherency
+ *	===================
+ *
+ *	dma_inv_range(start, end)
+ *
+ *		Invalidate (discard) the specified virtual address range.
+ *		May not write back any entries.  If 'start' or 'end'
+ *		are not cache line aligned, those lines must be written
+ *		back.
+ *		- start  - virtual start address
+ *		- end    - virtual end address
+ *
+ *	dma_clean_range(start, end)
+ *
+ *		Clean (write back) the specified virtual address range.
+ *		- start  - virtual start address
+ *		- end    - virtual end address
+ *
+ *	dma_flush_range(start, end)
+ *
+ *		Clean and invalidate the specified virtual address range.
+ *		- start  - virtual start address
+ *		- end    - virtual end address
  */
 
+struct cpu_cache_fns {
+	void (*flush_kern_all)(void);
+	void (*flush_user_all)(void);
+	void (*flush_user_range)(unsigned long, unsigned long, unsigned int);
+
+	void (*coherent_kern_range)(unsigned long, unsigned long);
+	void (*flush_kern_dcache_page)(void *);
+
+	void (*dma_inv_range)(unsigned long, unsigned long);
+	void (*dma_clean_range)(unsigned long, unsigned long);
+	void (*dma_flush_range)(unsigned long, unsigned long);
+};
+
 /*
- * Generic I + D cache
+ * Select the calling method
  */
-#define flush_cache_all()						\
-	do {								\
-		cpu_cache_clean_invalidate_all();			\
-	} while (0)
+#ifdef MULTI_CACHE
 
-/* This is always called for current->mm */
-#define flush_cache_mm(_mm)						\
-	do {								\
-		if ((_mm) == current->active_mm)			\
-			cpu_cache_clean_invalidate_all();		\
-	} while (0)
+extern struct cpu_cache_fns cpu_cache;
 
-#define flush_cache_range(_vma,_start,_end)				\
-	do {								\
-		if ((_vma)->vm_mm == current->active_mm)		\
-			cpu_cache_clean_invalidate_range((_start), (_end), 1); \
-	} while (0)
+#define __cpuc_flush_kern_all		cpu_cache.flush_kern_all
+#define __cpuc_flush_user_all		cpu_cache.flush_user_all
+#define __cpuc_flush_user_range		cpu_cache.flush_user_range
+#define __cpuc_coherent_kern_range	cpu_cache.coherent_kern_range
+#define __cpuc_flush_dcache_page	cpu_cache.flush_kern_dcache_page
 
-#define flush_cache_page(_vma,_vmaddr)					\
-	do {								\
-		if ((_vma)->vm_mm == current->active_mm) {		\
-			cpu_cache_clean_invalidate_range((_vmaddr),	\
-				(_vmaddr) + PAGE_SIZE,			\
-				((_vma)->vm_flags & VM_EXEC));		\
-		} \
-	} while (0)
+/*
+ * These are private to the dma-mapping API.  Do not use directly.
+ * Their sole purpose is to ensure that data held in the cache
+ * is visible to DMA, or data written by DMA to system memory is
+ * visible to the CPU.
+ */
+#define dmac_inv_range			cpu_cache.dma_inv_range
+#define dmac_clean_range		cpu_cache.dma_clean_range
+#define dmac_flush_range		cpu_cache.dma_flush_range
+
+#else
+
+#define __cpuc_flush_kern_all		__glue(_CACHE,_flush_kern_cache_all)
+#define __cpuc_flush_user_all		__glue(_CACHE,_flush_user_cache_all)
+#define __cpuc_flush_user_range		__glue(_CACHE,_flush_user_cache_range)
+#define __cpuc_coherent_kern_range	__glue(_CACHE,_coherent_kern_range)
+#define __cpuc_flush_dcache_page	__glue(_CACHE,_flush_kern_dcache_page)
+
+extern void __cpuc_flush_kern_all(void);
+extern void __cpuc_flush_user_all(void);
+extern void __cpuc_flush_user_range(unsigned long, unsigned long, unsigned int);
+extern void __cpuc_coherent_kern_range(unsigned long, unsigned long);
+extern void __cpuc_flush_dcache_page(void *);
 
 /*
- * D cache only
+ * These are private to the dma-mapping API.  Do not use directly.
+ * Their sole purpose is to ensure that data held in the cache
+ * is visible to DMA, or data written by DMA to system memory is
+ * visible to the CPU.
  */
+#define dmac_inv_range			__glue(_CACHE,_dma_inv_range)
+#define dmac_clean_range		__glue(_CACHE,_dma_clean_range)
+#define dmac_flush_range		__glue(_CACHE,_dma_flush_range)
+
+extern void dmac_inv_range(unsigned long, unsigned long);
+extern void dmac_clean_range(unsigned long, unsigned long);
+extern void dmac_flush_range(unsigned long, unsigned long);
+
+#endif
 
-#define invalidate_dcache_range(_s,_e)	cpu_dcache_invalidate_range((_s),(_e))
-#define clean_dcache_range(_s,_e)	cpu_dcache_clean_range((_s),(_e))
-#define flush_dcache_range(_s,_e)	cpu_cache_clean_invalidate_range((_s),(_e),0)
+/*
+ * Convert calls to our calling convention.
+ */
+#define flush_cache_all()		__cpuc_flush_kern_all()
 
-#define clean_dcache_area(start,size) \
-	cpu_cache_clean_invalidate_range((unsigned long)start, \
-					 ((unsigned long)start) + size, 0);
+static inline void flush_cache_mm(struct mm_struct *mm)
+{
+	if (current->active_mm == mm)
+		__cpuc_flush_user_all();
+}
+
+static inline void
+flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end)
+{
+	if (current->active_mm == vma->vm_mm)
+		__cpuc_flush_user_range(start & PAGE_MASK, PAGE_ALIGN(end),
+					vma->vm_flags);
+}
+
+static inline void
+flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr)
+{
+	if (current->active_mm == vma->vm_mm) {
+		unsigned long addr = user_addr & PAGE_MASK;
+		__cpuc_flush_user_range(addr, addr + PAGE_SIZE, vma->vm_flags);
+	}
+}
+
+/*
+ * Perform necessary cache operations to ensure that data previously
+ * stored within this range of addresses can be executed by the CPU.
+ */
+#define flush_icache_range(s,e)		__cpuc_coherent_kern_range(s,e)
+
+/*
+ * Perform necessary cache operations to ensure that the TLB will
+ * see data written in the specified area.
+ */
+#define clean_dcache_area(start,size)	cpu_dcache_clean_area(start, size)
 
 /*
  * flush_dcache_page is used when the kernel has written to the page
@@ -104,18 +276,3 @@
  * duplicate cache flushing elsewhere performed by flush_dcache_page().
  */
 #define flush_icache_page(vma,page)	do { } while (0)
-
-/*
- * I cache coherency stuff.
- *
- * This *is not* just icache.  It is to make data written to memory
- * consistent such that instructions fetched from the region are what
- * we expect.
- *
- * This generally means that we have to clean out the Dcache and write
- * buffers, and maybe flush the Icache in the specified range.
- */
-#define flush_icache_range(_s,_e)					\
-	do {								\
-		cpu_icache_invalidate_range((_s), (_e));		\
-	} while (0)
diff -Nru a/include/asm-arm/proc-armv/locks.h b/include/asm-arm/proc-armv/locks.h
--- a/include/asm-arm/proc-armv/locks.h	Wed Apr 30 22:28:17 2003
+++ b/include/asm-arm/proc-armv/locks.h	Wed Apr 30 22:28:17 2003
@@ -67,7 +67,7 @@
 "	blle	" #wake				\
 	:					\
 	: "r" (ptr), "I" (1)			\
-	: "ip", "lr", "cc");			\
+	: "ip", "lr", "cc", "memory");		\
 	})
 
 /*
@@ -133,7 +133,7 @@
 "	bleq	" #wake				\
 	:					\
 	: "r" (ptr), "I" (1)			\
-	: "ip", "lr", "cc");			\
+	: "ip", "lr", "cc", "memory");		\
 	})
 
 #endif
diff -Nru a/include/asm-arm/proc-armv/pgalloc.h b/include/asm-arm/proc-armv/pgalloc.h
--- a/include/asm-arm/proc-armv/pgalloc.h	Wed Apr 30 22:28:09 2003
+++ b/include/asm-arm/proc-armv/pgalloc.h	Wed Apr 30 22:28:09 2003
@@ -6,6 +6,7 @@
  * Page table allocation/freeing primitives for 32-bit ARM processors.
  */
 #include <asm/cacheflush.h>
+#include <asm/tlbflush.h>
 #include "pgtable.h"
 
 /*
@@ -27,17 +28,9 @@
 static inline pte_t *
 pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)
 {
-	int count = 0;
 	pte_t *pte;
 
-	do {
-		pte = (pte_t *)__get_free_page(GFP_KERNEL);
-		if (!pte) {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pte && (count++ < 10));
-
+	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (pte) {
 		clear_page(pte);
 		clean_dcache_area(pte, sizeof(pte_t) * PTRS_PER_PTE);
@@ -51,16 +44,8 @@
 pte_alloc_one(struct mm_struct *mm, unsigned long addr)
 {
 	struct page *pte;
-	int count = 0;
-
-	do {
-		pte = alloc_pages(GFP_KERNEL, 0);
-		if (!pte) {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pte && (count++ < 10));
 
+	pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
 	if (pte) {
 		void *page = page_address(pte);
 		clear_page(page);
@@ -108,7 +93,7 @@
 	pmdval = __pa(pte_ptr) | _PAGE_KERNEL_TABLE;
 	pmdp[0] = __pmd(pmdval);
 	pmdp[1] = __pmd(pmdval + 256 * sizeof(pte_t));
-	cpu_flush_pmd(pmdp);
+	flush_pmd_entry(pmdp);
 }
 
 static inline void
@@ -121,5 +106,5 @@
 	pmdval = page_to_pfn(ptep) << PAGE_SHIFT | _PAGE_USER_TABLE;
 	pmdp[0] = __pmd(pmdval);
 	pmdp[1] = __pmd(pmdval + 256 * sizeof(pte_t));
-	cpu_flush_pmd(pmdp);
+	flush_pmd_entry(pmdp);
 }
diff -Nru a/include/asm-arm/proc-armv/pgtable.h b/include/asm-arm/proc-armv/pgtable.h
--- a/include/asm-arm/proc-armv/pgtable.h	Wed Apr 30 22:28:04 2003
+++ b/include/asm-arm/proc-armv/pgtable.h	Wed Apr 30 22:28:04 2003
@@ -51,6 +51,7 @@
 #define PMD_SECT_TEX(x)		((x) << 12)	/* v5 */
 
 #define PMD_SECT_UNCACHED	(0)
+#define PMD_SECT_BUFFERED	(PMD_SECT_BUFFERABLE)
 #define PMD_SECT_WT		(PMD_SECT_CACHEABLE)
 #define PMD_SECT_WB		(PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE)
 #define PMD_SECT_MINICACHE	(PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE)
@@ -120,14 +121,19 @@
 #define _PAGE_KERNEL_TABLE	(PMD_TYPE_TABLE | PMD_BIT4 | PMD_DOMAIN(DOMAIN_KERNEL))
 
 #define pmd_bad(pmd)		(pmd_val(pmd) & 2)
-#define set_pmd(pmdp,pmd)	do { *pmdp = pmd; cpu_flush_pmd(pmdp); } while (0)
 
-static inline void pmd_clear(pmd_t *pmdp)
-{
-	pmdp[0] = __pmd(0);
-	pmdp[1] = __pmd(0);
-	cpu_flush_pmd(pmdp);
-}
+#define set_pmd(pmdp,pmd)		\
+	do {				\
+		*pmdp = pmd;		\
+		flush_pmd_entry(pmdp);	\
+	} while (0)
+
+#define pmd_clear(pmdp)			\
+	do {				\
+		pmdp[0] = __pmd(0);	\
+		pmdp[1] = __pmd(0);	\
+		clean_pmd_entry(pmdp);	\
+	} while (0)
 
 static inline pte_t *pmd_page_kernel(pmd_t pmd)
 {
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	Wed Apr 30 22:28:03 2003
+++ b/include/asm-arm/proc-armv/system.h	Wed Apr 30 22:28:03 2003
@@ -15,12 +15,16 @@
 #define set_cr(x)					\
 	__asm__ __volatile__(				\
 	"mcr	p15, 0, %0, c1, c0, 0	@ set CR"	\
-	: : "r" (x))
+	: : "r" (x) : "cc")
 
-#define get_cr(x)					\
+#define get_cr()					\
+	({						\
+	unsigned int __val;				\
 	__asm__ __volatile__(				\
 	"mrc	p15, 0, %0, c1, c0, 0	@ get CR"	\
-	: "=r" (x))
+	: "=r" (__val) : : "cc");			\
+	__val;						\
+	})
 
 #define CR_M	(1 << 0)	/* MMU enable				*/
 #define CR_A	(1 << 1)	/* Alignment abort enable		*/
@@ -48,16 +52,6 @@
 #endif
 
 /*
- * Save the current interrupt enable state.
- */
-#define local_save_flags(x)					\
-	({							\
-	__asm__ __volatile__(					\
-	"mrs	%0, cpsr		@ local_save_flags"	\
-	: "=r" (x) : : "memory");				\
-	})
-
-/*
  * Save the current interrupt enable state & disable IRQs
  */
 #define local_irq_save(x)					\
@@ -70,7 +64,7 @@
 "	msr	cpsr_c, %1"					\
 	: "=r" (x), "=r" (temp)					\
 	:							\
-	: "memory");						\
+	: "memory", "cc");					\
 	})
 	
 /*
@@ -85,7 +79,7 @@
 "	msr	cpsr_c, %0"					\
 	: "=r" (temp)						\
 	:							\
-	: "memory");						\
+	: "memory", "cc");					\
 	})
 
 /*
@@ -100,7 +94,7 @@
 "	msr	cpsr_c, %0"					\
 	: "=r" (temp)						\
 	:							\
-	: "memory");						\
+	: "memory", "cc");					\
 	})
 
 /*
@@ -115,7 +109,7 @@
 "	msr	cpsr_c, %0"					\
 	: "=r" (temp)						\
 	:							\
-	: "memory");						\
+	: "memory", "cc");					\
 	})
 
 /*
@@ -130,7 +124,17 @@
 "	msr	cpsr_c, %0"					\
 	: "=r" (temp)						\
 	:							\
-	: "memory");						\
+	: "memory", "cc");					\
+	})
+
+/*
+ * Save the current interrupt enable state.
+ */
+#define local_save_flags(x)					\
+	({							\
+	__asm__ __volatile__(					\
+	"mrs	%0, cpsr		@ local_save_flags"	\
+	: "=r" (x) : : "memory", "cc");				\
 	})
 
 /*
@@ -141,7 +145,7 @@
 	"msr	cpsr_c, %0		@ local_irq_restore\n"	\
 	:							\
 	: "r" (x)						\
-	: "memory")
+	: "memory", "cc")
 
 #if defined(CONFIG_CPU_SA1100) || defined(CONFIG_CPU_SA110)
 /*
@@ -186,12 +190,12 @@
 		case 1:	__asm__ __volatile__ ("swpb %0, %1, [%2]"
 					: "=&r" (ret)
 					: "r" (x), "r" (ptr)
-					: "memory");
+					: "memory", "cc");
 			break;
 		case 4:	__asm__ __volatile__ ("swp %0, %1, [%2]"
 					: "=&r" (ret)
 					: "r" (x), "r" (ptr)
-					: "memory");
+					: "memory", "cc");
 			break;
 #endif
 		default: __bad_xchg(ptr, size), ret = 0;
diff -Nru a/include/asm-arm/proc-armv/tlbflush.h b/include/asm-arm/proc-armv/tlbflush.h
--- a/include/asm-arm/proc-armv/tlbflush.h	Wed Apr 30 22:28:14 2003
+++ b/include/asm-arm/proc-armv/tlbflush.h	Wed Apr 30 22:28:14 2003
@@ -20,6 +20,7 @@
 #define TLB_V4_D_FULL	(1 << 10)
 #define TLB_V4_I_FULL	(1 << 11)
 
+#define TLB_DCLEAN	(1 << 30)
 #define TLB_WB		(1 << 31)
 
 /*
@@ -65,7 +66,7 @@
 # define v4_always_flags	(-1UL)
 #endif
 
-#define v4wbi_tlb_flags	(TLB_WB | \
+#define v4wbi_tlb_flags	(TLB_WB | TLB_DCLEAN | \
 			 TLB_V4_I_FULL | TLB_V4_D_FULL | \
 			 TLB_V4_I_PAGE | TLB_V4_D_PAGE)
 
@@ -84,7 +85,7 @@
 # define v4wbi_always_flags	(-1UL)
 #endif
 
-#define v4wb_tlb_flags	(TLB_WB | \
+#define v4wb_tlb_flags	(TLB_WB | TLB_DCLEAN | \
 			 TLB_V4_I_FULL | TLB_V4_D_FULL | \
 			 TLB_V4_D_PAGE)
 
@@ -285,6 +286,41 @@
 		asm("mcr%? p15, 0, %0, c8, c5, 1" : : "r" (kaddr));
 	if (!tlb_flag(TLB_V4_I_PAGE) && tlb_flag(TLB_V4_I_FULL))
 		asm("mcr%? p15, 0, %0, c8, c5, 0" : : "r" (zero));
+}
+
+/*
+ *	flush_pmd_entry
+ *
+ *	Flush a PMD entry (word aligned, or double-word aligned) to
+ *	RAM if the TLB for the CPU we are running on requires this.
+ *	This is typically used when we are creating PMD entries.
+ *
+ *	clean_pmd_entry
+ *
+ *	Clean (but don't drain the write buffer) if the CPU requires
+ *	these operations.  This is typically used when we are removing
+ *	PMD entries.
+ */
+static inline void flush_pmd_entry(pmd_t *pmd)
+{
+	const unsigned int zero = 0;
+	const unsigned int __tlb_flag = __cpu_tlb_flags;
+
+	if (tlb_flag(TLB_DCLEAN))
+		asm("mcr%?	p15, 0, %0, c7, c10, 1	@ flush_pmd"
+			: : "r" (pmd));
+	if (tlb_flag(TLB_WB))
+		asm("mcr%?	p15, 0, %0, c7, c10, 4	@ flush_pmd"
+			: : "r" (zero));
+}
+
+static inline void clean_pmd_entry(pmd_t *pmd)
+{
+	const unsigned int __tlb_flag = __cpu_tlb_flags;
+
+	if (tlb_flag(TLB_DCLEAN))
+		asm("mcr%?	p15, 0, %0, c7, c10, 1	@ flush_pmd"
+			: : "r" (pmd));
 }
 
 #undef tlb_flag
diff -Nru a/include/asm-arm/procinfo.h b/include/asm-arm/procinfo.h
--- a/include/asm-arm/procinfo.h	Wed Apr 30 22:28:05 2003
+++ b/include/asm-arm/procinfo.h	Wed Apr 30 22:28:05 2003
@@ -14,6 +14,7 @@
 
 struct cpu_tlb_fns;
 struct cpu_user_fns;
+struct cpu_cache_fns;
 struct processor;
 
 /*
@@ -37,13 +38,14 @@
 	struct processor	*proc;
 	struct cpu_tlb_fns	*tlb;
 	struct cpu_user_fns	*user;
+	struct cpu_cache_fns	*cache;
 };
 
 extern unsigned int elf_hwcap;
 
 #endif	/* __ASSEMBLY__ */
 
-#define PROC_INFO_SZ	44
+#define PROC_INFO_SZ	48
 
 #define HWCAP_SWP	1
 #define HWCAP_HALF	2
diff -Nru a/include/asm-arm/setup.h b/include/asm-arm/setup.h
--- a/include/asm-arm/setup.h	Wed Apr 30 22:28:09 2003
+++ b/include/asm-arm/setup.h	Wed Apr 30 22:28:09 2003
@@ -202,4 +202,17 @@
 
 extern struct meminfo meminfo;
 
+/*
+ * Early command line parameters.
+ */
+struct early_params {
+	const char *arg;
+	void (*fn)(char **p);
+};
+
+#define __early_param(name,fn)				\
+static struct early_params __early_##fn			\
+__attribute__((section("__early_param"), unused)) =	\
+	{ name, fn }
+
 #endif
diff -Nru a/include/asm-arm/sizes.h b/include/asm-arm/sizes.h
--- a/include/asm-arm/sizes.h	Wed Apr 30 22:28:17 2003
+++ b/include/asm-arm/sizes.h	Wed Apr 30 22:28:17 2003
@@ -16,7 +16,7 @@
 /* DO NOT EDIT!! - this file automatically generated
  *                 from .s file by awk -f s2h.awk
  */
-/*  Size defintions
+/*  Size definitions
  *  Copyright (C) ARM Limited 1998. All rights reserved.
  */
 
diff -Nru a/include/asm-arm/tlb.h b/include/asm-arm/tlb.h
--- a/include/asm-arm/tlb.h	Wed Apr 30 22:28:03 2003
+++ b/include/asm-arm/tlb.h	Wed Apr 30 22:28:03 2003
@@ -18,6 +18,7 @@
 #define __ASMARM_TLB_H
 
 #include <asm/tlbflush.h>
+#include <asm/cacheflush.h>
 
 /*
  * TLB handling.  This allows us to remove pages from the page
@@ -26,6 +27,7 @@
 struct mmu_gather {
 	struct mm_struct	*mm;
 	unsigned int		freed;
+	unsigned int		fullmm;
 
 	unsigned int		flushes;
 	unsigned int		avoided_flushes;
@@ -41,6 +43,7 @@
 
 	tlb->mm = mm;
 	tlb->freed = 0;
+	tlb->fullmm = full_mm_flush;
 
 	return tlb;
 }
@@ -68,7 +71,13 @@
 }
 
 #define tlb_remove_tlb_entry(tlb,ptep,address)	do { } while (0)
-#define tlb_start_vma(tlb,vma)			do { } while (0)
+
+#define tlb_start_vma(tlb,vma)						\
+	do {								\
+		if (!tlb->fullmm)					\
+			flush_cache_range(vma, vma->vm_start, vma->vm_end); \
+	} while (0)
+
 #define tlb_end_vma(tlb,vma)			do { } while (0)
 
 #define tlb_remove_page(tlb,page)	free_page_and_swap_cache(page)
diff -Nru a/include/asm-cris/pgalloc.h b/include/asm-cris/pgalloc.h
--- a/include/asm-cris/pgalloc.h	Wed Apr 30 22:28:16 2003
+++ b/include/asm-cris/pgalloc.h	Wed Apr 30 22:28:16 2003
@@ -62,7 +62,7 @@
 {
         pte_t *pte;
 
-        pte = (pte_t *) __get_free_page(GFP_KERNEL);
+        pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
         if (pte)
                 clear_page(pte);
         return pte;
diff -Nru a/include/asm-h8300/irq.h b/include/asm-h8300/irq.h
--- a/include/asm-h8300/irq.h	Wed Apr 30 22:28:05 2003
+++ b/include/asm-h8300/irq.h	Wed Apr 30 22:28:05 2003
@@ -13,7 +13,7 @@
 
 #define IRQ_SCHED_TIMER	(40)    /* interrupt source for scheduling timer */
 
-static __inline__ int irq_cannonicalize(int irq)
+static __inline__ int irq_canonicalize(int irq)
 {
 	return irq;
 }
diff -Nru a/include/asm-i386/arch_hooks.h b/include/asm-i386/arch_hooks.h
--- a/include/asm-i386/arch_hooks.h	Wed Apr 30 22:28:11 2003
+++ b/include/asm-i386/arch_hooks.h	Wed Apr 30 22:28:11 2003
@@ -1,6 +1,8 @@
 #ifndef _ASM_ARCH_HOOKS_H
 #define _ASM_ARCH_HOOKS_H
 
+#include <linux/interrupt.h>
+
 /*
  *	linux/include/asm/arch_hooks.h
  *
@@ -12,7 +14,7 @@
 extern void init_ISA_irqs(void);
 extern void apic_intr_init(void);
 extern void smp_intr_init(void);
-extern void timer_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+extern irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 /* these are the defined hooks */
 extern void intr_init_hook(void);
diff -Nru a/include/asm-i386/bugs.h b/include/asm-i386/bugs.h
--- a/include/asm-i386/bugs.h	Wed Apr 30 22:28:05 2003
+++ b/include/asm-i386/bugs.h	Wed Apr 30 22:28:05 2003
@@ -200,6 +200,8 @@
 #endif
 }
 
+extern void alternative_instructions(void);
+
 static void __init check_bugs(void)
 {
 	identify_cpu(&boot_cpu_data);
@@ -212,4 +214,5 @@
 	check_hlt();
 	check_popad();
 	system_utsname.machine[1] = '0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86);
+	alternative_instructions(); 
 }
diff -Nru a/include/asm-i386/cpufeature.h b/include/asm-i386/cpufeature.h
--- a/include/asm-i386/cpufeature.h	Wed Apr 30 22:28:13 2003
+++ b/include/asm-i386/cpufeature.h	Wed Apr 30 22:28:13 2003
@@ -63,6 +63,11 @@
 #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) */
+/* cpu types for specific tunings: */
+#define X86_FEATURE_K8		(3*32+ 4) /* Opteron, Athlon64 */
+#define X86_FEATURE_K7		(3*32+ 5) /* Athlon */
+#define X86_FEATURE_P3		(3*32+ 6) /* P3 */
+#define X86_FEATURE_P4		(3*32+ 7) /* P4 */
 
 /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
 
diff -Nru a/include/asm-i386/div64.h b/include/asm-i386/div64.h
--- a/include/asm-i386/div64.h	Wed Apr 30 22:28:03 2003
+++ b/include/asm-i386/div64.h	Wed Apr 30 22:28:03 2003
@@ -14,4 +14,22 @@
 	__mod; \
 })
 
+/*
+ * (long)X = ((long long)divs) / (long)div
+ * (long)rem = ((long long)divs) % (long)div
+ *
+ * Warning, this will do an exception if X overflows.
+ */
+#define div_long_long_rem(a,b,c) div_ll_X_l_rem(a,b,c)
+
+extern inline long
+div_ll_X_l_rem(long long divs, long div, long *rem)
+{
+	long dum2;
+      __asm__("divl %2":"=a"(dum2), "=d"(*rem)
+      :	"rm"(div), "A"(divs));
+
+	return dum2;
+
+}
 #endif
diff -Nru a/include/asm-i386/floppy.h b/include/asm-i386/floppy.h
--- a/include/asm-i386/floppy.h	Wed Apr 30 22:28:06 2003
+++ b/include/asm-i386/floppy.h	Wed Apr 30 22:28:06 2003
@@ -51,7 +51,7 @@
 static int virtual_dma_mode;
 static int doing_pdma;
 
-static void floppy_hardint(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t floppy_hardint(int irq, void *dev_id, struct pt_regs * regs)
 {
 	register unsigned char st;
 
@@ -63,10 +63,8 @@
 	static int bytes=0;
 	static int dma_wait=0;
 #endif
-	if(!doing_pdma) {
-		floppy_interrupt(irq, dev_id, regs);
-		return;
-	}
+	if (!doing_pdma)
+		return floppy_interrupt(irq, dev_id, regs);
 
 #ifdef TRACE_FLPY_INT
 	if(!calls)
@@ -130,7 +128,7 @@
 	calls++;
 #endif
 	if(st == 0x20)
-		return;
+		return IRQ_HANDLED;
 	if(!(st & 0x20)) {
 		virtual_dma_residue += virtual_dma_count;
 		virtual_dma_count=0;
@@ -143,12 +141,13 @@
 #endif
 		doing_pdma = 0;
 		floppy_interrupt(irq, dev_id, regs);
-		return;
+		return IRQ_HANDLED;
 	}
 #ifdef TRACE_FLPY_INT
 	if(!virtual_dma_count)
 		dma_wait++;
 #endif
+	return IRQ_HANDLED;
 }
 
 static void fd_disable_dma(void)
diff -Nru a/include/asm-i386/irq.h b/include/asm-i386/irq.h
--- a/include/asm-i386/irq.h	Wed Apr 30 22:28:11 2003
+++ b/include/asm-i386/irq.h	Wed Apr 30 22:28:11 2003
@@ -15,7 +15,7 @@
 /* include comes from machine specific directory */
 #include "irq_vectors.h"
 
-static __inline__ int irq_cannonicalize(int irq)
+static __inline__ int irq_canonicalize(int irq)
 {
 	return ((irq == 2) ? 9 : irq);
 }
diff -Nru a/include/asm-i386/processor.h b/include/asm-i386/processor.h
--- a/include/asm-i386/processor.h	Wed Apr 30 22:28:04 2003
+++ b/include/asm-i386/processor.h	Wed Apr 30 22:28:04 2003
@@ -15,6 +15,7 @@
 #include <asm/sigcontext.h>
 #include <asm/cpufeature.h>
 #include <asm/msr.h>
+#include <asm/system.h>
 #include <linux/cache.h>
 #include <linux/config.h>
 #include <linux/threads.h>
@@ -495,32 +496,93 @@
 
 #define cpu_relax()	rep_nop()
 
-/* Prefetch instructions for Pentium III and AMD Athlon */
-#ifdef 	CONFIG_X86_PREFETCH
+/* generic versions from gas */
+#define GENERIC_NOP1	".byte 0x90\n"
+#define GENERIC_NOP2    	".byte 0x89,0xf6\n"
+#define GENERIC_NOP3        ".byte 0x8d,0x76,0x00\n"
+#define GENERIC_NOP4        ".byte 0x8d,0x74,0x26,0x00\n"
+#define GENERIC_NOP5        GENERIC_NOP1 GENERIC_NOP4
+#define GENERIC_NOP6	".byte 0x8d,0xb6,0x00,0x00,0x00,0x00\n"
+#define GENERIC_NOP7	".byte 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00\n"
+#define GENERIC_NOP8	GENERIC_NOP1 GENERIC_NOP7
+
+/* Opteron nops */
+#define K8_NOP1 GENERIC_NOP1
+#define K8_NOP2	".byte 0x66,0x90\n" 
+#define K8_NOP3	".byte 0x66,0x66,0x90\n" 
+#define K8_NOP4	".byte 0x66,0x66,0x66,0x90\n" 
+#define K8_NOP5	K8_NOP3 K8_NOP2 
+#define K8_NOP6	K8_NOP3 K8_NOP3
+#define K8_NOP7	K8_NOP4 K8_NOP3
+#define K8_NOP8	K8_NOP4 K8_NOP4
+
+/* K7 nops */
+/* uses eax dependencies (arbitary choice) */
+#define K7_NOP1  GENERIC_NOP1
+#define K7_NOP2	".byte 0x8b,0xc0\n" 
+#define K7_NOP3	".byte 0x8d,0x04,0x20\n"
+#define K7_NOP4	".byte 0x8d,0x44,0x20,0x00\n"
+#define K7_NOP5	K7_NOP4 ASM_NOP1
+#define K7_NOP6	".byte 0x8d,0x80,0,0,0,0\n"
+#define K7_NOP7        ".byte 0x8D,0x04,0x05,0,0,0,0\n"
+#define K7_NOP8        K7_NOP7 ASM_NOP1
+
+#ifdef CONFIG_MK8
+#define ASM_NOP1 K8_NOP1
+#define ASM_NOP2 K8_NOP2
+#define ASM_NOP3 K8_NOP3
+#define ASM_NOP4 K8_NOP4
+#define ASM_NOP5 K8_NOP5
+#define ASM_NOP6 K8_NOP6
+#define ASM_NOP7 K8_NOP7
+#define ASM_NOP8 K8_NOP8
+#elif CONFIG_MK7
+#define ASM_NOP1 K7_NOP1
+#define ASM_NOP2 K7_NOP2
+#define ASM_NOP3 K7_NOP3
+#define ASM_NOP4 K7_NOP4
+#define ASM_NOP5 K7_NOP5
+#define ASM_NOP6 K7_NOP6
+#define ASM_NOP7 K7_NOP7
+#define ASM_NOP8 K7_NOP8
+#else
+#define ASM_NOP1 GENERIC_NOP1
+#define ASM_NOP2 GENERIC_NOP2
+#define ASM_NOP3 GENERIC_NOP3
+#define ASM_NOP4 GENERIC_NOP4
+#define ASM_NOP5 GENERIC_NOP5
+#define ASM_NOP6 GENERIC_NOP6
+#define ASM_NOP7 GENERIC_NOP7
+#define ASM_NOP8 GENERIC_NOP8
+#endif
 
+#define ASM_NOP_MAX 8
+
+/* Prefetch instructions for Pentium III and AMD Athlon */
+/* It's not worth to care about 3dnow! prefetches for the K6
+   because they are microcoded there and very slow. */
 #define ARCH_HAS_PREFETCH
 extern inline void prefetch(const void *x)
 {
-	__asm__ __volatile__ ("prefetchnta (%0)" : : "r"(x));
+	alternative_input(ASM_NOP4,
+			  "prefetchnta (%1)",
+			  X86_FEATURE_XMM,
+			  "r" (x));
 }
 
-#elif defined CONFIG_X86_USE_3DNOW
-
 #define ARCH_HAS_PREFETCH
 #define ARCH_HAS_PREFETCHW
 #define ARCH_HAS_SPINLOCK_PREFETCH
 
-extern inline void prefetch(const void *x)
-{
-	 __asm__ __volatile__ ("prefetch (%0)" : : "r"(x));
-}
-
+/* 3dnow! prefetch to get an exclusive cache line. Useful for 
+   spinlocks to avoid one state transition in the cache coherency protocol. */
 extern inline void prefetchw(const void *x)
 {
-	 __asm__ __volatile__ ("prefetchw (%0)" : : "r"(x));
+	alternative_input(ASM_NOP4,
+			  "prefetchw (%1)",
+			  X86_FEATURE_3DNOW,
+			  "r" (x));
 }
 #define spin_lock_prefetch(x)	prefetchw(x)
-
-#endif
 
 #endif /* __ASM_I386_PROCESSOR_H */
diff -Nru a/include/asm-i386/system.h b/include/asm-i386/system.h
--- a/include/asm-i386/system.h	Wed Apr 30 22:28:03 2003
+++ b/include/asm-i386/system.h	Wed Apr 30 22:28:03 2003
@@ -4,6 +4,7 @@
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <asm/segment.h>
+#include <asm/cpufeature.h>
 #include <linux/bitops.h> /* for LOCK_PREFIX */
 
 #ifdef __KERNEL__
@@ -276,6 +277,67 @@
 /* Compiling for a 386 proper.	Is it worth implementing via cli/sti?  */
 #endif
 
+#ifdef __KERNEL__
+struct alt_instr { 
+	__u8 *instr; 		/* original instruction */
+	__u8 *replacement;
+	__u8  cpuid;		/* cpuid bit set for replacement */
+	__u8  instrlen;		/* length of original instruction */
+	__u8  replacementlen; 	/* length of new instruction, <= instrlen */ 
+	__u8  pad;
+}; 
+#endif
+
+/* 
+ * Alternative instructions for different CPU types or capabilities.
+ * 
+ * This allows to use optimized instructions even on generic binary
+ * kernels.
+ * 
+ * length of oldinstr must be longer or equal the length of newinstr
+ * It can be padded with nops as needed.
+ * 
+ * For non barrier like inlines please define new variants
+ * without volatile and memory clobber.
+ */
+#define alternative(oldinstr, newinstr, feature) 	\
+	asm volatile ("661:\n\t" oldinstr "\n662:\n" 		     \
+		      ".section .altinstructions,\"a\"\n"     	     \
+		      "  .align 4\n"				       \
+		      "  .long 661b\n"            /* label */          \
+		      "  .long 663f\n"		  /* new instruction */ 	\
+		      "  .byte %c0\n"             /* feature bit */    \
+		      "  .byte 662b-661b\n"       /* sourcelen */      \
+		      "  .byte 664f-663f\n"       /* replacementlen */ \
+		      ".previous\n"						\
+		      ".section .altinstr_replacement,\"ax\"\n"			\
+		      "663:\n\t" newinstr "\n664:\n"   /* replacement */    \
+		      ".previous" :: "i" (feature) : "memory")  
+
+/*
+ * Alternative inline assembly with input.
+ * 
+ * Pecularities:
+ * No memory clobber here. 
+ * Argument numbers start with 1.
+ * Best is to use constraints that are fixed size (like (%1) ... "r")
+ * If you use variable sized constraints like "m" or "g" in the 
+ * replacement maake sure to pad to the worst case length.
+ */
+#define alternative_input(oldinstr, newinstr, feature, input)			\
+	asm volatile ("661:\n\t" oldinstr "\n662:\n"				\
+		      ".section .altinstructions,\"a\"\n"			\
+		      "  .align 4\n"						\
+		      "  .long 661b\n"            /* label */			\
+		      "  .long 663f\n"		  /* new instruction */ 	\
+		      "  .byte %c0\n"             /* feature bit */		\
+		      "  .byte 662b-661b\n"       /* sourcelen */		\
+		      "  .byte 664f-663f\n"       /* replacementlen */ 		\
+		      ".previous\n"						\
+		      ".section .altinstr_replacement,\"ax\"\n"			\
+		      "663:\n\t" newinstr "\n664:\n"   /* replacement */ 	\
+		      ".previous" :: "i" (feature), input)  
+
 /*
  * Force strict CPU ordering.
  * And yes, this is required on UP too when we're talking
@@ -294,13 +356,15 @@
  * nop for these.
  */
  
-#ifdef CONFIG_X86_SSE2
-#define mb()	asm volatile("mfence" ::: "memory")
-#define rmb()	asm volatile("lfence" ::: "memory")
-#else
-#define mb() 	__asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
-#define rmb()	mb()
-#endif
+
+/* 
+ * Actually only lfence would be needed for mb() because all stores done 
+ * by the kernel should be already ordered. But keep a full barrier for now. 
+ */
+
+#define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2)
+#define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2)
+
 /**
  * read_barrier_depends - Flush all pending reads that subsequents reads
  * depend on.
@@ -356,7 +420,9 @@
 #define read_barrier_depends()	do { } while(0)
 
 #ifdef CONFIG_X86_OOSTORE
-#define wmb() 	__asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
+/* Actually there are no OOO store capable CPUs for now that do SSE, 
+   but make it already an possibility. */
+#define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM)
 #else
 #define wmb()	__asm__ __volatile__ ("": : :"memory")
 #endif
diff -Nru a/include/asm-ia64/irq.h b/include/asm-ia64/irq.h
--- a/include/asm-ia64/irq.h	Wed Apr 30 22:28:19 2003
+++ b/include/asm-ia64/irq.h	Wed Apr 30 22:28:19 2003
@@ -6,7 +6,7 @@
  *	David Mosberger-Tang <davidm@hpl.hp.com>
  *	Stephane Eranian <eranian@hpl.hp.com>
  *
- * 11/24/98	S.Eranian 	updated TIMER_IRQ and irq_cannonicalize
+ * 11/24/98	S.Eranian 	updated TIMER_IRQ and irq_canonicalize
  * 01/20/99	S.Eranian	added keyboard interrupt
  * 02/29/00     D.Mosberger	moved most things into hw_irq.h
  */
@@ -14,7 +14,7 @@
 #define NR_IRQS		256
 
 static __inline__ int
-irq_cannonicalize (int irq)
+irq_canonicalize (int irq)
 {
 	/*
 	 * We do the legacy thing here of pretending that irqs < 16
diff -Nru a/include/asm-ia64/pgalloc.h b/include/asm-ia64/pgalloc.h
--- a/include/asm-ia64/pgalloc.h	Wed Apr 30 22:28:03 2003
+++ b/include/asm-ia64/pgalloc.h	Wed Apr 30 22:28:03 2003
@@ -93,7 +93,7 @@
 static inline pmd_t*
 pmd_alloc_one (struct mm_struct *mm, unsigned long addr)
 {
-	pmd_t *pmd = (pmd_t *) __get_free_page(GFP_KERNEL);
+	pmd_t *pmd = (pmd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 
 	if (likely(pmd != NULL))
 		clear_page(pmd);
@@ -125,7 +125,7 @@
 static inline struct page *
 pte_alloc_one (struct mm_struct *mm, unsigned long addr)
 {
-	struct page *pte = alloc_pages(GFP_KERNEL, 0);
+	struct page *pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
 
 	if (likely(pte != NULL))
 		clear_page(page_address(pte));
@@ -135,7 +135,7 @@
 static inline pte_t *
 pte_alloc_one_kernel (struct mm_struct *mm, unsigned long addr)
 {
-	pte_t *pte = (pte_t *) __get_free_page(GFP_KERNEL);
+	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 
 	if (likely(pte != NULL))
 		clear_page(pte);
diff -Nru a/include/asm-m68k/irq.h b/include/asm-m68k/irq.h
--- a/include/asm-m68k/irq.h	Wed Apr 30 22:28:12 2003
+++ b/include/asm-m68k/irq.h	Wed Apr 30 22:28:12 2003
@@ -45,7 +45,7 @@
 
 #define IRQ_SCHED_TIMER	(8)    /* interrupt source for scheduling timer */
 
-static __inline__ int irq_cannonicalize(int irq)
+static __inline__ int irq_canonicalize(int irq)
 {
 	return irq;
 }
diff -Nru a/include/asm-m68k/motorola_pgalloc.h b/include/asm-m68k/motorola_pgalloc.h
--- a/include/asm-m68k/motorola_pgalloc.h	Wed Apr 30 22:28:20 2003
+++ b/include/asm-m68k/motorola_pgalloc.h	Wed Apr 30 22:28:20 2003
@@ -11,7 +11,7 @@
 {
 	pte_t *pte;
 
-	pte = (pte_t *) __get_free_page(GFP_KERNEL);
+	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (pte) {
 		clear_page(pte);
 		__flush_page_to_ram(pte);
@@ -30,7 +30,7 @@
 
 static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	struct page *page = alloc_pages(GFP_KERNEL, 0);
+	struct page *page = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
 	pte_t *pte;
 
 	if(!page)
diff -Nru a/include/asm-m68k/sun3_pgalloc.h b/include/asm-m68k/sun3_pgalloc.h
--- a/include/asm-m68k/sun3_pgalloc.h	Wed Apr 30 22:28:08 2003
+++ b/include/asm-m68k/sun3_pgalloc.h	Wed Apr 30 22:28:08 2003
@@ -39,7 +39,7 @@
 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 
 					  unsigned long address)
 {
-	unsigned long page = __get_free_page(GFP_KERNEL);
+	unsigned long page = __get_free_page(GFP_KERNEL|__GFP_REPEAT);
 
 	if (!page)
 		return NULL;
@@ -51,7 +51,7 @@
 static inline struct page *pte_alloc_one(struct mm_struct *mm, 
 					 unsigned long address)
 {
-        struct page *page = alloc_pages(GFP_KERNEL, 0);
+        struct page *page = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
 
 	if (page == NULL)
 		return NULL;
diff -Nru a/include/asm-mips/irq.h b/include/asm-mips/irq.h
--- a/include/asm-mips/irq.h	Wed Apr 30 22:28:04 2003
+++ b/include/asm-mips/irq.h	Wed Apr 30 22:28:04 2003
@@ -16,12 +16,12 @@
 #define TIMER_IRQ 0
 
 #ifdef CONFIG_I8259
-static inline int irq_cannonicalize(int irq)
+static inline int irq_canonicalize(int irq)
 {
 	return ((irq == 2) ? 9 : irq);
 }
 #else
-#define irq_cannonicalize(irq) (irq)	/* Sane hardware, sane code ... */
+#define irq_canonicalize(irq) (irq)	/* Sane hardware, sane code ... */
 #endif
 
 struct irqaction;
diff -Nru a/include/asm-mips/pgalloc.h b/include/asm-mips/pgalloc.h
--- a/include/asm-mips/pgalloc.h	Wed Apr 30 22:28:10 2003
+++ b/include/asm-mips/pgalloc.h	Wed Apr 30 22:28:10 2003
@@ -132,7 +132,7 @@
 {
 	pte_t *pte;
 
-	pte = (pte_t *) __get_free_page(GFP_KERNEL);
+	pte = (pte_t *) __get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (pte)
 		clear_page(pte);
 	return pte;
diff -Nru a/include/asm-mips64/irq.h b/include/asm-mips64/irq.h
--- a/include/asm-mips64/irq.h	Wed Apr 30 22:28:07 2003
+++ b/include/asm-mips64/irq.h	Wed Apr 30 22:28:07 2003
@@ -34,12 +34,12 @@
 			(node_level_to_irq[CPUID_TO_COMPACT_NODEID(c)][(l)])
 
 #ifdef CONFIG_I8259
-static inline int irq_cannonicalize(int irq)
+static inline int irq_canonicalize(int irq)
 {
 	return ((irq == 2) ? 9 : irq);
 }
 #else
-#define irq_cannonicalize(irq) (irq)	/* Sane hardware, sane code ... */
+#define irq_canonicalize(irq) (irq)	/* Sane hardware, sane code ... */
 #endif
 
 
diff -Nru a/include/asm-mips64/pgalloc.h b/include/asm-mips64/pgalloc.h
--- a/include/asm-mips64/pgalloc.h	Wed Apr 30 22:28:15 2003
+++ b/include/asm-mips64/pgalloc.h	Wed Apr 30 22:28:15 2003
@@ -93,7 +93,7 @@
 {
 	pte_t *pte;
 
-	pte = (pte_t *) __get_free_page(GFP_KERNEL);
+	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (pte)
 		clear_page(pte);
 	return pte;
@@ -141,7 +141,7 @@
 {
 	pmd_t *pmd;
 
-	pmd = (pmd_t *) __get_free_pages(GFP_KERNEL, 1);
+	pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT, 1);
 	if (pmd)
 		pmd_init((unsigned long)pmd, (unsigned long)invalid_pte_table);
 	return pmd;
diff -Nru a/include/asm-parisc/irq.h b/include/asm-parisc/irq.h
--- a/include/asm-parisc/irq.h	Wed Apr 30 22:28:07 2003
+++ b/include/asm-parisc/irq.h	Wed Apr 30 22:28:07 2003
@@ -66,7 +66,7 @@
 
 extern struct irq_region *irq_region[NR_IRQ_REGS];
 
-static __inline__ int irq_cannonicalize(int irq)
+static __inline__ int irq_canonicalize(int irq)
 {
 #ifdef CONFIG_EISA
 	return (irq == (IRQ_FROM_REGION(EISA_IRQ_REGION)+2) 
diff -Nru a/include/asm-parisc/pgalloc.h b/include/asm-parisc/pgalloc.h
--- a/include/asm-parisc/pgalloc.h	Wed Apr 30 22:28:18 2003
+++ b/include/asm-parisc/pgalloc.h	Wed Apr 30 22:28:18 2003
@@ -35,7 +35,7 @@
 
 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	pmd_t *pmd = (pmd_t *) __get_free_page(GFP_KERNEL);
+	pmd_t *pmd = (pmd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (pmd)
 		clear_page(pmd);
 	return pmd;
@@ -73,7 +73,7 @@
 static inline struct page *
 pte_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	struct page *page = alloc_page(GFP_KERNEL);
+	struct page *page = alloc_page(GFP_KERNEL|__GFP_REPEAT);
 	if (likely(page != NULL))
 		clear_page(page_address(page));
 	return page;
@@ -82,7 +82,7 @@
 static inline pte_t *
 pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)
 {
-	pte_t *pte = (pte_t *) __get_free_page(GFP_KERNEL);
+	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (likely(pte != NULL))
 		clear_page(pte);
 	return pte;
diff -Nru a/include/asm-ppc/bug.h b/include/asm-ppc/bug.h
--- a/include/asm-ppc/bug.h	Wed Apr 30 22:28:14 2003
+++ b/include/asm-ppc/bug.h	Wed Apr 30 22:28:14 2003
@@ -2,7 +2,7 @@
 #define _PPC_BUG_H
 
 #include <linux/config.h>
-#include <asm/system.h> /* for xmon definition */
+#include <asm/xmon.h>
 
 #ifdef CONFIG_XMON
 extern void xmon(struct pt_regs *);
diff -Nru a/include/asm-ppc/cputable.h b/include/asm-ppc/cputable.h
--- a/include/asm-ppc/cputable.h	Wed Apr 30 22:28:08 2003
+++ b/include/asm-ppc/cputable.h	Wed Apr 30 22:28:08 2003
@@ -74,6 +74,7 @@
 #define CPU_FTR_NAP_DISABLE_L2_PR	0x00002000
 #define CPU_FTR_DUAL_PLL_750FX		0x00004000
 #define CPU_FTR_NO_DPM			0x00008000
+#define CPU_FTR_HAS_HIGH_BATS		0x00010000
 
 #ifdef __ASSEMBLY__
 
diff -Nru a/include/asm-ppc/delay.h b/include/asm-ppc/delay.h
--- a/include/asm-ppc/delay.h	Wed Apr 30 22:28:12 2003
+++ b/include/asm-ppc/delay.h	Wed Apr 30 22:28:12 2003
@@ -31,7 +31,7 @@
  *  -- paulus
  */
 #define __MAX_UDELAY	(226050910/HZ)	/* maximum udelay argument */
-#define __MAX_NDELAY	(4294967295/HZ)	/* maximum ndelay argument */
+#define __MAX_NDELAY	(2147483647/HZ)	/* maximum ndelay argument */
 
 extern __inline__ void __udelay(unsigned int x)
 {
diff -Nru a/include/asm-ppc/irq.h b/include/asm-ppc/irq.h
--- a/include/asm-ppc/irq.h	Wed Apr 30 22:28:04 2003
+++ b/include/asm-ppc/irq.h	Wed Apr 30 22:28:04 2003
@@ -66,7 +66,7 @@
 #define NR_IRQS		((NR_UIC_IRQS * NR_UICS) + NR_BOARD_IRQS)
 #endif
 static __inline__ int
-irq_cannonicalize(int irq)
+irq_canonicalize(int irq)
 {
 	return (irq);
 }
@@ -78,7 +78,7 @@
 #define	NR_IRQS		(NR_UIC_IRQS + NR_BOARD_IRQS)
 
 static __inline__ int
-irq_cannonicalize(int irq)
+irq_canonicalize(int irq)
 {
 	return (irq);
 }
@@ -148,7 +148,7 @@
 #define	mk_int_int_mask(IL) (1 << (7 - (IL/2)))
 
 /* always the same on 8xx -- Cort */
-static __inline__ int irq_cannonicalize(int irq)
+static __inline__ int irq_canonicalize(int irq)
 {
 	return irq;
 }
@@ -196,10 +196,10 @@
  * powermacs as well as prep/chrp boxes.
  * Prep and chrp both have cascaded 8259 PICs.
  */
-static __inline__ int irq_cannonicalize(int irq)
+static __inline__ int irq_canonicalize(int irq)
 {
-	if (ppc_md.irq_cannonicalize)
-		return ppc_md.irq_cannonicalize(irq);
+	if (ppc_md.irq_canonicalize)
+		return ppc_md.irq_canonicalize(irq);
 	return irq;
 }
 
diff -Nru a/include/asm-ppc/machdep.h b/include/asm-ppc/machdep.h
--- a/include/asm-ppc/machdep.h	Wed Apr 30 22:28:07 2003
+++ b/include/asm-ppc/machdep.h	Wed Apr 30 22:28:07 2003
@@ -25,7 +25,7 @@
 	int		(*show_cpuinfo)(struct seq_file *m);
 	int		(*show_percpuinfo)(struct seq_file *m, int i);
 	/* Optional, may be NULL. */
-	unsigned int	(*irq_cannonicalize)(unsigned int irq);
+	unsigned int	(*irq_canonicalize)(unsigned int irq);
 	void		(*init_IRQ)(void);
 	int		(*get_irq)(struct pt_regs *);
 	
diff -Nru a/include/asm-ppc/ocp.h b/include/asm-ppc/ocp.h
--- a/include/asm-ppc/ocp.h	Wed Apr 30 22:28:06 2003
+++ b/include/asm-ppc/ocp.h	Wed Apr 30 22:28:06 2003
@@ -36,7 +36,6 @@
 #include <linux/list.h>
 #include <linux/config.h>
 #include <linux/device.h>
-#include <linux/devfs_fs_kernel.h>
 
 #include <asm/ocp_ids.h>
 #include <asm/mmu.h>		/* For phys_addr_t */
diff -Nru a/include/asm-ppc/processor.h b/include/asm-ppc/processor.h
--- a/include/asm-ppc/processor.h	Wed Apr 30 22:28:03 2003
+++ b/include/asm-ppc/processor.h	Wed Apr 30 22:28:03 2003
@@ -104,6 +104,15 @@
 #define	SPRN_DBAT2U	0x21C	/* Data BAT 2 Upper Register */
 #define	SPRN_DBAT3L	0x21F	/* Data BAT 3 Lower Register */
 #define	SPRN_DBAT3U	0x21E	/* Data BAT 3 Upper Register */
+#define	SPRN_DBAT4L	0x239	/* Data BAT 4 Lower Register */
+#define	SPRN_DBAT4U	0x238	/* Data BAT 4 Upper Register */
+#define	SPRN_DBAT5L	0x23B	/* Data BAT 5 Lower Register */
+#define	SPRN_DBAT5U	0x23A	/* Data BAT 5 Upper Register */
+#define	SPRN_DBAT6L	0x23D	/* Data BAT 6 Lower Register */
+#define	SPRN_DBAT6U	0x23C	/* Data BAT 6 Upper Register */
+#define	SPRN_DBAT7L	0x23F	/* Data BAT 7 Lower Register */
+#define	SPRN_DBAT7U	0x23E	/* Data BAT 7 Upper Register */
+
 #define	SPRN_DBCR	0x3F2	/* Debug Control Regsiter */
 #define	  DBCR_EDM	0x80000000
 #define	  DBCR_IDM	0x40000000
@@ -267,6 +276,14 @@
 #define	SPRN_IBAT2U	0x214	/* Instruction BAT 2 Upper Register */
 #define	SPRN_IBAT3L	0x217	/* Instruction BAT 3 Lower Register */
 #define	SPRN_IBAT3U	0x216	/* Instruction BAT 3 Upper Register */
+#define	SPRN_IBAT4L	0x231	/* Instruction BAT 4 Lower Register */
+#define	SPRN_IBAT4U	0x230	/* Instruction BAT 4 Upper Register */
+#define	SPRN_IBAT5L	0x233	/* Instruction BAT 5 Lower Register */
+#define	SPRN_IBAT5U	0x232	/* Instruction BAT 5 Upper Register */
+#define	SPRN_IBAT6L	0x235	/* Instruction BAT 6 Lower Register */
+#define	SPRN_IBAT6U	0x234	/* Instruction BAT 6 Upper Register */
+#define	SPRN_IBAT7L	0x237	/* Instruction BAT 7 Lower Register */
+#define	SPRN_IBAT7U	0x236	/* Instruction BAT 7 Upper Register */
 #define	SPRN_ICCR	0x3FB	/* Instruction Cache Cacheability Register */
 #define	  ICCR_NOCACHE		0	/* Noncacheable */
 #define	  ICCR_CACHE		1	/* Cacheable */
@@ -448,6 +465,14 @@
 #define	DBAT2U	SPRN_DBAT2U	/* Data BAT 2 Upper Register */
 #define	DBAT3L	SPRN_DBAT3L	/* Data BAT 3 Lower Register */
 #define	DBAT3U	SPRN_DBAT3U	/* Data BAT 3 Upper Register */
+#define	DBAT4L	SPRN_DBAT4L	/* Data BAT 4 Lower Register */
+#define	DBAT4U	SPRN_DBAT4U	/* Data BAT 4 Upper Register */
+#define	DBAT5L	SPRN_DBAT5L	/* Data BAT 5 Lower Register */
+#define	DBAT5U	SPRN_DBAT5U	/* Data BAT 5 Upper Register */
+#define	DBAT6L	SPRN_DBAT6L	/* Data BAT 6 Lower Register */
+#define	DBAT6U	SPRN_DBAT6U	/* Data BAT 6 Upper Register */
+#define	DBAT7L	SPRN_DBAT7L	/* Data BAT 7 Lower Register */
+#define	DBAT7U	SPRN_DBAT7U	/* Data BAT 7 Upper Register */
 #define	DCMP	SPRN_DCMP      	/* Data TLB Compare Register */
 #define	DEC	SPRN_DEC       	/* Decrement Register */
 #define	DMISS	SPRN_DMISS     	/* Data TLB Miss Register */
@@ -466,6 +491,14 @@
 #define	IBAT2U	SPRN_IBAT2U	/* Instruction BAT 2 Upper Register */
 #define	IBAT3L	SPRN_IBAT3L	/* Instruction BAT 3 Lower Register */
 #define	IBAT3U	SPRN_IBAT3U	/* Instruction BAT 3 Upper Register */
+#define	IBAT4L	SPRN_IBAT4L	/* Instruction BAT 4 Lower Register */
+#define	IBAT4U	SPRN_IBAT4U	/* Instruction BAT 4 Upper Register */
+#define	IBAT5L	SPRN_IBAT5L	/* Instruction BAT 5 Lower Register */
+#define	IBAT5U	SPRN_IBAT5U	/* Instruction BAT 5 Upper Register */
+#define	IBAT6L	SPRN_IBAT6L	/* Instruction BAT 6 Lower Register */
+#define	IBAT6U	SPRN_IBAT6U	/* Instruction BAT 6 Upper Register */
+#define	IBAT7L	SPRN_IBAT7L	/* Instruction BAT 7 Lower Register */
+#define	IBAT7U	SPRN_IBAT7U	/* Instruction BAT 7 Upper Register */
 #define	ICMP	SPRN_ICMP	/* Instruction TLB Compare Register */
 #define	IMISS	SPRN_IMISS	/* Instruction TLB Miss Register */
 #define	IMMR	SPRN_IMMR      	/* PPC 860/821 Internal Memory Map Register */
diff -Nru a/include/asm-ppc/system.h b/include/asm-ppc/system.h
--- a/include/asm-ppc/system.h	Wed Apr 30 22:28:08 2003
+++ b/include/asm-ppc/system.h	Wed Apr 30 22:28:08 2003
@@ -50,8 +50,6 @@
 #endif /* CONFIG_SMP */
 
 #ifdef __KERNEL__
-extern void xmon_irq(int, void *, struct pt_regs *);
-extern void xmon(struct pt_regs *excp);
 extern void print_backtrace(unsigned long *);
 extern void show_regs(struct pt_regs * regs);
 extern void flush_instruction_cache(void);
diff -Nru a/include/asm-ppc/xmon.h b/include/asm-ppc/xmon.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/include/asm-ppc/xmon.h	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,17 @@
+#ifndef __PPC_XMON_H
+#define __PPC_XMON_H
+#ifdef __KERNEL__
+
+struct pt_regs;
+
+extern void xmon(struct pt_regs *excp);
+extern void xmon_printf(const char *fmt, ...);
+extern void xmon_map_scc(void);
+extern int xmon_bpt(struct pt_regs *regs);
+extern int xmon_sstep(struct pt_regs *regs);
+extern int xmon_iabr_match(struct pt_regs *regs);
+extern int xmon_dabr_match(struct pt_regs *regs);
+extern void (*xmon_fault_handler)(struct pt_regs *regs);
+
+#endif
+#endif
diff -Nru a/include/asm-ppc64/irq.h b/include/asm-ppc64/irq.h
--- a/include/asm-ppc64/irq.h	Wed Apr 30 22:28:19 2003
+++ b/include/asm-ppc64/irq.h	Wed Apr 30 22:28:19 2003
@@ -46,7 +46,7 @@
  * powermacs as well as prep/chrp boxes.
  * Prep and chrp both have cascaded 8259 PICs.
  */
-static __inline__ int irq_cannonicalize(int irq)
+static __inline__ int irq_canonicalize(int irq)
 {
 	return irq;
 }
diff -Nru a/include/asm-ppc64/pgalloc.h b/include/asm-ppc64/pgalloc.h
--- a/include/asm-ppc64/pgalloc.h	Wed Apr 30 22:28:03 2003
+++ b/include/asm-ppc64/pgalloc.h	Wed Apr 30 22:28:03 2003
@@ -31,19 +31,11 @@
 static inline pmd_t *
 pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
 {
-	int count = 0;
 	pmd_t *pmd;
 
-	do {
-		pmd = (pmd_t *)__get_free_page(GFP_KERNEL);
-		if (pmd)
-			clear_page(pmd);
-		else {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pmd && (count++ < 10));
-
+	pmd = (pmd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
+	if (pmd)
+		clear_page(pmd);
 	return pmd;
 }
 
@@ -62,19 +54,11 @@
 static inline pte_t *
 pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)
 {
-	int count = 0;
 	pte_t *pte;
 
-	do {
-		pte = (pte_t *)__get_free_page(GFP_KERNEL);
-		if (pte)
-			clear_page(pte);
-		else {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pte && (count++ < 10));
-
+	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
+	if (pte)
+		clear_page(pte);
 	return pte;
 }
 
diff -Nru a/include/asm-s390/pgalloc.h b/include/asm-s390/pgalloc.h
--- a/include/asm-s390/pgalloc.h	Wed Apr 30 22:28:11 2003
+++ b/include/asm-s390/pgalloc.h	Wed Apr 30 22:28:11 2003
@@ -120,20 +120,13 @@
 pte_alloc_one_kernel(struct mm_struct *mm, unsigned long vmaddr)
 {
 	pte_t *pte;
-	int count;
         int i;
 
-	count = 0;
-	do {
-		pte = (pte_t *) __get_free_page(GFP_KERNEL);
-		if (pte != NULL) {
-			for (i=0; i < PTRS_PER_PTE; i++)
-				pte_clear(pte+i);
-		} else {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pte && (count++ < 10));
+	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
+	if (pte != NULL) {
+		for (i=0; i < PTRS_PER_PTE; i++)
+			pte_clear(pte+i);
+	}
 	return pte;
 }
 
diff -Nru a/include/asm-sh/pgalloc.h b/include/asm-sh/pgalloc.h
--- a/include/asm-sh/pgalloc.h	Wed Apr 30 22:28:09 2003
+++ b/include/asm-sh/pgalloc.h	Wed Apr 30 22:28:09 2003
@@ -35,7 +35,7 @@
 
 static inline pte_t *pte_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	pte_t *pte = (pte_t *) __get_free_page(GFP_KERNEL);
+	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (pte)
 		clear_page(pte);
 	return pte;
diff -Nru a/include/asm-sh/serial-bigsur.h b/include/asm-sh/serial-bigsur.h
--- a/include/asm-sh/serial-bigsur.h	Wed Apr 30 22:28:12 2003
+++ b/include/asm-sh/serial-bigsur.h	Wed Apr 30 22:28:12 2003
@@ -25,6 +25,6 @@
 #define SERIAL_PORT_DFNS STD_SERIAL_PORT_DEFNS
 
 /* XXX: This should be moved ino irq.h */
-#define irq_cannonicalize(x) (x)
+#define irq_canonicalize(x) (x)
 
 #endif /* _ASM_SERIAL_BIGSUR_H */
diff -Nru a/include/asm-sh/serial-ec3104.h b/include/asm-sh/serial-ec3104.h
--- a/include/asm-sh/serial-ec3104.h	Wed Apr 30 22:28:09 2003
+++ b/include/asm-sh/serial-ec3104.h	Wed Apr 30 22:28:09 2003
@@ -21,4 +21,4 @@
 #define SERIAL_PORT_DFNS STD_SERIAL_PORT_DEFNS
 
 /* XXX: This should be moved ino irq.h */
-#define irq_cannonicalize(x) (x)
+#define irq_canonicalize(x) (x)
diff -Nru a/include/asm-sh/serial.h b/include/asm-sh/serial.h
--- a/include/asm-sh/serial.h	Wed Apr 30 22:28:10 2003
+++ b/include/asm-sh/serial.h	Wed Apr 30 22:28:10 2003
@@ -49,7 +49,7 @@
 #define SERIAL_PORT_DFNS STD_SERIAL_PORT_DEFNS
 
 /* XXX: This should be moved ino irq.h */
-#define irq_cannonicalize(x) (x)
+#define irq_canonicalize(x) (x)
 
 #endif
 #endif /* _ASM_SERIAL_H */
diff -Nru a/include/asm-sparc/auxio.h b/include/asm-sparc/auxio.h
--- a/include/asm-sparc/auxio.h	Wed Apr 30 22:28:03 2003
+++ b/include/asm-sparc/auxio.h	Wed Apr 30 22:28:03 2003
@@ -9,8 +9,6 @@
 #include <asm/system.h>
 #include <asm/vaddrs.h>
 
-extern unsigned char *auxio_register;
-
 /* This register is an unsigned char in IO space.  It does two things.
  * First, it is used to control the front panel LED light on machines
  * that have it (good for testing entry points to trap handlers and irq's)
@@ -31,41 +29,52 @@
 #define AUXIO_FLPY_EJCT   0x02    /* Eject floppy disk.  Write only. */
 #define AUXIO_LED         0x01    /* On if set, off if unset. Read/Write */
 
-#define AUXREG   ((volatile unsigned char *)(auxio_register))
+#ifndef __ASSEMBLY__
+
+/* 
+ * NOTE: these routines are implementation dependent-- 
+ * understand the hardware you are querying! 
+ */
+extern void set_auxio(unsigned char bits_on, unsigned char bits_off);
+extern unsigned char get_auxio(void); /* .../asm-sparc/floppy.h */
 
-/* These are available on sun4c */
-#define TURN_ON_LED   if (AUXREG) *AUXREG = (*AUXREG | AUXIO_ORMEIN | AUXIO_LED)
-#define TURN_OFF_LED  if (AUXREG) *AUXREG = ((*AUXREG | AUXIO_ORMEIN) & (~AUXIO_LED))
-#define FLIP_LED      if (AUXREG) *AUXREG = ((*AUXREG | AUXIO_ORMEIN) ^ AUXIO_LED)
-#define FLPY_MOTORON  if (AUXREG) *AUXREG = ((*AUXREG | AUXIO_ORMEIN) | AUXIO_FLPY_DSEL)
-#define FLPY_MOTOROFF if (AUXREG) *AUXREG = ((*AUXREG | AUXIO_ORMEIN) & (~AUXIO_FLPY_DSEL))
-#define FLPY_TCNTON   if (AUXREG) *AUXREG = ((*AUXREG | AUXIO_ORMEIN) | AUXIO_FLPY_TCNT)
-#define FLPY_TCNTOFF  if (AUXREG) *AUXREG = ((*AUXREG | AUXIO_ORMEIN) & (~AUXIO_FLPY_TCNT))
+/*
+ * The following routines are provided for driver-compatibility
+ * with sparc64 (primarily sunlance.c)
+ */
 
-#ifndef __ASSEMBLY__
-#define set_auxio(bits_on, bits_off) \
+#define AUXIO_LTE_ON    1
+#define AUXIO_LTE_OFF   0
+
+/* auxio_set_lte - Set Link Test Enable (TPE Link Detect)
+ *
+ * on - AUXIO_LTE_ON or AUXIO_LTE_OFF
+ */
+#define auxio_set_lte(on) \
 do { \
-	unsigned char regval; \
-	unsigned long flags; \
-	save_flags(flags); cli(); \
-	switch(sparc_cpu_model) { \
-	case sun4c: \
-		regval = *AUXREG; \
-		*AUXREG = ((regval | bits_on) & ~bits_off) | AUXIO_ORMEIN; \
-		break; \
-	case sun4m: \
-		if(!AUXREG) \
-			break;     /* VME chassic sun4m, no auxio. */ \
-		regval = *AUXREG; \
-		*AUXREG = ((regval | bits_on) & ~bits_off) | AUXIO_ORMEIN4M; \
-		break; \
-	case sun4d: \
-		break; \
-	default: \
-		panic("Can't set AUXIO register on this machine."); \
-	}; \
-	restore_flags(flags); \
-} while(0)
+	if(on) { \
+		set_auxio(AUXIO_LINK_TEST, 0); \
+	} else { \
+		set_auxio(0, AUXIO_LINK_TEST); \
+	} \
+} while (0)
+
+#define AUXIO_LED_ON    1
+#define AUXIO_LED_OFF   0
+
+/* auxio_set_led - Set system front panel LED
+ *
+ * on - AUXIO_LED_ON or AUXIO_LED_OFF
+ */
+#define auxio_set_led(on) \
+do { \
+	if(on) { \
+		set_auxio(AUXIO_LED, 0); \
+	} else { \
+		set_auxio(0, AUXIO_LED); \
+	} \
+} while (0)
+
 #endif /* !(__ASSEMBLY__) */
 
 
diff -Nru a/include/asm-sparc/bitext.h b/include/asm-sparc/bitext.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/include/asm-sparc/bitext.h	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,24 @@
+/*
+ * bitext.h: Bit string operations on the sparc, specific to architecture.
+ *
+ * Copyright 2002 Pete Zaitcev <zaitcev@yahoo.com>
+ */
+
+#ifndef _SPARC_BITEXT_H
+#define _SPARC_BITEXT_H
+
+#include <linux/smp_lock.h>
+
+struct bit_map {
+	spinlock_t lock;
+	unsigned long *map;
+	int size;
+	int used;
+	int last_off;
+};
+
+extern int bit_map_string_get(struct bit_map *t, int len, int align);
+extern void bit_map_clear(struct bit_map *t, int offset, int len);
+extern void bit_map_init(struct bit_map *t, unsigned long *map, int size);
+
+#endif /* defined(_SPARC_BITEXT_H) */
diff -Nru a/include/asm-sparc/floppy.h b/include/asm-sparc/floppy.h
--- a/include/asm-sparc/floppy.h	Wed Apr 30 22:28:03 2003
+++ b/include/asm-sparc/floppy.h	Wed Apr 30 22:28:03 2003
@@ -115,7 +115,7 @@
 	case 5: /* FD_DATA */
 		return sun_fdc->data_82072;
 	case 7: /* FD_DIR */
-		return (*AUXREG & AUXIO_FLPY_DCHG)? 0x80: 0;
+		return (get_auxio() & AUXIO_FLPY_DCHG)? 0x80: 0;
 	};
 	panic("sun_82072_fd_inb: How did I get here?");
 }
@@ -337,7 +337,7 @@
                 sun_fdops.fd_inb = sun_82072_fd_inb;
                 sun_fdops.fd_outb = sun_82072_fd_outb;
                 fdc_status = &sun_fdc->status_82072;
-                /* printk("AUXIO @0x%p\n", auxio_register); */ /* P3 */
+                /* printk("AUXIO @0x%lx\n", auxio_register); */ /* P3 */
         } else {
                 sun_fdops.fd_inb = sun_82077_fd_inb;
                 sun_fdops.fd_outb = sun_82077_fd_outb;
diff -Nru a/include/asm-sparc/iommu.h b/include/asm-sparc/iommu.h
--- a/include/asm-sparc/iommu.h	Wed Apr 30 22:28:05 2003
+++ b/include/asm-sparc/iommu.h	Wed Apr 30 22:28:05 2003
@@ -6,6 +6,7 @@
 #define _SPARC_IOMMU_H
 
 #include <asm/page.h>
+#include <asm/bitext.h>
 
 /* The iommu handles all virtual to physical address translations
  * that occur between the SBUS and physical memory.  Access by
@@ -100,11 +101,11 @@
 struct iommu_struct {
 	struct iommu_regs *regs;
 	iopte_t *page_table;
-	iopte_t *lowest;     /* to speed up searches... */
-	unsigned long plow;
 	/* For convenience */
 	unsigned long start; /* First managed virtual address */
 	unsigned long end;   /* Last managed virtual address */
+
+	struct bit_map usemap;
 };
 
 extern __inline__ void iommu_invalidate(struct iommu_regs *regs)
@@ -112,9 +113,9 @@
 	regs->tlbflush = 0;
 }
 
-extern __inline__ void iommu_invalidate_page(struct iommu_regs *regs, unsigned long page)
+extern __inline__ void iommu_invalidate_page(struct iommu_regs *regs, unsigned long ba)
 {
-	regs->pageflush = (page & PAGE_MASK);
+	regs->pageflush = (ba & PAGE_MASK);
 }
 
 #endif /* !(_SPARC_IOMMU_H) */
diff -Nru a/include/asm-sparc/irq.h b/include/asm-sparc/irq.h
--- a/include/asm-sparc/irq.h	Wed Apr 30 22:28:10 2003
+++ b/include/asm-sparc/irq.h	Wed Apr 30 22:28:10 2003
@@ -10,6 +10,7 @@
 #include <linux/config.h>
 #include <linux/linkage.h>
 #include <linux/threads.h>     /* For NR_CPUS */
+#include <linux/interrupt.h>
 
 #include <asm/system.h>     /* For SUN4M_NCPUS */
 #include <asm/btfixup.h>
@@ -21,7 +22,7 @@
 
 #define NR_IRQS    16
 
-#define irq_cannonicalize(irq)	(irq)
+#define irq_canonicalize(irq)	(irq)
 
 /* Dave Redman (djhr@tadpole.co.uk)
  * changed these to function pointers.. it saves cycles and will allow
@@ -47,8 +48,8 @@
 #define clear_profile_irq(cpu) BTFIXUP_CALL(clear_profile_irq)(cpu)
 #define load_profile_irq(cpu,limit) BTFIXUP_CALL(load_profile_irq)(cpu,limit)
 
-extern void (*sparc_init_timers)(void (*lvl10_irq)(int, void *, struct pt_regs *));
-extern void claim_ticker14(void (*irq_handler)(int, void *, struct pt_regs *),
+extern void (*sparc_init_timers)(irqreturn_t (*lvl10_irq)(int, void *, struct pt_regs *));
+extern void claim_ticker14(irqreturn_t (*irq_handler)(int, void *, struct pt_regs *),
 			   int irq,
 			   unsigned int timeout);
 
@@ -62,7 +63,7 @@
 #define set_irq_udt(cpu) BTFIXUP_CALL(set_irq_udt)(cpu)
 #endif
 
-extern int request_fast_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *), unsigned long flags, __const__ char *devname);
+extern int request_fast_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_regs *), unsigned long flags, __const__ char *devname);
 
 /* On the sun4m, just like the timers, we have both per-cpu and master
  * interrupt registers.
diff -Nru a/include/asm-sparc/kgdb.h b/include/asm-sparc/kgdb.h
--- a/include/asm-sparc/kgdb.h	Wed Apr 30 22:28:06 2003
+++ b/include/asm-sparc/kgdb.h	Wed Apr 30 22:28:06 2003
@@ -52,43 +52,43 @@
 #define KGDB_NPC    0x114
 
 #define SAVE_KGDB_GLOBALS(reg) \
-        std     %g0, [%reg + REGWIN_SZ + KGDB_G0]; \
-        std     %g2, [%reg + REGWIN_SZ + KGDB_G2]; \
-        std     %g4, [%reg + REGWIN_SZ + KGDB_G4]; \
-        std     %g6, [%reg + REGWIN_SZ + KGDB_G6];
+        std     %g0, [%reg + STACKFRAME_SZ + KGDB_G0]; \
+        std     %g2, [%reg + STACKFRAME_SZ + KGDB_G2]; \
+        std     %g4, [%reg + STACKFRAME_SZ + KGDB_G4]; \
+        std     %g6, [%reg + STACKFRAME_SZ + KGDB_G6];
 
 #define SAVE_KGDB_INS(reg) \
-        std     %i0, [%reg + REGWIN_SZ + KGDB_I0]; \
-        std     %i2, [%reg + REGWIN_SZ + KGDB_I2]; \
-        std     %i4, [%reg + REGWIN_SZ + KGDB_I4]; \
-        std     %i6, [%reg + REGWIN_SZ + KGDB_I6];
+        std     %i0, [%reg + STACKFRAME_SZ + KGDB_I0]; \
+        std     %i2, [%reg + STACKFRAME_SZ + KGDB_I2]; \
+        std     %i4, [%reg + STACKFRAME_SZ + KGDB_I4]; \
+        std     %i6, [%reg + STACKFRAME_SZ + KGDB_I6];
 
 #define SAVE_KGDB_SREGS(reg, reg_y, reg_psr, reg_wim, reg_tbr, reg_pc, reg_npc) \
-        st      %reg_y, [%reg + REGWIN_SZ + KGDB_Y]; \
-        st      %reg_psr, [%reg + REGWIN_SZ + KGDB_PSR]; \
-        st      %reg_wim, [%reg + REGWIN_SZ + KGDB_WIM]; \
-        st      %reg_tbr, [%reg + REGWIN_SZ + KGDB_TBR]; \
-        st      %reg_pc, [%reg + REGWIN_SZ + KGDB_PC]; \
-        st      %reg_npc, [%reg + REGWIN_SZ + KGDB_NPC];
+        st      %reg_y, [%reg + STACKFRAME_SZ + KGDB_Y]; \
+        st      %reg_psr, [%reg + STACKFRAME_SZ + KGDB_PSR]; \
+        st      %reg_wim, [%reg + STACKFRAME_SZ + KGDB_WIM]; \
+        st      %reg_tbr, [%reg + STACKFRAME_SZ + KGDB_TBR]; \
+        st      %reg_pc, [%reg + STACKFRAME_SZ + KGDB_PC]; \
+        st      %reg_npc, [%reg + STACKFRAME_SZ + KGDB_NPC];
 
 #define LOAD_KGDB_GLOBALS(reg) \
-        ld      [%reg + REGWIN_SZ + KGDB_G1], %g1; \
-        ldd     [%reg + REGWIN_SZ + KGDB_G2], %g2; \
-        ldd     [%reg + REGWIN_SZ + KGDB_G4], %g4; \
-        ldd     [%reg + REGWIN_SZ + KGDB_G6], %g6;
+        ld      [%reg + STACKFRAME_SZ + KGDB_G1], %g1; \
+        ldd     [%reg + STACKFRAME_SZ + KGDB_G2], %g2; \
+        ldd     [%reg + STACKFRAME_SZ + KGDB_G4], %g4; \
+        ldd     [%reg + STACKFRAME_SZ + KGDB_G6], %g6;
 
 #define LOAD_KGDB_INS(reg) \
-        ldd     [%reg + REGWIN_SZ + KGDB_I0], %i0; \
-        ldd     [%reg + REGWIN_SZ + KGDB_I2], %i2; \
-        ldd     [%reg + REGWIN_SZ + KGDB_I4], %i4; \
-        ldd     [%reg + REGWIN_SZ + KGDB_I6], %i6;
+        ldd     [%reg + STACKFRAME_SZ + KGDB_I0], %i0; \
+        ldd     [%reg + STACKFRAME_SZ + KGDB_I2], %i2; \
+        ldd     [%reg + STACKFRAME_SZ + KGDB_I4], %i4; \
+        ldd     [%reg + STACKFRAME_SZ + KGDB_I6], %i6;
 
 #define LOAD_KGDB_SREGS(reg, reg_y, reg_psr, reg_wim, reg_tbr, reg_pc, reg_npc) \
-	ld	[%reg + REGWIN_SZ + KGDB_Y], %reg_y; \
-	ld	[%reg + REGWIN_SZ + KGDB_PSR], %reg_psr; \
-	ld	[%reg + REGWIN_SZ + KGDB_WIM], %reg_wim; \
-	ld	[%reg + REGWIN_SZ + KGDB_TBR], %reg_tbr; \
-	ld	[%reg + REGWIN_SZ + KGDB_PC], %reg_pc; \
-	ld	[%reg + REGWIN_SZ + KGDB_NPC], %reg_npc;
+	ld	[%reg + STACKFRAME_SZ + KGDB_Y], %reg_y; \
+	ld	[%reg + STACKFRAME_SZ + KGDB_PSR], %reg_psr; \
+	ld	[%reg + STACKFRAME_SZ + KGDB_WIM], %reg_wim; \
+	ld	[%reg + STACKFRAME_SZ + KGDB_TBR], %reg_tbr; \
+	ld	[%reg + STACKFRAME_SZ + KGDB_PC], %reg_pc; \
+	ld	[%reg + STACKFRAME_SZ + KGDB_NPC], %reg_npc;
 
 #endif /* !(_SPARC_KGDB_H) */
diff -Nru a/include/asm-sparc/pgtable.h b/include/asm-sparc/pgtable.h
--- a/include/asm-sparc/pgtable.h	Wed Apr 30 22:28:10 2003
+++ b/include/asm-sparc/pgtable.h	Wed Apr 30 22:28:10 2003
@@ -27,6 +27,7 @@
 #ifndef __ASSEMBLY__
 
 struct vm_area_struct;
+struct page;
 
 extern void load_mmu(void);
 extern unsigned long calc_highpages(void);
@@ -51,15 +52,30 @@
 
 /*
  * mmu_map/unmap are provided by iommu/iounit; Invalid to call on IIep.
+ *
+ * The mmu_map_dma_area establishes two mappings in one go.
+ * These mappings point to pages normally mapped at 'va' (linear address).
+ * First mapping is for CPU visible address at 'a', uncached.
+ * This is an alias, but it works because it is an uncached mapping.
+ * Second mapping is for device visible address, or "bus" address.
+ * The bus address is returned at '*pba'.
+ *
+ * These functions seem distinct, but are hard to split. On sun4c,
+ * at least for now, 'a' is equal to bus address, and retured in *pba.
+ * On sun4m, page attributes depend on the CPU type, so we have to
+ * know if we are mapping RAM or I/O, so it has to be an additional argument
+ * to a separate mapping function for CPU visible mappings.
  */
-BTFIXUPDEF_CALL(void,  mmu_map_dma_area, unsigned long va, __u32 addr, int len)
-BTFIXUPDEF_CALL(unsigned long /*phys*/, mmu_translate_dvma, unsigned long busa)
+BTFIXUPDEF_CALL(int,  mmu_map_dma_area, dma_addr_t *, unsigned long, unsigned long, int len)
+BTFIXUPDEF_CALL(struct page *, mmu_translate_dvma, unsigned long busa)
 BTFIXUPDEF_CALL(void,  mmu_unmap_dma_area, unsigned long busa, int len)
 
-#define mmu_map_dma_area(va, ba,len) BTFIXUP_CALL(mmu_map_dma_area)(va,ba,len)
+#define mmu_map_dma_area(pba,va,a,len) BTFIXUP_CALL(mmu_map_dma_area)(pba,va,a,len)
 #define mmu_unmap_dma_area(ba,len) BTFIXUP_CALL(mmu_unmap_dma_area)(ba,len)
 #define mmu_translate_dvma(ba)     BTFIXUP_CALL(mmu_translate_dvma)(ba)
 
+/*
+ */
 BTFIXUPDEF_SIMM13(pmd_shift)
 BTFIXUPDEF_SETHI(pmd_size)
 BTFIXUPDEF_SETHI(pmd_mask)
@@ -376,6 +392,12 @@
 BTFIXUPDEF_CALL(void, update_mmu_cache, struct vm_area_struct *, unsigned long, pte_t)
 
 #define update_mmu_cache(vma,addr,pte) BTFIXUP_CALL(update_mmu_cache)(vma,addr,pte)
+
+BTFIXUPDEF_CALL(void, sparc_mapiorange, unsigned int, unsigned long,
+    unsigned long, unsigned int)
+BTFIXUPDEF_CALL(void, sparc_unmapiorange, unsigned long, unsigned int)
+#define sparc_mapiorange(bus,pa,va,len) BTFIXUP_CALL(sparc_mapiorange)(bus,pa,va,len)
+#define sparc_unmapiorange(va,len) BTFIXUP_CALL(sparc_unmapiorange)(va,len)
 
 extern int invalid_segment;
 
diff -Nru a/include/asm-sparc/processor.h b/include/asm-sparc/processor.h
--- a/include/asm-sparc/processor.h	Wed Apr 30 22:28:19 2003
+++ b/include/asm-sparc/processor.h	Wed Apr 30 22:28:19 2003
@@ -131,7 +131,7 @@
 			     "std\t%%g0, [%0 + %3 + 0x30]\n\t"
 			     "st\t%1, [%0 + %3 + 0x38]\n\t"
 			     "st\t%%g0, [%0 + %3 + 0x3c]"
-			     : : "r" (regs), "r" (sp - REGWIN_SZ), "r" (zero),
+			     : : "r" (regs), "r" (sp - sizeof(struct reg_window)), "r" (zero),
 			     "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0])));
 }
 
diff -Nru a/include/asm-sparc/ptrace.h b/include/asm-sparc/ptrace.h
--- a/include/asm-sparc/ptrace.h	Wed Apr 30 22:28:16 2003
+++ b/include/asm-sparc/ptrace.h	Wed Apr 30 22:28:16 2003
@@ -58,7 +58,6 @@
 
 #define TRACEREG_SZ   sizeof(struct pt_regs)
 #define STACKFRAME_SZ sizeof(struct sparc_stackf)
-#define REGWIN_SZ     sizeof(struct reg_window)
 
 #ifdef __KERNEL__
 #define user_mode(regs) (!((regs)->psr & PSR_PS))
@@ -70,7 +69,6 @@
 /* For assembly code. */
 #define TRACEREG_SZ       0x50
 #define STACKFRAME_SZ     0x60
-#define REGWIN_SZ         0x40
 #endif
 
 /*
diff -Nru a/include/asm-sparc/sbus.h b/include/asm-sparc/sbus.h
--- a/include/asm-sparc/sbus.h	Wed Apr 30 22:28:05 2003
+++ b/include/asm-sparc/sbus.h	Wed Apr 30 22:28:05 2003
@@ -10,7 +10,7 @@
 #include <linux/ioport.h>
 
 #include <asm/oplib.h>
-#include <asm/iommu.h>
+/* #include <asm/iommu.h> */ /* Unused since we use opaque iommu (|io-unit) */
 #include <asm/scatterlist.h>
 
 /* We scan which devices are on the SBus using the PROM node device
diff -Nru a/include/asm-sparc/signal.h b/include/asm-sparc/signal.h
--- a/include/asm-sparc/signal.h	Wed Apr 30 22:28:10 2003
+++ b/include/asm-sparc/signal.h	Wed Apr 30 22:28:10 2003
@@ -118,10 +118,10 @@
 };
 
 /* Sigvec flags */
-#define SV_SSTACK    1u    /* This signal handler should use sig-stack */
-#define SV_INTR      2u    /* Sig return should not restart system call */
-#define SV_RESET     4u    /* Set handler to SIG_DFL upon taken signal */
-#define SV_IGNCHILD  8u    /* Do not send SIGCHLD */
+#define _SV_SSTACK    1u    /* This signal handler should use sig-stack */
+#define _SV_INTR      2u    /* Sig return should not restart system call */
+#define _SV_RESET     4u    /* Set handler to SIG_DFL upon taken signal */
+#define _SV_IGNCHILD  8u    /* Do not send SIGCHLD */
 
 /*
  * sa_flags values: SA_STACK is not currently supported, but will allow the
@@ -132,11 +132,11 @@
  * SA_RESTART flag to get restarting signals (which were the default long ago)
  * SA_SHIRQ flag is for shared interrupt support on PCI and EISA.
  */
-#define SA_NOCLDSTOP	SV_IGNCHILD
-#define SA_STACK	SV_SSTACK
-#define SA_ONSTACK	SV_SSTACK
-#define SA_RESTART	SV_INTR
-#define SA_ONESHOT	SV_RESET
+#define SA_NOCLDSTOP	_SV_IGNCHILD
+#define SA_STACK	_SV_SSTACK
+#define SA_ONSTACK	_SV_SSTACK
+#define SA_RESTART	_SV_INTR
+#define SA_ONESHOT	_SV_RESET
 #define SA_INTERRUPT	0x10u
 #define SA_NOMASK	0x20u
 #define SA_SHIRQ	0x40u
diff -Nru a/include/asm-sparc/winmacro.h b/include/asm-sparc/winmacro.h
--- a/include/asm-sparc/winmacro.h	Wed Apr 30 22:28:08 2003
+++ b/include/asm-sparc/winmacro.h	Wed Apr 30 22:28:08 2003
@@ -11,14 +11,6 @@
 #include <asm/ptrace.h>
 #include <asm/psr.h>
 
-/* These are just handy. */
-#define _SV	save	%sp, -REGWIN_SZ, %sp
-#define _RS     restore 
-
-#define FLUSH_ALL_KERNEL_WINDOWS \
-	_SV; _SV; _SV; _SV; _SV; _SV; _SV; \
-	_RS; _RS; _RS; _RS; _RS; _RS; _RS;
-
 /* Store the register window onto the 8-byte aligned area starting
  * at %reg.  It might be %sp, it might not, we don't care.
  */
@@ -45,25 +37,25 @@
 
 /* Loading and storing struct pt_reg trap frames. */
 #define LOAD_PT_INS(base_reg) \
-        ldd     [%base_reg + REGWIN_SZ + PT_I0], %i0; \
-        ldd     [%base_reg + REGWIN_SZ + PT_I2], %i2; \
-        ldd     [%base_reg + REGWIN_SZ + PT_I4], %i4; \
-        ldd     [%base_reg + REGWIN_SZ + PT_I6], %i6;
+        ldd     [%base_reg + STACKFRAME_SZ + PT_I0], %i0; \
+        ldd     [%base_reg + STACKFRAME_SZ + PT_I2], %i2; \
+        ldd     [%base_reg + STACKFRAME_SZ + PT_I4], %i4; \
+        ldd     [%base_reg + STACKFRAME_SZ + PT_I6], %i6;
 
 #define LOAD_PT_GLOBALS(base_reg) \
-        ld      [%base_reg + REGWIN_SZ + PT_G1], %g1; \
-        ldd     [%base_reg + REGWIN_SZ + PT_G2], %g2; \
-        ldd     [%base_reg + REGWIN_SZ + PT_G4], %g4; \
-        ldd     [%base_reg + REGWIN_SZ + PT_G6], %g6;
+        ld      [%base_reg + STACKFRAME_SZ + PT_G1], %g1; \
+        ldd     [%base_reg + STACKFRAME_SZ + PT_G2], %g2; \
+        ldd     [%base_reg + STACKFRAME_SZ + PT_G4], %g4; \
+        ldd     [%base_reg + STACKFRAME_SZ + PT_G6], %g6;
 
 #define LOAD_PT_YREG(base_reg, scratch) \
-        ld      [%base_reg + REGWIN_SZ + PT_Y], %scratch; \
+        ld      [%base_reg + STACKFRAME_SZ + PT_Y], %scratch; \
         wr      %scratch, 0x0, %y;
 
 #define LOAD_PT_PRIV(base_reg, pt_psr, pt_pc, pt_npc) \
-        ld      [%base_reg + REGWIN_SZ + PT_PSR], %pt_psr; \
-        ld      [%base_reg + REGWIN_SZ + PT_PC], %pt_pc; \
-        ld      [%base_reg + REGWIN_SZ + PT_NPC], %pt_npc;
+        ld      [%base_reg + STACKFRAME_SZ + PT_PSR], %pt_psr; \
+        ld      [%base_reg + STACKFRAME_SZ + PT_PC], %pt_pc; \
+        ld      [%base_reg + STACKFRAME_SZ + PT_NPC], %pt_npc;
 
 #define LOAD_PT_ALL(base_reg, pt_psr, pt_pc, pt_npc, scratch) \
         LOAD_PT_YREG(base_reg, scratch) \
@@ -72,25 +64,25 @@
         LOAD_PT_PRIV(base_reg, pt_psr, pt_pc, pt_npc)
 
 #define STORE_PT_INS(base_reg) \
-        std     %i0, [%base_reg + REGWIN_SZ + PT_I0]; \
-        std     %i2, [%base_reg + REGWIN_SZ + PT_I2]; \
-        std     %i4, [%base_reg + REGWIN_SZ + PT_I4]; \
-        std     %i6, [%base_reg + REGWIN_SZ + PT_I6];
+        std     %i0, [%base_reg + STACKFRAME_SZ + PT_I0]; \
+        std     %i2, [%base_reg + STACKFRAME_SZ + PT_I2]; \
+        std     %i4, [%base_reg + STACKFRAME_SZ + PT_I4]; \
+        std     %i6, [%base_reg + STACKFRAME_SZ + PT_I6];
 
 #define STORE_PT_GLOBALS(base_reg) \
-        st      %g1, [%base_reg + REGWIN_SZ + PT_G1]; \
-        std     %g2, [%base_reg + REGWIN_SZ + PT_G2]; \
-        std     %g4, [%base_reg + REGWIN_SZ + PT_G4]; \
-        std     %g6, [%base_reg + REGWIN_SZ + PT_G6];
+        st      %g1, [%base_reg + STACKFRAME_SZ + PT_G1]; \
+        std     %g2, [%base_reg + STACKFRAME_SZ + PT_G2]; \
+        std     %g4, [%base_reg + STACKFRAME_SZ + PT_G4]; \
+        std     %g6, [%base_reg + STACKFRAME_SZ + PT_G6];
 
 #define STORE_PT_YREG(base_reg, scratch) \
         rd      %y, %scratch; \
-        st      %scratch, [%base_reg + REGWIN_SZ + PT_Y];
+        st      %scratch, [%base_reg + STACKFRAME_SZ + PT_Y];
 
 #define STORE_PT_PRIV(base_reg, pt_psr, pt_pc, pt_npc) \
-        st      %pt_psr, [%base_reg + REGWIN_SZ + PT_PSR]; \
-        st      %pt_pc,  [%base_reg + REGWIN_SZ + PT_PC]; \
-        st      %pt_npc, [%base_reg + REGWIN_SZ + PT_NPC];
+        st      %pt_psr, [%base_reg + STACKFRAME_SZ + PT_PSR]; \
+        st      %pt_pc,  [%base_reg + STACKFRAME_SZ + PT_PC]; \
+        st      %pt_npc, [%base_reg + STACKFRAME_SZ + PT_NPC];
 
 #define STORE_PT_ALL(base_reg, reg_psr, reg_pc, reg_npc, g_scratch) \
         STORE_PT_PRIV(base_reg, reg_psr, reg_pc, reg_npc) \
diff -Nru a/include/asm-sparc64/asi.h b/include/asm-sparc64/asi.h
--- a/include/asm-sparc64/asi.h	Wed Apr 30 22:28:06 2003
+++ b/include/asm-sparc64/asi.h	Wed Apr 30 22:28:06 2003
@@ -102,13 +102,13 @@
 #define ASI_PST8_P		0xc0 /* Primary, 8 8-bit, partial		*/
 #define ASI_PST8_S		0xc1 /* Secondary, 8 8-bit, partial		*/
 #define ASI_PST16_P		0xc2 /* Primary, 4 16-bit, partial		*/
-#define ASI_PST16_S		0xc3 /* Seconary, 4 16-bit, partial		*/
+#define ASI_PST16_S		0xc3 /* Secondary, 4 16-bit, partial		*/
 #define ASI_PST32_P		0xc4 /* Primary, 2 32-bit, partial		*/
 #define ASI_PST32_S		0xc5 /* Secondary, 2 32-bit, partial		*/
 #define ASI_PST8_PL		0xc8 /* Primary, 8 8-bit, partial, little	*/
 #define ASI_PST8_SL		0xc9 /* Secondary, 8 8-bit, partial, little	*/
 #define ASI_PST16_PL		0xca /* Primary, 4 16-bit, partial, little	*/
-#define ASI_PST16_SL		0xcb /* Seconary, 4 16-bit, partial, little	*/
+#define ASI_PST16_SL		0xcb /* Secondary, 4 16-bit, partial, little	*/
 #define ASI_PST32_PL		0xcc /* Primary, 2 32-bit, partial, little	*/
 #define ASI_PST32_SL		0xcd /* Secondary, 2 32-bit, partial, little	*/
 #define ASI_FL8_P		0xd0 /* Primary, 1 8-bit, fpu ld/st		*/
diff -Nru a/include/asm-sparc64/auxio.h b/include/asm-sparc64/auxio.h
--- a/include/asm-sparc64/auxio.h	Wed Apr 30 22:28:20 2003
+++ b/include/asm-sparc64/auxio.h	Wed Apr 30 22:28:20 2003
@@ -1,111 +1,98 @@
 /* $Id: auxio.h,v 1.3 2001/06/05 08:16:34 davem Exp $
- * auxio.h:  Definitions and code for the Auxiliary I/O register.
+ * auxio.h:  Definitions and code for the Auxiliary I/O registers.
  *
  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
+ *
+ * Refactoring for unified NCR/PCIO support 2002 Eric Brower (ebrower@usa.net)
  */
 #ifndef _SPARC64_AUXIO_H
 #define _SPARC64_AUXIO_H
 
-#include <asm/system.h>
-#include <asm/io.h>
-
-/* FIXME: All of this should be checked for sun4u. It has /sbus/auxio, but
-   I don't know whether it is the same and don't have a floppy */
+/* AUXIO implementations:
+ * sbus-based NCR89C105 "Slavio"
+ *	LED/Floppy (AUX1) register
+ *	Power (AUX2) register
+ *
+ * ebus-based auxio on PCIO 
+ *	LED Auxio Register
+ *	Power Auxio Register
+ *
+ * Register definitions from NCR _NCR89C105 Chip Specification_
+ * 
+ * SLAVIO AUX1 @ 0x1900000
+ * -------------------------------------------------
+ * | (R) | (R) |  D  | (R) |  E  |  M  |  T  |  L  |
+ * -------------------------------------------------
+ * (R) - bit 7:6,4 are reserved and should be masked in s/w
+ *  D  - Floppy Density Sense (1=high density) R/O
+ *  E  - Link Test Enable, directly reflected on AT&T 7213 LTE pin
+ *  M  - Monitor/Mouse Mux, directly reflected on MON_MSE_MUX pin
+ *  T  - Terminal Count: sends TC pulse to 82077 floppy controller
+ *  L  - System LED on front panel (0=off, 1=on) 
+ */
+#define AUXIO_AUX1_MASK		0xc0 /* Mask bits 		*/
+#define AUXIO_AUX1_FDENS	0x20 /* Floppy Density Sense	*/
+#define AUXIO_AUX1_LTE 		0x08 /* Link Test Enable 	*/
+#define AUXIO_AUX1_MMUX		0x04 /* Monitor/Mouse Mux	*/
+#define AUXIO_AUX1_FTCNT	0x02 /* Terminal Count, 	*/
+#define AUXIO_AUX1_LED		0x01 /* System LED		*/
+
+/* SLAVIO AUX2 @ 0x1910000
+ * -------------------------------------------------
+ * | (R) | (R) |  D  | (R) | (R) | (R) |  C  |  F  |
+ * -------------------------------------------------
+ * (R) - bits 7:6,4:2 are reserved and should be masked in s/w
+ *  D  - Power Failure Detect (1=power fail)
+ *  C  - Clear Power Failure Detect Int (1=clear)
+ *  F  - Power Off (1=power off)
+ */
+#define AUXIO_AUX2_MASK		0xdc /* Mask Bits		*/
+#define AUXIO_AUX2_PFAILDET	0x20 /* Power Fail Detect	*/
+#define AUXIO_AUX2_PFAILCLR 	0x02 /* Clear Pwr Fail Det Intr	*/
+#define AUXIO_AUX2_PWR_OFF	0x01 /* Power Off		*/
 
-extern unsigned long auxio_register;
+/* Register definitions from Sun Microsystems _PCIO_ p/n 802-7837
+ *
+ * PCIO LED Auxio @ 0x726000
+ * -------------------------------------------------
+ * |             31:1 Unused                 | LED |
+ * -------------------------------------------------
+ * Bits 31:1 unused
+ * LED - System LED on front panel (0=off, 1=on)
+ */
+#define AUXIO_PCIO_LED		0x01 /* System LED 		*/ 
 
-/* This register is an unsigned char in IO space.  It does two things.
- * First, it is used to control the front panel LED light on machines
- * that have it (good for testing entry points to trap handlers and irq's)
- * Secondly, it controls various floppy drive parameters.
- */
-#define AUXIO_ORMEIN      0xf0    /* All writes must set these bits. */
-#define AUXIO_ORMEIN4M    0xc0    /* sun4m - All writes must set these bits. */
-#define AUXIO_FLPY_DENS   0x20    /* Floppy density, high if set. Read only. */
-#define AUXIO_FLPY_DCHG   0x10    /* A disk change occurred.  Read only. */
-#define AUXIO_EDGE_ON     0x10    /* sun4m - On means Jumper block is in. */
-#define AUXIO_FLPY_DSEL   0x08    /* Drive select/start-motor. Write only. */
-#define AUXIO_LINK_TEST   0x08    /* sun4m - On means TPE Carrier detect. */
-
-/* Set the following to one, then zero, after doing a pseudo DMA transfer. */
-#define AUXIO_FLPY_TCNT   0x04    /* Floppy terminal count. Write only. */
-
-/* Set the following to zero to eject the floppy. */
-#define AUXIO_FLPY_EJCT   0x02    /* Eject floppy disk.  Write only. */
-#define AUXIO_LED         0x01    /* On if set, off if unset. Read/Write */
-
-#define AUXREG   (auxio_register)
-
-/* These are available on sun4c */
-#define TURN_ON_LED   \
-do {	if (AUXREG) \
-		sbus_writeb(sbus_readb(AUXREG) | \
-			    (AUXIO_ORMEIN | AUXIO_LED), AUXREG); \
-} while(0)
-#define TURN_OFF_LED  \
-do {	if (AUXREG) \
-		sbus_writeb((sbus_readb(AUXREG) | \
-			     AUXIO_ORMEIN) & (~AUXIO_LED), \
-			    AUXREG); \
-} while(0)
-#define FLIP_LED	\
-do {	if (AUXREG)  \
-		sbus_writeb((sbus_readb(AUXREG) | \
-			     AUXIO_ORMEIN) ^ AUXIO_LEN, \
-			    AUXREG); \
-} while(0)
-#define FLPY_MOTORON	\
-do {	if (AUXREG) \
-		sbus_writeb(sbus_readb(AUXREG) | \
-			    (AUXIO_ORMEIN | AUXIO_FLPY_DSEL), \
-			    AUXREG); \
-} while(0)
-#define FLPY_MOTOROFF	\
-do {	if (AUXREG) \
-		sbus_writeb((sbus_readb(AUXREG) | \
-			     AUXIO_ORMEIN) & (~AUXIO_FLPY_DSEL), \
-			    AUXREG); \
-} while(0)
-#define FLPY_TCNTON	\
-do {	if (AUXREG) \
-		sbus_writeb((sbus_readb(AUXREG) | \
-			     AUXIO_ORMEIN) | AUXIO_FLPY_TCNT, \
-			    AUXREG); \
-} while(0)
-#define FLPY_TCNTOFF	\
-do {	if (AUXREG) \
-		sbus_writeb((sbus_readb(AUXREG) | \
-			     AUXIO_ORMEIN) & (~AUXIO_FLPY_TCNT), \
-			    AUXREG); \
-} while(0)
+/* PCIO Power Auxio @ 0x724000
+ * -------------------------------------------------
+ * |             31:2 Unused           | CPO | SPO |
+ * -------------------------------------------------
+ * Bits 31:2 unused
+ * CPO - Courtesy Power Off (1=off)
+ * SPO - System Power Off   (1=off)
+ */
+#define AUXIO_PCIO_CPWR_OFF	0x02 /* Courtesy Power Off	*/
+#define AUXIO_PCIO_SPWR_OFF	0x01 /* System Power Off	*/
 
 #ifndef __ASSEMBLY__
-static __inline__ void set_auxio(unsigned char bits_on, unsigned char bits_off)
-{
-	unsigned char regval;
-	unsigned long flags;
-
-	local_irq_save(flags);
-	if (AUXREG) {
-		unsigned char newval;
-
-		regval = sbus_readb(AUXREG);
-		newval  = regval | bits_on;
-		newval &= ~bits_off;
-		newval |= AUXIO_ORMEIN4M;
-		sbus_writeb(newval, AUXREG);
-	}
-	local_irq_restore(flags);
-}
-#endif /* !(__ASSEMBLY__) */
-
-
-/* AUXIO2 (Power Off Control) */
-extern __volatile__ unsigned char * auxio_power_register;
-
-#define	AUXIO_POWER_DETECT_FAILURE	32
-#define	AUXIO_POWER_CLEAR_FAILURE	2
-#define	AUXIO_POWER_OFF			1
 
+#define AUXIO_LTE_ON	1
+#define AUXIO_LTE_OFF	0
+
+/* auxio_set_lte - Set Link Test Enable (TPE Link Detect)
+ *
+ * on - AUXIO_LTE_ON or AUXIO_LTE_OFF
+ */
+extern void auxio_set_lte(int on);
+
+#define AUXIO_LED_ON	1
+#define AUXIO_LED_OFF	0
+
+/* auxio_set_led - Set system front panel LED 
+ *
+ * on - AUXIO_LED_ON or AUXIO_LED_OFF
+ */
+extern void auxio_set_led(int on);
+
+#endif /* ifndef __ASSEMBLY__ */ 
 
-#endif /* !(_SPARC_AUXIO_H) */
+#endif /* !(_SPARC64_AUXIO_H) */
diff -Nru a/include/asm-sparc64/bpp.h b/include/asm-sparc64/bpp.h
--- a/include/asm-sparc64/bpp.h	Wed Apr 30 22:28:19 2003
+++ b/include/asm-sparc64/bpp.h	Wed Apr 30 22:28:19 2003
@@ -17,7 +17,7 @@
  * with compliant or compatible devices. It will use whatever features
  * the device supports, prefering those that are typically faster.
  *
- * When the device is opened, it is left in COMPATABILITY mode, and
+ * When the device is opened, it is left in COMPATIBILITY mode, and
  * writes work like any printer device. The driver only attempt to
  * negotiate 1284 modes when needed so that plugs can be pulled,
  * switch boxes switched, etc., without disrupting things. It will
diff -Nru a/include/asm-sparc64/chafsr.h b/include/asm-sparc64/chafsr.h
--- a/include/asm-sparc64/chafsr.h	Wed Apr 30 22:28:13 2003
+++ b/include/asm-sparc64/chafsr.h	Wed Apr 30 22:28:13 2003
@@ -61,7 +61,7 @@
 /* Uncorrectable system bus data ECC error for read of interrupt vector */
 #define CHAFSR_IVU		0x0000200000000000
 
-/* Unmappeed error from system bus */
+/* Unmapped error from system bus */
 #define CHAFSR_TO		0x0000100000000000
 
 /* Bus error response from system bus */
@@ -127,7 +127,7 @@
 
 /* The AFSR must be explicitly cleared by software, it is not cleared automatically
  * by a read.  Writes to bits <51:33> with bits set will clear the corresponding
- * bits in the AFSR.  Bits assosciated with disrupting traps must be cleared before
+ * bits in the AFSR.  Bits associated with disrupting traps must be cleared before
  * interrupts are re-enabled to prevent multiple traps for the same error.  I.e.
  * PSTATE.IE and AFSR bits control delivery of disrupting traps.
  *
diff -Nru a/include/asm-sparc64/estate.h b/include/asm-sparc64/estate.h
--- a/include/asm-sparc64/estate.h	Wed Apr 30 22:28:15 2003
+++ b/include/asm-sparc64/estate.h	Wed Apr 30 22:28:15 2003
@@ -15,7 +15,7 @@
  * errors 2) uncorrectable E-cache errors.  Such events only occur on reads
  * of the E-cache by the local processor for: 1) data loads 2) instruction
  * fetches 3) atomic operations.  Such events _cannot_ occur for: 1) merge
- * 2) writeback 2) copyout.  The AFSR bits assosciated with these traps are
+ * 2) writeback 2) copyout.  The AFSR bits associated with these traps are
  * UCC and UCU.
  */
 
@@ -31,7 +31,7 @@
  * 4) As the result of such errors on instruction vector fetch can generate any
  *    of the 3 trap types.
  *
- * The AFSR bits assosciated with these traps are EMU, EDU, WDU, CPU, IVU, UE,
+ * The AFSR bits associated with these traps are EMU, EDU, WDU, CPU, IVU, UE,
  * BERR, and TO.
  */
 
diff -Nru a/include/asm-sparc64/irq.h b/include/asm-sparc64/irq.h
--- a/include/asm-sparc64/irq.h	Wed Apr 30 22:28:10 2003
+++ b/include/asm-sparc64/irq.h	Wed Apr 30 22:28:10 2003
@@ -12,6 +12,7 @@
 #include <linux/linkage.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
+#include <linux/interrupt.h>
 #include <asm/pil.h>
 #include <asm/ptrace.h>
 
@@ -113,7 +114,7 @@
 
 #define NR_IRQS    16
 
-#define irq_cannonicalize(irq)	(irq)
+#define irq_canonicalize(irq)	(irq)
 extern void disable_irq(unsigned int);
 #define disable_irq_nosync disable_irq
 extern void enable_irq(unsigned int);
@@ -128,7 +129,7 @@
 #endif
 
 extern int request_fast_irq(unsigned int irq,
-			    void (*handler)(int, void *, struct pt_regs *),
+			    irqreturn_t (*handler)(int, void *, struct pt_regs *),
 			    unsigned long flags, __const__ char *devname,
 			    void *dev_id);
 
diff -Nru a/include/asm-sparc64/ns87303.h b/include/asm-sparc64/ns87303.h
--- a/include/asm-sparc64/ns87303.h	Wed Apr 30 22:28:12 2003
+++ b/include/asm-sparc64/ns87303.h	Wed Apr 30 22:28:12 2003
@@ -9,7 +9,7 @@
 #define _SPARC_NS87303_H 1
 
 /*
- * Controll Register Index Values
+ * Control Register Index Values
  */
 #define FER	0x00
 #define FAR	0x01
@@ -58,7 +58,7 @@
 #define TUP_EPP_TIMO	0x02	/* Enable EPP timeout IRQ                    */
 
 /* Advanced SuperIO Config Register (ASC) bits */
-#define ASC_LPT_IRQ7	0x01	/* Allways use IRQ7 for LPT                  */
+#define ASC_LPT_IRQ7	0x01	/* Always use IRQ7 for LPT                  */
 #define ASC_DRV2_SEL	0x02	/* Logical Drive Exchange controlled by TDR  */
 
 #define FER_RESERVED	0x00
diff -Nru a/include/asm-sparc64/pci.h b/include/asm-sparc64/pci.h
--- a/include/asm-sparc64/pci.h	Wed Apr 30 22:28:05 2003
+++ b/include/asm-sparc64/pci.h	Wed Apr 30 22:28:05 2003
@@ -50,7 +50,7 @@
  * size must be the same as what as passed into pci_alloc_consistent,
  * and likewise dma_addr must be the same as what *dma_addrp was set to.
  *
- * References to the memory and mappings assosciated with cpu_addr/dma_addr
+ * References to the memory and mappings associated with cpu_addr/dma_addr
  * past this call are illegal.
  */
 extern void pci_free_consistent(struct pci_dev *hwdev, size_t size, void *vaddr, dma_addr_t dma_handle);
@@ -92,7 +92,7 @@
 	(((PTR)->LEN_NAME) = (VAL))
 
 /* Map a set of buffers described by scatterlist in streaming
- * mode for DMA.  This is the scather-gather version of the
+ * mode for DMA.  This is the scatter-gather version of the
  * above pci_map_single interface.  Here the scatter gather list
  * elements are each tagged with the appropriate dma address
  * and length.  They are obtained via sg_dma_{address,length}(SG).
diff -Nru a/include/asm-sparc64/pgalloc.h b/include/asm-sparc64/pgalloc.h
--- a/include/asm-sparc64/pgalloc.h	Wed Apr 30 22:28:17 2003
+++ b/include/asm-sparc64/pgalloc.h	Wed Apr 30 22:28:18 2003
@@ -71,7 +71,7 @@
 		struct page *page;
 
 		preempt_enable();
-		page = alloc_page(GFP_KERNEL);
+		page = alloc_page(GFP_KERNEL|__GFP_REPEAT);
 		if (page) {
 			ret = (struct page *)page_address(page);
 			clear_page(ret);
@@ -110,7 +110,7 @@
 		preempt_enable();
 	} else {
 		preempt_enable();
-		ret = (unsigned long *) __get_free_page(GFP_KERNEL);
+		ret = (unsigned long *) __get_free_page(GFP_KERNEL|__GFP_REPEAT);
 		if(ret)
 			memset(ret, 0, PAGE_SIZE);
 	}
@@ -159,7 +159,7 @@
 
 	pmd = pmd_alloc_one_fast(mm, address);
 	if (!pmd) {
-		pmd = (pmd_t *)__get_free_page(GFP_KERNEL);
+		pmd = (pmd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 		if (pmd)
 			memset(pmd, 0, PAGE_SIZE);
 	}
diff -Nru a/include/asm-sparc64/signal.h b/include/asm-sparc64/signal.h
--- a/include/asm-sparc64/signal.h	Wed Apr 30 22:28:06 2003
+++ b/include/asm-sparc64/signal.h	Wed Apr 30 22:28:06 2003
@@ -123,10 +123,10 @@
 };
 
 /* Sigvec flags */
-#define SV_SSTACK    1u    /* This signal handler should use sig-stack */
-#define SV_INTR      2u    /* Sig return should not restart system call */
-#define SV_RESET     4u    /* Set handler to SIG_DFL upon taken signal */
-#define SV_IGNCHILD  8u    /* Do not send SIGCHLD */
+#define _SV_SSTACK    1u    /* This signal handler should use sig-stack */
+#define _SV_INTR      2u    /* Sig return should not restart system call */
+#define _SV_RESET     4u    /* Set handler to SIG_DFL upon taken signal */
+#define _SV_IGNCHILD  8u    /* Do not send SIGCHLD */
 
 /*
  * sa_flags values: SA_STACK is not currently supported, but will allow the
@@ -137,11 +137,11 @@
  * SA_RESTART flag to get restarting signals (which were the default long ago)
  * SA_SHIRQ flag is for shared interrupt support on PCI and EISA.
  */
-#define SA_NOCLDSTOP	SV_IGNCHILD
-#define SA_STACK	SV_SSTACK
-#define SA_ONSTACK	SV_SSTACK
-#define SA_RESTART	SV_INTR
-#define SA_ONESHOT	SV_RESET
+#define SA_NOCLDSTOP	_SV_IGNCHILD
+#define SA_STACK	_SV_SSTACK
+#define SA_ONSTACK	_SV_SSTACK
+#define SA_RESTART	_SV_INTR
+#define SA_ONESHOT	_SV_RESET
 #define SA_INTERRUPT	0x10u
 #define SA_NOMASK	0x20u
 #define SA_SHIRQ	0x40u
diff -Nru a/include/asm-sparc64/svr4.h b/include/asm-sparc64/svr4.h
--- a/include/asm-sparc64/svr4.h	Wed Apr 30 22:28:11 2003
+++ b/include/asm-sparc64/svr4.h	Wed Apr 30 22:28:11 2003
@@ -85,7 +85,7 @@
 	SVR4_SS_DISABLE,
 };
 
-/* signal stack exection place, unsupported */
+/* signal stack execution place, unsupported */
 typedef struct svr4_stack_t {
         char *sp;
         int  size;
diff -Nru a/include/asm-sparc64/timer.h b/include/asm-sparc64/timer.h
--- a/include/asm-sparc64/timer.h	Wed Apr 30 22:28:04 2003
+++ b/include/asm-sparc64/timer.h	Wed Apr 30 22:28:04 2003
@@ -7,6 +7,8 @@
 #ifndef _SPARC64_TIMER_H
 #define _SPARC64_TIMER_H
 
+#include <linux/types.h>
+
 /* How timers work:
  *
  * On uniprocessors we just use counter zero for the system wide
@@ -63,6 +65,7 @@
 
 #ifdef CONFIG_SMP
 extern unsigned long timer_tick_offset;
+struct pt_regs;
 extern void timer_tick_interrupt(struct pt_regs *);
 #endif
 
diff -Nru a/include/asm-sparc64/upa.h b/include/asm-sparc64/upa.h
--- a/include/asm-sparc64/upa.h	Wed Apr 30 22:28:18 2003
+++ b/include/asm-sparc64/upa.h	Wed Apr 30 22:28:18 2003
@@ -21,7 +21,7 @@
 #define UPA_PORTID_PREQDQ       0x000000007e000000 /* slave-wr's to mod supported  */
 #define UPA_PORTID_PREQRD       0x0000000001e00000 /* # incoming P_REQ's supported */
 #define UPA_PORTID_UPACAP       0x00000000001f0000 /* UPA capabilities of mod      */
-#define UPA_PORTID_ID           0x000000000000ffff /* Module Indentification bits  */
+#define UPA_PORTID_ID           0x000000000000ffff /* Module Identification bits  */
 
 /* UPA I/O space accessors */
 #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
diff -Nru a/include/asm-v850/irq.h b/include/asm-v850/irq.h
--- a/include/asm-v850/irq.h	Wed Apr 30 22:28:17 2003
+++ b/include/asm-v850/irq.h	Wed Apr 30 22:28:17 2003
@@ -37,7 +37,7 @@
 struct hw_interrupt_type;
 struct irqaction;
 
-#define irq_cannonicalize(irq)	(irq)
+#define irq_canonicalize(irq)	(irq)
 
 /* Initialize irq handling for IRQs.
    BASE_IRQ, BASE_IRQ+INTERVAL, ..., BASE_IRQ+NUM*INTERVAL
diff -Nru a/include/asm-x86_64/floppy.h b/include/asm-x86_64/floppy.h
--- a/include/asm-x86_64/floppy.h	Wed Apr 30 22:28:06 2003
+++ b/include/asm-x86_64/floppy.h	Wed Apr 30 22:28:06 2003
@@ -51,7 +51,7 @@
 static int virtual_dma_mode;
 static int doing_pdma;
 
-static void floppy_hardint(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t floppy_hardint(int irq, void *dev_id, struct pt_regs * regs)
 {
 	register unsigned char st;
 
@@ -109,12 +109,14 @@
 #endif
 		doing_pdma = 0;
 		floppy_interrupt(irq, dev_id, regs);
-		return;
+		return IRQ_HANDLED;
 	}
 #ifdef TRACE_FLPY_INT
 	if(!virtual_dma_count)
 		dma_wait++;
 #endif
+
+	return IRQ_HANDLED;
 }
 
 static void fd_disable_dma(void)
diff -Nru a/include/asm-x86_64/irq.h b/include/asm-x86_64/irq.h
--- a/include/asm-x86_64/irq.h	Wed Apr 30 22:28:03 2003
+++ b/include/asm-x86_64/irq.h	Wed Apr 30 22:28:03 2003
@@ -23,7 +23,7 @@
  */
 #define NR_IRQS 224
 
-static __inline__ int irq_cannonicalize(int irq)
+static __inline__ int irq_canonicalize(int irq)
 {
 	return ((irq == 2) ? 9 : irq);
 }
diff -Nru a/include/asm-x86_64/mpspec.h b/include/asm-x86_64/mpspec.h
--- a/include/asm-x86_64/mpspec.h	Wed Apr 30 22:28:08 2003
+++ b/include/asm-x86_64/mpspec.h	Wed Apr 30 22:28:08 2003
@@ -198,6 +198,8 @@
 #endif /*CONFIG_X86_IO_APIC*/
 #endif
 
+extern void mp_config_ioapic_for_sci(int irq);
+
 extern int using_apic_timer;
 
 #endif
diff -Nru a/include/asm-x86_64/msr.h b/include/asm-x86_64/msr.h
--- a/include/asm-x86_64/msr.h	Wed Apr 30 22:28:17 2003
+++ b/include/asm-x86_64/msr.h	Wed Apr 30 22:28:17 2003
@@ -228,6 +228,9 @@
 
 /* VIA Cyrix defined MSRs*/
 #define MSR_VIA_FCR			0x1107
+#define MSR_VIA_LONGHAUL		0x110a
+#define MSR_VIA_RNG			0x110b
+#define MSR_VIA_BCR2			0x1147
 
 /* Intel defined MSRs. */
 #define MSR_IA32_P5_MC_ADDR		0
diff -Nru a/include/asm-x86_64/pgalloc.h b/include/asm-x86_64/pgalloc.h
--- a/include/asm-x86_64/pgalloc.h	Wed Apr 30 22:28:10 2003
+++ b/include/asm-x86_64/pgalloc.h	Wed Apr 30 22:28:10 2003
@@ -31,12 +31,12 @@
 
 static inline pmd_t *pmd_alloc_one (struct mm_struct *mm, unsigned long addr)
 {
-	return (pmd_t *) get_zeroed_page(GFP_KERNEL); 
+	return (pmd_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
 }
 
 static inline pgd_t *pgd_alloc (struct mm_struct *mm)
 {
-	return (pgd_t *)get_zeroed_page(GFP_KERNEL);
+	return (pgd_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
 }
 
 static inline void pgd_free (pgd_t *pgd)
@@ -48,12 +48,12 @@
 
 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
 {
-	return (pte_t *) get_zeroed_page(GFP_KERNEL);
+	return (pte_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
 }
 
 static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	void *p = (void *)get_zeroed_page(GFP_KERNEL); 
+	void *p = (void *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
 	if (!p)
 		return NULL;
 	return virt_to_page(p);
diff -Nru a/include/asm-x86_64/processor.h b/include/asm-x86_64/processor.h
--- a/include/asm-x86_64/processor.h	Wed Apr 30 22:28:18 2003
+++ b/include/asm-x86_64/processor.h	Wed Apr 30 22:28:18 2003
@@ -304,11 +304,16 @@
 
 #define cpu_has_fpu 1
 
+#if 0
+/* disabled for now to work around opteron errata #91. Also gcc 3.2
+   doesn't like this in some cases. */
 #define ARCH_HAS_PREFETCH
+#define prefetch(x) __builtin_prefetch((x),0,1)
+#endif
+
 #define ARCH_HAS_PREFETCHW
 #define ARCH_HAS_SPINLOCK_PREFETCH
 
-#define prefetch(x) __builtin_prefetch((x),0,1)
 #define prefetchw(x) __builtin_prefetch((x),1,1)
 #define spin_lock_prefetch(x)  prefetchw(x)
 #define cpu_relax()   rep_nop()
diff -Nru a/include/asm-x86_64/vsyscall.h b/include/asm-x86_64/vsyscall.h
--- a/include/asm-x86_64/vsyscall.h	Wed Apr 30 22:28:18 2003
+++ b/include/asm-x86_64/vsyscall.h	Wed Apr 30 22:28:18 2003
@@ -1,7 +1,6 @@
 #ifndef _ASM_X86_64_VSYSCALL_H_
 #define _ASM_X86_64_VSYSCALL_H_
 
-#include <linux/time.h>
 #include <linux/seqlock.h>
 
 enum vsyscall_num {
diff -Nru a/include/linux/8250_pci.h b/include/linux/8250_pci.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/include/linux/8250_pci.h	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,2 @@
+int pci_siig10x_fn(struct pci_dev *dev, int enable);
+int pci_siig20x_fn(struct pci_dev *dev, int enable);
diff -Nru a/include/linux/acpi.h b/include/linux/acpi.h
--- a/include/linux/acpi.h	Wed Apr 30 22:28:03 2003
+++ b/include/linux/acpi.h	Wed Apr 30 22:28:03 2003
@@ -33,6 +33,7 @@
 
 #include <acpi/acpi.h>
 #include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
 #include <asm/acpi.h>
 
 
diff -Nru a/include/linux/blk.h b/include/linux/blk.h
--- a/include/linux/blk.h	Wed Apr 30 22:28:15 2003
+++ b/include/linux/blk.h	Wed Apr 30 22:28:15 2003
@@ -12,24 +12,6 @@
 extern void add_disk_randomness(struct gendisk *disk);
 extern void rand_initialize_disk(struct gendisk *disk);
 
-#ifdef CONFIG_BLK_DEV_RAM
-
-extern int rd_doload;          /* 1 = load ramdisk, 0 = don't load */
-extern int rd_prompt;          /* 1 = prompt for ramdisk, 0 = don't prompt */
-extern int rd_image_start;     /* starting block # of image */
-
-#ifdef CONFIG_BLK_DEV_INITRD
-
-#define INITRD_MINOR 250 /* shouldn't collide with /dev/ram* too soon ... */
-
-extern unsigned long initrd_start,initrd_end;
-extern int initrd_below_start_ok; /* 1 if it is not an error if initrd_start < memory_start */
-void initrd_init(void);
-
-#endif /* CONFIG_BLK_DEV_INITRD */
-
-#endif
-
 /*
  * end_request() and friends. Must be called with the request queue spinlock
  * acquired. All functions called within end_request() _must_be_ atomic.
@@ -43,6 +25,7 @@
 extern int end_that_request_first(struct request *, int, int);
 extern int end_that_request_chunk(struct request *, int, int);
 extern void end_that_request_last(struct request *);
+extern void end_request(struct request *req, int uptodate);
 struct request *elv_next_request(request_queue_t *q);
 
 static inline void blkdev_dequeue_request(struct request *req)
@@ -54,20 +37,5 @@
 	if (req->q)
 		elv_remove_request(req->q, req);
 }
-
-/*
- * If we have our own end_request, we do not want to include this mess
- */
-#ifndef LOCAL_END_REQUEST
-static inline void end_request(struct request *req, int uptodate)
-{
-	if (end_that_request_first(req, uptodate, req->hard_cur_sectors))
-		return;
-
-	add_disk_randomness(req->rq_disk);
-	blkdev_dequeue_request(req);
-	end_that_request_last(req);
-}
-#endif /* !LOCAL_END_REQUEST */
 
 #endif /* _BLK_H */
diff -Nru a/include/linux/blkdev.h b/include/linux/blkdev.h
--- a/include/linux/blkdev.h	Wed Apr 30 22:28:05 2003
+++ b/include/linux/blkdev.h	Wed Apr 30 22:28:05 2003
@@ -341,7 +341,7 @@
 extern void blk_start_queue(request_queue_t *q);
 extern void blk_stop_queue(request_queue_t *q);
 extern void __blk_stop_queue(request_queue_t *q);
-extern void __blk_run_queue(request_queue_t *q);
+extern void blk_run_queue(request_queue_t *q);
 
 static inline request_queue_t *bdev_get_queue(struct block_device *bdev)
 {
@@ -390,6 +390,8 @@
 extern void blk_queue_free_tags(request_queue_t *);
 extern void blk_queue_invalidate_tags(request_queue_t *);
 extern void blk_congestion_wait(int rw, long timeout);
+
+extern void blk_rq_bio_prep(request_queue_t *, struct request *, struct bio *);
 
 #define MAX_PHYS_SEGMENTS 128
 #define MAX_HW_SEGMENTS 128
diff -Nru a/include/linux/buffer_head.h b/include/linux/buffer_head.h
--- a/include/linux/buffer_head.h	Wed Apr 30 22:28:03 2003
+++ b/include/linux/buffer_head.h	Wed Apr 30 22:28:03 2003
@@ -128,9 +128,6 @@
 	})
 #define page_has_buffers(page)	PagePrivate(page)
 
-#define invalidate_buffers(dev)	__invalidate_buffers((dev), 0)
-
-
 /*
  * Declarations
  */
@@ -159,7 +156,6 @@
 void mark_buffer_async_read(struct buffer_head *bh);
 void mark_buffer_async_write(struct buffer_head *bh);
 void invalidate_bdev(struct block_device *, int);
-void __invalidate_buffers(kdev_t dev, int);
 int sync_blockdev(struct block_device *bdev);
 void __wait_on_buffer(struct buffer_head *);
 wait_queue_head_t *bh_waitq_head(struct buffer_head *bh);
@@ -172,7 +168,7 @@
 void __brelse(struct buffer_head *);
 void __bforget(struct buffer_head *);
 struct buffer_head *__bread(struct block_device *, sector_t block, int size);
-struct buffer_head *alloc_buffer_head(void);
+struct buffer_head *alloc_buffer_head(int gfp_flags);
 void free_buffer_head(struct buffer_head * bh);
 void FASTCALL(unlock_buffer(struct buffer_head *bh));
 void ll_rw_block(int, int, struct buffer_head * bh[]);
diff -Nru a/include/linux/cdrom.h b/include/linux/cdrom.h
--- a/include/linux/cdrom.h	Wed Apr 30 22:28:03 2003
+++ b/include/linux/cdrom.h	Wed Apr 30 22:28:03 2003
@@ -715,7 +715,7 @@
 };
 
 #ifdef __KERNEL__
-#include <linux/devfs_fs_kernel.h>
+#include <linux/fs.h>		/* not really needed, later.. */
 #include <linux/device.h>
 
 struct cdrom_write_settings {
diff -Nru a/include/linux/compat_ioctl.h b/include/linux/compat_ioctl.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/include/linux/compat_ioctl.h	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,653 @@
+/* List here explicitly which ioctl's are known to have
+ * compatible types passed or none at all...
+ */
+/* Big T */
+COMPATIBLE_IOCTL(TCGETA)
+COMPATIBLE_IOCTL(TCSETA)
+COMPATIBLE_IOCTL(TCSETAW)
+COMPATIBLE_IOCTL(TCSETAF)
+COMPATIBLE_IOCTL(TCSBRK)
+COMPATIBLE_IOCTL(TCXONC)
+COMPATIBLE_IOCTL(TCFLSH)
+COMPATIBLE_IOCTL(TCGETS)
+COMPATIBLE_IOCTL(TCSETS)
+COMPATIBLE_IOCTL(TCSETSW)
+COMPATIBLE_IOCTL(TCSETSF)
+COMPATIBLE_IOCTL(TIOCLINUX)
+/* Little t */
+COMPATIBLE_IOCTL(TIOCGETD)
+COMPATIBLE_IOCTL(TIOCSETD)
+COMPATIBLE_IOCTL(TIOCEXCL)
+COMPATIBLE_IOCTL(TIOCNXCL)
+COMPATIBLE_IOCTL(TIOCCONS)
+COMPATIBLE_IOCTL(TIOCGSOFTCAR)
+COMPATIBLE_IOCTL(TIOCSSOFTCAR)
+COMPATIBLE_IOCTL(TIOCSWINSZ)
+COMPATIBLE_IOCTL(TIOCGWINSZ)
+COMPATIBLE_IOCTL(TIOCMGET)
+COMPATIBLE_IOCTL(TIOCMBIC)
+COMPATIBLE_IOCTL(TIOCMBIS)
+COMPATIBLE_IOCTL(TIOCMSET)
+COMPATIBLE_IOCTL(TIOCPKT)
+COMPATIBLE_IOCTL(TIOCNOTTY)
+COMPATIBLE_IOCTL(TIOCSTI)
+COMPATIBLE_IOCTL(TIOCOUTQ)
+COMPATIBLE_IOCTL(TIOCSPGRP)
+COMPATIBLE_IOCTL(TIOCGPGRP)
+COMPATIBLE_IOCTL(TIOCSCTTY)
+COMPATIBLE_IOCTL(TIOCGPTN)
+COMPATIBLE_IOCTL(TIOCSPTLCK)
+COMPATIBLE_IOCTL(TIOCSERGETLSR)
+/* Big F */
+COMPATIBLE_IOCTL(FBIOGET_VSCREENINFO)
+COMPATIBLE_IOCTL(FBIOPUT_VSCREENINFO)
+COMPATIBLE_IOCTL(FBIOPAN_DISPLAY)
+COMPATIBLE_IOCTL(FBIOGET_CON2FBMAP)
+COMPATIBLE_IOCTL(FBIOPUT_CON2FBMAP)
+/* Little f */
+COMPATIBLE_IOCTL(FIOCLEX)
+COMPATIBLE_IOCTL(FIONCLEX)
+COMPATIBLE_IOCTL(FIOASYNC)
+COMPATIBLE_IOCTL(FIONBIO)
+COMPATIBLE_IOCTL(FIONREAD)  /* This is also TIOCINQ */
+/* 0x00 */
+COMPATIBLE_IOCTL(FIBMAP)
+COMPATIBLE_IOCTL(FIGETBSZ)
+/* 0x03 -- HD/IDE ioctl's used by hdparm and friends.
+ *         Some need translations, these do not.
+ */
+COMPATIBLE_IOCTL(HDIO_GET_IDENTITY)
+COMPATIBLE_IOCTL(HDIO_SET_DMA)
+COMPATIBLE_IOCTL(HDIO_SET_UNMASKINTR)
+COMPATIBLE_IOCTL(HDIO_SET_NOWERR)
+COMPATIBLE_IOCTL(HDIO_SET_32BIT)
+COMPATIBLE_IOCTL(HDIO_SET_MULTCOUNT)
+COMPATIBLE_IOCTL(HDIO_DRIVE_CMD)
+COMPATIBLE_IOCTL(HDIO_SET_PIO_MODE)
+COMPATIBLE_IOCTL(HDIO_SET_NICE)
+/* 0x02 -- Floppy ioctls */
+COMPATIBLE_IOCTL(FDMSGON)
+COMPATIBLE_IOCTL(FDMSGOFF)
+COMPATIBLE_IOCTL(FDSETEMSGTRESH)
+COMPATIBLE_IOCTL(FDFLUSH)
+COMPATIBLE_IOCTL(FDWERRORCLR)
+COMPATIBLE_IOCTL(FDSETMAXERRS)
+COMPATIBLE_IOCTL(FDGETMAXERRS)
+COMPATIBLE_IOCTL(FDGETDRVTYP)
+COMPATIBLE_IOCTL(FDEJECT)
+COMPATIBLE_IOCTL(FDCLRPRM)
+COMPATIBLE_IOCTL(FDFMTBEG)
+COMPATIBLE_IOCTL(FDFMTEND)
+COMPATIBLE_IOCTL(FDRESET)
+COMPATIBLE_IOCTL(FDTWADDLE)
+COMPATIBLE_IOCTL(FDFMTTRK)
+COMPATIBLE_IOCTL(FDRAWCMD)
+/* 0x12 */
+COMPATIBLE_IOCTL(BLKROSET)
+COMPATIBLE_IOCTL(BLKROGET)
+COMPATIBLE_IOCTL(BLKRRPART)
+COMPATIBLE_IOCTL(BLKFLSBUF)
+COMPATIBLE_IOCTL(BLKSECTSET)
+COMPATIBLE_IOCTL(BLKSSZGET)
+/* RAID */
+COMPATIBLE_IOCTL(RAID_VERSION)
+COMPATIBLE_IOCTL(GET_ARRAY_INFO)
+COMPATIBLE_IOCTL(GET_DISK_INFO)
+COMPATIBLE_IOCTL(PRINT_RAID_DEBUG)
+COMPATIBLE_IOCTL(RAID_AUTORUN)
+COMPATIBLE_IOCTL(CLEAR_ARRAY)
+COMPATIBLE_IOCTL(ADD_NEW_DISK)
+COMPATIBLE_IOCTL(HOT_REMOVE_DISK)
+COMPATIBLE_IOCTL(SET_ARRAY_INFO)
+COMPATIBLE_IOCTL(SET_DISK_INFO)
+COMPATIBLE_IOCTL(WRITE_RAID_INFO)
+COMPATIBLE_IOCTL(UNPROTECT_ARRAY)
+COMPATIBLE_IOCTL(PROTECT_ARRAY)
+COMPATIBLE_IOCTL(HOT_ADD_DISK)
+COMPATIBLE_IOCTL(SET_DISK_FAULTY)
+COMPATIBLE_IOCTL(RUN_ARRAY)
+COMPATIBLE_IOCTL(START_ARRAY)
+COMPATIBLE_IOCTL(STOP_ARRAY)
+COMPATIBLE_IOCTL(STOP_ARRAY_RO)
+COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
+#ifdef CONFIG_DM
+/* DM */
+COMPATIBLE_IOCTL(DM_VERSION)
+COMPATIBLE_IOCTL(DM_REMOVE_ALL)
+COMPATIBLE_IOCTL(DM_DEV_CREATE)
+COMPATIBLE_IOCTL(DM_DEV_REMOVE)
+COMPATIBLE_IOCTL(DM_DEV_RELOAD)
+COMPATIBLE_IOCTL(DM_DEV_SUSPEND)
+COMPATIBLE_IOCTL(DM_DEV_RENAME)
+COMPATIBLE_IOCTL(DM_DEV_DEPS)
+COMPATIBLE_IOCTL(DM_DEV_STATUS)
+COMPATIBLE_IOCTL(DM_TARGET_STATUS)
+COMPATIBLE_IOCTL(DM_TARGET_WAIT)
+#endif
+/* Big K */
+COMPATIBLE_IOCTL(PIO_FONT)
+COMPATIBLE_IOCTL(GIO_FONT)
+COMPATIBLE_IOCTL(KDSIGACCEPT)
+COMPATIBLE_IOCTL(KDGETKEYCODE)
+COMPATIBLE_IOCTL(KDSETKEYCODE)
+COMPATIBLE_IOCTL(KIOCSOUND)
+COMPATIBLE_IOCTL(KDMKTONE)
+COMPATIBLE_IOCTL(KDGKBTYPE)
+COMPATIBLE_IOCTL(KDSETMODE)
+COMPATIBLE_IOCTL(KDGETMODE)
+COMPATIBLE_IOCTL(KDSKBMODE)
+COMPATIBLE_IOCTL(KDGKBMODE)
+COMPATIBLE_IOCTL(KDSKBMETA)
+COMPATIBLE_IOCTL(KDGKBMETA)
+COMPATIBLE_IOCTL(KDGKBENT)
+COMPATIBLE_IOCTL(KDSKBENT)
+COMPATIBLE_IOCTL(KDGKBSENT)
+COMPATIBLE_IOCTL(KDSKBSENT)
+COMPATIBLE_IOCTL(KDGKBDIACR)
+COMPATIBLE_IOCTL(KDSKBDIACR)
+COMPATIBLE_IOCTL(KDKBDREP)
+COMPATIBLE_IOCTL(KDGKBLED)
+COMPATIBLE_IOCTL(KDSKBLED)
+COMPATIBLE_IOCTL(KDGETLED)
+COMPATIBLE_IOCTL(KDSETLED)
+COMPATIBLE_IOCTL(GIO_SCRNMAP)
+COMPATIBLE_IOCTL(PIO_SCRNMAP)
+COMPATIBLE_IOCTL(GIO_UNISCRNMAP)
+COMPATIBLE_IOCTL(PIO_UNISCRNMAP)
+COMPATIBLE_IOCTL(PIO_FONTRESET)
+COMPATIBLE_IOCTL(PIO_UNIMAPCLR)
+/* Big S */
+COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
+COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK)
+COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK)
+COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY)
+COMPATIBLE_IOCTL(SCSI_IOCTL_TAGGED_ENABLE)
+COMPATIBLE_IOCTL(SCSI_IOCTL_TAGGED_DISABLE)
+COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER)
+COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND)
+COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST)
+COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI)
+/* Big T */
+COMPATIBLE_IOCTL(TUNSETNOCSUM)
+COMPATIBLE_IOCTL(TUNSETDEBUG)
+COMPATIBLE_IOCTL(TUNSETIFF)
+COMPATIBLE_IOCTL(TUNSETPERSIST)
+COMPATIBLE_IOCTL(TUNSETOWNER)
+/* Big V */
+COMPATIBLE_IOCTL(VT_SETMODE)
+COMPATIBLE_IOCTL(VT_GETMODE)
+COMPATIBLE_IOCTL(VT_GETSTATE)
+COMPATIBLE_IOCTL(VT_OPENQRY)
+COMPATIBLE_IOCTL(VT_ACTIVATE)
+COMPATIBLE_IOCTL(VT_WAITACTIVE)
+COMPATIBLE_IOCTL(VT_RELDISP)
+COMPATIBLE_IOCTL(VT_DISALLOCATE)
+COMPATIBLE_IOCTL(VT_RESIZE)
+COMPATIBLE_IOCTL(VT_RESIZEX)
+COMPATIBLE_IOCTL(VT_LOCKSWITCH)
+COMPATIBLE_IOCTL(VT_UNLOCKSWITCH)
+/* Little v */
+/* Little v, the video4linux ioctls (conflict?) */
+COMPATIBLE_IOCTL(VIDIOCGCAP)
+COMPATIBLE_IOCTL(VIDIOCGCHAN)
+COMPATIBLE_IOCTL(VIDIOCSCHAN)
+COMPATIBLE_IOCTL(VIDIOCGPICT)
+COMPATIBLE_IOCTL(VIDIOCSPICT)
+COMPATIBLE_IOCTL(VIDIOCCAPTURE)
+COMPATIBLE_IOCTL(VIDIOCKEY)
+COMPATIBLE_IOCTL(VIDIOCGAUDIO)
+COMPATIBLE_IOCTL(VIDIOCSAUDIO)
+COMPATIBLE_IOCTL(VIDIOCSYNC)
+COMPATIBLE_IOCTL(VIDIOCMCAPTURE)
+COMPATIBLE_IOCTL(VIDIOCGMBUF)
+COMPATIBLE_IOCTL(VIDIOCGUNIT)
+COMPATIBLE_IOCTL(VIDIOCGCAPTURE)
+COMPATIBLE_IOCTL(VIDIOCSCAPTURE)
+/* BTTV specific... */
+COMPATIBLE_IOCTL(_IOW('v',  BASE_VIDIOCPRIVATE+0, char [256]))
+COMPATIBLE_IOCTL(_IOR('v',  BASE_VIDIOCPRIVATE+1, char [256]))
+COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int))
+COMPATIBLE_IOCTL(_IOW('v' , BASE_VIDIOCPRIVATE+3, char [16])) /* struct bttv_pll_info */
+COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+4, int))
+COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+5, int))
+COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+6, int))
+COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+7, int))
+/* Little p (/dev/rtc, /dev/envctrl, etc.) */
+COMPATIBLE_IOCTL(RTC_AIE_ON)
+COMPATIBLE_IOCTL(RTC_AIE_OFF)
+COMPATIBLE_IOCTL(RTC_UIE_ON)
+COMPATIBLE_IOCTL(RTC_UIE_OFF)
+COMPATIBLE_IOCTL(RTC_PIE_ON)
+COMPATIBLE_IOCTL(RTC_PIE_OFF)
+COMPATIBLE_IOCTL(RTC_WIE_ON)
+COMPATIBLE_IOCTL(RTC_WIE_OFF)
+COMPATIBLE_IOCTL(RTC_ALM_SET)
+COMPATIBLE_IOCTL(RTC_ALM_READ)
+COMPATIBLE_IOCTL(RTC_RD_TIME)
+COMPATIBLE_IOCTL(RTC_SET_TIME)
+COMPATIBLE_IOCTL(RTC_WKALM_SET)
+COMPATIBLE_IOCTL(RTC_WKALM_RD)
+/* Little m */
+COMPATIBLE_IOCTL(MTIOCTOP)
+/* Socket level stuff */
+COMPATIBLE_IOCTL(FIOSETOWN)
+COMPATIBLE_IOCTL(SIOCSPGRP)
+COMPATIBLE_IOCTL(FIOGETOWN)
+COMPATIBLE_IOCTL(SIOCGPGRP)
+COMPATIBLE_IOCTL(SIOCATMARK)
+COMPATIBLE_IOCTL(SIOCSIFLINK)
+COMPATIBLE_IOCTL(SIOCSIFENCAP)
+COMPATIBLE_IOCTL(SIOCGIFENCAP)
+COMPATIBLE_IOCTL(SIOCSIFBR)
+COMPATIBLE_IOCTL(SIOCGIFBR)
+COMPATIBLE_IOCTL(SIOCSARP)
+COMPATIBLE_IOCTL(SIOCGARP)
+COMPATIBLE_IOCTL(SIOCDARP)
+COMPATIBLE_IOCTL(SIOCSRARP)
+COMPATIBLE_IOCTL(SIOCGRARP)
+COMPATIBLE_IOCTL(SIOCDRARP)
+COMPATIBLE_IOCTL(SIOCADDDLCI)
+COMPATIBLE_IOCTL(SIOCDELDLCI)
+COMPATIBLE_IOCTL(SIOCGMIIPHY)
+COMPATIBLE_IOCTL(SIOCGMIIREG)
+COMPATIBLE_IOCTL(SIOCSMIIREG)
+COMPATIBLE_IOCTL(SIOCGIFVLAN)
+COMPATIBLE_IOCTL(SIOCSIFVLAN)
+/* SG stuff */
+COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
+COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
+COMPATIBLE_IOCTL(SG_EMULATED_HOST)
+COMPATIBLE_IOCTL(SG_SET_TRANSFORM)
+COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
+COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
+COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
+COMPATIBLE_IOCTL(SG_GET_SCSI_ID)
+COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA)
+COMPATIBLE_IOCTL(SG_GET_LOW_DMA)
+COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID)
+COMPATIBLE_IOCTL(SG_GET_PACK_ID)
+COMPATIBLE_IOCTL(SG_GET_NUM_WAITING)
+COMPATIBLE_IOCTL(SG_SET_DEBUG)
+COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE)
+COMPATIBLE_IOCTL(SG_GET_COMMAND_Q)
+COMPATIBLE_IOCTL(SG_SET_COMMAND_Q)
+COMPATIBLE_IOCTL(SG_GET_VERSION_NUM)
+COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN)
+COMPATIBLE_IOCTL(SG_SCSI_RESET)
+COMPATIBLE_IOCTL(SG_IO)
+COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE)
+COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
+COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
+/* PPP stuff */
+COMPATIBLE_IOCTL(PPPIOCGFLAGS)
+COMPATIBLE_IOCTL(PPPIOCSFLAGS)
+COMPATIBLE_IOCTL(PPPIOCGASYNCMAP)
+COMPATIBLE_IOCTL(PPPIOCSASYNCMAP)
+COMPATIBLE_IOCTL(PPPIOCGUNIT)
+COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP)
+COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP)
+COMPATIBLE_IOCTL(PPPIOCGMRU)
+COMPATIBLE_IOCTL(PPPIOCSMRU)
+COMPATIBLE_IOCTL(PPPIOCSMAXCID)
+COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP)
+COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP)
+COMPATIBLE_IOCTL(PPPIOCXFERUNIT)
+/* PPPIOCSCOMPRESS is translated */
+COMPATIBLE_IOCTL(PPPIOCGNPMODE)
+COMPATIBLE_IOCTL(PPPIOCSNPMODE)
+COMPATIBLE_IOCTL(PPPIOCGDEBUG)
+COMPATIBLE_IOCTL(PPPIOCSDEBUG)
+/* PPPIOCSPASS is translated */
+/* PPPIOCSACTIVE is translated */
+/* PPPIOCGIDLE is translated */
+COMPATIBLE_IOCTL(PPPIOCNEWUNIT)
+COMPATIBLE_IOCTL(PPPIOCATTACH)
+COMPATIBLE_IOCTL(PPPIOCDETACH)
+COMPATIBLE_IOCTL(PPPIOCSMRRU)
+COMPATIBLE_IOCTL(PPPIOCCONNECT)
+COMPATIBLE_IOCTL(PPPIOCDISCONN)
+COMPATIBLE_IOCTL(PPPIOCATTCHAN)
+COMPATIBLE_IOCTL(PPPIOCGCHAN)
+/* PPPOX */
+COMPATIBLE_IOCTL(PPPOEIOCSFWD)
+COMPATIBLE_IOCTL(PPPOEIOCDFWD)
+/* LP */
+COMPATIBLE_IOCTL(LPGETSTATUS)
+/* CDROM stuff */
+COMPATIBLE_IOCTL(CDROMPAUSE)
+COMPATIBLE_IOCTL(CDROMRESUME)
+COMPATIBLE_IOCTL(CDROMPLAYMSF)
+COMPATIBLE_IOCTL(CDROMPLAYTRKIND)
+COMPATIBLE_IOCTL(CDROMREADTOCHDR)
+COMPATIBLE_IOCTL(CDROMREADTOCENTRY)
+COMPATIBLE_IOCTL(CDROMSTOP)
+COMPATIBLE_IOCTL(CDROMSTART)
+COMPATIBLE_IOCTL(CDROMEJECT)
+COMPATIBLE_IOCTL(CDROMVOLCTRL)
+COMPATIBLE_IOCTL(CDROMSUBCHNL)
+COMPATIBLE_IOCTL(CDROMEJECT_SW)
+COMPATIBLE_IOCTL(CDROMMULTISESSION)
+COMPATIBLE_IOCTL(CDROM_GET_MCN)
+COMPATIBLE_IOCTL(CDROMRESET)
+COMPATIBLE_IOCTL(CDROMVOLREAD)
+COMPATIBLE_IOCTL(CDROMSEEK)
+COMPATIBLE_IOCTL(CDROMPLAYBLK)
+COMPATIBLE_IOCTL(CDROMCLOSETRAY)
+COMPATIBLE_IOCTL(CDROM_SET_OPTIONS)
+COMPATIBLE_IOCTL(CDROM_CLEAR_OPTIONS)
+COMPATIBLE_IOCTL(CDROM_SELECT_SPEED)
+COMPATIBLE_IOCTL(CDROM_SELECT_DISC)
+COMPATIBLE_IOCTL(CDROM_MEDIA_CHANGED)
+COMPATIBLE_IOCTL(CDROM_DRIVE_STATUS)
+COMPATIBLE_IOCTL(CDROM_DISC_STATUS)
+COMPATIBLE_IOCTL(CDROM_CHANGER_NSLOTS)
+COMPATIBLE_IOCTL(CDROM_LOCKDOOR)
+COMPATIBLE_IOCTL(CDROM_DEBUG)
+COMPATIBLE_IOCTL(CDROM_GET_CAPABILITY)
+/* DVD ioctls */
+COMPATIBLE_IOCTL(DVD_READ_STRUCT)
+COMPATIBLE_IOCTL(DVD_WRITE_STRUCT)
+COMPATIBLE_IOCTL(DVD_AUTH)
+/* Big L */
+COMPATIBLE_IOCTL(LOOP_SET_FD)
+COMPATIBLE_IOCTL(LOOP_CLR_FD)
+/* Big A */
+/* sparc only */
+/* Big Q for sound/OSS */
+COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC)
+COMPATIBLE_IOCTL(SNDCTL_SYNTH_INFO)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_CTRLRATE)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_GETOUTCOUNT)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_GETINCOUNT)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_PERCMODE)
+COMPATIBLE_IOCTL(SNDCTL_FM_LOAD_INSTR)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_TESTMIDI)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_RESETSAMPLES)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_NRSYNTHS)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_NRMIDIS)
+COMPATIBLE_IOCTL(SNDCTL_MIDI_INFO)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_THRESHOLD)
+COMPATIBLE_IOCTL(SNDCTL_SYNTH_MEMAVL)
+COMPATIBLE_IOCTL(SNDCTL_FM_4OP_ENABLE)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_PANIC)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_OUTOFBAND)
+COMPATIBLE_IOCTL(SNDCTL_SEQ_GETTIME)
+COMPATIBLE_IOCTL(SNDCTL_SYNTH_ID)
+COMPATIBLE_IOCTL(SNDCTL_SYNTH_CONTROL)
+COMPATIBLE_IOCTL(SNDCTL_SYNTH_REMOVESAMPLE)
+/* Big T for sound/OSS */
+COMPATIBLE_IOCTL(SNDCTL_TMR_TIMEBASE)
+COMPATIBLE_IOCTL(SNDCTL_TMR_START)
+COMPATIBLE_IOCTL(SNDCTL_TMR_STOP)
+COMPATIBLE_IOCTL(SNDCTL_TMR_CONTINUE)
+COMPATIBLE_IOCTL(SNDCTL_TMR_TEMPO)
+COMPATIBLE_IOCTL(SNDCTL_TMR_SOURCE)
+COMPATIBLE_IOCTL(SNDCTL_TMR_METRONOME)
+COMPATIBLE_IOCTL(SNDCTL_TMR_SELECT)
+/* Little m for sound/OSS */
+COMPATIBLE_IOCTL(SNDCTL_MIDI_PRETIME)
+COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUMODE)
+COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUCMD)
+/* Big P for sound/OSS */
+COMPATIBLE_IOCTL(SNDCTL_DSP_RESET)
+COMPATIBLE_IOCTL(SNDCTL_DSP_SYNC)
+COMPATIBLE_IOCTL(SNDCTL_DSP_SPEED)
+COMPATIBLE_IOCTL(SNDCTL_DSP_STEREO)
+COMPATIBLE_IOCTL(SNDCTL_DSP_GETBLKSIZE)
+COMPATIBLE_IOCTL(SNDCTL_DSP_CHANNELS)
+COMPATIBLE_IOCTL(SOUND_PCM_WRITE_FILTER)
+COMPATIBLE_IOCTL(SNDCTL_DSP_POST)
+COMPATIBLE_IOCTL(SNDCTL_DSP_SUBDIVIDE)
+COMPATIBLE_IOCTL(SNDCTL_DSP_SETFRAGMENT)
+COMPATIBLE_IOCTL(SNDCTL_DSP_GETFMTS)
+COMPATIBLE_IOCTL(SNDCTL_DSP_SETFMT)
+COMPATIBLE_IOCTL(SNDCTL_DSP_GETOSPACE)
+COMPATIBLE_IOCTL(SNDCTL_DSP_GETISPACE)
+COMPATIBLE_IOCTL(SNDCTL_DSP_NONBLOCK)
+COMPATIBLE_IOCTL(SNDCTL_DSP_GETCAPS)
+COMPATIBLE_IOCTL(SNDCTL_DSP_GETTRIGGER)
+COMPATIBLE_IOCTL(SNDCTL_DSP_SETTRIGGER)
+COMPATIBLE_IOCTL(SNDCTL_DSP_GETIPTR)
+COMPATIBLE_IOCTL(SNDCTL_DSP_GETOPTR)
+/* SNDCTL_DSP_MAPINBUF,  XXX needs translation */
+/* SNDCTL_DSP_MAPOUTBUF,  XXX needs translation */
+COMPATIBLE_IOCTL(SNDCTL_DSP_SETSYNCRO)
+COMPATIBLE_IOCTL(SNDCTL_DSP_SETDUPLEX)
+COMPATIBLE_IOCTL(SNDCTL_DSP_GETODELAY)
+COMPATIBLE_IOCTL(SNDCTL_DSP_PROFILE)
+COMPATIBLE_IOCTL(SOUND_PCM_READ_RATE)
+COMPATIBLE_IOCTL(SOUND_PCM_READ_CHANNELS)
+COMPATIBLE_IOCTL(SOUND_PCM_READ_BITS)
+COMPATIBLE_IOCTL(SOUND_PCM_READ_FILTER)
+/* Big C for sound/OSS */
+COMPATIBLE_IOCTL(SNDCTL_COPR_RESET)
+COMPATIBLE_IOCTL(SNDCTL_COPR_LOAD)
+COMPATIBLE_IOCTL(SNDCTL_COPR_RDATA)
+COMPATIBLE_IOCTL(SNDCTL_COPR_RCODE)
+COMPATIBLE_IOCTL(SNDCTL_COPR_WDATA)
+COMPATIBLE_IOCTL(SNDCTL_COPR_WCODE)
+COMPATIBLE_IOCTL(SNDCTL_COPR_RUN)
+COMPATIBLE_IOCTL(SNDCTL_COPR_HALT)
+COMPATIBLE_IOCTL(SNDCTL_COPR_SENDMSG)
+COMPATIBLE_IOCTL(SNDCTL_COPR_RCVMSG)
+/* Big M for sound/OSS */
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_VOLUME)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_BASS)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_TREBLE)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_SYNTH)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_PCM)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_SPEAKER)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_MIC)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_CD)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_IMIX)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_ALTPCM)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECLEV)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_IGAIN)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_OGAIN)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE1)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE2)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE3)
+COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL1))
+COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL2))
+COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL3))
+COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEIN))
+COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEOUT))
+COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_VIDEO))
+COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_RADIO))
+COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_MONITOR))
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_MUTE)
+/* SOUND_MIXER_READ_ENHANCE,  same value as READ_MUTE */
+/* SOUND_MIXER_READ_LOUD,  same value as READ_MUTE */
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECSRC)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_DEVMASK)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECMASK)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_STEREODEVS)
+COMPATIBLE_IOCTL(SOUND_MIXER_READ_CAPS)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_VOLUME)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_BASS)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_TREBLE)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SYNTH)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_PCM)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SPEAKER)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MIC)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_CD)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IMIX)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_ALTPCM)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECLEV)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IGAIN)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_OGAIN)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE1)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE2)
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE3)
+COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL1))
+COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL2))
+COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL3))
+COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEIN))
+COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEOUT))
+COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_VIDEO))
+COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_RADIO))
+COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_MONITOR))
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MUTE)
+/* SOUND_MIXER_WRITE_ENHANCE,  same value as WRITE_MUTE */
+/* SOUND_MIXER_WRITE_LOUD,  same value as WRITE_MUTE */
+COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECSRC)
+COMPATIBLE_IOCTL(SOUND_MIXER_INFO)
+COMPATIBLE_IOCTL(SOUND_OLD_MIXER_INFO)
+COMPATIBLE_IOCTL(SOUND_MIXER_ACCESS)
+COMPATIBLE_IOCTL(SOUND_MIXER_AGC)
+COMPATIBLE_IOCTL(SOUND_MIXER_3DSE)
+COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE1)
+COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE2)
+COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE3)
+COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE4)
+COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
+COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
+COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
+COMPATIBLE_IOCTL(OSS_GETVERSION)
+/* AUTOFS */
+COMPATIBLE_IOCTL(AUTOFS_IOC_READY)
+COMPATIBLE_IOCTL(AUTOFS_IOC_FAIL)
+COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC)
+COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER)
+COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE)
+/* DEVFS */
+COMPATIBLE_IOCTL(DEVFSDIOC_GET_PROTO_REV)
+COMPATIBLE_IOCTL(DEVFSDIOC_SET_EVENT_MASK)
+COMPATIBLE_IOCTL(DEVFSDIOC_RELEASE_EVENT_QUEUE)
+COMPATIBLE_IOCTL(DEVFSDIOC_SET_DEBUG_MASK)
+/* Raw devices */
+COMPATIBLE_IOCTL(RAW_SETBIND)
+COMPATIBLE_IOCTL(RAW_GETBIND)
+/* SMB ioctls which do not need any translations */
+COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
+/* Little a */
+COMPATIBLE_IOCTL(ATMSIGD_CTRL)
+COMPATIBLE_IOCTL(ATMARPD_CTRL)
+COMPATIBLE_IOCTL(ATMLEC_CTRL)
+COMPATIBLE_IOCTL(ATMLEC_MCAST)
+COMPATIBLE_IOCTL(ATMLEC_DATA)
+COMPATIBLE_IOCTL(ATM_SETSC)
+COMPATIBLE_IOCTL(SIOCSIFATMTCP)
+COMPATIBLE_IOCTL(SIOCMKCLIP)
+COMPATIBLE_IOCTL(ATMARP_MKIP)
+COMPATIBLE_IOCTL(ATMARP_SETENTRY)
+COMPATIBLE_IOCTL(ATMARP_ENCAP)
+COMPATIBLE_IOCTL(ATMTCP_CREATE)
+COMPATIBLE_IOCTL(ATMTCP_REMOVE)
+COMPATIBLE_IOCTL(ATMMPC_CTRL)
+COMPATIBLE_IOCTL(ATMMPC_DATA)
+#if defined(CONFIG_BLK_DEV_LVM) || defined(CONFIG_BLK_DEV_LVM_MODULE)
+/* 0xfe - lvm */
+COMPATIBLE_IOCTL(VG_SET_EXTENDABLE)
+COMPATIBLE_IOCTL(VG_STATUS_GET_COUNT)
+COMPATIBLE_IOCTL(VG_STATUS_GET_NAMELIST)
+COMPATIBLE_IOCTL(VG_REMOVE)
+COMPATIBLE_IOCTL(VG_RENAME)
+COMPATIBLE_IOCTL(VG_REDUCE)
+COMPATIBLE_IOCTL(PE_LOCK_UNLOCK)
+COMPATIBLE_IOCTL(PV_FLUSH)
+COMPATIBLE_IOCTL(LVM_LOCK_LVM)
+COMPATIBLE_IOCTL(LVM_GET_IOP_VERSION)
+#ifdef LVM_TOTAL_RESET
+COMPATIBLE_IOCTL(LVM_RESET)
+#endif
+COMPATIBLE_IOCTL(LV_SET_ACCESS)
+COMPATIBLE_IOCTL(LV_SET_STATUS)
+COMPATIBLE_IOCTL(LV_SET_ALLOCATION)
+COMPATIBLE_IOCTL(LE_REMAP)
+COMPATIBLE_IOCTL(LV_BMAP)
+COMPATIBLE_IOCTL(LV_SNAPSHOT_USE_RATE)
+#endif /* LVM */
+#if defined(CONFIG_DRM) || defined(CONFIG_DRM_MODULE)
+COMPATIBLE_IOCTL(DRM_IOCTL_GET_MAGIC)
+COMPATIBLE_IOCTL(DRM_IOCTL_IRQ_BUSID)
+COMPATIBLE_IOCTL(DRM_IOCTL_AUTH_MAGIC)
+COMPATIBLE_IOCTL(DRM_IOCTL_BLOCK)
+COMPATIBLE_IOCTL(DRM_IOCTL_UNBLOCK)
+COMPATIBLE_IOCTL(DRM_IOCTL_CONTROL)
+COMPATIBLE_IOCTL(DRM_IOCTL_ADD_BUFS)
+COMPATIBLE_IOCTL(DRM_IOCTL_MARK_BUFS)
+COMPATIBLE_IOCTL(DRM_IOCTL_ADD_CTX)
+COMPATIBLE_IOCTL(DRM_IOCTL_RM_CTX)
+COMPATIBLE_IOCTL(DRM_IOCTL_MOD_CTX)
+COMPATIBLE_IOCTL(DRM_IOCTL_GET_CTX)
+COMPATIBLE_IOCTL(DRM_IOCTL_SWITCH_CTX)
+COMPATIBLE_IOCTL(DRM_IOCTL_NEW_CTX)
+COMPATIBLE_IOCTL(DRM_IOCTL_ADD_DRAW)
+COMPATIBLE_IOCTL(DRM_IOCTL_RM_DRAW)
+COMPATIBLE_IOCTL(DRM_IOCTL_LOCK)
+COMPATIBLE_IOCTL(DRM_IOCTL_UNLOCK)
+COMPATIBLE_IOCTL(DRM_IOCTL_FINISH)
+#endif /* DRM */
+/* Big W */
+/* WIOC_GETSUPPORT not yet implemented -E */
+COMPATIBLE_IOCTL(WDIOC_GETSTATUS)
+COMPATIBLE_IOCTL(WDIOC_GETBOOTSTATUS)
+COMPATIBLE_IOCTL(WDIOC_GETTEMP)
+COMPATIBLE_IOCTL(WDIOC_SETOPTIONS)
+COMPATIBLE_IOCTL(WDIOC_KEEPALIVE)
+/* Big R */
+COMPATIBLE_IOCTL(RNDGETENTCNT)
+COMPATIBLE_IOCTL(RNDADDTOENTCNT)
+COMPATIBLE_IOCTL(RNDGETPOOL)
+COMPATIBLE_IOCTL(RNDADDENTROPY)
+COMPATIBLE_IOCTL(RNDZAPENTCNT)
+COMPATIBLE_IOCTL(RNDCLEARPOOL)
+/* Bluetooth ioctls */
+COMPATIBLE_IOCTL(HCIDEVUP)
+COMPATIBLE_IOCTL(HCIDEVDOWN)
+COMPATIBLE_IOCTL(HCIDEVRESET)
+COMPATIBLE_IOCTL(HCIDEVRESTAT)
+COMPATIBLE_IOCTL(HCIGETDEVLIST)
+COMPATIBLE_IOCTL(HCIGETDEVINFO)
+COMPATIBLE_IOCTL(HCIGETCONNLIST)
+COMPATIBLE_IOCTL(HCIGETCONNINFO)
+COMPATIBLE_IOCTL(HCISETRAW)
+COMPATIBLE_IOCTL(HCISETSCAN)
+COMPATIBLE_IOCTL(HCISETAUTH)
+COMPATIBLE_IOCTL(HCISETENCRYPT)
+COMPATIBLE_IOCTL(HCISETPTYPE)
+COMPATIBLE_IOCTL(HCISETLINKPOL)
+COMPATIBLE_IOCTL(HCISETLINKMODE)
+COMPATIBLE_IOCTL(HCISETACLMTU)
+COMPATIBLE_IOCTL(HCISETSCOMTU)
+COMPATIBLE_IOCTL(HCIINQUIRY)
+/* Misc. */
+COMPATIBLE_IOCTL(0x41545900)		/* ATYIO_CLKR */
+COMPATIBLE_IOCTL(0x41545901)		/* ATYIO_CLKW */
+COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
+COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
+COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM)
+COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE)
+/* USB */
+COMPATIBLE_IOCTL(USBDEVFS_RESETEP)
+COMPATIBLE_IOCTL(USBDEVFS_SETINTERFACE)
+COMPATIBLE_IOCTL(USBDEVFS_SETCONFIGURATION)
+COMPATIBLE_IOCTL(USBDEVFS_GETDRIVER)
+COMPATIBLE_IOCTL(USBDEVFS_DISCARDURB)
+COMPATIBLE_IOCTL(USBDEVFS_CLAIMINTERFACE)
+COMPATIBLE_IOCTL(USBDEVFS_RELEASEINTERFACE)
+COMPATIBLE_IOCTL(USBDEVFS_CONNECTINFO)
+COMPATIBLE_IOCTL(USBDEVFS_HUB_PORTINFO)
+COMPATIBLE_IOCTL(USBDEVFS_RESET)
+COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
+/* MTD */
+COMPATIBLE_IOCTL(MEMGETINFO)
+COMPATIBLE_IOCTL(MEMERASE)
+COMPATIBLE_IOCTL(MEMLOCK)
+COMPATIBLE_IOCTL(MEMUNLOCK)
+COMPATIBLE_IOCTL(MEMGETREGIONCOUNT)
+COMPATIBLE_IOCTL(MEMGETREGIONINFO)
+/* NBD */
+COMPATIBLE_IOCTL(NBD_SET_SOCK)
+COMPATIBLE_IOCTL(NBD_SET_BLKSIZE)
+COMPATIBLE_IOCTL(NBD_SET_SIZE)
+COMPATIBLE_IOCTL(NBD_DO_IT)
+COMPATIBLE_IOCTL(NBD_CLEAR_SOCK)
+COMPATIBLE_IOCTL(NBD_CLEAR_QUE)
+COMPATIBLE_IOCTL(NBD_PRINT_DEBUG)
+COMPATIBLE_IOCTL(NBD_SET_SIZE_BLOCKS)
+COMPATIBLE_IOCTL(NBD_DISCONNECT)
diff -Nru a/include/linux/console.h b/include/linux/console.h
--- a/include/linux/console.h	Wed Apr 30 22:28:08 2003
+++ b/include/linux/console.h	Wed Apr 30 22:28:08 2003
@@ -97,12 +97,13 @@
 	char	name[8];
 	void	(*write)(struct console *, const char *, unsigned);
 	int	(*read)(struct console *, const char *, unsigned);
-	kdev_t	(*device)(struct console *);
+	struct tty_driver *(*device)(struct console *, int *);
 	void	(*unblank)(void);
 	int	(*setup)(struct console *, char *);
 	short	flags;
 	short	index;
 	int	cflag;
+	void	*data;
 	struct	 console *next;
 };
 
diff -Nru a/include/linux/cpufreq.h b/include/linux/cpufreq.h
--- a/include/linux/cpufreq.h	Wed Apr 30 22:28:11 2003
+++ b/include/linux/cpufreq.h	Wed Apr 30 22:28:11 2003
@@ -68,7 +68,6 @@
         unsigned int            policy; /* see above */
 	struct cpufreq_governor *governor; /* see below */
 	struct cpufreq_cpuinfo  cpuinfo;     /* see above */
-	struct device		* dev;
 	struct kobject		kobj;
  	struct semaphore	lock;   /* CPU ->setpolicy or ->target may
 					   only be called once a time */
diff -Nru a/include/linux/dcache.h b/include/linux/dcache.h
--- a/include/linux/dcache.h	Wed Apr 30 22:28:19 2003
+++ b/include/linux/dcache.h	Wed Apr 30 22:28:19 2003
@@ -270,7 +270,6 @@
 		if (!atomic_read(&dentry->d_count))
 			BUG();
 		atomic_inc(&dentry->d_count);
-		dentry->d_vfs_flags |= DCACHE_REFERENCED;
 	}
 	return dentry;
 }
diff -Nru a/include/linux/devfs_fs_kernel.h b/include/linux/devfs_fs_kernel.h
--- a/include/linux/devfs_fs_kernel.h	Wed Apr 30 22:28:13 2003
+++ b/include/linux/devfs_fs_kernel.h	Wed Apr 30 22:28:13 2003
@@ -25,18 +25,15 @@
 				      unsigned int flags,
 				      unsigned int major, unsigned int minor,
 				      umode_t mode, void *ops, void *info);
-extern void devfs_unregister (devfs_handle_t de);
-extern int devfs_mk_symlink (const char *name, const char *link);
-extern devfs_handle_t devfs_mk_dir(const char *fmt, ...)
+extern int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...)
+	__attribute__((format (printf, 3, 4)));
+extern int devfs_mk_symlink(const char *name, const char *link);
+extern int devfs_mk_dir(const char *fmt, ...)
 	__attribute__((format (printf, 1, 2)));
 extern void devfs_remove(const char *fmt, ...)
 	__attribute__((format (printf, 1, 2)));
 extern int devfs_register_tape(const char *name);
 extern void devfs_unregister_tape(int num);
-extern void devfs_create_partitions(struct gendisk *dev);
-extern void devfs_create_cdrom(struct gendisk *dev);
-extern void devfs_remove_partitions(struct gendisk *dev);
-extern void devfs_remove_cdrom(struct gendisk *dev);
 extern void devfs_register_partition(struct gendisk *dev, int part);
 extern void mount_devfs_fs(void);
 #else  /*  CONFIG_DEVFS_FS  */
@@ -50,38 +47,26 @@
 {
     return NULL;
 }
-static inline void devfs_unregister (devfs_handle_t de)
+static inline int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...)
 {
-    return;
+	return 0;
 }
 static inline int devfs_mk_symlink (const char *name, const char *link)
 {
     return 0;
 }
-static inline devfs_handle_t devfs_mk_dir(const char *fmt, ...)
+static inline int devfs_mk_dir(const char *fmt, ...)
 {
-    return NULL;
+	return 0;
 }
 static inline void devfs_remove(const char *fmt, ...)
 {
 }
-static inline int devfs_register_tape (devfs_handle_t de)
+static inline int devfs_register_tape (const char *name)
 {
     return -1;
 }
 static inline void devfs_unregister_tape(int num)
-{
-}
-static inline void devfs_create_partitions(struct gendisk *dev)
-{
-}
-static inline void devfs_create_cdrom(struct gendisk *dev)
-{
-}
-static inline void devfs_remove_partitions(struct gendisk *dev)
-{
-}
-static inline void devfs_remove_cdrom(struct gendisk *dev)
 {
 }
 static inline void devfs_register_partition(struct gendisk *dev, int part)
diff -Nru a/include/linux/device.h b/include/linux/device.h
--- a/include/linux/device.h	Wed Apr 30 22:28:16 2003
+++ b/include/linux/device.h	Wed Apr 30 22:28:16 2003
@@ -1,7 +1,7 @@
 /*
  * device.h - generic, centralized driver model
  *
- * Copyright (c) 2001 Patrick Mochel <mochel@osdl.org>
+ * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org>
  *
  * This is a relatively simple centralized driver model.
  * The data structures were mainly lifted directly from the PCI
@@ -60,7 +60,8 @@
 
 struct device;
 struct device_driver;
-struct device_class;
+struct class;
+struct class_device;
 
 struct bus_type {
 	char			* name;
@@ -116,11 +117,9 @@
 struct device_driver {
 	char			* name;
 	struct bus_type		* bus;
-	struct device_class	* devclass;
 
 	struct semaphore	unload_sem;
 	struct kobject		kobj;
-	struct list_head	class_list;
 	struct list_head	devices;
 
 	int	(*probe)	(struct device * dev);
@@ -160,74 +159,106 @@
 /*
  * device classes
  */
-struct device_class {
+struct class {
 	char			* name;
-	u32			devnum;
 
 	struct subsystem	subsys;
-	struct kset		devices;
-	struct kset		drivers;
+	struct list_head	children;
+	struct list_head	interfaces;
 
-	int	(*add_device)(struct device *);
-	void	(*remove_device)(struct device *);
-	int	(*hotplug)(struct device *dev, char **envp, 
+	int	(*hotplug)(struct class_device *dev, char **envp, 
 			   int num_envp, char *buffer, int buffer_size);
 };
 
-extern int devclass_register(struct device_class *);
-extern void devclass_unregister(struct device_class *);
+extern int class_register(struct class *);
+extern void class_unregister(struct class *);
 
-extern struct device_class * get_devclass(struct device_class *);
-extern void put_devclass(struct device_class *);
+extern struct class * class_get(struct class *);
+extern void class_put(struct class *);
 
 
-struct devclass_attribute {
+struct class_attribute {
 	struct attribute	attr;
-	ssize_t (*show)(struct device_class *, char * buf);
-	ssize_t (*store)(struct device_class *, const char * buf, size_t count);
+	ssize_t (*show)(struct class *, char * buf);
+	ssize_t (*store)(struct class *, const char * buf, size_t count);
 };
 
-#define DEVCLASS_ATTR(_name,_str,_mode,_show,_store)	\
-struct devclass_attribute devclass_attr_##_name = { 		\
-	.attr = {.name	= _str,	.mode	= _mode },	\
-	.show	= _show,				\
-	.store	= _store,				\
+#define CLASS_ATTR(_name,_mode,_show,_store)			\
+struct class_attribute class_attr_##_name = { 			\
+	.attr = {.name = __stringify(_name), .mode = _mode },	\
+	.show	= _show,					\
+	.store	= _store,					\
 };
 
-extern int devclass_create_file(struct device_class *, struct devclass_attribute *);
-extern void devclass_remove_file(struct device_class *, struct devclass_attribute *);
+extern int class_create_file(struct class *, struct class_attribute *);
+extern void class_remove_file(struct class *, struct class_attribute *);
 
 
-/*
- * device interfaces
- * These are the logical interfaces of device classes. 
- * These entities map directly to specific userspace interfaces, like 
- * device nodes.
- * Interfaces are registered with the device class they belong to. When
- * a device is registered with the class, each interface's add_device 
- * callback is called. It is up to the interface to decide whether or not
- * it supports the device.
- */
+struct class_device {
+	struct list_head	node;
 
-struct device_interface {
-	char			* name;
-	struct device_class	* devclass;
+	struct kobject		kobj;
+	struct class		* class;	/* required */
+	struct device		* dev;		/* not necessary, but nice to have */
+	void			* class_data;	/* class-specific data */
+
+	char	class_id[BUS_ID_SIZE];	/* unique to this class */
+};
+
+static inline void *
+class_get_devdata (struct class_device *dev)
+{
+	return dev->class_data;
+}
+
+static inline void
+class_set_devdata (struct class_device *dev, void *data)
+{
+	dev->class_data = data;
+}
+
+
+extern int class_device_register(struct class_device *);
+extern void class_device_unregister(struct class_device *);
+extern void class_device_initialize(struct class_device *);
+extern int class_device_add(struct class_device *);
+extern void class_device_del(struct class_device *);
+
+extern struct class_device * class_device_get(struct class_device *);
+extern void class_device_put(struct class_device *);
+
+struct class_device_attribute {
+	struct attribute	attr;
+	ssize_t (*show)(struct class_device *, char * buf);
+	ssize_t (*store)(struct class_device *, const char * buf, size_t count);
+};
+
+#define CLASS_DEVICE_ATTR(_name,_mode,_show,_store)		\
+struct class_device_attribute class_device_attr_##_name = { 	\
+	.attr = {.name = __stringify(_name), .mode = _mode },	\
+	.show	= _show,					\
+	.store	= _store,					\
+};
 
-	struct kset		kset;
-	u32			devnum;
+extern int class_device_create_file(struct class_device *, struct class_device_attribute *);
+extern void class_device_remove_file(struct class_device *, struct class_device_attribute *);
 
-	int (*add_device)	(struct device *);
-	int (*remove_device)	(struct device *);
+
+struct class_interface {
+	struct list_head	node;
+	struct class		*class;
+
+	int (*add)	(struct class_device *);
+	void (*remove)	(struct class_device *);
 };
 
-extern int interface_register(struct device_interface *);
-extern void interface_unregister(struct device_interface *);
+extern int class_interface_register(struct class_interface *);
+extern void class_interface_unregister(struct class_interface *);
 
 
 struct device {
 	struct list_head node;		/* node in sibling list */
 	struct list_head bus_list;	/* node in bus's list */
-	struct list_head class_list;
 	struct list_head driver_list;
 	struct list_head children;
 	struct device 	* parent;
@@ -240,14 +271,10 @@
 	struct device_driver *driver;	/* which driver has allocated this
 					   device */
 	void		*driver_data;	/* data private to the driver */
-
-	u32		class_num;	/* class-enumerated value */
-	void		* class_data;	/* class-specific data */
-
 	void		*platform_data;	/* Platform specific data (e.g. ACPI,
 					   BIOS data relevant to device) */
 
-	u32		power_state;  /* Current operating state. In
+	u32		power_state;	/* Current operating state. In
 					   ACPI-speak, this is D0-D3, D0
 					   being fully functional, and D3
 					   being off. */
@@ -347,6 +374,7 @@
 	u32		id;
 	struct sys_root	* root;
 	struct device	dev;
+	struct class_device class_dev;
 };
 
 extern int sys_device_register(struct sys_device *);
diff -Nru a/include/linux/eeprom.h b/include/linux/eeprom.h
--- a/include/linux/eeprom.h	Wed Apr 30 22:28:03 2003
+++ b/include/linux/eeprom.h	Wed Apr 30 22:28:03 2003
@@ -59,7 +59,7 @@
 /* foo. put this in a .c file */
 static inline void eeprom_update(struct eeprom *ee, u32 mask, int pol)
 {
-	long flags;
+	unsigned long flags;
 	u32 data;
 
 	spin_lock_irqsave(ee->lock, flags);
diff -Nru a/include/linux/eisa.h b/include/linux/eisa.h
--- a/include/linux/eisa.h	Wed Apr 30 22:28:15 2003
+++ b/include/linux/eisa.h	Wed Apr 30 22:28:15 2003
@@ -25,13 +25,15 @@
 };
 
 /* There is not much we can say about an EISA device, apart from
- * signature, slot number, and base address. */
+ * signature, slot number, and base address. dma_mask is set by
+ * default to 32 bits.*/
 
 struct eisa_device {
 	struct eisa_device_id id;
 	int                   slot;
 	unsigned long         base_addr;
 	struct resource       res;
+	u64                   dma_mask;
 	struct device         dev; /* generic device */
 };
 
@@ -63,12 +65,12 @@
  * busses (PA-RISC ?), so we try to handle that. */
 
 struct eisa_root_device {
-	struct list_head node;
 	struct device   *dev;	 /* Pointer to bridge device */
 	struct resource *res;
 	unsigned long    bus_base_addr;
 	int		 slots;  /* Max slot number */
 	int              bus_nr; /* Set by eisa_root_register */
+	struct resource  eisa_root_res;	/* ditto */
 };
 
 int eisa_root_register (struct eisa_root_device *root);
diff -Nru a/include/linux/fb.h b/include/linux/fb.h
--- a/include/linux/fb.h	Wed Apr 30 22:28:07 2003
+++ b/include/linux/fb.h	Wed Apr 30 22:28:07 2003
@@ -348,7 +348,6 @@
 
 #include <linux/fs.h>
 #include <linux/init.h>
-#include <linux/devfs_fs_kernel.h>
 
 struct fb_info;
 struct vm_area_struct;
@@ -397,7 +396,7 @@
 };
 
 struct fb_info {
-   kdev_t node;
+   int node;
    int flags;
    int open;                            /* Has this been open already ? */
 #define FBINFO_FLAG_MODULE	1	/* Low-level driver is a module */
diff -Nru a/include/linux/fs.h b/include/linux/fs.h
--- a/include/linux/fs.h	Wed Apr 30 22:28:06 2003
+++ b/include/linux/fs.h	Wed Apr 30 22:28:06 2003
@@ -1041,6 +1041,7 @@
 extern void bdput(struct block_device *);
 extern int blkdev_open(struct inode *, struct file *);
 extern int blkdev_close(struct inode *, struct file *);
+extern struct block_device *open_by_devnum(dev_t, unsigned, int);
 extern struct file_operations def_blk_fops;
 extern struct address_space_operations def_blk_aops;
 extern struct file_operations def_chr_fops;
@@ -1067,10 +1068,7 @@
 /* fs/block_dev.c */
 #define BDEVNAME_SIZE	32	/* Largest string for a blockdev identifier */
 extern const char *__bdevname(dev_t, char *buffer);
-extern inline const char *bdevname(struct block_device *bdev, char *buffer)
-{
-	return __bdevname(bdev->bd_dev, buffer);
-}
+extern const char *bdevname(struct block_device *bdev, char *buffer);
 extern struct block_device *lookup_bdev(const char *);
 extern struct block_device *open_bdev_excl(const char *, int, int, void *);
 extern void close_bdev_excl(struct block_device *, int);
@@ -1102,10 +1100,9 @@
 #define bio_data_dir(bio)	((bio)->bi_rw & 1)
 
 extern int check_disk_change(struct block_device *);
-extern int full_check_disk_change(struct block_device *);
-extern int __check_disk_change(dev_t);
 extern int invalidate_inodes(struct super_block *);
-extern int invalidate_device(kdev_t, int);
+extern int __invalidate_device(struct block_device *, int);
+extern int invalidate_partition(struct gendisk *, int);
 unsigned long invalidate_mapping_pages(struct address_space *mapping,
 					pgoff_t start, pgoff_t end);
 unsigned long invalidate_inode_pages(struct address_space *mapping);
@@ -1293,6 +1290,10 @@
 extern ssize_t generic_read_dir(struct file *, char *, size_t, loff_t *);
 extern struct file_operations simple_dir_operations;
 extern struct inode_operations simple_dir_inode_operations;
+struct tree_descr { char *name; struct file_operations *ops; int mode; };
+extern int simple_fill_super(struct super_block *, int, struct tree_descr *);
+extern int simple_pin_fs(char *name, struct vfsmount **mount, int *count);
+extern void simple_release_fs(struct vfsmount **mount, int *count);
 
 #ifdef CONFIG_BLK_DEV_INITRD
 extern unsigned int real_root_dev;
diff -Nru a/include/linux/genhd.h b/include/linux/genhd.h
--- a/include/linux/genhd.h	Wed Apr 30 22:28:05 2003
+++ b/include/linux/genhd.h	Wed Apr 30 22:28:05 2003
@@ -15,6 +15,7 @@
 #include <linux/device.h>
 #include <linux/smp.h>
 #include <linux/string.h>
+#include <linux/fs.h>
 
 enum {
 /* These three have identical behaviour; use the second one if DOS FDISK gets
@@ -55,16 +56,12 @@
 } __attribute__((packed));
 
 #ifdef __KERNEL__
-#include <linux/devfs_fs_kernel.h>	/* we don't need any devfs crap
-					   here, but some of the implicitly
-					   included headers.   will clean
-					   this mess up later.	--hch */
 struct hd_struct {
 	sector_t start_sect;
 	sector_t nr_sects;
 	struct kobject kobj;
 	unsigned reads, read_sectors, writes, write_sectors;
-	int policy;
+	int policy, partno;
 };
 
 #define GENHD_FL_REMOVABLE  1
@@ -89,7 +86,7 @@
 	int minor_shift;		/* number of times minor is shifted to
 					   get real minor */
 	char disk_name[16];		/* name of major driver */
-	struct hd_struct *part;		/* [indexed by minor] */
+	struct hd_struct **part;	/* [indexed by minor] */
 	struct block_device_operations *fops;
 	struct request_queue *queue;
 	void *private_data;
@@ -369,6 +366,11 @@
 			int (*lock)(dev_t, void *),
 			void *data);
 extern void blk_unregister_region(dev_t dev, unsigned long range);
+
+static inline struct block_device *bdget_disk(struct gendisk *disk, int index)
+{
+	return bdget(MKDEV(disk->major, disk->first_minor) + index);
+}
 
 #endif
 
diff -Nru a/include/linux/gfp.h b/include/linux/gfp.h
--- a/include/linux/gfp.h	Wed Apr 30 22:28:06 2003
+++ b/include/linux/gfp.h	Wed Apr 30 22:28:06 2003
@@ -11,13 +11,27 @@
 #define __GFP_DMA	0x01
 #define __GFP_HIGHMEM	0x02
 
-/* Action modifiers - doesn't change the zoning */
+/*
+ * Action modifiers - doesn't change the zoning
+ *
+ * __GFP_REPEAT: Try hard to allocate the memory, but the allocation attempt
+ * _might_ fail.  This depends upon the particular VM implementation.
+ *
+ * __GFP_NOFAIL: The VM implementation _must_ retry infinitely: the caller
+ * cannot handle allocation failures.
+ *
+ * __GFP_NORETRY: The VM implementation must not retry indefinitely.
+ */
 #define __GFP_WAIT	0x10	/* Can wait and reschedule? */
 #define __GFP_HIGH	0x20	/* Should access emergency pools? */
 #define __GFP_IO	0x40	/* Can start physical IO? */
 #define __GFP_FS	0x80	/* Can call down to low-level FS? */
 #define __GFP_COLD	0x100	/* Cache-cold page required */
 #define __GFP_NOWARN	0x200	/* Suppress page allocation failure warning */
+#define __GFP_REPEAT	0x400	/* Retry the allocation.  Might fail */
+#define __GFP_NOFAIL	0x800	/* Retry for ever.  Cannot fail */
+#define __GFP_NORETRY	0x1000	/* Do not retry.  Might fail */
+#define __GFP_NO_GROW	0x2000	/* Slab internal usage */
 
 #define GFP_ATOMIC	(__GFP_HIGH)
 #define GFP_NOIO	(__GFP_WAIT)
diff -Nru a/include/linux/i2c-sensor.h b/include/linux/i2c-sensor.h
--- a/include/linux/i2c-sensor.h	Wed Apr 30 22:28:10 2003
+++ b/include/linux/i2c-sensor.h	Wed Apr 30 22:28:10 2003
@@ -22,18 +22,6 @@
 #ifndef _LINUX_I2C_SENSOR_H
 #define _LINUX_I2C_SENSOR_H
 
-#include <linux/sysctl.h>
-
-/* The type of callback functions used in sensors_{proc,sysctl}_real */
-typedef void (*i2c_real_callback) (struct i2c_client * client,
-				       int operation, int ctl_name,
-				       int *nrels_mag, long *results);
-
-/* Values for the operation field in the above function type */
-#define SENSORS_PROC_REAL_INFO 1
-#define SENSORS_PROC_REAL_READ 2
-#define SENSORS_PROC_REAL_WRITE 3
-
 /* A structure containing detect information.
    Force variables overrule all other variables; they force a detection on
    that place. If a specific chip is given, the module blindly assumes this
@@ -41,8 +29,8 @@
    will still try to figure out what type of chip is present. This is useful
    if for some reasons the detect for SMBus or ISA address space filled
    fails.
-   probe: insmod parameter. Initialize this list with SENSORS_I2C_END values.
-     A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for
+   probe: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values.
+     A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for
      the ISA bus, -1 for any I2C bus), the second is the address. 
    kind: The kind of chip. 0 equals any chip.
 */
@@ -52,10 +40,10 @@
 };
 
 /* A structure containing the detect information.
-   normal_i2c: filled in by the module writer. Terminated by SENSORS_I2C_END.
+   normal_i2c: filled in by the module writer. Terminated by I2C_CLIENT_ISA_END.
      A list of I2C addresses which should normally be examined.
    normal_i2c_range: filled in by the module writer. Terminated by 
-     SENSORS_I2C_END
+     I2C_CLIENT_ISA_END
      A list of pairs of I2C addresses, each pair being an inclusive range of
      addresses which should normally be examined.
    normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END.
@@ -66,24 +54,24 @@
      range of addresses which should normally be examined. The third is the
      modulo parameter: only addresses which are 0 module this value relative
      to the first address of the range are actually considered.
-   probe: insmod parameter. Initialize this list with SENSORS_I2C_END values.
-     A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for
+   probe: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values.
+     A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for
      the ISA bus, -1 for any I2C bus), the second is the address. These
      addresses are also probed, as if they were in the 'normal' list.
-   probe_range: insmod parameter. Initialize this list with SENSORS_I2C_END 
+   probe_range: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END 
      values.
-     A list of triples. The first value is a bus number (SENSORS_ISA_BUS for
+     A list of triples. The first value is a bus number (ANY_I2C_ISA_BUS for
      the ISA bus, -1 for any I2C bus), the second and third are addresses. 
      These form an inclusive range of addresses that are also probed, as
      if they were in the 'normal' list.
-   ignore: insmod parameter. Initialize this list with SENSORS_I2C_END values.
-     A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for
+   ignore: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values.
+     A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for
      the ISA bus, -1 for any I2C bus), the second is the I2C address. These
      addresses are never probed. This parameter overrules 'normal' and 
      'probe', but not the 'force' lists.
-   ignore_range: insmod parameter. Initialize this list with SENSORS_I2C_END 
+   ignore_range: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END 
       values.
-     A list of triples. The first value is a bus number (SENSORS_ISA_BUS for
+     A list of triples. The first value is a bus number (ANY_I2C_ISA_BUS for
      the ISA bus, -1 for any I2C bus), the second and third are addresses. 
      These form an inclusive range of I2C addresses that are never probed.
      This parameter overrules 'normal' and 'probe', but not the 'force' lists.
@@ -102,74 +90,35 @@
 	struct i2c_force_data *forces;
 };
 
-/* Internal numbers to terminate lists */
-#define SENSORS_I2C_END 0xfffe
-#define SENSORS_ISA_END 0xfffefffe
-
-/* The numbers to use to set an ISA or I2C bus address */
-#define SENSORS_ISA_BUS 9191
-#define SENSORS_ANY_I2C_BUS 0xffff
-
-/* The length of the option lists */
-#define SENSORS_MAX_OPTS 48
-
-/* Default fill of many variables */
-#define SENSORS_DEFAULTS {SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
-                          SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
-                          SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
-                          SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
-                          SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
-                          SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
-                          SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
-                          SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
-                          SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
-                          SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
-                          SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
-                          SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
-                          SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
-                          SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
-                          SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
-                          SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END}
-
-/* This is ugly. We need to evaluate SENSORS_MAX_OPTS before it is 
-   stringified */
-#define SENSORS_MODPARM_AUX1(x) "1-" #x "h"
-#define SENSORS_MODPARM_AUX(x) SENSORS_MODPARM_AUX1(x)
-#define SENSORS_MODPARM SENSORS_MODPARM_AUX(SENSORS_MAX_OPTS)
-
-/* SENSORS_MODULE_PARM creates a module parameter, and puts it in the
-   module header */
-#define SENSORS_MODULE_PARM(var,desc) \
-  static unsigned short var[SENSORS_MAX_OPTS] = SENSORS_DEFAULTS; \
-  MODULE_PARM(var,SENSORS_MODPARM); \
-  MODULE_PARM_DESC(var,desc)
-
-/* SENSORS_MODULE_PARM creates a 'force_*' module parameter, and puts it in
-   the module header */
 #define SENSORS_MODULE_PARM_FORCE(name) \
-  SENSORS_MODULE_PARM(force_ ## name, \
+  I2C_CLIENT_MODULE_PARM(force_ ## name, \
                       "List of adapter,address pairs which are unquestionably" \
                       " assumed to contain a `" # name "' chip")
 
 
 /* This defines several insmod variables, and the addr_data structure */
 #define SENSORS_INSMOD \
-  SENSORS_MODULE_PARM(probe, \
+  I2C_CLIENT_MODULE_PARM(probe, \
                       "List of adapter,address pairs to scan additionally"); \
-  SENSORS_MODULE_PARM(probe_range, \
+  I2C_CLIENT_MODULE_PARM(probe_range, \
                       "List of adapter,start-addr,end-addr triples to scan " \
                       "additionally"); \
-  SENSORS_MODULE_PARM(ignore, \
+  I2C_CLIENT_MODULE_PARM(ignore, \
                       "List of adapter,address pairs not to scan"); \
-  SENSORS_MODULE_PARM(ignore_range, \
+  I2C_CLIENT_MODULE_PARM(ignore_range, \
                       "List of adapter,start-addr,end-addr triples not to " \
                       "scan"); \
-  static struct i2c_address_data addr_data = \
-                                       {normal_i2c, normal_i2c_range, \
-                                        normal_isa, normal_isa_range, \
-                                        probe, probe_range, \
-                                        ignore, ignore_range, \
-                                        forces}
+	static struct i2c_address_data addr_data = {			\
+			.normal_i2c =		normal_i2c,		\
+			.normal_i2c_range =	normal_i2c_range,	\
+			.normal_isa =		normal_isa,		\
+			.normal_isa_range =	normal_isa_range,	\
+			.probe =		probe,			\
+			.probe_range =		probe_range,		\
+			.ignore =		ignore,			\
+			.ignore_range =		ignore_range,		\
+			.forces =		forces,			\
+		}
 
 /* The following functions create an enum with the chip names as elements. 
    The first element of the enum is any_chip. These are the only macros
@@ -177,7 +126,7 @@
 
 #define SENSORS_INSMOD_0 \
   enum chips { any_chip }; \
-  SENSORS_MODULE_PARM(force, \
+  I2C_CLIENT_MODULE_PARM(force, \
                       "List of adapter,address pairs to boldly assume " \
                       "to be present"); \
   static struct i2c_force_data forces[] = {{force,any_chip},{NULL}}; \
@@ -185,7 +134,7 @@
 
 #define SENSORS_INSMOD_1(chip1) \
   enum chips { any_chip, chip1 }; \
-  SENSORS_MODULE_PARM(force, \
+  I2C_CLIENT_MODULE_PARM(force, \
                       "List of adapter,address pairs to boldly assume " \
                       "to be present"); \
   SENSORS_MODULE_PARM_FORCE(chip1); \
@@ -196,7 +145,7 @@
 
 #define SENSORS_INSMOD_2(chip1,chip2) \
   enum chips { any_chip, chip1, chip2 }; \
-  SENSORS_MODULE_PARM(force, \
+  I2C_CLIENT_MODULE_PARM(force, \
                       "List of adapter,address pairs to boldly assume " \
                       "to be present"); \
   SENSORS_MODULE_PARM_FORCE(chip1); \
@@ -209,7 +158,7 @@
 
 #define SENSORS_INSMOD_3(chip1,chip2,chip3) \
   enum chips { any_chip, chip1, chip2, chip3 }; \
-  SENSORS_MODULE_PARM(force, \
+  I2C_CLIENT_MODULE_PARM(force, \
                       "List of adapter,address pairs to boldly assume " \
                       "to be present"); \
   SENSORS_MODULE_PARM_FORCE(chip1); \
@@ -224,7 +173,7 @@
 
 #define SENSORS_INSMOD_4(chip1,chip2,chip3,chip4) \
   enum chips { any_chip, chip1, chip2, chip3, chip4 }; \
-  SENSORS_MODULE_PARM(force, \
+  I2C_CLIENT_MODULE_PARM(force, \
                       "List of adapter,address pairs to boldly assume " \
                       "to be present"); \
   SENSORS_MODULE_PARM_FORCE(chip1); \
@@ -241,7 +190,7 @@
 
 #define SENSORS_INSMOD_5(chip1,chip2,chip3,chip4,chip5) \
   enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \
-  SENSORS_MODULE_PARM(force, \
+  I2C_CLIENT_MODULE_PARM(force, \
                       "List of adapter,address pairs to boldly assume " \
                       "to be present"); \
   SENSORS_MODULE_PARM_FORCE(chip1); \
@@ -260,7 +209,7 @@
 
 #define SENSORS_INSMOD_6(chip1,chip2,chip3,chip4,chip5,chip6) \
   enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \
-  SENSORS_MODULE_PARM(force, \
+  I2C_CLIENT_MODULE_PARM(force, \
                       "List of adapter,address pairs to boldly assume " \
                       "to be present"); \
   SENSORS_MODULE_PARM_FORCE(chip1); \
@@ -281,7 +230,7 @@
 
 #define SENSORS_INSMOD_7(chip1,chip2,chip3,chip4,chip5,chip6,chip7) \
   enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, chip7 }; \
-  SENSORS_MODULE_PARM(force, \
+  I2C_CLIENT_MODULE_PARM(force, \
                       "List of adapter,address pairs to boldly assume " \
                       "to be present"); \
   SENSORS_MODULE_PARM_FORCE(chip1); \
@@ -304,7 +253,7 @@
 
 #define SENSORS_INSMOD_8(chip1,chip2,chip3,chip4,chip5,chip6,chip7,chip8) \
   enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8 }; \
-  SENSORS_MODULE_PARM(force, \
+  I2C_CLIENT_MODULE_PARM(force, \
                       "List of adapter,address pairs to boldly assume " \
                       "to be present"); \
   SENSORS_MODULE_PARM_FORCE(chip1); \
@@ -327,16 +276,13 @@
                                                  {NULL}}; \
   SENSORS_INSMOD
 
-typedef int i2c_found_addr_proc(struct i2c_adapter *adapter,
-				    int addr, int kind);
-
 /* Detect function. It iterates over all possible addresses itself. For
    SMBus addresses, it will only call found_proc if some client is connected
    to the SMBus (unless a 'force' matched); for ISA detections, this is not
    done. */
 extern int i2c_detect(struct i2c_adapter *adapter,
-			  struct i2c_address_data *address_data,
-			  i2c_found_addr_proc * found_proc);
+		      struct i2c_address_data *address_data,
+		      int (*found_proc) (struct i2c_adapter *, int, int));
 
 
 /* This macro is used to scale user-input to sensible values in almost all
@@ -350,24 +296,4 @@
 	else
 		return value;
 }
-
-
-/* The maximum length of the prefix */
-#define SENSORS_PREFIX_MAX 20
-
-/* Sysctl IDs */
-#ifdef DEV_HWMON
-#define DEV_SENSORS DEV_HWMON
-#else				/* ndef DEV_HWMOM */
-#define DEV_SENSORS 2		/* The id of the lm_sensors directory within the
-				   dev table */
-#endif				/* def DEV_HWMON */
-
-#define SENSORS_CHIPS 1
-struct i2c_chips_data {
-	int sysctl_id;
-	char name[SENSORS_PREFIX_MAX + 13];
-};
-
 #endif				/* def _LINUX_I2C_SENSOR_H */
-
diff -Nru a/include/linux/i2c.h b/include/linux/i2c.h
--- a/include/linux/i2c.h	Wed Apr 30 22:28:05 2003
+++ b/include/linux/i2c.h	Wed Apr 30 22:28:05 2003
@@ -290,10 +290,12 @@
 };
 
 /* Internal numbers to terminate lists */
-#define I2C_CLIENT_END 0xfffe
+#define I2C_CLIENT_END		0xfffe
+#define I2C_CLIENT_ISA_END	0xfffefffe
 
 /* The numbers to use to set I2C bus address */
-#define ANY_I2C_BUS 0xffff
+#define ANY_I2C_BUS		0xffff
+#define ANY_I2C_ISA_BUS		9191
 
 /* The length of the option lists */
 #define I2C_CLIENT_MAX_OPTS 48
@@ -338,12 +340,9 @@
  * It will only call found_proc if some client is connected at the
  * specific address (unless a 'force' matched);
  */
-typedef int i2c_client_found_addr_proc (struct i2c_adapter *adapter,
-                                     int addr, unsigned short flags,int kind);
-
 extern int i2c_probe(struct i2c_adapter *adapter, 
 		struct i2c_client_address_data *address_data,
-		i2c_client_found_addr_proc *found_proc);
+		int (*found_proc) (struct i2c_adapter *, int, int));
 
 /* An ioctl like call to set div. parameters of the adapter.
  */
@@ -559,11 +558,15 @@
   I2C_CLIENT_MODULE_PARM(force, \
                       "List of adapter,address pairs to boldly assume " \
                       "to be present"); \
-  static struct i2c_client_address_data addr_data = \
-                                       {normal_i2c, normal_i2c_range, \
-                                        probe, probe_range, \
-                                        ignore, ignore_range, \
-                                        force}
+	static struct i2c_client_address_data addr_data = {		\
+			.normal_i2c = 		normal_i2c,		\
+			.normal_i2c_range =	normal_i2c_range,	\
+			.probe =		probe,			\
+			.probe_range =		probe_range,		\
+			.ignore =		ignore,			\
+			.ignore_range =		ignore_range,		\
+			.force =		force,			\
+		}
 
 /* Detect whether we are on the isa bus. If this returns true, all i2c
    access will fail! */
diff -Nru a/include/linux/ide.h b/include/linux/ide.h
--- a/include/linux/ide.h	Wed Apr 30 22:28:08 2003
+++ b/include/linux/ide.h	Wed Apr 30 22:28:08 2003
@@ -228,25 +228,6 @@
 #define PRD_ENTRIES     (PAGE_SIZE / (2 * PRD_BYTES))
 
 /*
- * Our Physical Region Descriptor (PRD) table should be large enough
- * to handle the biggest I/O request we are likely to see.  Since requests
- * can have no more than 256 sectors, and since the typical blocksize is
- * two or more sectors, we could get by with a limit of 128 entries here for
- * the usual worst case.  Most requests seem to include some contiguous blocks,
- * further reducing the number of table entries required.
- *
- * The driver reverts to PIO mode for individual requests that exceed
- * this limit (possible with 512 byte blocksizes, eg. MSDOS f/s), so handling
- * 100% of all crazy scenarios here is not necessary.
- *
- * As it turns out though, we must allocate a full 4KB page for this,
- * so the two PRD tables (ide0 & ide1) will each get half of that,
- * allowing each to have about 256 entries (8 bytes each) from this.
- */
-#define PRD_BYTES	8
-#define PRD_ENTRIES	(PAGE_SIZE / (2 * PRD_BYTES))
-
-/*
  * Some more useful definitions
  */
 #define IDE_MAJOR_NAME	"hd"	/* the same for all i/f; see also genhd.c */
@@ -1245,7 +1226,6 @@
  * We need blk.h, but we replace its end_request by our own version.
  */
 #define IDE_DRIVER		/* Toggle some magic bits in blk.h */
-#define LOCAL_END_REQUEST	/* Don't generate end_request in blk.h */
 #include <linux/blk.h>
 
 extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs);
@@ -1428,6 +1408,8 @@
 	void			*special;
 } pkt_task_t;
 
+extern inline u32 ide_read_24(ide_drive_t *);
+
 extern inline void SELECT_DRIVE(ide_drive_t *);
 extern inline void SELECT_INTERRUPT(ide_drive_t *);
 extern inline void SELECT_MASK(ide_drive_t *, int);
@@ -1568,7 +1550,7 @@
 
 extern int ide_spin_wait_hwgroup(ide_drive_t *);
 extern void ide_timer_expiry(unsigned long);
-extern void ide_intr(int irq, void *dev_id, struct pt_regs *regs);
+extern irqreturn_t ide_intr(int irq, void *dev_id, struct pt_regs *regs);
 extern void do_ide_request(request_queue_t *);
 extern void ide_init_subdrivers(void);
 
diff -Nru a/include/linux/if_pppox.h b/include/linux/if_pppox.h
--- a/include/linux/if_pppox.h	Wed Apr 30 22:28:05 2003
+++ b/include/linux/if_pppox.h	Wed Apr 30 22:28:05 2003
@@ -134,10 +134,15 @@
 
 #define pppox_sk(__sk) ((struct pppox_opt *)(__sk)->protinfo)
 
+struct module;
+
 struct pppox_proto {
-	int (*create)(struct socket *sock);
-	int (*ioctl)(struct socket *sock, unsigned int cmd,
-		     unsigned long arg);
+	int		(*create)(struct socket *sock);
+	int		(*ioctl)(struct socket *sock, unsigned int cmd,
+				 unsigned long arg);
+	int		(*release)(struct socket *sock);
+	void            (*sk_free)(struct sock *sk);
+	struct module	*owner;
 };
 
 extern int register_pppox_proto(int proto_num, struct pppox_proto *pp);
@@ -145,6 +150,9 @@
 extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
 extern int pppox_channel_ioctl(struct ppp_channel *pc, unsigned int cmd,
 			       unsigned long arg);
+extern struct sock *pppox_sk_alloc(struct socket *sock, int protocol,
+				   int priority, int zero_it,
+				   kmem_cache_t *slab);
 
 /* PPPoX socket states */
 enum {
diff -Nru a/include/linux/igmp.h b/include/linux/igmp.h
--- a/include/linux/igmp.h	Wed Apr 30 22:28:09 2003
+++ b/include/linux/igmp.h	Wed Apr 30 22:28:09 2003
@@ -191,7 +191,7 @@
          (IGMPV3_MASK((value) >> (nbmant), nbexp) + (nbexp))))
 
 #define IGMPV3_QQIC(value) IGMPV3_EXP(0x80, 4, 3, value)
-#define IGMPV3_MRC(value) IGMPV3_EXP(0x8000, 12, 3, value)
+#define IGMPV3_MRC(value) IGMPV3_EXP(0x80, 4, 3, value)
 
 extern int ip_check_mc(struct in_device *dev, u32 mc_addr, u32 src_addr, u16 proto);
 extern int igmp_rcv(struct sk_buff *);
@@ -199,10 +199,12 @@
 extern int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr);
 extern void ip_mc_drop_socket(struct sock *sk);
 extern int ip_mc_source(int add, int omode, struct sock *sk,
-		struct ip_mreq_source *mreqs);
-extern int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf);
+		struct ip_mreq_source *mreqs, int ifindex);
+extern int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf,int ifindex);
 extern int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
 		struct ip_msfilter *optval, int *optlen);
+extern int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
+		struct group_filter *optval, int *optlen);
 extern int ip_mc_sf_allow(struct sock *sk, u32 local, u32 rmt, int dif);
 extern void ip_mr_init(void);
 extern void ip_mc_init_dev(struct in_device *);
diff -Nru a/include/linux/initrd.h b/include/linux/initrd.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/include/linux/initrd.h	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,18 @@
+
+#define INITRD_MINOR 250 /* shouldn't collide with /dev/ram* too soon ... */
+
+/* 1 = load ramdisk, 0 = don't load */
+extern int rd_doload;
+
+/* 1 = prompt for ramdisk, 0 = don't prompt */
+extern int rd_prompt;
+
+/* starting block # of image */
+extern int rd_image_start;
+
+/* 1 if it is not an error if initrd_start < memory_start */
+extern int initrd_below_start_ok;
+
+/* free_initrd_mem always gets called with the next two as arguments.. */
+extern unsigned long initrd_start, initrd_end;
+extern void free_initrd_mem(unsigned long, unsigned long);
diff -Nru a/include/linux/input.h b/include/linux/input.h
--- a/include/linux/input.h	Wed Apr 30 22:28:08 2003
+++ b/include/linux/input.h	Wed Apr 30 22:28:08 2003
@@ -734,7 +734,6 @@
  * In-kernel definitions.
  */
 
-#include <linux/devfs_fs_kernel.h>
 #include <linux/fs.h>
 #include <linux/timer.h>
 
@@ -895,8 +894,8 @@
 int input_accept_process(struct input_handle *handle, struct file *file);
 int input_flush_device(struct input_handle* handle, struct file* file);
 
-devfs_handle_t input_register_minor(char *name, int minor, int minor_base);
-void input_unregister_minor(devfs_handle_t handle);
+/* will go away once devfs_register gets sanitized */
+void input_register_minor(char *name, int minor, int minor_base);
 
 void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
 
@@ -909,7 +908,7 @@
 #define input_regs(a,b)		do { (a)->regs = (b); } while (0)
 #define input_sync(a)		do { input_event(a, EV_SYN, SYN_REPORT, 0); (a)->regs = NULL; } while (0)
 
-extern struct device_class input_devclass;
+extern struct class input_class;
 
 #endif
 #endif
diff -Nru a/include/linux/interrupt.h b/include/linux/interrupt.h
--- a/include/linux/interrupt.h	Wed Apr 30 22:28:10 2003
+++ b/include/linux/interrupt.h	Wed Apr 30 22:28:10 2003
@@ -11,8 +11,28 @@
 #include <asm/ptrace.h>
 #include <asm/system.h>
 
+/*
+ * For 2.4.x compatibility, 2.4.x can use
+ *
+ *	typedef void irqreturn_t;
+ *	#define IRQ_NONE
+ *	#define IRQ_HANDLED
+ *	#define IRQ_RETVAL(x)
+ *
+ * To mix old-style and new-style irq handler returns.
+ *
+ * IRQ_NONE means we didn't handle it.
+ * IRQ_HANDLED means that we did have a valid interrupt and handled it.
+ * IRQ_RETVAL(x) selects on the two depending on x being non-zero (for handled)
+ */
+typedef int irqreturn_t;
+
+#define IRQ_NONE	(0)
+#define IRQ_HANDLED	(1)
+#define IRQ_RETVAL(x)	((x) != 0)
+
 struct irqaction {
-	void (*handler)(int, void *, struct pt_regs *);
+	irqreturn_t (*handler)(int, void *, struct pt_regs *);
 	unsigned long flags;
 	unsigned long mask;
 	const char *name;
@@ -20,15 +40,16 @@
 	struct irqaction *next;
 };
 
+extern irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs);
 extern int request_irq(unsigned int,
-		       void (*handler)(int, void *, struct pt_regs *),
+		       irqreturn_t (*handler)(int, void *, struct pt_regs *),
 		       unsigned long, const char *, void *);
 extern void free_irq(unsigned int, void *);
 
 /*
  * Temporary defines for UP kernels, until all code gets fixed.
  */
-#if !CONFIG_SMP
+#ifndef CONFIG_SMP
 # define cli()			local_irq_disable()
 # define sti()			local_irq_enable()
 # define save_flags(x)		local_save_flags(x)
diff -Nru a/include/linux/ioctl32.h b/include/linux/ioctl32.h
--- a/include/linux/ioctl32.h	Wed Apr 30 22:28:03 2003
+++ b/include/linux/ioctl32.h	Wed Apr 30 22:28:03 2003
@@ -19,5 +19,12 @@
 
 extern int unregister_ioctl32_conversion(unsigned int cmd);
 
+typedef int (*ioctl_trans_handler_t)(unsigned int, unsigned int, unsigned long, struct file *);
+
+struct ioctl_trans {
+	unsigned long cmd;
+	ioctl_trans_handler_t handler;
+	struct ioctl_trans *next;
+};
 
 #endif
diff -Nru a/include/linux/irq.h b/include/linux/irq.h
--- a/include/linux/irq.h	Wed Apr 30 22:28:08 2003
+++ b/include/linux/irq.h	Wed Apr 30 22:28:08 2003
@@ -72,7 +72,6 @@
 extern int setup_irq(unsigned int , struct irqaction * );
 
 extern hw_irq_controller no_irq_type;  /* needed in every arch ? */
-extern void no_action(int cpl, void *dev_id, struct pt_regs *regs);
 
 #endif
 
diff -Nru a/include/linux/isdn.h b/include/linux/isdn.h
--- a/include/linux/isdn.h	Wed Apr 30 22:28:19 2003
+++ b/include/linux/isdn.h	Wed Apr 30 22:28:19 2003
@@ -201,10 +201,6 @@
 #  include <linux/concap.h>
 #endif
 
-#ifdef CONFIG_DEVFS_FS
-#  include <linux/devfs_fs_kernel.h>
-#endif
-
 #include <linux/isdnif.h>
 
 #define ISDN_DRVIOCTL_MASK       0x7f  /* Mask for Device-ioctl */
diff -Nru a/include/linux/iso_fs.h b/include/linux/iso_fs.h
--- a/include/linux/iso_fs.h	Wed Apr 30 22:28:11 2003
+++ b/include/linux/iso_fs.h	Wed Apr 30 22:28:11 2003
@@ -224,8 +224,6 @@
 extern int get_rock_ridge_filename(struct iso_directory_record *, char *, struct inode *);
 extern int isofs_name_translate(struct iso_directory_record *, char *, struct inode *);
 
-extern int find_rock_ridge_relocation(struct iso_directory_record *, struct inode *);
-
 int get_joliet_filename(struct iso_directory_record *, unsigned char *, struct inode *);
 int get_acorn_filename(struct iso_directory_record *, char *, struct inode *);
 
diff -Nru a/include/linux/kdev_t.h b/include/linux/kdev_t.h
--- a/include/linux/kdev_t.h	Wed Apr 30 22:28:15 2003
+++ b/include/linux/kdev_t.h	Wed Apr 30 22:28:15 2003
@@ -99,7 +99,6 @@
 
 #define HASHDEV(dev)	(kdev_val(dev))
 #define NODEV		(mk_kdev(0,0))
-#define B_FREE		(mk_kdev(0xff,0xff))
 
 static inline int kdev_same(kdev_t dev1, kdev_t dev2)
 {
diff -Nru a/include/linux/linux_logo.h b/include/linux/linux_logo.h
--- a/include/linux/linux_logo.h	Wed Apr 30 22:28:06 2003
+++ b/include/linux/linux_logo.h	Wed Apr 30 22:28:06 2003
@@ -32,6 +32,6 @@
 	const unsigned char *data;
 };
 
-extern const struct linux_logo * __init find_logo(int depth);
+extern const struct linux_logo *fb_find_logo(int depth);
 
 #endif /* _LINUX_LINUX_LOGO_H */
diff -Nru a/include/linux/list.h b/include/linux/list.h
--- a/include/linux/list.h	Wed Apr 30 22:28:10 2003
+++ b/include/linux/list.h	Wed Apr 30 22:28:10 2003
@@ -320,6 +320,31 @@
 	for (pos = (head)->next, n = pos->next; pos != (head); \
 		pos = n, ({ smp_read_barrier_depends(); 0;}), n = pos->next)
 
+/**
+ * list_for_each_entry_rcu	-	iterate over rcu list of given type
+ * @pos:	the type * to use as a loop counter.
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_rcu(pos, head, member)			\
+	for (pos = list_entry((head)->next, typeof(*pos), member),	\
+		     prefetch(pos->member.next);			\
+	     &pos->member != (head); 					\
+	     pos = list_entry(pos->member.next, typeof(*pos), member),	\
+		     ({ smp_read_barrier_depends(); 0;}),		\
+		     prefetch(pos->member.next))
+
+
+/**
+ * list_for_each_continue_rcu	-	iterate over an rcu-protected list 
+ *			continuing from existing point.
+ * @pos:	the &struct list_head to use as a loop counter.
+ * @head:	the head for your list.
+ */
+#define list_for_each_continue_rcu(pos, head) \
+	for ((pos) = (pos)->next, prefetch((pos)->next); (pos) != (head); \
+        	(pos) = (pos)->next, ({ smp_read_barrier_depends(); 0;}), prefetch((pos)->next))
+
 /* 
  * Double linked lists with a single pointer list head. 
  * Mostly useful for hash tables where the two pointer list head is 
@@ -411,6 +436,10 @@
 #define hlist_for_each(pos, head) \
 	for (pos = (head)->first; pos; \
 	     pos = pos->next) 
+
+#define hlist_for_each_safe(pos, n, head) \
+	for (pos = (head)->first; n = pos ? pos->next : 0, pos; \
+	     pos = n)
 
 #else
 #warning "don't include kernel headers in userspace"
diff -Nru a/include/linux/miscdevice.h b/include/linux/miscdevice.h
--- a/include/linux/miscdevice.h	Wed Apr 30 22:28:10 2003
+++ b/include/linux/miscdevice.h	Wed Apr 30 22:28:10 2003
@@ -1,8 +1,6 @@
 #ifndef _LINUX_MISCDEVICE_H
 #define _LINUX_MISCDEVICE_H
 
-#include <linux/devfs_fs_kernel.h>
-
 #define BUSMOUSE_MINOR 0
 #define PSMOUSE_MINOR  1
 #define MS_BUSMOUSE_MINOR 2
@@ -44,7 +42,7 @@
 	const char *name;
 	struct file_operations *fops;
 	struct miscdevice * next, * prev;
-	devfs_handle_t devfs_handle;
+	char devfs_name[64];
 };
 
 extern int misc_register(struct miscdevice * misc);
diff -Nru a/include/linux/mm.h b/include/linux/mm.h
--- a/include/linux/mm.h	Wed Apr 30 22:28:04 2003
+++ b/include/linux/mm.h	Wed Apr 30 22:28:04 2003
@@ -594,28 +594,10 @@
 
 extern unsigned int nr_used_zone_pages(void);
 
-#ifdef CONFIG_MMU
 extern struct page * vmalloc_to_page(void *addr);
 extern struct page * follow_page(struct mm_struct *mm, unsigned long address,
 		int write);
 extern int remap_page_range(struct vm_area_struct *vma, unsigned long from,
 		unsigned long to, unsigned long size, pgprot_t prot);
-#else
-static inline struct page * vmalloc_to_page(void *addr)
-{
-	return NULL;
-}
-static inline struct page * follow_page(struct mm_struct *mm,
-		unsigned long address, int write)
-{
-	return NULL;
-}
-static inline int remap_page_range(struct vm_area_struct *vma,
-		unsigned long from, unsigned long to,
-		unsigned long size, pgprot_t prot)
-{
-	return -EPERM;
-}
-#endif /* CONFIG_MMU */
 #endif /* __KERNEL__ */
 #endif /* _LINUX_MM_H */
diff -Nru a/include/linux/module.h b/include/linux/module.h
--- a/include/linux/module.h	Wed Apr 30 22:28:15 2003
+++ b/include/linux/module.h	Wed Apr 30 22:28:15 2003
@@ -20,10 +20,7 @@
 #include <asm/module.h>
 
 /* Not Yet Implemented */
-#define MODULE_AUTHOR(name)
-#define MODULE_DESCRIPTION(desc)
 #define MODULE_SUPPORTED_DEVICE(name)
-#define MODULE_PARM_DESC(var,desc)
 #define print_modules()
 
 /* v850 toolchain uses a `_' prefix for all user symbols */
@@ -58,12 +55,11 @@
 	       unsigned long value);
 
 #ifdef MODULE
-#define ___module_cat(a,b) a ## b
+#define ___module_cat(a,b) __mod_ ## a ## b
 #define __module_cat(a,b) ___module_cat(a,b)
-/* For userspace: you can also call me... */
-#define MODULE_ALIAS(alias)					\
-	static const char __module_cat(__alias_,__LINE__)[]	\
-		__attribute__((section(".modinfo"),unused)) = "alias=" alias
+#define __MODULE_INFO(tag, name, info)					  \
+static const char __module_cat(name,__LINE__)[]				  \
+  __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info
 
 #define MODULE_GENERIC_TABLE(gtype,name)			\
 extern const struct gtype##_id __mod_##gtype##_table		\
@@ -71,6 +67,19 @@
 
 #define THIS_MODULE (&__this_module)
 
+#else  /* !MODULE */
+
+#define MODULE_GENERIC_TABLE(gtype,name)
+#define __MODULE_INFO(tag, name, info)
+#define THIS_MODULE ((struct module *)0)
+#endif
+
+/* Generic info of form tag = "info" */
+#define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
+
+/* For userspace: you can also call me... */
+#define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
+
 /*
  * The following license idents are currently accepted as indicating free
  * software modules
@@ -97,17 +106,18 @@
  * 2.	So the community can ignore bug reports including proprietary modules
  * 3.	So vendors can do likewise based on their own policies
  */
-#define MODULE_LICENSE(license)					\
-	static const char __module_license[]			\
-		__attribute__((section(".init.license"), unused)) = license
+#define MODULE_LICENSE(_license) MODULE_INFO(license, _license)
 
-#else  /* !MODULE */
-
-#define MODULE_ALIAS(alias)
-#define MODULE_GENERIC_TABLE(gtype,name)
-#define THIS_MODULE ((struct module *)0)
-#define MODULE_LICENSE(license)
-#endif
+/* Author, ideally of form NAME <EMAIL>[, NAME <EMAIL>]*[ and NAME <EMAIL>] */
+#define MODULE_AUTHOR(_author) MODULE_INFO(author, _author)
+  
+/* What your module does. */
+#define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
+
+/* One for each parameter, describing how to use it.  Some files do
+   multiple of these per line, so can't just use MODULE_INFO. */
+#define MODULE_PARM_DESC(_parm, desc) \
+	__MODULE_INFO(parm, _parm, #_parm ":" desc)
 
 #define MODULE_DEVICE_TABLE(type,name)		\
   MODULE_GENERIC_TABLE(type##_device,name)
@@ -255,6 +265,7 @@
 
 #ifdef CONFIG_MODULE_UNLOAD
 
+unsigned int module_refcount(struct module *mod);
 void __symbol_put(const char *symbol);
 #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x)
 void symbol_put_addr(void *addr);
@@ -265,6 +276,17 @@
 #define local_dec(x) atomic_dec(x)
 #endif
 
+/* Sometimes we know we already have a refcount, and it's easier not
+   to handle the error case (which only happens with rmmod --wait). */
+static inline void __module_get(struct module *module)
+{
+	if (module) {
+		BUG_ON(module_refcount(module) == 0);
+		local_inc(&module->ref[get_cpu()].count);
+		put_cpu();
+	}
+}
+
 static inline int try_module_get(struct module *module)
 {
 	int ret = 1;
@@ -300,6 +322,9 @@
 static inline void module_put(struct module *module)
 {
 }
+static inline void __module_get(struct module *module)
+{
+}
 #define symbol_put(x) do { } while(0)
 #define symbol_put_addr(p) do { } while(0)
 
@@ -356,6 +381,10 @@
 #define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); })
 #define symbol_put(x) do { } while(0)
 #define symbol_put_addr(x) do { } while(0)
+
+static inline void __module_get(struct module *module)
+{
+}
 
 static inline int try_module_get(struct module *module)
 {
diff -Nru a/include/linux/net.h b/include/linux/net.h
--- a/include/linux/net.h	Wed Apr 30 22:28:08 2003
+++ b/include/linux/net.h	Wed Apr 30 22:28:08 2003
@@ -127,15 +127,21 @@
 				      int offset, size_t size, int flags);
 };
 
+struct module;
+
 struct net_proto_family {
-	int	family;
-	int	(*create)(struct socket *sock, int protocol);
+	int		family;
+	int		(*create)(struct socket *sock, int protocol);
 	/* These are counters for the number of different methods of
 	   each we support */
-	short	authentication;
-	short	encryption;
-	short	encrypt_net;
+	short		authentication;
+	short		encryption;
+	short		encrypt_net;
+	struct module	*owner;
 };
+
+extern int	     net_family_get(int family);
+extern void	     net_family_put(int family);
 
 struct iovec;
 
diff -Nru a/include/linux/netfilter.h b/include/linux/netfilter.h
--- a/include/linux/netfilter.h	Wed Apr 30 22:28:09 2003
+++ b/include/linux/netfilter.h	Wed Apr 30 22:28:09 2003
@@ -47,6 +47,7 @@
 
 	/* User fills in from here down. */
 	nf_hookfn *hook;
+	struct module *owner;
 	int pf;
 	int hooknum;
 	/* Hooks are ordered in ascending priority. */
diff -Nru a/include/linux/netfilter_bridge.h b/include/linux/netfilter_bridge.h
--- a/include/linux/netfilter_bridge.h	Wed Apr 30 22:28:10 2003
+++ b/include/linux/netfilter_bridge.h	Wed Apr 30 22:28:10 2003
@@ -30,6 +30,7 @@
 #define BRNF_PKT_TYPE			0x01
 #define BRNF_BRIDGED_DNAT		0x02
 #define BRNF_DONT_TAKE_PARENT		0x04
+#define BRNF_BRIDGED			0x08
 
 enum nf_br_hook_priorities {
 	NF_BR_PRI_FIRST = INT_MIN,
diff -Nru a/include/linux/netfilter_ipv4/ipt_physdev.h b/include/linux/netfilter_ipv4/ipt_physdev.h
--- a/include/linux/netfilter_ipv4/ipt_physdev.h	Wed Apr 30 22:28:13 2003
+++ b/include/linux/netfilter_ipv4/ipt_physdev.h	Wed Apr 30 22:28:13 2003
@@ -5,11 +5,16 @@
 #include <linux/if.h>
 #endif
 
-#define IPT_PHYSDEV_OP_MATCH_IN 0x01
-#define IPT_PHYSDEV_OP_MATCH_OUT 0x02
+#define IPT_PHYSDEV_OP_IN		0x01
+#define IPT_PHYSDEV_OP_OUT		0x02
+#define IPT_PHYSDEV_OP_BRIDGED		0x04
+#define IPT_PHYSDEV_OP_ISIN		0x08
+#define IPT_PHYSDEV_OP_ISOUT		0x10
+#define IPT_PHYSDEV_OP_MASK		(0x20 - 1)
 
 struct ipt_physdev_info {
 	u_int8_t invert;
+	u_int8_t bitmask;
 	char physindev[IFNAMSIZ];
 	char in_mask[IFNAMSIZ];
 	char physoutdev[IFNAMSIZ];
diff -Nru a/include/linux/nfsd/syscall.h b/include/linux/nfsd/syscall.h
--- a/include/linux/nfsd/syscall.h	Wed Apr 30 22:28:19 2003
+++ b/include/linux/nfsd/syscall.h	Wed Apr 30 22:28:19 2003
@@ -59,7 +59,7 @@
 struct nfsctl_export {
 	char			ex_client[NFSCLNT_IDMAX+1];
 	char			ex_path[NFS_MAXPATHLEN+1];
-	__kernel_dev_t		ex_dev;
+	__kernel_old_dev_t	ex_dev;
 	__kernel_ino_t		ex_ino;
 	int			ex_flags;
 	__kernel_uid_t		ex_anon_uid;
@@ -104,7 +104,6 @@
 #define ca_export	u.u_export
 #define ca_getfd	u.u_getfd
 #define	ca_getfs	u.u_getfs
-#define ca_authd	u.u_authd
 };
 
 union nfsctl_res {
diff -Nru a/include/linux/percpu_counter.h b/include/linux/percpu_counter.h
--- a/include/linux/percpu_counter.h	Wed Apr 30 22:28:10 2003
+++ b/include/linux/percpu_counter.h	Wed Apr 30 22:28:10 2003
@@ -7,7 +7,7 @@
 #include <linux/config.h>
 #include <linux/spinlock.h>
 #include <linux/smp.h>
-#include <linux/preempt.h>
+#include <linux/threads.h>
 
 #ifdef CONFIG_SMP
 
diff -Nru a/include/linux/quotaops.h b/include/linux/quotaops.h
--- a/include/linux/quotaops.h	Wed Apr 30 22:28:06 2003
+++ b/include/linux/quotaops.h	Wed Apr 30 22:28:06 2003
@@ -166,6 +166,7 @@
  */
 #define sb_dquot_ops				(NULL)
 #define sb_quotactl_ops				(NULL)
+#define sync_dquots_dev(dev,type)		(NULL)
 #define DQUOT_INIT(inode)			do { } while(0)
 #define DQUOT_DROP(inode)			do { } while(0)
 #define DQUOT_ALLOC_INODE(inode)		(0)
diff -Nru a/include/linux/sched.h b/include/linux/sched.h
--- a/include/linux/sched.h	Wed Apr 30 22:28:04 2003
+++ b/include/linux/sched.h	Wed Apr 30 22:28:04 2003
@@ -465,8 +465,9 @@
 #define PF_FROZEN	0x00010000	/* frozen for system suspend */
 #define PF_FSTRANS	0x00020000	/* inside a filesystem transaction */
 #define PF_KSWAPD	0x00040000	/* I am kswapd */
+#define PF_SWAPOFF	0x00080000	/* I am in swapoff */
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 extern void set_cpus_allowed(task_t *p, unsigned long new_mask);
 #else
 # define set_cpus_allowed(p, new_mask) do { } while (0)
diff -Nru a/include/linux/serial_core.h b/include/linux/serial_core.h
--- a/include/linux/serial_core.h	Wed Apr 30 22:28:04 2003
+++ b/include/linux/serial_core.h	Wed Apr 30 22:28:04 2003
@@ -300,6 +300,7 @@
 			int *flow);
 int uart_set_options(struct uart_port *port, struct console *co, int baud,
 		     int parity, int bits, int flow);
+struct tty_driver *uart_console_device(struct console *co, int *index);
 
 /*
  * Port/driver registration/removal
diff -Nru a/include/linux/serio.h b/include/linux/serio.h
--- a/include/linux/serio.h	Wed Apr 30 22:28:10 2003
+++ b/include/linux/serio.h	Wed Apr 30 22:28:10 2003
@@ -10,6 +10,7 @@
  */
 
 #include <linux/ioctl.h>
+#include <linux/interrupt.h>
 
 #define SPIOCSTYPE	_IOW('q', 0x01, unsigned long)
 
@@ -50,7 +51,8 @@
 	char *name;
 
 	void (*write_wakeup)(struct serio *);
-	void (*interrupt)(struct serio *, unsigned char, unsigned int, struct pt_regs *);
+	irqreturn_t (*interrupt)(struct serio *, unsigned char,
+			unsigned int, struct pt_regs *);
 	void (*connect)(struct serio *, struct serio_dev *dev);
 	void (*disconnect)(struct serio *);
 	void (*cleanup)(struct serio *);
@@ -61,7 +63,7 @@
 int serio_open(struct serio *serio, struct serio_dev *dev);
 void serio_close(struct serio *serio);
 void serio_rescan(struct serio *serio);
-void serio_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs);
+irqreturn_t serio_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs);
 
 void serio_register_port(struct serio *serio);
 void serio_unregister_port(struct serio *serio);
diff -Nru a/include/linux/slab.h b/include/linux/slab.h
--- a/include/linux/slab.h	Wed Apr 30 22:28:19 2003
+++ b/include/linux/slab.h	Wed Apr 30 22:28:19 2003
@@ -22,8 +22,11 @@
 #define	SLAB_KERNEL		GFP_KERNEL
 #define	SLAB_DMA		GFP_DMA
 
-#define SLAB_LEVEL_MASK		(__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS|__GFP_COLD|__GFP_NOWARN)
-#define	SLAB_NO_GROW		0x00001000UL	/* don't grow a cache */
+#define SLAB_LEVEL_MASK		(__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS|\
+				__GFP_COLD|__GFP_NOWARN|__GFP_REPEAT|\
+				__GFP_NOFAIL|__GFP_NORETRY)
+
+#define	SLAB_NO_GROW		__GFP_NO_GROW	/* don't grow a cache */
 
 /* flags to pass to kmem_cache_create().
  * The first 3 are only valid when the allocator as been build
diff -Nru a/include/linux/time.h b/include/linux/time.h
--- a/include/linux/time.h	Wed Apr 30 22:28:11 2003
+++ b/include/linux/time.h	Wed Apr 30 22:28:11 2003
@@ -26,6 +26,16 @@
 
 #include <linux/spinlock.h>
 #include <linux/seqlock.h>
+#include <linux/timex.h>
+#include <asm/div64.h>
+#ifndef div_long_long_rem
+
+#define div_long_long_rem(dividend,divisor,remainder) ({ \
+		       u64 result = dividend;		\
+		       *remainder = do_div(result,divisor); \
+		       result; })
+
+#endif
 
 /*
  * Have the 32 bit jiffies value wrap 5 minutes after boot
@@ -59,25 +69,52 @@
 #ifndef NSEC_PER_USEC
 #define NSEC_PER_USEC (1000L)
 #endif
+/*
+ * We want to do realistic conversions of time so we need to use the same
+ * values the update wall clock code uses as the jiffie size.  This value
+ * is: TICK_NSEC(TICK_USEC) (both of which are defined in timex.h).  This 
+ * is a constant and is in nanoseconds.  We will used scaled math and
+ * with a scales defined here as SEC_JIFFIE_SC,  USEC_JIFFIE_SC and 
+ * NSEC_JIFFIE_SC.  Note that these defines contain nothing but
+ * constants and so are computed at compile time.  SHIFT_HZ (computed in
+ * timex.h) adjusts the scaling for different HZ values.
+ */
+#define SEC_JIFFIE_SC (30 - SHIFT_HZ)
+#define NSEC_JIFFIE_SC (SEC_JIFFIE_SC + 30)
+#define USEC_JIFFIE_SC (SEC_JIFFIE_SC + 20)
+#define SEC_CONVERSION ((unsigned long)(((u64)NSEC_PER_SEC << SEC_JIFFIE_SC) /\
+                            (u64)TICK_NSEC(TICK_USEC))) 
+#define NSEC_CONVERSION ((unsigned long)(((u64)1 << NSEC_JIFFIE_SC) / \
+                            (u64)TICK_NSEC(TICK_USEC))) 
+#define USEC_CONVERSION \
+               ((unsigned long)(((u64)NSEC_PER_USEC << USEC_JIFFIE_SC)/ \
+                                 (u64)TICK_NSEC(TICK_USEC))) 
+#define MAX_SEC_IN_JIFFIES \
+    (u32)((u64)((u64)MAX_JIFFY_OFFSET * TICK_NSEC(TICK_USEC)) / NSEC_PER_SEC)
 
 static __inline__ unsigned long
 timespec_to_jiffies(struct timespec *value)
 {
 	unsigned long sec = value->tv_sec;
-	long nsec = value->tv_nsec;
+	long nsec = value->tv_nsec + TICK_NSEC(TICK_USEC) - 1;
 
-	if (sec >= (MAX_JIFFY_OFFSET / HZ))
+	if (sec >=  MAX_SEC_IN_JIFFIES)
 		return MAX_JIFFY_OFFSET;
-	nsec += 1000000000L / HZ - 1;
-	nsec /= 1000000000L / HZ;
-	return HZ * sec + nsec;
+	return (((u64)sec * SEC_CONVERSION) +
+		(((u64)nsec * NSEC_CONVERSION) >>
+		 (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
+
 }
 
 static __inline__ void
 jiffies_to_timespec(unsigned long jiffies, struct timespec *value)
 {
-	value->tv_nsec = (jiffies % HZ) * (1000000000L / HZ);
-	value->tv_sec = jiffies / HZ;
+	/*
+	 * Convert jiffies to nanoseconds and seperate with
+	 * one divide.
+	 */
+	u64 nsec = (u64)jiffies * TICK_NSEC(TICK_USEC); 
+	value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &value->tv_nsec);
 }
 
 /* Same for "timeval" */
@@ -85,20 +122,25 @@
 timeval_to_jiffies(struct timeval *value)
 {
 	unsigned long sec = value->tv_sec;
-	long usec = value->tv_usec;
+	long usec = value->tv_usec + USEC_PER_SEC / HZ - 1;
 
-	if (sec >= (MAX_JIFFY_OFFSET / HZ))
+	if (sec >= MAX_SEC_IN_JIFFIES)
 		return MAX_JIFFY_OFFSET;
-	usec += 1000000L / HZ - 1;
-	usec /= 1000000L / HZ;
-	return HZ * sec + usec;
+	return (((u64)sec * SEC_CONVERSION) +
+		(((u64)usec * USEC_CONVERSION) >>
+		 (USEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
 }
 
 static __inline__ void
 jiffies_to_timeval(unsigned long jiffies, struct timeval *value)
 {
-	value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
-	value->tv_sec = jiffies / HZ;
+	/*
+	 * Convert jiffies to nanoseconds and seperate with
+	 * one divide.
+	 */
+	u64 nsec = (u64)jiffies * TICK_NSEC(TICK_USEC); 
+	value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &value->tv_usec);
+	value->tv_usec /= NSEC_PER_USEC;
 }
 
 static __inline__ int timespec_equal(struct timespec *a, struct timespec *b) 
@@ -140,6 +182,7 @@
 }
 
 extern struct timespec xtime;
+extern struct timespec wall_to_monotonic;
 extern seqlock_t xtime_lock;
 
 static inline unsigned long get_seconds(void)
@@ -200,6 +243,9 @@
 #define CLOCK_MONOTONIC_HR	  5
 
 #define MAX_CLOCKS 6
+#define CLOCKS_MASK  (CLOCK_REALTIME | CLOCK_MONOTONIC | \
+                     CLOCK_REALTIME_HR | CLOCK_MONOTONIC_HR)
+#define CLOCKS_MONO (CLOCK_MONOTONIC & CLOCK_MONOTONIC_HR)
 
 /*
  * The various flags for setting POSIX.1b interval timers.
diff -Nru a/include/linux/timer.h b/include/linux/timer.h
--- a/include/linux/timer.h	Wed Apr 30 22:28:13 2003
+++ b/include/linux/timer.h	Wed Apr 30 22:28:13 2003
@@ -65,7 +65,7 @@
 extern int del_timer(struct timer_list * timer);
 extern int mod_timer(struct timer_list *timer, unsigned long expires);
   
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
   extern int del_timer_sync(struct timer_list * timer);
 #else
 # define del_timer_sync(t) del_timer(t)
diff -Nru a/include/linux/timex.h b/include/linux/timex.h
--- a/include/linux/timex.h	Wed Apr 30 22:28:04 2003
+++ b/include/linux/timex.h	Wed Apr 30 22:28:04 2003
@@ -51,7 +51,6 @@
 #ifndef _LINUX_TIMEX_H
 #define _LINUX_TIMEX_H
 
-#include <linux/time.h>
 #include <asm/param.h>
 
 /*
@@ -177,6 +176,7 @@
 /* a value TUSEC for TICK_USEC (can be set bij adjtimex)		*/
 #define TICK_NSEC(TUSEC) (SH_DIV (TUSEC * USER_HZ * 1000, ACTHZ, 8))
 
+#include <linux/time.h>
 /*
  * syscall interface - used (mainly by NTP daemon)
  * to discipline kernel clock oscillator
diff -Nru a/include/linux/tty.h b/include/linux/tty.h
--- a/include/linux/tty.h	Wed Apr 30 22:28:09 2003
+++ b/include/linux/tty.h	Wed Apr 30 22:28:09 2003
@@ -259,12 +259,14 @@
  */
 struct tty_struct {
 	int	magic;
-	struct tty_driver driver;
+	struct tty_driver *driver;
+	int index;
 	struct tty_ldisc ldisc;
 	struct termios *termios, *termios_locked;
+	char name[64];
 	int pgrp;
 	int session;
-	kdev_t	device;
+	dev_t	device;
 	unsigned long flags;
 	int count;
 	struct winsize winsize;
@@ -378,8 +380,8 @@
 extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc);
 extern int tty_register_driver(struct tty_driver *driver);
 extern int tty_unregister_driver(struct tty_driver *driver);
-extern void tty_register_device(struct tty_driver *driver, unsigned minor);
-extern void tty_unregister_device(struct tty_driver *driver, unsigned minor);
+extern void tty_register_device(struct tty_driver *driver, unsigned index);
+extern void tty_unregister_device(struct tty_driver *driver, unsigned index);
 extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp,
 			     int buflen);
 extern void tty_write_message(struct tty_struct *tty, char *msg);
diff -Nru a/include/linux/tty_driver.h b/include/linux/tty_driver.h
--- a/include/linux/tty_driver.h	Wed Apr 30 22:28:11 2003
+++ b/include/linux/tty_driver.h	Wed Apr 30 22:28:11 2003
@@ -231,6 +231,4 @@
 #define SERIAL_TYPE_NORMAL	1
 #define SERIAL_TYPE_CALLOUT	2
 
-extern struct device_class tty_devclass;
-
 #endif /* #ifdef _LINUX_TTY_DRIVER_H */
diff -Nru a/include/linux/umem.h b/include/linux/umem.h
--- a/include/linux/umem.h	Wed Apr 30 22:28:04 2003
+++ b/include/linux/umem.h	Wed Apr 30 22:28:04 2003
@@ -128,4 +128,11 @@
 #define PCI_VENDOR_ID_MICRO_MEMORY		0x1332
 #define PCI_DEVICE_ID_MICRO_MEMORY_5415CN	0x5415
 #define PCI_DEVICE_ID_MICRO_MEMORY_5425CN	0x5425
+#define PCI_DEVICE_ID_MICRO_MEMORY_6155		0x6155
+
+/* bits for card->flags */
+#define UM_FLAG_DMA_IN_REGS		1
+#define UM_FLAG_NO_BYTE_STATUS		2
+#define UM_FLAG_NO_BATTREG		4
+#define	UM_FLAG_NO_BATT			8
 #endif
diff -Nru a/include/linux/usb.h b/include/linux/usb.h
--- a/include/linux/usb.h	Wed Apr 30 22:28:08 2003
+++ b/include/linux/usb.h	Wed Apr 30 22:28:08 2003
@@ -765,6 +765,7 @@
 	urb->start_frame = -1;
 }
 
+extern void usb_init_urb(struct urb *urb);
 extern struct urb *usb_alloc_urb(int iso_packets, int mem_flags);
 extern void usb_free_urb(struct urb *urb);
 #define usb_put_urb usb_free_urb
@@ -973,7 +974,7 @@
 void usb_show_string(struct usb_device *dev, char *id, int index);
 
 #ifdef DEBUG
-#define dbg(format, arg...) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg)
+#define dbg(format, arg...) printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , ## arg)
 #else
 #define dbg(format, arg...) do {} while (0)
 #endif
diff -Nru a/include/linux/videodev.h b/include/linux/videodev.h
--- a/include/linux/videodev.h	Wed Apr 30 22:28:20 2003
+++ b/include/linux/videodev.h	Wed Apr 30 22:28:20 2003
@@ -19,7 +19,6 @@
 #ifdef __KERNEL__
 
 #include <linux/poll.h>
-#include <linux/devfs_fs_kernel.h>
 #include <linux/mm.h>
 
 struct video_device
@@ -39,7 +38,7 @@
 	/* for videodev.c intenal usage -- don't touch */
 	int users;
 	struct semaphore lock;
-	devfs_handle_t devfs_handle;
+	char devfs_name[64];	/* devfs */
 };
 
 #define VIDEO_MAJOR	81
diff -Nru a/include/linux/vmalloc.h b/include/linux/vmalloc.h
--- a/include/linux/vmalloc.h	Wed Apr 30 22:28:19 2003
+++ b/include/linux/vmalloc.h	Wed Apr 30 22:28:19 2003
@@ -27,7 +27,8 @@
 extern void *__vmalloc(unsigned long size, int gfp_mask, pgprot_t prot);
 extern void vfree(void *addr);
 
-extern void *vmap(struct page **pages, unsigned int count);
+extern void *vmap(struct page **pages, unsigned int count,
+			unsigned long flags, pgprot_t prot);
 extern void vunmap(void *addr);
  
 /*
diff -Nru a/include/linux/wrapper.h b/include/linux/wrapper.h
--- a/include/linux/wrapper.h	Wed Apr 30 22:28:07 2003
+++ /dev/null	Wed Dec 31 16:00:00 1969
@@ -1,7 +0,0 @@
-#ifndef _WRAPPER_H_
-#define _WRAPPER_H_
-
-#define mem_map_reserve(p)	set_bit(PG_reserved, &((p)->flags))
-#define mem_map_unreserve(p)	clear_bit(PG_reserved, &((p)->flags))
-
-#endif /* _WRAPPER_H_ */
diff -Nru a/include/media/saa7146.h b/include/media/saa7146.h
--- a/include/media/saa7146.h	Wed Apr 30 22:28:03 2003
+++ b/include/media/saa7146.h	Wed Apr 30 22:28:03 2003
@@ -6,7 +6,6 @@
 #include <linux/delay.h>	/* for delay-stuff */
 #include <linux/slab.h>		/* for kmalloc/kfree */
 #include <linux/pci.h>		/* for pci-config-stuff, vendor ids etc. */
-#include <linux/wrapper.h>	/* for mem_map_reserve */
 #include <linux/init.h>		/* for "__init" */
 #include <linux/interrupt.h>	/* for IMMEDIATE_BH */
 #include <linux/kmod.h>		/* for kernel module loader */
diff -Nru a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
--- a/include/net/bluetooth/hci_core.h	Wed Apr 30 22:28:10 2003
+++ b/include/net/bluetooth/hci_core.h	Wed Apr 30 22:28:10 2003
@@ -262,7 +262,7 @@
 int hci_conn_auth(struct hci_conn *conn);
 int hci_conn_encrypt(struct hci_conn *conn);
 
-static inline void hci_conn_set_timer(struct hci_conn *conn, long timeout)
+static inline void hci_conn_set_timer(struct hci_conn *conn, unsigned long timeout)
 {
 	mod_timer(&conn->timer, jiffies + timeout);
 }
@@ -280,8 +280,12 @@
 
 static inline void hci_conn_put(struct hci_conn *conn)
 {
-	if (atomic_dec_and_test(&conn->refcnt) && conn->out)
-		hci_conn_set_timer(conn, HCI_DISCONN_TIMEOUT);
+	if (atomic_dec_and_test(&conn->refcnt)) {
+		if (conn->type == SCO_LINK)
+			hci_conn_set_timer(conn, HZ / 100);
+		else if (conn->out)
+			hci_conn_set_timer(conn, HCI_DISCONN_TIMEOUT);
+	}
 }
 
 /* ----- HCI tasks ----- */
diff -Nru a/include/net/bluetooth/rfcomm.h b/include/net/bluetooth/rfcomm.h
--- a/include/net/bluetooth/rfcomm.h	Wed Apr 30 22:28:15 2003
+++ b/include/net/bluetooth/rfcomm.h	Wed Apr 30 22:28:15 2003
@@ -146,6 +146,11 @@
 	u16 param_mask;
 } __attribute__ ((packed));
 
+struct rfcomm_rls {
+	u8  dlci;
+	u8  status;
+} __attribute__ ((packed));
+
 struct rfcomm_msc {
 	u8  dlci;
 	u8  v24_sig;
@@ -215,10 +220,9 @@
 {
 	if (!rfcomm_thread)
 		return;
-
 	//set_bit(event, &rfcomm_event);
-	if (!test_and_set_bit(RFCOMM_SCHED_WAKEUP, &rfcomm_event))
-		wake_up_process(rfcomm_thread);
+	set_bit(RFCOMM_SCHED_WAKEUP, &rfcomm_event);
+	wake_up_process(rfcomm_thread);
 }
 
 extern struct semaphore rfcomm_sem;
diff -Nru a/include/net/if_inet6.h b/include/net/if_inet6.h
--- a/include/net/if_inet6.h	Wed Apr 30 22:28:18 2003
+++ b/include/net/if_inet6.h	Wed Apr 30 22:28:18 2003
@@ -15,6 +15,8 @@
 #ifndef _NET_IF_INET6_H
 #define _NET_IF_INET6_H
 
+#include <net/snmp.h>
+
 #define IF_RA_RCVD	0x20
 #define IF_RS_SENT	0x10
 
@@ -152,6 +154,11 @@
 	void		*sysctl;
 };
 
+struct ipv6_devstat {
+	struct proc_dir_entry	*proc_dir_entry;
+	DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6);
+};
+
 struct inet6_dev 
 {
 	struct net_device		*dev;
@@ -185,6 +192,7 @@
 	struct neigh_parms	*nd_parms;
 	struct inet6_dev	*next;
 	struct ipv6_devconf	cnf;
+	struct ipv6_devstat	stats;
 };
 
 extern struct ipv6_devconf ipv6_devconf;
diff -Nru a/include/net/ip6_route.h b/include/net/ip6_route.h
--- a/include/net/ip6_route.h	Wed Apr 30 22:28:05 2003
+++ b/include/net/ip6_route.h	Wed Apr 30 22:28:05 2003
@@ -59,7 +59,7 @@
 					    struct in6_addr *saddr,
 					    int oif, int flags);
 
-extern struct rt6_info		*ndisc_get_dummy_rt(void);
+extern struct rt6_info		*ip6_dst_alloc(void);
 
 /*
  *	support functions for ND
diff -Nru a/include/net/ipv6.h b/include/net/ipv6.h
--- a/include/net/ipv6.h	Wed Apr 30 22:28:15 2003
+++ b/include/net/ipv6.h	Wed Apr 30 22:28:15 2003
@@ -106,23 +106,47 @@
 /* sysctls */
 extern int sysctl_ipv6_bindv6only;
 
+/* MIBs */
 DECLARE_SNMP_STAT(struct ipv6_mib, ipv6_statistics);
 #define IP6_INC_STATS(field)		SNMP_INC_STATS(ipv6_statistics, field)
 #define IP6_INC_STATS_BH(field)		SNMP_INC_STATS_BH(ipv6_statistics, field)
 #define IP6_INC_STATS_USER(field) 	SNMP_INC_STATS_USER(ipv6_statistics, field)
 DECLARE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics);
-#define ICMP6_INC_STATS(field)		SNMP_INC_STATS(icmpv6_statistics, field)
-#define ICMP6_INC_STATS_BH(field)	SNMP_INC_STATS_BH(icmpv6_statistics, field)
-#define ICMP6_INC_STATS_USER(field) 	SNMP_INC_STATS_USER(icmpv6_statistics, field)
-#define ICMP6_STATS_PTR_BH(field) 					\
-	(&								\
-	 ((per_cpu_ptr(icmpv6_statistics[0], smp_processor_id()))->	\
-	  field))
+#define ICMP6_INC_STATS(idev, field)		({			\
+	struct inet6_dev *_idev = (idev);				\
+	if (likely(_idev != NULL))					\
+		SNMP_INC_STATS(idev->stats.icmpv6, field); 		\
+	SNMP_INC_STATS(icmpv6_statistics, field);			\
+})
+#define ICMP6_INC_STATS_BH(idev, field)		({			\
+	struct inet6_dev *_idev = (idev);				\
+	if (likely(_idev != NULL))					\
+		SNMP_INC_STATS_BH((_idev)->stats.icmpv6, field);	\
+	SNMP_INC_STATS_BH(icmpv6_statistics, field);			\
+})
+#define ICMP6_INC_STATS_USER(idev, field) 	({			\
+	struct inet6_dev *_idev = (idev);				\
+	if (likely(_idev != NULL))					\
+		SNMP_INC_STATS_USER(_idev->stats.icmpv6, field);	\
+	SNMP_INC_STATS_USER(icmpv6_statistics, field);			\
+})
+#define ICMP6_INC_STATS_OFFSET_BH(idev, field, offset)	({			\
+	struct inet6_dev *_idev = idev;						\
+	__typeof__(offset) _offset = (offset);					\
+	if (likely(_idev != NULL))						\
+		SNMP_INC_STATS_OFFSET_BH(_idev->stats.icmpv6, field, _offset);	\
+	SNMP_INC_STATS_OFFSET_BH(icmpv6_statistics, field, _offset);    	\
+})
 DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);
 #define UDP6_INC_STATS(field)		SNMP_INC_STATS(udp_stats_in6, field)
 #define UDP6_INC_STATS_BH(field)	SNMP_INC_STATS_BH(udp_stats_in6, field)
 #define UDP6_INC_STATS_USER(field) 	SNMP_INC_STATS_USER(udp_stats_in6, field)
 extern atomic_t			inet6_sock_nr;
+
+int snmp6_register_dev(struct inet6_dev *idev);
+int snmp6_unregister_dev(struct inet6_dev *idev);
+int snmp6_mib_init(void *ptr[2], size_t mibsize);
+void snmp6_mib_free(void *ptr[2]);
 
 struct ip6_ra_chain
 {
diff -Nru a/include/net/irda/irport.h b/include/net/irda/irport.h
--- a/include/net/irda/irport.h	Wed Apr 30 22:28:11 2003
+++ b/include/net/irda/irport.h	Wed Apr 30 22:28:11 2003
@@ -73,7 +73,7 @@
 	/* For piggyback drivers */
 	void *priv;                
 	void (*change_speed)(void *priv, __u32 speed);
-	void (*interrupt)(int irq, void *dev_id, struct pt_regs *regs);
+	int (*interrupt)(int irq, void *dev_id, struct pt_regs *regs);
 };
 
 struct irport_cb *irport_open(int i, unsigned int iobase, unsigned int irq);
@@ -81,7 +81,7 @@
 void irport_start(struct irport_cb *self);
 void irport_stop(struct irport_cb *self);
 void irport_change_speed(void *priv, __u32 speed);
-void irport_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+irqreturn_t irport_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 int  irport_hard_xmit(struct sk_buff *skb, struct net_device *dev);
 int  irport_net_open(struct net_device *dev);
 int  irport_net_close(struct net_device *dev);
diff -Nru a/include/net/pkt_cls.h b/include/net/pkt_cls.h
--- a/include/net/pkt_cls.h	Wed Apr 30 22:28:13 2003
+++ b/include/net/pkt_cls.h	Wed Apr 30 22:28:13 2003
@@ -39,6 +39,8 @@
 	int	(*fn)(struct tcf_proto *, unsigned long node, struct tcf_walker *);
 };
 
+struct module;
+
 struct tcf_proto_ops
 {
 	struct tcf_proto_ops	*next;
@@ -56,6 +58,8 @@
 
 	/* rtnetlink specific */
 	int			(*dump)(struct tcf_proto*, unsigned long, struct sk_buff *skb, struct tcmsg*);
+
+	struct module		*owner;
 };
 
 /* Main classifier routine: scans classifier chain attached
diff -Nru a/include/net/pkt_sched.h b/include/net/pkt_sched.h
--- a/include/net/pkt_sched.h	Wed Apr 30 22:28:05 2003
+++ b/include/net/pkt_sched.h	Wed Apr 30 22:28:05 2003
@@ -49,6 +49,8 @@
 	int			(*dump)(struct Qdisc *, unsigned long, struct sk_buff *skb, struct tcmsg*);
 };
 
+struct module;
+
 struct Qdisc_ops
 {
 	struct Qdisc_ops	*next;
@@ -67,6 +69,8 @@
 	int			(*change)(struct Qdisc *, struct rtattr *arg);
 
 	int			(*dump)(struct Qdisc *, struct sk_buff *);
+
+	struct module		*owner;
 };
 
 extern rwlock_t qdisc_tree_lock;
diff -Nru a/include/net/snmp.h b/include/net/snmp.h
--- a/include/net/snmp.h	Wed Apr 30 22:28:08 2003
+++ b/include/net/snmp.h	Wed Apr 30 22:28:08 2003
@@ -304,6 +304,8 @@
 
 #define SNMP_INC_STATS_BH(mib, field) 	\
 	(per_cpu_ptr(mib[0], smp_processor_id())->field++)
+#define SNMP_INC_STATS_OFFSET_BH(mib, field, offset)	\
+	((*((&per_cpu_ptr(mib[0], smp_processor_id())->field) + (offset)))++)
 #define SNMP_INC_STATS_USER(mib, field) \
 	(per_cpu_ptr(mib[1], smp_processor_id())->field++)
 #define SNMP_INC_STATS(mib, field) 	\
diff -Nru a/include/pcmcia/bus_ops.h b/include/pcmcia/bus_ops.h
--- a/include/pcmcia/bus_ops.h	Wed Apr 30 22:28:10 2003
+++ b/include/pcmcia/bus_ops.h	Wed Apr 30 22:28:10 2003
@@ -1,2 +0,0 @@
-/* now empty */
-#warning please remove the reference to this file
diff -Nru a/include/pcmcia/driver_ops.h b/include/pcmcia/driver_ops.h
--- a/include/pcmcia/driver_ops.h	Wed Apr 30 22:28:10 2003
+++ b/include/pcmcia/driver_ops.h	Wed Apr 30 22:28:10 2003
@@ -1,2 +0,0 @@
-/* now empty */
-#warning please remove the reference to this file
diff -Nru a/include/pcmcia/ds.h b/include/pcmcia/ds.h
--- a/include/pcmcia/ds.h	Wed Apr 30 22:28:03 2003
+++ b/include/pcmcia/ds.h	Wed Apr 30 22:28:03 2003
@@ -31,7 +31,6 @@
 #define _LINUX_DS_H
 
 #include <pcmcia/bulkmem.h>
-#include <linux/device.h>
 #include <pcmcia/cs_types.h>
 
 typedef struct tuple_parse_t {
@@ -107,6 +106,7 @@
 #define DS_BIND_MTD			_IOWR('d', 64, mtd_info_t)
 
 #ifdef __KERNEL__
+#include <linux/device.h>
 
 typedef struct dev_node_t {
     char		dev_name[DEV_NAME_LEN];
@@ -141,11 +141,6 @@
 #define DEV_OK(l) \
     ((l) && ((l->state & ~DEV_BUSY) == (DEV_CONFIG|DEV_PRESENT)))
 
-int register_pccard_driver(dev_info_t *dev_info,
-			   dev_link_t *(*attach)(void),
-			   void (*detach)(dev_link_t *));
-
-int unregister_pccard_driver(dev_info_t *dev_info);
 
 extern struct bus_type pcmcia_bus_type;
 
@@ -157,9 +152,18 @@
 	struct device_driver	drv;
 };
 
+/* driver registration */
 int pcmcia_register_driver(struct pcmcia_driver *driver);
 void pcmcia_unregister_driver(struct pcmcia_driver *driver);
 
-#endif /* __KERNEL__ */
+/* legacy driver registration interface.  don't use in new code */
+int register_pccard_driver(dev_info_t *dev_info,
+			   dev_link_t *(*attach)(void),
+			   void (*detach)(dev_link_t *));
+int unregister_pccard_driver(dev_info_t *dev_info);
+
+/* error reporting */
+void cs_error(client_handle_t handle, int func, int ret);
 
+#endif /* __KERNEL__ */
 #endif /* _LINUX_DS_H */
diff -Nru a/include/pcmcia/ss.h b/include/pcmcia/ss.h
--- a/include/pcmcia/ss.h	Wed Apr 30 22:28:17 2003
+++ b/include/pcmcia/ss.h	Wed Apr 30 22:28:17 2003
@@ -148,12 +148,13 @@
 	 * returned to driver) = sock_offset + (0, 1, .. , (nsock-1) */
 	struct pccard_operations *ops;		/* see above */
 	void *s_info;				/* socket_info_t */
+	struct class_device class_dev;		/* generic class structure */
 };
 
-extern struct device_class pcmcia_socket_class;
+extern struct class pcmcia_socket_class;
 
 /* socket drivers are expected to use these callbacks in their .drv struct */
-int pcmcia_socket_dev_suspend(struct device * dev, u32 state, u32 level);
-int pcmcia_socket_dev_resume(struct device * dev, u32 level);
+extern int pcmcia_socket_dev_suspend(struct pcmcia_socket_class_data *cls_d, u32 state, u32 level);
+extern int pcmcia_socket_dev_resume(struct pcmcia_socket_class_data *cls_d, u32 level);
 
 #endif /* _LINUX_SS_H */
diff -Nru a/include/sound/ad1848.h b/include/sound/ad1848.h
--- a/include/sound/ad1848.h	Wed Apr 30 22:28:07 2003
+++ b/include/sound/ad1848.h	Wed Apr 30 22:28:07 2003
@@ -23,6 +23,7 @@
  */
 
 #include "pcm.h"
+#include <linux/interrupt.h>
 
 /* IO ports */
 
@@ -163,7 +164,7 @@
 int snd_ad1848_pcm(ad1848_t * chip, int device, snd_pcm_t **rpcm);
 const snd_pcm_ops_t *snd_ad1848_get_pcm_ops(int direction);
 int snd_ad1848_mixer(ad1848_t * chip);
-void snd_ad1848_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+irqreturn_t snd_ad1848_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 /* exported mixer stuffs */
 enum { AD1848_MIX_SINGLE, AD1848_MIX_DOUBLE, AD1848_MIX_CAPTURE };
diff -Nru a/include/sound/cs4231.h b/include/sound/cs4231.h
--- a/include/sound/cs4231.h	Wed Apr 30 22:28:09 2003
+++ b/include/sound/cs4231.h	Wed Apr 30 22:28:09 2003
@@ -316,7 +316,7 @@
 void snd_cs4231_mce_up(cs4231_t *chip);
 void snd_cs4231_mce_down(cs4231_t *chip);
 
-void snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 const char *snd_cs4231_chip_id(cs4231_t *chip);
 
diff -Nru a/include/sound/emu10k1.h b/include/sound/emu10k1.h
--- a/include/sound/emu10k1.h	Wed Apr 30 22:28:06 2003
+++ b/include/sound/emu10k1.h	Wed Apr 30 22:28:06 2003
@@ -30,6 +30,7 @@
 #include <sound/hwdep.h>
 #include <sound/ac97_codec.h>
 #include <sound/util_mem.h>
+#include <linux/interrupt.h>
 #include <asm/io.h>
 
 #ifndef PCI_VENDOR_ID_CREATIVE
@@ -1014,7 +1015,7 @@
 int snd_emu10k1_mixer(emu10k1_t * emu);
 int snd_emu10k1_fx8010_new(emu10k1_t *emu, int device, snd_hwdep_t ** rhwdep);
 
-void snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 /* initialization */
 void snd_emu10k1_voice_init(emu10k1_t * emu, int voice);
diff -Nru a/include/sound/es1688.h b/include/sound/es1688.h
--- a/include/sound/es1688.h	Wed Apr 30 22:28:11 2003
+++ b/include/sound/es1688.h	Wed Apr 30 22:28:11 2003
@@ -24,6 +24,7 @@
 
 #include "control.h"
 #include "pcm.h"
+#include <linux/interrupt.h>
 
 #define ES1688_HW_AUTO		0x0000
 #define ES1688_HW_688		0x0001
@@ -109,7 +110,7 @@
 void snd_es1688_mixer_write(es1688_t *chip, unsigned char reg, unsigned char data);
 unsigned char snd_es1688_mixer_read(es1688_t *chip, unsigned char reg);
 
-void snd_es1688_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+irqreturn_t snd_es1688_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 int snd_es1688_create(snd_card_t * card,
 		      unsigned long port,
diff -Nru a/include/sound/gus.h b/include/sound/gus.h
--- a/include/sound/gus.h	Wed Apr 30 22:28:04 2003
+++ b/include/sound/gus.h	Wed Apr 30 22:28:04 2003
@@ -561,7 +561,7 @@
 };
 
 #if 0
-extern void snd_gf1_lfo_effect_interrupt(snd_gus_card_t * gus, snd_gf1_voice_t * voice);
+extern irqreturn_t snd_gf1_lfo_effect_interrupt(snd_gus_card_t * gus, snd_gf1_voice_t * voice);
 #endif
 extern void snd_gf1_lfo_init(snd_gus_card_t * gus);
 extern void snd_gf1_lfo_done(snd_gus_card_t * gus);
@@ -666,7 +666,7 @@
 
 /* gus_irq.c */
 
-void snd_gus_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+irqreturn_t snd_gus_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 #ifdef CONFIG_SND_DEBUG
 void snd_gus_irq_profile_init(snd_gus_card_t *gus);
 #endif
diff -Nru a/include/sound/initval.h b/include/sound/initval.h
--- a/include/sound/initval.h	Wed Apr 30 22:28:03 2003
+++ b/include/sound/initval.h	Wed Apr 30 22:28:03 2003
@@ -100,8 +100,9 @@
 #ifdef SNDRV_LEGACY_FIND_FREE_IRQ
 #include <linux/interrupt.h>
 
-static void snd_legacy_empty_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_legacy_empty_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
 {
+	return IRQ_HANDLED;
 }
 
 static int snd_legacy_find_free_irq(int *irq_table)
diff -Nru a/include/sound/mpu401.h b/include/sound/mpu401.h
--- a/include/sound/mpu401.h	Wed Apr 30 22:28:16 2003
+++ b/include/sound/mpu401.h	Wed Apr 30 22:28:16 2003
@@ -22,7 +22,9 @@
  *
  */
 
+#include <linux/interrupt.h>
 #include "rawmidi.h"
+#include <linux/interrupt.h>
 
 #define MPU401_HW_MPU401		1	/* native MPU401 */
 #define MPU401_HW_SB			2	/* SoundBlaster MPU-401 UART */
@@ -102,7 +104,7 @@
 
  */
 
-void snd_mpu401_uart_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+irqreturn_t snd_mpu401_uart_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 int snd_mpu401_uart_new(snd_card_t * card,
 			int device,
diff -Nru a/include/sound/sb.h b/include/sound/sb.h
--- a/include/sound/sb.h	Wed Apr 30 22:28:08 2003
+++ b/include/sound/sb.h	Wed Apr 30 22:28:08 2003
@@ -24,6 +24,7 @@
 
 #include "pcm.h"
 #include "rawmidi.h"
+#include <linux/interrupt.h>
 #include <asm/io.h>
 
 enum sb_hw_type {
@@ -99,7 +100,7 @@
 	snd_rawmidi_t *rmidi;
 	snd_rawmidi_substream_t *midi_substream_input;
 	snd_rawmidi_substream_t *midi_substream_output;
-	void (*rmidi_callback)(int irq, void *dev_id, struct pt_regs *regs);
+	irqreturn_t (*rmidi_callback)(int irq, void *dev_id, struct pt_regs *regs);
 
 	spinlock_t reg_lock;
 	spinlock_t open_lock;
@@ -282,7 +283,7 @@
 int snd_sbdsp_create(snd_card_t *card,
 		     unsigned long port,
 		     int irq,
-		     void (*irq_handler)(int, void *, struct pt_regs *),
+		     irqreturn_t (*irq_handler)(int, void *, struct pt_regs *),
 		     int dma8, int dma16,
 		     unsigned short hardware,
 		     sb_t **r_chip);
@@ -308,7 +309,7 @@
 const snd_pcm_ops_t *snd_sb16dsp_get_pcm_ops(int direction);
 int snd_sb16dsp_configure(sb_t *chip);
 /* sb16.c */
-void snd_sb16dsp_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+irqreturn_t snd_sb16dsp_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 int snd_sb16_playback_open(snd_pcm_substream_t *substream);
 int snd_sb16_capture_open(snd_pcm_substream_t *substream);
 int snd_sb16_playback_close(snd_pcm_substream_t *substream);
diff -Nru a/include/video/pm3fb.h b/include/video/pm3fb.h
--- a/include/video/pm3fb.h	Wed Apr 30 22:28:16 2003
+++ b/include/video/pm3fb.h	Wed Apr 30 22:28:16 2003
@@ -1147,11 +1147,6 @@
 #define MUST_BYTESWAP
 #endif
 
-/* for compatibility between 2.5, 2.4 and 2.2 */
-#ifndef B_FREE
-#define B_FREE   -1
-#endif
-
 /* permedia3 -specific definitions */
 #define PM3_SCALE_TO_CLOCK(pr, fe, po) ((2 * PM3_REF_CLOCK * fe) / (pr * (1 << (po))))
 
diff -Nru a/init/Kconfig b/init/Kconfig
--- a/init/Kconfig	Wed Apr 30 22:28:15 2003
+++ b/init/Kconfig	Wed Apr 30 22:28:15 2003
@@ -56,12 +56,12 @@
 	  and some programs won't run unless you say Y here. In particular, if
 	  you want to run the DOS emulator dosemu under Linux (read the
 	  DOSEMU-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>), you'll need to say Y
+	  <http://www.tldp.org/docs.html#howto>), you'll need to say Y
 	  here.
 
 	  You can find documentation about IPC with "info ipc" and also in
 	  section 6.4 of the Linux Programmer's Guide, available from
-	  <http://www.linuxdoc.org/docs.html#guide>.
+	  <http://www.tldp.org/docs.html#guide>.
 
 config BSD_PROCESS_ACCT
 	bool "BSD Process Accounting"
diff -Nru a/init/Makefile b/init/Makefile
--- a/init/Makefile	Wed Apr 30 22:28:08 2003
+++ b/init/Makefile	Wed Apr 30 22:28:08 2003
@@ -6,6 +6,7 @@
 mounts-y			:= do_mounts.o
 mounts-$(CONFIG_DEVFS_FS)	+= do_mounts_devfs.o
 mounts-$(CONFIG_BLK_DEV_RAM)	+= do_mounts_rd.o
+mounts-$(CONFIG_BLK_DEV_INITRD)	+= do_mounts_initrd.o
 mounts-$(CONFIG_BLK_DEV_MD)	+= do_mounts_md.o
 
 # files to be removed upon make clean
diff -Nru a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/init/do_mounts_initrd.c	Wed Apr 30 22:28:20 2003
@@ -0,0 +1,115 @@
+
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/minix_fs.h>
+#include <linux/ext2_fs.h>
+#include <linux/romfs_fs.h>
+#include <linux/initrd.h>
+
+#include "do_mounts.h"
+
+unsigned int real_root_dev;	/* do_proc_dointvec cannot handle kdev_t */
+static int __initdata old_fd, root_fd;
+static int __initdata mount_initrd = 1;
+
+static int __init no_initrd(char *str)
+{
+	mount_initrd = 0;
+	return 1;
+}
+
+__setup("noinitrd", no_initrd);
+
+static int __init do_linuxrc(void * shell)
+{
+	static char *argv[] = { "linuxrc", NULL, };
+	extern char * envp_init[];
+
+	close(old_fd);close(root_fd);
+	close(0);close(1);close(2);
+	setsid();
+	(void) open("/dev/console",O_RDWR,0);
+	(void) dup(0);
+	(void) dup(0);
+	return execve(shell, argv, envp_init);
+}
+
+static void __init handle_initrd(void)
+{
+	int error;
+	int i, pid;
+
+	real_root_dev = ROOT_DEV;
+	create_dev("/dev/root.old", Root_RAM0, NULL);
+	/* mount initrd on rootfs' /root */
+	mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
+	sys_mkdir("/old", 0700);
+	root_fd = open("/", 0, 0);
+	old_fd = open("/old", 0, 0);
+	/* move initrd over / and chdir/chroot in initrd root */
+	sys_chdir("/root");
+	sys_mount(".", "/", NULL, MS_MOVE, NULL);
+	sys_chroot(".");
+	mount_devfs_fs ();
+
+	pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
+	if (pid > 0) {
+		while (pid != waitpid(-1, &i, 0))
+			yield();
+	}
+
+	/* move initrd to rootfs' /old */
+	sys_fchdir(old_fd);
+	sys_mount("/", ".", NULL, MS_MOVE, NULL);
+	/* switch root and cwd back to / of rootfs */
+	sys_fchdir(root_fd);
+	sys_chroot(".");
+	close(old_fd);
+	close(root_fd);
+	umount_devfs("/old/dev");
+
+	if (real_root_dev == Root_RAM0) {
+		sys_chdir("/old");
+		return;
+	}
+
+	ROOT_DEV = real_root_dev;
+	mount_root();
+
+	printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
+	error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
+	if (!error)
+		printk("okay\n");
+	else {
+		int fd = open("/dev/root.old", O_RDWR, 0);
+		printk("failed\n");
+		printk(KERN_NOTICE "Unmounting old root\n");
+		sys_umount("/old", MNT_DETACH);
+		printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
+		if (fd < 0) {
+			error = fd;
+		} else {
+			error = sys_ioctl(fd, BLKFLSBUF, 0);
+			close(fd);
+		}
+		printk(!error ? "okay\n" : "failed\n");
+	}
+}
+
+int __init initrd_load(void)
+{
+	if (!mount_initrd)
+		return 0;
+
+	create_dev("/dev/ram", MKDEV(RAMDISK_MAJOR, 0), NULL);
+	create_dev("/dev/initrd", MKDEV(RAMDISK_MAJOR, INITRD_MINOR), NULL);
+	/* Load the initrd data into /dev/ram0. Execute it as initrd unless
+	 * /dev/ram0 is supposed to be our actual root device, in
+	 * that case the ram disk is just set up here, and gets
+	 * mounted in the normal path. */
+	if (rd_load_image("/dev/initrd") && ROOT_DEV != Root_RAM0) {
+		handle_initrd();
+		return 1;
+	}
+	return 0;
+}
diff -Nru a/init/do_mounts_rd.c b/init/do_mounts_rd.c
--- a/init/do_mounts_rd.c	Wed Apr 30 22:28:13 2003
+++ b/init/do_mounts_rd.c	Wed Apr 30 22:28:13 2003
@@ -4,6 +4,7 @@
 #include <linux/minix_fs.h>
 #include <linux/ext2_fs.h>
 #include <linux/romfs_fs.h>
+#include <linux/initrd.h>
 
 #include "do_mounts.h"
 
@@ -246,115 +247,6 @@
 	create_dev("/dev/ram", MKDEV(RAMDISK_MAJOR, n), NULL);
 	return rd_load_image("/dev/root");
 }
-
-#ifdef CONFIG_BLK_DEV_INITRD
-
-unsigned int real_root_dev;	/* do_proc_dointvec cannot handle kdev_t */
-static int __initdata old_fd, root_fd;
-static int __initdata mount_initrd = 1;
-
-static int __init no_initrd(char *str)
-{
-	mount_initrd = 0;
-	return 1;
-}
-
-__setup("noinitrd", no_initrd);
-
-static int __init do_linuxrc(void * shell)
-{
-	static char *argv[] = { "linuxrc", NULL, };
-	extern char * envp_init[];
-
-	close(old_fd);close(root_fd);
-	close(0);close(1);close(2);
-	setsid();
-	(void) open("/dev/console",O_RDWR,0);
-	(void) dup(0);
-	(void) dup(0);
-	return execve(shell, argv, envp_init);
-}
-
-static void __init handle_initrd(void)
-{
-	int error;
-	int i, pid;
-
-	real_root_dev = ROOT_DEV;
-	create_dev("/dev/root.old", Root_RAM0, NULL);
-	/* mount initrd on rootfs' /root */
-	mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
-	sys_mkdir("/old", 0700);
-	root_fd = open("/", 0, 0);
-	old_fd = open("/old", 0, 0);
-	/* move initrd over / and chdir/chroot in initrd root */
-	sys_chdir("/root");
-	sys_mount(".", "/", NULL, MS_MOVE, NULL);
-	sys_chroot(".");
-	mount_devfs_fs ();
-
-	pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
-	if (pid > 0) {
-		while (pid != waitpid(-1, &i, 0))
-			yield();
-	}
-
-	/* move initrd to rootfs' /old */
-	sys_fchdir(old_fd);
-	sys_mount("/", ".", NULL, MS_MOVE, NULL);
-	/* switch root and cwd back to / of rootfs */
-	sys_fchdir(root_fd);
-	sys_chroot(".");
-	close(old_fd);
-	close(root_fd);
-	umount_devfs("/old/dev");
-
-	if (real_root_dev == Root_RAM0) {
-		sys_chdir("/old");
-		return;
-	}
-
-	ROOT_DEV = real_root_dev;
-	mount_root();
-
-	printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
-	error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
-	if (!error)
-		printk("okay\n");
-	else {
-		int fd = open("/dev/root.old", O_RDWR, 0);
-		printk("failed\n");
-		printk(KERN_NOTICE "Unmounting old root\n");
-		sys_umount("/old", MNT_DETACH);
-		printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
-		if (fd < 0) {
-			error = fd;
-		} else {
-			error = sys_ioctl(fd, BLKFLSBUF, 0);
-			close(fd);
-		}
-		printk(!error ? "okay\n" : "failed\n");
-	}
-}
-
-int __init initrd_load(void)
-{
-	if (!mount_initrd)
-		return 0;
-
-	create_dev("/dev/ram", MKDEV(RAMDISK_MAJOR, 0), NULL);
-	create_dev("/dev/initrd", MKDEV(RAMDISK_MAJOR, INITRD_MINOR), NULL);
-	/* Load the initrd data into /dev/ram0. Execute it as initrd unless
-	 * /dev/ram0 is supposed to be our actual root device, in
-	 * that case the ram disk is just set up here, and gets
-	 * mounted in the normal path. */
-	if (rd_load_image("/dev/initrd") && ROOT_DEV != Root_RAM0) {
-		handle_initrd();
-		return 1;
-	}
-	return 0;
-}
-#endif
 
 #ifdef BUILD_CRAMDISK
 
diff -Nru a/init/main.c b/init/main.c
--- a/init/main.c	Wed Apr 30 22:28:05 2003
+++ b/init/main.c	Wed Apr 30 22:28:05 2003
@@ -24,6 +24,7 @@
 #include <linux/init.h>
 #include <linux/smp_lock.h>
 #include <linux/blk.h>
+#include <linux/initrd.h>
 #include <linux/hdreg.h>
 #include <linux/bootmem.h>
 #include <linux/tty.h>
diff -Nru a/ipc/shm.c b/ipc/shm.c
--- a/ipc/shm.c	Wed Apr 30 22:28:09 2003
+++ b/ipc/shm.c	Wed Apr 30 22:28:09 2003
@@ -361,27 +361,35 @@
 	}
 }
 
-static void shm_get_stat (unsigned long *rss, unsigned long *swp) 
+static void shm_get_stat(unsigned long *rss, unsigned long *swp) 
 {
-	struct shmem_inode_info *info;
 	int i;
 
 	*rss = 0;
 	*swp = 0;
 
-	for(i = 0; i <= shm_ids.max_id; i++) {
-		struct shmid_kernel* shp;
-		struct inode * inode;
+	for (i = 0; i <= shm_ids.max_id; i++) {
+		struct shmid_kernel *shp;
+		struct inode *inode;
 
 		shp = shm_get(i);
-		if(shp == NULL)
+		if(!shp)
 			continue;
+
 		inode = shp->shm_file->f_dentry->d_inode;
-		info = SHMEM_I(inode);
-		spin_lock (&info->lock);
-		*rss += inode->i_mapping->nrpages;
-		*swp += info->swapped;
-		spin_unlock (&info->lock);
+
+		if (is_file_hugepages(shp->shm_file)) {
+			struct address_space *mapping = inode->i_mapping;
+			spin_lock(&mapping->page_lock);
+			*rss += (HPAGE_SIZE/PAGE_SIZE)*mapping->nrpages;
+			spin_unlock(&mapping->page_lock);
+		} else {
+			struct shmem_inode_info *info = SHMEM_I(inode);
+			spin_lock(&info->lock);
+			*rss += inode->i_mapping->nrpages;
+			*swp += info->swapped;
+			spin_unlock(&info->lock);
+		}
 	}
 }
 
@@ -737,21 +745,66 @@
  * detach and kill segment if marked destroyed.
  * The work is done in shm_close.
  */
-asmlinkage long sys_shmdt (char *shmaddr)
+asmlinkage long sys_shmdt(char *shmaddr)
 {
 	struct mm_struct *mm = current->mm;
-	struct vm_area_struct *shmd, *shmdnext;
+	struct vm_area_struct *vma, *next;
+	unsigned long addr = (unsigned long)shmaddr;
+	loff_t size = 0;
 	int retval = -EINVAL;
 
 	down_write(&mm->mmap_sem);
-	for (shmd = mm->mmap; shmd; shmd = shmdnext) {
-		shmdnext = shmd->vm_next;
-		if ((shmd->vm_ops == &shm_vm_ops || (shmd->vm_flags & VM_HUGETLB))
-		    && shmd->vm_start - (shmd->vm_pgoff << PAGE_SHIFT) == (ulong) shmaddr) {
-			do_munmap(mm, shmd->vm_start, shmd->vm_end - shmd->vm_start);
+
+	/*
+	 * If it had been mremap()'d, the starting address would not
+	 * match the usual checks anyway. So assume all vma's are
+	 * above the starting address given.
+	 */
+	vma = find_vma(mm, addr);
+
+	while (vma) {
+		next = vma->vm_next;
+
+		/*
+		 * Check if the starting address would match, i.e. it's
+		 * a fragment created by mprotect() and/or munmap(), or it
+		 * otherwise it starts at this address with no hassles.
+		 */
+		if ((vma->vm_ops == &shm_vm_ops || is_vm_hugetlb_page(vma)) &&
+			(vma->vm_start - addr)/PAGE_SIZE == vma->vm_pgoff) {
+
+
+			size = vma->vm_file->f_dentry->d_inode->i_size;
+			do_munmap(mm, vma->vm_start, vma->vm_end - vma->vm_start);
+			/*
+			 * We discovered the size of the shm segment, so
+			 * break out of here and fall through to the next
+			 * loop that uses the size information to stop
+			 * searching for matching vma's.
+			 */
 			retval = 0;
+			vma = next;
+			break;
 		}
+		vma = next;
+	}
+
+	/*
+	 * We need look no further than the maximum address a fragment
+	 * could possibly have landed at. Also cast things to loff_t to
+	 * prevent overflows and make comparisions vs. equal-width types.
+	 */
+	while (vma && (loff_t)(vma->vm_end - addr) <= size) {
+		next = vma->vm_next;
+
+		/* finding a matching vma now does not alter retval */
+		if ((vma->vm_ops == &shm_vm_ops || is_vm_hugetlb_page(vma)) &&
+			(vma->vm_start - addr)/PAGE_SIZE == vma->vm_pgoff)
+
+			do_munmap(mm, vma->vm_start, vma->vm_end - vma->vm_start);
+		vma = next;
 	}
+
 	up_write(&mm->mmap_sem);
 	return retval;
 }
diff -Nru a/kernel/acct.c b/kernel/acct.c
--- a/kernel/acct.c	Wed Apr 30 22:28:10 2003
+++ b/kernel/acct.c	Wed Apr 30 22:28:10 2003
@@ -335,7 +335,7 @@
 	ac.ac_stime = encode_comp_t(current->stime);
 	ac.ac_uid = current->uid;
 	ac.ac_gid = current->gid;
-	ac.ac_tty = (current->tty) ? kdev_t_to_nr(current->tty->device) : 0;
+	ac.ac_tty = current->tty ? current->tty->device : 0;
 
 	ac.ac_flag = 0;
 	if (current->flags & PF_FORKNOEXEC)
diff -Nru a/kernel/cpufreq.c b/kernel/cpufreq.c
--- a/kernel/cpufreq.c	Wed Apr 30 22:28:05 2003
+++ b/kernel/cpufreq.c	Wed Apr 30 22:28:05 2003
@@ -49,23 +49,17 @@
 static LIST_HEAD(cpufreq_governor_list);
 static DECLARE_MUTEX		(cpufreq_governor_sem);
 
-static struct device_interface cpufreq_interface;
+static struct class_interface cpufreq_interface;
 
 static int cpufreq_cpu_get(unsigned int cpu) {
 	if (cpu >= NR_CPUS)
 		return 0;
 
-	if (!kset_get(&cpufreq_interface.kset))
-		return 0;
-
-	if (!try_module_get(cpufreq_driver->owner)) {
-		kset_put(&cpufreq_interface.kset);
+	if (!try_module_get(cpufreq_driver->owner))
 		return 0;
-	}
 
 	if (!kobject_get(&cpufreq_driver->policy[cpu].kobj)) {
 		module_put(cpufreq_driver->owner);
-		kset_put(&cpufreq_interface.kset);
 		return 0;
 	}
 
@@ -75,7 +69,6 @@
 static void cpufreq_cpu_put(unsigned int cpu) {
 	kobject_put(&cpufreq_driver->policy[cpu].kobj);
 	module_put(cpufreq_driver->owner);
-	kset_put(&cpufreq_interface.kset);
 }
 
 /*********************************************************************
@@ -115,24 +108,20 @@
 
 
 /* forward declarations */
-static int cpufreq_add_dev (struct device * dev);
-static int cpufreq_remove_dev (struct device * dev);
+static int cpufreq_add_dev (struct class_device * dev);
+static void cpufreq_remove_dev (struct class_device * dev);
 
 /* drivers/base/cpu.c */
 extern struct device_class cpu_devclass;
 
-static struct device_interface cpufreq_interface = {
-        .name = "cpufreq",
-        .devclass = &cpu_devclass,
-        .add_device = &cpufreq_add_dev,
-        .remove_device = &cpufreq_remove_dev,
-	.kset = { .subsys = &cpu_devclass.subsys, },
-        .devnum = 0,
+static struct class_interface cpufreq_interface = {
+        .add =		&cpufreq_add_dev,
+        .remove =	&cpufreq_remove_dev,
 };
 
-static inline int to_cpu_nr (struct device *dev)
+static inline int to_cpu_nr (struct class_device *dev)
 {
-	struct sys_device * cpu_sys_dev = container_of(dev, struct sys_device, dev);
+	struct sys_device * cpu_sys_dev = container_of(dev->dev, struct sys_device, dev);
 	return (cpu_sys_dev->id);
 }
 
@@ -334,21 +323,16 @@
  *
  * Adds the cpufreq interface for a CPU device. 
  */
-static int cpufreq_add_dev (struct device * dev)
+static int cpufreq_add_dev (struct class_device * class_dev)
 {
-	unsigned int cpu = to_cpu_nr(dev);
+	unsigned int cpu = to_cpu_nr(class_dev);
 	int ret = 0;
 	struct cpufreq_policy new_policy;
 	struct cpufreq_policy *policy;
 	struct freq_attr **drv_attr;
 
-	if (!kset_get(&cpufreq_interface.kset))
-		return -EINVAL;
-
-	if (!try_module_get(cpufreq_driver->owner)) {
-		kset_put(&cpufreq_interface.kset);
+	if (!try_module_get(cpufreq_driver->owner))
 		return -EINVAL;
-	}
 
 	/* call driver. From then on the cpufreq must be able
 	 * to accept all calls to ->verify and ->setpolicy for this CPU
@@ -366,15 +350,15 @@
 	memcpy(&new_policy, 
 	       policy, 
 	       sizeof(struct cpufreq_policy));
+	class_set_devdata(class_dev, policy);
 	up(&cpufreq_driver_sem);
 
 	init_MUTEX(&policy->lock);
 	/* prepare interface data */
-	policy->kobj.parent = &dev->kobj;
+	policy->kobj.parent = &class_dev->kobj;
 	policy->kobj.ktype = &ktype_cpufreq;
-	policy->dev = dev;
-	strncpy(policy->kobj.name, 
-		cpufreq_interface.name, KOBJ_NAME_LEN);
+//	policy->dev = dev->dev;
+	strncpy(policy->kobj.name, "cpufreq", KOBJ_NAME_LEN);
 
 	ret = kobject_register(&policy->kobj);
 	if (ret)
@@ -385,7 +369,9 @@
 		sysfs_create_file(&policy->kobj, &((*drv_attr)->attr));
 		drv_attr++;
 	}
+	/* set up files for this cpu device */
 
+	
 	/* set default policy */
 	ret = cpufreq_set_policy(&new_policy);
 	if (ret)
@@ -393,7 +379,6 @@
 
  out:
 	module_put(cpufreq_driver->owner);
-	kset_put(&cpufreq_interface.kset);
 	return ret;
 }
 
@@ -403,17 +388,12 @@
  *
  * Removes the cpufreq interface for a CPU device.
  */
-static int cpufreq_remove_dev (struct device * dev)
+static void cpufreq_remove_dev (struct class_device * class_dev)
 {
-	unsigned int cpu = to_cpu_nr(dev);
-
-	if (!kset_get(&cpufreq_interface.kset))
-		return -EINVAL;
+	unsigned int cpu = to_cpu_nr(class_dev);
 
-	if (!kobject_get(&cpufreq_driver->policy[cpu].kobj)) {
-		kset_put(&cpufreq_interface.kset);
-		return -EINVAL;
-	}
+	if (!kobject_get(&cpufreq_driver->policy[cpu].kobj))
+		return;
 
 	down(&cpufreq_driver_sem);
 	if ((cpufreq_driver->target) && 
@@ -433,8 +413,7 @@
 
 	up(&cpufreq_driver_sem);
 	kobject_put(&cpufreq_driver->policy[cpu].kobj);
-	kset_put(&cpufreq_interface.kset);
-	return 0;
+	return;
 }
 
 
@@ -840,12 +819,6 @@
 	    ((!driver_data->setpolicy) && (!driver_data->target)))
 		return -EINVAL;
 
-
-	if (kset_get(&cpufreq_interface.kset)) {
-		kset_put(&cpufreq_interface.kset);
-		return -EBUSY;
-	}
-
 	down(&cpufreq_driver_sem);
 	if (cpufreq_driver) {
 		up(&cpufreq_driver_sem);		
@@ -862,7 +835,7 @@
 
 	memset(cpufreq_driver->policy, 0, NR_CPUS * sizeof(struct cpufreq_policy));
 
-	return interface_register(&cpufreq_interface);
+	return class_interface_register(&cpufreq_interface);
 }
 EXPORT_SYMBOL_GPL(cpufreq_register_driver);
 
@@ -877,16 +850,10 @@
  */
 int cpufreq_unregister_driver(struct cpufreq_driver *driver)
 {
-	if (!kset_get(&cpufreq_interface.kset))
-		return 0;
-
-	if (!cpufreq_driver || (driver != cpufreq_driver)) {
-		kset_put(&cpufreq_interface.kset);
+	if (!cpufreq_driver || (driver != cpufreq_driver))
 		return -EINVAL;
-	}
 
-	kset_put(&cpufreq_interface.kset);
-	interface_unregister(&cpufreq_interface);
+	class_interface_unregister(&cpufreq_interface);
 
 	down(&cpufreq_driver_sem);
 	kfree(cpufreq_driver->policy);
@@ -914,9 +881,6 @@
 	if (in_interrupt())
 		panic("cpufreq_restore() called from interrupt context!");
 
-	if (!kset_get(&cpufreq_interface.kset))
-		return 0;
-
 	if (!try_module_get(cpufreq_driver->owner))
 		goto error_out;
 
@@ -934,8 +898,6 @@
 
 	module_put(cpufreq_driver->owner);
  error_out:
-	kset_put(&cpufreq_interface.kset);
-
 	return ret;
 }
 EXPORT_SYMBOL_GPL(cpufreq_restore);
diff -Nru a/kernel/fork.c b/kernel/fork.c
--- a/kernel/fork.c	Wed Apr 30 22:28:04 2003
+++ b/kernel/fork.c	Wed Apr 30 22:28:04 2003
@@ -43,7 +43,9 @@
 extern int copy_semundo(unsigned long clone_flags, struct task_struct *tsk);
 extern void exit_semundo(struct task_struct *tsk);
 
-/* The idle threads do not count.. */
+/* The idle threads do not count..
+ * Protected by write_lock_irq(&tasklist_lock)
+ */
 int nr_threads;
 
 int max_threads;
@@ -792,9 +794,9 @@
 	atomic_inc(&p->user->processes);
 
 	/*
-	 * Counter increases are protected by
-	 * the kernel lock so nr_threads can't
-	 * increase under us (but it may decrease).
+	 * If multiple threads are within copy_process(), then this check
+	 * triggers too late. This doesn't hurt, the check is only there
+	 * to stop root fork bombs.
 	 */
 	if (nr_threads >= max_threads)
 		goto bad_fork_cleanup_count;
diff -Nru a/kernel/ksyms.c b/kernel/ksyms.c
--- a/kernel/ksyms.c	Wed Apr 30 22:28:03 2003
+++ b/kernel/ksyms.c	Wed Apr 30 22:28:03 2003
@@ -186,11 +186,9 @@
 EXPORT_SYMBOL(put_filp);
 EXPORT_SYMBOL(files_lock);
 EXPORT_SYMBOL(check_disk_change);
-EXPORT_SYMBOL(__check_disk_change);
-EXPORT_SYMBOL(__invalidate_buffers);
 EXPORT_SYMBOL(invalidate_bdev);
 EXPORT_SYMBOL(invalidate_inodes);
-EXPORT_SYMBOL(invalidate_device);
+EXPORT_SYMBOL(__invalidate_device);
 EXPORT_SYMBOL(invalidate_inode_pages);
 EXPORT_SYMBOL_GPL(invalidate_inode_pages2);
 EXPORT_SYMBOL(truncate_inode_pages);
@@ -210,6 +208,7 @@
 EXPORT_SYMBOL(bd_release);
 EXPORT_SYMBOL(open_bdev_excl);
 EXPORT_SYMBOL(close_bdev_excl);
+EXPORT_SYMBOL(open_by_devnum);
 EXPORT_SYMBOL(__brelse);
 EXPORT_SYMBOL(__bforget);
 EXPORT_SYMBOL(ll_rw_block);
@@ -314,6 +313,9 @@
 EXPORT_SYMBOL(simple_prepare_write);
 EXPORT_SYMBOL(simple_commit_write);
 EXPORT_SYMBOL(simple_empty);
+EXPORT_SYMBOL(simple_fill_super);
+EXPORT_SYMBOL(simple_pin_fs);
+EXPORT_SYMBOL(simple_release_fs);
 EXPORT_SYMBOL(fd_install);
 EXPORT_SYMBOL(put_unused_fd);
 EXPORT_SYMBOL(get_sb_bdev);
@@ -513,6 +515,7 @@
 EXPORT_SYMBOL(vsnprintf);
 EXPORT_SYMBOL(vsscanf);
 EXPORT_SYMBOL(__bdevname);
+EXPORT_SYMBOL(bdevname);
 EXPORT_SYMBOL(cdevname);
 EXPORT_SYMBOL(simple_strtoull);
 EXPORT_SYMBOL(simple_strtoul);
diff -Nru a/kernel/module.c b/kernel/module.c
--- a/kernel/module.c	Wed Apr 30 22:28:13 2003
+++ b/kernel/module.c	Wed Apr 30 22:28:13 2003
@@ -431,7 +431,7 @@
 }
 #endif
 
-static unsigned int module_refcount(struct module *mod)
+unsigned int module_refcount(struct module *mod)
 {
 	unsigned int i, total = 0;
 
@@ -439,6 +439,7 @@
 		total += atomic_read(&mod->ref[i].count);
 	return total;
 }
+EXPORT_SYMBOL(module_refcount);
 
 /* This exists whether we can unload or not */
 static void free_module(struct module *mod);
@@ -939,12 +940,12 @@
 /* Change all symbols so that sh_value encodes the pointer directly. */
 static int simplify_symbols(Elf_Shdr *sechdrs,
 			    unsigned int symindex,
-			    unsigned int strindex,
+			    const char *strtab,
 			    unsigned int versindex,
 			    struct module *mod)
 {
 	Elf_Sym *sym = (void *)sechdrs[symindex].sh_addr;
-	const char *strtab = (char *)sechdrs[strindex].sh_addr;
+	
 	unsigned int i, n = sechdrs[symindex].sh_size / sizeof(Elf_Sym);
 	int ret = 0;
 
@@ -1063,13 +1064,9 @@
 		|| strcmp(license, "Dual MPL/GPL") == 0);
 }
 
-static void set_license(struct module *mod, Elf_Shdr *sechdrs, int licenseidx)
+static void set_license(struct module *mod, const char *license)
 {
-	char *license;
-
-	if (licenseidx) 
-		license = (char *)sechdrs[licenseidx].sh_addr;
-	else
+	if (!license)
 		license = "unspecified";
 
 	mod->license_gplok = license_is_gpl_compatible(license);
@@ -1080,6 +1077,40 @@
 	}
 }
 
+/* Parse tag=value strings from .modinfo section */
+static char *next_string(char *string, unsigned long *secsize)
+{
+	/* Skip non-zero chars */
+	while (string[0]) {
+		string++;
+		if ((*secsize)-- <= 1)
+			return NULL;
+	}
+
+	/* Skip any zero padding. */
+	while (!string[0]) {
+		string++;
+		if ((*secsize)-- <= 1)
+			return NULL;
+	}
+	return string;
+}
+
+static char *get_modinfo(Elf_Shdr *sechdrs,
+			 unsigned int info,
+			 const char *tag)
+{
+	char *p;
+	unsigned int taglen = strlen(tag);
+	unsigned long size = sechdrs[info].sh_size;
+
+	for (p = (char *)sechdrs[info].sh_addr; p; p = next_string(p, &size)) {
+		if (strncmp(p, tag, taglen) == 0 && p[taglen] == '=')
+			return p + taglen + 1;
+	}
+	return NULL;
+}
+
 /* Allocate and load the module: note that size of section 0 is always
    zero, and we rely on this for optional sections. */
 static struct module *load_module(void __user *umod,
@@ -1088,9 +1119,9 @@
 {
 	Elf_Ehdr *hdr;
 	Elf_Shdr *sechdrs;
-	char *secstrings, *args;
-	unsigned int i, symindex, exportindex, strindex, setupindex, exindex,
-		modindex, obsparmindex, licenseindex, gplindex, vmagindex,
+	char *secstrings, *args, *modmagic, *strtab = NULL;
+	unsigned int i, symindex = 0, strindex = 0, setupindex, exindex,
+		exportindex, modindex, obsparmindex, infoindex, gplindex,
 		crcindex, gplcrcindex, versindex;
 	long arglen;
 	struct module *mod;
@@ -1124,6 +1155,7 @@
 	/* Convenience variables */
 	sechdrs = (void *)hdr + hdr->e_shoff;
 	secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
+	sechdrs[0].sh_addr = 0;
 
 	/* And these should exist, but gcc whinges if we don't init them */
 	symindex = strindex = 0;
@@ -1137,6 +1169,7 @@
 		if (sechdrs[i].sh_type == SHT_SYMTAB) {
 			symindex = i;
 			strindex = sechdrs[i].sh_link;
+			strtab = (char *)hdr + sechdrs[strindex].sh_offset;
 		}
 #ifndef CONFIG_MODULE_UNLOAD
 		/* Don't load .exit sections */
@@ -1145,12 +1178,6 @@
 #endif
 	}
 
-#ifdef CONFIG_KALLSYMS
-	/* Keep symbol and string tables for decoding later. */
-	sechdrs[symindex].sh_flags |= SHF_ALLOC;
-	sechdrs[strindex].sh_flags |= SHF_ALLOC;
-#endif
-
 	modindex = find_sec(hdr, sechdrs, secstrings,
 			    ".gnu.linkonce.this_module");
 	if (!modindex) {
@@ -1168,9 +1195,16 @@
 	setupindex = find_sec(hdr, sechdrs, secstrings, "__param");
 	exindex = find_sec(hdr, sechdrs, secstrings, "__ex_table");
 	obsparmindex = find_sec(hdr, sechdrs, secstrings, "__obsparm");
-	licenseindex = find_sec(hdr, sechdrs, secstrings, ".init.license");
-	vmagindex = find_sec(hdr, sechdrs, secstrings, "__vermagic");
 	versindex = find_sec(hdr, sechdrs, secstrings, "__versions");
+	infoindex = find_sec(hdr, sechdrs, secstrings, ".modinfo");
+
+	/* Don't keep modinfo section */
+	sechdrs[infoindex].sh_flags &= ~(unsigned long)SHF_ALLOC;
+#ifdef CONFIG_KALLSYMS
+	/* Keep symbol and string tables for decoding later. */
+	sechdrs[symindex].sh_flags |= SHF_ALLOC;
+	sechdrs[strindex].sh_flags |= SHF_ALLOC;
+#endif
 
 	/* Check module struct version now, before we try to use module. */
 	if (!check_modstruct_version(sechdrs, versindex, mod)) {
@@ -1178,14 +1212,15 @@
 		goto free_hdr;
 	}
 
+	modmagic = get_modinfo(sechdrs, infoindex, "vermagic");
 	/* This is allowed: modprobe --force will invalidate it. */
-	if (!vmagindex) {
+	if (!modmagic) {
 		tainted |= TAINT_FORCED_MODULE;
 		printk(KERN_WARNING "%s: no version magic, tainting kernel.\n",
 		       mod->name);
-	} else if (!same_magic((char *)sechdrs[vmagindex].sh_addr, vermagic)) {
+	} else if (!same_magic(modmagic, vermagic)) {
 		printk(KERN_ERR "%s: version magic '%s' should be '%s'\n",
-		       mod->name, (char*)sechdrs[vmagindex].sh_addr, vermagic);
+		       mod->name, modmagic, vermagic);
 		err = -ENOEXEC;
 		goto free_hdr;
 	}
@@ -1265,11 +1300,11 @@
 	/* Now we've moved module, initialize linked lists, etc. */
 	module_unload_init(mod);
 
-	/* Set up license info based on contents of section */
-	set_license(mod, sechdrs, licenseindex);
+	/* Set up license info based on the info section */
+	set_license(mod, get_modinfo(sechdrs, infoindex, "license"));
 
 	/* Fix up syms, so that st_value is a pointer to location. */
-	err = simplify_symbols(sechdrs, symindex, strindex, versindex, mod);
+	err = simplify_symbols(sechdrs, symindex, strtab, versindex, mod);
 	if (err < 0)
 		goto cleanup;
 
@@ -1300,8 +1335,7 @@
 	for (i = 1; i < hdr->e_shnum; i++) {
 		const char *strtab = (char *)sechdrs[strindex].sh_addr;
 		if (sechdrs[i].sh_type == SHT_REL)
-			err = apply_relocate(sechdrs, strtab, symindex, i,
-					     mod);
+			err = apply_relocate(sechdrs, strtab, symindex, i,mod);
 		else if (sechdrs[i].sh_type == SHT_RELA)
 			err = apply_relocate_add(sechdrs, strtab, symindex, i,
 						 mod);
diff -Nru a/kernel/posix-timers.c b/kernel/posix-timers.c
--- a/kernel/posix-timers.c	Wed Apr 30 22:28:09 2003
+++ b/kernel/posix-timers.c	Wed Apr 30 22:28:09 2003
@@ -33,7 +33,12 @@
 		       result; })
 
 #endif
+#define CLOCK_REALTIME_RES TICK_NSEC(TICK_USEC)  // In nano seconds.
 
+static inline u64  mpy_l_X_l_ll(unsigned long mpy1,unsigned long mpy2)
+{
+	return (u64)mpy1 * mpy2;
+}
 /*
  * Management arrays for POSIX timers.	 Timers are kept in slab memory
  * Timer ids are allocated by an external routine that keeps track of the
@@ -48,7 +53,7 @@
  * The idr_get_new *may* call slab for more memory so it must not be
  * called under a spin lock.  Likewise idr_remore may release memory
  * (but it may be ok to do this under a lock...).
- * idr_find is just a memory look up and is quite fast.  A zero return
+ * idr_find is just a memory look up and is quite fast.  A -1 return
  * indicates that the requested id does not exist.
  */
 
@@ -82,6 +87,7 @@
  * For some reason mips/mips64 define the SIGEV constants plus 128.
  * Here we define a mask to get rid of the common bits.	 The
  * optimizer should make this costless to all but mips.
+ * Note that no common bits (the non-mips case) will give 0xffffffff.
  */
 #define MIPS_SIGEV ~(SIGEV_NONE & \
 		      SIGEV_SIGNAL & \
@@ -93,7 +99,7 @@
  * The timer ID is turned into a timer address by idr_find().
  * Verifying a valid ID consists of:
  *
- * a) checking that idr_find() returns other than zero.
+ * a) checking that idr_find() returns other than -1.
  * b) checking that the timer id matches the one in the timer itself.
  * c) that the timer owner is in the callers thread group.
  */
@@ -162,6 +168,8 @@
 
 void register_posix_clock(int clock_id, struct k_clock *new_clock);
 static int do_posix_gettime(struct k_clock *clock, struct timespec *tp);
+static u64 do_posix_clock_monotonic_gettime_parts(
+	struct timespec *tp, struct timespec *mo);
 int do_posix_clock_monotonic_gettime(struct timespec *tp);
 int do_posix_clock_monotonic_settime(struct timespec *tp);
 static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags);
@@ -172,8 +180,8 @@
  */
 static __init int init_posix_timers(void)
 {
-	struct k_clock clock_realtime = {.res = NSEC_PER_SEC / HZ };
-	struct k_clock clock_monotonic = {.res = NSEC_PER_SEC / HZ,
+	struct k_clock clock_realtime = {.res = CLOCK_REALTIME_RES };
+	struct k_clock clock_monotonic = {.res = CLOCK_REALTIME_RES,
 		.clock_get = do_posix_clock_monotonic_gettime,
 		.clock_set = do_posix_clock_monotonic_settime
 	};
@@ -192,7 +200,7 @@
 
 static void tstojiffie(struct timespec *tp, int res, u64 *jiff)
 {
-	unsigned long sec = tp->tv_sec;
+	long sec = tp->tv_sec;
 	long nsec = tp->tv_nsec + res - 1;
 
 	if (nsec > NSEC_PER_SEC) {
@@ -201,35 +209,14 @@
 	}
 
 	/*
-	 * A note on jiffy overflow: It is possible for the system to
-	 * have been up long enough for the jiffies quanity to overflow.
-	 * In order for correct timer evaluations we require that the
-	 * specified time be somewhere between now and now + (max
-	 * unsigned int/2).  Times beyond this will be truncated back to
-	 * this value.   This is done in the absolute adjustment code,
-	 * below.  Here it is enough to just discard the high order
-	 * bits.
-	 */
-	*jiff = (u64)sec * HZ;
-	/*
-	 * Do the res thing. (Don't forget the add in the declaration of nsec)
-	 */
-	nsec -= nsec % res;
-	/*
-	 * Split to jiffie and sub jiffie
-	 */
-	*jiff += nsec / (NSEC_PER_SEC / HZ);
-}
-
-static void tstotimer(struct itimerspec *time, struct k_itimer *timer)
-{
-	u64 result;
-	int res = posix_clocks[timer->it_clock].res;
-
-	tstojiffie(&time->it_value, res, &result);
-	timer->it_timer.expires = (unsigned long)result;
-	tstojiffie(&time->it_interval, res, &result);
-	timer->it_incr = (unsigned long)result;
+	 * The scaling constants are defined in <linux/time.h>
+	 * The difference between there and here is that we do the
+	 * res rounding and compute a 64-bit result (well so does that
+	 * but it then throws away the high bits).
+  	 */
+	*jiff =  (mpy_l_X_l_ll(sec, SEC_CONVERSION) +
+		  (mpy_l_X_l_ll(nsec, NSEC_CONVERSION) >> 
+		   (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
 }
 
 static void schedule_next_timer(struct k_itimer *timr)
@@ -690,57 +677,81 @@
  * If it is relative time, we need to add the current (CLOCK_MONOTONIC)
  * time to it to get the proper time for the timer.
  */
-static int adjust_abs_time(struct k_clock *clock, struct timespec *tp, int abs)
+static int adjust_abs_time(struct k_clock *clock, struct timespec *tp, 
+			   int abs, u64 *exp)
 {
 	struct timespec now;
-	struct timespec oc;
-	do_posix_clock_monotonic_gettime(&now);
-
-	if (!abs || (posix_clocks[CLOCK_MONOTONIC].clock_get !=
-							clock->clock_get)) {
-		if (abs)
-			do_posix_gettime(clock, &oc);
-		else
-			oc.tv_nsec = oc.tv_sec = 0;
-
-		tp->tv_sec += now.tv_sec - oc.tv_sec;
-		tp->tv_nsec += now.tv_nsec - oc.tv_nsec;
+	struct timespec oc = *tp;
+	struct timespec wall_to_mono;
+	u64 jiffies_64_f;
+	int rtn =0;
 
+	if (abs) {
+		/*
+		 * The mask pick up the 4 basic clocks 
+		 */
+		if (!(clock - &posix_clocks[0]) & ~CLOCKS_MASK) {
+			jiffies_64_f = do_posix_clock_monotonic_gettime_parts(
+				&now,  &wall_to_mono);
+			/*
+			 * If we are doing a MONOTONIC clock
+			 */
+			if((clock - &posix_clocks[0]) & CLOCKS_MONO){
+				now.tv_sec += wall_to_mono.tv_sec;
+				now.tv_nsec += wall_to_mono.tv_nsec;
+			}
+		} else {
+			/*
+			 * Not one of the basic clocks
+			 */
+			do_posix_gettime(clock, &now);	
+			jiffies_64_f = get_jiffies_64();
+		}
+		/*
+		 * Take away now to get delta
+		 */
+		oc.tv_sec -= now.tv_sec;
+		oc.tv_nsec -= now.tv_nsec;
 		/*
 		 * Normalize...
 		 */
-		if ((tp->tv_nsec - NSEC_PER_SEC) >= 0) {
-			tp->tv_nsec -= NSEC_PER_SEC;
-			tp->tv_sec++;
+		while ((oc.tv_nsec - NSEC_PER_SEC) >= 0) {
+			oc.tv_nsec -= NSEC_PER_SEC;
+			oc.tv_sec++;
 		}
-		if ((tp->tv_nsec) < 0) {
-			tp->tv_nsec += NSEC_PER_SEC;
-			tp->tv_sec--;
+		while ((oc.tv_nsec) < 0) {
+			oc.tv_nsec += NSEC_PER_SEC;
+			oc.tv_sec--;
 		}
+	}else{
+		jiffies_64_f = get_jiffies_64();
 	}
 	/*
-	 * Check if the requested time is prior to now (if so set now) or
-	 * is more than the timer code can handle (if so we error out).
-	 * The (unsigned) catches the case of prior to "now" with the same
-	 * test.  Only on failure do we sort out what happened, and then
-	 * we use the (unsigned) to error out negative seconds.
+	 * Check if the requested time is prior to now (if so set now)
+	 */
+	if (oc.tv_sec < 0)
+		oc.tv_sec = oc.tv_nsec = 0;
+	tstojiffie(&oc, clock->res, exp);
+
+	/*
+	 * Check if the requested time is more than the timer code
+	 * can handle (if so we error out but return the value too).
 	 */
-	if ((unsigned) (tp->tv_sec - now.tv_sec) > (MAX_JIFFY_OFFSET / HZ)) {
-		if ((unsigned) tp->tv_sec < now.tv_sec) {
-			tp->tv_sec = now.tv_sec;
-			tp->tv_nsec = now.tv_nsec;
-		} else
+	if (*exp > ((u64)MAX_JIFFY_OFFSET))
 			/*
 			 * This is a considered response, not exactly in
 			 * line with the standard (in fact it is silent on
-			 * possible overflows).  We assume such a large
+			 * possible overflows).  We assume such a large 
 			 * value is ALMOST always a programming error and
 			 * try not to compound it by setting a really dumb
 			 * value.
 			 */
-			return -EINVAL;
-	}
-	return 0;
+			rtn = -EINVAL;
+	/*
+	 * return the actual jiffies expire time, full 64 bits
+	 */
+	*exp += jiffies_64_f;
+	return rtn;
 }
 
 /* Set a POSIX.1b interval timer. */
@@ -750,6 +761,7 @@
 		 struct itimerspec *new_setting, struct itimerspec *old_setting)
 {
 	struct k_clock *clock = &posix_clocks[timr->it_clock];
+	u64 expire_64;
 
 	if (old_setting)
 		do_timer_gettime(timr, old_setting);
@@ -788,14 +800,15 @@
 		return 0;
 	}
 
-	if ((flags & TIMER_ABSTIME) &&
-	    (clock->clock_get != do_posix_clock_monotonic_gettime))
-		// FIXME: what is this?
-		;
 	if (adjust_abs_time(clock,
-			    &new_setting->it_value, flags & TIMER_ABSTIME))
+			    &new_setting->it_value, flags & TIMER_ABSTIME, 
+			    &expire_64)) {
 		return -EINVAL;
-	tstotimer(new_setting, timr);
+	}
+	timr->it_timer.expires = (unsigned long)expire_64;	
+	tstojiffie(&new_setting->it_interval, clock->res, &expire_64);
+	timr->it_incr = (unsigned long)expire_64;
+
 
 	/*
 	 * For some reason the timer does not fire immediately if expires is
@@ -964,30 +977,46 @@
  * Note also that the while loop assures that the sub_jiff_offset
  * will be less than a jiffie, thus no need to normalize the result.
  * Well, not really, if called with ints off :(
- *
- * HELP, this code should make an attempt at resolution beyond the
- * jiffie.  Trouble is this is "arch" dependent...
  */
 
-int do_posix_clock_monotonic_gettime(struct timespec *tp)
+static u64 do_posix_clock_monotonic_gettime_parts(
+	struct timespec *tp, struct timespec *mo)
 {
-	long sub_sec;
-	u64 jiffies_64_f;
-
-#if (BITS_PER_LONG > 32)
-	jiffies_64_f = jiffies_64;
-#else
+	u64 jiff;
+	struct timeval tpv;
 	unsigned int seq;
 
 	do {
 		seq = read_seqbegin(&xtime_lock);
-		jiffies_64_f = jiffies_64;
+		do_gettimeofday(&tpv);
+		*mo = wall_to_monotonic;
+		jiff = jiffies_64;
 
-	} while (read_seqretry(&xtime_lock, seq));
-#endif
-	tp->tv_sec = div_long_long_rem(jiffies_64_f, HZ, &sub_sec);
-	tp->tv_nsec = sub_sec * (NSEC_PER_SEC / HZ);
+	} while(read_seqretry(&xtime_lock, seq));
+
+	/*
+	 * Love to get this before it is converted to usec.
+	 * It would save a div AND a mpy.
+	 */
+	tp->tv_sec = tpv.tv_sec;
+	tp->tv_nsec = tpv.tv_usec * NSEC_PER_USEC;
 
+	return jiff;
+}
+
+int do_posix_clock_monotonic_gettime(struct timespec *tp)
+{
+	struct timespec wall_to_mono;
+
+	do_posix_clock_monotonic_gettime_parts(tp, &wall_to_mono);
+
+	tp->tv_sec += wall_to_mono.tv_sec;
+	tp->tv_nsec += wall_to_mono.tv_nsec;
+
+	if ((tp->tv_nsec - NSEC_PER_SEC) > 0) {
+		tp->tv_nsec -= NSEC_PER_SEC;
+		tp->tv_sec++;
+	}
 	return 0;
 }
 
@@ -1138,7 +1167,7 @@
 	struct timespec t;
 	struct timer_list new_timer;
 	DECLARE_WAITQUEUE(abs_wqueue, current);
-	u64 rq_time = 0;
+	u64 rq_time = (u64)0;
 	s64 left;
 	int abs;
 	struct restart_block *restart_block =
@@ -1163,7 +1192,7 @@
 		if (!rq_time)
 			return -EINTR;
 		left = rq_time - get_jiffies_64();
-		if (left <= 0LL)
+		if (left <= (s64)0)
 			return 0;	/* Already passed */
 	}
 
@@ -1174,14 +1203,14 @@
 	do {
 		t = *tsave;
 		if (abs || !rq_time) {
-			adjust_abs_time(&posix_clocks[which_clock], &t, abs);
-			tstojiffie(&t, posix_clocks[which_clock].res, &rq_time);
+			adjust_abs_time(&posix_clocks[which_clock], &t, abs,
+					&rq_time);
 		}
 
 		left = rq_time - get_jiffies_64();
-		if (left >= MAX_JIFFY_OFFSET)
-			left = MAX_JIFFY_OFFSET;
-		if (left < 0)
+		if (left >= (s64)MAX_JIFFY_OFFSET)
+			left = (s64)MAX_JIFFY_OFFSET;
+		if (left < (s64)0)
 			break;
 
 		new_timer.expires = jiffies + left;
@@ -1192,13 +1221,12 @@
 
 		del_timer_sync(&new_timer);
 		left = rq_time - get_jiffies_64();
-	} while (left > 0 && !test_thread_flag(TIF_SIGPENDING));
+	} while (left > (s64)0 && !test_thread_flag(TIF_SIGPENDING));
 
 	if (abs_wqueue.task_list.next)
 		finish_wait(&nanosleep_abs_wqueue, &abs_wqueue);
 
-	if (left > 0) {
-		unsigned long rmd;
+	if (left > (s64)0) {
 
 		/*
 		 * Always restart abs calls from scratch to pick up any
@@ -1207,9 +1235,10 @@
 		if (abs)
 			return -ERESTARTNOHAND;
 
-		tsave->tv_sec = div_long_long_rem(left, HZ, &rmd);
-		tsave->tv_nsec = rmd * (NSEC_PER_SEC / HZ);
-
+		left *= TICK_NSEC(TICK_USEC);
+		tsave->tv_sec = div_long_long_rem(left, 
+						  NSEC_PER_SEC, 
+						  &tsave->tv_nsec);
 		restart_block->fn = clock_nanosleep_restart;
 		restart_block->arg0 = which_clock;
 		restart_block->arg1 = (unsigned long)tsave;
diff -Nru a/kernel/printk.c b/kernel/printk.c
--- a/kernel/printk.c	Wed Apr 30 22:28:19 2003
+++ b/kernel/printk.c	Wed Apr 30 22:28:19 2003
@@ -674,7 +674,7 @@
  */
 void tty_write_message(struct tty_struct *tty, char *msg)
 {
-	if (tty && tty->driver.write)
-		tty->driver.write(tty, 0, msg, strlen(msg));
+	if (tty && tty->driver->write)
+		tty->driver->write(tty, 0, msg, strlen(msg));
 	return;
 }
diff -Nru a/kernel/resource.c b/kernel/resource.c
--- a/kernel/resource.c	Wed Apr 30 22:28:11 2003
+++ b/kernel/resource.c	Wed Apr 30 22:28:11 2003
@@ -21,7 +21,7 @@
 
 
 struct resource ioport_resource = { "PCI IO", 0x0000, IO_SPACE_LIMIT, IORESOURCE_IO };
-struct resource iomem_resource = { "PCI mem", 0x00000000, 0xffffffff, IORESOURCE_MEM };
+struct resource iomem_resource = { "PCI mem", 0UL, ~0UL, IORESOURCE_MEM };
 
 static rwlock_t resource_lock = RW_LOCK_UNLOCKED;
 
diff -Nru a/kernel/sched.c b/kernel/sched.c
--- a/kernel/sched.c	Wed Apr 30 22:28:15 2003
+++ b/kernel/sched.c	Wed Apr 30 22:28:15 2003
@@ -1091,7 +1091,7 @@
 #define IDLE_REBALANCE_TICK (HZ/1000 ?: 1)
 #define BUSY_REBALANCE_TICK (HZ/5 ?: 1)
 #define IDLE_NODE_REBALANCE_TICK (IDLE_REBALANCE_TICK * 5)
-#define BUSY_NODE_REBALANCE_TICK (BUSY_REBALANCE_TICK * 100)
+#define BUSY_NODE_REBALANCE_TICK (BUSY_REBALANCE_TICK * 2)
 
 #ifdef CONFIG_NUMA
 static void balance_node(runqueue_t *this_rq, int idle, int this_cpu)
@@ -1666,7 +1666,7 @@
  */
 int task_prio(task_t *p)
 {
-	return p->prio - MAX_USER_RT_PRIO;
+	return p->prio - MAX_RT_PRIO;
 }
 
 /**
diff -Nru a/kernel/suspend.c b/kernel/suspend.c
--- a/kernel/suspend.c	Wed Apr 30 22:28:06 2003
+++ b/kernel/suspend.c	Wed Apr 30 22:28:06 2003
@@ -1161,15 +1161,14 @@
 		struct block_device *bdev;
 		printk("Resuming from device %s\n",
 				__bdevname(resume_device, b));
-		bdev = bdget(resume_device);
-		if (!bdev) {
-			printk("No such block device ?!\n");
-			BUG();
+		bdev = open_by_devnum(resume_device, FMODE_READ, BDEV_RAW);
+		if (IS_ERR(bdev)) {
+			error = PTR_ERR(bdev);
+		} else {
+			set_blocksize(bdev, PAGE_SIZE);
+			error = __read_suspend_image(bdev, cur, noresume);
+			blkdev_put(bdev, BDEV_RAW);
 		}
-		blkdev_get(bdev, FMODE_READ, O_RDONLY, BDEV_RAW);
-		set_blocksize(bdev, PAGE_SIZE);
-		error = __read_suspend_image(bdev, cur, noresume);
-		blkdev_put(bdev, BDEV_RAW);
 	} else error = -ENOMEM;
 
 	if (scratch_page)
diff -Nru a/kernel/timer.c b/kernel/timer.c
--- a/kernel/timer.c	Wed Apr 30 22:28:15 2003
+++ b/kernel/timer.c	Wed Apr 30 22:28:15 2003
@@ -441,8 +441,16 @@
 unsigned long tick_usec = TICK_USEC; 		/* ACTHZ   period (usec) */
 unsigned long tick_nsec = TICK_NSEC(TICK_USEC);	/* USER_HZ period (nsec) */
 
-/* The current time */
+/* 
+ * The current time 
+ * wall_to_monotonic is what we need to add to xtime (or xtime corrected 
+ * for sub jiffie times) to get to monotonic time.  Monotonic is pegged at zero
+ * at zero at system boot time, so wall_to_monotonic will be negative,
+ * however, we will ALWAYS keep the tv_nsec part positive so we can use
+ * the usual normalization.
+ */
 struct timespec xtime __attribute__ ((aligned (16)));
+struct timespec wall_to_monotonic __attribute__ ((aligned (16)));
 
 /* Don't completely fail for HZ > 500.  */
 int tickadj = 500/HZ ? : 1;		/* microsecs */
@@ -508,6 +516,7 @@
     case TIME_INS:
 	if (xtime.tv_sec % 86400 == 0) {
 	    xtime.tv_sec--;
+	    wall_to_monotonic.tv_sec++;
 	    time_state = TIME_OOP;
 	    clock_was_set();
 	    printk(KERN_NOTICE "Clock: inserting leap second 23:59:60 UTC\n");
@@ -517,6 +526,7 @@
     case TIME_DEL:
 	if ((xtime.tv_sec + 1) % 86400 == 0) {
 	    xtime.tv_sec++;
+	    wall_to_monotonic.tv_sec--;
 	    time_state = TIME_WAIT;
 	    clock_was_set();
 	    printk(KERN_NOTICE "Clock: deleting leap second 23:59:59 UTC\n");
diff -Nru a/lib/kobject.c b/lib/kobject.c
--- a/lib/kobject.c	Wed Apr 30 22:28:16 2003
+++ b/lib/kobject.c	Wed Apr 30 22:28:16 2003
@@ -1,5 +1,8 @@
 /*
  * kobject.c - library routines for handling generic kernel objects
+ *
+ * Copyright (c) 2002-2003 Patrick Mochel <mochel@osdl.org>
+ *
  */
 
 #undef DEBUG
@@ -9,6 +12,8 @@
 #include <linux/module.h>
 #include <linux/stat.h>
 
+/* This lock can be removed entirely when the sysfs_init() code is cleaned up
+ * to not try to reference itself before it is initialized. */
 static spinlock_t kobj_lock = SPIN_LOCK_UNLOCKED;
 
 /**
@@ -336,12 +341,14 @@
 struct kobject * kobject_get(struct kobject * kobj)
 {
 	struct kobject * ret = kobj;
-	spin_lock(&kobj_lock);
+	unsigned long flags;
+
+	spin_lock_irqsave(&kobj_lock, flags);
 	if (kobj && atomic_read(&kobj->refcount) > 0)
 		atomic_inc(&kobj->refcount);
 	else
 		ret = NULL;
-	spin_unlock(&kobj_lock);
+	spin_unlock_irqrestore(&kobj_lock, flags);
 	return ret;
 }
 
@@ -371,10 +378,15 @@
 
 void kobject_put(struct kobject * kobj)
 {
-	if (!atomic_dec_and_lock(&kobj->refcount, &kobj_lock))
-		return;
-	spin_unlock(&kobj_lock);
-	kobject_cleanup(kobj);
+	unsigned long flags;
+
+	local_irq_save(flags);
+	if (atomic_dec_and_lock(&kobj->refcount, &kobj_lock)) {
+		spin_unlock_irqrestore(&kobj_lock, flags);
+		kobject_cleanup(kobj);
+	} else {
+		local_irq_restore(flags);
+	}
 }
 
 
diff -Nru a/lib/percpu_counter.c b/lib/percpu_counter.c
--- a/lib/percpu_counter.c	Wed Apr 30 22:28:03 2003
+++ b/lib/percpu_counter.c	Wed Apr 30 22:28:03 2003
@@ -1,5 +1,6 @@
 
 #include <linux/percpu_counter.h>
+#include <linux/sched.h>
 
 void percpu_counter_mod(struct percpu_counter *fbc, long amount)
 {
diff -Nru a/mm/filemap.c b/mm/filemap.c
--- a/mm/filemap.c	Wed Apr 30 22:28:07 2003
+++ b/mm/filemap.c	Wed Apr 30 22:28:07 2003
@@ -31,12 +31,11 @@
  * This is needed for the following functions:
  *  - try_to_release_page
  *  - block_invalidatepage
- *  - page_has_buffers
  *  - generic_osync_inode
  *
- * FIXME: remove all knowledge of the buffer layer from this file
+ * FIXME: remove all knowledge of the buffer layer from the core VM
  */
-#include <linux/buffer_head.h>
+#include <linux/buffer_head.h> /* for generic_osync_inode */
 
 #include <asm/uaccess.h>
 #include <asm/mman.h>
diff -Nru a/mm/memory.c b/mm/memory.c
--- a/mm/memory.c	Wed Apr 30 22:28:08 2003
+++ b/mm/memory.c	Wed Apr 30 22:28:08 2003
@@ -292,8 +292,11 @@
 				 * and not mapped via rmap - duplicate the
 				 * mapping as is.
 				 */
-				page = pfn_to_page(pfn);
-				if (!pfn_valid(pfn) || PageReserved(page)) {
+				page = NULL;
+				if (pfn_valid(pfn)) 
+					page = pfn_to_page(pfn); 
+
+				if (!page || PageReserved(page)) {
 					set_pte(dst_pte, pte);
 					goto cont_copy_pte_range_noset;
 				}
diff -Nru a/mm/mmap.c b/mm/mmap.c
--- a/mm/mmap.c	Wed Apr 30 22:28:11 2003
+++ b/mm/mmap.c	Wed Apr 30 22:28:11 2003
@@ -355,6 +355,26 @@
 }
 
 /*
+ * If the vma has a ->close operation then the driver probably needs to release
+ * per-vma resources, so we don't attempt to merge those.
+ */
+#define VM_SPECIAL (VM_IO | VM_DONTCOPY | VM_DONTEXPAND | VM_RESERVED)
+
+static inline int is_mergeable_vma(struct vm_area_struct *vma,
+			struct file *file, unsigned long vm_flags)
+{
+	if (vma->vm_ops && vma->vm_ops->close)
+		return 0;
+	if (vma->vm_file != file)
+		return 0;
+	if (vma->vm_flags != vm_flags)
+		return 0;
+	if (vma->vm_private_data)
+		return 0;
+	return 1;
+}
+
+/*
  * Return true if we can merge this (vm_flags,file,vm_pgoff,size)
  * in front of (at a lower virtual address and file offset than) the vma.
  *
@@ -366,9 +386,7 @@
 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
 	struct file *file, unsigned long vm_pgoff, unsigned long size)
 {
-	if ((vma->vm_flags & VM_DONTEXPAND) || (vm_flags & VM_DONTEXPAND))
-		return 0;
-	if (vma->vm_file == file && vma->vm_flags == vm_flags) {
+	if (is_mergeable_vma(vma, file, vm_flags)) {
 		if (!file)
 			return 1;	/* anon mapping */
 		if (vma->vm_pgoff == vm_pgoff + size)
@@ -385,9 +403,7 @@
 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
 	struct file *file, unsigned long vm_pgoff)
 {
-	if ((vma->vm_flags & VM_DONTEXPAND) || (vm_flags & VM_DONTEXPAND))
-		return 0;
-	if (vma->vm_file == file && vma->vm_flags == vm_flags) {
+	if (is_mergeable_vma(vma, file, vm_flags)) {
 		unsigned long vma_size;
 
 		if (!file)
@@ -412,6 +428,13 @@
 {
 	spinlock_t * lock = &mm->page_table_lock;
 
+	/*
+	 * We later require that vma->vm_flags == vm_flags, so this tests
+	 * vma->vm_flags & VM_SPECIAL, too.
+	 */
+	if (vm_flags & VM_SPECIAL)
+		return 0;
+
 	if (!prev) {
 		prev = rb_entry(rb_parent, struct vm_area_struct, vm_rb);
 		goto merge_next;
@@ -421,6 +444,7 @@
 	 * Can it merge with the predecessor?
 	 */
 	if (prev->vm_end == addr &&
+			is_mergeable_vma(prev, file, vm_flags) &&
 			can_vma_merge_after(prev, vm_flags, file, pgoff)) {
 		struct vm_area_struct *next;
 		struct inode *inode = file ? file->f_dentry->d_inode : NULL;
diff -Nru a/mm/oom_kill.c b/mm/oom_kill.c
--- a/mm/oom_kill.c	Wed Apr 30 22:28:10 2003
+++ b/mm/oom_kill.c	Wed Apr 30 22:28:10 2003
@@ -129,6 +129,8 @@
 				chosen = p;
 				maxpoints = points;
 			}
+			if (p->flags & PF_SWAPOFF)
+				return p;
 		}
 	while_each_thread(g, p);
 	return chosen;
@@ -206,6 +208,11 @@
  */
 void out_of_memory(void)
 {
+	/*
+	 * oom_lock protects out_of_memory()'s static variables.
+	 * It's a global lock; this is not performance-critical.
+	 */
+	static spinlock_t oom_lock = SPIN_LOCK_UNLOCKED;
 	static unsigned long first, last, count, lastkill;
 	unsigned long now, since;
 
@@ -215,6 +222,7 @@
 	if (nr_swap_pages > 0)
 		return;
 
+	spin_lock(&oom_lock);
 	now = jiffies;
 	since = now - last;
 	last = now;
@@ -233,14 +241,14 @@
 	 */
 	since = now - first;
 	if (since < HZ)
-		return;
+		goto out_unlock;
 
 	/*
 	 * If we have gotten only a few failures,
 	 * we're not really oom. 
 	 */
 	if (++count < 10)
-		return;
+		goto out_unlock;
 
 	/*
 	 * If we just killed a process, wait a while
@@ -249,15 +257,27 @@
 	 */
 	since = now - lastkill;
 	if (since < HZ*5)
-		return;
+		goto out_unlock;
 
 	/*
 	 * Ok, really out of memory. Kill something.
 	 */
 	lastkill = now;
+
+	/* oom_kill() sleeps */
+	spin_unlock(&oom_lock);
 	oom_kill();
+	spin_lock(&oom_lock);
 
 reset:
-	first = now;
+	/*
+	 * We dropped the lock above, so check to be sure the variable
+	 * first only ever increases to prevent false OOM's.
+	 */
+	if (time_after(now, first))
+		first = now;
 	count = 0;
+
+out_unlock:
+	spin_unlock(&oom_lock);
 }
diff -Nru a/mm/page-writeback.c b/mm/page-writeback.c
--- a/mm/page-writeback.c	Wed Apr 30 22:28:12 2003
+++ b/mm/page-writeback.c	Wed Apr 30 22:28:12 2003
@@ -462,88 +462,6 @@
 EXPORT_SYMBOL(write_one_page);
 
 /*
- * Add a page to the dirty page list.
- *
- * It is a sad fact of life that this function is called from several places
- * deeply under spinlocking.  It may not sleep.
- *
- * If the page has buffers, the uptodate buffers are set dirty, to preserve
- * dirty-state coherency between the page and the buffers.  It the page does
- * not have buffers then when they are later attached they will all be set
- * dirty.
- *
- * The buffers are dirtied before the page is dirtied.  There's a small race
- * window in which a writepage caller may see the page cleanness but not the
- * buffer dirtiness.  That's fine.  If this code were to set the page dirty
- * before the buffers, a concurrent writepage caller could clear the page dirty
- * bit, see a bunch of clean buffers and we'd end up with dirty buffers/clean
- * page on the dirty page list.
- *
- * There is also a small window where the page is dirty, and not on dirty_pages.
- * Also a possibility that by the time the page is added to dirty_pages, it has
- * been set clean.  The page lists are somewhat approximate in this regard.
- * It's better to have clean pages accidentally attached to dirty_pages than to
- * leave dirty pages attached to clean_pages.
- *
- * We use private_lock to lock against try_to_free_buffers while using the
- * page's buffer list.  Also use this to protect against clean buffers being
- * added to the page after it was set dirty.
- *
- * FIXME: may need to call ->reservepage here as well.  That's rather up to the
- * address_space though.
- *
- * 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;
-	int ret = 0;
-
-	if (mapping == NULL) {
-		SetPageDirty(page);
-		goto out;
-	}
-
-	if (!PageUptodate(page))
-		buffer_error();
-
-	spin_lock(&mapping->private_lock);
-	if (page_has_buffers(page)) {
-		struct buffer_head *head = page_buffers(page);
-		struct buffer_head *bh = head;
-
-		do {
-			if (buffer_uptodate(bh))
-				set_buffer_dirty(bh);
-			else
-				buffer_error();
-			bh = bh->b_this_page;
-		} while (bh != head);
-	}
-	spin_unlock(&mapping->private_lock);
-
-	if (!TestSetPageDirty(page)) {
-		spin_lock(&mapping->page_lock);
-		if (page->mapping) {	/* Race with truncate? */
-			if (!mapping->backing_dev_info->memory_backed)
-				inc_page_state(nr_dirty);
-			list_del(&page->list);
-			list_add(&page->list, &mapping->dirty_pages);
-		}
-		spin_unlock(&mapping->page_lock);
-		__mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
-	}
-	
-out:
-	return ret;
-}
-EXPORT_SYMBOL(__set_page_dirty_buffers);
-
-/*
  * For address_spaces which do not use buffers.  Just set the page's dirty bit
  * and move it to the dirty_pages list.  Also perform space reservation if
  * required.
diff -Nru a/mm/page_alloc.c b/mm/page_alloc.c
--- a/mm/page_alloc.c	Wed Apr 30 22:28:04 2003
+++ b/mm/page_alloc.c	Wed Apr 30 22:28:04 2003
@@ -536,6 +536,7 @@
 	struct page *page;
 	int i;
 	int cold;
+	int do_retry;
 
 	if (wait)
 		might_sleep();
@@ -626,10 +627,21 @@
 	}
 
 	/*
-	 * Don't let big-order allocations loop.  Yield for kswapd, try again.
+	 * Don't let big-order allocations loop unless the caller explicitly
+	 * requests that.  Wait for some write requests to complete then retry.
+	 *
+	 * In this implementation, __GFP_REPEAT means __GFP_NOFAIL, but that
+	 * may not be true in other implementations.
 	 */
-	if (order <= 3) {
-		yield();
+	do_retry = 0;
+	if (!(gfp_mask & __GFP_NORETRY)) {
+		if ((order <= 3) || (gfp_mask & __GFP_REPEAT))
+			do_retry = 1;
+		if (gfp_mask & __GFP_NOFAIL)
+			do_retry = 1;
+	}
+	if (do_retry) {
+		blk_congestion_wait(WRITE, HZ/50);
 		goto rebalance;
 	}
 
diff -Nru a/mm/swap.c b/mm/swap.c
--- a/mm/swap.c	Wed Apr 30 22:28:08 2003
+++ b/mm/swap.c	Wed Apr 30 22:28:08 2003
@@ -21,7 +21,7 @@
 #include <linux/pagevec.h>
 #include <linux/init.h>
 #include <linux/mm_inline.h>
-#include <linux/buffer_head.h>
+#include <linux/buffer_head.h>	/* for try_to_release_page() */
 #include <linux/percpu.h>
 
 /* How many pages do we try to swap or page in/out together? */
diff -Nru a/mm/swap_state.c b/mm/swap_state.c
--- a/mm/swap_state.c	Wed Apr 30 22:28:08 2003
+++ b/mm/swap_state.c	Wed Apr 30 22:28:08 2003
@@ -13,7 +13,6 @@
 #include <linux/init.h>
 #include <linux/pagemap.h>
 #include <linux/backing-dev.h>
-#include <linux/buffer_head.h>	/* block_sync_page() */
 
 #include <asm/pgtable.h>
 
@@ -187,7 +186,7 @@
 
 	BUG_ON(!PageLocked(page));
 	BUG_ON(PageWriteback(page));
-	BUG_ON(page_has_buffers(page));
+	BUG_ON(PagePrivate(page));
   
 	entry.val = page->index;
 
@@ -236,7 +235,7 @@
 
 	BUG_ON(!PageLocked(page));
 	BUG_ON(PageWriteback(page));
-	BUG_ON(page_has_buffers(page));
+	BUG_ON(PagePrivate(page));
 
 	entry.val = page->index;
 
diff -Nru a/mm/swapfile.c b/mm/swapfile.c
--- a/mm/swapfile.c	Wed Apr 30 22:28:05 2003
+++ b/mm/swapfile.c	Wed Apr 30 22:28:05 2003
@@ -7,6 +7,7 @@
 
 #include <linux/config.h>
 #include <linux/mm.h>
+#include <linux/mman.h>
 #include <linux/slab.h>
 #include <linux/kernel_stat.h>
 #include <linux/swap.h>
@@ -15,7 +16,6 @@
 #include <linux/namei.h>
 #include <linux/shm.h>
 #include <linux/blkdev.h>
-#include <linux/buffer_head.h>
 #include <linux/writeback.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
@@ -300,7 +300,7 @@
 	struct swap_info_struct * p;
 	swp_entry_t entry;
 
-	BUG_ON(page_has_buffers(page));
+	BUG_ON(PagePrivate(page));
 	BUG_ON(!PageLocked(page));
 
 	if (!PageSwapCache(page))
@@ -355,7 +355,7 @@
 	if (page) {
 		int one_user;
 
-		BUG_ON(page_has_buffers(page));
+		BUG_ON(PagePrivate(page));
 		page_cache_get(page);
 		one_user = (page_count(page) == 2);
 		/* Only cache user (+us), or swap space full? Free it! */
@@ -590,6 +590,11 @@
 	 * to swapoff for a while, then reappear - but that is rare.
 	 */
 	while ((i = find_next_to_unuse(si, i))) {
+		if (signal_pending(current)) {
+			retval = -EINTR;
+			break;
+		}
+
 		/* 
 		 * Get a page for the entry, using the existing swap
 		 * cache page if there is one.  Otherwise, get a clean
@@ -759,8 +764,7 @@
 
 		/*
 		 * Make sure that we aren't completely killing
-		 * interactive performance.  Interruptible check on
-		 * signal_pending() would be nice, but changes the spec?
+		 * interactive performance.
 		 */
 		cond_resched();
 	}
@@ -1029,12 +1033,18 @@
 		}
 		prev = type;
 	}
-	err = -EINVAL;
 	if (type < 0) {
+		err = -EINVAL;
+		swap_list_unlock();
+		goto out_dput;
+	}
+	if (vm_enough_memory(p->pages))
+		vm_unacct_memory(p->pages);
+	else {
+		err = -ENOMEM;
 		swap_list_unlock();
 		goto out_dput;
 	}
-
 	if (prev < 0) {
 		swap_list.head = p->next;
 	} else {
@@ -1048,7 +1058,9 @@
 	total_swap_pages -= p->pages;
 	p->flags &= ~SWP_WRITEOK;
 	swap_list_unlock();
+	current->flags |= PF_SWAPOFF;
 	err = try_to_unuse(type);
+	current->flags &= ~PF_SWAPOFF;
 	if (err) {
 		/* re-insert swap space back into swap_list */
 		swap_list_lock();
diff -Nru a/mm/vmalloc.c b/mm/vmalloc.c
--- a/mm/vmalloc.c	Wed Apr 30 22:28:10 2003
+++ b/mm/vmalloc.c	Wed Apr 30 22:28:10 2003
@@ -308,7 +308,7 @@
  *
  *	@addr:		memory base address
  *
- *	Free the virtually continguos memory area starting at @addr, as
+ *	Free the virtually contiguous memory area starting at @addr, as
  *	obtained from vmalloc(), vmalloc_32() or __vmalloc().
  *
  *	May not be called in interrupt context.
@@ -324,7 +324,7 @@
  *
  *	@addr:		memory base address
  *
- *	Free the virtually continguos memory area starting at @addr,
+ *	Free the virtually contiguous memory area starting at @addr,
  *	which was created from the page array passed to vmap().
  *
  *	May not be called in interrupt context.
@@ -336,25 +336,28 @@
 }
 
 /**
- *	vmap  -  map an array of pages into virtually continguos space
+ *	vmap  -  map an array of pages into virtually contiguous space
  *
  *	@pages:		array of page pointers
  *	@count:		number of pages to map
+ *	@flags:		vm_area->flags
+ *	@prot:		page protection for the mapping
  *
- *	Maps @count pages from @pages into continguos kernel virtual
+ *	Maps @count pages from @pages into contiguous kernel virtual
  *	space.
  */
-void *vmap(struct page **pages, unsigned int count)
+void *vmap(struct page **pages, unsigned int count,
+		unsigned long flags, pgprot_t prot)
 {
 	struct vm_struct *area;
 
 	if (count > num_physpages)
 		return NULL;
 
-	area = get_vm_area((count << PAGE_SHIFT), VM_MAP);
+	area = get_vm_area((count << PAGE_SHIFT), flags);
 	if (!area)
 		return NULL;
-	if (map_vm_area(area, PAGE_KERNEL, &pages)) {
+	if (map_vm_area(area, prot, &pages)) {
 		vunmap(area->addr);
 		return NULL;
 	}
@@ -363,14 +366,14 @@
 }
 
 /**
- *	__vmalloc  -  allocate virtually continguos memory
+ *	__vmalloc  -  allocate virtually contiguous memory
  *
  *	@size:		allocation size
  *	@gfp_mask:	flags for the page level allocator
  *	@prot:		protection mask for the allocated pages
  *
  *	Allocate enough pages to cover @size from the page level
- *	allocator with @gfp_mask flags.  Map them into continguos
+ *	allocator with @gfp_mask flags.  Map them into contiguous
  *	kernel virtual space, using a pagetable protection of @prot.
  */
 void *__vmalloc(unsigned long size, int gfp_mask, pgprot_t prot)
@@ -418,12 +421,12 @@
 }
 
 /**
- *	vmalloc  -  allocate virtually continguos memory
+ *	vmalloc  -  allocate virtually contiguous memory
  *
  *	@size:		allocation size
  *
  *	Allocate enough pages to cover @size from the page level
- *	allocator and map them into continguos kernel virtual space.
+ *	allocator and map them into contiguous kernel virtual space.
  *
  *	For tight cotrol over page level allocator and protection flags
  *	use __vmalloc() instead.
@@ -434,12 +437,12 @@
 }
 
 /**
- *	vmalloc_32  -  allocate virtually continguos memory (32bit addressable)
+ *	vmalloc_32  -  allocate virtually contiguous memory (32bit addressable)
  *
  *	@size:		allocation size
  *
  *	Allocate enough 32bit PA addressable pages to cover @size from the
- *	page level allocator and map them into continguos kernel virtual space.
+ *	page level allocator and map them into contiguous kernel virtual space.
  */
 void *vmalloc_32(unsigned long size)
 {
diff -Nru a/mm/vmscan.c b/mm/vmscan.c
--- a/mm/vmscan.c	Wed Apr 30 22:28:05 2003
+++ b/mm/vmscan.c	Wed Apr 30 22:28:05 2003
@@ -22,7 +22,8 @@
 #include <linux/writeback.h>
 #include <linux/suspend.h>
 #include <linux/blkdev.h>
-#include <linux/buffer_head.h>		/* for try_to_release_page() */
+#include <linux/buffer_head.h>	/* for try_to_release_page(),
+					buffer_heads_over_limit */
 #include <linux/mm_inline.h>
 #include <linux/pagevec.h>
 #include <linux/backing-dev.h>
@@ -134,11 +135,9 @@
  * If the vm encounted mapped pages on the LRU it increase the pressure on
  * slab to avoid swapping.
  *
- * FIXME: do not do for zone highmem
- *
  * We do weird things to avoid (scanned*seeks*entries) overflowing 32 bits.
  */
-static int shrink_slab(long scanned,  unsigned int gfp_mask)
+static int shrink_slab(long scanned, unsigned int gfp_mask)
 {
 	struct shrinker *shrinker;
 	long pages;
@@ -558,6 +557,7 @@
 refill_inactive_zone(struct zone *zone, const int nr_pages_in,
 			struct page_state *ps, int priority)
 {
+	int pgmoved;
 	int pgdeactivate = 0;
 	int nr_pages = nr_pages_in;
 	LIST_HEAD(l_hold);	/* The pages which were snipped off */
@@ -571,6 +571,7 @@
 	long swap_tendency;
 
 	lru_add_drain();
+	pgmoved = 0;
 	spin_lock_irq(&zone->lru_lock);
 	while (nr_pages && !list_empty(&zone->active_list)) {
 		page = list_entry(zone->active_list.prev, struct page, lru);
@@ -585,9 +586,11 @@
 		} else {
 			page_cache_get(page);
 			list_add(&page->lru, &l_hold);
+			pgmoved++;
 		}
 		nr_pages--;
 	}
+	zone->nr_active -= pgmoved;
 	spin_unlock_irq(&zone->lru_lock);
 
 	/*
@@ -647,10 +650,10 @@
 			continue;
 		}
 		list_add(&page->lru, &l_inactive);
-		pgdeactivate++;
 	}
 
 	pagevec_init(&pvec, 1);
+	pgmoved = 0;
 	spin_lock_irq(&zone->lru_lock);
 	while (!list_empty(&l_inactive)) {
 		page = list_entry(l_inactive.prev, struct page, lru);
@@ -660,19 +663,27 @@
 		if (!TestClearPageActive(page))
 			BUG();
 		list_move(&page->lru, &zone->inactive_list);
+		pgmoved++;
 		if (!pagevec_add(&pvec, page)) {
+			zone->nr_inactive += pgmoved;
 			spin_unlock_irq(&zone->lru_lock);
+			pgdeactivate += pgmoved;
+			pgmoved = 0;
 			if (buffer_heads_over_limit)
 				pagevec_strip(&pvec);
 			__pagevec_release(&pvec);
 			spin_lock_irq(&zone->lru_lock);
 		}
 	}
+	zone->nr_inactive += pgmoved;
+	pgdeactivate += pgmoved;
 	if (buffer_heads_over_limit) {
 		spin_unlock_irq(&zone->lru_lock);
 		pagevec_strip(&pvec);
 		spin_lock_irq(&zone->lru_lock);
 	}
+
+	pgmoved = 0;
 	while (!list_empty(&l_active)) {
 		page = list_entry(l_active.prev, struct page, lru);
 		prefetchw_prev_lru_page(page, &l_active, flags);
@@ -680,14 +691,16 @@
 			BUG();
 		BUG_ON(!PageActive(page));
 		list_move(&page->lru, &zone->active_list);
+		pgmoved++;
 		if (!pagevec_add(&pvec, page)) {
+			zone->nr_active += pgmoved;
+			pgmoved = 0;
 			spin_unlock_irq(&zone->lru_lock);
 			__pagevec_release(&pvec);
 			spin_lock_irq(&zone->lru_lock);
 		}
 	}
-	zone->nr_active -= pgdeactivate;
-	zone->nr_inactive += pgdeactivate;
+	zone->nr_active += pgmoved;
 	spin_unlock_irq(&zone->lru_lock);
 	pagevec_release(&pvec);
 
@@ -804,8 +817,7 @@
  * excessive rotation of the inactive list, which is _supposed_ to be an LRU,
  * yes?
  */
-int
-try_to_free_pages(struct zone *classzone,
+int try_to_free_pages(struct zone *classzone,
 		unsigned int gfp_mask, unsigned int order)
 {
 	int priority;
@@ -835,9 +847,10 @@
 
 		/* Take a nap, wait for some writeback to complete */
 		blk_congestion_wait(WRITE, HZ/10);
-		shrink_slab(total_scanned, gfp_mask);
+		if (classzone - classzone->zone_pgdat->node_zones < ZONE_HIGHMEM)
+			shrink_slab(total_scanned, gfp_mask);
 	}
-	if (gfp_mask & __GFP_FS)
+	if ((gfp_mask & __GFP_FS) && !(gfp_mask & __GFP_NORETRY))
 		out_of_memory();
 	return 0;
 }
@@ -895,7 +908,8 @@
 				max_scan = SWAP_CLUSTER_MAX;
 			to_free -= shrink_zone(zone, max_scan, GFP_KERNEL,
 					to_reclaim, &nr_mapped, ps, priority);
-			shrink_slab(max_scan + nr_mapped, GFP_KERNEL);
+			if (i < ZONE_HIGHMEM)
+				shrink_slab(max_scan + nr_mapped, GFP_KERNEL);
 			if (zone->all_unreclaimable)
 				continue;
 			if (zone->pages_scanned > zone->present_pages * 2)
diff -Nru a/net/802/psnap.c b/net/802/psnap.c
--- a/net/802/psnap.c	Wed Apr 30 22:28:19 2003
+++ b/net/802/psnap.c	Wed Apr 30 22:28:19 2003
@@ -21,9 +21,9 @@
 #include <linux/mm.h>
 #include <linux/in.h>
 #include <linux/init.h>
-#include <linux/brlock.h>
 
-LIST_HEAD(snap_list);
+static LIST_HEAD(snap_list);
+static spinlock_t snap_lock = SPIN_LOCK_UNLOCKED;
 static struct llc_sap *snap_sap;
 
 /*
@@ -34,17 +34,13 @@
 	struct list_head *entry;
 	struct datalink_proto *proto = NULL, *p;
 
-	if (list_empty(&snap_list))
-		goto out;
-
-	list_for_each(entry, &snap_list) {
+	list_for_each_rcu(entry, &snap_list) {
 		p = list_entry(entry, struct datalink_proto, node);
 		if (!memcmp(p->type, desc, 5)) {
 			proto = p;
 			break;
 		}
 	}
-out:
 	return proto;
 }
 
@@ -55,11 +51,13 @@
 		    struct packet_type *pt)
 {
 	int rc = 1;
-	struct datalink_proto *proto = find_snap_client(skb->h.raw);
+	struct datalink_proto *proto;
 	static struct packet_type snap_packet_type = {
 		.type = __constant_htons(ETH_P_SNAP),
 	};
 
+	rcu_read_lock();
+	proto = find_snap_client(skb->h.raw);
 	if (proto) {
 		/* Pass the frame on. */
 		skb->h.raw  += 5;
@@ -71,6 +69,7 @@
 		rc = 1;
 	}
 
+	rcu_read_unlock();
 	return rc;
 }
 
@@ -124,7 +123,7 @@
 {
 	struct datalink_proto *proto = NULL;
 
-	br_write_lock_bh(BR_NETPROTO_LOCK);
+	spin_lock_bh(&snap_lock);
 
 	if (find_snap_client(desc))
 		goto out;
@@ -135,10 +134,12 @@
 		proto->rcvfunc		= rcvfunc;
 		proto->header_length	= 5 + 3; /* snap + 802.2 */
 		proto->request		= snap_request;
-		list_add(&proto->node, &snap_list);
+		list_add_rcu(&proto->node, &snap_list);
 	}
 out:
-	br_write_unlock_bh(BR_NETPROTO_LOCK);
+	spin_unlock_bh(&snap_lock);
+
+	synchronize_net();
 	return proto;
 }
 
@@ -147,12 +148,13 @@
  */
 void unregister_snap_client(struct datalink_proto *proto)
 {
-	br_write_lock_bh(BR_NETPROTO_LOCK);
+	spin_lock_bh(&snap_lock);
+	list_del_rcu(&proto->node);
+	spin_unlock_bh(&snap_lock);
 
-	list_del(&proto->node);
-	kfree(proto);
+	synchronize_net();
 
-	br_write_unlock_bh(BR_NETPROTO_LOCK);
+	kfree(proto);
 }
 
 MODULE_LICENSE("GPL");
diff -Nru a/net/Kconfig b/net/Kconfig
--- a/net/Kconfig	Wed Apr 30 22:28:04 2003
+++ b/net/Kconfig	Wed Apr 30 22:28:04 2003
@@ -18,7 +18,7 @@
 
 	  For a general introduction to Linux networking, it is highly
 	  recommended to read the NET-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 menu "Networking options"
 	depends on NET
@@ -162,7 +162,7 @@
 
 	  For an excellent introduction to Linux networking, please read the
 	  NET-3-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  This option is also necessary if you want to use the full power of
 	  term (term is a program which gives you almost full Internet
@@ -294,7 +294,7 @@
 	  Novell client ncpfs (available from
 	  <ftp://platan.vc.cvut.cz/pub/linux/ncpfs/>) or from
 	  within the Linux DOS emulator DOSEMU (read the DOSEMU-HOWTO,
-	  available from <http://www.linuxdoc.org/docs.html#howto>).  In order
+	  available from <http://www.tldp.org/docs.html#howto>).  In order
 	  to do the former, you'll also have to say Y to "NCP file system
 	  support", below.
 
@@ -307,7 +307,7 @@
 	  <ftp://ibiblio.org/pub/Linux/system/network/daemons/> or
 	  mars_nwe from <ftp://www.compu-art.de/mars_nwe/>. For more
 	  information, read the IPX-HOWTO available from
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  General information about how to connect Linux, Windows machines and
 	  Macs is on the WWW at <http://www.eats.com/linux_mac_win.html>.
@@ -339,7 +339,7 @@
 	  General information about how to connect Linux, Windows machines and
 	  Macs is on the WWW at <http://www.eats.com/linux_mac_win.html>.  The
 	  NET-3-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>, contains valuable
+	  <http://www.tldp.org/docs.html#howto>, contains valuable
 	  information as well.
 
 	  This driver is also available as a module ( = code which can be
diff -Nru a/net/appletalk/ddp.c b/net/appletalk/ddp.c
--- a/net/appletalk/ddp.c	Wed Apr 30 22:28:19 2003
+++ b/net/appletalk/ddp.c	Wed Apr 30 22:28:19 2003
@@ -190,10 +190,9 @@
 	struct sock *sk = (struct sock *)data;
 
 	if (!atomic_read(&sk->wmem_alloc) &&
-	    !atomic_read(&sk->rmem_alloc) && test_bit(SOCK_DEAD, &sk->flags)) {
+	    !atomic_read(&sk->rmem_alloc) && test_bit(SOCK_DEAD, &sk->flags))
 		sock_put(sk);
-		MOD_DEC_USE_COUNT;
-	} else {
+	else {
 		sk->timer.expires = jiffies + SOCK_DESTROY_TIME;
 		add_timer(&sk->timer);
 	}
@@ -205,10 +204,9 @@
 	skb_queue_purge(&sk->receive_queue);
 
 	if (!atomic_read(&sk->wmem_alloc) &&
-	    !atomic_read(&sk->rmem_alloc) && test_bit(SOCK_DEAD, &sk->flags)) {
+	    !atomic_read(&sk->rmem_alloc) && test_bit(SOCK_DEAD, &sk->flags))
 		sock_put(sk);
-		MOD_DEC_USE_COUNT;
-	} else {
+	else {
 		init_timer(&sk->timer);
 		sk->timer.expires = jiffies + SOCK_DESTROY_TIME;
 		sk->timer.function = atalk_destroy_timer;
@@ -249,7 +247,6 @@
 			*iface = tmp->next;
 			kfree(tmp);
 			dev->atalk_ptr = NULL;
-			MOD_DEC_USE_COUNT;
 		} else
 			iface = &tmp->next;
 	}
@@ -259,13 +256,10 @@
 static struct atalk_iface *atif_add_device(struct net_device *dev,
 					   struct atalk_addr *sa)
 {
-	struct atalk_iface *iface;
-
-	MOD_INC_USE_COUNT;
+	struct atalk_iface *iface = kmalloc(sizeof(*iface), GFP_KERNEL);
 
-	iface = kmalloc(sizeof(*iface), GFP_KERNEL);
 	if (!iface)
-		goto out_mem;
+		goto out;
 
 	iface->dev = dev;
 	dev->atalk_ptr = iface;
@@ -278,9 +272,6 @@
 	write_unlock_bh(&atalk_interfaces_lock);
 out:
 	return iface;
-out_mem:
-	MOD_DEC_USE_COUNT;
-	goto out;
 }
 
 /* Perform phase 2 AARP probing on our tentative address */
@@ -982,17 +973,16 @@
 	struct atalk_sock *at;
 	int rc = -ESOCKTNOSUPPORT;
 
-	MOD_INC_USE_COUNT;
 	/*
 	 * We permit SOCK_DGRAM and RAW is an extension. It is trivial to do
 	 * and gives you the full ELAP frame. Should be handy for CAP 8) 
 	 */
 	if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM)
-		goto decmod;
+		goto out;
 	rc = -ENOMEM;
 	sk = sk_alloc(PF_APPLETALK, GFP_KERNEL, 1, NULL);
 	if (!sk)
-		goto decmod;
+		goto out;
 	at = at_sk(sk) = kmalloc(sizeof(*at), GFP_KERNEL);
 	if (!at)
 		goto outsk;
@@ -1005,8 +995,6 @@
 	return rc;
 outsk:
 	sk_free(sk);
-decmod:
-	MOD_DEC_USE_COUNT;
 	goto out;
 }
 
@@ -1785,6 +1773,7 @@
 static struct net_proto_family atalk_family_ops = {
 	.family		= PF_APPLETALK,
 	.create		= atalk_create,
+	.owner		= THIS_MODULE,
 };
 
 static struct proto_ops SOCKOPS_WRAPPED(atalk_dgram_ops) = {
diff -Nru a/net/atm/lec.c b/net/atm/lec.c
--- a/net/atm/lec.c	Wed Apr 30 22:28:11 2003
+++ b/net/atm/lec.c	Wed Apr 30 22:28:11 2003
@@ -552,15 +552,9 @@
 };
 
 static struct atm_dev lecatm_dev = {
-        &lecdev_ops,
-        NULL,	    /*PHY*/
-        "lec",	    /*type*/
-        999,	    /*dummy device number*/
-        NULL,NULL,  /*no VCCs*/
-        NULL,NULL,  /*no data*/
-        0,	    /*no flags*/
-        NULL,	    /* no local address*/
-        { 0 }	    /*no ESI or rest of the atm_dev struct things*/
+	.ops	= &lecdev_ops,
+	.type	= "lec",
+	.number	= 999,	/* dummy device number */
 };
 
 /*
diff -Nru a/net/atm/mpc.c b/net/atm/mpc.c
--- a/net/atm/mpc.c	Wed Apr 30 22:28:15 2003
+++ b/net/atm/mpc.c	Wed Apr 30 22:28:15 2003
@@ -744,7 +744,7 @@
 	.ops	= &mpc_ops,
 	.type	= "mpc",
 	.number	= 42,
-	/* members not explicitely initialised will be 0 */
+	/* members not explicitly initialised will be 0 */
 };
 
 int atm_mpoa_mpoad_attach (struct atm_vcc *vcc, int arg)
diff -Nru a/net/atm/resources.c b/net/atm/resources.c
--- a/net/atm/resources.c	Wed Apr 30 22:28:17 2003
+++ b/net/atm/resources.c	Wed Apr 30 22:28:17 2003
@@ -1,4 +1,4 @@
-/* net/atm/resources.c - Staticly allocated resources */
+/* net/atm/resources.c - Statically allocated resources */
 
 /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
 
diff -Nru a/net/ax25/Kconfig b/net/ax25/Kconfig
--- a/net/ax25/Kconfig	Wed Apr 30 22:28:16 2003
+++ b/net/ax25/Kconfig	Wed Apr 30 22:28:16 2003
@@ -13,7 +13,7 @@
 	help
 	  If you want to connect your Linux box to an amateur radio, answer Y
 	  here. You want to read <http://www.tapr.org/tapr/html/pkthome.html> and
-	  the AX25-HOWTO, available from <http://www.linuxdoc.org/docs.html#howto>.
+	  the AX25-HOWTO, available from <http://www.tldp.org/docs.html#howto>.
 
 	  Note that the answer to this question won't directly affect the
 	  kernel: saying N will just cause the configurator to skip all
@@ -42,7 +42,7 @@
 	  Information about where to get supporting software for Linux amateur
 	  radio as well as information about how to configure an AX.25 port is
 	  contained in the AX25-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. You might also want to
+	  <http://www.tldp.org/docs.html#howto>. You might also want to
 	  check out the file <file:Documentation/networking/ax25.txt> in the
 	  kernel source. More information about digital amateur radio in
 	  general is on the WWW at
@@ -76,7 +76,7 @@
 	  A comprehensive listing of all the software for Linux amateur radio
 	  users as well as information about how to configure an AX.25 port is
 	  contained in the AX25-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>. You also might want to
+	  <http://www.tldp.org/docs.html#howto>. You also might want to
 	  check out the file <file:Documentation/networking/ax25.txt>. More
 	  information about digital amateur radio in general is on the WWW at
 	  <http://www.tapr.org/tapr/html/pkthome.html>.
@@ -97,7 +97,7 @@
 	  A comprehensive listing of all the software for Linux amateur radio
 	  users as well as information about how to configure an AX.25 port is
 	  contained in the AX25-HOWTO, available from
-	  <http://www.linuxdoc.org/docs.html#howto>.  You also might want to
+	  <http://www.tldp.org/docs.html#howto>.  You also might want to
 	  check out the file <file:Documentation/networking/ax25.txt>. More
 	  information about digital amateur radio in general is on the WWW at
 	  <http://www.tapr.org/tapr/html/pkthome.html>.
diff -Nru a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
--- a/net/ax25/af_ax25.c	Wed Apr 30 22:28:17 2003
+++ b/net/ax25/af_ax25.c	Wed Apr 30 22:28:17 2003
@@ -68,8 +68,6 @@
 	}
 
 	kfree(ax25);
-
-	MOD_DEC_USE_COUNT;
 }
 
 static void ax25_free_sock(struct sock *sk)
@@ -507,8 +505,6 @@
 	if ((ax25 = kmalloc(sizeof(*ax25), GFP_ATOMIC)) == NULL)
 		return NULL;
 
-	MOD_INC_USE_COUNT;
-
 	memset(ax25, 0x00, sizeof(*ax25));
 
 	skb_queue_head_init(&ax25->write_queue);
@@ -1912,6 +1908,7 @@
 static struct net_proto_family ax25_family_ops = {
 	.family =	PF_AX25,
 	.create =	ax25_create,
+	.owner	=	THIS_MODULE,
 };
 
 static struct proto_ops ax25_proto_ops = {
diff -Nru a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
--- a/net/bluetooth/af_bluetooth.c	Wed Apr 30 22:28:05 2003
+++ b/net/bluetooth/af_bluetooth.c	Wed Apr 30 22:28:05 2003
@@ -321,6 +321,7 @@
 }
 
 struct net_proto_family bt_sock_family_ops = {
+	.owner  = THIS_MODULE,
 	.family	= PF_BLUETOOTH,
 	.create	= bt_sock_create,
 };
diff -Nru a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
--- a/net/bluetooth/bnep/core.c	Wed Apr 30 22:28:12 2003
+++ b/net/bluetooth/bnep/core.c	Wed Apr 30 22:28:12 2003
@@ -536,7 +536,7 @@
 
 	memset(dev->broadcast, 0xff, ETH_ALEN);
 	
-	/* This is rx header therefor addresses are swaped.
+	/* This is rx header therefore addresses are swapped.
 	 * ie eh.h_dest is our local address. */
 	memcpy(s->eh.h_dest,   &src, ETH_ALEN);
 	memcpy(s->eh.h_source, &dst, ETH_ALEN);
diff -Nru a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
--- a/net/bluetooth/hci_conn.c	Wed Apr 30 22:28:19 2003
+++ b/net/bluetooth/hci_conn.c	Wed Apr 30 22:28:19 2003
@@ -71,6 +71,7 @@
 
 	memset(&cp, 0, sizeof(cp));
 	bacpy(&cp.bdaddr, &conn->dst);
+	cp.pscan_rep_mode = 0x01;
 
 	if ((ie = inquiry_cache_lookup(hdev, &conn->dst)) &&
 			inquiry_entry_age(ie) <= INQUIRY_ENTRY_AGE_MAX) {
diff -Nru a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
--- a/net/bluetooth/hci_event.c	Wed Apr 30 22:28:03 2003
+++ b/net/bluetooth/hci_event.c	Wed Apr 30 22:28:03 2003
@@ -520,7 +520,7 @@
 			hci_send_cmd(hdev, OGF_LINK_POLICY, OCF_WRITE_LINK_POLICY, sizeof(cp), &cp);
 		}
 
-		/* Set packet type for incomming connection */
+		/* Set packet type for incoming connection */
 		if (!conn->out) {
 			struct hci_cp_change_conn_ptype cp;
 			cp.handle = ev->handle;
diff -Nru a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
--- a/net/bluetooth/hci_sock.c	Wed Apr 30 22:28:10 2003
+++ b/net/bluetooth/hci_sock.c	Wed Apr 30 22:28:10 2003
@@ -161,8 +161,6 @@
 	skb_queue_purge(&sk->write_queue);
 
 	sock_put(sk);
-
-	MOD_DEC_USE_COUNT;
 	return 0;
 }
 
@@ -591,8 +589,6 @@
 	sk->state   = BT_OPEN;
 
 	bt_sock_link(&hci_sk_list, sk);
-
-	MOD_INC_USE_COUNT;
 	return 0;
 }
 
diff -Nru a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
--- a/net/bluetooth/l2cap.c	Wed Apr 30 22:28:12 2003
+++ b/net/bluetooth/l2cap.c	Wed Apr 30 22:28:12 2003
@@ -1039,7 +1039,7 @@
 		sk->state = BT_CONNECTED;
 		sk->state_change(sk);
 	} else {
-		/* Incomming channel.
+		/* Incoming channel.
 		 * Wake up socket sleeping on accept.
 		 */
 		parent->data_ready(parent, 0);
@@ -1788,7 +1788,7 @@
 		if (sk->state != BT_LISTEN)
 			continue;
 
-		if (!bacmp(&bt_sk(sk)->src, bdaddr)) {
+		if (!bacmp(&bt_sk(sk)->src, &hdev->bdaddr)) {
 			lm1 |= (HCI_LM_ACCEPT | l2cap_pi(sk)->link_mode);
 			exact++;
 		} else if (!bacmp(&bt_sk(sk)->src, BDADDR_ANY))
diff -Nru a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
--- a/net/bluetooth/rfcomm/core.c	Wed Apr 30 22:28:03 2003
+++ b/net/bluetooth/rfcomm/core.c	Wed Apr 30 22:28:03 2003
@@ -798,6 +798,33 @@
 	return rfcomm_send_frame(s, buf, ptr - buf);
 }
 
+static int rfcomm_send_rls(struct rfcomm_session *s, int cr, u8 dlci, u8 status)
+{
+	struct rfcomm_hdr *hdr;
+	struct rfcomm_mcc *mcc;
+	struct rfcomm_rls *rls;
+	u8 buf[16], *ptr = buf;
+
+	BT_DBG("%p cr %d status 0x%x", s, cr, status);
+
+	hdr = (void *) ptr; ptr += sizeof(*hdr);
+	hdr->addr = __addr(s->initiator, 0);
+	hdr->ctrl = __ctrl(RFCOMM_UIH, 0);
+	hdr->len  = __len8(sizeof(*mcc) + sizeof(*rls));
+
+	mcc = (void *) ptr; ptr += sizeof(*mcc);
+	mcc->type = __mcc_type(cr, RFCOMM_RLS);
+	mcc->len  = __len8(sizeof(*rls));
+
+	rls = (void *) ptr; ptr += sizeof(*rls);
+	rls->dlci   = __addr(1, dlci);
+	rls->status = status;
+
+	*ptr = __fcs(buf); ptr++;
+
+	return rfcomm_send_frame(s, buf, ptr - buf);
+}
+
 static int rfcomm_send_msc(struct rfcomm_session *s, int cr, u8 dlci, u8 v24_sig)
 {
 	struct rfcomm_hdr *hdr;
@@ -1040,7 +1067,7 @@
 		return 0;
 	}
 
-	/* Notify socket layer about incomming connection */
+	/* Notify socket layer about incoming connection */
 	channel = __srv_channel(dlci);
 	if (rfcomm_connect_ind(s, channel, &d)) {
 		d->dlci = dlci;
@@ -1123,7 +1150,7 @@
 			return 0;
 		
 		/* PN request for non existing DLC.
-		 * Assume incomming connection. */
+		 * Assume incoming connection. */
 		if (rfcomm_connect_ind(s, channel, &d)) {
 			d->dlci = dlci;
 			d->addr = __addr(s->initiator, dlci);
@@ -1229,6 +1256,26 @@
 	return 0;
 }
 
+static int rfcomm_recv_rls(struct rfcomm_session *s, int cr, struct sk_buff *skb)
+{
+	struct rfcomm_rls *rls = (void *) skb->data;
+	u8 dlci = __get_dlci(rls->dlci);
+
+	BT_DBG("dlci %d cr %d status 0x%x", dlci, cr, rls->status);
+	
+	if (!cr)
+		return 0;
+
+	/* FIXME: We should probably do something with this
+	   information here. But for now it's sufficient just
+	   to reply -- Bluetooth 1.1 says it's mandatory to 
+	   recognise and respond to RLS */
+
+	rfcomm_send_rls(s, 0, dlci, rls->status);
+
+	return 0;
+}
+
 static int rfcomm_recv_msc(struct rfcomm_session *s, int cr, struct sk_buff *skb)
 {
 	struct rfcomm_msc *msc = (void *) skb->data;
@@ -1279,6 +1326,10 @@
 		rfcomm_recv_rpn(s, cr, len, skb);
 		break;
 
+	case RFCOMM_RLS:
+		rfcomm_recv_rls(s, cr, skb);
+		break;
+
 	case RFCOMM_MSC:
 		rfcomm_recv_msc(s, cr, skb);
 		break;
@@ -1432,9 +1483,9 @@
 			d->rx_credits = d->credits;
 		}
 	} else {
-		/* CFC disabled. 
+		/* CFC disabled.
 		 * Give ourselves some credits */
-		d->tx_credits = RFCOMM_MAX_CREDITS;
+		d->tx_credits = 5;
 	}
 
 	if (test_bit(RFCOMM_TX_THROTTLED, &d->flags))
@@ -1600,14 +1651,15 @@
 	BT_DBG("");
 
 	while (!atomic_read(&terminate)) {
-		if (!test_and_clear_bit(RFCOMM_SCHED_WAKEUP, &rfcomm_event)) {
+		if (!test_bit(RFCOMM_SCHED_WAKEUP, &rfcomm_event)) {
 			/* No pending events. Let's sleep.
-			 * Incomming connections and data will wake us up. */
+			 * Incoming connections and data will wake us up. */
 			set_current_state(TASK_INTERRUPTIBLE);
 			schedule();
 		}
 
 		/* Process stuff */
+		clear_bit(RFCOMM_SCHED_WAKEUP, &rfcomm_event);
 		rfcomm_process_sessions();
 	}
 	set_current_state(TASK_RUNNING);
diff -Nru a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
--- a/net/bluetooth/rfcomm/tty.c	Wed Apr 30 22:28:10 2003
+++ b/net/bluetooth/rfcomm/tty.c	Wed Apr 30 22:28:10 2003
@@ -72,7 +72,6 @@
 	struct tasklet_struct   wakeup_task;
 
 	atomic_t 		wmem_alloc;
-	unsigned int 		sndbuf;
 };
 
 static LIST_HEAD(rfcomm_dev_list);
@@ -200,8 +199,6 @@
 	dev->flags = req->flags & 
 		((1 << RFCOMM_RELEASE_ONHUP) | (1 << RFCOMM_REUSE_DLC));
 
-	dev->sndbuf = RFCOMM_MAX_CREDITS * RFCOMM_DEFAULT_MTU * 10;
-
 	init_waitqueue_head(&dev->wait);
 	tasklet_init(&dev->wakeup_task, rfcomm_tty_wakeup, (unsigned long) dev);
 
@@ -238,6 +235,13 @@
 }
 
 /* ---- Send buffer ---- */
+static inline unsigned int rfcomm_room(struct rfcomm_dlc *dlc)
+{
+	/* We can't let it be zero, because we don't get a callback
+	   when tx_credits becomes nonzero, hence we'd never wake up */
+	return dlc->mtu * (dlc->tx_credits?:1);
+}
+
 static void rfcomm_wfree(struct sk_buff *skb)
 {
 	struct rfcomm_dev *dev = (void *) skb->sk;
@@ -257,7 +261,7 @@
 
 static struct sk_buff *rfcomm_wmalloc(struct rfcomm_dev *dev, unsigned long size, int priority)
 {
-	if (atomic_read(&dev->wmem_alloc) < dev->sndbuf) {
+	if (atomic_read(&dev->wmem_alloc) < rfcomm_room(dev->dlc)) {
 		struct sk_buff *skb = alloc_skb(size, priority);
 		if (skb) {
 			rfcomm_set_owner_w(skb, dev);
@@ -532,7 +536,7 @@
 	struct rfcomm_dlc *dlc;
 	int err, id;
 
-        id = minor(tty->device) - tty->driver.minor_start;
+        id = tty->index;
 
 	BT_DBG("tty %p id %d", tty, id);
 
@@ -651,11 +655,14 @@
 static int rfcomm_tty_write_room(struct tty_struct *tty)
 {
 	struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
-	struct rfcomm_dlc *dlc = dev->dlc;
+	int room;
 
 	BT_DBG("tty %p", tty);
 
-	return dlc->mtu * (dlc->tx_credits ? : 10);
+	room = rfcomm_room(dev->dlc) - atomic_read(&dev->wmem_alloc);
+	if (room < 0)
+		room = 0;
+	return room;
 }
 
 static int rfcomm_tty_set_modem_status(uint cmd, struct rfcomm_dlc *dlc, uint status)
@@ -849,10 +856,12 @@
 static struct termios *rfcomm_tty_termios_locked[RFCOMM_TTY_PORTS];
 
 static struct tty_driver rfcomm_tty_driver = {
+	.owner			= THIS_MODULE,
+
 	.magic			= TTY_DRIVER_MAGIC,
 	.driver_name		= "rfcomm",
 #ifdef CONFIG_DEVFS_FS
-	.name			= "bluetooth/rfcomm/%d",
+	.name			= "bluetooth/rfcomm/",
 #else
 	.name			= "rfcomm",
 #endif
@@ -890,7 +899,7 @@
 {
 	int i;
 
-	/* Initalize our global data */
+	/* Initialize our global data */
 	for (i = 0; i < RFCOMM_TTY_PORTS; i++)
 		rfcomm_tty_table[i] = NULL;
 
diff -Nru a/net/bridge/br_device.c b/net/bridge/br_device.c
--- a/net/bridge/br_device.c	Wed Apr 30 22:28:03 2003
+++ b/net/bridge/br_device.c	Wed Apr 30 22:28:03 2003
@@ -74,27 +74,20 @@
 
 int br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-	struct net_bridge *br;
 	int ret;
 
-	br = dev->priv;
-	read_lock(&br->lock);
+	rcu_read_lock();
 	ret = __br_dev_xmit(skb, dev);
-	read_unlock(&br->lock);
+	rcu_read_unlock();
 
 	return ret;
 }
 
 static int br_dev_open(struct net_device *dev)
 {
-	struct net_bridge *br;
-
 	netif_start_queue(dev);
 
-	br = dev->priv;
-	write_lock(&br->lock);
-	br_stp_enable_bridge(br);
-	write_unlock(&br->lock);
+	br_stp_enable_bridge(dev->priv);
 
 	return 0;
 }
@@ -105,12 +98,7 @@
 
 static int br_dev_stop(struct net_device *dev)
 {
-	struct net_bridge *br;
-
-	br = dev->priv;
-	write_lock(&br->lock);
-	br_stp_disable_bridge(br);
-	write_unlock(&br->lock);
+	br_stp_disable_bridge(dev->priv);
 
 	netif_stop_queue(dev);
 
diff -Nru a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
--- a/net/bridge/br_fdb.c	Wed Apr 30 22:28:04 2003
+++ b/net/bridge/br_fdb.c	Wed Apr 30 22:28:04 2003
@@ -41,15 +41,15 @@
 	return 0;
 }
 
-static __inline__ void copy_fdb(struct __fdb_entry *ent, struct net_bridge_fdb_entry *f)
+static __inline__ void copy_fdb(struct __fdb_entry *ent, 
+				const struct net_bridge_fdb_entry *f)
 {
 	memset(ent, 0, sizeof(struct __fdb_entry));
 	memcpy(ent->mac_addr, f->addr.addr, ETH_ALEN);
 	ent->port_no = f->dst?f->dst->port_no:0;
 	ent->is_local = f->is_local;
-	ent->ageing_timer_value = 0;
-	if (!f->is_static)
-		ent->ageing_timer_value = jiffies - f->ageing_timer;
+	ent->ageing_timer_value = f->is_static ? 0 
+		: ((jiffies - f->ageing_timer) * USER_HZ) / HZ;
 }
 
 static __inline__ int br_mac_hash(unsigned char *mac)
@@ -68,28 +68,6 @@
 	return x & (BR_HASH_SIZE - 1);
 }
 
-static __inline__ void __hash_link(struct net_bridge *br,
-				   struct net_bridge_fdb_entry *ent,
-				   int hash)
-{
-	ent->next_hash = br->hash[hash];
-	if (ent->next_hash != NULL)
-		ent->next_hash->pprev_hash = &ent->next_hash;
-	br->hash[hash] = ent;
-	ent->pprev_hash = &br->hash[hash];
-}
-
-static __inline__ void __hash_unlink(struct net_bridge_fdb_entry *ent)
-{
-	*(ent->pprev_hash) = ent->next_hash;
-	if (ent->next_hash != NULL)
-		ent->next_hash->pprev_hash = ent->pprev_hash;
-	ent->next_hash = NULL;
-	ent->pprev_hash = NULL;
-}
-
-
-
 void br_fdb_changeaddr(struct net_bridge_port *p, unsigned char *newaddr)
 {
 	struct net_bridge *br;
@@ -99,22 +77,24 @@
 	br = p->br;
 	write_lock_bh(&br->hash_lock);
 	for (i=0;i<BR_HASH_SIZE;i++) {
-		struct net_bridge_fdb_entry *f;
+		struct hlist_node *h;
+		
+		hlist_for_each(h, &br->hash[i]) {
+			struct net_bridge_fdb_entry *f
+				= hlist_entry(h, struct net_bridge_fdb_entry, hlist);
 
-		f = br->hash[i];
-		while (f != NULL) {
 			if (f->dst == p && f->is_local) {
 				memcpy(f->addr.addr, newaddr, ETH_ALEN);
 				if (newhash != i) {
-					__hash_unlink(f);
-					__hash_link(br, f, newhash);
+					hlist_del(&f->hlist);
+					hlist_add_head(&f->hlist,
+						       &br->hash[newhash]);
 				}
-				write_unlock_bh(&br->hash_lock);
-				return;
+				goto out;
 			}
-			f = f->next_hash;
 		}
 	}
+ out:
 	write_unlock_bh(&br->hash_lock);
 }
 
@@ -127,19 +107,16 @@
 
 	write_lock_bh(&br->hash_lock);
 	for (i=0;i<BR_HASH_SIZE;i++) {
-		struct net_bridge_fdb_entry *f;
-
-		f = br->hash[i];
-		while (f != NULL) {
-			struct net_bridge_fdb_entry *g;
-
-			g = f->next_hash;
+		struct hlist_node *h, *g;
+		
+		hlist_for_each_safe(h, g, &br->hash[i]) {
+			struct net_bridge_fdb_entry *f
+				= hlist_entry(h, struct net_bridge_fdb_entry, hlist);
 			if (!f->is_static &&
 			    time_before_eq(f->ageing_timer, timeout)) {
-				__hash_unlink(f);
+				hlist_del(&f->hlist);
 				br_fdb_put(f);
 			}
-			f = g;
 		}
 	}
 	write_unlock_bh(&br->hash_lock);
@@ -151,18 +128,15 @@
 
 	write_lock_bh(&br->hash_lock);
 	for (i=0;i<BR_HASH_SIZE;i++) {
-		struct net_bridge_fdb_entry *f;
-
-		f = br->hash[i];
-		while (f != NULL) {
-			struct net_bridge_fdb_entry *g;
-
-			g = f->next_hash;
+		struct hlist_node *h, *g;
+		
+		hlist_for_each_safe(h, g, &br->hash[i]) {
+			struct net_bridge_fdb_entry *f
+				= hlist_entry(h, struct net_bridge_fdb_entry, hlist);
 			if (f->dst == p) {
-				__hash_unlink(f);
+				hlist_del(&f->hlist);
 				br_fdb_put(f);
 			}
-			f = g;
 		}
 	}
 	write_unlock_bh(&br->hash_lock);
@@ -170,25 +144,24 @@
 
 struct net_bridge_fdb_entry *br_fdb_get(struct net_bridge *br, unsigned char *addr)
 {
-	struct net_bridge_fdb_entry *fdb;
+	struct hlist_node *h;
 
 	read_lock_bh(&br->hash_lock);
-	fdb = br->hash[br_mac_hash(addr)];
-	while (fdb != NULL) {
+		
+	hlist_for_each(h, &br->hash[br_mac_hash(addr)]) {
+		struct net_bridge_fdb_entry *fdb
+			= hlist_entry(h, struct net_bridge_fdb_entry, hlist);
+
 		if (!memcmp(fdb->addr.addr, addr, ETH_ALEN)) {
-			if (!has_expired(br, fdb)) {
-				atomic_inc(&fdb->use_count);
-				read_unlock_bh(&br->hash_lock);
-				return fdb;
-			}
+			if (has_expired(br, fdb))
+				goto ret_null;
 
+			atomic_inc(&fdb->use_count);
 			read_unlock_bh(&br->hash_lock);
-			return NULL;
+			return fdb;
 		}
-
-		fdb = fdb->next_hash;
 	}
-
+ ret_null:
 	read_unlock_bh(&br->hash_lock);
 	return NULL;
 }
@@ -213,12 +186,16 @@
 
 	read_lock_bh(&br->hash_lock);
 	for (i=0;i<BR_HASH_SIZE;i++) {
-		struct net_bridge_fdb_entry *f;
-
-		for (f = br->hash[i]; f != NULL && num < maxnum;
-		     f = f->next_hash) {
+		struct hlist_node *h;
+		
+		hlist_for_each(h, &br->hash[i]) {
+			struct net_bridge_fdb_entry *f
+				= hlist_entry(h, struct net_bridge_fdb_entry, hlist);
 			struct __fdb_entry ent;
 
+			if (num >= maxnum)
+				goto out;
+
 			if (has_expired(br, f)) 
 				continue;
 
@@ -277,14 +254,15 @@
 		   unsigned char *addr,
 		   int is_local)
 {
+	struct hlist_node *h;
 	struct net_bridge_fdb_entry *fdb;
 	int hash;
 
 	hash = br_mac_hash(addr);
 
 	write_lock_bh(&br->hash_lock);
-	fdb = br->hash[hash];
-	while (fdb != NULL) {
+	hlist_for_each(h, &br->hash[hash]) {
+		fdb = hlist_entry(h, struct net_bridge_fdb_entry, hlist);
 		if (!fdb->is_local &&
 		    !memcmp(fdb->addr.addr, addr, ETH_ALEN)) {
 			__fdb_possibly_replace(fdb, source, is_local);
@@ -292,7 +270,6 @@
 			return;
 		}
 
-		fdb = fdb->next_hash;
 	}
 
 	fdb = kmalloc(sizeof(*fdb), GFP_ATOMIC);
@@ -308,7 +285,7 @@
 	fdb->is_static = is_local;
 	fdb->ageing_timer = jiffies;
 
-	__hash_link(br, fdb, hash);
+	hlist_add_head(&fdb->hlist, &br->hash[hash]);
 
 	write_unlock_bh(&br->hash_lock);
 }
diff -Nru a/net/bridge/br_forward.c b/net/bridge/br_forward.c
--- a/net/bridge/br_forward.c	Wed Apr 30 22:28:07 2003
+++ b/net/bridge/br_forward.c	Wed Apr 30 22:28:07 2003
@@ -21,7 +21,8 @@
 #include <linux/netfilter_bridge.h>
 #include "br_private.h"
 
-static inline int should_deliver(struct net_bridge_port *p, struct sk_buff *skb)
+static inline int should_deliver(const struct net_bridge_port *p, 
+				 const struct sk_buff *skb)
 {
 	if (skb->dev == p->dev ||
 	    p->state != BR_STATE_FORWARDING)
@@ -52,7 +53,7 @@
 	return 0;
 }
 
-static void __br_deliver(struct net_bridge_port *to, struct sk_buff *skb)
+static void __br_deliver(const struct net_bridge_port *to, struct sk_buff *skb)
 {
 	skb->dev = to->dev;
 #ifdef CONFIG_NETFILTER_DEBUG
@@ -62,7 +63,7 @@
 			br_forward_finish);
 }
 
-static void __br_forward(struct net_bridge_port *to, struct sk_buff *skb)
+static void __br_forward(const struct net_bridge_port *to, struct sk_buff *skb)
 {
 	struct net_device *indev;
 
@@ -73,8 +74,8 @@
 			br_forward_finish);
 }
 
-/* called under bridge lock */
-void br_deliver(struct net_bridge_port *to, struct sk_buff *skb)
+/* called with rcu_read_lock */
+void br_deliver(const struct net_bridge_port *to, struct sk_buff *skb)
 {
 	if (should_deliver(to, skb)) {
 		__br_deliver(to, skb);
@@ -84,8 +85,8 @@
 	kfree_skb(skb);
 }
 
-/* called under bridge lock */
-void br_forward(struct net_bridge_port *to, struct sk_buff *skb)
+/* called with rcu_read_lock */
+void br_forward(const struct net_bridge_port *to, struct sk_buff *skb)
 {
 	if (should_deliver(to, skb)) {
 		__br_forward(to, skb);
@@ -97,7 +98,8 @@
 
 /* called under bridge lock */
 static void br_flood(struct net_bridge *br, struct sk_buff *skb, int clone,
-	void (*__packet_hook)(struct net_bridge_port *p, struct sk_buff *skb))
+	void (*__packet_hook)(const struct net_bridge_port *p, 
+			      struct sk_buff *skb))
 {
 	struct net_bridge_port *p;
 	struct net_bridge_port *prev;
@@ -115,8 +117,7 @@
 
 	prev = NULL;
 
-	p = br->port_list;
-	while (p != NULL) {
+	list_for_each_entry_rcu(p, &br->port_list, list) {
 		if (should_deliver(p, skb)) {
 			if (prev != NULL) {
 				struct sk_buff *skb2;
@@ -132,8 +133,6 @@
 
 			prev = p;
 		}
-
-		p = p->next;
 	}
 
 	if (prev != NULL) {
@@ -144,7 +143,8 @@
 	kfree_skb(skb);
 }
 
-/* called under bridge lock */
+
+/* called with rcu_read_lock */
 void br_flood_deliver(struct net_bridge *br, struct sk_buff *skb, int clone)
 {
 	br_flood(br, skb, clone, __br_deliver);
diff -Nru a/net/bridge/br_if.c b/net/bridge/br_if.c
--- a/net/bridge/br_if.c	Wed Apr 30 22:28:19 2003
+++ b/net/bridge/br_if.c	Wed Apr 30 22:28:19 2003
@@ -18,8 +18,8 @@
 #include <linux/if_bridge.h>
 #include <linux/inetdevice.h>
 #include <linux/module.h>
+#include <linux/init.h>
 #include <linux/rtnetlink.h>
-#include <linux/brlock.h>
 #include <net/sock.h>
 #include <asm/uaccess.h>
 #include "br_private.h"
@@ -38,45 +38,39 @@
 	return 100;
 }
 
-/* called under BR_NETPROTO_LOCK and bridge lock */
-static int __br_del_if(struct net_bridge *br, struct net_device *dev)
+static void destroy_nbp(void *arg)
 {
-	struct net_bridge_port *p;
-	struct net_bridge_port **pptr;
+	struct net_bridge_port *p = arg;
+	dev_put(p->dev);
+	kfree(p);
+}
 
-	if ((p = dev->br_port) == NULL)
-		return -EINVAL;
+/* called under bridge lock */
+static void del_nbp(struct net_bridge_port *p)
+{
+	struct net_device *dev = p->dev;
 
 	br_stp_disable_port(p);
 
 	dev_set_promiscuity(dev, -1);
 	dev->br_port = NULL;
 
-	pptr = &br->port_list;
-	while (*pptr != NULL) {
-		if (*pptr == p) {
-			*pptr = p->next;
-			break;
-		}
-
-		pptr = &((*pptr)->next);
-	}
+	list_del_rcu(&p->list);
 
-	br_fdb_delete_by_port(br, p);
-	kfree(p);
-	dev_put(dev);
+	br_fdb_delete_by_port(p->br, p);
 
-	return 0;
+	call_rcu(&p->rcu, destroy_nbp, p);
 }
 
 static void del_ifs(struct net_bridge *br)
 {
-	br_write_lock_bh(BR_NETPROTO_LOCK);
-	write_lock(&br->lock);
-	while (br->port_list != NULL)
-		__br_del_if(br, br->port_list->dev);
-	write_unlock(&br->lock);
-	br_write_unlock_bh(BR_NETPROTO_LOCK);
+	struct list_head *p, *n;
+
+	spin_lock_bh(&br->lock);
+	list_for_each_safe(p, n, &br->port_list) {
+		del_nbp(list_entry(p, struct net_bridge_port, list));
+	}
+	spin_unlock_bh(&br->lock);
 }
 
 static struct net_bridge *new_nb(const char *name)
@@ -98,7 +92,8 @@
 	ether_setup(dev);
 	br_dev_setup(dev);
 
-	br->lock = RW_LOCK_UNLOCKED;
+	br->lock = SPIN_LOCK_UNLOCKED;
+	INIT_LIST_HEAD(&br->port_list);
 	br->hash_lock = RW_LOCK_UNLOCKED;
 
 	br->bridge_id.prio[0] = 0x80;
@@ -155,8 +150,7 @@
 	br_init_port(p);
 	p->state = BR_STATE_DISABLED;
 
-	p->next = br->port_list;
-	br->port_list = p;
+	list_add_rcu(&p->list, &br->port_list);
 
 	return p;
 }
@@ -218,9 +212,9 @@
 		return -ELOOP;
 
 	dev_hold(dev);
-	write_lock_bh(&br->lock);
+	spin_lock_bh(&br->lock);
 	if ((p = new_nbp(br, dev)) == NULL) {
-		write_unlock_bh(&br->lock);
+		spin_unlock_bh(&br->lock);
 		dev_put(dev);
 		return -EXFULL;
 	}
@@ -231,21 +225,24 @@
 	br_fdb_insert(br, p, dev->dev_addr, 1);
 	if ((br->dev.flags & IFF_UP) && (dev->flags & IFF_UP))
 		br_stp_enable_port(p);
-	write_unlock_bh(&br->lock);
+	spin_unlock_bh(&br->lock);
 
 	return 0;
 }
 
 int br_del_if(struct net_bridge *br, struct net_device *dev)
 {
-	int retval;
+	struct net_bridge_port *p;
+	int retval = 0;
 
-	br_write_lock_bh(BR_NETPROTO_LOCK);
-	write_lock(&br->lock);
-	retval = __br_del_if(br, dev);
-	br_stp_recalculate_bridge_id(br);
-	write_unlock(&br->lock);
-	br_write_unlock_bh(BR_NETPROTO_LOCK);
+	spin_lock_bh(&br->lock);
+	if ((p = dev->br_port) == NULL || p->br != br)
+		retval = -EINVAL;
+	else {
+		del_nbp(p);
+		br_stp_recalculate_bridge_id(br);
+	}
+	spin_unlock_bh(&br->lock);
 
 	return retval;
 }
@@ -269,13 +266,11 @@
 {
 	struct net_bridge_port *p;
 
-	read_lock(&br->lock);
-	p = br->port_list;
-	while (p != NULL) {
+	rcu_read_lock();
+	list_for_each_entry_rcu(p, &br->port_list, list) {
 		ifindices[p->port_no] = p->dev->ifindex;
-		p = p->next;
 	}
-	read_unlock(&br->lock);
+	rcu_read_unlock();
 }
 
 
diff -Nru a/net/bridge/br_input.c b/net/bridge/br_input.c
--- a/net/bridge/br_input.c	Wed Apr 30 22:28:06 2003
+++ b/net/bridge/br_input.c	Wed Apr 30 22:28:06 2003
@@ -59,15 +59,16 @@
 
 	dest = skb->mac.ethernet->h_dest;
 
+	rcu_read_lock();
 	p = skb->dev->br_port;
-	if (p == NULL)
-		goto err_nolock;
+	smp_read_barrier_depends();
 
-	br = p->br;
-	read_lock(&br->lock);
-	if (skb->dev->br_port == NULL)
-		goto err;
+	if (p == NULL || p->state == BR_STATE_DISABLED) {
+		kfree(skb);
+		goto out;
+	}
 
+	br = p->br;
 	passedup = 0;
 	if (br->dev.flags & IFF_PROMISC) {
 		struct sk_buff *skb2;
@@ -105,35 +106,20 @@
 	br_flood_forward(br, skb, 0);
 
 out:
-	read_unlock(&br->lock);
-	return 0;
-
-err:
-	read_unlock(&br->lock);
-err_nolock:
-	kfree_skb(skb);
+	rcu_read_unlock();
 	return 0;
 }
 
 int br_handle_frame(struct sk_buff *skb)
 {
-	struct net_bridge *br;
 	unsigned char *dest;
 	struct net_bridge_port *p;
 
 	dest = skb->mac.ethernet->h_dest;
 
+	rcu_read_lock();
 	p = skb->dev->br_port;
-	if (p == NULL)
-		goto err_nolock;
-
-	br = p->br;
-	read_lock(&br->lock);
-	if (skb->dev->br_port == NULL)
-		goto err;
-
-	if (!(br->dev.flags & IFF_UP) ||
-	    p->state == BR_STATE_DISABLED)
+	if (p == NULL || p->state == BR_STATE_DISABLED)
 		goto err;
 
 	if (skb->mac.ethernet->h_source[0] & 1)
@@ -141,39 +127,30 @@
 
 	if (p->state == BR_STATE_LEARNING ||
 	    p->state == BR_STATE_FORWARDING)
-		br_fdb_insert(br, p, skb->mac.ethernet->h_source, 0);
+		br_fdb_insert(p->br, p, skb->mac.ethernet->h_source, 0);
 
-	if (br->stp_enabled &&
+	if (p->br->stp_enabled &&
 	    !memcmp(dest, bridge_ula, 5) &&
-	    !(dest[5] & 0xF0))
-		goto handle_special_frame;
+	    !(dest[5] & 0xF0)) {
+		if (!dest[5]) 
+			br_stp_handle_bpdu(skb);
+		goto err;
+	}
 
 	if (p->state == BR_STATE_FORWARDING) {
 		if (br_should_route_hook && br_should_route_hook(&skb)) {
-			read_unlock(&br->lock);
+			rcu_read_unlock();
 			return -1;
 		}
 
 		NF_HOOK(PF_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
 			br_handle_frame_finish);
-		read_unlock(&br->lock);
+		rcu_read_unlock();
 		return 0;
 	}
 
 err:
-	read_unlock(&br->lock);
-err_nolock:
-	kfree_skb(skb);
-	return 0;
-
-handle_special_frame:
-	if (!dest[5]) {
-		br_stp_handle_bpdu(skb);
-		read_unlock(&br->lock);
-		return 0;
-	}
-
+	rcu_read_unlock();
 	kfree_skb(skb);
-	read_unlock(&br->lock);
 	return 0;
 }
diff -Nru a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c
--- a/net/bridge/br_ioctl.c	Wed Apr 30 22:28:04 2003
+++ b/net/bridge/br_ioctl.c	Wed Apr 30 22:28:04 2003
@@ -19,6 +19,24 @@
 #include <asm/uaccess.h>
 #include "br_private.h"
 
+/* import values in USER_HZ  */
+static inline unsigned long user_to_ticks(unsigned long utick)
+{
+	return (utick * HZ) / USER_HZ;
+}
+
+/* export values in USER_HZ */
+static inline unsigned long ticks_to_user(unsigned long tick)
+{
+	return (tick * USER_HZ) / HZ;
+}
+
+/* Report time remaining in user HZ  */
+static unsigned long timer_residue(const struct br_timer *timer)
+{
+	return ticks_to_user(timer->running ? (jiffies - timer->expires) : 0);
+}
+
 static int br_ioctl_device(struct net_bridge *br,
 			   unsigned int cmd,
 			   unsigned long arg0,
@@ -53,28 +71,28 @@
 	{
 		struct __bridge_info b;
 
-	        read_lock(&br->lock);
 		memset(&b, 0, sizeof(struct __bridge_info));
+		rcu_read_lock();
 		memcpy(&b.designated_root, &br->designated_root, 8);
 		memcpy(&b.bridge_id, &br->bridge_id, 8);
 		b.root_path_cost = br->root_path_cost;
-		b.max_age = br->max_age;
-		b.hello_time = br->hello_time;
+		b.max_age = ticks_to_user(br->max_age);
+		b.hello_time = ticks_to_user(br->hello_time);
 		b.forward_delay = br->forward_delay;
 		b.bridge_max_age = br->bridge_max_age;
 		b.bridge_hello_time = br->bridge_hello_time;
-		b.bridge_forward_delay = br->bridge_forward_delay;
+		b.bridge_forward_delay = ticks_to_user(br->bridge_forward_delay);
 		b.topology_change = br->topology_change;
 		b.topology_change_detected = br->topology_change_detected;
 		b.root_port = br->root_port;
 		b.stp_enabled = br->stp_enabled;
-		b.ageing_time = br->ageing_time;
-		b.gc_interval = br->gc_interval;
-		b.hello_timer_value = br_timer_get_residue(&br->hello_timer);
-		b.tcn_timer_value = br_timer_get_residue(&br->tcn_timer);
-		b.topology_change_timer_value = br_timer_get_residue(&br->topology_change_timer);
-		b.gc_timer_value = br_timer_get_residue(&br->gc_timer);
-	        read_unlock(&br->lock);
+		b.ageing_time = ticks_to_user(br->ageing_time);
+		b.gc_interval = ticks_to_user(br->gc_interval);
+		b.hello_timer_value = timer_residue(&br->hello_timer);
+		b.tcn_timer_value = timer_residue(&br->tcn_timer);
+		b.topology_change_timer_value = timer_residue(&br->topology_change_timer);
+		b.gc_timer_value = timer_residue(&br->gc_timer);
+	        rcu_read_unlock();
 
 		if (copy_to_user((void *)arg0, &b, sizeof(b)))
 			return -EFAULT;
@@ -101,35 +119,35 @@
 	}
 
 	case BRCTL_SET_BRIDGE_FORWARD_DELAY:
-		write_lock(&br->lock);
-		br->bridge_forward_delay = arg0;
+		spin_lock_bh(&br->lock);
+		br->bridge_forward_delay = user_to_ticks(arg0);
 		if (br_is_root_bridge(br))
-			br->forward_delay = arg0;
-		write_unlock(&br->lock);
+			br->forward_delay = br->bridge_forward_delay;
+		spin_unlock_bh(&br->lock);
 		return 0;
 
 	case BRCTL_SET_BRIDGE_HELLO_TIME:
-		write_lock(&br->lock);
-		br->bridge_hello_time = arg0;
+		spin_lock_bh(&br->lock);
+		br->bridge_hello_time = user_to_ticks(arg0);
 		if (br_is_root_bridge(br))
-			br->hello_time = arg0;
-		write_unlock(&br->lock);
+			br->hello_time = br->bridge_hello_time;
+		spin_unlock_bh(&br->lock);
 		return 0;
 
 	case BRCTL_SET_BRIDGE_MAX_AGE:
-		write_lock(&br->lock);
-		br->bridge_max_age = arg0;
+		spin_lock_bh(&br->lock);
+		br->bridge_max_age = user_to_ticks(arg0);
 		if (br_is_root_bridge(br))
-			br->max_age = arg0;
-		write_unlock(&br->lock);
+			br->max_age = br->bridge_max_age;
+		spin_unlock_bh(&br->lock);
 		return 0;
 
 	case BRCTL_SET_AGEING_TIME:
-		br->ageing_time = arg0;
+		br->ageing_time = user_to_ticks(arg0);
 		return 0;
 
 	case BRCTL_SET_GC_INTERVAL:
-		br->gc_interval = arg0;
+		br->gc_interval = user_to_ticks(arg0);
 		return 0;
 
 	case BRCTL_GET_PORT_INFO:
@@ -137,9 +155,11 @@
 		struct __port_info p;
 		struct net_bridge_port *pt;
 
-		read_lock(&br->lock);
-		if ((pt = br_get_port(br, arg1)) == NULL)
+		rcu_read_lock();
+		if ((pt = br_get_port(br, arg1)) == NULL) {
+			rcu_read_unlock();
 			return -EINVAL;
+		}
 
 		memset(&p, 0, sizeof(struct __port_info));
 		memcpy(&p.designated_root, &pt->designated_root, 8);
@@ -151,11 +171,11 @@
 		p.state = pt->state;
 		p.top_change_ack = pt->topology_change_ack;
 		p.config_pending = pt->config_pending;
-		p.message_age_timer_value = br_timer_get_residue(&pt->message_age_timer);
-		p.forward_delay_timer_value = br_timer_get_residue(&pt->forward_delay_timer);
-		p.hold_timer_value = br_timer_get_residue(&pt->hold_timer);
+		p.message_age_timer_value = timer_residue(&pt->message_age_timer);
+		p.forward_delay_timer_value = timer_residue(&pt->forward_delay_timer);
+		p.hold_timer_value = timer_residue(&pt->hold_timer);
 
-		read_unlock(&br->lock);
+		rcu_read_unlock();
 
 		if (copy_to_user((void *)arg0, &p, sizeof(p)))
 			return -EFAULT;
@@ -168,33 +188,37 @@
 		return 0;
 
 	case BRCTL_SET_BRIDGE_PRIORITY:
-		write_lock(&br->lock);
+		spin_lock_bh(&br->lock);
 		br_stp_set_bridge_priority(br, arg0);
-		write_unlock(&br->lock);
+		spin_unlock_bh(&br->lock);
 		return 0;
 
 	case BRCTL_SET_PORT_PRIORITY:
 	{
 		struct net_bridge_port *p;
+		int ret = 0;
 
-		write_lock(&br->lock);
-		if ((p = br_get_port(br, arg0)) == NULL)
-			return -EINVAL;
-		br_stp_set_port_priority(p, arg1);
-		write_unlock(&br->lock);
-		return 0;
+		spin_lock_bh(&br->lock);
+		if ((p = br_get_port(br, arg0)) == NULL) 
+			ret = -EINVAL;
+		else
+			br_stp_set_port_priority(p, arg1);
+		spin_unlock_bh(&br->lock);
+		return ret;
 	}
 
 	case BRCTL_SET_PATH_COST:
 	{
 		struct net_bridge_port *p;
+		int ret = 0;
 
-		write_lock(&br->lock);
+		spin_lock_bh(&br->lock);
 		if ((p = br_get_port(br, arg0)) == NULL)
-			return -EINVAL;
-		br_stp_set_path_cost(p, arg1);
-		write_unlock(&br->lock);
-		return 0;
+			ret = -EINVAL;
+		else
+			br_stp_set_path_cost(p, arg1);
+		spin_unlock_bh(&br->lock);
+		return ret;
 	}
 
 	case BRCTL_GET_FDB_ENTRIES:
diff -Nru a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
--- a/net/bridge/br_netfilter.c	Wed Apr 30 22:28:18 2003
+++ b/net/bridge/br_netfilter.c	Wed Apr 30 22:28:18 2003
@@ -350,6 +350,7 @@
 		nf_bridge->mask |= BRNF_PKT_TYPE;
 	}
 
+	nf_bridge->mask |= BRNF_BRIDGED; /* The physdev module checks on this */
 	nf_bridge->physoutdev = skb->dev;
 
 	NF_HOOK(PF_INET, NF_IP_FORWARD, skb, bridge_parent(nf_bridge->physindev),
@@ -572,15 +573,51 @@
  * ip_refrag() can return NF_STOLEN.
  */
 static struct nf_hook_ops br_nf_ops[] = {
-	{ { NULL, NULL }, br_nf_pre_routing, PF_BRIDGE, NF_BR_PRE_ROUTING, NF_BR_PRI_BRNF },
-	{ { NULL, NULL }, br_nf_local_in, PF_BRIDGE, NF_BR_LOCAL_IN, NF_BR_PRI_BRNF },
-	{ { NULL, NULL }, br_nf_forward, PF_BRIDGE, NF_BR_FORWARD, NF_BR_PRI_BRNF },
-	{ { NULL, NULL }, br_nf_local_out, PF_BRIDGE, NF_BR_LOCAL_OUT, NF_BR_PRI_FIRST },
-	{ { NULL, NULL }, br_nf_post_routing, PF_BRIDGE, NF_BR_POST_ROUTING, NF_BR_PRI_LAST },
-	{ { NULL, NULL }, ipv4_sabotage_in, PF_INET, NF_IP_PRE_ROUTING, NF_IP_PRI_FIRST },
-	{ { NULL, NULL }, ipv4_sabotage_out, PF_INET, NF_IP_FORWARD, NF_IP_PRI_BRIDGE_SABOTAGE_FORWARD },
-	{ { NULL, NULL }, ipv4_sabotage_out, PF_INET, NF_IP_LOCAL_OUT, NF_IP_PRI_BRIDGE_SABOTAGE_LOCAL_OUT },
-	{ { NULL, NULL }, ipv4_sabotage_out, PF_INET, NF_IP_POST_ROUTING, NF_IP_PRI_FIRST }
+	{ .hook = br_nf_pre_routing, 
+	  .owner = THIS_MODULE, 
+	  .pf = PF_BRIDGE, 
+	  .hooknum = NF_BR_PRE_ROUTING, 
+	  .priority = NF_BR_PRI_BRNF, },
+	{ .hook = br_nf_local_in,
+	  .owner = THIS_MODULE,
+	  .pf = PF_BRIDGE,
+	  .hooknum = NF_BR_LOCAL_IN,
+	  .priority = NF_BR_PRI_BRNF, },
+	{ .hook = br_nf_forward,
+	  .owner = THIS_MODULE,
+	  .pf = PF_BRIDGE,
+	  .hooknum = NF_BR_FORWARD,
+	  .priority = NF_BR_PRI_BRNF, },
+	{ .hook = br_nf_local_out,
+	  .owner = THIS_MODULE,
+	  .pf = PF_BRIDGE,
+	  .hooknum = NF_BR_LOCAL_OUT,
+	  .priority = NF_BR_PRI_FIRST, },
+	{ .hook = br_nf_post_routing,
+	  .owner = THIS_MODULE,
+	  .pf = PF_BRIDGE,
+	  .hooknum = NF_BR_POST_ROUTING,
+	  .priority = NF_BR_PRI_LAST, },
+	{ .hook = ipv4_sabotage_in,
+	  .owner = THIS_MODULE,
+	  .pf = PF_INET,
+	  .hooknum = NF_IP_PRE_ROUTING,
+	  .priority = NF_IP_PRI_FIRST, },
+	{ .hook = ipv4_sabotage_out,
+	  .owner = THIS_MODULE,
+	  .pf = PF_INET,
+	  .hooknum = NF_IP_FORWARD,
+	  .priority = NF_IP_PRI_BRIDGE_SABOTAGE_FORWARD, },
+	{ .hook = ipv4_sabotage_out,
+	  .owner = THIS_MODULE,
+	  .pf = PF_INET,
+	  .hooknum = NF_IP_LOCAL_OUT,
+	  .priority = NF_IP_PRI_BRIDGE_SABOTAGE_LOCAL_OUT, },
+	{ .hook = ipv4_sabotage_out,
+	  .owner = THIS_MODULE,
+	  .pf = PF_INET,
+	  .hooknum = NF_IP_POST_ROUTING,
+	  .priority = NF_IP_PRI_FIRST, },
 };
 
 #define NUMHOOKS (sizeof(br_nf_ops)/sizeof(br_nf_ops[0]))
diff -Nru a/net/bridge/br_notify.c b/net/bridge/br_notify.c
--- a/net/bridge/br_notify.c	Wed Apr 30 22:28:04 2003
+++ b/net/bridge/br_notify.c	Wed Apr 30 22:28:04 2003
@@ -41,10 +41,10 @@
 	switch (event) 
 	{
 	case NETDEV_CHANGEADDR:
-		write_lock_bh(&br->lock);
+		spin_lock_bh(&br->lock);
 		br_fdb_changeaddr(p, dev->dev_addr);
 		br_stp_recalculate_bridge_id(br);
-		write_unlock_bh(&br->lock);
+		spin_unlock_bh(&br->lock);
 		break;
 
 	case NETDEV_GOING_DOWN:
@@ -53,17 +53,17 @@
 
 	case NETDEV_DOWN:
 		if (br->dev.flags & IFF_UP) {
-			write_lock_bh(&br->lock);
+			spin_lock_bh(&br->lock);
 			br_stp_disable_port(p);
-			write_unlock_bh(&br->lock);
+			spin_unlock_bh(&br->lock);
 		}
 		break;
 
 	case NETDEV_UP:
 		if (!(br->dev.flags & IFF_UP)) {
-			write_lock_bh(&br->lock);
+			spin_lock_bh(&br->lock);
 			br_stp_enable_port(p);
-			write_unlock_bh(&br->lock);
+			spin_unlock_bh(&br->lock);
 		}
 		break;
 
diff -Nru a/net/bridge/br_private.h b/net/bridge/br_private.h
--- a/net/bridge/br_private.h	Wed Apr 30 22:28:05 2003
+++ b/net/bridge/br_private.h	Wed Apr 30 22:28:05 2003
@@ -43,8 +43,7 @@
 
 struct net_bridge_fdb_entry
 {
-	struct net_bridge_fdb_entry	*next_hash;
-	struct net_bridge_fdb_entry	**pprev_hash;
+	struct hlist_node		hlist;
 	atomic_t			use_count;
 	mac_addr			addr;
 	struct net_bridge_port		*dst;
@@ -55,9 +54,9 @@
 
 struct net_bridge_port
 {
-	struct net_bridge_port		*next;
 	struct net_bridge		*br;
 	struct net_device		*dev;
+	struct list_head		list;
 	int				port_no;
 
 	/* STP */
@@ -75,16 +74,18 @@
 	struct br_timer			forward_delay_timer;
 	struct br_timer			hold_timer;
 	struct br_timer			message_age_timer;
+
+	struct rcu_head			rcu;
 };
 
 struct net_bridge
 {
-	rwlock_t			lock;
-	struct net_bridge_port		*port_list;
+	spinlock_t			lock;
+	struct list_head		port_list;
 	struct net_device		dev;
 	struct net_device_stats		statistics;
 	rwlock_t			hash_lock;
-	struct net_bridge_fdb_entry	*hash[BR_HASH_SIZE];
+	struct hlist_head		hash[BR_HASH_SIZE];
 	struct timer_list		tick;
 
 	/* STP */
@@ -114,6 +115,13 @@
 extern struct notifier_block br_device_notifier;
 extern unsigned char bridge_ula[6];
 
+/* called under bridge lock */
+static inline int br_is_root_bridge(const struct net_bridge *br)
+{
+	return !memcmp(&br->bridge_id, &br->designated_root, 8);
+}
+
+
 /* br_device.c */
 extern void br_dev_setup(struct net_device *dev);
 extern int br_dev_xmit(struct sk_buff *skb, struct net_device *dev);
@@ -137,10 +145,10 @@
 		   int is_local);
 
 /* br_forward.c */
-extern void br_deliver(struct net_bridge_port *to,
+extern void br_deliver(const struct net_bridge_port *to,
 		struct sk_buff *skb);
 extern int br_dev_queue_push_xmit(struct sk_buff *skb);
-extern void br_forward(struct net_bridge_port *to,
+extern void br_forward(const struct net_bridge_port *to,
 		struct sk_buff *skb);
 extern int br_forward_finish(struct sk_buff *skb);
 extern void br_flood_deliver(struct net_bridge *br,
@@ -180,7 +188,6 @@
 extern void br_netfilter_fini(void);
 
 /* br_stp.c */
-extern int br_is_root_bridge(struct net_bridge *br);
 extern struct net_bridge_port *br_get_port(struct net_bridge *br,
 				    int port_no);
 extern void br_init_port(struct net_bridge_port *p);
diff -Nru a/net/bridge/br_private_stp.h b/net/bridge/br_private_stp.h
--- a/net/bridge/br_private_stp.h	Wed Apr 30 22:28:10 2003
+++ b/net/bridge/br_private_stp.h	Wed Apr 30 22:28:10 2003
@@ -32,12 +32,18 @@
 	int		forward_delay;
 };
 
+/* called under bridge lock */
+static inline int br_is_designated_port(const struct net_bridge_port *p)
+{
+	return !memcmp(&p->designated_bridge, &p->br->bridge_id, 8) &&
+		(p->designated_port == p->port_id);
+}
+
+
 /* br_stp.c */
 extern void br_become_root_bridge(struct net_bridge *br);
 extern void br_config_bpdu_generation(struct net_bridge *);
 extern void br_configuration_update(struct net_bridge *);
-extern int  br_is_designated_port(struct net_bridge_port *p);
-extern int  br_is_root_bridge(struct net_bridge *br);
 extern void br_port_state_selection(struct net_bridge *);
 extern void br_received_config_bpdu(struct net_bridge_port *p, struct br_config_bpdu *bpdu);
 extern void br_received_tcn_bpdu(struct net_bridge_port *p);
diff -Nru a/net/bridge/br_stp.c b/net/bridge/br_stp.c
--- a/net/bridge/br_stp.c	Wed Apr 30 22:28:05 2003
+++ b/net/bridge/br_stp.c	Wed Apr 30 22:28:05 2003
@@ -20,32 +20,14 @@
 #include "br_private.h"
 #include "br_private_stp.h"
 
-
-
-/* called under ioctl_lock or bridge lock */
-int br_is_root_bridge(struct net_bridge *br)
-{
-	return !memcmp(&br->bridge_id, &br->designated_root, 8);
-}
-
 /* called under bridge lock */
-int br_is_designated_port(struct net_bridge_port *p)
-{
-	return !memcmp(&p->designated_bridge, &p->br->bridge_id, 8) &&
-		(p->designated_port == p->port_id);
-}
-
-/* called under ioctl_lock or bridge lock */
 struct net_bridge_port *br_get_port(struct net_bridge *br, int port_no)
 {
 	struct net_bridge_port *p;
 
-	p = br->port_list;
-	while (p != NULL) {
+	list_for_each_entry_rcu(p, &br->port_list, list) {
 		if (p->port_no == port_no)
 			return p;
-
-		p = p->next;
 	}
 
 	return NULL;
@@ -109,12 +91,10 @@
 
 	root_port = 0;
 
-	p = br->port_list;
-	while (p != NULL) {
+	list_for_each_entry(p, &br->port_list, list) {
 		if (br_should_become_root_port(p, root_port))
 			root_port = p->port_no;
 
-		p = p->next;
 	}
 
 	br->root_port = root_port;
@@ -241,13 +221,11 @@
 {
 	struct net_bridge_port *p;
 
-	p = br->port_list;
-	while (p != NULL) {
+	list_for_each_entry(p, &br->port_list, list) {
 		if (p->state != BR_STATE_DISABLED &&
 		    br_should_become_designated_port(p))
 			br_become_designated_port(p);
 
-		p = p->next;
 	}
 }
 
@@ -313,13 +291,10 @@
 {
 	struct net_bridge_port *p;
 
-	p = br->port_list;
-	while (p != NULL) {
+	list_for_each_entry(p, &br->port_list, list) {
 		if (p->state != BR_STATE_DISABLED &&
 		    br_is_designated_port(p))
 			br_transmit_config(p);
-
-		p = p->next;
 	}
 }
 
@@ -391,8 +366,7 @@
 {
 	struct net_bridge_port *p;
 
-	p = br->port_list;
-	while (p != NULL) {
+	list_for_each_entry(p, &br->port_list, list) {
 		if (p->state != BR_STATE_DISABLED) {
 			if (p->port_no == br->root_port) {
 				p->config_pending = 0;
@@ -407,8 +381,6 @@
 				br_make_blocking(p);
 			}
 		}
-
-		p = p->next;
 	}
 }
 
@@ -419,18 +391,13 @@
 	br_transmit_config(p);
 }
 
-/* lock-safe */
+/* called under bridge lock */
 void br_received_config_bpdu(struct net_bridge_port *p, struct br_config_bpdu *bpdu)
 {
 	struct net_bridge *br;
 	int was_root;
 
-	if (p->state == BR_STATE_DISABLED)
-		return;
-
 	br = p->br;
-	read_lock(&br->lock);
-
 	was_root = br_is_root_bridge(br);
 	if (br_supersedes_port_info(p, bpdu)) {
 		br_record_config_information(p, bpdu);
@@ -455,21 +422,16 @@
 	} else if (br_is_designated_port(p)) {		
 		br_reply(p);		
 	}
-
-	read_unlock(&br->lock);
 }
 
-/* lock-safe */
+/* called under bridge lock */
 void br_received_tcn_bpdu(struct net_bridge_port *p)
 {
-	read_lock(&p->br->lock);
-	if (p->state != BR_STATE_DISABLED &&
-	    br_is_designated_port(p)) {
+	if (br_is_designated_port(p)) {
 		printk(KERN_INFO "%s: received tcn bpdu on port %i(%s)\n",
 		       p->br->dev.name, p->port_no, p->dev->name);
 
 		br_topology_change_detection(p->br);
 		br_topology_change_acknowledge(p);
 	}
-	read_unlock(&p->br->lock);
 }
diff -Nru a/net/bridge/br_stp_bpdu.c b/net/bridge/br_stp_bpdu.c
--- a/net/bridge/br_stp_bpdu.c	Wed Apr 30 22:28:15 2003
+++ b/net/bridge/br_stp_bpdu.c	Wed Apr 30 22:28:15 2003
@@ -132,18 +132,23 @@
 
 static unsigned char header[6] = {0x42, 0x42, 0x03, 0x00, 0x00, 0x00};
 
-/* called under bridge lock */
+/* NO locks */
 void br_stp_handle_bpdu(struct sk_buff *skb)
 {
 	unsigned char *buf;
 	struct net_bridge_port *p;
+	struct net_bridge *br;
 
 	buf = skb->mac.raw + 14;
 	p = skb->dev->br_port;
-	if (!p->br->stp_enabled || memcmp(buf, header, 6)) {
-		kfree_skb(skb);
-		return;
-	}
+	br = p->br;
+
+	spin_lock_bh(&br->lock);
+	if (p->state == BR_STATE_DISABLED 
+	    || !(br->dev.flags & IFF_UP)
+	    || !br->stp_enabled 
+	    || memcmp(buf, header, 6)) 
+		goto out;
 
 	if (buf[6] == BPDU_TYPE_CONFIG) {
 		struct br_config_bpdu bpdu;
@@ -178,16 +183,14 @@
 		bpdu.hello_time = br_get_ticks(buf+34);
 		bpdu.forward_delay = br_get_ticks(buf+36);
 
-		kfree_skb(skb);
 		br_received_config_bpdu(p, &bpdu);
-		return;
+		goto out;
 	}
 
 	if (buf[6] == BPDU_TYPE_TCN) {
 		br_received_tcn_bpdu(p);
-		kfree_skb(skb);
-		return;
+		goto out;
 	}
-
-	kfree_skb(skb);
+ out:
+	spin_unlock_bh(&br->lock);
 }
diff -Nru a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
--- a/net/bridge/br_stp_if.c	Wed Apr 30 22:28:16 2003
+++ b/net/bridge/br_stp_if.c	Wed Apr 30 22:28:16 2003
@@ -44,6 +44,7 @@
 	struct net_bridge_port *p;
 	struct timer_list *timer = &br->tick;
 
+	spin_lock_bh(&br->lock);
 	init_timer(timer);
 	timer->data = (unsigned long) br;
 	timer->function = br_tick;
@@ -53,22 +54,21 @@
 	br_timer_set(&br->hello_timer, jiffies);
 	br_config_bpdu_generation(br);
 
-	p = br->port_list;
-	while (p != NULL) {
+	list_for_each_entry(p, &br->port_list, list) {
 		if (p->dev->flags & IFF_UP)
 			br_stp_enable_port(p);
-
-		p = p->next;
 	}
 
 	br_timer_set(&br->gc_timer, jiffies);
+	spin_unlock_bh(&br->lock);
 }
 
-/* called under bridge lock */
+/* NO locks held */
 void br_stp_disable_bridge(struct net_bridge *br)
 {
 	struct net_bridge_port *p;
 
+	spin_lock_bh(&br->lock);
 	br->topology_change = 0;
 	br->topology_change_detected = 0;
 	br_timer_clear(&br->hello_timer);
@@ -77,13 +77,11 @@
 	br_timer_clear(&br->gc_timer);
 	br_fdb_cleanup(br);
 
-	p = br->port_list;
-	while (p != NULL) {
+	list_for_each_entry(p, &br->port_list, list) {
 		if (p->state != BR_STATE_DISABLED)
 			br_stp_disable_port(p);
-
-		p = p->next;
 	}
+	spin_unlock_bh(&br->lock);
 
 	del_timer_sync(&br->tick);
 }
@@ -133,15 +131,13 @@
 	memcpy(br->bridge_id.addr, addr, ETH_ALEN);
 	memcpy(br->dev.dev_addr, addr, ETH_ALEN);
 
-	p = br->port_list;
-	while (p != NULL) {
+	list_for_each_entry(p, &br->port_list, list) {
 		if (!memcmp(p->designated_bridge.addr, oldaddr, ETH_ALEN))
 			memcpy(p->designated_bridge.addr, addr, ETH_ALEN);
 
 		if (!memcmp(p->designated_root.addr, oldaddr, ETH_ALEN))
 			memcpy(p->designated_root.addr, addr, ETH_ALEN);
 
-		p = p->next;
 	}
 
 	br_configuration_update(br);
@@ -160,13 +156,11 @@
 
 	addr = br_mac_zero;
 
-	p = br->port_list;
-	while (p != NULL) {
+	list_for_each_entry(p, &br->port_list, list) {
 		if (addr == br_mac_zero ||
 		    memcmp(p->dev->dev_addr, addr, ETH_ALEN) < 0)
 			addr = p->dev->dev_addr;
 
-		p = p->next;
 	}
 
 	if (memcmp(br->bridge_id.addr, addr, ETH_ALEN))
@@ -181,15 +175,13 @@
 
 	wasroot = br_is_root_bridge(br);
 
-	p = br->port_list;
-	while (p != NULL) {
+	list_for_each_entry(p, &br->port_list, list) {
 		if (p->state != BR_STATE_DISABLED &&
 		    br_is_designated_port(p)) {
 			p->designated_bridge.prio[0] = (newprio >> 8) & 0xFF;
 			p->designated_bridge.prio[1] = newprio & 0xFF;
 		}
 
-		p = p->next;
 	}
 
 	br->bridge_id.prio[0] = (newprio >> 8) & 0xFF;
diff -Nru a/net/bridge/br_stp_timer.c b/net/bridge/br_stp_timer.c
--- a/net/bridge/br_stp_timer.c	Wed Apr 30 22:28:09 2003
+++ b/net/bridge/br_stp_timer.c	Wed Apr 30 22:28:09 2003
@@ -32,13 +32,10 @@
 {
 	struct net_bridge_port *p;
 
-	p = br->port_list;
-	while (p != NULL) {
+	list_for_each_entry(p, &br->port_list, list) {
 		if (p->state != BR_STATE_DISABLED &&
 		    !memcmp(&p->designated_bridge, &br->bridge_id, 8))
 			return 1;
-
-		p = p->next;
 	}
 
 	return 0;
@@ -162,12 +159,9 @@
 		br_topology_change_timer_expired(br);
 	}
 
-	p = br->port_list;
-	while (p != NULL) {
+	list_for_each_entry(p, &br->port_list, list) {
 		if (p->state != BR_STATE_DISABLED)
 			br_check_port_timers(p);
-
-		p = p->next;
 	}
 }
 
@@ -175,10 +169,10 @@
 {
 	struct net_bridge *br = (struct net_bridge *)__data;
 
-	read_lock(&br->lock);
-	br_check_timers(br);
-	read_unlock(&br->lock);
-
+	if (spin_trylock_bh(&br->lock)) {
+		br_check_timers(br);
+		spin_unlock_bh(&br->lock);
+	}
 	br->tick.expires = jiffies + 1;
 	add_timer(&br->tick);
 }
diff -Nru a/net/bridge/netfilter/ebt_vlan.c b/net/bridge/netfilter/ebt_vlan.c
--- a/net/bridge/netfilter/ebt_vlan.c	Wed Apr 30 22:28:10 2003
+++ b/net/bridge/netfilter/ebt_vlan.c	Wed Apr 30 22:28:10 2003
@@ -45,7 +45,7 @@
  * Function description: ebt_filter_vlan() is main engine for 
  * checking passed 802.1Q frame according to 
  * the passed extension parameters (in the *data buffer)
- * ebt_filter_vlan() is called after successfull check the rule params
+ * ebt_filter_vlan() is called after successful check the rule params
  * by ebt_check_vlan() function.
  * Parameters:
  * const struct sk_buff *skb - pointer to passed ethernet frame buffer
@@ -137,7 +137,7 @@
 	 */
 	if (datalen != sizeof(struct ebt_vlan_info)) {
 		DEBUG_MSG
-		    ("passed size %d is not eq to ebt_vlan_info (%d)\n",
+		    ("passed size %d is not eq to ebt_vlan_info (%Zd)\n",
 		     datalen, sizeof(struct ebt_vlan_info));
 		return -EINVAL;
 	}
diff -Nru a/net/bridge/netfilter/ebtable_filter.c b/net/bridge/netfilter/ebtable_filter.c
--- a/net/bridge/netfilter/ebtable_filter.c	Wed Apr 30 22:28:16 2003
+++ b/net/bridge/netfilter/ebtable_filter.c	Wed Apr 30 22:28:16 2003
@@ -70,18 +70,21 @@
 static struct nf_hook_ops ebt_ops_filter[] = {
 	{
 		.hook		= ebt_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_BRIDGE,
 		.hooknum	= NF_BR_LOCAL_IN,
 		.priority	= NF_BR_PRI_FILTER_BRIDGED,
 	},
 	{
 		.hook		= ebt_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_BRIDGE,
 		.hooknum	= NF_BR_FORWARD,
 		.priority	= NF_BR_PRI_FILTER_BRIDGED,
 	},
 	{
 		.hook		= ebt_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_BRIDGE,
 		.hooknum	= NF_BR_LOCAL_OUT,
 		.priority	= NF_BR_PRI_FILTER_OTHER,
diff -Nru a/net/bridge/netfilter/ebtable_nat.c b/net/bridge/netfilter/ebtable_nat.c
--- a/net/bridge/netfilter/ebtable_nat.c	Wed Apr 30 22:28:19 2003
+++ b/net/bridge/netfilter/ebtable_nat.c	Wed Apr 30 22:28:19 2003
@@ -76,18 +76,21 @@
 static struct nf_hook_ops ebt_ops_nat[] = {
 	{
 		.hook		= ebt_nat_dst,
+		.owner		= THIS_MODULE,
 		.pf		= PF_BRIDGE,
 		.hooknum	= NF_BR_LOCAL_OUT,
 		.priority	= NF_BR_PRI_NAT_DST_OTHER,
 	},
 	{
 		.hook		= ebt_nat_src,
+		.owner		= THIS_MODULE,
 		.pf		= PF_BRIDGE,
 		.hooknum	= NF_BR_POST_ROUTING,
 		.priority	= NF_BR_PRI_NAT_SRC,
 	},
 	{
 		.hook		= ebt_nat_dst,
+		.owner		= THIS_MODULE,
 		.pf		= PF_BRIDGE,
 		.hooknum	= NF_BR_PRE_ROUTING,
 		.priority	= NF_BR_PRI_NAT_DST_BRIDGED,
diff -Nru a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
--- a/net/bridge/netfilter/ebtables.c	Wed Apr 30 22:28:07 2003
+++ b/net/bridge/netfilter/ebtables.c	Wed Apr 30 22:28:07 2003
@@ -48,8 +48,8 @@
 	/* The tty for the current task */
 	my_tty = current->tty;
 	if (my_tty != NULL) {
-		(*(my_tty->driver).write)(my_tty, 0, str, strlen(str));
-		(*(my_tty->driver).write)(my_tty, 0, "\015\012", 2);
+		my_tty->driver->write(my_tty, 0, str, strlen(str));
+		my_tty->driver->write(my_tty, 0, "\015\012", 2);
 	}
 }
 
diff -Nru a/net/core/dev.c b/net/core/dev.c
--- a/net/core/dev.c	Wed Apr 30 22:28:09 2003
+++ b/net/core/dev.c	Wed Apr 30 22:28:09 2003
@@ -223,9 +223,9 @@
  *
  *	BEWARE!!! Protocol handlers, mangling input packets,
  *	MUST BE last in hash buckets and checking protocol handlers
- *	MUST start from promiscous ptype_all chain in net_bh.
+ *	MUST start from promiscuous ptype_all chain in net_bh.
  *	It is true now, do not change it.
- *	Explantion follows: if protocol handler, mangling packet, will
+ *	Explanation follows: if protocol handler, mangling packet, will
  *	be the first on list, it is not able to sense, that packet
  *	is cloned and should be copied-on-write, so that it will
  *	change it and subsequent readers will get broken packet.
@@ -1434,7 +1434,7 @@
 }
 
 #if defined(CONFIG_BRIDGE) || defined (CONFIG_BRIDGE_MODULE)
-int (*br_handle_frame_hook)(struct sk_buff *skb) = NULL;
+int (*br_handle_frame_hook)(struct sk_buff *skb);
 
 static __inline__ int handle_bridge(struct sk_buff *skb,
 				     struct packet_type *pt_prev)
@@ -2582,6 +2582,16 @@
 	if ((ret = kobject_register(&dev->kobj)))
 		goto out_err;
 	
+	/* Fix illegal SG+CSUM combinations. */
+	if ((dev->features & NETIF_F_SG) &&
+	    !(dev->features & (NETIF_F_IP_CSUM |
+			       NETIF_F_NO_CSUM |
+			       NETIF_F_HW_CSUM))) {
+		printk("%s: Dropping NETIF_F_SG since no checksum feature.\n",
+		       dev->name);
+		dev->features &= ~NETIF_F_SG;
+	}
+
 	/*
 	 *	nil rebuild_header routine,
 	 *	that should be never called and used as just bug trap.
diff -Nru a/net/core/dst.c b/net/core/dst.c
--- a/net/core/dst.c	Wed Apr 30 22:28:11 2003
+++ b/net/core/dst.c	Wed Apr 30 22:28:11 2003
@@ -252,9 +252,7 @@
 }
 
 struct notifier_block dst_dev_notifier = {
-	dst_dev_event,
-	NULL,
-	0
+	.notifier_call	= dst_dev_event,
 };
 
 void __init dst_init(void)
diff -Nru a/net/core/link_watch.c b/net/core/link_watch.c
--- a/net/core/link_watch.c	Wed Apr 30 22:28:03 2003
+++ b/net/core/link_watch.c	Wed Apr 30 22:28:03 2003
@@ -30,8 +30,8 @@
 	LW_SE_USED
 };
 
-static unsigned long linkwatch_flags = 0;
-static unsigned long linkwatch_nextevent = 0;
+static unsigned long linkwatch_flags;
+static unsigned long linkwatch_nextevent;
 
 static void linkwatch_event(void *dummy);
 static DECLARE_WORK(linkwatch_work, linkwatch_event, NULL);
diff -Nru a/net/core/neighbour.c b/net/core/neighbour.c
--- a/net/core/neighbour.c	Wed Apr 30 22:28:04 2003
+++ b/net/core/neighbour.c	Wed Apr 30 22:28:04 2003
@@ -1473,141 +1473,141 @@
 } neigh_sysctl_template = {
 	.neigh_vars = {
 		{
-			.ctl_name =	NET_NEIGH_MCAST_SOLICIT,
-			.procname =	"mcast_solicit",
-			.maxlen =		sizeof(int),
-			.mode =	0644,
-			.proc_handler =&proc_dointvec,
+			.ctl_name	= NET_NEIGH_MCAST_SOLICIT,
+			.procname	= "mcast_solicit",
+			.maxlen		= sizeof(int),
+			.mode		= 0644,
+			.proc_handler	= &proc_dointvec,
 		},
 		{
-			.ctl_name =	NET_NEIGH_UCAST_SOLICIT,
-			.procname =	"ucast_solicit",
-			.maxlen =		sizeof(int),
-			.mode =	0644,
-			.proc_handler =&proc_dointvec,
+			.ctl_name	= NET_NEIGH_UCAST_SOLICIT,
+			.procname	= "ucast_solicit",
+			.maxlen		= sizeof(int),
+			.mode		= 0644,
+			.proc_handler	= &proc_dointvec,
 		},
 		{
-			.ctl_name =	NET_NEIGH_APP_SOLICIT,
-			.procname =	"app_solicit",
-			.maxlen =		sizeof(int),
-			.mode =	0644,
-			.proc_handler =&proc_dointvec,
+			.ctl_name	= NET_NEIGH_APP_SOLICIT,
+			.procname	= "app_solicit",
+			.maxlen		= sizeof(int),
+			.mode		= 0644,
+			.proc_handler	= &proc_dointvec,
 		},
 		{
-			.ctl_name =	NET_NEIGH_RETRANS_TIME,
-			.procname =	"retrans_time",
-			.maxlen =		sizeof(int),
-			.mode =	0644,
-			.proc_handler =&proc_dointvec,
+			.ctl_name	= NET_NEIGH_RETRANS_TIME,
+			.procname	= "retrans_time",
+			.maxlen		= sizeof(int),
+			.mode		= 0644,
+			.proc_handler	= &proc_dointvec,
 		},
 		{
-			.ctl_name =	NET_NEIGH_REACHABLE_TIME,
-			.procname =	"base_reachable_time",
-			.maxlen =		sizeof(int),
-			.mode =	0644,
-			.proc_handler =&proc_dointvec_jiffies,
+			.ctl_name	= NET_NEIGH_REACHABLE_TIME,
+			.procname	= "base_reachable_time",
+			.maxlen		= sizeof(int),
+			.mode		= 0644,
+			.proc_handler	= &proc_dointvec_jiffies,
 		},
 		{
-			.ctl_name =	NET_NEIGH_DELAY_PROBE_TIME,
-			.procname =	"delay_first_probe_time",
-			.maxlen =		sizeof(int),
-			.mode =	0644,
-			.proc_handler =&proc_dointvec_jiffies,
+			.ctl_name	= NET_NEIGH_DELAY_PROBE_TIME,
+			.procname	= "delay_first_probe_time",
+			.maxlen		= sizeof(int),
+			.mode		= 0644,
+			.proc_handler	= &proc_dointvec_jiffies,
 		},
 		{
-			.ctl_name =	NET_NEIGH_GC_STALE_TIME,
-			.procname =	"gc_stale_time",
-			.maxlen =		sizeof(int),
-			.mode =	0644,
-			.proc_handler =&proc_dointvec_jiffies,
+			.ctl_name	= NET_NEIGH_GC_STALE_TIME,
+			.procname	= "gc_stale_time",
+			.maxlen		= sizeof(int),
+			.mode		= 0644,
+			.proc_handler	= &proc_dointvec_jiffies,
 		},
 		{
-			.ctl_name =	NET_NEIGH_UNRES_QLEN,
-			.procname =	"unres_qlen",
-			.maxlen =		sizeof(int),
-			.mode =	0644,
-			.proc_handler =&proc_dointvec,
+			.ctl_name	= NET_NEIGH_UNRES_QLEN,
+			.procname	= "unres_qlen",
+			.maxlen		= sizeof(int),
+			.mode		= 0644,
+			.proc_handler	= &proc_dointvec,
 		},
 		{
-			.ctl_name =	NET_NEIGH_PROXY_QLEN,
-			.procname =	"proxy_qlen",
-			.maxlen =		sizeof(int),
-			.mode =	0644,
-			.proc_handler =&proc_dointvec,
+			.ctl_name	= NET_NEIGH_PROXY_QLEN,
+			.procname	= "proxy_qlen",
+			.maxlen		= sizeof(int),
+			.mode		= 0644,
+			.proc_handler	= &proc_dointvec,
 		},
 		{
-			.ctl_name =	NET_NEIGH_ANYCAST_DELAY,
-			.procname =	"anycast_delay",
-			.maxlen =		sizeof(int),
-			.mode =	0644,
-			.proc_handler =&proc_dointvec,
+			.ctl_name	= NET_NEIGH_ANYCAST_DELAY,
+			.procname	= "anycast_delay",
+			.maxlen		= sizeof(int),
+			.mode		= 0644,
+			.proc_handler	= &proc_dointvec,
 		},
 		{
-			.ctl_name =	NET_NEIGH_PROXY_DELAY,
-			.procname =	"proxy_delay",
-			.maxlen =		sizeof(int),
-			.mode =	0644,
-			.proc_handler =&proc_dointvec,
+			.ctl_name	= NET_NEIGH_PROXY_DELAY,
+			.procname	= "proxy_delay",
+			.maxlen		= sizeof(int),
+			.mode		= 0644,
+			.proc_handler	= &proc_dointvec,
 		},
 		{
-			.ctl_name =	NET_NEIGH_LOCKTIME,
-			.procname =	"locktime",
-			.maxlen =		sizeof(int),
-			.mode =	0644,
-			.proc_handler =&proc_dointvec,
+			.ctl_name	= NET_NEIGH_LOCKTIME,
+			.procname	= "locktime",
+			.maxlen		= sizeof(int),
+			.mode		= 0644,
+			.proc_handler	= &proc_dointvec,
 		},
 		{
-			.ctl_name =	NET_NEIGH_GC_INTERVAL,
-			.procname =	"gc_interval",
-			.maxlen =		sizeof(int),
-			.mode =	0644,
-			.proc_handler =&proc_dointvec_jiffies,
+			.ctl_name	= NET_NEIGH_GC_INTERVAL,
+			.procname	= "gc_interval",
+			.maxlen		= sizeof(int),
+			.mode		= 0644,
+			.proc_handler	= &proc_dointvec_jiffies,
 		},
 		{
-			.ctl_name =	NET_NEIGH_GC_THRESH1,
-			.procname =	"gc_thresh1",
-			.maxlen =		sizeof(int),
-			.mode =	0644,
-			.proc_handler =&proc_dointvec,
+			.ctl_name	= NET_NEIGH_GC_THRESH1,
+			.procname	= "gc_thresh1",
+			.maxlen		= sizeof(int),
+			.mode		= 0644,
+			.proc_handler	= &proc_dointvec,
 		},
 		{
-			.ctl_name =	NET_NEIGH_GC_THRESH2,
-			.procname =	"gc_thresh2",
-			.maxlen =		sizeof(int),
-			.mode =	0644,
-			.proc_handler =&proc_dointvec,
+			.ctl_name	= NET_NEIGH_GC_THRESH2,
+			.procname	= "gc_thresh2",
+			.maxlen		= sizeof(int),
+			.mode		= 0644,
+			.proc_handler	= &proc_dointvec,
 		},
 		{
-			.ctl_name =	NET_NEIGH_GC_THRESH3,
-			.procname =	"gc_thresh3",
-			.maxlen =		sizeof(int),
-			.mode =	0644,
-			.proc_handler =&proc_dointvec,
+			.ctl_name	= NET_NEIGH_GC_THRESH3,
+			.procname	= "gc_thresh3",
+			.maxlen		= sizeof(int),
+			.mode		= 0644,
+			.proc_handler	= &proc_dointvec,
 		},
 	},
 	.neigh_dev = {
 		{
-			.ctl_name =	NET_PROTO_CONF_DEFAULT,
-			.procname =	"default",
-			.mode =	0555,
+			.ctl_name	= NET_PROTO_CONF_DEFAULT,
+			.procname	= "default",
+			.mode		= 0555,
 		},
 	},
 	.neigh_neigh_dir = {
 		{
-			.procname =	"neigh",
-			.mode =	0555,
+			.procname	= "neigh",
+			.mode		= 0555,
 		},
 	},
 	.neigh_proto_dir = {
 		{
-			.mode =	0555,
+			.mode		= 0555,
 		},
 	},
 	.neigh_root_dir = {
 		{
-			.ctl_name =	CTL_NET,
-			.procname =	"net",
-			.mode =	0555,
+			.ctl_name	= CTL_NET,
+			.procname	= "net",
+			.mode		= 0555,
 		},
 	},
 };
diff -Nru a/net/core/netfilter.c b/net/core/netfilter.c
--- a/net/core/netfilter.c	Wed Apr 30 22:28:09 2003
+++ b/net/core/netfilter.c	Wed Apr 30 22:28:09 2003
@@ -19,7 +19,6 @@
 #include <linux/interrupt.h>
 #include <linux/if.h>
 #include <linux/netdevice.h>
-#include <linux/brlock.h>
 #include <linux/inetdevice.h>
 #include <net/sock.h>
 #include <net/route.h>
@@ -40,12 +39,13 @@
 #endif
 
 /* Sockopts only registered and called from user context, so
-   BR_NETPROTO_LOCK would be overkill.  Also, [gs]etsockopt calls may
+   net locking would be overkill.  Also, [gs]etsockopt calls may
    sleep. */
 static DECLARE_MUTEX(nf_sockopt_mutex);
 
 struct list_head nf_hooks[NPROTO][NF_MAX_HOOKS];
 static LIST_HEAD(nf_sockopts);
+static spinlock_t nf_hook_lock = SPIN_LOCK_UNLOCKED;
 
 /* 
  * A queue handler may be registered for each protocol.  Each is protected by
@@ -56,28 +56,31 @@
 	nf_queue_outfn_t outfn;
 	void *data;
 } queue_handler[NPROTO];
+static rwlock_t queue_handler_lock = RW_LOCK_UNLOCKED;
 
 int nf_register_hook(struct nf_hook_ops *reg)
 {
 	struct list_head *i;
 
-	br_write_lock_bh(BR_NETPROTO_LOCK);
-	for (i = nf_hooks[reg->pf][reg->hooknum].next; 
-	     i != &nf_hooks[reg->pf][reg->hooknum]; 
-	     i = i->next) {
+	spin_lock_bh(&nf_hook_lock);
+	list_for_each(i, &nf_hooks[reg->pf][reg->hooknum]) {
 		if (reg->priority < ((struct nf_hook_ops *)i)->priority)
 			break;
 	}
-	list_add(&reg->list, i->prev);
-	br_write_unlock_bh(BR_NETPROTO_LOCK);
+	list_add_rcu(&reg->list, i->prev);
+	spin_unlock_bh(&nf_hook_lock);
+
+	synchronize_net();
 	return 0;
 }
 
 void nf_unregister_hook(struct nf_hook_ops *reg)
 {
-	br_write_lock_bh(BR_NETPROTO_LOCK);
-	list_del(&reg->list);
-	br_write_unlock_bh(BR_NETPROTO_LOCK);
+	spin_lock_bh(&nf_hook_lock);
+	list_del_rcu(&reg->list);
+	spin_unlock_bh(&nf_hook_lock);
+
+	synchronize_net();
 }
 
 /* Do exclusive ranges overlap? */
@@ -344,12 +347,18 @@
 			       int (*okfn)(struct sk_buff *),
 			       int hook_thresh)
 {
-	for (*i = (*i)->next; *i != head; *i = (*i)->next) {
+	/*
+	 * The caller must not block between calls to this
+	 * function because of risk of continuing from deleted element.
+	 */
+	list_for_each_continue_rcu(*i, head) {
 		struct nf_hook_ops *elem = (struct nf_hook_ops *)*i;
 
 		if (hook_thresh > elem->priority)
 			continue;
 
+		/* Optimization: we don't need to hold module
+                   reference here, since function can't sleep. --RR */
 		switch (elem->hook(hook, skb, indev, outdev, okfn)) {
 		case NF_QUEUE:
 			return NF_QUEUE;
@@ -381,7 +390,7 @@
 {      
 	int ret;
 
-	br_write_lock_bh(BR_NETPROTO_LOCK);
+	write_lock_bh(&queue_handler_lock);
 	if (queue_handler[pf].outfn)
 		ret = -EBUSY;
 	else {
@@ -389,7 +398,7 @@
 		queue_handler[pf].data = data;
 		ret = 0;
 	}
-	br_write_unlock_bh(BR_NETPROTO_LOCK);
+	write_unlock_bh(&queue_handler_lock);
 
 	return ret;
 }
@@ -397,10 +406,11 @@
 /* The caller must flush their queue before this */
 int nf_unregister_queue_handler(int pf)
 {
-	br_write_lock_bh(BR_NETPROTO_LOCK);
+	write_lock_bh(&queue_handler_lock);
 	queue_handler[pf].outfn = NULL;
 	queue_handler[pf].data = NULL;
-	br_write_unlock_bh(BR_NETPROTO_LOCK);
+	write_unlock_bh(&queue_handler_lock);
+	
 	return 0;
 }
 
@@ -408,12 +418,12 @@
  * Any packet that leaves via this function must come back 
  * through nf_reinject().
  */
-static void nf_queue(struct sk_buff *skb, 
-		     struct list_head *elem, 
-		     int pf, unsigned int hook,
-		     struct net_device *indev,
-		     struct net_device *outdev,
-		     int (*okfn)(struct sk_buff *))
+static int nf_queue(struct sk_buff *skb, 
+		    struct list_head *elem, 
+		    int pf, unsigned int hook,
+		    struct net_device *indev,
+		    struct net_device *outdev,
+		    int (*okfn)(struct sk_buff *))
 {
 	int status;
 	struct nf_info *info;
@@ -422,9 +432,12 @@
 	struct net_device *physoutdev = NULL;
 #endif
 
+	/* QUEUE == DROP if noone is waiting, to be safe. */
+	read_lock(&queue_handler_lock);
 	if (!queue_handler[pf].outfn) {
+		read_unlock(&queue_handler_lock);
 		kfree_skb(skb);
-		return;
+		return 1;
 	}
 
 	info = kmalloc(sizeof(*info), GFP_ATOMIC);
@@ -432,13 +445,21 @@
 		if (net_ratelimit())
 			printk(KERN_ERR "OOM queueing packet %p\n",
 			       skb);
+		read_unlock(&queue_handler_lock);
 		kfree_skb(skb);
-		return;
+		return 1;
 	}
 
 	*info = (struct nf_info) { 
 		(struct nf_hook_ops *)elem, pf, hook, indev, outdev, okfn };
 
+	/* If it's going away, ignore hook. */
+	if (!try_module_get(info->elem->owner)) {
+		read_unlock(&queue_handler_lock);
+		kfree(info);
+		return 0;
+	}
+
 	/* Bump dev refs so they don't vanish while packet is out */
 	if (indev) dev_hold(indev);
 	if (outdev) dev_hold(outdev);
@@ -453,6 +474,8 @@
 #endif
 
 	status = queue_handler[pf].outfn(skb, info, queue_handler[pf].data);
+	read_unlock(&queue_handler_lock);
+
 	if (status < 0) {
 		/* James M doesn't say fuck enough. */
 		if (indev) dev_put(indev);
@@ -461,10 +484,12 @@
 		if (physindev) dev_put(physindev);
 		if (physoutdev) dev_put(physoutdev);
 #endif
+		module_put(info->elem->owner);
 		kfree(info);
 		kfree_skb(skb);
-		return;
+		return 1;
 	}
+	return 1;
 }
 
 int nf_hook_slow(int pf, unsigned int hook, struct sk_buff *skb,
@@ -486,7 +511,7 @@
 	}
 
 	/* We may already have this, but read-locks nest anyway */
-	br_read_lock_bh(BR_NETPROTO_LOCK);
+	rcu_read_lock();
 
 #ifdef CONFIG_NETFILTER_DEBUG
 	if (skb->nf_debug & (1 << hook)) {
@@ -497,11 +522,13 @@
 #endif
 
 	elem = &nf_hooks[pf][hook];
+ next_hook:
 	verdict = nf_iterate(&nf_hooks[pf][hook], &skb, hook, indev,
 			     outdev, &elem, okfn, hook_thresh);
 	if (verdict == NF_QUEUE) {
 		NFDEBUG("nf_hook: Verdict = QUEUE.\n");
-		nf_queue(skb, elem, pf, hook, indev, outdev, okfn);
+		if (!nf_queue(skb, elem, pf, hook, indev, outdev, okfn))
+			goto next_hook;
 	}
 
 	switch (verdict) {
@@ -515,7 +542,7 @@
 		break;
 	}
 
-	br_read_unlock_bh(BR_NETPROTO_LOCK);
+	rcu_read_unlock();
 	return ret;
 }
 
@@ -525,16 +552,21 @@
 	struct list_head *elem = &info->elem->list;
 	struct list_head *i;
 
-	/* We don't have BR_NETPROTO_LOCK here */
-	br_read_lock_bh(BR_NETPROTO_LOCK);
-	for (i = nf_hooks[info->pf][info->hook].next; i != elem; i = i->next) {
-		if (i == &nf_hooks[info->pf][info->hook]) {
-			/* The module which sent it to userspace is gone. */
-			NFDEBUG("%s: module disappeared, dropping packet.\n",
-			         __FUNCTION__);
-			verdict = NF_DROP;
-			break;
-		}
+	rcu_read_lock();
+
+	/* Drop reference to owner of hook which queued us. */
+	module_put(info->elem->owner);
+
+	list_for_each_rcu(i, &nf_hooks[info->pf][info->hook]) {
+		if (i == elem) 
+  			break;
+  	}
+  
+	if (elem == &nf_hooks[info->pf][info->hook]) {
+		/* The module which sent it to userspace is gone. */
+		NFDEBUG("%s: module disappeared, dropping packet.\n",
+			__FUNCTION__);
+		verdict = NF_DROP;
 	}
 
 	/* Continue traversal iff userspace said ok... */
@@ -544,6 +576,7 @@
 	}
 
 	if (verdict == NF_ACCEPT) {
+	next_hook:
 		verdict = nf_iterate(&nf_hooks[info->pf][info->hook],
 				     &skb, info->hook, 
 				     info->indev, info->outdev, &elem,
@@ -556,15 +589,12 @@
 		break;
 
 	case NF_QUEUE:
-		nf_queue(skb, elem, info->pf, info->hook, 
-			 info->indev, info->outdev, info->okfn);
-		break;
-
-	case NF_DROP:
-		kfree_skb(skb);
+		if (!nf_queue(skb, elem, info->pf, info->hook, 
+			      info->indev, info->outdev, info->okfn))
+			goto next_hook;
 		break;
 	}
-	br_read_unlock_bh(BR_NETPROTO_LOCK);
+	rcu_read_unlock();
 
 	/* Release those devices we held, or Alexey will kill me. */
 	if (info->indev) dev_put(info->indev);
@@ -577,6 +607,10 @@
 			dev_put(skb->nf_bridge->physoutdev);
 	}
 #endif
+
+
+	if (verdict == NF_DROP)
+		kfree_skb(skb);
 
 	kfree(info);
 	return;
diff -Nru a/net/core/pktgen.c b/net/core/pktgen.c
--- a/net/core/pktgen.c	Wed Apr 30 22:28:12 2003
+++ b/net/core/pktgen.c	Wed Apr 30 22:28:12 2003
@@ -198,8 +198,8 @@
 
 /* Module parameters, defaults. */
 static int count_d = 100000;
-static int ipg_d = 0;
-static int clone_skb_d = 0;
+static int ipg_d;
+static int clone_skb_d;
 
 
 #define MAX_PKTGEN 8
@@ -220,7 +220,7 @@
 }
 
 #define PG_PROC_DIR "pktgen"
-static struct proc_dir_entry *proc_dir = 0;
+static struct proc_dir_entry *proc_dir;
 
 static struct net_device *setup_inject(struct pktgen_info* info)
 {
diff -Nru a/net/core/profile.c b/net/core/profile.c
--- a/net/core/profile.c	Wed Apr 30 22:28:19 2003
+++ b/net/core/profile.c	Wed Apr 30 22:28:19 2003
@@ -160,7 +160,9 @@
 		TIMER_INITIALIZER(whitehole_inject, 0, 0);
 
 static struct net_device whitehole_dev = {
-	"whitehole", 0x0, 0x0, 0x0, 0x0, 0, 0, 0, 0, 0, NULL, whitehole_init, };
+	.name	= "whitehole",
+	.init	= whitehole_init,
+};
 
 static int whitehole_open(struct net_device *dev)
 {
diff -Nru a/net/core/rtnetlink.c b/net/core/rtnetlink.c
--- a/net/core/rtnetlink.c	Wed Apr 30 22:28:20 2003
+++ b/net/core/rtnetlink.c	Wed Apr 30 22:28:20 2003
@@ -539,9 +539,7 @@
 }
 
 struct notifier_block rtnetlink_dev_notifier = {
-	rtnetlink_event,
-	NULL,
-	0
+	.notifier_call	= rtnetlink_event,
 };
 
 
diff -Nru a/net/core/skbuff.c b/net/core/skbuff.c
--- a/net/core/skbuff.c	Wed Apr 30 22:28:13 2003
+++ b/net/core/skbuff.c	Wed Apr 30 22:28:13 2003
@@ -20,6 +20,7 @@
  *		Ray VanTassle	:	Fixed --skb->lock in free
  *		Alan Cox	:	skb_copy copy arp field
  *		Andi Kleen	:	slabified it.
+ *		Robert Olsson	:	Removed skb_head_pool
  *
  *	NOTE:
  *		The __skb_ routines should be called with interrupts
@@ -63,15 +64,8 @@
 #include <asm/uaccess.h>
 #include <asm/system.h>
 
-int sysctl_hot_list_len = 128;
-
 static kmem_cache_t *skbuff_head_cache;
 
-static union {
-	struct sk_buff_head	list;
-	char			pad[SMP_CACHE_BYTES];
-} skb_head_pool[NR_CPUS];
-
 /*
  *	Keep out-of-line to prevent kernel bloat.
  *	__builtin_return_address is not used because it is not always
@@ -109,44 +103,6 @@
 	BUG();
 }
 
-static __inline__ struct sk_buff *skb_head_from_pool(void)
-{
-	struct sk_buff_head *list;
-	struct sk_buff *skb = NULL;
-	unsigned long flags;
-
-	local_irq_save(flags);
-
-	list = &skb_head_pool[smp_processor_id()].list;
-
-	if (skb_queue_len(list))
-		skb = __skb_dequeue(list);
-
-	local_irq_restore(flags);
-	return skb;
-}
-
-static __inline__ void skb_head_to_pool(struct sk_buff *skb)
-{
-	struct sk_buff_head *list;
-	unsigned long flags;
-
-	local_irq_save(flags);
-
-	list = &skb_head_pool[smp_processor_id()].list;
-
-	if (skb_queue_len(list) < sysctl_hot_list_len) {
-		__skb_queue_head(list, skb);
-		local_irq_restore(flags);
-
-		return;
-	}
-
-	local_irq_restore(flags);
-	kmem_cache_free(skbuff_head_cache, skb);
-}
-
-
 /* 	Allocate a new skbuff. We do this ourselves so we can fill in a few
  *	'private' fields and also do memory statistics to find all the
  *	[BEEP] leaks.
@@ -174,13 +130,10 @@
 		might_sleep();
 
 	/* Get the HEAD */
-	skb = skb_head_from_pool();
-	if (!skb) {
-		skb = kmem_cache_alloc(skbuff_head_cache,
-				       gfp_mask & ~__GFP_DMA);
-		if (!skb)
-			goto out;
-	}
+	skb = kmem_cache_alloc(skbuff_head_cache,
+			       gfp_mask & ~__GFP_DMA);
+	if (!skb)
+		goto out;
 
 	/* Get the DATA. Size must match skb_add_mtu(). */
 	size = SKB_DATA_ALIGN(size);
@@ -204,7 +157,7 @@
 out:
 	return skb;
 nodata:
-	skb_head_to_pool(skb);
+	kmem_cache_free(skbuff_head_cache, skb);
 	skb = NULL;
 	goto out;
 }
@@ -254,7 +207,7 @@
 void kfree_skbmem(struct sk_buff *skb)
 {
 	skb_release_data(skb);
-	skb_head_to_pool(skb);
+	kmem_cache_free(skbuff_head_cache, skb);
 }
 
 /**
@@ -309,13 +262,10 @@
 
 struct sk_buff *skb_clone(struct sk_buff *skb, int gfp_mask)
 {
-	struct sk_buff *n = skb_head_from_pool();
+	struct sk_buff *n = kmem_cache_alloc(skbuff_head_cache, gfp_mask);
 
-	if (!n) {
-		n = kmem_cache_alloc(skbuff_head_cache, gfp_mask);
-		if (!n)
-			return NULL;
-	}
+	if (!n) 
+		return NULL;
 
 #define C(x) n->x = skb->x
 
@@ -1204,8 +1154,6 @@
 
 void __init skb_init(void)
 {
-	int i;
-
 	skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
 					      sizeof(struct sk_buff),
 					      0,
@@ -1213,7 +1161,4 @@
 					      NULL, NULL);
 	if (!skbuff_head_cache)
 		panic("cannot create skbuff cache");
-
-	for (i = 0; i < NR_CPUS; i++)
-		skb_queue_head_init(&skb_head_pool[i].list);
 }
diff -Nru a/net/core/sock.c b/net/core/sock.c
--- a/net/core/sock.c	Wed Apr 30 22:28:13 2003
+++ b/net/core/sock.c	Wed Apr 30 22:28:13 2003
@@ -589,8 +589,10 @@
  */
 struct sock *sk_alloc(int family, int priority, int zero_it, kmem_cache_t *slab)
 {
-	struct sock *sk;
-       
+	struct sock *sk = NULL;
+
+	if (!net_family_get(family))
+		goto out;
 	if (!slab)
 		slab = sk_cachep;
 	sk = kmem_cache_alloc(slab, priority);
@@ -602,14 +604,16 @@
 			sock_lock_init(sk);
 		}
 		sk->slab = slab;
-	}
-
+	} else
+		net_family_put(family);
+out:
 	return sk;
 }
 
 void sk_free(struct sock *sk)
 {
 	struct sk_filter *filter;
+	const int family = sk->family;
 
 	if (sk->destruct)
 		sk->destruct(sk);
@@ -624,6 +628,7 @@
 		printk(KERN_DEBUG "sk_free: optmem leakage (%d bytes) detected.\n", atomic_read(&sk->omem_alloc));
 
 	kmem_cache_free(sk->slab, sk);
+	net_family_put(family);
 }
 
 void __init sk_init(void)
@@ -768,8 +773,13 @@
 				     unsigned long data_len, int noblock, int *errcode)
 {
 	struct sk_buff *skb;
+	unsigned int gfp_mask;
 	long timeo;
 	int err;
+
+	gfp_mask = sk->allocation;
+	if (gfp_mask & __GFP_WAIT)
+		gfp_mask |= __GFP_REPEAT;
 
 	timeo = sock_sndtimeo(sk, noblock);
 	while (1) {
diff -Nru a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
--- a/net/core/sysctl_net_core.c	Wed Apr 30 22:28:07 2003
+++ b/net/core/sysctl_net_core.c	Wed Apr 30 22:28:07 2003
@@ -28,7 +28,6 @@
 
 extern int sysctl_core_destroy_delay;
 extern int sysctl_optmem_max;
-extern int sysctl_hot_list_len;
 
 #ifdef CONFIG_NET_DIVERT
 extern char sysctl_divert_version[];
@@ -146,14 +145,6 @@
 		.ctl_name	= NET_CORE_OPTMEM_MAX,
 		.procname	= "optmem_max",
 		.data		= &sysctl_optmem_max,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= &proc_dointvec
-	},
-	{
-		.ctl_name	= NET_CORE_HOT_LIST_LENGTH,
-		.procname	= "hot_list_length",
-		.data		= &sysctl_hot_list_len,
 		.maxlen		= sizeof(int),
 		.mode		= 0644,
 		.proc_handler	= &proc_dointvec
diff -Nru a/net/core/wireless.c b/net/core/wireless.c
--- a/net/core/wireless.c	Wed Apr 30 22:28:15 2003
+++ b/net/core/wireless.c	Wed Apr 30 22:28:15 2003
@@ -66,7 +66,7 @@
 #define WE_STRICT_WRITE		/* Check write buffer size */
 /* I'll probably drop both the define and kernel message in the next version */
 
-/* Debuging stuff */
+/* Debugging stuff */
 #undef WE_IOCTL_DEBUG		/* Debug IOCTL API */
 #undef WE_EVENT_DEBUG		/* Debug Event dispatcher */
 
@@ -83,99 +83,168 @@
  * Meta-data about all the standard Wireless Extension request we
  * know about.
  */
-static const struct iw_ioctl_description	standard_ioctl[] = {
-	/* SIOCSIWCOMMIT */
-	{ IW_HEADER_TYPE_NULL, 0, 0, 0, 0, 0},
-	/* SIOCGIWNAME */
-	{ IW_HEADER_TYPE_CHAR, 0, 0, 0, 0, IW_DESCR_FLAG_DUMP},
-	/* SIOCSIWNWID */
-	{ IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, IW_DESCR_FLAG_EVENT},
-	/* SIOCGIWNWID */
-	{ IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, IW_DESCR_FLAG_DUMP},
-	/* SIOCSIWFREQ */
-	{ IW_HEADER_TYPE_FREQ, 0, 0, 0, 0, IW_DESCR_FLAG_EVENT},
-	/* SIOCGIWFREQ */
-	{ IW_HEADER_TYPE_FREQ, 0, 0, 0, 0, IW_DESCR_FLAG_DUMP},
-	/* SIOCSIWMODE */
-	{ IW_HEADER_TYPE_UINT, 0, 0, 0, 0, IW_DESCR_FLAG_EVENT},
-	/* SIOCGIWMODE */
-	{ IW_HEADER_TYPE_UINT, 0, 0, 0, 0, IW_DESCR_FLAG_DUMP},
-	/* SIOCSIWSENS */
-	{ IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
-	/* SIOCGIWSENS */
-	{ IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
-	/* SIOCSIWRANGE */
-	{ IW_HEADER_TYPE_NULL, 0, 0, 0, 0, 0},
-	/* SIOCGIWRANGE */
-	{ IW_HEADER_TYPE_POINT, 0, 1, 0, sizeof(struct iw_range), IW_DESCR_FLAG_DUMP},
-	/* SIOCSIWPRIV */
-	{ IW_HEADER_TYPE_NULL, 0, 0, 0, 0, 0},
-	/* SIOCGIWPRIV (handled directly by us) */
-	{ IW_HEADER_TYPE_NULL, 0, 0, 0, 0, 0},
-	/* SIOCSIWSTATS */
-	{ IW_HEADER_TYPE_NULL, 0, 0, 0, 0, 0},
-	/* SIOCGIWSTATS (handled directly by us) */
-	{ IW_HEADER_TYPE_NULL, 0, 0, 0, 0, IW_DESCR_FLAG_DUMP},
-	/* SIOCSIWSPY */
-	{ IW_HEADER_TYPE_POINT, 0, sizeof(struct sockaddr), 0, IW_MAX_SPY, 0},
-	/* SIOCGIWSPY */
-	{ IW_HEADER_TYPE_POINT, 0, (sizeof(struct sockaddr) + sizeof(struct iw_quality)), 0, IW_MAX_GET_SPY, 0},
-	/* -- hole -- */
-	{ IW_HEADER_TYPE_NULL, 0, 0, 0, 0, 0},
-	/* -- hole -- */
-	{ IW_HEADER_TYPE_NULL, 0, 0, 0, 0, 0},
-	/* SIOCSIWAP */
-	{ IW_HEADER_TYPE_ADDR, 0, 0, 0, 0, 0},
-	/* SIOCGIWAP */
-	{ IW_HEADER_TYPE_ADDR, 0, 0, 0, 0, IW_DESCR_FLAG_DUMP},
-	/* -- hole -- */
-	{ IW_HEADER_TYPE_NULL, 0, 0, 0, 0, 0},
-	/* SIOCGIWAPLIST */
-	{ IW_HEADER_TYPE_POINT, 0, (sizeof(struct sockaddr) + sizeof(struct iw_quality)), 0, IW_MAX_AP, 0},
-	/* SIOCSIWSCAN */
-	{ IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
-	/* SIOCGIWSCAN */
-	{ IW_HEADER_TYPE_POINT, 0, 1, 0, IW_SCAN_MAX_DATA, 0},
-	/* SIOCSIWESSID */
-	{ IW_HEADER_TYPE_POINT, 0, 1, 0, IW_ESSID_MAX_SIZE + 1, IW_DESCR_FLAG_EVENT},
-	/* SIOCGIWESSID */
-	{ IW_HEADER_TYPE_POINT, 0, 1, 0, IW_ESSID_MAX_SIZE + 1, IW_DESCR_FLAG_DUMP},
-	/* SIOCSIWNICKN */
-	{ IW_HEADER_TYPE_POINT, 0, 1, 0, IW_ESSID_MAX_SIZE + 1, 0},
-	/* SIOCGIWNICKN */
-	{ IW_HEADER_TYPE_POINT, 0, 1, 0, IW_ESSID_MAX_SIZE + 1, 0},
-	/* -- hole -- */
-	{ IW_HEADER_TYPE_NULL, 0, 0, 0, 0, 0},
-	/* -- hole -- */
-	{ IW_HEADER_TYPE_NULL, 0, 0, 0, 0, 0},
-	/* SIOCSIWRATE */
-	{ IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
-	/* SIOCGIWRATE */
-	{ IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
-	/* SIOCSIWRTS */
-	{ IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
-	/* SIOCGIWRTS */
-	{ IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
-	/* SIOCSIWFRAG */
-	{ IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
-	/* SIOCGIWFRAG */
-	{ IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
-	/* SIOCSIWTXPOW */
-	{ IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
-	/* SIOCGIWTXPOW */
-	{ IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
-	/* SIOCSIWRETRY */
-	{ IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
-	/* SIOCGIWRETRY */
-	{ IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
-	/* SIOCSIWENCODE */
-	{ IW_HEADER_TYPE_POINT, 0, 1, 0, IW_ENCODING_TOKEN_MAX, IW_DESCR_FLAG_EVENT | IW_DESCR_FLAG_RESTRICT},
-	/* SIOCGIWENCODE */
-	{ IW_HEADER_TYPE_POINT, 0, 1, 0, IW_ENCODING_TOKEN_MAX, IW_DESCR_FLAG_DUMP | IW_DESCR_FLAG_RESTRICT},
-	/* SIOCSIWPOWER */
-	{ IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
-	/* SIOCGIWPOWER */
-	{ IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
+static const struct iw_ioctl_description standard_ioctl[] = {
+	[SIOCSIWCOMMIT	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_NULL,
+	},
+	[SIOCGIWNAME	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_CHAR,
+		.flags		= IW_DESCR_FLAG_DUMP,
+	},
+	[SIOCSIWNWID	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_PARAM,
+		.flags		= IW_DESCR_FLAG_EVENT,
+	},
+	[SIOCGIWNWID	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_PARAM,
+		.flags		= IW_DESCR_FLAG_DUMP,
+	},
+	[SIOCSIWFREQ	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_FREQ,
+		.flags		= IW_DESCR_FLAG_EVENT,
+	},
+	[SIOCGIWFREQ	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_FREQ,
+		.flags		= IW_DESCR_FLAG_DUMP,
+	},
+	[SIOCSIWMODE	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_UINT,
+		.flags		= IW_DESCR_FLAG_EVENT,
+	},
+	[SIOCGIWMODE	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_UINT,
+		.flags		= IW_DESCR_FLAG_DUMP,
+	},
+	[SIOCSIWSENS	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_PARAM,
+	},
+	[SIOCGIWSENS	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_PARAM,
+	},
+	[SIOCSIWRANGE	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_NULL,
+	},
+	[SIOCGIWRANGE	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_POINT,
+		.token_size	= 1,
+		.max_tokens	= sizeof(struct iw_range),
+		.flags		= IW_DESCR_FLAG_DUMP,
+	},
+	[SIOCSIWPRIV	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_NULL,
+	},
+	[SIOCGIWPRIV	- SIOCIWFIRST] = { /* (handled directly by us) */
+		.header_type	= IW_HEADER_TYPE_NULL,
+	},
+	[SIOCSIWSTATS	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_NULL,
+	},
+	[SIOCGIWSTATS	- SIOCIWFIRST] = { /* (handled directly by us) */
+		.header_type	= IW_HEADER_TYPE_NULL,
+		.flags		= IW_DESCR_FLAG_DUMP,
+	},
+	[SIOCSIWSPY	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_POINT,
+		.token_size	= sizeof(struct sockaddr),
+		.max_tokens	= IW_MAX_SPY,
+	},
+	[SIOCGIWSPY	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_POINT,
+		.token_size	= sizeof(struct sockaddr) +
+				  sizeof(struct iw_quality),
+		.max_tokens	= IW_MAX_GET_SPY,
+	},
+	[SIOCSIWAP	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_ADDR,
+	},
+	[SIOCGIWAP	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_ADDR,
+		.flags		= IW_DESCR_FLAG_DUMP,
+	},
+	[SIOCGIWAPLIST	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_POINT,
+		.token_size	= sizeof(struct sockaddr) +
+				  sizeof(struct iw_quality),
+		.max_tokens	= IW_MAX_AP,
+	},
+	[SIOCSIWSCAN	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_PARAM,
+	},
+	[SIOCGIWSCAN	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_POINT,
+		.token_size	= 1,
+		.max_tokens	= IW_SCAN_MAX_DATA,
+	},
+	[SIOCSIWESSID	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_POINT,
+		.token_size	= 1,
+		.max_tokens	= IW_ESSID_MAX_SIZE + 1,
+		.flags		= IW_DESCR_FLAG_EVENT,
+	},
+	[SIOCGIWESSID	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_POINT,
+		.token_size	= 1,
+		.max_tokens	= IW_ESSID_MAX_SIZE + 1,
+		.flags		= IW_DESCR_FLAG_DUMP,
+	},
+	[SIOCSIWNICKN	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_POINT,
+		.token_size	= 1,
+		.max_tokens	= IW_ESSID_MAX_SIZE + 1,
+	},
+	[SIOCGIWNICKN	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_POINT,
+		.token_size	= 1,
+		.max_tokens	= IW_ESSID_MAX_SIZE + 1,
+	},
+	[SIOCSIWRATE	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_PARAM,
+	},
+	[SIOCGIWRATE	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_PARAM,
+	},
+	[SIOCSIWRTS	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_PARAM,
+	},
+	[SIOCGIWRTS	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_PARAM,
+	},
+	[SIOCSIWFRAG	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_PARAM,
+	},
+	[SIOCGIWFRAG	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_PARAM,
+	},
+	[SIOCSIWTXPOW	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_PARAM,
+	},
+	[SIOCGIWTXPOW	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_PARAM,
+	},
+	[SIOCSIWRETRY	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_PARAM,
+	},
+	[SIOCGIWRETRY	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_PARAM,
+	},
+	[SIOCSIWENCODE	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_POINT,
+		.token_size	= 1,
+		.max_tokens	= IW_ENCODING_TOKEN_MAX,
+		.flags		= IW_DESCR_FLAG_EVENT | IW_DESCR_FLAG_RESTRICT,
+	},
+	[SIOCGIWENCODE	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_POINT,
+		.token_size	= 1,
+		.max_tokens	= IW_ENCODING_TOKEN_MAX,
+		.flags		= IW_DESCR_FLAG_DUMP | IW_DESCR_FLAG_RESTRICT,
+	},
+	[SIOCSIWPOWER	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_PARAM,
+	},
+	[SIOCGIWPOWER	- SIOCIWFIRST] = {
+		.header_type	= IW_HEADER_TYPE_PARAM,
+	},
 };
 static const int standard_ioctl_num = (sizeof(standard_ioctl) /
 				       sizeof(struct iw_ioctl_description));
@@ -184,17 +253,24 @@
  * Meta-data about all the additional standard Wireless Extension events
  * we know about.
  */
-static const struct iw_ioctl_description	standard_event[] = {
-	/* IWEVTXDROP */
-	{ IW_HEADER_TYPE_ADDR, 0, 0, 0, 0, 0},
-	/* IWEVQUAL */
-	{ IW_HEADER_TYPE_QUAL, 0, 0, 0, 0, 0},
-	/* IWEVCUSTOM */
-	{ IW_HEADER_TYPE_POINT, 0, 1, 0, IW_CUSTOM_MAX, 0},
-	/* IWEVREGISTERED */
-	{ IW_HEADER_TYPE_ADDR, 0, 0, 0, 0, 0},
-	/* IWEVEXPIRED */
-	{ IW_HEADER_TYPE_ADDR, 0, 0, 0, 0, 0},
+static const struct iw_ioctl_description standard_event[] = {
+	[IWEVTXDROP	- IWEVFIRST] = {
+		.header_type	= IW_HEADER_TYPE_ADDR,
+	},
+	[IWEVQUAL	- IWEVFIRST] = {
+		.header_type	= IW_HEADER_TYPE_QUAL,
+	},
+	[IWEVCUSTOM	- IWEVFIRST] = {
+		.header_type	= IW_HEADER_TYPE_POINT,
+		.token_size	= 1,
+		.max_tokens	= IW_CUSTOM_MAX,
+	},
+	[IWEVREGISTERED	- IWEVFIRST] = {
+		.header_type	= IW_HEADER_TYPE_ADDR,
+	},
+	[IWEVEXPIRED	- IWEVFIRST] = {
+		.header_type	= IW_HEADER_TYPE_ADDR, 
+	},
 };
 static const int standard_event_num = (sizeof(standard_event) /
 				       sizeof(struct iw_ioctl_description));
@@ -929,7 +1005,7 @@
 /* ---------------------------------------------------------------- */
 /*
  * Main event dispatcher. Called from other parts and drivers.
- * Send the event on the apropriate channels.
+ * Send the event on the appropriate channels.
  * May be called from interrupt context.
  */
 void wireless_send_event(struct net_device *	dev,
diff -Nru a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
--- a/net/decnet/af_decnet.c	Wed Apr 30 22:28:09 2003
+++ b/net/decnet/af_decnet.c	Wed Apr 30 22:28:09 2003
@@ -469,24 +469,21 @@
 	skb_queue_purge(&scp->other_receive_queue);
 
 	dst_release(xchg(&sk->dst_cache, NULL));
-
-	MOD_DEC_USE_COUNT;
 }
 
 struct sock *dn_alloc_sock(struct socket *sock, int gfp)
 {
-	struct sock *sk;
 	struct dn_scp *scp;
+	struct sock *sk = sk_alloc(PF_DECnet, gfp, sizeof(struct dn_sock),
+				   dn_sk_cachep);
 
-	if  ((sk = sk_alloc(PF_DECnet, gfp, sizeof(struct dn_sock), dn_sk_cachep)) == NULL) 
-		goto no_sock;
+	if  (!sk)
+		goto out;
 
-	scp = (struct dn_scp *)(sk + 1);
-	DN_SK(sk) = scp;
+	DN_SK(sk) = scp = (struct dn_scp *)(sk + 1);
 
-	if (sock) {
-			sock->ops = &dn_proto_ops;
-	}
+	if (sock)
+		sock->ops = &dn_proto_ops;
 	sock_init_data(sock, sk);
 
 	sk->backlog_rcv = dn_nsp_backlog_rcv;
@@ -543,13 +540,8 @@
 	scp->delack_fxn = dn_nsp_delayed_ack;
 
 	dn_start_slow_timer(sk);
-
-	MOD_INC_USE_COUNT;
-
+out:
 	return sk;
-
-no_sock:
-	return NULL;
 }
 
 /*
@@ -2238,6 +2230,7 @@
 static struct net_proto_family	dn_family_ops = {
 	.family =	AF_DECnet,
 	.create =	dn_create,
+	.owner	=	THIS_MODULE,
 };
 
 static struct proto_ops dn_proto_ops = {
@@ -2304,7 +2297,7 @@
 	 * Requires an audit of the code to check for memory leaks and
 	 * initialisation problems etc.
 	 */
-	MOD_INC_USE_COUNT;
+	try_module_get(THIS_MODULE);
 
 	return 0;
 
diff -Nru a/net/decnet/dn_nsp_out.c b/net/decnet/dn_nsp_out.c
--- a/net/decnet/dn_nsp_out.c	Wed Apr 30 22:28:18 2003
+++ b/net/decnet/dn_nsp_out.c	Wed Apr 30 22:28:18 2003
@@ -642,7 +642,7 @@
 	}
 
 	/*
-	 * This doesn't go via the dn_nsp_send() fucntion since we need
+	 * This doesn't go via the dn_nsp_send() function since we need
 	 * to be able to send disc packets out which have no socket
 	 * associations.
 	 */
diff -Nru a/net/decnet/dn_route.c b/net/decnet/dn_route.c
--- a/net/decnet/dn_route.c	Wed Apr 30 22:28:18 2003
+++ b/net/decnet/dn_route.c	Wed Apr 30 22:28:18 2003
@@ -893,6 +893,7 @@
 			goto out;
 		dev_hold(dev_out);
 source_ok:
+		;
 	}
 
 	/* No destination? Assume its local */
diff -Nru a/net/econet/af_econet.c b/net/econet/af_econet.c
--- a/net/econet/af_econet.c	Wed Apr 30 22:28:09 2003
+++ b/net/econet/af_econet.c	Wed Apr 30 22:28:09 2003
@@ -502,7 +502,6 @@
 
 	if (!atomic_read(&sk->wmem_alloc) && !atomic_read(&sk->rmem_alloc)) {
 		sk_free(sk);
-		MOD_DEC_USE_COUNT;
 		return;
 	}
 
@@ -547,7 +546,6 @@
 	}
 
 	sk_free(sk);
-	MOD_DEC_USE_COUNT;
 	return 0;
 }
 
@@ -566,7 +564,6 @@
 		return -ESOCKTNOSUPPORT;
 
 	sock->state = SS_UNCONNECTED;
-	MOD_INC_USE_COUNT;
 
 	err = -ENOBUFS;
 	sk = sk_alloc(PF_ECONET, GFP_KERNEL, 1, NULL);
@@ -591,7 +588,6 @@
 out_free:
 	sk_free(sk);
 out:
-	MOD_DEC_USE_COUNT;
 	return err;
 }
 
@@ -693,6 +689,7 @@
 static struct net_proto_family econet_family_ops = {
 	.family =	PF_ECONET,
 	.create =	econet_create,
+	.owner	=	THIS_MODULE,
 };
 
 static struct proto_ops SOCKOPS_WRAPPED(econet_ops) = {
diff -Nru a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
--- a/net/ipv4/fib_semantics.c	Wed Apr 30 22:28:05 2003
+++ b/net/ipv4/fib_semantics.c	Wed Apr 30 22:28:05 2003
@@ -83,23 +83,62 @@
 {
 	int	error;
 	u8	scope;
-} fib_props[RTA_MAX+1] = {
-        { 0, RT_SCOPE_NOWHERE},		/* RTN_UNSPEC */
-	{ 0, RT_SCOPE_UNIVERSE},	/* RTN_UNICAST */
-	{ 0, RT_SCOPE_HOST},		/* RTN_LOCAL */
-	{ 0, RT_SCOPE_LINK},		/* RTN_BROADCAST */
-	{ 0, RT_SCOPE_LINK},		/* RTN_ANYCAST */
-	{ 0, RT_SCOPE_UNIVERSE},	/* RTN_MULTICAST */
-	{ -EINVAL, RT_SCOPE_UNIVERSE},	/* RTN_BLACKHOLE */
-	{ -EHOSTUNREACH, RT_SCOPE_UNIVERSE},/* RTN_UNREACHABLE */
-	{ -EACCES, RT_SCOPE_UNIVERSE},	/* RTN_PROHIBIT */
-	{ -EAGAIN, RT_SCOPE_UNIVERSE},	/* RTN_THROW */
+} fib_props[RTA_MAX + 1] = {
+        {
+		.error	= 0,
+		.scope	= RT_SCOPE_NOWHERE,
+	},	/* RTN_UNSPEC */
+	{
+		.error	= 0,
+		.scope	= RT_SCOPE_UNIVERSE,
+	},	/* RTN_UNICAST */
+	{
+		.error	= 0,
+		.scope	= RT_SCOPE_HOST,
+	},	/* RTN_LOCAL */
+	{
+		.error	= 0,
+		.scope	= RT_SCOPE_LINK,
+	},	/* RTN_BROADCAST */
+	{
+		.error	= 0,
+		.scope	= RT_SCOPE_LINK,
+	},	/* RTN_ANYCAST */
+	{
+		.error	= 0,
+		.scope	= RT_SCOPE_UNIVERSE,
+	},	/* RTN_MULTICAST */
+	{
+		.error	= -EINVAL,
+		.scope	= RT_SCOPE_UNIVERSE,
+	},	/* RTN_BLACKHOLE */
+	{
+		.error	= -EHOSTUNREACH,
+		.scope	= RT_SCOPE_UNIVERSE,
+	},	/* RTN_UNREACHABLE */
+	{
+		.error	= -EACCES,
+		.scope	= RT_SCOPE_UNIVERSE,
+	},	/* RTN_PROHIBIT */
+	{
+		.error	= -EAGAIN,
+		.scope	= RT_SCOPE_UNIVERSE,
+	},	/* RTN_THROW */
 #ifdef CONFIG_IP_ROUTE_NAT
-	{ 0, RT_SCOPE_HOST},		/* RTN_NAT */
+	{
+		.error	= 0,
+		.scope	= RT_SCOPE_HOST,
+	},	/* RTN_NAT */
 #else
-	{ -EINVAL, RT_SCOPE_NOWHERE},	/* RTN_NAT */
+	{
+		.error	= -EINVAL,
+		.scope	= RT_SCOPE_NOWHERE,
+	},	/* RTN_NAT */
 #endif
-	{ -EINVAL, RT_SCOPE_NOWHERE}	/* RTN_XRESOLVE */
+	{
+		.error	= -EINVAL,
+		.scope	= RT_SCOPE_NOWHERE,
+	},	/* RTN_XRESOLVE */
 };
 
 
@@ -317,7 +356,7 @@
    Attempt to reconcile all of these (alas, self-contradictory) conditions
    results in pretty ugly and hairy code with obscure logic.
 
-   I choosed to generalized it instead, so that the size
+   I chose to generalized it instead, so that the size
    of code does not increase practically, but it becomes
    much more general.
    Every prefix is assigned a "scope" value: "host" is local address,
diff -Nru a/net/ipv4/igmp.c b/net/ipv4/igmp.c
--- a/net/ipv4/igmp.c	Wed Apr 30 22:28:19 2003
+++ b/net/ipv4/igmp.c	Wed Apr 30 22:28:19 2003
@@ -103,6 +103,7 @@
 
 #define IP_MAX_MEMBERSHIPS 20
 
+#ifdef CONFIG_IP_MULTICAST
 /* Parameter names and values are taken from igmp-v2-06 draft */
 
 #define IGMP_V1_Router_Present_Timeout		(400*HZ)
@@ -126,13 +127,12 @@
 #define IGMP_V2_SEEN(in_dev) ((in_dev)->mr_v2_seen && \
 		time_before(jiffies, (in_dev)->mr_v2_seen))
 
-#ifdef CONFIG_MULTICAST
 static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im);
-#endif
 static void igmpv3_del_delrec(struct in_device *in_dev, __u32 multiaddr);
 static void igmpv3_clear_delrec(struct in_device *in_dev);
 static int sf_setstate(struct ip_mc_list *pmc);
 static void sf_markstate(struct ip_mc_list *pmc);
+#endif
 static void ip_mc_clear_src(struct ip_mc_list *pmc);
 int ip_mc_add_src(struct in_device *in_dev, __u32 *pmca, int sfmode,
 	int sfcount, __u32 *psfsrc, int delta);
@@ -770,11 +770,18 @@
 			in_dev->mr_v2_seen = jiffies +
 				IGMP_V2_Router_Present_Timeout;
 		}
+		/* cancel the interface change timer */
+		in_dev->mr_ifc_count = 0;
+		if (del_timer(&in_dev->mr_ifc_timer))
+			atomic_dec(&in_dev->refcnt);
+		/* clear deleted report items */
 		igmpv3_clear_delrec(in_dev);
 	} else if (len < 12) {
 		return;	/* ignore bogus packet; freed by caller */
 	} else { /* v3 */
 		max_delay = IGMPV3_MRC(ih3->code)*(HZ/IGMP_TIMER_SCALE);
+		if (!max_delay)
+			max_delay = 1;	/* can't mod w/ 0 */
 		in_dev->mr_maxdelay = max_delay;
 		if (ih3->qrv)
 			in_dev->mr_qrv = ih3->qrv;
@@ -951,7 +958,6 @@
 	in_dev->mc_tomb = pmc;
 	write_unlock_bh(&in_dev->mc_lock);
 }
-#endif
 
 static void igmpv3_del_delrec(struct in_device *in_dev, __u32 multiaddr)
 {
@@ -997,7 +1003,23 @@
 		in_dev_put(pmc->interface);
 		kfree(pmc);
 	}
+	/* clear dead sources, too */
+	read_lock(&in_dev->lock);
+	for (pmc=in_dev->mc_list; pmc; pmc=pmc->next) {
+		struct ip_sf_list *psf, *psf_next;
+
+		spin_lock_bh(&pmc->lock);
+		psf = pmc->tomb;
+		pmc->tomb = 0;
+		spin_unlock_bh(&pmc->lock);
+		for (; psf; psf=psf_next) {
+			psf_next = psf->sf_next;
+			kfree(psf);
+		}
+	}
+	read_unlock(&in_dev->lock);
 }
+#endif
 
 static void igmp_group_dropped(struct ip_mc_list *im)
 {
@@ -1030,8 +1052,8 @@
 
 	igmp_ifc_event(in_dev);
 done:
-	ip_mc_clear_src(im);
 #endif
+	ip_mc_clear_src(im);
 }
 
 static void igmp_group_added(struct ip_mc_list *im)
@@ -1102,7 +1124,7 @@
 	im->crcount = 0;
 	atomic_set(&im->refcnt, 1);
 	spin_lock_init(&im->lock);
-#ifdef  CONFIG_IP_MULTICAST
+#ifdef CONFIG_IP_MULTICAST
 	im->tm_running=0;
 	init_timer(&im->timer);
 	im->timer.data=(unsigned long)im;
@@ -1116,7 +1138,9 @@
 	im->next=in_dev->mc_list;
 	in_dev->mc_list=im;
 	write_unlock_bh(&in_dev->lock);
+#ifdef CONFIG_IP_MULTICAST
 	igmpv3_del_delrec(in_dev, im->multiaddr);
+#endif
 	igmp_group_added(im);
 	if (in_dev->dev->flags & IFF_UP)
 		ip_rt_multicast_event(in_dev);
@@ -1173,7 +1197,9 @@
 	for (i=in_dev->mc_list; i; i=i->next)
 		igmp_group_dropped(i);
 
+#ifdef CONFIG_IP_MULTICAST
 	igmpv3_clear_delrec(in_dev);
+#endif
 
 	ip_mc_dec_group(in_dev, IGMP_ALL_HOSTS);
 }
@@ -1186,12 +1212,12 @@
 
 	ASSERT_RTNL();
 
+	in_dev->mc_tomb = 0;
 #ifdef CONFIG_IP_MULTICAST
 	in_dev->mr_gq_running = 0;
 	init_timer(&in_dev->mr_gq_timer);
 	in_dev->mr_gq_timer.data=(unsigned long) in_dev;
 	in_dev->mr_gq_timer.function=&igmp_gq_timer_expire;
-	in_dev->mc_tomb = 0;
 	in_dev->mr_ifc_count = 0;
 	init_timer(&in_dev->mr_ifc_timer);
 	in_dev->mr_ifc_timer.data=(unsigned long) in_dev;
@@ -1237,6 +1263,12 @@
 	struct net_device *dev = NULL;
 	struct in_device *idev = NULL;
 
+	if (imr->imr_ifindex) {
+		idev = inetdev_by_index(imr->imr_ifindex);
+		if (idev)
+			__in_dev_put(idev);
+		return idev;
+	}
 	if (imr->imr_address.s_addr) {
 		dev = ip_dev_find(imr->imr_address.s_addr);
 		if (!dev)
@@ -1282,13 +1314,16 @@
 		ip_rt_multicast_event(pmc->interface);
 	}
 	if (!psf->sf_count[MCAST_INCLUDE] && !psf->sf_count[MCAST_EXCLUDE]) {
+#ifdef CONFIG_IP_MULTICAST
 		struct in_device *in_dev = pmc->interface;
+#endif
 
 		/* no more filters for this source */
 		if (psf_prev)
 			psf_prev->sf_next = psf->sf_next;
 		else
 			pmc->sources = psf->sf_next;
+#ifdef CONFIG_IP_MULTICAST
 		if (psf->sf_oldin &&
 		    !IGMP_V1_SEEN(in_dev) && !IGMP_V2_SEEN(in_dev)) {
 			psf->sf_crcount = in_dev->mr_qrv ? in_dev->mr_qrv : 
@@ -1297,6 +1332,7 @@
 			pmc->tomb = psf;
 			rv = 1;
 		} else
+#endif
 			kfree(psf);
 	}
 	return rv;
@@ -1327,7 +1363,9 @@
 	}
 	spin_lock_bh(&pmc->lock);
 	read_unlock(&in_dev->lock);
+#ifdef CONFIG_IP_MULTICAST
 	sf_markstate(pmc);
+#endif
 	if (!delta) {
 		if (!pmc->sfcount[sfmode])
 			return -EINVAL;
@@ -1344,10 +1382,13 @@
 	if (pmc->sfmode == MCAST_EXCLUDE &&
 	    pmc->sfcount[MCAST_EXCLUDE] == 0 &&
 	    pmc->sfcount[MCAST_INCLUDE]) {
+#ifdef CONFIG_IP_MULTICAST
 		struct ip_sf_list *psf;
+#endif
 
 		/* filter mode change */
 		pmc->sfmode = MCAST_INCLUDE;
+#ifdef CONFIG_IP_MULTICAST
 		pmc->crcount = in_dev->mr_qrv ? in_dev->mr_qrv : 
 			IGMP_Unsolicited_Report_Count;
 		in_dev->mr_ifc_count = pmc->crcount;
@@ -1356,6 +1397,7 @@
 		igmp_ifc_event(pmc->interface);
 	} else if (sf_setstate(pmc) || changerec) {
 		igmp_ifc_event(pmc->interface);
+#endif
 	}
 	spin_unlock_bh(&pmc->lock);
 	return err;
@@ -1393,6 +1435,7 @@
 	return 0;
 }
 
+#ifdef CONFIG_IP_MULTICAST
 static void sf_markstate(struct ip_mc_list *pmc)
 {
 	struct ip_sf_list *psf;
@@ -1428,6 +1471,7 @@
 	}
 	return rv;
 }
+#endif
 
 /*
  * Add multicast source filter list to the interface list
@@ -1454,7 +1498,9 @@
 	spin_lock_bh(&pmc->lock);
 	read_unlock(&in_dev->lock);
 
+#ifdef CONFIG_IP_MULTICAST
 	sf_markstate(pmc);
+#endif
 	isexclude = pmc->sfmode == MCAST_EXCLUDE;
 	if (!delta)
 		pmc->sfcount[sfmode]++;
@@ -1471,14 +1517,17 @@
 		for (j=0; j<i; j++)
 			(void) ip_mc_del1_src(pmc, sfmode, &psfsrc[i]);
 	} else if (isexclude != (pmc->sfcount[MCAST_EXCLUDE] != 0)) {
+#ifdef CONFIG_IP_MULTICAST
 		struct in_device *in_dev = pmc->interface;
 		struct ip_sf_list *psf;
+#endif
 
 		/* filter mode change */
 		if (pmc->sfcount[MCAST_EXCLUDE])
 			pmc->sfmode = MCAST_EXCLUDE;
 		else if (pmc->sfcount[MCAST_INCLUDE])
 			pmc->sfmode = MCAST_INCLUDE;
+#ifdef CONFIG_IP_MULTICAST
 		/* else no filters; keep old mode for reports */
 
 		pmc->crcount = in_dev->mr_qrv ? in_dev->mr_qrv : 
@@ -1487,8 +1536,10 @@
 		for (psf=pmc->sources; psf; psf = psf->sf_next)
 			psf->sf_crcount = 0;
 		igmp_ifc_event(in_dev);
-	} else if (sf_setstate(pmc))
+	} else if (sf_setstate(pmc)) {
 		igmp_ifc_event(in_dev);
+#endif
+	}
 	spin_unlock_bh(&pmc->lock);
 	return err;
 }
@@ -1530,13 +1581,7 @@
 
 	rtnl_shlock();
 
-	if (!imr->imr_ifindex)
-		in_dev = ip_mc_find_dev(imr);
-	else {
-		in_dev = inetdev_by_index(imr->imr_ifindex);
-		if (in_dev)
-			__in_dev_put(in_dev);
-	}
+	in_dev = ip_mc_find_dev(imr);
 
 	if (!in_dev) {
 		iml = NULL;
@@ -1638,13 +1683,13 @@
 }
 
 int ip_mc_source(int add, int omode, struct sock *sk, struct
-	ip_mreq_source *mreqs)
+	ip_mreq_source *mreqs, int ifindex)
 {
 	int err;
-	struct ip_mreqn	imr;
+	struct ip_mreqn imr;
 	u32 addr = mreqs->imr_multiaddr;
 	struct ip_mc_socklist *pmc;
-	struct in_device *in_dev;
+	struct in_device *in_dev = 0;
 	struct inet_opt *inet = inet_sk(sk);
 	struct ip_sf_socklist *psl;
 	int i, j, rv;
@@ -1656,7 +1701,7 @@
 
 	imr.imr_multiaddr.s_addr = mreqs->imr_multiaddr;
 	imr.imr_address.s_addr = mreqs->imr_interface;
-	imr.imr_ifindex = 0;
+	imr.imr_ifindex = ifindex;
 	in_dev = ip_mc_find_dev(&imr);
 
 	if (!in_dev) {
@@ -1753,7 +1798,7 @@
 	return err;
 }
 
-int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf)
+int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex)
 {
 	int err;
 	struct ip_mreqn	imr;
@@ -1773,7 +1818,7 @@
 
 	imr.imr_multiaddr.s_addr = msf->imsf_multiaddr;
 	imr.imr_address.s_addr = msf->imsf_interface;
-	imr.imr_ifindex = 0;
+	imr.imr_ifindex = ifindex;
 	in_dev = ip_mc_find_dev(&imr);
 
 	if (!in_dev) {
@@ -1783,7 +1828,8 @@
 	err = -EADDRNOTAVAIL;
 
 	for (pmc=inet->mc_list; pmc; pmc=pmc->next) {
-		if (memcmp(&pmc->multi, &imr, sizeof(imr)) == 0)
+		if (pmc->multi.imr_multiaddr.s_addr == msf->imsf_multiaddr &&
+		    pmc->multi.imr_ifindex == imr.imr_ifindex)
 			break;
 	}
 	if (!pmc)		/* must have a prior join */
@@ -1834,9 +1880,6 @@
 
 	if (!MULTICAST(addr))
 		return -EINVAL;
-	if (msf->imsf_fmode != MCAST_INCLUDE &&
-	    msf->imsf_fmode != MCAST_EXCLUDE)
-		return -EINVAL;
 
 	rtnl_shlock();
 
@@ -1852,7 +1895,8 @@
 	err = -EADDRNOTAVAIL;
 
 	for (pmc=inet->mc_list; pmc; pmc=pmc->next) {
-		if (memcmp(&pmc->multi, &imr, sizeof(imr)) == 0)
+		if (pmc->multi.imr_multiaddr.s_addr == msf->imsf_multiaddr &&
+		    pmc->multi.imr_ifindex == imr.imr_ifindex)
 			break;
 	}
 	if (!pmc)		/* must have a prior join */
@@ -1882,6 +1926,61 @@
 	return err;
 }
 
+int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
+	struct group_filter *optval, int *optlen)
+{
+	int err, i, count, copycount;
+	struct sockaddr_in *psin;
+	u32 addr;
+	struct ip_mc_socklist *pmc;
+	struct inet_opt *inet = inet_sk(sk);
+	struct ip_sf_socklist *psl;
+
+	psin = (struct sockaddr_in *)&gsf->gf_group;
+	if (psin->sin_family != AF_INET)
+		return -EINVAL;
+	addr = psin->sin_addr.s_addr;
+	if (!MULTICAST(addr))
+		return -EINVAL;
+
+	rtnl_shlock();
+
+	err = -EADDRNOTAVAIL;
+
+	for (pmc=inet->mc_list; pmc; pmc=pmc->next) {
+		if (pmc->multi.imr_multiaddr.s_addr == addr &&
+		    pmc->multi.imr_ifindex == gsf->gf_interface)
+			break;
+	}
+	if (!pmc)		/* must have a prior join */
+		goto done;
+	gsf->gf_fmode = pmc->sfmode;
+	psl = pmc->sflist;
+	rtnl_shunlock();
+	count = psl ? psl->sl_count : 0;
+	copycount = count < gsf->gf_numsrc ? count : gsf->gf_numsrc;
+	gsf->gf_numsrc = count;
+	if (put_user(GROUP_FILTER_SIZE(copycount), optlen) ||
+	    copy_to_user((void *)optval, gsf, GROUP_FILTER_SIZE(0))) {
+		return -EFAULT;
+	}
+	for (i=0; i<copycount; i++) {
+		struct sockaddr_in *psin;
+		struct sockaddr_storage ss;
+
+		psin = (struct sockaddr_in *)&ss;
+		memset(&ss, 0, sizeof(ss));
+		psin->sin_family = AF_INET;
+		psin->sin_addr.s_addr = psl->sl_addr[i];
+		if (copy_to_user((void *)&optval->gf_slist[i], &ss, sizeof(ss)))
+			return -EFAULT;
+	}
+	return 0;
+done:
+	rtnl_shunlock();
+	return err;
+}
+
 /*
  * check if a multicast source filter allows delivery for a given <src,dst,intf>
  */
@@ -1892,6 +1991,9 @@
 	struct ip_sf_socklist *psl;
 	int i;
 
+	if (!MULTICAST(loc_addr))
+		return 1;
+
 	for (pmc=inet->mc_list; pmc; pmc=pmc->next) {
 		if (pmc->multi.imr_multiaddr.s_addr == loc_addr &&
 		    pmc->multi.imr_ifindex == dif)
@@ -1972,8 +2074,6 @@
 }
 
 
-#ifdef CONFIG_IP_MULTICAST
- 
 int ip_mc_procinfo(char *buffer, char **start, off_t offset, int length)
 {
 	off_t pos=0, begin=0;
@@ -1991,7 +2091,9 @@
 		if (in_dev == NULL)
 			continue;
 
+#ifdef CONFIG_IP_MULTICAST
 		querier = IGMP_V1_SEEN(in_dev) ? "V1" : "V2";
+#endif
 
 		len+=sprintf(buffer+len,"%d\t%-10s: %5d %7s\n",
 			     dev->ifindex, dev->name, dev->mc_count, querier);
@@ -2049,11 +2151,8 @@
 
 		for (imc=in_dev->mc_list; imc; imc=imc->next) {
 			struct ip_sf_list *psf;
-			unsigned long icount, xcount;
 
 			spin_lock_bh(&imc->lock);
-			icount = imc->sfcount[MCAST_INCLUDE];
-			xcount = imc->sfcount[MCAST_EXCLUDE];
 			for (psf=imc->sources; psf; psf=psf->sf_next) {
 				if (first) {
 					len += sprintf(buffer+len, "%3s %6s "
@@ -2080,33 +2179,6 @@
 					in_dev_put(in_dev);
 					goto done;
 				}
-				icount -= psf->sf_count[MCAST_INCLUDE];
-				xcount -= psf->sf_count[MCAST_EXCLUDE];
-			}
-			if (icount > 0 || xcount > 0) {
-				if (first) {
-					len += sprintf(buffer+len, "%3s %6s "
-						"%10s %10s %6s %6s\n", "Idx",
-						"Device", "MCA", "SRC", "INC",
-						"EXC");
-					first = 0;
-				}
-				len += sprintf(buffer+len, "%3d %6.6s 0x%08x "
-					"%10s %6lu %6lu\n", dev->ifindex,
-					dev->name, ntohl(imc->multiaddr),
-					"NONE", icount, xcount);
-				pos=begin+len;
-				if(pos<offset)
-				{
-					len=0;
-					begin=pos;
-				}
-				if(pos>offset+length) {
-					spin_unlock_bh(&imc->lock);
-					read_unlock(&in_dev->lock);
-					in_dev_put(in_dev);
-					goto done;
-				}
 			}
 			spin_unlock_bh(&imc->lock);
 		}
@@ -2124,6 +2196,4 @@
 		len=0;
 	return len;
 }
-
-#endif
 
diff -Nru a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
--- a/net/ipv4/ip_gre.c	Wed Apr 30 22:28:14 2003
+++ b/net/ipv4/ip_gre.c	Wed Apr 30 22:28:14 2003
@@ -159,7 +159,7 @@
 
 static rwlock_t ipgre_lock = RW_LOCK_UNLOCKED;
 
-/* Given src, dst and key, find approriate for input tunnel. */
+/* Given src, dst and key, find appropriate for input tunnel. */
 
 static struct ip_tunnel * ipgre_tunnel_lookup(u32 remote, u32 local, u32 key)
 {
@@ -777,9 +777,6 @@
 		skb->dst->ops->update_pmtu(skb->dst, mtu);
 
 	if (skb->protocol == htons(ETH_P_IP)) {
-		if (skb->dst)
-			skb->dst->ops->update_pmtu(skb->dst, mtu);
-
 		df |= (old_iph->frag_off&htons(IP_DF));
 
 		if ((old_iph->frag_off&htons(IP_DF)) &&
diff -Nru a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
--- a/net/ipv4/ip_output.c	Wed Apr 30 22:28:19 2003
+++ b/net/ipv4/ip_output.c	Wed Apr 30 22:28:19 2003
@@ -86,7 +86,7 @@
  *      Shall we try to damage output packets if routing dev changes?
  */
 
-int sysctl_ip_dynaddr = 0;
+int sysctl_ip_dynaddr;
 int sysctl_ip_default_ttl = IPDEFTTL;
 
 /* Generate a checksum for an outgoing IP datagram. */
@@ -263,7 +263,7 @@
 				newskb->dev, ip_dev_loopback_xmit);
 	}
 
-	if (skb->len > dev->mtu || skb_shinfo(skb)->frag_list)
+	if (skb->len > dst_pmtu(&rt->u.dst) || skb_shinfo(skb)->frag_list)
 		return ip_fragment(skb, ip_finish_output);
 	else
 		return ip_finish_output(skb);
@@ -273,7 +273,7 @@
 {
 	IP_INC_STATS(IpOutRequests);
 
-	if ((skb->len > skb->dst->dev->mtu || skb_shinfo(skb)->frag_list) &&
+	if ((skb->len > dst_pmtu(skb->dst) || skb_shinfo(skb)->frag_list) &&
 	    !skb_shinfo(skb)->tso_size)
 		return ip_fragment(skb, ip_finish_output);
 	else
@@ -1312,6 +1312,6 @@
 
 #ifdef CONFIG_IP_MULTICAST
 	proc_net_create("igmp", 0, ip_mc_procinfo);
-	proc_net_create("mcfilter", 0, ip_mcf_procinfo);
 #endif
+	proc_net_create("mcfilter", 0, ip_mcf_procinfo);
 }
diff -Nru a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
--- a/net/ipv4/ip_sockglue.c	Wed Apr 30 22:28:06 2003
+++ b/net/ipv4/ip_sockglue.c	Wed Apr 30 22:28:06 2003
@@ -177,7 +177,7 @@
 }
 
 
-/* Special input handler for packets catched by router alert option.
+/* Special input handler for packets caught by router alert option.
    They are selected only by protocol field, and then processed likely
    local ones; but only if someone wants them! Otherwise, router
    not running rsvpd will kill RSVP.
@@ -631,7 +631,7 @@
 				kfree(msf);
 				break;
 			}
-			err = ip_mc_msfilter(sk, msf);
+			err = ip_mc_msfilter(sk, msf, 0);
 			kfree(msf);
 			break;
 		}
@@ -670,7 +670,142 @@
 				omode = MCAST_INCLUDE;
 				add = 0;
 			}
-			err = ip_mc_source(add, omode, sk, &mreqs);
+			err = ip_mc_source(add, omode, sk, &mreqs, 0);
+			break;
+		}
+		case MCAST_JOIN_GROUP:
+		case MCAST_LEAVE_GROUP: 
+		{
+			struct group_req greq;
+			struct sockaddr_in *psin;
+			struct ip_mreqn mreq;
+
+			if (optlen < sizeof(struct group_req))
+				goto e_inval;
+			err = -EFAULT;
+			if(copy_from_user(&greq, optval, sizeof(greq)))
+				break;
+			psin = (struct sockaddr_in *)&greq.gr_group;
+			if (psin->sin_family != AF_INET)
+				goto e_inval;
+			memset(&mreq, 0, sizeof(mreq));
+			mreq.imr_multiaddr = psin->sin_addr;
+			mreq.imr_ifindex = greq.gr_interface;
+
+			if (optname == MCAST_JOIN_GROUP)
+				err = ip_mc_join_group(sk, &mreq);
+			else
+				err = ip_mc_leave_group(sk, &mreq);
+			break;
+		}
+		case MCAST_JOIN_SOURCE_GROUP:
+		case MCAST_LEAVE_SOURCE_GROUP:
+		case MCAST_BLOCK_SOURCE:
+		case MCAST_UNBLOCK_SOURCE:
+		{
+			struct group_source_req greqs;
+			struct ip_mreq_source mreqs;
+			struct sockaddr_in *psin;
+			int omode, add;
+
+			if (optlen != sizeof(struct group_source_req))
+				goto e_inval;
+			if (copy_from_user(&greqs, optval, sizeof(greqs))) {
+				err = -EFAULT;
+				break;
+			}
+			if (greqs.gsr_group.ss_family != AF_INET ||
+			    greqs.gsr_source.ss_family != AF_INET) {
+				err = -EADDRNOTAVAIL;
+				break;
+			}
+			psin = (struct sockaddr_in *)&greqs.gsr_group;
+			mreqs.imr_multiaddr = psin->sin_addr.s_addr;
+			psin = (struct sockaddr_in *)&greqs.gsr_source;
+			mreqs.imr_sourceaddr = psin->sin_addr.s_addr;
+			mreqs.imr_interface = 0; /* use index for mc_source */
+
+			if (optname == MCAST_BLOCK_SOURCE) {
+				omode = MCAST_EXCLUDE;
+				add = 1;
+			} else if (optname == MCAST_UNBLOCK_SOURCE) {
+				omode = MCAST_EXCLUDE;
+				add = 0;
+			} else if (optname == MCAST_JOIN_SOURCE_GROUP) {
+				struct ip_mreqn mreq;
+
+				psin = (struct sockaddr_in *)&greqs.gsr_group;
+				mreq.imr_multiaddr = psin->sin_addr;
+				mreq.imr_address.s_addr = 0;
+				mreq.imr_ifindex = greqs.gsr_interface;
+				err = ip_mc_join_group(sk, &mreq);
+				if (err)
+					break;
+				omode = MCAST_INCLUDE;
+				add = 1;
+			} else /* MCAST_LEAVE_SOURCE_GROUP */ {
+				omode = MCAST_INCLUDE;
+				add = 0;
+			}
+			err = ip_mc_source(add, omode, sk, &mreqs,
+				greqs.gsr_interface);
+			break;
+		}
+		case MCAST_MSFILTER:
+		{
+			struct sockaddr_in *psin;
+			struct ip_msfilter *msf = 0;
+			struct group_filter *gsf = 0;
+			int msize, i, ifindex;
+
+			if (optlen < GROUP_FILTER_SIZE(0))
+				goto e_inval;
+			gsf = (struct group_filter *)kmalloc(optlen,GFP_KERNEL);
+			if (gsf == 0) {
+				err = -ENOBUFS;
+				break;
+			}
+			err = -EFAULT;
+			if (copy_from_user(gsf, optval, optlen)) {
+				goto mc_msf_out;
+			}
+			if (GROUP_FILTER_SIZE(gsf->gf_numsrc) < optlen) {
+				err = EINVAL;
+				goto mc_msf_out;
+			}
+			msize = IP_MSFILTER_SIZE(gsf->gf_numsrc);
+			msf = (struct ip_msfilter *)kmalloc(msize,GFP_KERNEL);
+			if (msf == 0) {
+				err = -ENOBUFS;
+				goto mc_msf_out;
+			}
+			ifindex = gsf->gf_interface;
+			psin = (struct sockaddr_in *)&gsf->gf_group;
+			if (psin->sin_family != AF_INET) {
+				err = -EADDRNOTAVAIL;
+				goto mc_msf_out;
+			}
+			msf->imsf_multiaddr = psin->sin_addr.s_addr;
+			msf->imsf_interface = 0;
+			msf->imsf_fmode = gsf->gf_fmode;
+			msf->imsf_numsrc = gsf->gf_numsrc;
+			err = -EADDRNOTAVAIL;
+			for (i=0; i<gsf->gf_numsrc; ++i) {
+				psin = (struct sockaddr_in *)&gsf->gf_slist[i];
+
+				if (psin->sin_family != AF_INET)
+					goto mc_msf_out;
+				msf->imsf_slist[i] = psin->sin_addr.s_addr;
+			}
+			kfree(gsf);
+			gsf = 0;
+
+			err = ip_mc_msfilter(sk, msf, ifindex);
+mc_msf_out:
+			if (msf)
+				kfree(msf);
+			if (gsf)
+				kfree(gsf);
 			break;
 		}
 		case IP_ROUTER_ALERT:	
@@ -826,12 +961,34 @@
 			struct ip_msfilter msf;
 			int err;
 
-			if (len < IP_MSFILTER_SIZE(0))
+			if (len < IP_MSFILTER_SIZE(0)) {
+				release_sock(sk);
 				return -EINVAL;
-			if (copy_from_user(&msf, optval, IP_MSFILTER_SIZE(0)))
+			}
+			if (copy_from_user(&msf, optval, IP_MSFILTER_SIZE(0))) {
+				release_sock(sk);
 				return -EFAULT;
+			}
 			err = ip_mc_msfget(sk, &msf,
 				(struct ip_msfilter *)optval, optlen);
+			release_sock(sk);
+			return err;
+		}
+		case MCAST_MSFILTER:
+		{
+			struct group_filter gsf;
+			int err;
+
+			if (len < GROUP_FILTER_SIZE(0)) {
+				release_sock(sk);
+				return -EINVAL;
+			}
+			if (copy_from_user(&gsf, optval, GROUP_FILTER_SIZE(0))) {
+				release_sock(sk);
+				return -EFAULT;
+			}
+			err = ip_mc_gsfget(sk, &gsf,
+				(struct group_filter *)optval, optlen);
 			release_sock(sk);
 			return err;
 		}
diff -Nru a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
--- a/net/ipv4/ipconfig.c	Wed Apr 30 22:28:04 2003
+++ b/net/ipv4/ipconfig.c	Wed Apr 30 22:28:04 2003
@@ -27,7 +27,7 @@
  *  Merged changes from 2.2.19 into 2.4.3
  *              -- Eric Biederman <ebiederman@lnxi.com>, 22 April Aug 2001
  *
- *  Multipe Nameservers in /proc/net/pnp
+ *  Multiple Nameservers in /proc/net/pnp
  *              --  Josef Siemes <jsiemes@web.de>, Aug 2002
  */
 
diff -Nru a/net/ipv4/ipip.c b/net/ipv4/ipip.c
--- a/net/ipv4/ipip.c	Wed Apr 30 22:28:20 2003
+++ b/net/ipv4/ipip.c	Wed Apr 30 22:28:20 2003
@@ -433,7 +433,7 @@
 		fl.fl4_src = eiph->saddr;
 		fl.fl4_tos = eiph->tos;
 		if (ip_route_output_key(&rt, &fl) ||
-		    rt->u.dst.dev->type != ARPHRD_IPGRE) {
+		    rt->u.dst.dev->type != ARPHRD_TUNNEL) {
 			ip_rt_put(rt);
 			kfree_skb(skb2);
 			return;
@@ -441,7 +441,7 @@
 	} else {
 		ip_rt_put(rt);
 		if (ip_route_input(skb2, eiph->daddr, eiph->saddr, eiph->tos, skb2->dev) ||
-		    skb2->dst->dev->type != ARPHRD_IPGRE) {
+		    skb2->dst->dev->type != ARPHRD_TUNNEL) {
 			kfree_skb(skb2);
 			return;
 		}
diff -Nru a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig
--- a/net/ipv4/netfilter/Kconfig	Wed Apr 30 22:28:15 2003
+++ b/net/ipv4/netfilter/Kconfig	Wed Apr 30 22:28:15 2003
@@ -48,7 +48,7 @@
 	  <file:Documentation/modules.txt>.  If unsure, say `Y'.
 
 config IP_NF_TFTP
-	tristate "TFTP prtocol support"
+	tristate "TFTP protocol support"
 	depends on IP_NF_CONNTRACK
 	help
 	  TFTP connection tracking helper, this is required depending
diff -Nru a/net/ipv4/netfilter/arptable_filter.c b/net/ipv4/netfilter/arptable_filter.c
--- a/net/ipv4/netfilter/arptable_filter.c	Wed Apr 30 22:28:03 2003
+++ b/net/ipv4/netfilter/arptable_filter.c	Wed Apr 30 22:28:03 2003
@@ -133,11 +133,13 @@
 static struct nf_hook_ops arpt_ops[] = {
 	{
 		.hook		= arpt_hook,
+		.owner		= THIS_MODULE,
 		.pf		= NF_ARP,
 		.hooknum	= NF_ARP_IN,
 	},
 	{
 		.hook		= arpt_hook,
+		.owner		= THIS_MODULE,
 		.pf		= NF_ARP,
 		.hooknum	= NF_ARP_OUT,
 	}
diff -Nru a/net/ipv4/netfilter/ip_conntrack_amanda.c b/net/ipv4/netfilter/ip_conntrack_amanda.c
--- a/net/ipv4/netfilter/ip_conntrack_amanda.c	Wed Apr 30 22:28:11 2003
+++ b/net/ipv4/netfilter/ip_conntrack_amanda.c	Wed Apr 30 22:28:11 2003
@@ -207,5 +207,7 @@
 	return 0;
 }
 
+EXPORT_SYMBOL(ip_amanda_lock);
+
 module_init(init);
 module_exit(fini);
diff -Nru a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
--- a/net/ipv4/netfilter/ip_conntrack_core.c	Wed Apr 30 22:28:03 2003
+++ b/net/ipv4/netfilter/ip_conntrack_core.c	Wed Apr 30 22:28:03 2003
@@ -1421,7 +1421,7 @@
 	ip_conntrack_max = 8 * ip_conntrack_htable_size;
 
 	printk("ip_conntrack version %s (%u buckets, %d max)"
-	       " - %d bytes per conntrack\n", IP_CONNTRACK_VERSION,
+	       " - %Zd bytes per conntrack\n", IP_CONNTRACK_VERSION,
 	       ip_conntrack_htable_size, ip_conntrack_max,
 	       sizeof(struct ip_conntrack));
 
diff -Nru a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_conntrack_ftp.c
--- a/net/ipv4/netfilter/ip_conntrack_ftp.c	Wed Apr 30 22:28:14 2003
+++ b/net/ipv4/netfilter/ip_conntrack_ftp.c	Wed Apr 30 22:28:14 2003
@@ -437,9 +437,7 @@
 	return 0;
 }
 
-#ifdef CONFIG_IP_NF_NAT_NEEDED
 EXPORT_SYMBOL(ip_ftp_lock);
-#endif
 
 MODULE_LICENSE("GPL");
 module_init(init);
diff -Nru a/net/ipv4/netfilter/ip_conntrack_irc.c b/net/ipv4/netfilter/ip_conntrack_irc.c
--- a/net/ipv4/netfilter/ip_conntrack_irc.c	Wed Apr 30 22:28:14 2003
+++ b/net/ipv4/netfilter/ip_conntrack_irc.c	Wed Apr 30 22:28:14 2003
@@ -289,9 +289,7 @@
 	}
 }
 
-#ifdef CONFIG_IP_NF_NAT_NEEDED
 EXPORT_SYMBOL(ip_irc_lock);
-#endif
 
 module_init(init);
 module_exit(fini);
diff -Nru a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
--- a/net/ipv4/netfilter/ip_conntrack_standalone.c	Wed Apr 30 22:28:08 2003
+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c	Wed Apr 30 22:28:08 2003
@@ -227,6 +227,7 @@
    make it the first hook. */
 static struct nf_hook_ops ip_conntrack_in_ops = {
 	.hook		= ip_conntrack_in,
+	.owner		= THIS_MODULE,
 	.pf		= PF_INET,
 	.hooknum	= NF_IP_PRE_ROUTING,
 	.priority	= NF_IP_PRI_CONNTRACK,
@@ -234,6 +235,7 @@
 
 static struct nf_hook_ops ip_conntrack_local_out_ops = {
 	.hook		= ip_conntrack_local,
+	.owner		= THIS_MODULE,
 	.pf		= PF_INET,
 	.hooknum	= NF_IP_LOCAL_OUT,
 	.priority	= NF_IP_PRI_CONNTRACK,
@@ -242,6 +244,7 @@
 /* Refragmenter; last chance. */
 static struct nf_hook_ops ip_conntrack_out_ops = {
 	.hook		= ip_refrag,
+	.owner		= THIS_MODULE,
 	.pf		= PF_INET,
 	.hooknum	= NF_IP_POST_ROUTING,
 	.priority	= NF_IP_PRI_LAST,
@@ -249,6 +252,7 @@
 
 static struct nf_hook_ops ip_conntrack_local_in_ops = {
 	.hook		= ip_confirm,
+	.owner		= THIS_MODULE,
 	.pf		= PF_INET,
 	.hooknum	= NF_IP_LOCAL_IN,
 	.priority	= NF_IP_PRI_LAST-1,
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	Wed Apr 30 22:28:08 2003
+++ b/net/ipv4/netfilter/ip_fw_compat.c	Wed Apr 30 22:28:08 2003
@@ -226,6 +226,7 @@
 
 static struct nf_hook_ops preroute_ops = {
 	.hook		= fw_in,
+	.owner		= THIS_MODULE,
 	.pf		= PF_INET,
 	.hooknum	= NF_IP_PRE_ROUTING,
 	.priority	= NF_IP_PRI_FILTER,
@@ -233,6 +234,7 @@
 
 static struct nf_hook_ops postroute_ops = {
 	.hook		= fw_in,
+	.owner		= THIS_MODULE,
 	.pf		= PF_INET,
 	.hooknum	= NF_IP_POST_ROUTING,
 	.priority	= NF_IP_PRI_FILTER,
@@ -240,6 +242,7 @@
 
 static struct nf_hook_ops forward_ops = {
 	.hook		= fw_in,
+	.owner		= THIS_MODULE,
 	.pf		= PF_INET,
 	.hooknum	= NF_IP_FORWARD,
 	.priority	= NF_IP_PRI_FILTER,
@@ -247,6 +250,7 @@
 
 static struct nf_hook_ops local_in_ops = {
 	.hook		= fw_confirm,
+	.owner		= THIS_MODULE,
 	.pf		= PF_INET,
 	.hooknum	= NF_IP_LOCAL_IN,
 	.priority	= NF_IP_PRI_LAST - 1,
diff -Nru a/net/ipv4/netfilter/ip_fw_compat_masq.c b/net/ipv4/netfilter/ip_fw_compat_masq.c
--- a/net/ipv4/netfilter/ip_fw_compat_masq.c	Wed Apr 30 22:28:15 2003
+++ b/net/ipv4/netfilter/ip_fw_compat_masq.c	Wed Apr 30 22:28:15 2003
@@ -1,7 +1,7 @@
 /* Masquerading compatibility layer.
 
    Note that there are no restrictions on other programs binding to
-   ports 61000:65095 (in 2.0 and 2.2 they get EADDRINUSE).  Just DONT
+   ports 61000:65095 (in 2.0 and 2.2 they get EADDRINUSE).  Just DON'T
    DO IT.
  */
 #include <linux/skbuff.h>
diff -Nru a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c
--- a/net/ipv4/netfilter/ip_nat_standalone.c	Wed Apr 30 22:28:15 2003
+++ b/net/ipv4/netfilter/ip_nat_standalone.c	Wed Apr 30 22:28:15 2003
@@ -238,6 +238,7 @@
 /* Before packet filtering, change destination */
 static struct nf_hook_ops ip_nat_in_ops = {
 	.hook		= ip_nat_fn,
+	.owner		= THIS_MODULE,
 	.pf		= PF_INET,
 	.hooknum	= NF_IP_PRE_ROUTING,
 	.priority	= NF_IP_PRI_NAT_DST,
@@ -246,6 +247,7 @@
 /* After packet filtering, change source */
 static struct nf_hook_ops ip_nat_out_ops = {
 	.hook		= ip_nat_out,
+	.owner		= THIS_MODULE,
 	.pf		= PF_INET,
 	.hooknum	= NF_IP_POST_ROUTING,
 	.priority	= NF_IP_PRI_NAT_SRC,
@@ -254,6 +256,7 @@
 /* Before packet filtering, change destination */
 static struct nf_hook_ops ip_nat_local_out_ops = {
 	.hook		= ip_nat_local_fn,
+	.owner		= THIS_MODULE,
 	.pf		= PF_INET,
 	.hooknum	= NF_IP_LOCAL_OUT,
 	.priority	= NF_IP_PRI_NAT_DST,
@@ -262,6 +265,7 @@
 #ifdef CONFIG_IP_NF_NAT_LOCAL
 static struct nf_hook_ops ip_nat_local_in_ops = {
 	.hook		= ip_nat_fn,
+	.owner		= THIS_MODULE,
 	.pf		= PF_INET,
 	.hooknum	= NF_IP_LOCAL_IN,
 	.priority	= NF_IP_PRI_NAT_SRC,
diff -Nru a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c
--- a/net/ipv4/netfilter/ip_queue.c	Wed Apr 30 22:28:20 2003
+++ b/net/ipv4/netfilter/ip_queue.c	Wed Apr 30 22:28:20 2003
@@ -300,8 +300,9 @@
 	write_lock_bh(&queue_lock);
 	
 	if (!peer_pid)
-		goto err_out_unlock;
+		goto err_out_free_nskb; 
 
+ 	/* netlink_unicast will either free the nskb or attach it to a socket */ 
 	status = netlink_unicast(ipqnl, nskb, peer_pid, MSG_DONTWAIT);
 	if (status < 0)
 		goto err_out_unlock;
@@ -312,6 +313,9 @@
 
 	write_unlock_bh(&queue_lock);
 	return status;
+
+err_out_free_nskb:
+	kfree_skb(nskb); 
 	
 err_out_unlock:
 	write_unlock_bh(&queue_lock);
diff -Nru a/net/ipv4/netfilter/ipfwadm_core.c b/net/ipv4/netfilter/ipfwadm_core.c
--- a/net/ipv4/netfilter/ipfwadm_core.c	Wed Apr 30 22:28:08 2003
+++ b/net/ipv4/netfilter/ipfwadm_core.c	Wed Apr 30 22:28:08 2003
@@ -505,7 +505,7 @@
 		   It will not affect performance if you will follow
 		   the following simple rules:
 
-		   - if inteface is aliased, ALWAYS specify fw_viadev,
+		   - if interface is aliased, ALWAYS specify fw_viadev,
 		     so that previous check will guarantee, that we will
 		     not waste time when packet arrive on another interface.
 
diff -Nru a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c
--- a/net/ipv4/netfilter/ipt_REJECT.c	Wed Apr 30 22:28:15 2003
+++ b/net/ipv4/netfilter/ipt_REJECT.c	Wed Apr 30 22:28:15 2003
@@ -11,7 +11,6 @@
 #include <net/icmp.h>
 #include <net/ip.h>
 #include <net/tcp.h>
-struct in_device;
 #include <net/route.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
 #include <linux/netfilter_ipv4/ipt_REJECT.h>
@@ -71,8 +70,7 @@
 						.saddr = (local ?
 							  oldskb->nh.iph->daddr :
 							  0),
-						.tos = (RT_TOS(oldskb->nh.iph->tos) |
-							RTO_CONN) } } };
+						.tos = RT_TOS(oldskb->nh.iph->tos) } } };
 
 		/* Routing: if not headed for us, route won't like source */
 		if (ip_route_output_key(&rt, &fl))
@@ -88,8 +86,10 @@
 	   hh_len of incoming interface < hh_len of outgoing interface */
 	nskb = skb_copy_expand(oldskb, hh_len, skb_tailroom(oldskb),
 			       GFP_ATOMIC);
-	if (!nskb)
+	if (!nskb) {
+		dst_release(&rt->u.dst);
 		return;
+	}
 
 	dst_release(nskb->dst);
 	nskb->dst = &rt->u.dst;
diff -Nru a/net/ipv4/netfilter/ipt_physdev.c b/net/ipv4/netfilter/ipt_physdev.c
--- a/net/ipv4/netfilter/ipt_physdev.c	Wed Apr 30 22:28:06 2003
+++ b/net/ipv4/netfilter/ipt_physdev.c	Wed Apr 30 22:28:06 2003
@@ -4,6 +4,9 @@
 #include <linux/skbuff.h>
 #include <linux/netfilter_ipv4/ipt_physdev.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter_bridge.h>
+#define MATCH   1
+#define NOMATCH 0
 
 static int
 match(const struct sk_buff *skb,
@@ -25,29 +28,62 @@
 	/* Not a bridged IP packet or no info available yet:
 	 * LOCAL_OUT/mangle and LOCAL_OUT/nat don't know if
 	 * the destination device will be a bridge. */
-	if (!(nf_bridge = skb->nf_bridge))
-		return 1;
+	if (!(nf_bridge = skb->nf_bridge)) {
+		/* Return MATCH if the invert flags of the used options are on */
+		if ((info->bitmask & IPT_PHYSDEV_OP_BRIDGED) &&
+		    !(info->invert & IPT_PHYSDEV_OP_BRIDGED))
+			return NOMATCH;
+		if ((info->bitmask & IPT_PHYSDEV_OP_ISIN) &&
+		    !(info->invert & IPT_PHYSDEV_OP_ISIN))
+			return NOMATCH;
+		if ((info->bitmask & IPT_PHYSDEV_OP_ISOUT) &&
+		    !(info->invert & IPT_PHYSDEV_OP_ISOUT))
+			return NOMATCH;
+		if ((info->bitmask & IPT_PHYSDEV_OP_IN) &&
+		    !(info->invert & IPT_PHYSDEV_OP_IN))
+			return NOMATCH;
+		if ((info->bitmask & IPT_PHYSDEV_OP_OUT) &&
+		    !(info->invert & IPT_PHYSDEV_OP_OUT))
+			return NOMATCH;
+		return MATCH;
+	}
 
-	indev = nf_bridge->physindev ? nf_bridge->physindev->name : nulldevname;
-	outdev = nf_bridge->physoutdev ?
-		 nf_bridge->physoutdev->name : nulldevname;
+	/* This only makes sense in the FORWARD and POSTROUTING chains */
+	if ((info->bitmask & IPT_PHYSDEV_OP_BRIDGED) &&
+	    (!!(nf_bridge->mask & BRNF_BRIDGED) ^
+	    !(info->invert & IPT_PHYSDEV_OP_BRIDGED)))
+		return NOMATCH;
+
+	if ((info->bitmask & IPT_PHYSDEV_OP_ISIN &&
+	    (!nf_bridge->physindev ^ !!(info->invert & IPT_PHYSDEV_OP_ISIN))) ||
+	    (info->bitmask & IPT_PHYSDEV_OP_ISOUT &&
+	    (!nf_bridge->physoutdev ^ !!(info->invert & IPT_PHYSDEV_OP_ISOUT))))
+		return NOMATCH;
 
+	if (!(info->bitmask & IPT_PHYSDEV_OP_IN))
+		goto match_outdev;
+	indev = nf_bridge->physindev ? nf_bridge->physindev->name : nulldevname;
 	for (i = 0, ret = 0; i < IFNAMSIZ/sizeof(unsigned long); i++) {
 		ret |= (((const unsigned long *)indev)[i]
 			^ ((const unsigned long *)info->physindev)[i])
 			& ((const unsigned long *)info->in_mask)[i];
 	}
 
-	if ((ret == 0) ^ !(info->invert & IPT_PHYSDEV_OP_MATCH_IN))
-		return 0;
+	if ((ret == 0) ^ !(info->invert & IPT_PHYSDEV_OP_IN))
+		return NOMATCH;
 
+match_outdev:
+	if (!(info->bitmask & IPT_PHYSDEV_OP_OUT))
+		return MATCH;
+	outdev = nf_bridge->physoutdev ?
+		 nf_bridge->physoutdev->name : nulldevname;
 	for (i = 0, ret = 0; i < IFNAMSIZ/sizeof(unsigned long); i++) {
 		ret |= (((const unsigned long *)outdev)[i]
 			^ ((const unsigned long *)info->physoutdev)[i])
 			& ((const unsigned long *)info->out_mask)[i];
 	}
 
-	return (ret != 0) ^ !(info->invert & IPT_PHYSDEV_OP_MATCH_OUT);
+	return (ret != 0) ^ !(info->invert & IPT_PHYSDEV_OP_OUT);
 }
 
 static int
@@ -57,9 +93,13 @@
 		       unsigned int matchsize,
 		       unsigned int hook_mask)
 {
+	const struct ipt_physdev_info *info = matchinfo;
+
 	if (matchsize != IPT_ALIGN(sizeof(struct ipt_physdev_info)))
 		return 0;
-
+	if (!(info->bitmask & IPT_PHYSDEV_OP_MASK) ||
+	    info->bitmask & ~IPT_PHYSDEV_OP_MASK)
+		return 0;
 	return 1;
 }
 
diff -Nru a/net/ipv4/netfilter/iptable_filter.c b/net/ipv4/netfilter/iptable_filter.c
--- a/net/ipv4/netfilter/iptable_filter.c	Wed Apr 30 22:28:07 2003
+++ b/net/ipv4/netfilter/iptable_filter.c	Wed Apr 30 22:28:07 2003
@@ -125,18 +125,21 @@
 static struct nf_hook_ops ipt_ops[] = {
 	{
 		.hook		= ipt_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_INET,
 		.hooknum	= NF_IP_LOCAL_IN,
 		.priority	= NF_IP_PRI_FILTER,
 	},
 	{
 		.hook		= ipt_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_INET,
 		.hooknum	= NF_IP_FORWARD,
 		.priority	= NF_IP_PRI_FILTER,
 	},
 	{
 		.hook		= ipt_local_out_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_INET,
 		.hooknum	= NF_IP_LOCAL_OUT,
 		.priority	= NF_IP_PRI_FILTER,
diff -Nru a/net/ipv4/netfilter/iptable_mangle.c b/net/ipv4/netfilter/iptable_mangle.c
--- a/net/ipv4/netfilter/iptable_mangle.c	Wed Apr 30 22:28:16 2003
+++ b/net/ipv4/netfilter/iptable_mangle.c	Wed Apr 30 22:28:16 2003
@@ -178,30 +178,35 @@
 static struct nf_hook_ops ipt_ops[] = {
 	{
 		.hook		= ipt_route_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_INET,
 		.hooknum	= NF_IP_PRE_ROUTING, 
 		.priority	= NF_IP_PRI_MANGLE,
 	},
 	{
 		.hook		= ipt_route_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_INET,
 		.hooknum	= NF_IP_LOCAL_IN,
 		.priority	= NF_IP_PRI_MANGLE,
 	},
 	{
 		.hook		= ipt_route_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_INET,
 		.hooknum	= NF_IP_FORWARD,
 		.priority	= NF_IP_PRI_MANGLE,
 	},
 	{
 		.hook		= ipt_local_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_INET,
 		.hooknum	= NF_IP_LOCAL_OUT,
 		.priority	= NF_IP_PRI_MANGLE,
 	},
 	{
 		.hook		= ipt_route_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_INET,
 		.hooknum	= NF_IP_POST_ROUTING,
 		.priority	= NF_IP_PRI_MANGLE,
diff -Nru a/net/ipv4/route.c b/net/ipv4/route.c
--- a/net/ipv4/route.c	Wed Apr 30 22:28:19 2003
+++ b/net/ipv4/route.c	Wed Apr 30 22:28:19 2003
@@ -44,7 +44,7 @@
  *		Alan Cox	:	Multicast fixed (I hope)
  * 		Pavel Krauz	:	Limited broadcast fixed
  *		Mike McLagan	:	Routing by source
- *	Alexey Kuznetsov	:	End of old history. Splitted to fib.c and
+ *	Alexey Kuznetsov	:	End of old history. Split to fib.c and
  *					route.c and rewritten from scratch.
  *		Andi Kleen	:	Load-limit warning messages.
  *	Vitaly E. Lavrov	:	Transparent proxy revived after year coma.
diff -Nru a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
--- a/net/ipv4/tcp_input.c	Wed Apr 30 22:28:14 2003
+++ b/net/ipv4/tcp_input.c	Wed Apr 30 22:28:14 2003
@@ -78,16 +78,16 @@
 #ifdef CONFIG_INET_ECN
 int sysctl_tcp_ecn = 1;
 #else
-int sysctl_tcp_ecn = 0;
+int sysctl_tcp_ecn;
 #endif
 int sysctl_tcp_dsack = 1;
 int sysctl_tcp_app_win = 31;
 int sysctl_tcp_adv_win_scale = 2;
 
-int sysctl_tcp_stdurg = 0;
-int sysctl_tcp_rfc1337 = 0;
+int sysctl_tcp_stdurg;
+int sysctl_tcp_rfc1337;
 int sysctl_tcp_max_orphans = NR_FILE;
-int sysctl_tcp_frto = 0;
+int sysctl_tcp_frto;
 
 #define FLAG_DATA		0x01 /* Incoming frame contained data.		*/
 #define FLAG_WIN_UPDATE		0x02 /* Incoming ACK was a window update.	*/
diff -Nru a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
--- a/net/ipv4/tcp_ipv4.c	Wed Apr 30 22:28:07 2003
+++ b/net/ipv4/tcp_ipv4.c	Wed Apr 30 22:28:07 2003
@@ -838,7 +838,7 @@
 	/* Socket identity is still unknown (sport may be zero).
 	 * However we set state to SYN-SENT and not releasing socket
 	 * lock select source port, enter ourselves into the hash tables and
-	 * complete initalization after this.
+	 * complete initialization after this.
 	 */
 	tcp_set_state(sk, TCP_SYN_SENT);
 	err = tcp_v4_hash_connect(sk);
diff -Nru a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
--- a/net/ipv4/tcp_minisocks.c	Wed Apr 30 22:28:14 2003
+++ b/net/ipv4/tcp_minisocks.c	Wed Apr 30 22:28:14 2003
@@ -33,11 +33,11 @@
 #define SYNC_INIT 1
 #endif
 
-int sysctl_tcp_tw_recycle = 0;
+int sysctl_tcp_tw_recycle;
 int sysctl_tcp_max_tw_buckets = NR_FILE*2;
 
 int sysctl_tcp_syncookies = SYNC_INIT; 
-int sysctl_tcp_abort_on_overflow = 0;
+int sysctl_tcp_abort_on_overflow;
 
 static __inline__ int tcp_in_window(u32 seq, u32 end_seq, u32 s_win, u32 e_win)
 {
@@ -50,7 +50,7 @@
 
 /* New-style handling of TIME_WAIT sockets. */
 
-int tcp_tw_count = 0;
+int tcp_tw_count;
 
 
 /* Must be called with locally disabled BHs. */
diff -Nru a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
--- a/net/ipv4/tcp_output.c	Wed Apr 30 22:28:12 2003
+++ b/net/ipv4/tcp_output.c	Wed Apr 30 22:28:12 2003
@@ -79,7 +79,7 @@
  *    large MSS.
  * 4. We do not make 3, we advertise MSS, calculated from first
  *    hop device mtu, but allow to raise it to ip_rt_min_advmss.
- *    This may be overriden via information stored in routing table.
+ *    This may be overridden via information stored in routing table.
  * 5. Value 65535 for MSS is valid in IPv6 and means "as large as possible,
  *    probably even Jumbo".
  */
diff -Nru a/net/ipv4/xfrm4_tunnel.c b/net/ipv4/xfrm4_tunnel.c
--- a/net/ipv4/xfrm4_tunnel.c	Wed Apr 30 22:28:04 2003
+++ b/net/ipv4/xfrm4_tunnel.c	Wed Apr 30 22:28:04 2003
@@ -174,6 +174,8 @@
 
 static int ipip_init_state(struct xfrm_state *x, void *args)
 {
+	if (!x->props.mode)
+		return -EINVAL;
 	x->props.header_len = sizeof(struct iphdr);
 
 	return 0;
diff -Nru a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
--- a/net/ipv6/addrconf.c	Wed Apr 30 22:28:17 2003
+++ b/net/ipv6/addrconf.c	Wed Apr 30 22:28:17 2003
@@ -132,45 +132,43 @@
 
 static struct notifier_block *inet6addr_chain;
 
-struct ipv6_devconf ipv6_devconf =
-{
-	0,				/* forwarding		*/
-	IPV6_DEFAULT_HOPLIMIT,		/* hop limit		*/
-	IPV6_MIN_MTU,			/* mtu			*/
-	1,				/* accept RAs		*/
-	1,				/* accept redirects	*/
-	1,				/* autoconfiguration	*/
-	1,				/* dad transmits	*/
-	MAX_RTR_SOLICITATIONS,		/* router solicits	*/
-	RTR_SOLICITATION_INTERVAL,	/* rtr solicit interval	*/
-	MAX_RTR_SOLICITATION_DELAY,	/* rtr solicit delay	*/
+struct ipv6_devconf ipv6_devconf = {
+	.forwarding		= 0,
+	.hop_limit		= IPV6_DEFAULT_HOPLIMIT,
+	.mtu6			= IPV6_MIN_MTU,
+	.accept_ra		= 1,
+	.accept_redirects	= 1,
+	.autoconf		= 1,
+	.dad_transmits		= 1,
+	.rtr_solicits		= MAX_RTR_SOLICITATIONS,
+	.rtr_solicit_interval	= RTR_SOLICITATION_INTERVAL,
+	.rtr_solicit_delay	= MAX_RTR_SOLICITATION_DELAY,
 #ifdef CONFIG_IPV6_PRIVACY
-	.use_tempaddr 			= 0,
-	.temp_valid_lft			= TEMP_VALID_LIFETIME,
-	.temp_prefered_lft		= TEMP_PREFERRED_LIFETIME,
-	.regen_max_retry		= REGEN_MAX_RETRY,
-	.max_desync_factor		= MAX_DESYNC_FACTOR,
+	.use_tempaddr 		= 0,
+	.temp_valid_lft		= TEMP_VALID_LIFETIME,
+	.temp_prefered_lft	= TEMP_PREFERRED_LIFETIME,
+	.regen_max_retry	= REGEN_MAX_RETRY,
+	.max_desync_factor	= MAX_DESYNC_FACTOR,
 #endif
 };
 
-static struct ipv6_devconf ipv6_devconf_dflt =
-{
-	0,				/* forwarding		*/
-	IPV6_DEFAULT_HOPLIMIT,		/* hop limit		*/
-	IPV6_MIN_MTU,			/* mtu			*/
-	1,				/* accept RAs		*/
-	1,				/* accept redirects	*/
-	1,				/* autoconfiguration	*/
-	1,				/* dad transmits	*/
-	MAX_RTR_SOLICITATIONS,		/* router solicits	*/
-	RTR_SOLICITATION_INTERVAL,	/* rtr solicit interval	*/
-	MAX_RTR_SOLICITATION_DELAY,	/* rtr solicit delay	*/
+static struct ipv6_devconf ipv6_devconf_dflt = {
+	.forwarding		= 0,
+	.hop_limit		= IPV6_DEFAULT_HOPLIMIT,
+	.mtu6			= IPV6_MIN_MTU,
+	.accept_ra		= 1,
+	.accept_redirects	= 1,
+	.autoconf		= 1,
+	.dad_transmits		= 1,
+	.rtr_solicits		= MAX_RTR_SOLICITATIONS,
+	.rtr_solicit_interval	= RTR_SOLICITATION_INTERVAL,
+	.rtr_solicit_delay	= MAX_RTR_SOLICITATION_DELAY,
 #ifdef CONFIG_IPV6_PRIVACY
-	.use_tempaddr			= 0,
-	.temp_valid_lft			= TEMP_VALID_LIFETIME,
-	.temp_prefered_lft		= TEMP_PREFERRED_LIFETIME,
-	.regen_max_retry		= REGEN_MAX_RETRY,
-	.max_desync_factor		= MAX_DESYNC_FACTOR,
+	.use_tempaddr		= 0,
+	.temp_valid_lft		= TEMP_VALID_LIFETIME,
+	.temp_prefered_lft	= TEMP_PREFERRED_LIFETIME,
+	.regen_max_retry	= REGEN_MAX_RETRY,
+	.max_desync_factor	= MAX_DESYNC_FACTOR,
 #endif
 };
 
@@ -300,6 +298,7 @@
 		printk("Freeing alive inet6 device %p\n", idev);
 		return;
 	}
+	snmp6_unregister_dev(idev);
 	inet6_dev_count--;
 	kfree(idev);
 }
@@ -332,6 +331,15 @@
 		/* We refer to the device */
 		dev_hold(dev);
 
+		if (snmp6_register_dev(ndev) < 0) {
+			ADBG((KERN_WARNING
+				"%s(): cannot create /proc/net/dev_snmp6/%s\n",
+				__FUNCTION__, dev->name));
+			neigh_parms_release(&nd_tbl, ndev->nd_parms);
+			in6_dev_finish_destroy(ndev);
+			return NULL;
+		}
+
 #ifdef CONFIG_IPV6_PRIVACY
 		get_random_bytes(ndev->rndid, sizeof(ndev->rndid));
 		get_random_bytes(ndev->entropy, sizeof(ndev->entropy));
@@ -737,9 +745,9 @@
 #endif
 
 /*
- *	Choose an apropriate source address
+ *	Choose an appropriate source address
  *	should do:
- *	i)	get an address with an apropriate scope
+ *	i)	get an address with an appropriate scope
  *	ii)	see if there is a specific route for the destination and use
  *		an address of the attached interface 
  *	iii)	don't use deprecated addresses
diff -Nru a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
--- a/net/ipv6/af_inet6.c	Wed Apr 30 22:28:10 2003
+++ b/net/ipv6/af_inet6.c	Wed Apr 30 22:28:10 2003
@@ -631,79 +631,72 @@
 	inet_unregister_protosw(p);
 }
 
-static int __init init_ipv6_mibs(void)
+int
+snmp6_mib_init(void *ptr[2], size_t mibsize)
 {
 	int i;
- 
-	ipv6_statistics[0] = kmalloc_percpu(sizeof (struct ipv6_mib),
-						GFP_KERNEL);
-	if (!ipv6_statistics[0])
-		goto err_ip_mib0;
-	ipv6_statistics[1] = kmalloc_percpu(sizeof (struct ipv6_mib),
-						GFP_KERNEL);
-	if (!ipv6_statistics[1])
-		goto err_ip_mib1;
-	
-	icmpv6_statistics[0] = kmalloc_percpu(sizeof (struct icmpv6_mib),
-						GFP_KERNEL);
-	if (!icmpv6_statistics[0])
-		goto err_icmp_mib0;
-	icmpv6_statistics[1] = kmalloc_percpu(sizeof (struct icmpv6_mib),
-						GFP_KERNEL);
-	if (!icmpv6_statistics[1])
-		goto err_icmp_mib1;
-	
-	udp_stats_in6[0] = kmalloc_percpu(sizeof (struct udp_mib),
-						GFP_KERNEL);
-	if (!udp_stats_in6[0])
-		goto err_udp_mib0;
-	udp_stats_in6[1] = kmalloc_percpu(sizeof (struct udp_mib),
-						GFP_KERNEL);
-	if (!udp_stats_in6[1])
-		goto err_udp_mib1;
 
-	/* Zero all percpu versions of the mibs */
+	if (ptr == NULL)
+		return -EINVAL;
+
+	ptr[0] = kmalloc_percpu(mibsize, GFP_KERNEL);
+	if (!ptr[0])
+		goto err0;
+
+	ptr[1] = kmalloc_percpu(mibsize, GFP_KERNEL);
+	if (!ptr[1])
+		goto err1;
+
+	/* Zero percpu version of the mibs */
 	for (i = 0; i < NR_CPUS; i++) {
 		if (cpu_possible(i)) {
-		memset(per_cpu_ptr(ipv6_statistics[0], i), 0,
-				sizeof (struct ipv6_mib));
-		memset(per_cpu_ptr(ipv6_statistics[1], i), 0,
-				sizeof (struct ipv6_mib));
-		memset(per_cpu_ptr(icmpv6_statistics[0], i), 0,
-				sizeof (struct icmpv6_mib));
-		memset(per_cpu_ptr(icmpv6_statistics[1], i), 0,
-				sizeof (struct icmpv6_mib));
-		memset(per_cpu_ptr(udp_stats_in6[0], i), 0,
-				sizeof (struct udp_mib));
-		memset(per_cpu_ptr(udp_stats_in6[1], i), 0,
-				sizeof (struct udp_mib));
+			memset(per_cpu_ptr(ptr[0], i), 0, mibsize);
+			memset(per_cpu_ptr(ptr[1], i), 0, mibsize);
 		}
 	}
 	return 0;
 
-err_udp_mib1:
-	kfree_percpu(udp_stats_in6[0]);
-err_udp_mib0:
-	kfree_percpu(icmpv6_statistics[1]);
-err_icmp_mib1:
-	kfree_percpu(icmpv6_statistics[0]);
-err_icmp_mib0:
-	kfree_percpu(ipv6_statistics[1]);
-err_ip_mib1:
-	kfree_percpu(ipv6_statistics[0]);
-err_ip_mib0:
+err1:
+	kfree_percpu(ptr[0]);
+	ptr[0] = NULL;
+err0:
+	return -ENOMEM;
+}
+
+void
+snmp6_mib_free(void *ptr[2])
+{
+	if (ptr == NULL)
+		return;
+	kfree_percpu(ptr[0]);
+	kfree_percpu(ptr[1]);
+	ptr[0] = ptr[1] = NULL;
+}
+
+static int __init init_ipv6_mibs(void)
+{
+	if (snmp6_mib_init((void **)ipv6_statistics, sizeof (struct ipv6_mib)) < 0)
+		goto err_ip_mib;
+	if (snmp6_mib_init((void **)icmpv6_statistics, sizeof (struct icmpv6_mib)) < 0)
+		goto err_icmp_mib;
+	if (snmp6_mib_init((void **)udp_stats_in6, sizeof (struct udp_mib)) < 0)
+		goto err_udp_mib;
+	return 0;
+
+err_udp_mib:
+	snmp6_mib_free((void **)icmpv6_statistics);
+err_icmp_mib:
+	snmp6_mib_free((void **)ipv6_statistics);
+err_ip_mib:
 	return -ENOMEM;
 	
 }
 
 static void cleanup_ipv6_mibs(void)
 {
-	kfree_percpu(ipv6_statistics[0]);
-	kfree_percpu(ipv6_statistics[1]);
-	kfree_percpu(icmpv6_statistics[0]);
-	kfree_percpu(icmpv6_statistics[1]);
-	kfree_percpu(udp_stats_in6[0]);
-	kfree_percpu(udp_stats_in6[1]);
+	snmp6_mib_free((void **)ipv6_statistics);
+	snmp6_mib_free((void **)icmpv6_statistics);
+	snmp6_mib_free((void **)udp_stats_in6);
 }
 
 extern int ipv6_misc_proc_init(void);
@@ -819,6 +812,7 @@
 #ifdef CONFIG_PROC_FS
 proc_anycast6_fail:
 	proc_net_remove("snmp6");
+	proc_net_remove("dev_snmp6");
 	proc_net_remove("sockstat6");
 proc_misc6_fail:
 	proc_net_remove("udp6");
@@ -854,6 +848,7 @@
 	proc_net_remove("tcp6");
 	proc_net_remove("udp6");
 	proc_net_remove("sockstat6");
+	proc_net_remove("dev_snmp6");
 	proc_net_remove("snmp6");
 	proc_net_remove("anycast6");
 #endif
diff -Nru a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
--- a/net/ipv6/exthdrs.c	Wed Apr 30 22:28:04 2003
+++ b/net/ipv6/exthdrs.c	Wed Apr 30 22:28:04 2003
@@ -19,7 +19,7 @@
  *	yoshfuji		: ensure not to overrun while parsing 
  *				  tlv options.
  *	Mitsuru KANDA @USAGI and: Remove ipv6_parse_exthdrs().
- *	YOSHIFUJI Hideaki @USAGI  Register inbound extention header
+ *	YOSHIFUJI Hideaki @USAGI  Register inbound extension header
  *				  handlers as inet6_protocol{}.
  */
 
@@ -344,7 +344,7 @@
    this stupid requirement making rthdr idea useless)
 
    Actually, it creates severe problems  for us.
-   Embrionic requests has no associated sockets,
+   Embryonic requests has no associated sockets,
    so that user have no control over it and
    cannot not only to set reply options, but
    even to know, that someone wants to connect
diff -Nru a/net/ipv6/icmp.c b/net/ipv6/icmp.c
--- a/net/ipv6/icmp.c	Wed Apr 30 22:28:07 2003
+++ b/net/ipv6/icmp.c	Wed Apr 30 22:28:07 2003
@@ -26,6 +26,8 @@
  *	yoshfuji		:	ensure to sent parameter problem for
  *					fragments.
  *	YOSHIFUJI Hideaki @USAGI:	added sysctl for icmp rate limit.
+ *	Randy Dunlap and
+ *	YOSHIFUJI Hideaki @USAGI:	Per-interface statistics support
  */
 
 #include <linux/module.h>
@@ -247,6 +249,7 @@
 void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, 
 		 struct net_device *dev)
 {
+	struct inet6_dev *idev;
 	struct ipv6hdr *hdr = skb->nh.ipv6h;
 	struct sock *sk = icmpv6_socket->sk;
 	struct in6_addr *saddr = NULL;
@@ -351,11 +354,16 @@
 
 	msg.len = len;
 
+	idev = in6_dev_get(skb->dev);
+	
 	ip6_build_xmit(sk, icmpv6_getfrag, &msg, &fl, len, NULL, -1,
 		       MSG_DONTWAIT);
 	if (type >= ICMPV6_DEST_UNREACH && type <= ICMPV6_PARAMPROB)
-		ICMP6_STATS_PTR_BH(Icmp6OutDestUnreachs) [type-ICMPV6_DEST_UNREACH]++;
-	ICMP6_INC_STATS_BH(Icmp6OutMsgs);
+		ICMP6_INC_STATS_OFFSET_BH(idev, Icmp6OutDestUnreachs, type - ICMPV6_DEST_UNREACH);
+	ICMP6_INC_STATS_BH(idev, Icmp6OutMsgs);
+
+	if (likely(idev != NULL))
+		in6_dev_put(idev);
 out:
 	icmpv6_xmit_unlock();
 }
@@ -363,6 +371,7 @@
 static void icmpv6_echo_reply(struct sk_buff *skb)
 {
 	struct sock *sk = icmpv6_socket->sk;
+	struct inet6_dev *idev;
 	struct icmp6hdr *icmph = (struct icmp6hdr *) skb->h.raw;
 	struct in6_addr *saddr;
 	struct icmpv6_msg msg;
@@ -394,14 +403,19 @@
 	fl.fl_icmp_type = ICMPV6_ECHO_REPLY;
 	fl.fl_icmp_code = 0;
 
+	idev = in6_dev_get(skb->dev);
+
 	icmpv6_xmit_lock();
 
 	ip6_build_xmit(sk, icmpv6_getfrag, &msg, &fl, msg.len, NULL, -1,
 		       MSG_DONTWAIT);
-	ICMP6_INC_STATS_BH(Icmp6OutEchoReplies);
-	ICMP6_INC_STATS_BH(Icmp6OutMsgs);
+	ICMP6_INC_STATS_BH(idev, Icmp6OutEchoReplies);
+	ICMP6_INC_STATS_BH(idev, Icmp6OutMsgs);
 
 	icmpv6_xmit_unlock();
+
+	if (likely(idev != NULL))
+		in6_dev_put(idev);
 }
 
 static void icmpv6_notify(struct sk_buff *skb, int type, int code, u32 info)
@@ -464,12 +478,13 @@
 {
 	struct sk_buff *skb = *pskb;
 	struct net_device *dev = skb->dev;
+	struct inet6_dev *idev = __in6_dev_get(dev);
 	struct in6_addr *saddr, *daddr;
 	struct ipv6hdr *orig_hdr;
 	struct icmp6hdr *hdr;
 	int type;
 
-	ICMP6_INC_STATS_BH(Icmp6InMsgs);
+	ICMP6_INC_STATS_BH(idev, Icmp6InMsgs);
 
 	saddr = &skb->nh.ipv6h->saddr;
 	daddr = &skb->nh.ipv6h->daddr;
@@ -517,9 +532,9 @@
 	type = hdr->icmp6_type;
 
 	if (type >= ICMPV6_DEST_UNREACH && type <= ICMPV6_PARAMPROB)
-		ICMP6_STATS_PTR_BH(Icmp6InDestUnreachs)[type-ICMPV6_DEST_UNREACH]++;
+		ICMP6_INC_STATS_OFFSET_BH(idev, Icmp6InDestUnreachs, type - ICMPV6_DEST_UNREACH);
 	else if (type >= ICMPV6_ECHO_REQUEST && type <= NDISC_REDIRECT)
-		ICMP6_STATS_PTR_BH(Icmp6InEchos)[type-ICMPV6_ECHO_REQUEST]++;
+		ICMP6_INC_STATS_OFFSET_BH(idev, Icmp6InEchos, type - ICMPV6_ECHO_REQUEST);
 
 	switch (type) {
 	case ICMPV6_ECHO_REQUEST:
@@ -587,7 +602,7 @@
 			break;
 
 		/* 
-		 * error of unkown type. 
+		 * error of unknown type. 
 		 * must pass to upper level 
 		 */
 
@@ -597,7 +612,7 @@
 	return 0;
 
 discard_it:
-	ICMP6_INC_STATS_BH(Icmp6InErrors);
+	ICMP6_INC_STATS_BH(idev, Icmp6InErrors);
 	kfree_skb(skb);
 	return 0;
 }
diff -Nru a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
--- a/net/ipv6/ip6_fib.c	Wed Apr 30 22:28:15 2003
+++ b/net/ipv6/ip6_fib.c	Wed Apr 30 22:28:15 2003
@@ -232,7 +232,7 @@
 /*
  *	Routing Table
  *
- *	return the apropriate node for a routing tree "add" operation
+ *	return the appropriate node for a routing tree "add" operation
  *	by either creating and inserting or by returning an existing
  *	node.
  */
@@ -697,7 +697,7 @@
 }
 
 /*
- *	Get node with sepciafied destination prefix (and source prefix,
+ *	Get node with specified destination prefix (and source prefix,
  *	if subtrees are used)
  */
 
diff -Nru a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
--- a/net/ipv6/ip6_output.c	Wed Apr 30 22:28:04 2003
+++ b/net/ipv6/ip6_output.c	Wed Apr 30 22:28:04 2003
@@ -263,7 +263,7 @@
  *	To avoid extra problems ND packets are send through this
  *	routine. It's code duplication but I really want to avoid
  *	extra checks since ipv6_build_header is used by TCP (which
- *	is for us performace critical)
+ *	is for us performance critical)
  */
 
 int ip6_nd_hdr(struct sock *sk, struct sk_buff *skb, struct net_device *dev,
diff -Nru a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
--- a/net/ipv6/ipv6_sockglue.c	Wed Apr 30 22:28:04 2003
+++ b/net/ipv6/ipv6_sockglue.c	Wed Apr 30 22:28:04 2003
@@ -120,6 +120,12 @@
 	return 0;
 }
 
+extern int ip6_mc_source(int add, int omode, struct sock *sk,
+	struct group_source_req *pgsr);
+extern int ip6_mc_msfilter(struct sock *sk, struct group_filter *gsf);
+extern int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf,
+	struct group_filter *optval, int *optlen);
+
 
 int ipv6_setsockopt(struct sock *sk, int level, int optname, char *optval, 
 		    int optlen)
@@ -393,12 +399,13 @@
 			break;
 		}
 		psin6 = (struct sockaddr_in6 *)&greq.gr_group;
-		if (optname == IPV6_ADD_MEMBERSHIP)
+		if (optname == MCAST_JOIN_GROUP)
 			retv = ipv6_sock_mc_join(sk, greq.gr_interface,
 				&psin6->sin6_addr);
 		else
 			retv = ipv6_sock_mc_drop(sk, greq.gr_interface,
 				&psin6->sin6_addr);
+		break;
 	}
 	case MCAST_JOIN_SOURCE_GROUP:
 	case MCAST_LEAVE_SOURCE_GROUP:
@@ -414,7 +421,8 @@
 			retv = -EFAULT;
 			break;
 		}
-		if (greqs.gsr_group.ss_family != AF_INET6) {
+		if (greqs.gsr_group.ss_family != AF_INET6 ||
+		    greqs.gsr_source.ss_family != AF_INET6) {
 			retv = -EADDRNOTAVAIL;
 			break;
 		}
diff -Nru a/net/ipv6/ipv6_syms.c b/net/ipv6/ipv6_syms.c
--- a/net/ipv6/ipv6_syms.c	Wed Apr 30 22:28:13 2003
+++ b/net/ipv6/ipv6_syms.c	Wed Apr 30 22:28:13 2003
@@ -34,5 +34,6 @@
 EXPORT_SYMBOL(ipv6_chk_addr);
 EXPORT_SYMBOL(in6addr_any);
 EXPORT_SYMBOL(in6addr_loopback);
+EXPORT_SYMBOL(in6_dev_finish_destroy);
 EXPORT_SYMBOL(xfrm6_rcv);
 EXPORT_SYMBOL(xfrm6_clear_mutable_options);
diff -Nru a/net/ipv6/mcast.c b/net/ipv6/mcast.c
--- a/net/ipv6/mcast.c	Wed Apr 30 22:28:16 2003
+++ b/net/ipv6/mcast.c	Wed Apr 30 22:28:16 2003
@@ -768,7 +768,7 @@
 		psf = pmc->mca_tomb;
 		pmc->mca_tomb = 0;
 		spin_unlock_bh(&pmc->mca_lock);
-		for (psf=pmc->mca_tomb; psf; psf=psf_next) {
+		for (; psf; psf=psf_next) {
 			psf_next = psf->sf_next;
 			kfree(psf);
 		}
@@ -1042,6 +1042,8 @@
 		mld_clear_delrec(idev);
 	} else if (len >= 28) {
 		max_delay = MLDV2_MRC(ntohs(mlh2->mrc))*(HZ/10);
+		if (!max_delay)
+			max_delay = 1;
 		idev->mc_maxdelay = max_delay;
 		if (mlh2->qrv)
 			idev->mc_qrv = mlh2->qrv;
@@ -1251,6 +1253,7 @@
 	struct ipv6hdr *pip6 = skb->nh.ipv6h;
 	struct mld2_report *pmr = (struct mld2_report *)skb->h.raw;
 	int payload_len, mldlen;
+	struct inet6_dev *idev = in6_dev_get(skb->dev);
 
 	payload_len = skb->tail - (unsigned char *)skb->nh.ipv6h -
 		sizeof(struct ipv6hdr);
@@ -1260,7 +1263,9 @@
 	pmr->csum = csum_ipv6_magic(&pip6->saddr, &pip6->daddr, mldlen,
 		IPPROTO_ICMPV6, csum_partial(skb->h.raw, mldlen, 0));
 	dev_queue_xmit(skb);
-	ICMP6_INC_STATS(Icmp6OutMsgs);
+	ICMP6_INC_STATS(idev,Icmp6OutMsgs);
+	if (likely(idev != NULL))
+		in6_dev_put(idev);
 }
 
 static int grec_size(struct ifmcaddr6 *pmc, int type, int gdel, int sdel)
@@ -1518,6 +1523,7 @@
 static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
 {
 	struct sock *sk = igmp6_socket->sk;
+	struct inet6_dev *idev;
         struct sk_buff *skb;
         struct icmp6hdr *hdr;
 	struct in6_addr *snd_addr;
@@ -1575,12 +1581,17 @@
 					   IPPROTO_ICMPV6,
 					   csum_partial((__u8 *) hdr, len, 0));
 
+	idev = in6_dev_get(skb->dev);
+
 	dev_queue_xmit(skb);
 	if (type == ICMPV6_MGM_REDUCTION)
-		ICMP6_INC_STATS(Icmp6OutGroupMembReductions);
+		ICMP6_INC_STATS(idev, Icmp6OutGroupMembReductions);
 	else
-		ICMP6_INC_STATS(Icmp6OutGroupMembResponses);
-	ICMP6_INC_STATS(Icmp6OutMsgs);
+		ICMP6_INC_STATS(idev, Icmp6OutGroupMembResponses);
+	ICMP6_INC_STATS(idev, Icmp6OutMsgs);
+
+	if (likely(idev != NULL))
+		in6_dev_put(idev);
 	return;
 
 out:
@@ -2093,11 +2104,9 @@
 
 		for (imc=idev->mc_list; imc; imc=imc->next) {
 			struct ip6_sf_list *psf;
-			unsigned long icount, xcount, i;
+			unsigned long i;
 
 			spin_lock_bh(&imc->mca_lock);
-			icount = imc->mca_sfcount[MCAST_INCLUDE];
-			xcount = imc->mca_sfcount[MCAST_EXCLUDE];
 			for (psf=imc->mca_sources; psf; psf=psf->sf_next) {
 				if (first) {
 					len += sprintf(buffer+len, "%3s %6s "
@@ -2119,36 +2128,6 @@
 				len += sprintf(buffer+len, " %6lu %6lu\n",
 					psf->sf_count[MCAST_INCLUDE],
 					psf->sf_count[MCAST_EXCLUDE]);
-				pos = begin+len;
-				if (pos < offset) {
-					len=0;
-					begin=pos;
-				}
-				if (pos > offset+length) {
-					spin_unlock_bh(&imc->mca_lock);
-					read_unlock_bh(&idev->lock);
-					in6_dev_put(idev);
-					goto done;
-				}
-				icount -= psf->sf_count[MCAST_INCLUDE];
-				xcount -= psf->sf_count[MCAST_EXCLUDE];
-			}
-			if (icount > 0 || xcount > 0) {
-				if (first) {
-					len += sprintf(buffer+len, "%3s %6s "
-						"%32s %32s %6s %6s\n", "Idx",
-						"Device", "Multicast Address",
-						"Source Address", "INC", "EXC");
-					first = 0;
-				}
-				len += sprintf(buffer+len,"%3d %6.6s ",
-					dev->ifindex, dev->name);
-
-				for (i=0; i<16; i++)
-					len += sprintf(buffer+len, "%02x",
-						imc->mca_addr.s6_addr[i]);
-				len += sprintf(buffer+len, " %32s %6lu %6lu\n",
-					"NONE", icount, xcount);
 				pos = begin+len;
 				if (pos < offset) {
 					len=0;
diff -Nru a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
--- a/net/ipv6/ndisc.c	Wed Apr 30 22:28:10 2003
+++ b/net/ipv6/ndisc.c	Wed Apr 30 22:28:10 2003
@@ -415,6 +415,7 @@
 {
 	static struct in6_addr tmpaddr;
 	struct inet6_ifaddr *ifp;
+	struct inet6_dev *idev;
 	struct flowi fl;
 	struct rt6_info *rt = NULL;
 	struct dst_entry* dst;
@@ -427,7 +428,7 @@
 
 	len = sizeof(struct icmp6hdr) + sizeof(struct in6_addr);
 
-	rt = ndisc_get_dummy_rt();
+	rt = ip6_dst_alloc();
 	if (!rt) 
 		return;
 
@@ -497,10 +498,14 @@
 
 	dst_clone(dst);
 	skb->dst = dst;
+	idev = in6_dev_get(dst->dev);
 	dst_output(skb);
 
-	ICMP6_INC_STATS(Icmp6OutNeighborAdvertisements);
-	ICMP6_INC_STATS(Icmp6OutMsgs);
+	ICMP6_INC_STATS(idev, Icmp6OutNeighborAdvertisements);
+	ICMP6_INC_STATS(idev, Icmp6OutMsgs);
+
+	if (likely(idev != NULL))
+		in6_dev_put(idev);
 }        
 
 void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh,
@@ -510,6 +515,7 @@
 	struct flowi fl;
 	struct rt6_info *rt = NULL;
 	struct dst_entry* dst;
+	struct inet6_dev *idev;
         struct sock *sk = ndisc_socket->sk;
         struct sk_buff *skb;
         struct nd_msg *msg;
@@ -524,7 +530,7 @@
 		saddr = &addr_buf;
 	}
 
-	rt = ndisc_get_dummy_rt();
+	rt = ip6_dst_alloc();
 	if (!rt) 
 		return;
 
@@ -576,10 +582,14 @@
 	/* send it! */
 	dst_clone(dst);
 	skb->dst = dst;
+	idev = in6_dev_get(dst->dev);
 	dst_output(skb);
 
-	ICMP6_INC_STATS(Icmp6OutNeighborSolicits);
-	ICMP6_INC_STATS(Icmp6OutMsgs);
+	ICMP6_INC_STATS(idev, Icmp6OutNeighborSolicits);
+	ICMP6_INC_STATS(idev, Icmp6OutMsgs);
+
+	if (likely(idev != NULL))
+		in6_dev_put(idev);
 }
 
 void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr,
@@ -588,6 +598,7 @@
 	struct flowi fl;
 	struct rt6_info *rt = NULL;
 	struct dst_entry* dst;
+	struct inet6_dev *idev;
 	struct sock *sk = ndisc_socket->sk;
         struct sk_buff *skb;
         struct icmp6hdr *hdr;
@@ -595,7 +606,7 @@
         int len;
 	int err;
 
-	rt = ndisc_get_dummy_rt();
+	rt = ip6_dst_alloc();
 	if (!rt) 
 		return;
 
@@ -644,10 +655,14 @@
 	/* send it! */
 	dst_clone(dst);
 	skb->dst = dst;
+	idev = in6_dev_get(dst->dev);
 	dst_output(skb);
 
-	ICMP6_INC_STATS(Icmp6OutRouterSolicits);
-	ICMP6_INC_STATS(Icmp6OutMsgs);
+	ICMP6_INC_STATS(idev, Icmp6OutRouterSolicits);
+	ICMP6_INC_STATS(idev, Icmp6OutMsgs);
+
+	if (likely(idev != NULL))
+		in6_dev_put(idev);
 }
 		   
 
@@ -792,7 +807,7 @@
 
 			/* 
 			 *	update / create cache entry
-			 *	for the source adddress
+			 *	for the source address
 			 */
 
 			neigh = neigh_event_ns(&nd_tbl, lladdr, saddr, dev);
@@ -837,7 +852,7 @@
 	
 			/*
 			 *   update / create cache entry
-			 *   for the source adddress
+			 *   for the source address
 			 */
 
 			neigh = neigh_event_ns(&nd_tbl, lladdr, saddr, skb->dev);
@@ -1271,6 +1286,7 @@
 	struct net_device *dev;
 	struct rt6_info *rt;
 	struct dst_entry *dst;
+	struct inet6_dev *idev;
 	struct flowi fl;
 	u8 *opt;
 	int rd_len;
@@ -1379,10 +1395,14 @@
 					     csum_partial((u8 *) icmph, len, 0));
 
 	skb->dst = dst;
+	idev = in6_dev_get(dst->dev);
 	dst_output(skb);
 
-	ICMP6_INC_STATS(Icmp6OutRedirects);
-	ICMP6_INC_STATS(Icmp6OutMsgs);
+	ICMP6_INC_STATS(idev, Icmp6OutRedirects);
+	ICMP6_INC_STATS(idev, Icmp6OutMsgs);
+
+	if (likely(idev != NULL))
+		in6_dev_put(idev);
 }
 
 static void pndisc_redo(struct sk_buff *skb)
diff -Nru a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c
--- a/net/ipv6/netfilter/ip6_queue.c	Wed Apr 30 22:28:06 2003
+++ b/net/ipv6/netfilter/ip6_queue.c	Wed Apr 30 22:28:06 2003
@@ -304,8 +304,9 @@
 	write_lock_bh(&queue_lock);
 	
 	if (!peer_pid)
-		goto err_out_unlock;
+		goto err_out_free_nskb; 
 
+ 	/* netlink_unicast will either free the nskb or attach it to a socket */ 
 	status = netlink_unicast(ipqnl, nskb, peer_pid, MSG_DONTWAIT);
 	if (status < 0)
 		goto err_out_unlock;
@@ -316,6 +317,9 @@
 
 	write_unlock_bh(&queue_lock);
 	return status;
+	
+err_out_free_nskb:
+	kfree_skb(nskb); 
 	
 err_out_unlock:
 	write_unlock_bh(&queue_lock);
diff -Nru a/net/ipv6/netfilter/ip6t_LOG.c b/net/ipv6/netfilter/ip6t_LOG.c
--- a/net/ipv6/netfilter/ip6t_LOG.c	Wed Apr 30 22:28:07 2003
+++ b/net/ipv6/netfilter/ip6t_LOG.c	Wed Apr 30 22:28:07 2003
@@ -89,7 +89,7 @@
 	printk("DST=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x ", NIP6(ipv6h->daddr));
 
 	/* Max length: 44 "LEN=65535 TC=255 HOPLIMIT=255 FLOWLBL=FFFFF " */
-	printk("LEN=%u TC=%u HOPLIMIT=%u FLOWLBL=%u ",
+	printk("LEN=%Zu TC=%u HOPLIMIT=%u FLOWLBL=%u ",
 	       ntohs(ipv6h->payload_len) + sizeof(struct ipv6hdr),
 	       (ntohl(*(u_int32_t *)ipv6h) & 0x0ff00000) >> 20,
 	       ipv6h->hop_limit,
diff -Nru a/net/ipv6/netfilter/ip6table_filter.c b/net/ipv6/netfilter/ip6table_filter.c
--- a/net/ipv6/netfilter/ip6table_filter.c	Wed Apr 30 22:28:04 2003
+++ b/net/ipv6/netfilter/ip6table_filter.c	Wed Apr 30 22:28:04 2003
@@ -123,18 +123,21 @@
 static struct nf_hook_ops ip6t_ops[] = {
 	{
 		.hook		= ip6t_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_INET6,
 		.hooknum	= NF_IP6_LOCAL_IN,
 		.priority	= NF_IP6_PRI_FILTER,
 	},
 	{
 		.hook		= ip6t_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_INET6,
 		.hooknum	= NF_IP6_FORWARD,
 		.priority	= NF_IP6_PRI_FILTER,
 	},
 	{
 		.hook		= ip6t_local_out_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_INET6,
 		.hooknum	= NF_IP6_LOCAL_OUT,
 		.priority	= NF_IP6_PRI_FILTER,
diff -Nru a/net/ipv6/netfilter/ip6table_mangle.c b/net/ipv6/netfilter/ip6table_mangle.c
--- a/net/ipv6/netfilter/ip6table_mangle.c	Wed Apr 30 22:28:08 2003
+++ b/net/ipv6/netfilter/ip6table_mangle.c	Wed Apr 30 22:28:08 2003
@@ -186,30 +186,35 @@
 static struct nf_hook_ops ip6t_ops[] = {
 	{
 		.hook		= ip6t_route_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_INET6,
 		.hooknum	= NF_IP6_PRE_ROUTING,
 		.priority	= NF_IP6_PRI_MANGLE,
 	},
 	{
 		.hook		= ip6t_local_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_INET6,
 		.hooknum	= NF_IP6_LOCAL_IN,
 		.priority	= NF_IP6_PRI_MANGLE,
 	},
 	{
 		.hook		= ip6t_route_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_INET6,
 		.hooknum	= NF_IP6_FORWARD,
 		.priority	= NF_IP6_PRI_MANGLE,
 	},
 	{
 		.hook		= ip6t_local_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_INET6,
 		.hooknum	= NF_IP6_LOCAL_OUT,
 		.priority	= NF_IP6_PRI_MANGLE,
 	},
 	{
 		.hook		= ip6t_route_hook,
+		.owner		= THIS_MODULE,
 		.pf		= PF_INET6,
 		.hooknum	= NF_IP6_POST_ROUTING,
 		.priority	= NF_IP6_PRI_MANGLE,
diff -Nru a/net/ipv6/proc.c b/net/ipv6/proc.c
--- a/net/ipv6/proc.c	Wed Apr 30 22:28:08 2003
+++ b/net/ipv6/proc.c	Wed Apr 30 22:28:08 2003
@@ -10,12 +10,14 @@
  * Version:	$Id: proc.c,v 1.17 2002/02/01 22:01:04 davem Exp $
  *
  * Authors:	David S. Miller (davem@caip.rutgers.edu)
+ * 		YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
  *
  *		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; either version
  *		2 of the License, or (at your option) any later version.
  */
+#include <linux/config.h>
 #include <linux/sched.h>
 #include <linux/socket.h>
 #include <linux/net.h>
@@ -28,6 +30,10 @@
 #include <net/transp_v6.h>
 #include <net/ipv6.h>
 
+#ifdef CONFIG_PROC_FS
+static struct proc_dir_entry *proc_net_devsnmp6;
+#endif
+
 static int fold_prot_inuse(struct proto *proto)
 {
 	int res = 0;
@@ -53,14 +59,16 @@
 }
 
 
-static struct snmp6_item
+struct snmp6_item
 {
 	char *name;
-	void **mib;
 	int   offset;
-} snmp6_list[] = {
+};
+#define SNMP6_SENTINEL	{ .name = NULL, .offset = 0 }
+
+static struct snmp6_item snmp6_ipv6_list[] = {
 /* ipv6 mib according to draft-ietf-ipngwg-ipv6-mib-04 */
-#define SNMP6_GEN(x) { #x , (void **)ipv6_statistics, offsetof(struct ipv6_mib, x) }
+#define SNMP6_GEN(x) { .name = #x , .offset = offsetof(struct ipv6_mib, x) }
 	SNMP6_GEN(Ip6InReceives),
 	SNMP6_GEN(Ip6InHdrErrors),
 	SNMP6_GEN(Ip6InTooBigErrors),
@@ -84,6 +92,10 @@
 	SNMP6_GEN(Ip6InMcastPkts),
 	SNMP6_GEN(Ip6OutMcastPkts),
 #undef SNMP6_GEN
+	SNMP6_SENTINEL
+};
+
+static struct snmp6_item snmp6_icmp6_list[] = {
 /* icmpv6 mib according to draft-ietf-ipngwg-ipv6-icmp-mib-02
 
    Exceptions:  {In|Out}AdminProhibs are removed, because I see
@@ -94,7 +106,7 @@
 		OutRouterAdvertisements too.
 		OutGroupMembQueries too.
  */
-#define SNMP6_GEN(x) { #x , (void **)icmpv6_statistics, offsetof(struct icmpv6_mib, x) }
+#define SNMP6_GEN(x) { .name = #x , .offset = offsetof(struct icmpv6_mib, x) }
 	SNMP6_GEN(Icmp6InMsgs),
 	SNMP6_GEN(Icmp6InErrors),
 	SNMP6_GEN(Icmp6InDestUnreachs),
@@ -124,12 +136,17 @@
 	SNMP6_GEN(Icmp6OutGroupMembResponses),
 	SNMP6_GEN(Icmp6OutGroupMembReductions),
 #undef SNMP6_GEN
-#define SNMP6_GEN(x) { "Udp6" #x , (void **)udp_stats_in6, offsetof(struct udp_mib, Udp##x) }
+	SNMP6_SENTINEL
+};
+
+static struct snmp6_item snmp6_udp6_list[] = {
+#define SNMP6_GEN(x) { .name = "Udp6" #x , .offset = offsetof(struct udp_mib, Udp##x) }
 	SNMP6_GEN(InDatagrams),
 	SNMP6_GEN(NoPorts),
 	SNMP6_GEN(InErrors),
-	SNMP6_GEN(OutDatagrams)
+	SNMP6_GEN(OutDatagrams),
 #undef SNMP6_GEN
+	SNMP6_SENTINEL
 };
 
 static unsigned long
@@ -151,18 +168,30 @@
         return res;
 }
 
-static int snmp6_seq_show(struct seq_file *seq, void *v)
+static inline void
+snmp6_seq_show_item(struct seq_file *seq, void **mib, struct snmp6_item *itemlist)
 {
 	int i;
+	for (i=0; itemlist[i].name; i++)
+		seq_printf(seq, "%-32s\t%lu\n", itemlist[i].name, 
+				fold_field(mib, itemlist[i].offset));
+}
 
-	for (i=0; i<sizeof(snmp6_list)/sizeof(snmp6_list[0]); i++)
-		seq_printf(seq, "%-32s\t%lu\n", snmp6_list[i].name,
-			       fold_field(snmp6_list[i].mib, snmp6_list[i].offset));
+static int snmp6_seq_show(struct seq_file *seq, void *v)
+{
+	struct inet6_dev *idev = (struct inet6_dev *)seq->private;
 
+	if (idev) {
+		seq_printf(seq, "%-32s\t%u\n", "ifIndex", idev->dev->ifindex);
+		snmp6_seq_show_item(seq, (void **)idev->stats.icmpv6, snmp6_icmp6_list);
+	} else {
+		snmp6_seq_show_item(seq, (void **)ipv6_statistics, snmp6_ipv6_list);
+		snmp6_seq_show_item(seq, (void **)icmpv6_statistics, snmp6_icmp6_list);
+		snmp6_seq_show_item(seq, (void **)udp_stats_in6, snmp6_udp6_list);
+	}
 	return 0;
 }
 
-
 static int sockstat6_seq_open(struct inode *inode, struct file *file)
 {
 	return single_open(file, sockstat6_seq_show, NULL);
@@ -177,7 +206,7 @@
 
 static int snmp6_seq_open(struct inode *inode, struct file *file)
 {
-	return single_open(file, snmp6_seq_show, NULL);
+	return single_open(file, snmp6_seq_show, PDE(inode)->data);
 }
 
 static struct file_operations snmp6_seq_fops = {
@@ -187,6 +216,57 @@
 	.release = single_release,
 };
 
+int snmp6_register_dev(struct inet6_dev *idev)
+{
+	int err = -ENOMEM;
+#ifdef CONFIG_PROC_FS
+	struct proc_dir_entry *p;
+#endif
+
+	if (!idev || !idev->dev)
+		return -EINVAL;
+
+	if (snmp6_mib_init((void **)idev->stats.icmpv6, sizeof(struct icmpv6_mib)) < 0)
+		goto err_icmp;
+
+#ifdef CONFIG_PROC_FS
+	if (!proc_net_devsnmp6) {
+		err = -ENOENT;
+		goto err_proc;
+	}
+	p = create_proc_entry(idev->dev->name, S_IRUGO, proc_net_devsnmp6);
+	if (!p)
+		goto err_proc;
+	p->data = idev;
+	p->proc_fops = &snmp6_seq_fops;
+
+	idev->stats.proc_dir_entry = p;
+#endif
+	return 0;
+
+#ifdef CONFIG_PROC_FS
+err_proc:
+	snmp6_mib_free((void **)idev->stats.icmpv6);
+#endif
+err_icmp:
+	return err;
+}
+
+int snmp6_unregister_dev(struct inet6_dev *idev)
+{
+#ifdef CONFIG_PROC_FS
+	if (!proc_net_devsnmp6)
+		return -ENOENT;
+	if (!idev || !idev->stats.proc_dir_entry)
+		return -EINVAL;
+	remove_proc_entry(idev->stats.proc_dir_entry->name,
+			  proc_net_devsnmp6);
+#endif
+	snmp6_mib_free((void **)idev->stats.icmpv6);
+
+	return 0;
+}
+
 int __init ipv6_misc_proc_init(void)
 {
 	int rc = 0;
@@ -197,6 +277,9 @@
 		goto proc_snmp6_fail;
 	else
 		p->proc_fops = &snmp6_seq_fops;
+	proc_net_devsnmp6 = proc_mkdir("dev_snmp6", proc_net);
+	if (!proc_net_devsnmp6)
+		goto proc_dev_snmp6_fail;
 	p = create_proc_entry("sockstat6", S_IRUGO, proc_net);
 	if (!p)
 		goto proc_sockstat6_fail;
@@ -206,6 +289,8 @@
 	return rc;
 
 proc_sockstat6_fail:
+	remove_proc_entry("dev_snmp6", proc_net);
+proc_dev_snmp6_fail:
 	remove_proc_entry("snmp6", proc_net);
 proc_snmp6_fail:
 	rc = -ENOMEM;
diff -Nru a/net/ipv6/route.c b/net/ipv6/route.c
--- a/net/ipv6/route.c	Wed Apr 30 22:28:14 2003
+++ b/net/ipv6/route.c	Wed Apr 30 22:28:14 2003
@@ -130,12 +130,17 @@
 rwlock_t rt6_lock = RW_LOCK_UNLOCKED;
 
 
-/*	Dummy rt for ndisc */
-struct rt6_info *ndisc_get_dummy_rt()
+/* allocate dst with ip6_dst_ops */
+static __inline__ struct rt6_info *__ip6_dst_alloc(void)
 {
 	return dst_alloc(&ip6_dst_ops);
 }
 
+struct rt6_info *ip6_dst_alloc(void)
+{
+	return __ip6_dst_alloc();
+}
+
 /*
  *	Route lookup. Any rt6_lock is implied.
  */
@@ -640,7 +645,7 @@
 	if (rtmsg->rtmsg_metric == 0)
 		rtmsg->rtmsg_metric = IP6_RT_PRIO_USER;
 
-	rt = dst_alloc(&ip6_dst_ops);
+	rt = __ip6_dst_alloc();
 
 	if (rt == NULL)
 		return -ENOMEM;
@@ -1035,9 +1040,7 @@
 
 static struct rt6_info * ip6_rt_copy(struct rt6_info *ort)
 {
-	struct rt6_info *rt;
-
-	rt = dst_alloc(&ip6_dst_ops);
+	struct rt6_info *rt = __ip6_dst_alloc();
 
 	if (rt) {
 		rt->u.dst.input = ort->u.dst.input;
@@ -1181,9 +1184,8 @@
 
 int ip6_rt_addr_add(struct in6_addr *addr, struct net_device *dev)
 {
-	struct rt6_info *rt;
+	struct rt6_info *rt = __ip6_dst_alloc();
 
-	rt = dst_alloc(&ip6_dst_ops);
 	if (rt == NULL)
 		return -ENOMEM;
 
diff -Nru a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
--- a/net/ipv6/tcp_ipv6.c	Wed Apr 30 22:28:10 2003
+++ b/net/ipv6/tcp_ipv6.c	Wed Apr 30 22:28:10 2003
@@ -751,7 +751,7 @@
 	sk = tcp_v6_lookup(&hdr->daddr, th->dest, &hdr->saddr, th->source, skb->dev->ifindex);
 
 	if (sk == NULL) {
-		ICMP6_INC_STATS_BH(Icmp6InErrors);
+		ICMP6_INC_STATS_BH(__in6_dev_get(skb->dev), Icmp6InErrors);
 		return;
 	}
 
diff -Nru a/net/ipv6/udp.c b/net/ipv6/udp.c
--- a/net/ipv6/udp.c	Wed Apr 30 22:28:15 2003
+++ b/net/ipv6/udp.c	Wed Apr 30 22:28:15 2003
@@ -378,7 +378,7 @@
 
 	ip6_dst_store(sk, dst, fl.fl6_dst);
 
-	/* get the source adddress used in the apropriate device */
+	/* get the source address used in the appropriate device */
 
 	err = ipv6_get_saddr(dst, daddr, &saddr);
 
diff -Nru a/net/ipv6/xfrm6_input.c b/net/ipv6/xfrm6_input.c
--- a/net/ipv6/xfrm6_input.c	Wed Apr 30 22:28:20 2003
+++ b/net/ipv6/xfrm6_input.c	Wed Apr 30 22:28:20 2003
@@ -136,7 +136,7 @@
 	unsigned char *tmp_hdr = NULL;
 	int hdr_len = 0;
 	u16 nh_offset = 0;
-	u8 nexthdr = 0;
+	int nexthdr = 0;
 
 	nh_offset = ((unsigned char*)&skb->nh.ipv6h->nexthdr) - skb->nh.raw;
 	hdr_len = sizeof(struct ipv6hdr);
diff -Nru a/net/ipx/Kconfig b/net/ipx/Kconfig
--- a/net/ipx/Kconfig	Wed Apr 30 22:28:08 2003
+++ b/net/ipx/Kconfig	Wed Apr 30 22:28:08 2003
@@ -12,7 +12,7 @@
 	  same address). The way this is done is to create a virtual internal
 	  "network" inside your box and to assign an IPX address to this
 	  network. Say Y here if you want to do this; read the IPX-HOWTO at
-	  <http://www.linuxdoc.org/docs.html#howto> for details.
+	  <http://www.tldp.org/docs.html#howto> for details.
 
 	  The full internal IPX network enables you to allocate sockets on
 	  different virtual nodes of the internal network. This is done by
diff -Nru a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c
--- a/net/ipx/af_ipx.c	Wed Apr 30 22:28:05 2003
+++ b/net/ipx/af_ipx.c	Wed Apr 30 22:28:05 2003
@@ -95,18 +95,6 @@
 atomic_t ipx_sock_nr;
 #endif
 
-static void ipxcfg_set_auto_create(char val)
-{
-	if (ipxcfg_auto_create_interfaces != val) {
-		if (val)
-			MOD_INC_USE_COUNT;
-		else
-			MOD_DEC_USE_COUNT;
-
-		ipxcfg_auto_create_interfaces = val;
-	}
-}
-
 static void ipxcfg_set_auto_select(char val)
 {
 	ipxcfg_auto_select_primary = val;
@@ -373,7 +361,6 @@
 	if (intrfc->if_dev)
 		dev_put(intrfc->if_dev);
 	kfree(intrfc);
-	MOD_DEC_USE_COUNT;
 }
 
 static void ipxitf_down(struct ipx_interface *intrfc)
@@ -428,7 +415,7 @@
 	int is_broadcast = !memcmp(ipx->ipx_dest.node, ipx_broadcast_node,
 				   IPX_NODE_LEN);
 	struct sock *s;
-	int ret;
+	int rc;
 
 	spin_lock_bh(&intrfc->if_sklist_lock);
 	s = intrfc->if_sklist;
@@ -444,7 +431,7 @@
 
 			if (copy) {
 				skb1 = skb_clone(skb, GFP_ATOMIC);
-				ret = -ENOMEM;
+				rc = -ENOMEM;
 				if (!skb1)
 					goto out;
 			} else {
@@ -464,10 +451,10 @@
 	if (!copy)
 		kfree_skb(skb);
 
-	ret = 0;
+	rc = 0;
 out:
 	spin_unlock_bh(&intrfc->if_sklist_lock);
-	return ret;
+	return rc;
 }
 #else
 static struct sock *ncp_connection_hack(struct ipx_interface *intrfc,
@@ -510,7 +497,7 @@
 	struct ipxhdr *ipx = ipx_hdr(skb);
 	struct sock *sock1 = NULL, *sock2 = NULL;
 	struct sk_buff *skb1 = NULL, *skb2 = NULL;
-	int ret;
+	int rc;
 
 	if (intrfc == ipx_primary_net && ntohs(ipx->ipx_dest.sock) == 0x451)
 		sock1 = ncp_connection_hack(intrfc, ipx);
@@ -541,10 +528,11 @@
 	/*
 	 * If there is nothing to do return. The kfree will cancel any charging.
 	 */
+	rc = 0;
 	if (!sock1 && !sock2) {
 		if (!copy)
 			kfree_skb(skb);
-		return 0;
+		goto out;
 	}
 
 	/*
@@ -560,9 +548,9 @@
 	else
 		skb1 = skb;
 
-	ret = -ENOMEM;
+	rc = -ENOMEM;
 	if (!skb1)
-		goto out;
+		goto out_put;
 
 	/* Do we need 2 SKBs? */
 	if (sock1 && sock2)
@@ -573,20 +561,20 @@
 	if (sock1)
 		ipxitf_def_skb_handler(sock1, skb1);
 
-	ret = -ENOMEM;
 	if (!skb2)
-		goto out;
+		goto out_put;
 
 	if (sock2)
 		ipxitf_def_skb_handler(sock2, skb2);
 
-	ret = 0;
-out:
+	rc = 0;
+out_put:
 	if (sock1)
 		sock_put(sock1);
 	if (sock2)
 		sock_put(sock2);
-	return ret;
+out:
+	return rc;
 }
 #endif	/* CONFIG_IPX_INTERN */
 
@@ -740,7 +728,7 @@
 static int ipxitf_rcv(struct ipx_interface *intrfc, struct sk_buff *skb)
 {
 	struct ipxhdr *ipx = ipx_hdr(skb);
-	int ret = 0;
+	int rc = 0;
 
 	ipxitf_hold(intrfc);
 
@@ -750,8 +738,8 @@
 	
 	IPX_SKB_CB(skb)->last_hop.index = -1;
 	if (ipx->ipx_type == IPX_TYPE_PPROP) {
-		ret = ipxitf_pprop(intrfc, skb);
-		if (ret)
+		rc = ipxitf_pprop(intrfc, skb);
+		if (rc)
 			goto out_free_skb;
 	}
 
@@ -769,7 +757,7 @@
 		if (skb->pkt_type == PACKET_HOST) {
 			skb = skb_unshare(skb, GFP_ATOMIC);
 			if (skb)
-				ret = ipxrtr_route_skb(skb);
+				rc = ipxrtr_route_skb(skb);
 			goto out_intrfc;
 		}
 
@@ -779,7 +767,7 @@
 	/* see if we should keep it */
 	if (!memcmp(ipx_broadcast_node, ipx->ipx_dest.node, IPX_NODE_LEN) ||
 	    !memcmp(intrfc->if_node, ipx->ipx_dest.node, IPX_NODE_LEN)) {
-		ret = ipxitf_demux_socket(intrfc, skb, 0);
+		rc = ipxitf_demux_socket(intrfc, skb, 0);
 		goto out_intrfc;
 	}
 
@@ -788,7 +776,7 @@
 	kfree_skb(skb);
 out_intrfc:
 	ipxitf_put(intrfc);
-	return ret;
+	return rc;
 }
 
 static void ipxitf_discover_netnum(struct ipx_interface *intrfc,
@@ -846,7 +834,7 @@
 static int ipxitf_pprop(struct ipx_interface *intrfc, struct sk_buff *skb)
 {
 	struct ipxhdr *ipx = ipx_hdr(skb);
-	int i, ret = -EINVAL;
+	int i, rc = -EINVAL;
 	struct ipx_interface *ifcs;
 	char *c;
 	u32 *l;
@@ -860,7 +848,7 @@
 	    				IPX_MAX_PPROP_HOPS * sizeof(u32))
 		goto out;
 	/* are we broadcasting this damn thing? */
-	ret = 0;
+	rc = 0;
 	if (!sysctl_ipx_pprop_broadcasting)
 		goto out;
 	/* We do broadcast packet on the IPX_MAX_PPROP_HOPS hop, but we
@@ -909,7 +897,7 @@
 	}
 	spin_unlock_bh(&ipx_interfaces_lock);
 out:
-	return ret;
+	return rc;
 }
 
 static void ipxitf_insert(struct ipx_interface *intrfc)
@@ -949,7 +937,6 @@
 		intrfc->if_sklist 	= NULL;
 		atomic_set(&intrfc->refcnt, 1);
 		spin_lock_init(&intrfc->if_sklist_lock);
-		MOD_INC_USE_COUNT;
 	}
 
 	return intrfc;
@@ -958,24 +945,24 @@
 static int ipxitf_create_internal(struct ipx_interface_definition *idef)
 {
 	struct ipx_interface *intrfc;
-	int ret = -EEXIST;
+	int rc = -EEXIST;
 
 	/* Only one primary network allowed */
 	if (ipx_primary_net)
 		goto out;
 
 	/* Must have a valid network number */
-	ret = -EADDRNOTAVAIL;
+	rc = -EADDRNOTAVAIL;
 	if (!idef->ipx_network)
 		goto out;
 	intrfc = ipxitf_find_using_net(idef->ipx_network);
-	ret = -EADDRINUSE;
+	rc = -EADDRINUSE;
 	if (intrfc) {
 		ipxitf_put(intrfc);
 		goto out;
 	}
 	intrfc = ipxitf_alloc(NULL, idef->ipx_network, 0, NULL, 1, 0);
-	ret = -EAGAIN;
+	rc = -EAGAIN;
 	if (!intrfc)
 		goto out;
 	memcpy((char *)&(intrfc->if_node), idef->ipx_node, IPX_NODE_LEN);
@@ -983,28 +970,24 @@
 	ipxitf_hold(intrfc);
 	ipxitf_insert(intrfc);
 
-	ret = ipxitf_add_local_route(intrfc);
+	rc = ipxitf_add_local_route(intrfc);
 	ipxitf_put(intrfc);
 out:
-	return ret;
+	return rc;
 }
 
 static int ipx_map_frame_type(unsigned char type)
 {
-	int ret = 0;
+	int rc = 0;
 
 	switch (type) {
-		case IPX_FRAME_ETHERII:
-			ret = htons(ETH_P_IPX);		break;
-		case IPX_FRAME_8022:
-			ret = htons(ETH_P_802_2);	break;
-		case IPX_FRAME_SNAP:
-			ret = htons(ETH_P_SNAP);	break;
-		case IPX_FRAME_8023:
-			ret = htons(ETH_P_802_3);	break;
+	case IPX_FRAME_ETHERII:	rc = htons(ETH_P_IPX);		break;
+	case IPX_FRAME_8022:	rc = htons(ETH_P_802_2);	break;
+	case IPX_FRAME_SNAP:	rc = htons(ETH_P_SNAP);		break;
+	case IPX_FRAME_8023:	rc = htons(ETH_P_802_3);	break;
 	}
 
-	return ret;
+	return rc;
 }
 
 static int ipxitf_create(struct ipx_interface_definition *idef)
@@ -1013,19 +996,19 @@
 	unsigned short dlink_type = 0;
 	struct datalink_proto *datalink = NULL;
 	struct ipx_interface *intrfc;
-	int err;
+	int rc;
 
 	if (idef->ipx_special == IPX_INTERNAL) {
-		err = ipxitf_create_internal(idef);
+		rc = ipxitf_create_internal(idef);
 		goto out;
 	}
 
-	err = -EEXIST;
+	rc = -EEXIST;
 	if (idef->ipx_special == IPX_PRIMARY && ipx_primary_net)
 		goto out;
 
 	intrfc = ipxitf_find_using_net(idef->ipx_network);
-	err = -EADDRINUSE;
+	rc = -EADDRINUSE;
 	if (idef->ipx_network && intrfc) {
 		ipxitf_put(intrfc);
 		goto out;
@@ -1035,49 +1018,49 @@
 		ipxitf_put(intrfc);
 
 	dev = dev_get_by_name(idef->ipx_device);
-	err = -ENODEV;
+	rc = -ENODEV;
 	if (!dev)
 		goto out;
 
 	switch (idef->ipx_dlink_type) {
-		case IPX_FRAME_TR_8022:
-			printk(KERN_WARNING "IPX frame type 802.2TR is "
-				"obsolete Use 802.2 instead.\n");
-			/* fall through */
-		case IPX_FRAME_8022:
-			dlink_type 	= htons(ETH_P_802_2);
-			datalink 	= p8022_datalink;
+	case IPX_FRAME_TR_8022:
+		printk(KERN_WARNING "IPX frame type 802.2TR is "
+			"obsolete Use 802.2 instead.\n");
+		/* fall through */
+	case IPX_FRAME_8022:
+		dlink_type 	= htons(ETH_P_802_2);
+		datalink 	= p8022_datalink;
+		break;
+	case IPX_FRAME_ETHERII:
+		if (dev->type != ARPHRD_IEEE802) {
+			dlink_type 	= htons(ETH_P_IPX);
+			datalink 	= pEII_datalink;
 			break;
-		case IPX_FRAME_ETHERII:
-			if (dev->type != ARPHRD_IEEE802) {
-				dlink_type 	= htons(ETH_P_IPX);
-				datalink 	= pEII_datalink;
-				break;
-			} else 
-				printk(KERN_WARNING "IPX frame type EtherII "
-					"over token-ring is obsolete. Use SNAP "
+		} else 
+			printk(KERN_WARNING "IPX frame type EtherII over "
+					"token-ring is obsolete. Use SNAP "
 					"instead.\n");
-			/* fall through */
-		case IPX_FRAME_SNAP:
-			dlink_type 	= htons(ETH_P_SNAP);
-			datalink 	= pSNAP_datalink;
-			break;
-		case IPX_FRAME_8023:
-			dlink_type 	= htons(ETH_P_802_3);
-			datalink 	= p8023_datalink;
-			break;
-		case IPX_FRAME_NONE:
-		default:
-			err = -EPROTONOSUPPORT;
-			goto out_dev;
+		/* fall through */
+	case IPX_FRAME_SNAP:
+		dlink_type 	= htons(ETH_P_SNAP);
+		datalink 	= pSNAP_datalink;
+		break;
+	case IPX_FRAME_8023:
+		dlink_type 	= htons(ETH_P_802_3);
+		datalink 	= p8023_datalink;
+		break;
+	case IPX_FRAME_NONE:
+	default:
+		rc = -EPROTONOSUPPORT;
+		goto out_dev;
 	}
 
-	err = -ENETDOWN;
+	rc = -ENETDOWN;
 	if (!(dev->flags & IFF_UP))
 		goto out_dev;
 
 	/* Check addresses are suitable */
-	err = -EINVAL;
+	rc = -EINVAL;
 	if (dev->addr_len > IPX_NODE_LEN)
 		goto out_dev;
 
@@ -1087,7 +1070,7 @@
 		intrfc = ipxitf_alloc(dev, idef->ipx_network, dlink_type,
 				      datalink, 0, dev->hard_header_len +
 					datalink->header_length);
-		err = -EAGAIN;
+		rc = -EAGAIN;
 		if (!intrfc)
 			goto out_dev;
 		/* Setup primary if necessary */
@@ -1106,18 +1089,18 @@
 
 
 	/* If the network number is known, add a route */
-	err = 0;
+	rc = 0;
 	if (!intrfc->if_netnum)
 		goto out_intrfc;
 
-	err = ipxitf_add_local_route(intrfc);
+	rc = ipxitf_add_local_route(intrfc);
 out_intrfc:
 	ipxitf_put(intrfc);
 	goto out;
 out_dev:
 	dev_put(dev);
 out:
-	return err;
+	return rc;
 }
 
 static int ipxitf_delete(struct ipx_interface_definition *idef)
@@ -1125,7 +1108,7 @@
 	struct net_device *dev = NULL;
 	unsigned short dlink_type = 0;
 	struct ipx_interface *intrfc;
-	int ret = 0;
+	int rc = 0;
 
 	spin_lock_bh(&ipx_interfaces_lock);
 	if (idef->ipx_special == IPX_INTERNAL) {
@@ -1133,30 +1116,30 @@
 			__ipxitf_put(ipx_internal_net);
 			goto out;
 		}
-		ret = -ENOENT;
+		rc = -ENOENT;
 		goto out;
 	}
 
 	dlink_type = ipx_map_frame_type(idef->ipx_dlink_type);
-	ret = -EPROTONOSUPPORT;
+	rc = -EPROTONOSUPPORT;
 	if (!dlink_type)
 		goto out;
 
 	dev = __dev_get_by_name(idef->ipx_device);
-	ret = -ENODEV;
+	rc = -ENODEV;
 	if (!dev)
 		goto out;
 
 	intrfc = __ipxitf_find_using_phys(dev, dlink_type);
-	ret = -EINVAL;
+	rc = -EINVAL;
 	if (!intrfc)
 		goto out;
 	__ipxitf_put(intrfc);
 
-	ret = 0;
+	rc = 0;
 out:
 	spin_unlock_bh(&ipx_interfaces_lock);
-	return ret;
+	return rc;
 }
 
 static struct ipx_interface *ipxitf_auto_create(struct net_device *dev,
@@ -1173,24 +1156,11 @@
 		goto out;
 
 	switch (htons(dlink_type)) {
-		case ETH_P_IPX:
-			datalink = pEII_datalink;
-			break;
-
-		case ETH_P_802_2:
-			datalink = p8022_datalink;
-			break;
-
-		case ETH_P_SNAP:
-			datalink = pSNAP_datalink;
-			break;
-
-		case ETH_P_802_3:
-			datalink = p8023_datalink;
-			break;
-
-		default:
-			goto out;
+	case ETH_P_IPX:		datalink = pEII_datalink;	break;
+	case ETH_P_802_2:	datalink = p8022_datalink;	break;
+	case ETH_P_SNAP:	datalink = pSNAP_datalink;	break;
+	case ETH_P_802_3:	datalink = p8023_datalink;	break;
+	default:		goto out;
 	}
 
 	intrfc = ipxitf_alloc(dev, 0, dlink_type, datalink, 0,
@@ -1212,80 +1182,82 @@
 
 static int ipxitf_ioctl(unsigned int cmd, void *arg)
 {
+	int rc = -EINVAL;
 	struct ifreq ifr;
 	int val;
 
 	switch (cmd) {
-		case SIOCSIFADDR: {
-			struct sockaddr_ipx *sipx;
-			struct ipx_interface_definition f;
-
-			if (copy_from_user(&ifr, arg, sizeof(ifr)))
-				return -EFAULT;
-
-			sipx = (struct sockaddr_ipx *)&ifr.ifr_addr;
-			if (sipx->sipx_family != AF_IPX)
-				return -EINVAL;
-
-			f.ipx_network = sipx->sipx_network;
-			memcpy(f.ipx_device, ifr.ifr_name,
-				sizeof(f.ipx_device));
-			memcpy(f.ipx_node, sipx->sipx_node, IPX_NODE_LEN);
-			f.ipx_dlink_type = sipx->sipx_type;
-			f.ipx_special = sipx->sipx_special;
+	case SIOCSIFADDR: {
+		struct sockaddr_ipx *sipx;
+		struct ipx_interface_definition f;
 
-			if (sipx->sipx_action == IPX_DLTITF)
-				return ipxitf_delete(&f);
-			else
-				return ipxitf_create(&f);
-		}
-
-		case SIOCGIFADDR: {
-			int err = 0;
-			struct sockaddr_ipx *sipx;
-			struct ipx_interface *ipxif;
-			struct net_device *dev;
-
-			if (copy_from_user(&ifr, arg, sizeof(ifr)))
-				return -EFAULT;
-
-			sipx = (struct sockaddr_ipx *)&ifr.ifr_addr;
-			dev = __dev_get_by_name(ifr.ifr_name);
-			if (!dev)
-				return -ENODEV;
-
-			ipxif = ipxitf_find_using_phys(dev, ipx_map_frame_type(sipx->sipx_type));
-			if (!ipxif)
-				return -EADDRNOTAVAIL;
-
-			sipx->sipx_family	= AF_IPX;
-			sipx->sipx_network	= ipxif->if_netnum;
-			memcpy(sipx->sipx_node, ipxif->if_node,
-				sizeof(sipx->sipx_node));
-			if (copy_to_user(arg, &ifr, sizeof(ifr)))
-				err = -EFAULT;
+		rc = -EFAULT;
+		if (copy_from_user(&ifr, arg, sizeof(ifr)))
+			break;
+		sipx = (struct sockaddr_ipx *)&ifr.ifr_addr;
+		rc = -EINVAL;
+		if (sipx->sipx_family != AF_IPX)
+			break;
+		f.ipx_network = sipx->sipx_network;
+		memcpy(f.ipx_device, ifr.ifr_name,
+			sizeof(f.ipx_device));
+		memcpy(f.ipx_node, sipx->sipx_node, IPX_NODE_LEN);
+		f.ipx_dlink_type = sipx->sipx_type;
+		f.ipx_special = sipx->sipx_special;
 
-			ipxitf_put(ipxif);
-			return err;
-		}
+		if (sipx->sipx_action == IPX_DLTITF)
+			rc = ipxitf_delete(&f);
+		else
+			rc = ipxitf_create(&f);
+		break;
+	}
+	case SIOCGIFADDR: {
+		struct sockaddr_ipx *sipx;
+		struct ipx_interface *ipxif;
+		struct net_device *dev;
 
-		case SIOCAIPXITFCRT: 
-			if (get_user(val, (unsigned char *) arg))
-				return -EFAULT;
-			ipxcfg_set_auto_create(val);
+		rc = -EFAULT;
+		if (copy_from_user(&ifr, arg, sizeof(ifr)))
 			break;
-
-		case SIOCAIPXPRISLT: 
-			if (get_user(val, (unsigned char *) arg))
-				return -EFAULT;
-			ipxcfg_set_auto_select(val);
+		sipx = (struct sockaddr_ipx *)&ifr.ifr_addr;
+		dev  = __dev_get_by_name(ifr.ifr_name);
+		rc   = -ENODEV;
+		if (!dev)
+			break;
+		ipxif = ipxitf_find_using_phys(dev,
+					   ipx_map_frame_type(sipx->sipx_type));
+		rc = -EADDRNOTAVAIL;
+		if (!ipxif)
 			break;
 
-		default:
-			return -EINVAL;
+		sipx->sipx_family	= AF_IPX;
+		sipx->sipx_network	= ipxif->if_netnum;
+		memcpy(sipx->sipx_node, ipxif->if_node,
+			sizeof(sipx->sipx_node));
+		rc = -EFAULT;
+		if (copy_to_user(arg, &ifr, sizeof(ifr)))
+			break;
+		ipxitf_put(ipxif);
+		rc = 0;
+		break;
+	}
+	case SIOCAIPXITFCRT: 
+		rc = -EFAULT;
+		if (get_user(val, (unsigned char *) arg))
+			break;
+		rc = 0;
+		ipxcfg_auto_create_interfaces = val;
+		break;
+	case SIOCAIPXPRISLT: 
+		rc = -EFAULT;
+		if (get_user(val, (unsigned char *) arg))
+			break;
+		rc = 0;
+		ipxcfg_set_auto_select(val);
+		break;
 	}
 
-	return 0;
+	return rc;
 }
 
 /* Routing tables for the IPX socket layer. */
@@ -1321,13 +1293,13 @@
 			    unsigned char *node)
 {
 	struct ipx_route *rt;
-	int ret;
+	int rc;
 
 	/* Get a route structure; either existing or create */
 	rt = ipxrtr_lookup(network);
 	if (!rt) {
 		rt = kmalloc(sizeof(*rt), GFP_ATOMIC);
-		ret = -EAGAIN;
+		rc = -EAGAIN;
 		if (!rt)
 			goto out;
 
@@ -1338,7 +1310,7 @@
 		ipx_routes	= rt;
 		write_unlock_bh(&ipx_routes_lock);
 	} else {
-		ret = -EEXIST;
+		rc = -EEXIST;
 		if (intrfc == ipx_internal_net)
 			goto out_put;
 	}
@@ -1353,11 +1325,11 @@
 		rt->ir_routed = 1;
 	}
 
-	ret = 0;
+	rc = 0;
 out_put:
 	ipxrtr_put(rt);
 out:
-	return ret;
+	return rc;
 }
 
 static void ipxrtr_del_routes(struct ipx_interface *intrfc)
@@ -1378,44 +1350,44 @@
 static int ipxrtr_create(struct ipx_route_definition *rd)
 {
 	struct ipx_interface *intrfc;
-	int ret = -ENETUNREACH;
+	int rc = -ENETUNREACH;
 
 	/* Find the appropriate interface */
 	intrfc = ipxitf_find_using_net(rd->ipx_router_network);
 	if (!intrfc)
 		goto out;
-	ret = ipxrtr_add_route(rd->ipx_network, intrfc, rd->ipx_router_node);
+	rc = ipxrtr_add_route(rd->ipx_network, intrfc, rd->ipx_router_node);
 	ipxitf_put(intrfc);
 out:
-	return ret;
+	return rc;
 }
 
 static int ipxrtr_delete(long net)
 {
 	struct ipx_route **r;
 	struct ipx_route *tmp;
-	int err;
+	int rc;
 
 	write_lock_bh(&ipx_routes_lock);
 	for (r = &ipx_routes; (tmp = *r) != NULL;) {
 		if (tmp->ir_net == net) {
 			/* Directly connected; can't lose route */
-			err = -EPERM;
+			rc = -EPERM;
 			if (!tmp->ir_routed)
 				goto out;
 
 			*r = tmp->ir_next;
 			ipxrtr_put(tmp);
-			err = 0;
+			rc = 0;
 			goto out;
 		}
 
 		r = &(tmp->ir_next);
 	}
-	err = -ENOENT;
+	rc = -ENOENT;
 out:
 	write_unlock_bh(&ipx_routes_lock);
-	return err;
+	return rc;
 }
 
 /*
@@ -1470,7 +1442,7 @@
 	int size;
 	int ipx_offset;
 	struct ipx_route *rt = NULL;
-	int err;
+	int rc;
 
 	/* Find the appropriate interface on which to send packet */
 	if (!usipx->sipx_network && ipx_primary_net) {
@@ -1478,7 +1450,7 @@
 		intrfc = ipx_primary_net;
 	} else {
 		rt = ipxrtr_lookup(usipx->sipx_network);
-		err = -ENETUNREACH;
+		rc = -ENETUNREACH;
 		if (!rt)
 			goto out;
 		intrfc = rt->ir_intrfc;
@@ -1488,7 +1460,7 @@
 	ipx_offset = intrfc->if_ipx_offset;
 	size = sizeof(struct ipxhdr) + len + ipx_offset;
 
-	skb = sock_alloc_send_skb(sk, size, noblock, &err);
+	skb = sock_alloc_send_skb(sk, size, noblock, &rc);
 	if (!skb)
 		goto out_put;
 
@@ -1507,8 +1479,8 @@
 	IPX_SKB_CB(skb)->ipx_source_net = ipxs->intrfc->if_netnum;
 	memcpy(ipx->ipx_source.node, ipxs->node, IPX_NODE_LEN);
 #else
-	err = ntohs(ipxs->port);
-	if (err == 0x453 || err == 0x452) {
+	rc = ntohs(ipxs->port);
+	if (rc == 0x453 || rc == 0x452) {
 		/* RIP/SAP special handling for mars_nwe */
 		IPX_SKB_CB(skb)->ipx_source_net = intrfc->if_netnum;
 		memcpy(ipx->ipx_source.node, intrfc->if_node, IPX_NODE_LEN);
@@ -1523,8 +1495,8 @@
 	memcpy(ipx->ipx_dest.node, usipx->sipx_node, IPX_NODE_LEN);
 	ipx->ipx_dest.sock		= usipx->sipx_port;
 
-	err = memcpy_fromiovec(skb_put(skb, len), iov, len);
-	if (err) {
+	rc = memcpy_fromiovec(skb_put(skb, len), iov, len);
+	if (rc) {
 		kfree_skb(skb);
 		goto out_put;
 	}	
@@ -1535,14 +1507,14 @@
 	else
 		ipx->ipx_checksum = ipx_cksum(ipx, len + sizeof(struct ipxhdr));
 
-	err = ipxitf_send(intrfc, skb, (rt && rt->ir_routed) ? 
-				rt->ir_router_node : ipx->ipx_dest.node);
+	rc = ipxitf_send(intrfc, skb, (rt && rt->ir_routed) ? 
+			 rt->ir_router_node : ipx->ipx_dest.node);
 out_put:
 	ipxitf_put(intrfc);
 	if (rt)
 		ipxrtr_put(rt);
 out:
-	return err;
+	return rc;
 }
 
 /* the skb has to be unshared, we'll end up calling ipxitf_send, that'll
@@ -1573,7 +1545,7 @@
 {
 	struct rtentry rt;	/* Use these to behave like 'other' stacks */
 	struct sockaddr_ipx *sg, *st;
-	int ret = -EFAULT;
+	int rc = -EFAULT;
 
 	if (copy_from_user(&rt, arg, sizeof(rt)))
 		goto out;
@@ -1581,43 +1553,43 @@
 	sg = (struct sockaddr_ipx *)&rt.rt_gateway;
 	st = (struct sockaddr_ipx *)&rt.rt_dst;
 
-	ret = -EINVAL;
+	rc = -EINVAL;
 	if (!(rt.rt_flags & RTF_GATEWAY) || /* Direct routes are fixed */
 	    sg->sipx_family != AF_IPX ||
 	    st->sipx_family != AF_IPX)
 		goto out;
 
 	switch (cmd) {
-		case SIOCDELRT:
-			ret = ipxrtr_delete(st->sipx_network);
-			break;
-		case SIOCADDRT: {
-			struct ipx_route_definition f;
-			f.ipx_network		= st->sipx_network;
-			f.ipx_router_network	= sg->sipx_network;
-			memcpy(f.ipx_router_node, sg->sipx_node, IPX_NODE_LEN);
-			ret = ipxrtr_create(&f);
-			break;
-		}
+	case SIOCDELRT:
+		rc = ipxrtr_delete(st->sipx_network);
+		break;
+	case SIOCADDRT: {
+		struct ipx_route_definition f;
+		f.ipx_network		= st->sipx_network;
+		f.ipx_router_network	= sg->sipx_network;
+		memcpy(f.ipx_router_node, sg->sipx_node, IPX_NODE_LEN);
+		rc = ipxrtr_create(&f);
+		break;
+	}
 	}
 
 out:
-	return ret;
+	return rc;
 }
 
 const char *ipx_frame_name(unsigned short frame)
 {
-	char* ret = "None";
+	char* rc = "None";
 
 	switch (ntohs(frame)) {
-		case ETH_P_IPX:		ret = "EtherII";	break;
-		case ETH_P_802_2:	ret = "802.2";		break;
-		case ETH_P_SNAP:	ret = "SNAP";		break;
-		case ETH_P_802_3:	ret = "802.3";		break;
-		case ETH_P_TR_802_2:	ret = "802.2TR";	break;
+	case ETH_P_IPX:		rc = "EtherII";	break;
+	case ETH_P_802_2:	rc = "802.2";	break;
+	case ETH_P_SNAP:	rc = "SNAP";	break;
+	case ETH_P_802_3:	rc = "802.3";	break;
+	case ETH_P_TR_802_2:	rc = "802.2TR";	break;
 	}
 
-	return ret;
+	return rc;
 }
 
 const char *ipx_device_name(struct ipx_interface *intrfc)
@@ -1634,23 +1606,23 @@
 {
 	struct sock *sk = sock->sk;
 	int opt;
-	int ret = -EINVAL;
+	int rc = -EINVAL;
 
 	if (optlen != sizeof(int))
 		goto out;
 
-	ret = -EFAULT;
+	rc = -EFAULT;
 	if (get_user(opt, (unsigned int *)optval))
 		goto out;
 
-	ret = -ENOPROTOOPT;
+	rc = -ENOPROTOOPT;
 	if (!(level == SOL_IPX && optname == IPX_TYPE))
 		goto out;
 
 	ipx_sk(sk)->type = opt;
-	ret = 0;
+	rc = 0;
 out:
-	return ret;
+	return rc;
 }
 
 static int ipx_getsockopt(struct socket *sock, int level, int optname,
@@ -1659,61 +1631,59 @@
 	struct sock *sk = sock->sk;
 	int val = 0;
 	int len;
-	int ret = -ENOPROTOOPT;
+	int rc = -ENOPROTOOPT;
 
 	if (!(level == SOL_IPX && optname == IPX_TYPE))
 		goto out;
 
 	val = ipx_sk(sk)->type;
 
-	ret = -EFAULT;
+	rc = -EFAULT;
 	if (get_user(len, optlen))
 		goto out;
 
 	len = min_t(unsigned int, len, sizeof(int));
-	ret = -EINVAL;
+	rc = -EINVAL;
 	if(len < 0)
 		goto out;
 		
-	ret = -EFAULT;
+	rc = -EFAULT;
 	if (put_user(len, optlen) || copy_to_user(optval, &val, len))
 		goto out;
 
-	ret = 0;
+	rc = 0;
 out:
-	return ret;
+	return rc;
 }
 
 static int ipx_create(struct socket *sock, int protocol)
 {
-	int ret = -ESOCKTNOSUPPORT;
+	int rc = -ESOCKTNOSUPPORT;
 	struct ipx_opt *ipx = NULL;
 	struct sock *sk;
 
-	MOD_INC_USE_COUNT;
 	switch (sock->type) {
-		case SOCK_DGRAM:
-			sk = sk_alloc(PF_IPX, GFP_KERNEL, 1, NULL);
-                	ret = -ENOMEM;
-			if (!sk)
-				goto decmod;
-			ipx = ipx_sk(sk) = kmalloc(sizeof(*ipx), GFP_KERNEL);
-			if (!ipx)
-				goto outsk;
-			memset(ipx, 0, sizeof(*ipx));
-                        sock->ops = &ipx_dgram_ops;
-                        break;
-
-		case SOCK_SEQPACKET:
-			/*
-			 * SPX support is not anymore in the kernel sources. If
-			 * you want to ressurrect it, completing it and making
-			 * it understand shared skbs, be fully multithreaded,
-			 * etc, grab the sources in an early 2.5 kernel tree.
-			 */
-		case SOCK_STREAM:       /* Allow higher levels to piggyback */
-		default:
-			goto decmod;
+	case SOCK_DGRAM:
+		sk = sk_alloc(PF_IPX, GFP_KERNEL, 1, NULL);
+        	rc = -ENOMEM;
+		if (!sk)
+			goto out;
+		ipx = ipx_sk(sk) = kmalloc(sizeof(*ipx), GFP_KERNEL);
+		if (!ipx)
+			goto outsk;
+		memset(ipx, 0, sizeof(*ipx));
+                sock->ops = &ipx_dgram_ops;
+                break;
+	case SOCK_SEQPACKET:
+		/*
+		 * SPX support is not anymore in the kernel sources. If
+		 * you want to ressurrect it, completing it and making
+		 * it understand shared skbs, be fully multithreaded,
+		 * etc, grab the sources in an early 2.5 kernel tree.
+		 */
+	case SOCK_STREAM:       /* Allow higher levels to piggyback */
+	default:
+		goto out;
 	}
 #ifdef IPX_REFCNT_DEBUG
         atomic_inc(&ipx_sock_nr);
@@ -1722,13 +1692,11 @@
 #endif
 	sock_init_data(sock, sk);
 	sk->no_check = 1;		/* Checksum off by default */
-	ret = 0;
+	rc = 0;
 out:
-	return ret;
+	return rc;
 outsk:
 	sk_free(sk);
-decmod:
-	MOD_DEC_USE_COUNT;
 	goto out;
 }
 
@@ -1745,10 +1713,6 @@
 	__set_bit(SOCK_DEAD, &sk->flags);
 	sock->sk = NULL;
 	ipx_destroy_socket(sk);
-
-	if (sock->type == SOCK_DGRAM)
-		MOD_DEC_USE_COUNT;
-
 out:
 	return 0;
 }
@@ -1782,25 +1746,25 @@
 	struct ipx_opt *ipxs = ipx_sk(sk);
 	struct ipx_interface *intrfc;
 	struct sockaddr_ipx *addr = (struct sockaddr_ipx *)uaddr;
-	int ret = -EINVAL;
+	int rc = -EINVAL;
 
 	if (!sk->zapped || addr_len != sizeof(struct sockaddr_ipx))
 		goto out;
 
 	intrfc = ipxitf_find_using_net(addr->sipx_network);
-	ret = -EADDRNOTAVAIL;
+	rc = -EADDRNOTAVAIL;
 	if (!intrfc)
 		goto out;
 
 	if (!addr->sipx_port) {
 		addr->sipx_port = ipx_first_free_socketnum(intrfc);
-		ret = -EINVAL;
+		rc = -EINVAL;
 		if (!addr->sipx_port)
 			goto out_put;
 	}
 
 	/* protect IPX system stuff like routing/sap */
-	ret = -EACCES;
+	rc = -EACCES;
 	if (ntohs(addr->sipx_port) < IPX_MIN_EPHEMERAL_SOCKET &&
 	    !capable(CAP_NET_ADMIN))
 		goto out_put;
@@ -1814,7 +1778,7 @@
 		 * node number 0 was specified, the default is used.
 		 */
 
-		ret = -EINVAL;
+		rc = -EINVAL;
 		if (!memcmp(addr->sipx_node, ipx_broadcast_node, IPX_NODE_LEN))
 			goto out_put;
 		if (!memcmp(addr->sipx_node, ipx_this_node, IPX_NODE_LEN))
@@ -1822,7 +1786,7 @@
 		else
 			memcpy(ipxs->node, addr->sipx_node, IPX_NODE_LEN);
 
-		ret = -EADDRINUSE;
+		rc = -EADDRINUSE;
 		if (ipxitf_find_internal_socket(intrfc, ipxs->node,
 						ipxs->port)) {
 			SOCK_DEBUG(sk,
@@ -1838,7 +1802,7 @@
 
 		memcpy(ipxs->node, intrfc->if_node, IPX_NODE_LEN);
 
-		ret = -EADDRINUSE;
+		rc = -EADDRINUSE;
 		if (ipxitf_find_socket(intrfc, addr->sipx_port)) {
 			SOCK_DEBUG(sk,
 				"IPX: bind failed because port %X in use.\n",
@@ -1852,7 +1816,7 @@
 	/* Source addresses are easy. It must be our network:node pair for
 	   an interface routed to IPX with the ipx routing ioctl() */
 
-	ret = -EADDRINUSE;
+	rc = -EADDRINUSE;
 	if (ipxitf_find_socket(intrfc, addr->sipx_port)) {
 		SOCK_DEBUG(sk, "IPX: bind failed because port %X in use.\n",
 				ntohs((int)addr->sipx_port));
@@ -1865,11 +1829,11 @@
 	sk->zapped = 0;
 	SOCK_DEBUG(sk, "IPX: bound socket 0x%04X.\n", ntohs(addr->sipx_port) );
 
-	ret = 0;
+	rc = 0;
 out_put:
 	ipxitf_put(intrfc);
 out:
-	return ret;
+	return rc;
 }
 
 static int ipx_connect(struct socket *sock, struct sockaddr *uaddr,
@@ -1878,7 +1842,7 @@
 	struct sock *sk = sock->sk;
 	struct ipx_opt *ipxs = ipx_sk(sk);
 	struct sockaddr_ipx *addr;
-	int ret = -EINVAL;
+	int rc = -EINVAL;
 	struct ipx_route *rt;
 
 	sk->state	= TCP_CLOSE;
@@ -1896,23 +1860,23 @@
 		uaddr.sipx_network 	= 0;
 
 #ifdef CONFIG_IPX_INTERN
-		ret = -ENETDOWN;
+		rc = -ENETDOWN;
 		if (!ipxs->intrfc)
 			goto out; /* Someone zonked the iface */
 		memcpy(uaddr.sipx_node, ipxs->intrfc->if_node,
 			IPX_NODE_LEN);
 #endif	/* CONFIG_IPX_INTERN */
 
-		ret = ipx_bind(sock, (struct sockaddr *)&uaddr,
-				sizeof(struct sockaddr_ipx));
-		if (ret)
+		rc = ipx_bind(sock, (struct sockaddr *)&uaddr,
+			      sizeof(struct sockaddr_ipx));
+		if (rc)
 			goto out;
 	}
 
         /* We can either connect to primary network or somewhere
 	 * we can route to */
 	rt = ipxrtr_lookup(addr->sipx_network);
-	ret = -ENETUNREACH;
+	rc = -ENETUNREACH;
 	if (!rt && !(!addr->sipx_network && ipx_primary_net))
 		goto out;
 
@@ -1928,9 +1892,9 @@
 
 	if (rt)
 		ipxrtr_put(rt);
-	ret = 0;
+	rc = 0;
 out:
-	return ret;
+	return rc;
 }
 
 
@@ -1941,12 +1905,12 @@
 	struct sockaddr_ipx sipx;
 	struct sock *sk = sock->sk;
 	struct ipx_opt *ipxs = ipx_sk(sk);
-	int ret;
+	int rc;
 
 	*uaddr_len = sizeof(struct sockaddr_ipx);
 
 	if (peer) {
-		ret = -ENOTCONN;
+		rc = -ENOTCONN;
 		if (sk->state != TCP_ESTABLISHED)
 			goto out;
 
@@ -1976,9 +1940,9 @@
 	sipx.sipx_type	 = ipxs->type;
 	memcpy(uaddr, &sipx, sizeof(sipx));
 
-	ret = 0;
+	rc = 0;
 out:
-	return ret;
+	return rc;
 }
 
 int ipx_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt)
@@ -1987,7 +1951,7 @@
 	struct ipx_interface *intrfc;
 	struct ipxhdr *ipx;
 	u16 ipx_pktsize;
-	int ret = 0;
+	int rc = 0;
 		
 	/* Not ours */	
         if (skb->pkt_type == PACKET_OTHERHOST)
@@ -2026,13 +1990,13 @@
 			goto drop;
 	}
 
-	ret = ipxitf_rcv(intrfc, skb);
+	rc = ipxitf_rcv(intrfc, skb);
 	ipxitf_put(intrfc);
 	goto out;
 drop:
 	kfree_skb(skb);
 out:
-	return ret;
+	return rc;
 }
 
 static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock,
@@ -2042,7 +2006,7 @@
 	struct ipx_opt *ipxs = ipx_sk(sk);
 	struct sockaddr_ipx *usipx = (struct sockaddr_ipx *)msg->msg_name;
 	struct sockaddr_ipx local_sipx;
-	int ret = -EINVAL;
+	int rc = -EINVAL;
 	int flags = msg->msg_flags;
 
 	/* Socket gets bound below anyway */
@@ -2058,24 +2022,24 @@
 			uaddr.sipx_port		= 0;
 			uaddr.sipx_network	= 0;
 #ifdef CONFIG_IPX_INTERN
-			ret = -ENETDOWN;
+			rc = -ENETDOWN;
 			if (!ipxs->intrfc)
 				goto out; /* Someone zonked the iface */
 			memcpy(uaddr.sipx_node, ipxs->intrfc->if_node,
 				IPX_NODE_LEN);
 #endif
-			ret = ipx_bind(sock, (struct sockaddr *)&uaddr,
+			rc = ipx_bind(sock, (struct sockaddr *)&uaddr,
 					sizeof(struct sockaddr_ipx));
-			if (ret)
+			if (rc)
 				goto out;
 		}
 
-		ret = -EINVAL;
+		rc = -EINVAL;
 		if (msg->msg_namelen < sizeof(*usipx) ||
 		    usipx->sipx_family != AF_IPX)
 			goto out;
 	} else {
-		ret = -ENOTCONN;
+		rc = -ENOTCONN;
 		if (sk->state != TCP_ESTABLISHED)
 			goto out;
 
@@ -2087,12 +2051,12 @@
 		memcpy(usipx->sipx_node, ipxs->dest_addr.node, IPX_NODE_LEN);
 	}
 
-	ret = ipxrtr_route_packet(sk, usipx, msg->msg_iov, len,
-				     flags & MSG_DONTWAIT);
-	if (ret >= 0)
-		ret = len;
+	rc = ipxrtr_route_packet(sk, usipx, msg->msg_iov, len,
+				 flags & MSG_DONTWAIT);
+	if (rc >= 0)
+		rc = len;
 out:
-	return ret;
+	return rc;
 }
 
 
@@ -2104,7 +2068,7 @@
 	struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)msg->msg_name;
 	struct ipxhdr *ipx = NULL;
 	struct sk_buff *skb;
-	int copied, err;
+	int copied, rc;
 
 	/* put the autobinding in */
 	if (!ipxs->port) {
@@ -2114,24 +2078,24 @@
 		uaddr.sipx_network 	= 0;
 
 #ifdef CONFIG_IPX_INTERN
-		err = -ENETDOWN;
+		rc = -ENETDOWN;
 		if (!ipxs->intrfc)
 			goto out; /* Someone zonked the iface */
 		memcpy(uaddr.sipx_node, ipxs->intrfc->if_node, IPX_NODE_LEN);
 #endif	/* CONFIG_IPX_INTERN */
 
-		err = ipx_bind(sock, (struct sockaddr *)&uaddr,
-				sizeof(struct sockaddr_ipx));
-		if (err)
+		rc = ipx_bind(sock, (struct sockaddr *)&uaddr,
+			      sizeof(struct sockaddr_ipx));
+		if (rc)
 			goto out;
 	}
 	
-	err = -ENOTCONN;
+	rc = -ENOTCONN;
 	if (sk->zapped)
 		goto out;
 
 	skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
-					flags & MSG_DONTWAIT, &err);
+				flags & MSG_DONTWAIT, &rc);
 	if (!skb)
 		goto out;
 
@@ -2142,9 +2106,9 @@
 		msg->msg_flags |= MSG_TRUNC;
 	}
 
-	err = skb_copy_datagram_iovec(skb, sizeof(struct ipxhdr), msg->msg_iov,
-					copied);
-	if (err)
+	rc = skb_copy_datagram_iovec(skb, sizeof(struct ipxhdr), msg->msg_iov,
+				     copied);
+	if (rc)
 		goto out_free;
 	sk->stamp = skb->stamp;
 
@@ -2157,92 +2121,92 @@
 		sipx->sipx_network	= IPX_SKB_CB(skb)->ipx_source_net;
 		sipx->sipx_type 	= ipx->ipx_type;
 	}
-	err = copied;
+	rc = copied;
 
 out_free:
 	skb_free_datagram(sk, skb);
 out:
-	return err;
+	return rc;
 }
 
 
 static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 {
+	int rc = 0;
 	long amount = 0;
 	struct sock *sk = sock->sk;
 
 	switch (cmd) {
-		case TIOCOUTQ:
-			amount = sk->sndbuf - atomic_read(&sk->wmem_alloc);
-			if (amount < 0)
-				amount = 0;
-			return put_user(amount, (int *)arg);
-
-		case TIOCINQ: {
-			struct sk_buff *skb = skb_peek(&sk->receive_queue);
-			/* These two are safe on a single CPU system as only
-			 * user tasks fiddle here */
-			if (skb)
-				amount = skb->len - sizeof(struct ipxhdr);
-			return put_user(amount, (int *)arg);
-		}
-
-		case SIOCADDRT:
-		case SIOCDELRT:
-			if (!capable(CAP_NET_ADMIN))
-				return -EPERM;
-			return ipxrtr_ioctl(cmd, (void *)arg);
-
-		case SIOCSIFADDR:
-		case SIOCAIPXITFCRT:
-		case SIOCAIPXPRISLT:
-			if (!capable(CAP_NET_ADMIN))
-				return -EPERM;
-
-		case SIOCGIFADDR:
-			return ipxitf_ioctl(cmd, (void *)arg);
-
-		case SIOCIPXCFGDATA:
-			return ipxcfg_get_config_data((void *)arg);
-
-		case SIOCIPXNCPCONN:
-			/*
-			 * This socket wants to take care of the NCP connection
-			 * handed to us in arg.
-			 */
-                	if (!capable(CAP_NET_ADMIN))
-                		return -EPERM;
-			return get_user(ipx_sk(sk)->ipx_ncp_conn,
-					(const unsigned short *)(arg));
-
-		case SIOCGSTAMP: {
-			int ret = -EINVAL;
-			if (sk) {
-				if (!sk->stamp.tv_sec)
-					return -ENOENT;
-				ret = -EFAULT;
-				if (!copy_to_user((void *)arg, &sk->stamp,
-						sizeof(struct timeval)))
-					ret = 0;
-			}
-
-			return ret;
+	case TIOCOUTQ:
+		amount = sk->sndbuf - atomic_read(&sk->wmem_alloc);
+		if (amount < 0)
+			amount = 0;
+		rc = put_user(amount, (int *)arg);
+		break;
+	case TIOCINQ: {
+		struct sk_buff *skb = skb_peek(&sk->receive_queue);
+		/* These two are safe on a single CPU system as only
+		 * user tasks fiddle here */
+		if (skb)
+			amount = skb->len - sizeof(struct ipxhdr);
+		rc = put_user(amount, (int *)arg);
+		break;
+	}
+	case SIOCADDRT:
+	case SIOCDELRT:
+		rc = -EPERM;
+		if (capable(CAP_NET_ADMIN))
+			rc = ipxrtr_ioctl(cmd, (void *)arg);
+		break;
+	case SIOCSIFADDR:
+	case SIOCAIPXITFCRT:
+	case SIOCAIPXPRISLT:
+		rc = -EPERM;
+		if (!capable(CAP_NET_ADMIN))
+			break;
+	case SIOCGIFADDR:
+		rc = ipxitf_ioctl(cmd, (void *)arg);
+		break;
+	case SIOCIPXCFGDATA:
+		rc = ipxcfg_get_config_data((void *)arg);
+		break;
+	case SIOCIPXNCPCONN:
+		/*
+		 * This socket wants to take care of the NCP connection
+		 * handed to us in arg.
+		 */
+        	rc = -EPERM;
+        	if (!capable(CAP_NET_ADMIN))
+			break;
+		rc = get_user(ipx_sk(sk)->ipx_ncp_conn,
+			      (const unsigned short *)(arg));
+		break;
+	case SIOCGSTAMP:
+		rc = -EINVAL;
+		if (sk) {
+			rc = -ENOENT;
+			if (!sk->stamp.tv_sec)
+				break;
+			rc = -EFAULT;
+			if (!copy_to_user((void *)arg, &sk->stamp,
+					  sizeof(struct timeval)))
+				rc = 0;
 		}
-
-		case SIOCGIFDSTADDR:
-		case SIOCSIFDSTADDR:
-		case SIOCGIFBRDADDR:
-		case SIOCSIFBRDADDR:
-		case SIOCGIFNETMASK:
-		case SIOCSIFNETMASK:
-			return -EINVAL;
-
-		default:
-			return dev_ioctl(cmd,(void *) arg);
+		break;
+	case SIOCGIFDSTADDR:
+	case SIOCSIFDSTADDR:
+	case SIOCGIFBRDADDR:
+	case SIOCSIFBRDADDR:
+	case SIOCGIFNETMASK:
+	case SIOCSIFNETMASK:
+		rc = -EINVAL;
+		break;
+	default:
+		rc = dev_ioctl(cmd,(void *) arg);
+		break;
 	}
 
-	/*NOT REACHED*/
-	return 0;
+	return rc;
 }
 
 /*
@@ -2252,6 +2216,7 @@
 static struct net_proto_family ipx_family_ops = {
 	.family		= PF_IPX,
 	.create		= ipx_create,
+	.owner		= THIS_MODULE,
 };
 
 static struct proto_ops SOCKOPS_WRAPPED(ipx_dgram_ops) = {
@@ -2278,19 +2243,19 @@
 SOCKOPS_WRAP(ipx_dgram, PF_IPX);
 
 static struct packet_type ipx_8023_packet_type = {
-	.type =		__constant_htons(ETH_P_802_3),
-	.func =		ipx_rcv,
-	.data =		(void *) 1,	/* yap, I understand shared skbs :-) */
+	.type		= __constant_htons(ETH_P_802_3),
+	.func		= ipx_rcv,
+	.data		= (void *)1,	/* yap, I understand shared skbs :-) */
 };
 
 static struct packet_type ipx_dix_packet_type = {
-	.type =		__constant_htons(ETH_P_IPX),
-	.func =		ipx_rcv,
-	.data =		(void *) 1,	/* yap, I understand shared skbs :-) */
+	.type		= __constant_htons(ETH_P_IPX),
+	.func		= ipx_rcv,
+	.data		= (void *)1,	/* yap, I understand shared skbs :-) */
 };
 
 static struct notifier_block ipx_dev_notifier = {
-	.notifier_call =ipxitf_device_event,
+	.notifier_call	= ipxitf_device_event,
 };
 
 extern struct datalink_proto *make_EII_client(void);
@@ -2344,21 +2309,6 @@
 	return 0;
 }
 
-module_init(ipx_init);
-
-/* Note on MOD_{INC,DEC}_USE_COUNT:
- *
- * Use counts are incremented/decremented when
- * sockets are created/deleted.
- *
- * Routes are always associated with an interface, and
- * allocs/frees will remain properly accounted for by
- * their associated interfaces.
- *
- * Ergo, before the ipx module can be removed, all IPX
- * sockets be closed from user space.
- */
-
 static void __exit ipx_proto_finito(void)
 {
 	/*
@@ -2389,5 +2339,6 @@
 	sock_unregister(ipx_family_ops.family);
 }
 
+module_init(ipx_init);
 module_exit(ipx_proto_finito);
 MODULE_LICENSE("GPL");
diff -Nru a/net/irda/Kconfig b/net/irda/Kconfig
--- a/net/irda/Kconfig	Wed Apr 30 22:28:09 2003
+++ b/net/irda/Kconfig	Wed Apr 30 22:28:09 2003
@@ -16,7 +16,7 @@
 	  some user-space utilities like irattach.  For more information, see
 	  the file <file:Documentation/networking/irda.txt>.  You also want to
 	  read the IR-HOWTO, available at
-	  <http://www.linuxdoc.org/docs.html#howto>.
+	  <http://www.tldp.org/docs.html#howto>.
 
 	  If you want to exchange bits of data (vCal, vCard) with a PDA, you
 	  will need to install some OBEX application, such as OpenObex :
diff -Nru a/net/irda/af_irda.c b/net/irda/af_irda.c
--- a/net/irda/af_irda.c	Wed Apr 30 22:28:07 2003
+++ b/net/irda/af_irda.c	Wed Apr 30 22:28:07 2003
@@ -858,7 +858,7 @@
 	 */
 
 	/*
-	 * We can perform the accept only if there is incomming data
+	 * We can perform the accept only if there is incoming data
 	 * on the listening socket.
 	 * So, we will block the caller until we receive any data.
 	 * If the caller was waiting on select() or poll() before
@@ -1132,9 +1132,6 @@
 	self->nslots = DISCOVERY_DEFAULT_SLOTS;
 	self->daddr = DEV_ADDR_ANY;	/* Until we get connected */
 	self->saddr = 0x0;		/* so IrLMP assign us any link */
-
-	MOD_INC_USE_COUNT;
-
 	return 0;
 }
 
@@ -1177,9 +1174,6 @@
 	}
 #endif /* CONFIG_IRDA_ULTRA */
 	kfree(self);
-	MOD_DEC_USE_COUNT;
-
-	return;
 }
 
 /*
@@ -1216,7 +1210,7 @@
 	/* Notes on socket locking and deallocation... - Jean II
 	 * In theory we should put pairs of sock_hold() / sock_put() to
 	 * prevent the socket to be destroyed whenever there is an
-	 * outstanding request or outstanding incomming packet or event.
+	 * outstanding request or outstanding incoming packet or event.
 	 *
 	 * 1) This may include IAS request, both in connect and getsockopt.
 	 * Unfortunately, the situation is a bit more messy than it looks,
@@ -2409,6 +2403,7 @@
 static struct net_proto_family irda_family_ops = {
 	.family = PF_IRDA,
 	.create = irda_create,
+	.owner	= THIS_MODULE,
 };
 
 static struct proto_ops SOCKOPS_WRAPPED(irda_stream_ops) = {
diff -Nru a/net/irda/ircomm/ircomm_param.c b/net/irda/ircomm/ircomm_param.c
--- a/net/irda/ircomm/ircomm_param.c	Wed Apr 30 22:28:09 2003
+++ b/net/irda/ircomm/ircomm_param.c	Wed Apr 30 22:28:09 2003
@@ -176,7 +176,7 @@
  * Function ircomm_param_service_type (self, buf, len)
  *
  *    Handle service type, this function will both be called after the LM-IAS
- *    query and then the remote device sends its initial paramters
+ *    query and then the remote device sends its initial parameters
  *
  */
 static int ircomm_param_service_type(void *instance, irda_param_t *param, 
diff -Nru a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
--- a/net/irda/ircomm/ircomm_tty.c	Wed Apr 30 22:28:07 2003
+++ b/net/irda/ircomm/ircomm_tty.c	Wed Apr 30 22:28:07 2003
@@ -99,11 +99,7 @@
 	memset(&driver, 0, sizeof(struct tty_driver));
 	driver.magic           = TTY_DRIVER_MAGIC;
 	driver.driver_name     = "ircomm";
-#ifdef CONFIG_DEVFS_FS
-	driver.name            = "ircomm%d";
-#else
 	driver.name            = "ircomm";
-#endif
 	driver.major           = IRCOMM_TTY_MAJOR;
 	driver.minor_start     = IRCOMM_TTY_MINOR;
 	driver.num             = IRCOMM_TTY_PORTS;
@@ -251,7 +247,7 @@
 
 	tty = self->tty;
 
-	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+	if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
 		/* this is a callout device */
 		/* just verify that normal device is not in use */
 		if (self->flags & ASYNC_NORMAL_ACTIVE)
@@ -306,7 +302,7 @@
 	add_wait_queue(&self->open_wait, &wait);
 	
 	IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
-	      __FILE__,__LINE__, tty->driver.name, self->open_count );
+	      __FILE__,__LINE__, tty->driver->name, self->open_count );
 
 	/* As far as I can see, we protect open_count - Jean II */
 	spin_lock_irqsave(&self->spinlock, flags);
@@ -356,7 +352,7 @@
 		}
 		
 		IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
-		      __FILE__,__LINE__, tty->driver.name, self->open_count );
+		      __FILE__,__LINE__, tty->driver->name, self->open_count );
 		
 		schedule();
 	}
@@ -373,7 +369,7 @@
 	self->blocked_open--;
 	
 	IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
-	      __FILE__,__LINE__, tty->driver.name, self->open_count);
+	      __FILE__,__LINE__, tty->driver->name, self->open_count);
 			 
 	if (!retval)
 		self->flags |= ASYNC_NORMAL_ACTIVE;
@@ -398,7 +394,7 @@
 	IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
 	MOD_INC_USE_COUNT;
-	line = minor(tty->device) - tty->driver.minor_start;
+	line = tty->index;
 	if ((line < 0) || (line >= IRCOMM_TTY_PORTS)) {
 		MOD_DEC_USE_COUNT;
 		return -ENODEV;
@@ -451,7 +447,7 @@
 	self->tty = tty;
 	spin_unlock_irqrestore(&self->spinlock, flags);
 
-	IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __FUNCTION__ , tty->driver.name, 
+	IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __FUNCTION__ , tty->driver->name, 
 		   self->line, self->open_count);
 
 	/* Not really used by us, but lets do it anyway */
@@ -592,8 +588,8 @@
 
 	ircomm_tty_shutdown(self);
 
-	if (tty->driver.flush_buffer)
-		tty->driver.flush_buffer(tty);
+	if (tty->driver->flush_buffer)
+		tty->driver->flush_buffer(tty);
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
 
diff -Nru a/net/irda/ircomm/ircomm_tty_attach.c b/net/irda/ircomm/ircomm_tty_attach.c
--- a/net/irda/ircomm/ircomm_tty_attach.c	Wed Apr 30 22:28:16 2003
+++ b/net/irda/ircomm/ircomm_tty_attach.c	Wed Apr 30 22:28:16 2003
@@ -518,12 +518,12 @@
 	del_timer(&self->watchdog_timer);
 
 	/* Remove LM-IAS object now so it is not reused.
-	 * IrCOMM deals very poorly with multiple incomming connections.
+	 * IrCOMM deals very poorly with multiple incoming connections.
 	 * It should looks a lot more like IrNET, and "dup" a server TSAP
 	 * to the application TSAP (based on various rules).
 	 * This is a cheap workaround allowing multiple clients to
 	 * connect to us. It will not always work.
-	 * Each IrCOMM socket has an IAS entry. Incomming connection will
+	 * Each IrCOMM socket has an IAS entry. Incoming connection will
 	 * pick the first one found. So, when we are fully connected,
 	 * we remove our IAS entries so that the next IAS entry is used.
 	 * We do that for *both* client and server, because a server
diff -Nru a/net/irda/irda_device.c b/net/irda/irda_device.c
--- a/net/irda/irda_device.c	Wed Apr 30 22:28:09 2003
+++ b/net/irda/irda_device.c	Wed Apr 30 22:28:09 2003
@@ -120,7 +120,7 @@
 /*
  * Function irda_device_set_media_busy (self, status)
  *
- *    Called when we have detected that another station is transmiting
+ *    Called when we have detected that another station is transmitting
  *    in contention mode.
  */
 void irda_device_set_media_busy(struct net_device *dev, int status)
@@ -480,7 +480,7 @@
  */
 int irda_device_register_dongle(struct dongle_reg *new)
 {
-	/* Check if this dongle has been registred before */
+	/* Check if this dongle has been registered before */
 	if (hashbin_lock_find(dongles, new->type, NULL)) {
 		MESSAGE("%s: Dongle already registered\n", __FUNCTION__);
                 return 0;
@@ -495,7 +495,7 @@
 /*
  * Function irda_device_unregister_dongle (dongle)
  *
- *    Unregister dongle, and remove dongle from list of registred dongles
+ *    Unregister dongle, and remove dongle from list of registered dongles
  *
  */
 void irda_device_unregister_dongle(struct dongle_reg *dongle)
diff -Nru a/net/irda/iriap.c b/net/irda/iriap.c
--- a/net/irda/iriap.c	Wed Apr 30 22:28:06 2003
+++ b/net/irda/iriap.c	Wed Apr 30 22:28:06 2003
@@ -273,7 +273,7 @@
 /*
  * Function iriap_disconnect_indication (handle, reason)
  *
- *    Got disconnect, so clean up everything assosiated with this connection
+ *    Got disconnect, so clean up everything associated with this connection
  *
  */
 static void iriap_disconnect_indication(void *instance, void *sap,
diff -Nru a/net/irda/irias_object.c b/net/irda/irias_object.c
--- a/net/irda/irias_object.c	Wed Apr 30 22:28:11 2003
+++ b/net/irda/irias_object.c	Wed Apr 30 22:28:11 2003
@@ -140,7 +140,7 @@
 /*
  * Function irias_delete_object (obj)
  *
- *    Remove object from hashbin and deallocate all attributes assosiated with
+ *    Remove object from hashbin and deallocate all attributes associated with
  *    with this object and the object itself
  *
  */
diff -Nru a/net/irda/irlan/irlan_common.c b/net/irda/irlan/irlan_common.c
--- a/net/irda/irlan/irlan_common.c	Wed Apr 30 22:28:10 2003
+++ b/net/irda/irlan/irlan_common.c	Wed Apr 30 22:28:10 2003
@@ -524,7 +524,7 @@
 	ASSERT(self->magic == IRLAN_MAGIC, return;);
 	
 	/* 
-	 * Check if object has already been registred by a previous provider.
+	 * Check if object has already been registered by a previous provider.
 	 * If that is the case, we just change the value of the attribute
 	 */
 	if (!irias_find_object("IrLAN")) {
@@ -538,7 +538,7 @@
 					      new_value);
 	}
 	
-        /* Register PnP object only if not registred before */
+        /* Register PnP object only if not registered before */
         if (!irias_find_object("PnP")) {
 		obj = irias_new_object("PnP", IAS_PNP_ID);
 #if 0
@@ -835,7 +835,7 @@
 /*
  * Function irlan_get_unicast_addr (self)
  *
- *    Retrives the unicast address from the IrLAN provider. This address
+ *    Retrieves the unicast address from the IrLAN provider. This address
  *    will be inserted into the devices structure, so the ethernet layer
  *    can construct its packets.
  *
diff -Nru a/net/irda/irlap.c b/net/irda/irlap.c
--- a/net/irda/irlap.c	Wed Apr 30 22:28:17 2003
+++ b/net/irda/irlap.c	Wed Apr 30 22:28:17 2003
@@ -997,12 +997,12 @@
 	ASSERT(self != NULL, return;);
 	ASSERT(self->magic == LAP_MAGIC, return;);
 
-	/* Set the negociated xbofs value */
+	/* Set the negotiated xbofs value */
 	self->next_bofs   = self->qos_tx.additional_bofs.value;
 	if (now)
 		self->bofs_count = self->next_bofs;
 
-	/* Set the negociated link speed (may need the new xbofs value) */
+	/* Set the negotiated link speed (may need the new xbofs value) */
 	irlap_change_speed(self, self->qos_tx.baud_rate.value, now);
 
 	self->window_size = self->qos_tx.window_size.value;
diff -Nru a/net/irda/irlap_event.c b/net/irda/irlap_event.c
--- a/net/irda/irlap_event.c	Wed Apr 30 22:28:11 2003
+++ b/net/irda/irlap_event.c	Wed Apr 30 22:28:11 2003
@@ -771,7 +771,7 @@
 		/* This is full of good intentions, but doesn't work in
 		 * practice.
 		 * After sending the first UA response, we switch the
-		 * dongle to the negociated speed, which is usually
+		 * dongle to the negotiated speed, which is usually
 		 * different than 9600 kb/s.
 		 * From there, there is two solutions :
 		 * 1) The other end has received the first UA response :
@@ -779,7 +779,7 @@
 		 * and will ignore and drop the second UA response.
 		 * Actually, it's even worse : the other side will almost
 		 * immediately send a RR that will likely collide with the
-		 * UA response (depending on negociated turnaround).
+		 * UA response (depending on negotiated turnaround).
 		 * 2) The other end has not received the first UA response,
 		 * will stay at 9600 and will never see the second UA response.
 		 * Jean II */
diff -Nru a/net/irda/irlmp.c b/net/irda/irlmp.c
--- a/net/irda/irlmp.c	Wed Apr 30 22:28:17 2003
+++ b/net/irda/irlmp.c	Wed Apr 30 22:28:17 2003
@@ -975,7 +975,7 @@
 /*
  * Function irlmp_discovery_expiry (expiry)
  *
- *	This device is no longer been discovered, and therefore it is beeing
+ *	This device is no longer been discovered, and therefore it is being
  *	purged from the discovery log. Inform all clients who have
  *	registered for this event...
  *
@@ -1279,7 +1279,7 @@
  * Function irlmp_hint_to_service (hint)
  *
  *    Returns a list of all servics contained in the given hint bits. This
- *    funtion assumes that the hint bits have the size of two bytes only
+ *    function assumes that the hint bits have the size of two bytes only
  */
 __u8 *irlmp_hint_to_service(__u8 *hint)
 {
@@ -1576,7 +1576,7 @@
 
 	/*
 	 *  Check if slsap is already in use. To do this we have to loop over
-	 *  every IrLAP connection and check every LSAP assosiated with each
+	 *  every IrLAP connection and check every LSAP associated with each
 	 *  the connection.
 	 */
 	spin_lock_irqsave(&irlmp->links->hb_spinlock, flags);
diff -Nru a/net/irda/irlmp_event.c b/net/irda/irlmp_event.c
--- a/net/irda/irlmp_event.c	Wed Apr 30 22:28:06 2003
+++ b/net/irda/irlmp_event.c	Wed Apr 30 22:28:06 2003
@@ -395,7 +395,7 @@
 		IRDA_DEBUG(4, "%s(), LS_CONNECT_REQUEST\n", __FUNCTION__);
 
 		/*
-		 *  LAP connection allready active, just bounce back! Since we
+		 *  LAP connection already active, just bounce back! Since we
 		 *  don't know which LSAP that tried to do this, we have to
 		 *  notify all LSAPs using this LAP, but that should be safe to
 		 *  do anyway.
diff -Nru a/net/irda/irlmp_frame.c b/net/irda/irlmp_frame.c
--- a/net/irda/irlmp_frame.c	Wed Apr 30 22:28:11 2003
+++ b/net/irda/irlmp_frame.c	Wed Apr 30 22:28:11 2003
@@ -418,7 +418,7 @@
 static inline void irlmp_update_cache(struct lap_cb *lap,
 				      struct lsap_cb *lsap)
 {
-	/* Prevent concurent read to get garbage */
+	/* Prevent concurrent read to get garbage */
 	lap->cache.valid = FALSE;
 	/* Update cache entry */
 	lap->cache.dlsap_sel = lsap->dlsap_sel;
@@ -431,7 +431,7 @@
 /*
  * Function irlmp_find_handle (self, dlsap_sel, slsap_sel, status, queue)
  *
- *    Find handle assosiated with destination and source LSAP
+ *    Find handle associated with destination and source LSAP
  *
  * Any IrDA connection (LSAP/TSAP) is uniquely identified by
  * 3 parameters, the local lsap, the remote lsap and the remote address. 
@@ -479,7 +479,7 @@
 		if ((status == CONNECT_CMD) && 
 		    (lsap->slsap_sel == slsap_sel) &&      
 		    (lsap->dlsap_sel == LSAP_ANY)) {
-			/* This is where the dest lsap sel is set on incomming
+			/* This is where the dest lsap sel is set on incoming
 			 * lsaps */
 			lsap->dlsap_sel = dlsap_sel;
 			break;
diff -Nru a/net/irda/irnet/irnet.h b/net/irda/irnet/irnet.h
--- a/net/irda/irnet/irnet.h	Wed Apr 30 22:28:12 2003
+++ b/net/irda/irnet/irnet.h	Wed Apr 30 22:28:12 2003
@@ -115,9 +115,9 @@
  * socket is then connected in the originating node to the pppd instance.
  * At this point, in the originating node, the first socket is closed.
  *
- * I admit, this is a bit messy and waste some ressources. The alternative
+ * I admit, this is a bit messy and waste some resources. The alternative
  * is caching incoming socket, and that's also quite messy and waste
- * ressources.
+ * resources.
  * We also make connection time slower. For example, on a 115 kb/s link it
  * adds 60ms to the connection time (770 ms). However, this is slower than
  * the time it takes to fire up pppd on my P133...
diff -Nru a/net/irda/irnet/irnet_irda.c b/net/irda/irnet/irnet_irda.c
--- a/net/irda/irnet/irnet_irda.c	Wed Apr 30 22:28:03 2003
+++ b/net/irda/irnet/irnet_irda.c	Wed Apr 30 22:28:03 2003
@@ -13,7 +13,7 @@
 /************************* CONTROL CHANNEL *************************/
 /*
  * When ppp is not active, /dev/irnet act as a control channel.
- * Writting allow to set up the IrDA destination of the IrNET channel,
+ * Writing allow to set up the IrDA destination of the IrNET channel,
  * and any application may be read events happening on IrNET...
  */
 
@@ -859,7 +859,7 @@
   /* As currently we don't block packets in ppp_irnet_send() while passive,
    * this is not really needed...
    * Also, not doing it give IrDA a chance to finish the setup properly
-   * before beeing swamped with packets... */
+   * before being swamped with packets... */
   ppp_output_wakeup(&new->chan);
 #endif /* CONNECT_INDIC_KICK */
 
diff -Nru a/net/irda/irnet/irnet_ppp.c b/net/irda/irnet/irnet_ppp.c
--- a/net/irda/irnet/irnet_ppp.c	Wed Apr 30 22:28:13 2003
+++ b/net/irda/irnet/irnet_ppp.c	Wed Apr 30 22:28:13 2003
@@ -20,7 +20,7 @@
 /*
  * When a pppd instance is not active on /dev/irnet, it acts as a control
  * channel.
- * Writting allow to set up the IrDA destination of the IrNET channel,
+ * Writing allow to set up the IrDA destination of the IrNET channel,
  * and any application may be read events happening in IrNET...
  */
 
@@ -39,7 +39,7 @@
 		 size_t		count)
 {
   char		command[IRNET_MAX_COMMAND];
-  char *	start;		/* Current command beeing processed */
+  char *	start;		/* Current command being processed */
   char *	next;		/* Next command to process */
   int		length;		/* Length of current command */
 
diff -Nru a/net/irda/irqueue.c b/net/irda/irqueue.c
--- a/net/irda/irqueue.c	Wed Apr 30 22:28:05 2003
+++ b/net/irda/irqueue.c	Wed Apr 30 22:28:05 2003
@@ -50,13 +50,13 @@
  */
 
 /*
- * Notes on the concurent access to hashbin and other SMP issues
+ * Notes on the concurrent access to hashbin and other SMP issues
  * -------------------------------------------------------------
  *	Hashbins are very often in the IrDA stack a global repository of
  * information, and therefore used in a very asynchronous manner following
  * various events (driver calls, timers, user calls...).
  *	Therefore, very often it is highly important to consider the
- * management of concurent access to the hashbin and how to guarantee the
+ * management of concurrent access to the hashbin and how to guarantee the
  * consistency of the operations on it.
  *
  *	First, we need to define the objective of locking :
@@ -158,12 +158,12 @@
  * Locking Policy :
  * --------------
  *	If the hashbin is used only in a single thread of execution
- * (explicitely or implicitely), you can use HB_NOLOCK
- *	If the calling module already provide concurent access protection,
+ * (explicitly or implicitely), you can use HB_NOLOCK
+ *	If the calling module already provide concurrent access protection,
  * you may use HB_NOLOCK.
  *
  *	In all other cases, you need to use HB_LOCK and lock the hashbin
- * everytime before calling one of the unprotected calls. You also must
+ * every time before calling one of the unprotected calls. You also must
  * use the pointer returned by the unprotected call within the locked
  * region.
  *
@@ -912,7 +912,7 @@
  *
  *    Find an item with the given hashv or name, and its successor
  *
- * This function allow to do concurent enumerations without the
+ * This function allow to do concurrent enumerations without the
  * need to lock over the whole session, because the caller keep the
  * context of the search. On the other hand, it might fail and return
  * NULL if the entry is removed. - Jean II
@@ -987,7 +987,7 @@
  *    NULL when all items have been traversed
  * 
  * The context of the search is stored within the hashbin, so you must
- * protect yourself from concurent enumerations. - Jean II
+ * protect yourself from concurrent enumerations. - Jean II
  */
 irda_queue_t *hashbin_get_next( hashbin_t *hashbin)
 {
diff -Nru a/net/irda/irttp.c b/net/irda/irttp.c
--- a/net/irda/irttp.c	Wed Apr 30 22:28:11 2003
+++ b/net/irda/irttp.c	Wed Apr 30 22:28:11 2003
@@ -478,7 +478,7 @@
  *    Remove TSAP from list of all TSAPs and then deallocate all resources
  *    associated with this TSAP
  *
- * Note : because we *free* the tsap structure, it is the responsability
+ * Note : because we *free* the tsap structure, it is the responsibility
  * of the caller to make sure we are called only once and to deal with
  * possible race conditions. - Jean II
  */
@@ -999,7 +999,7 @@
 /*
  * Function irttp_flow_request (self, command)
  *
- *    This funtion could be used by the upper layers to tell IrTTP to stop
+ *    This function could be used by the upper layers to tell IrTTP to stop
  *    delivering frames if the receive queues are starting to get full, or
  *    to tell IrTTP to start delivering frames again.
  */
diff -Nru a/net/irda/qos.c b/net/irda/qos.c
--- a/net/irda/qos.c	Wed Apr 30 22:28:16 2003
+++ b/net/irda/qos.c	Wed Apr 30 22:28:16 2003
@@ -72,7 +72,7 @@
  * payload), that's only 2042 bytes. Oups !
  * My nsc-ircc hardware has troubles receiving 2048 bytes frames at 4 Mb/s,
  * so adjust to 2042... I don't know if this bug applies only for 2048
- * bytes frames or all negociated frame sizes, but you can use the sysctl
+ * bytes frames or all negotiated frame sizes, but you can use the sysctl
  * to play with this value anyway.
  * Jean II */
 unsigned sysctl_max_tx_data_size = 2042;
@@ -280,7 +280,7 @@
 /*
  * Function irda_qos_compute_intersection (qos, new)
  *
- *    Compute the intersection of the old QoS capabilites with new ones
+ *    Compute the intersection of the old QoS capabilities with new ones
  *
  */
 void irda_qos_compute_intersection(struct qos_info *qos, struct qos_info *new)
diff -Nru a/net/irda/wrapper.c b/net/irda/wrapper.c
--- a/net/irda/wrapper.c	Wed Apr 30 22:28:14 2003
+++ b/net/irda/wrapper.c	Wed Apr 30 22:28:14 2003
@@ -267,7 +267,7 @@
 /*
  * Function async_unwrap_bof(dev, byte)
  *
- *    Handle Beggining Of Frame character received within a frame
+ *    Handle Beginning Of Frame character received within a frame
  *
  */
 static inline void
@@ -386,7 +386,7 @@
 	case BEGIN_FRAME:
 	case INSIDE_FRAME:
 	default:
-		/* Stuffed byte comming */
+		/* Stuffed byte coming */
 		rx_buff->state = LINK_ESCAPE;
 		break;
 	}
diff -Nru a/net/key/af_key.c b/net/key/af_key.c
--- a/net/key/af_key.c	Wed Apr 30 22:28:06 2003
+++ b/net/key/af_key.c	Wed Apr 30 22:28:06 2003
@@ -63,8 +63,6 @@
 	kfree(pfkey_sk(sk));
 
 	atomic_dec(&pfkey_socks_nr);
-
-	MOD_DEC_USE_COUNT;
 }
 
 static void pfkey_table_grab(void)
@@ -150,8 +148,6 @@
 	if (protocol != PF_KEY_V2)
 		return -EPROTONOSUPPORT;
 
-	MOD_INC_USE_COUNT;
-
 	err = -ENOMEM;
 	sk = sk_alloc(PF_KEY, GFP_KERNEL, 1, NULL);
 	if (sk == NULL)
@@ -176,9 +172,7 @@
 	pfkey_insert(sk);
 
 	return 0;
-
 out:
-	MOD_DEC_USE_COUNT;
 	return err;
 }
 
@@ -2792,6 +2786,7 @@
 static struct net_proto_family pfkey_family_ops = {
 	.family	=	PF_KEY,
 	.create	=	pfkey_create,
+	.owner	=	THIS_MODULE,
 };
 
 #ifdef CONFIG_PROC_FS
diff -Nru a/net/llc/af_llc.c b/net/llc/af_llc.c
--- a/net/llc/af_llc.c	Wed Apr 30 22:28:03 2003
+++ b/net/llc/af_llc.c	Wed Apr 30 22:28:03 2003
@@ -11,7 +11,7 @@
  *   connections.
  *
  * Copyright (c) 2001 by Jay Schulist <jschlst@samba.org>
- *		 2002 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ *		 2002-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  * This program can be redistributed or modified under the terms of the
  * GNU General Public License as published by the Free Software Foundation.
@@ -22,6 +22,7 @@
  */
 #include <linux/config.h>
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/tcp.h>
 #include <net/llc_sap.h>
 #include <net/llc_pdu.h>
@@ -192,9 +193,9 @@
 }
 
 /**
- *	llc_ui_autoport - provide dynamicly allocate SAP number
+ *	llc_ui_autoport - provide dynamically allocate SAP number
  *
- *	Provide the caller with a dynamicly allocated SAP number according
+ *	Provide the caller with a dynamically allocated SAP number according
  *	to the rules that are set in this function. Returns: 0, upon failure,
  *	SAP number otherwise.
  */
@@ -622,7 +623,8 @@
 	struct sk_buff *skb;
 	int rc = -EOPNOTSUPP;
 
-	dprintk("%s: accepting on %02X\n", __FUNCTION__, llc_sk(sk)->addr.sllc_ssap);
+	dprintk("%s: accepting on %02X\n", __FUNCTION__,
+	        llc_sk(sk)->addr.sllc_ssap);
 	lock_sock(sk);
 	if (sk->type != SOCK_STREAM)
 		goto out;
@@ -633,7 +635,8 @@
 	rc = llc_ui_wait_for_data(sk, sk->rcvtimeo);
 	if (rc)
 		goto out;
-	dprintk("%s: got a new connection on %02X\n", __FUNCTION__, llc_sk(sk)->addr.sllc_ssap);
+	dprintk("%s: got a new connection on %02X\n", __FUNCTION__,
+	        llc_sk(sk)->addr.sllc_ssap);
 	skb = skb_dequeue(&sk->receive_queue);
 	rc = -EINVAL;
 	if (!skb->sk)
@@ -691,8 +694,9 @@
 	timeout = sock_rcvtimeo(sk, noblock);
 	rc = llc_ui_wait_for_data(sk, timeout);
 	if (rc) {
-		dprintk("%s: llc_ui_wait_for_data failed recv in %02X from %02X\n",
-			__FUNCTION__, llc_sk(sk)->laddr.lsap, llc_sk(sk)->daddr.lsap);
+		dprintk("%s: llc_ui_wait_for_data failed recv "
+			"in %02X from %02X\n", __FUNCTION__,
+			llc_sk(sk)->laddr.lsap, llc_sk(sk)->daddr.lsap);
 		goto out;
 	}
 	skb = skb_dequeue(&sk->receive_queue);
@@ -741,7 +745,8 @@
 	struct sk_buff *skb;
 	int rc = -EINVAL, size = 0, copied = 0, hdrlen;
 
-	dprintk("%s: sending from %02X to %02X\n", __FUNCTION__, llc->laddr.lsap, llc->daddr.lsap);
+	dprintk("%s: sending from %02X to %02X\n", __FUNCTION__,
+		llc->laddr.lsap, llc->daddr.lsap);
 	lock_sock(sk);
 	if (addr) {
 		if (msg->msg_namelen < sizeof(*addr))
@@ -905,49 +910,49 @@
 		goto out;
 	rc = -EINVAL;
 	switch (optname) {
-		case LLC_OPT_RETRY:
-			if (opt > LLC_OPT_MAX_RETRY)
-				goto out;
-			llc->n2 = opt;
-			break;
-		case LLC_OPT_SIZE:
-			if (opt > LLC_OPT_MAX_SIZE)
-				goto out;
-			llc->n1 = opt;
-			break;
-		case LLC_OPT_ACK_TMR_EXP:
-			if (opt > LLC_OPT_MAX_ACK_TMR_EXP)
-				goto out;
-			llc->ack_timer.expire = opt;
-			break;
-		case LLC_OPT_P_TMR_EXP:
-			if (opt > LLC_OPT_MAX_P_TMR_EXP)
-				goto out;
-			llc->pf_cycle_timer.expire = opt;
-			break;
-		case LLC_OPT_REJ_TMR_EXP:
-			if (opt > LLC_OPT_MAX_REJ_TMR_EXP)
-				goto out;
-			llc->rej_sent_timer.expire = opt;
-			break;
-		case LLC_OPT_BUSY_TMR_EXP:
-			if (opt > LLC_OPT_MAX_BUSY_TMR_EXP)
-				goto out;
-			llc->busy_state_timer.expire = opt;
-			break;
-		case LLC_OPT_TX_WIN:
-			if (opt > LLC_OPT_MAX_WIN)
-				goto out;
-			llc->k = opt;
-			break;
-		case LLC_OPT_RX_WIN:
-			if (opt > LLC_OPT_MAX_WIN)
-				goto out;
-			llc->rw = opt;
-			break;
-		default:
-			rc = -ENOPROTOOPT;
+	case LLC_OPT_RETRY:
+		if (opt > LLC_OPT_MAX_RETRY)
+			goto out;
+		llc->n2 = opt;
+		break;
+	case LLC_OPT_SIZE:
+		if (opt > LLC_OPT_MAX_SIZE)
+			goto out;
+		llc->n1 = opt;
+		break;
+	case LLC_OPT_ACK_TMR_EXP:
+		if (opt > LLC_OPT_MAX_ACK_TMR_EXP)
+			goto out;
+		llc->ack_timer.expire = opt;
+		break;
+	case LLC_OPT_P_TMR_EXP:
+		if (opt > LLC_OPT_MAX_P_TMR_EXP)
+			goto out;
+		llc->pf_cycle_timer.expire = opt;
+		break;
+	case LLC_OPT_REJ_TMR_EXP:
+		if (opt > LLC_OPT_MAX_REJ_TMR_EXP)
 			goto out;
+		llc->rej_sent_timer.expire = opt;
+		break;
+	case LLC_OPT_BUSY_TMR_EXP:
+		if (opt > LLC_OPT_MAX_BUSY_TMR_EXP)
+			goto out;
+		llc->busy_state_timer.expire = opt;
+		break;
+	case LLC_OPT_TX_WIN:
+		if (opt > LLC_OPT_MAX_WIN)
+			goto out;
+		llc->k = opt;
+		break;
+	case LLC_OPT_RX_WIN:
+		if (opt > LLC_OPT_MAX_WIN)
+			goto out;
+		llc->rw = opt;
+		break;
+	default:
+		rc = -ENOPROTOOPT;
+		goto out;
 	}
 	rc = 0;
 out:
@@ -982,25 +987,25 @@
 	if (len != sizeof(int))
 		goto out;
 	switch (optname) {
-		case LLC_OPT_RETRY:
-			val = llc->n2;				break;
-		case LLC_OPT_SIZE:
-			val = llc->n1;				break;
-		case LLC_OPT_ACK_TMR_EXP:
-			val = llc->ack_timer.expire;		break;
-		case LLC_OPT_P_TMR_EXP:
-			val = llc->pf_cycle_timer.expire;	break;
-		case LLC_OPT_REJ_TMR_EXP:
-			val = llc->rej_sent_timer.expire;	break;
-		case LLC_OPT_BUSY_TMR_EXP:
-			val = llc->busy_state_timer.expire;	break;
-		case LLC_OPT_TX_WIN:
-			val = llc->k;				break;
-		case LLC_OPT_RX_WIN:
-			val = llc->rw;				break;
-		default:
-			rc = -ENOPROTOOPT;
-			goto out;
+	case LLC_OPT_RETRY:
+		val = llc->n2;				break;
+	case LLC_OPT_SIZE:
+		val = llc->n1;				break;
+	case LLC_OPT_ACK_TMR_EXP:
+		val = llc->ack_timer.expire;		break;
+	case LLC_OPT_P_TMR_EXP:
+		val = llc->pf_cycle_timer.expire;	break;
+	case LLC_OPT_REJ_TMR_EXP:
+		val = llc->rej_sent_timer.expire;	break;
+	case LLC_OPT_BUSY_TMR_EXP:
+		val = llc->busy_state_timer.expire;	break;
+	case LLC_OPT_TX_WIN:
+		val = llc->k;				break;
+	case LLC_OPT_RX_WIN:
+		val = llc->rw;				break;
+	default:
+		rc = -ENOPROTOOPT;
+		goto out;
 	}
 	rc = 0;
 	if (put_user(len, optlen) || copy_to_user(optval, &val, len))
@@ -1013,6 +1018,7 @@
 static struct net_proto_family llc_ui_family_ops = {
 	.family = PF_LLC,
 	.create = llc_ui_create,
+	.owner	= THIS_MODULE,
 };
 
 static struct proto_ops llc_ui_ops = {
@@ -1036,7 +1042,8 @@
 };
 
 static char llc_ui_banner[] __initdata =
-	KERN_INFO "NET4.0 IEEE 802.2 BSD sockets, Jay Schulist, 2001, Arnaldo C. Melo, 2002\n";
+	KERN_INFO "NET4.0 IEEE 802.2 BSD sockets, Jay Schulist, 2001, "
+		  "Arnaldo C. Melo, 2002-2003\n";
 
 int __init llc_ui_init(void)
 {
diff -Nru a/net/llc/llc_actn.c b/net/llc/llc_actn.c
--- a/net/llc/llc_actn.c	Wed Apr 30 22:28:06 2003
+++ b/net/llc/llc_actn.c	Wed Apr 30 22:28:06 2003
@@ -8,7 +8,7 @@
  *   them return 0 On success and 1 otherwise.
  *
  * Copyright (c) 1997 by Procom Technology, Inc.
- * 		 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ * 		 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  * This program can be redistributed or modified under the terms of the
  * GNU General Public License as published by the Free Software Foundation.
diff -Nru a/net/llc/llc_c_ac.c b/net/llc/llc_c_ac.c
--- a/net/llc/llc_c_ac.c	Wed Apr 30 22:28:18 2003
+++ b/net/llc/llc_c_ac.c	Wed Apr 30 22:28:18 2003
@@ -8,7 +8,7 @@
  *   them return 0 On success and 1 otherwise.
  *
  * Copyright (c) 1997 by Procom Technology, Inc.
- * 		 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ * 		 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  * This program can be redistributed or modified under the terms of the
  * GNU General Public License as published by the Free Software Foundation.
@@ -145,33 +145,32 @@
 	struct llc_opt *llc = llc_sk(sk);
 
 	switch (ev->type) {
-		case LLC_CONN_EV_TYPE_PDU:
-			if (!LLC_PDU_IS_RSP(pdu) &&
-			    !LLC_PDU_TYPE_IS_U(pdu) &&
-			    LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_FRMR) {
-				reason = LLC_RESET_REASON_LOCAL;
-				rc = 0;
-			} else if (!LLC_PDU_IS_CMD(pdu) &&
-				   !LLC_PDU_TYPE_IS_U(pdu) &&
-				   LLC_U_PDU_CMD(pdu) ==
-				   			LLC_2_PDU_CMD_SABME) {
-				reason = LLC_RESET_REASON_REMOTE;
-				rc = 0;
-			} else {
-				reason = 0;
-				rc  = 1;
-			}
-			break;
-		case LLC_CONN_EV_TYPE_ACK_TMR:
-		case LLC_CONN_EV_TYPE_P_TMR:
-		case LLC_CONN_EV_TYPE_REJ_TMR:
-		case LLC_CONN_EV_TYPE_BUSY_TMR:
-			if (llc->retry_count > llc->n2) {
-				reason = LLC_RESET_REASON_LOCAL;
-				rc = 0;
-			} else
-				rc = 1;
-			break;
+	case LLC_CONN_EV_TYPE_PDU:
+		if (!LLC_PDU_IS_RSP(pdu) &&
+		    !LLC_PDU_TYPE_IS_U(pdu) &&
+		    LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_FRMR) {
+			reason = LLC_RESET_REASON_LOCAL;
+			rc = 0;
+		} else if (!LLC_PDU_IS_CMD(pdu) &&
+			   !LLC_PDU_TYPE_IS_U(pdu) &&
+			   LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_SABME) {
+			reason = LLC_RESET_REASON_REMOTE;
+			rc = 0;
+		} else {
+			reason = 0;
+			rc  = 1;
+		}
+		break;
+	case LLC_CONN_EV_TYPE_ACK_TMR:
+	case LLC_CONN_EV_TYPE_P_TMR:
+	case LLC_CONN_EV_TYPE_REJ_TMR:
+	case LLC_CONN_EV_TYPE_BUSY_TMR:
+		if (llc->retry_count > llc->n2) {
+			reason = LLC_RESET_REASON_LOCAL;
+			rc = 0;
+		} else
+			rc = 1;
+		break;
 	}
 	if (!rc) {
 		ev->reason   = reason;
diff -Nru a/net/llc/llc_c_ev.c b/net/llc/llc_c_ev.c
--- a/net/llc/llc_c_ev.c	Wed Apr 30 22:28:04 2003
+++ b/net/llc/llc_c_ev.c	Wed Apr 30 22:28:04 2003
@@ -24,7 +24,7 @@
  * in their comments, at below.
  *
  * Copyright (c) 1997 by Procom Technology, Inc.
- * 		 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ * 		 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  * This program can be redistributed or modified under the terms of the
  * GNU General Public License as published by the Free Software Foundation.
@@ -485,11 +485,11 @@
 				rc = 0;
 		} else if (!LLC_PDU_TYPE_IS_U(pdu))
 			switch (LLC_U_PDU_CMD(pdu)) {
-				case LLC_2_PDU_CMD_SABME:
-				case LLC_2_PDU_CMD_DISC:
-					if (!LLC_U_PF_IS_0(pdu))
-						rc = 0;
-					break;
+			case LLC_2_PDU_CMD_SABME:
+			case LLC_2_PDU_CMD_DISC:
+				if (!LLC_U_PF_IS_0(pdu))
+					rc = 0;
+				break;
 			}
 	}
 	return rc;
@@ -505,10 +505,10 @@
 			rc = 0;
 		else if (!LLC_PDU_TYPE_IS_U(pdu))
 			switch (LLC_U_PDU_CMD(pdu)) {
-				case LLC_2_PDU_CMD_SABME:
-				case LLC_2_PDU_CMD_DISC:
-					rc = 0;
-					break;
+			case LLC_2_PDU_CMD_SABME:
+			case LLC_2_PDU_CMD_DISC:
+				rc = 0;
+				break;
 			}
 	}
 	return rc;
@@ -525,12 +525,12 @@
 				rc = 0;
 		} else if (!LLC_PDU_TYPE_IS_U(pdu))
 			switch (LLC_U_PDU_RSP(pdu)) {
-				case LLC_2_PDU_RSP_UA:
-				case LLC_2_PDU_RSP_DM:
-				case LLC_2_PDU_RSP_FRMR:
-					if (!LLC_U_PF_IS_1(pdu))
-						rc = 0;
-					break;
+			case LLC_2_PDU_RSP_UA:
+			case LLC_2_PDU_RSP_DM:
+			case LLC_2_PDU_RSP_FRMR:
+				if (!LLC_U_PF_IS_1(pdu))
+					rc = 0;
+				break;
 			}
 	}
 	return rc;
@@ -546,11 +546,11 @@
 			rc = 0;
 		else if (!LLC_PDU_TYPE_IS_U(pdu))
 			switch (LLC_U_PDU_RSP(pdu)) {
-				case LLC_2_PDU_RSP_UA:
-				case LLC_2_PDU_RSP_DM:
-				case LLC_2_PDU_RSP_FRMR:
-					rc = 0;
-					break;
+			case LLC_2_PDU_RSP_UA:
+			case LLC_2_PDU_RSP_DM:
+			case LLC_2_PDU_RSP_FRMR:
+				rc = 0;
+				break;
 			}
 	}
 
@@ -566,13 +566,13 @@
 		rc = 0;
 	else if (!LLC_PDU_TYPE_IS_U(pdu))
 		switch (LLC_U_PDU_CMD(pdu)) {
-			case LLC_2_PDU_CMD_SABME:
-			case LLC_2_PDU_CMD_DISC:
-			case LLC_2_PDU_RSP_UA:
-			case LLC_2_PDU_RSP_DM:
-			case LLC_2_PDU_RSP_FRMR:
-				rc = 0;
-				break;
+		case LLC_2_PDU_CMD_SABME:
+		case LLC_2_PDU_CMD_DISC:
+		case LLC_2_PDU_RSP_UA:
+		case LLC_2_PDU_RSP_DM:
+		case LLC_2_PDU_RSP_FRMR:
+			rc = 0;
+			break;
 		}
 	return rc;
 }
diff -Nru a/net/llc/llc_c_st.c b/net/llc/llc_c_st.c
--- a/net/llc/llc_c_st.c	Wed Apr 30 22:28:08 2003
+++ b/net/llc/llc_c_st.c	Wed Apr 30 22:28:08 2003
@@ -5,7 +5,7 @@
  * or in "llc_c_ac.c" and "llc_c_ev.c" modules.
  *
  * Copyright (c) 1997 by Procom Technology, Inc.
- * 		 2001, 2002 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ * 		 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  * This program can be redistributed or modified under the terms of the
  * GNU General Public License as published by the Free Software Foundation.
diff -Nru a/net/llc/llc_conn.c b/net/llc/llc_conn.c
--- a/net/llc/llc_conn.c	Wed Apr 30 22:28:04 2003
+++ b/net/llc/llc_conn.c	Wed Apr 30 22:28:04 2003
@@ -2,7 +2,7 @@
  * llc_conn.c - Driver routines for connection component.
  *
  * Copyright (c) 1997 by Procom Technology, Inc.
- *		 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ *		 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  * This program can be redistributed or modified under the terms of the
  * GNU General Public License as published by the Free Software Foundation.
@@ -84,7 +84,8 @@
 		goto out_kfree_skb;
 	}
 
-	if (!ev->ind_prim && !ev->cfm_prim) {   /* indicate or confirm not required */
+	if (!ev->ind_prim && !ev->cfm_prim) {
+		/* indicate or confirm not required */
 		if (!skb->list)
 			goto out_kfree_skb;
 		goto out_skb_put;
@@ -344,7 +345,7 @@
  *	llc_conn_send_pdus - Sends queued PDUs
  *	@sk: active connection
  *
- *	Sends queued pdus to MAC layer for transmition.
+ *	Sends queued pdus to MAC layer for transmission.
  */
 static void llc_conn_send_pdus(struct sock *sk)
 {
@@ -625,17 +626,17 @@
 	 * init_pf_cycle and I don't know what is it.
 	 */
 	switch (ev_type) {
-		case LLC_CONN_EV_TYPE_PRIM:
-			rc = llc_offset_table[state][0]; break;
-		case LLC_CONN_EV_TYPE_PDU:
-			rc = llc_offset_table[state][4]; break;
-		case LLC_CONN_EV_TYPE_SIMPLE:
-			rc = llc_offset_table[state][1]; break;
-		case LLC_CONN_EV_TYPE_P_TMR:
-		case LLC_CONN_EV_TYPE_ACK_TMR:
-		case LLC_CONN_EV_TYPE_REJ_TMR:
-		case LLC_CONN_EV_TYPE_BUSY_TMR:
-			rc = llc_offset_table[state][3]; break;
+	case LLC_CONN_EV_TYPE_PRIM:
+		rc = llc_offset_table[state][0]; break;
+	case LLC_CONN_EV_TYPE_PDU:
+		rc = llc_offset_table[state][4]; break;
+	case LLC_CONN_EV_TYPE_SIMPLE:
+		rc = llc_offset_table[state][1]; break;
+	case LLC_CONN_EV_TYPE_P_TMR:
+	case LLC_CONN_EV_TYPE_ACK_TMR:
+	case LLC_CONN_EV_TYPE_REJ_TMR:
+	case LLC_CONN_EV_TYPE_BUSY_TMR:
+		rc = llc_offset_table[state][3]; break;
 	}
 	return rc;
 }
diff -Nru a/net/llc/llc_evnt.c b/net/llc/llc_evnt.c
--- a/net/llc/llc_evnt.c	Wed Apr 30 22:28:05 2003
+++ b/net/llc/llc_evnt.c	Wed Apr 30 22:28:05 2003
@@ -7,7 +7,7 @@
  *   them return 0 On success and 1 otherwise.
  *
  * Copyright (c) 1997 by Procom Technology, Inc.
- * 		 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ * 		 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  * This program can be redistributed or modified under the terms of the
  * GNU General Public License as published by the Free Software Foundation.
diff -Nru a/net/llc/llc_if.c b/net/llc/llc_if.c
--- a/net/llc/llc_if.c	Wed Apr 30 22:28:09 2003
+++ b/net/llc/llc_if.c	Wed Apr 30 22:28:09 2003
@@ -2,7 +2,7 @@
  * llc_if.c - Defines LLC interface to upper layer
  *
  * Copyright (c) 1997 by Procom Technology, Inc.
- * 		 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ * 		 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  * This program can be redistributed or modified under the terms of the
  * GNU General Public License as published by the Free Software Foundation.
@@ -43,16 +43,15 @@
 	/* verify this SAP is not already open; if so, return error */
 	struct llc_sap *sap;
 
-	MOD_INC_USE_COUNT;
 	sap = llc_sap_find(lsap);
 	if (sap) { /* SAP already exists */
 		sap = NULL;
-		goto err;
+		goto out;
 	}
 	/* sap requested does not yet exist */
 	sap = llc_sap_alloc();
 	if (!sap)
-		goto err;
+		goto out;
 	/* allocated a SAP; initialize it and clear out its memory pool */
 	sap->laddr.lsap = lsap;
 	sap->rcv_func	= func;
@@ -61,9 +60,6 @@
 	llc_sap_save(sap);
 out:
 	return sap;
-err:
-	MOD_DEC_USE_COUNT;
-	goto out;
 }
 
 /**
@@ -76,7 +72,6 @@
 void llc_sap_close(struct llc_sap *sap)
 {
 	llc_free_sap(sap);
-	MOD_DEC_USE_COUNT;
 }
 
 /**
diff -Nru a/net/llc/llc_mac.c b/net/llc/llc_mac.c
--- a/net/llc/llc_mac.c	Wed Apr 30 22:28:15 2003
+++ b/net/llc/llc_mac.c	Wed Apr 30 22:28:15 2003
@@ -2,7 +2,7 @@
  * llc_mac.c - Manages interface between LLC and MAC
  *
  * Copyright (c) 1997 by Procom Technology, Inc.
- * 		 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ * 		 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  * This program can be redistributed or modified under the terms of the
  * GNU General Public License as published by the Free Software Foundation.
@@ -78,7 +78,8 @@
 	}
 	sap = llc_sap_find(pdu->dsap);
 	if (!sap) {/* unknown SAP */
-		dprintk("%s: llc_sap_find(%02X) failed!\n", __FUNCTION__, pdu->dsap);
+		dprintk("%s: llc_sap_find(%02X) failed!\n", __FUNCTION__,
+		        pdu->dsap);
 		goto drop;
 	}
 	llc_decode_pdu_type(skb, &dest);
@@ -255,41 +256,41 @@
 
 	switch (skb->dev->type) {
 #ifdef CONFIG_TR
-		case ARPHRD_IEEE802_TR: {
-			struct trh_hdr *trh;
-			struct net_device *dev = skb->dev;
-
-			trh = (struct trh_hdr *)skb_push(skb, sizeof(*trh));
-			trh->ac = AC;
-			trh->fc = LLC_FRAME;
-			if (sa)
-				memcpy(trh->saddr, sa, dev->addr_len);
-			else
-				memset(trh->saddr, 0, dev->addr_len);
-			if (da) {
-				memcpy(trh->daddr, da, dev->addr_len);
-				tr_source_route(skb, trh, dev);
-			}
-			skb->mac.raw = skb->data;
-			break;
+	case ARPHRD_IEEE802_TR: {
+		struct trh_hdr *trh;
+		struct net_device *dev = skb->dev;
+
+		trh = (struct trh_hdr *)skb_push(skb, sizeof(*trh));
+		trh->ac = AC;
+		trh->fc = LLC_FRAME;
+		if (sa)
+			memcpy(trh->saddr, sa, dev->addr_len);
+		else
+			memset(trh->saddr, 0, dev->addr_len);
+		if (da) {
+			memcpy(trh->daddr, da, dev->addr_len);
+			tr_source_route(skb, trh, dev);
 		}
+		skb->mac.raw = skb->data;
+		break;
+	}
 #endif
-		case ARPHRD_ETHER:
-		case ARPHRD_LOOPBACK: {
-			unsigned short len = skb->len;
-			struct ethhdr *eth;
-
-			skb->mac.raw = skb_push(skb, sizeof(*eth));
-			eth = (struct ethhdr *)skb->mac.raw;
-			eth->h_proto = htons(len);
-			memcpy(eth->h_dest, da, ETH_ALEN);
-			memcpy(eth->h_source, sa, ETH_ALEN);
-			break;
-		}
-		default:
-			printk(KERN_WARNING "Unknown DEVICE type : %d\n",
-			       skb->dev->type);
-			rc = 1;
+	case ARPHRD_ETHER:
+	case ARPHRD_LOOPBACK: {
+		unsigned short len = skb->len;
+		struct ethhdr *eth;
+
+		skb->mac.raw = skb_push(skb, sizeof(*eth));
+		eth = (struct ethhdr *)skb->mac.raw;
+		eth->h_proto = htons(len);
+		memcpy(eth->h_dest, da, ETH_ALEN);
+		memcpy(eth->h_source, sa, ETH_ALEN);
+		break;
+	}
+	default:
+		printk(KERN_WARNING "Unknown DEVICE type : %d\n",
+		       skb->dev->type);
+		rc = 1;
 	}
 	return rc;
 }
diff -Nru a/net/llc/llc_main.c b/net/llc/llc_main.c
--- a/net/llc/llc_main.c	Wed Apr 30 22:28:08 2003
+++ b/net/llc/llc_main.c	Wed Apr 30 22:28:08 2003
@@ -3,7 +3,7 @@
  * 	and connections of the LLC.
  *
  * Copyright (c) 1997 by Procom Technology, Inc.
- * 		 2001, 2002 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ * 		 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  * This program can be redistributed or modified under the terms of the
  * GNU General Public License as published by the Free Software Foundation.
@@ -162,7 +162,7 @@
 
 /**
  *     llc_sk_init - Initializes a socket with default llc values.
- *     @sk: socket to intiailize.
+ *     @sk: socket to initialize.
  *
  *     Initializes a socket with default llc values.
  */
@@ -224,9 +224,8 @@
 {
 	struct sock *sk = sk_alloc(family, priority, 1, NULL);
 
-	MOD_INC_USE_COUNT;
 	if (!sk)
-		goto decmod;
+		goto out;
 	if (llc_sk_init(sk))
 		goto outsk;
 	sock_init_data(NULL, sk);
@@ -240,8 +239,6 @@
 outsk:
 	sk_free(sk);
 	sk = NULL;
-decmod:
-	MOD_DEC_USE_COUNT;
 	goto out;
 }
 
@@ -279,7 +276,6 @@
 	}
 #endif
 	sock_put(sk);
-	MOD_DEC_USE_COUNT;
 }
 
 /**
@@ -604,5 +600,5 @@
 module_exit(llc_exit);
 
 MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Procom, 1997, Arnaldo C. Melo, Jay Schullist, 2001, 2002");
+MODULE_AUTHOR("Procom, 1997, Arnaldo C. Melo, Jay Schullist, 2001-2003");
 MODULE_DESCRIPTION("LLC 2.0, NET4.0 IEEE 802.2 extended support");
diff -Nru a/net/llc/llc_pdu.c b/net/llc/llc_pdu.c
--- a/net/llc/llc_pdu.c	Wed Apr 30 22:28:05 2003
+++ b/net/llc/llc_pdu.c	Wed Apr 30 22:28:05 2003
@@ -2,7 +2,7 @@
  * llc_pdu.c - access to PDU internals
  *
  * Copyright (c) 1997 by Procom Technology, Inc.
- *		 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ *		 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  * This program can be redistributed or modified under the terms of the
  * GNU General Public License as published by the Free Software Foundation.
@@ -63,13 +63,13 @@
 	pdu = llc_pdu_sn_hdr(skb);
 	
 	switch (pdu_type) {
-		case LLC_PDU_TYPE_I:
-		case LLC_PDU_TYPE_S:
-			pdu->ctrl_2 = (pdu->ctrl_2 & 0xFE) | bit_value;
-			break;
-		case LLC_PDU_TYPE_U:
-			pdu->ctrl_1 |= (pdu->ctrl_1 & 0xEF) | (bit_value << 4);
-			break;
+	case LLC_PDU_TYPE_I:
+	case LLC_PDU_TYPE_S:
+		pdu->ctrl_2 = (pdu->ctrl_2 & 0xFE) | bit_value;
+		break;
+	case LLC_PDU_TYPE_U:
+		pdu->ctrl_1 |= (pdu->ctrl_1 & 0xEF) | (bit_value << 4);
+		break;
 	}
 }
 
@@ -91,13 +91,13 @@
 	pdu = llc_pdu_sn_hdr(skb);
 
 	switch (pdu_type) {
-		case LLC_PDU_TYPE_I:
-		case LLC_PDU_TYPE_S:
-			*pf_bit = pdu->ctrl_2 & LLC_S_PF_BIT_MASK;
-			break;
-		case LLC_PDU_TYPE_U:
-			*pf_bit = (pdu->ctrl_1 & LLC_U_PF_BIT_MASK) >> 4;
-			break;
+	case LLC_PDU_TYPE_I:
+	case LLC_PDU_TYPE_S:
+		*pf_bit = pdu->ctrl_2 & LLC_S_PF_BIT_MASK;
+		break;
+	case LLC_PDU_TYPE_U:
+		*pf_bit = (pdu->ctrl_1 & LLC_U_PF_BIT_MASK) >> 4;
+		break;
 	}
 }
 
@@ -547,20 +547,20 @@
 	if ((pdu->ctrl_1 & LLC_PDU_TYPE_MASK) != LLC_PDU_TYPE_U)
 		goto out;
 	switch (LLC_U_PDU_CMD(pdu)) {
-		case LLC_1_PDU_CMD_XID:
-		case LLC_1_PDU_CMD_UI:
-		case LLC_1_PDU_CMD_TEST:
-			type = LLC_DEST_SAP;
-			break;
-		case LLC_2_PDU_CMD_SABME:
-		case LLC_2_PDU_CMD_DISC:
-		case LLC_2_PDU_RSP_UA:
-		case LLC_2_PDU_RSP_DM:
-		case LLC_2_PDU_RSP_FRMR:
-			break;
-		default:
-			type = LLC_DEST_INVALID;
-			break;
+	case LLC_1_PDU_CMD_XID:
+	case LLC_1_PDU_CMD_UI:
+	case LLC_1_PDU_CMD_TEST:
+		type = LLC_DEST_SAP;
+		break;
+	case LLC_2_PDU_CMD_SABME:
+	case LLC_2_PDU_CMD_DISC:
+	case LLC_2_PDU_RSP_UA:
+	case LLC_2_PDU_RSP_DM:
+	case LLC_2_PDU_RSP_FRMR:
+		break;
+	default:
+		type = LLC_DEST_INVALID;
+		break;
 	}
 out:
 	*dest = type;
@@ -604,13 +604,13 @@
 	} else
 		pdu_type = LLC_PDU_TYPE_I;
 	switch (pdu_type) {
-		case LLC_PDU_TYPE_I:
-		case LLC_PDU_TYPE_S:
-			pf_bit = pdu->ctrl_2 & LLC_S_PF_BIT_MASK;
-			break;
-		case LLC_PDU_TYPE_U:
-			pf_bit = (pdu->ctrl_1 & LLC_U_PF_BIT_MASK) >> 4;
-			break;
+	case LLC_PDU_TYPE_I:
+	case LLC_PDU_TYPE_S:
+		pf_bit = pdu->ctrl_2 & LLC_S_PF_BIT_MASK;
+		break;
+	case LLC_PDU_TYPE_U:
+		pf_bit = (pdu->ctrl_1 & LLC_U_PF_BIT_MASK) >> 4;
+		break;
 	}
 	return pf_bit;
 }
diff -Nru a/net/llc/llc_proc.c b/net/llc/llc_proc.c
--- a/net/llc/llc_proc.c	Wed Apr 30 22:28:04 2003
+++ b/net/llc/llc_proc.c	Wed Apr 30 22:28:04 2003
@@ -2,7 +2,7 @@
  * proc_llc.c - proc interface for LLC
  *
  * Copyright (c) 2001 by Jay Schulist <jschlst@samba.org>
- *		 2002 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ *		 2002-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  * This program can be redistributed or modified under the terms of the
  * GNU General Public License as published by the Free Software Foundation.
diff -Nru a/net/llc/llc_s_ac.c b/net/llc/llc_s_ac.c
--- a/net/llc/llc_s_ac.c	Wed Apr 30 22:28:16 2003
+++ b/net/llc/llc_s_ac.c	Wed Apr 30 22:28:16 2003
@@ -8,7 +8,7 @@
  *   them return 0 On success and 1 otherwise.
  *
  * Copyright (c) 1997 by Procom Technology, Inc.
- *		 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ *		 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  * This program can be redistributed or modified under the terms of the
  * GNU General Public License as published by the Free Software Foundation.
diff -Nru a/net/llc/llc_s_ev.c b/net/llc/llc_s_ev.c
--- a/net/llc/llc_s_ev.c	Wed Apr 30 22:28:12 2003
+++ b/net/llc/llc_s_ev.c	Wed Apr 30 22:28:12 2003
@@ -5,7 +5,7 @@
  * in 802.2 LLC protocol standard document.
  *
  * Copyright (c) 1997 by Procom Technology, Inc.
- *		 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ *		 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  * This program can be redistributed or modified under the terms of the
  * GNU General Public License as published by the Free Software Foundation.
diff -Nru a/net/llc/llc_s_st.c b/net/llc/llc_s_st.c
--- a/net/llc/llc_s_st.c	Wed Apr 30 22:28:04 2003
+++ b/net/llc/llc_s_st.c	Wed Apr 30 22:28:04 2003
@@ -5,7 +5,7 @@
  * which are described in 802.2 LLC protocol standard document.
  *
  * Copyright (c) 1997 by Procom Technology, Inc.
- *		 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ *		 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  * This program can be redistributed or modified under the terms of the
  * GNU General Public License as published by the Free Software Foundation.
diff -Nru a/net/llc/llc_sap.c b/net/llc/llc_sap.c
--- a/net/llc/llc_sap.c	Wed Apr 30 22:28:14 2003
+++ b/net/llc/llc_sap.c	Wed Apr 30 22:28:14 2003
@@ -2,7 +2,7 @@
  * llc_sap.c - driver routines for SAP component.
  *
  * Copyright (c) 1997 by Procom Technology, Inc.
- * 		 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ * 		 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  * This program can be redistributed or modified under the terms of the
  * GNU General Public License as published by the Free Software Foundation.
diff -Nru a/net/llc/llc_stat.c b/net/llc/llc_stat.c
--- a/net/llc/llc_stat.c	Wed Apr 30 22:28:05 2003
+++ b/net/llc/llc_stat.c	Wed Apr 30 22:28:05 2003
@@ -2,7 +2,7 @@
  * llc_stat.c - Implementation of LLC station component state machine
  * 		transitions
  * Copyright (c) 1997 by Procom Technology, Inc.
- * 		 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ * 		 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  * This program can be redistributed or modified under the terms of the
  * GNU General Public License as published by the Free Software Foundation.
diff -Nru a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
--- a/net/netlink/af_netlink.c	Wed Apr 30 22:28:09 2003
+++ b/net/netlink/af_netlink.c	Wed Apr 30 22:28:09 2003
@@ -1052,6 +1052,7 @@
 struct net_proto_family netlink_family_ops = {
 	.family = PF_NETLINK,
 	.create = netlink_create,
+	.owner	= THIS_MODULE,	/* for consistency 8) */
 };
 
 static int __init netlink_proto_init(void)
@@ -1066,6 +1067,11 @@
 #ifdef CONFIG_PROC_FS
 	create_proc_read_entry("net/netlink", 0, 0, netlink_read_proc, NULL);
 #endif
+	/* The netlink device handler may be needed early. */ 
+	rtnetlink_init();
+#ifdef CONFIG_NETLINK_DEV
+	init_netlink();
+#endif
 	return 0;
 }
 
@@ -1075,7 +1081,7 @@
        remove_proc_entry("net/netlink", NULL);
 }
 
-module_init(netlink_proto_init);
+subsys_initcall(netlink_proto_init);
 module_exit(netlink_proto_exit);
 
 MODULE_LICENSE("GPL");
diff -Nru a/net/netlink/netlink_dev.c b/net/netlink/netlink_dev.c
--- a/net/netlink/netlink_dev.c	Wed Apr 30 22:28:08 2003
+++ b/net/netlink/netlink_dev.c	Wed Apr 30 22:28:08 2003
@@ -170,16 +170,54 @@
 	.release =	netlink_release,
 };
 
-static struct { char *name; int minor; } entries[] = {
-	{"route", 0},
-	{"skip", 1},
-	{"usersock", 2},
-	{"fwmonitor", 3},
-	{"tcpdiag", 4},
-	{"arpd", 8},
-	{"route6", 11},
-	{"ip6_fw", 13},
-	{"dnrtmsg", 13},
+static struct {
+	char *name;
+	int minor;
+} entries[] = {
+	{
+		.name	= "route",
+		.minor	= NETLINK_ROUTE,
+	},
+	{
+		.name	= "skip",
+		.minor	= NETLINK_SKIP,
+	},
+	{
+		.name	= "usersock",
+		.minor	= NETLINK_USERSOCK,
+	},
+	{
+		.name	= "fwmonitor",
+		.minor	= NETLINK_FIREWALL,
+	},
+	{
+		.name	= "tcpdiag",
+		.minor	= NETLINK_TCPDIAG,
+	},
+	{
+		.name	= "nflog",
+		.minor	= NETLINK_NFLOG,
+	},
+	{
+		.name	= "xfrm",
+		.minor	= NETLINK_XFRM,
+	},
+	{
+		.name	= "arpd",
+		.minor	= NETLINK_ARPD,
+	},
+	{
+		.name	= "route6",
+		.minor	= NETLINK_ROUTE6,
+	},
+	{
+		.name	= "ip6_fw",
+		.minor	= NETLINK_IP6_FW,
+	},
+	{
+		.name	= "dnrtmsg",
+		.minor	= NETLINK_DNRTMSG,
+	},
 };
 
 static void __init make_devfs_entries (const char *name, int minor)
diff -Nru a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
--- a/net/netrom/af_netrom.c	Wed Apr 30 22:28:09 2003
+++ b/net/netrom/af_netrom.c	Wed Apr 30 22:28:09 2003
@@ -62,34 +62,25 @@
 
 static struct proto_ops nr_proto_ops;
 
-static void nr_free_sock(struct sock *sk)
-{
-	sk_free(sk);
-
-	MOD_DEC_USE_COUNT;
-}
-
 static struct sock *nr_alloc_sock(void)
 {
-	struct sock *sk;
 	nr_cb *nr;
+	struct sock *sk = sk_alloc(PF_NETROM, GFP_ATOMIC, 1, NULL);
 
-	MOD_INC_USE_COUNT;
-	if ((sk = sk_alloc(PF_NETROM, GFP_ATOMIC, 1, NULL)) == NULL)
-		goto decmod;
+	if (!sk)
+		goto out;
 
 	nr = nr_sk(sk) = kmalloc(sizeof(*nr), GFP_ATOMIC);
 	if (!nr)
 		goto frees;
 
 	memset(nr, 0x00, sizeof(*nr));
-
 	nr->sk = sk;
-
-out:	return sk;
-frees:	sk_free(sk);
+out:
+	return sk;
+frees:
+	sk_free(sk);
 	sk = NULL;
-decmod:	MOD_DEC_USE_COUNT;
 	goto out;
 }
 
@@ -300,9 +291,8 @@
 		sk->timer.function = nr_destroy_timer;
 		sk->timer.data     = (unsigned long)sk;
 		add_timer(&sk->timer);
-	} else {
-		nr_free_sock(sk);
-	}
+	} else
+		sk_free(sk);
 }
 
 /*
@@ -1232,6 +1222,7 @@
 static struct net_proto_family nr_family_ops = {
 	.family		=	PF_NETROM,
 	.create		=	nr_create,
+	.owner		=	THIS_MODULE,
 };
 
 static struct proto_ops nr_proto_ops = {
diff -Nru a/net/netrom/nr_dev.c b/net/netrom/nr_dev.c
--- a/net/netrom/nr_dev.c	Wed Apr 30 22:28:17 2003
+++ b/net/netrom/nr_dev.c	Wed Apr 30 22:28:17 2003
@@ -170,7 +170,6 @@
 
 static int nr_open(struct net_device *dev)
 {
-	MOD_INC_USE_COUNT;
 	netif_start_queue(dev);
 	ax25_listen_register((ax25_address *)dev->dev_addr, NULL);
 	return 0;
@@ -180,7 +179,6 @@
 {
 	netif_stop_queue(dev);
 	ax25_listen_release((ax25_address *)dev->dev_addr, NULL);
-	MOD_DEC_USE_COUNT;
 	return 0;
 }
 
@@ -199,6 +197,7 @@
 
 int nr_init(struct net_device *dev)
 {
+	SET_MODULE_OWNER(dev);
 	dev->mtu		= NR_MAX_PACKET_SIZE;
 	dev->hard_start_xmit	= nr_xmit;
 	dev->open		= nr_open;
diff -Nru a/net/packet/af_packet.c b/net/packet/af_packet.c
--- a/net/packet/af_packet.c	Wed Apr 30 22:28:12 2003
+++ b/net/packet/af_packet.c	Wed Apr 30 22:28:12 2003
@@ -209,7 +209,6 @@
 #ifdef PACKET_REFCNT_DEBUG
 	printk(KERN_DEBUG "PACKET socket %p is free, %d are alive\n", sk, atomic_read(&packet_socks_nr));
 #endif
-	MOD_DEC_USE_COUNT;
 }
 
 
@@ -939,7 +938,6 @@
 		return -ESOCKTNOSUPPORT;
 
 	sock->state = SS_UNCONNECTED;
-	MOD_INC_USE_COUNT;
 
 	err = -ENOBUFS;
 	sk = sk_alloc(PF_PACKET, GFP_KERNEL, 1, NULL);
@@ -992,7 +990,6 @@
 out_free:
 	sk_free(sk);
 out:
-	MOD_DEC_USE_COUNT;
 	return err;
 }
 
@@ -1752,6 +1749,7 @@
 static struct net_proto_family packet_family_ops = {
 	.family =	PF_PACKET,
 	.create =	packet_create,
+	.owner	=	THIS_MODULE,
 };
 
 static struct notifier_block packet_netdev_notifier = {
diff -Nru a/net/rose/af_rose.c b/net/rose/af_rose.c
--- a/net/rose/af_rose.c	Wed Apr 30 22:28:09 2003
+++ b/net/rose/af_rose.c	Wed Apr 30 22:28:09 2003
@@ -124,22 +124,13 @@
 	return 0;
 }
 
-static void rose_free_sock(struct sock *sk)
-{
-	sk_free(sk);
-
-	MOD_DEC_USE_COUNT;
-}
-
 static struct sock *rose_alloc_sock(void)
 {
-	struct sock *sk;
 	rose_cb *rose;
+	struct sock *sk = sk_alloc(PF_ROSE, GFP_ATOMIC, 1, NULL);
 
-	MOD_INC_USE_COUNT;
-
-	if ((sk = sk_alloc(PF_ROSE, GFP_ATOMIC, 1, NULL)) == NULL)
-		goto decmod;
+	if (!sk)
+		goto out;
 
 	rose = rose_sk(sk) = kmalloc(sizeof(*rose), GFP_ATOMIC);
 	if (!rose)
@@ -147,10 +138,11 @@
 
 	memset(rose, 0x00, sizeof(*rose));
 	rose->sk = sk;
-out:	return sk;
-frees:	sk_free(sk);
+out:
+	return sk;
+frees:
+	sk_free(sk);
 	sk = NULL;
-decmod:	MOD_DEC_USE_COUNT;
 	goto out;
 }
 
@@ -380,9 +372,8 @@
 		sk->timer.function = rose_destroy_timer;
 		sk->timer.data     = (unsigned long)sk;
 		add_timer(&sk->timer);
-	} else {
-		rose_free_sock(sk);
-	}
+	} else
+		sk_free(sk);
 }
 
 /*
@@ -1428,6 +1419,7 @@
 static struct net_proto_family rose_family_ops = {
 	.family		=	PF_ROSE,
 	.create		=	rose_create,
+	.owner		=	THIS_MODULE,
 };
 
 static struct proto_ops rose_proto_ops = {
diff -Nru a/net/rose/rose_dev.c b/net/rose/rose_dev.c
--- a/net/rose/rose_dev.c	Wed Apr 30 22:28:06 2003
+++ b/net/rose/rose_dev.c	Wed Apr 30 22:28:06 2003
@@ -135,7 +135,6 @@
 
 static int rose_open(struct net_device *dev)
 {
-	MOD_INC_USE_COUNT;
 	netif_start_queue(dev);
 	rose_add_loopback_node((rose_address *)dev->dev_addr);
 	return 0;
@@ -145,7 +144,6 @@
 {
 	netif_stop_queue(dev);
 	rose_del_loopback_node((rose_address *)dev->dev_addr);
-	MOD_DEC_USE_COUNT;
 	return 0;
 }
 
@@ -169,6 +167,7 @@
 
 int rose_init(struct net_device *dev)
 {
+	SET_MODULE_OWNER(dev);
 	dev->mtu		= ROSE_MAX_PACKET_SIZE - 2;
 	dev->hard_start_xmit	= rose_xmit;
 	dev->open		= rose_open;
diff -Nru a/net/sched/cls_api.c b/net/sched/cls_api.c
--- a/net/sched/cls_api.c	Wed Apr 30 22:28:06 2003
+++ b/net/sched/cls_api.c	Wed Apr 30 22:28:06 2003
@@ -17,6 +17,7 @@
 #include <asm/system.h>
 #include <asm/bitops.h>
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -64,37 +65,38 @@
 int register_tcf_proto_ops(struct tcf_proto_ops *ops)
 {
 	struct tcf_proto_ops *t, **tp;
+	int rc = -EEXIST;
 
 	write_lock(&cls_mod_lock);
-	for (tp = &tcf_proto_base; (t=*tp) != NULL; tp = &t->next) {
-		if (strcmp(ops->kind, t->kind) == 0) {
-			write_unlock(&cls_mod_lock);
-			return -EEXIST;
-		}
-	}
+	for (tp = &tcf_proto_base; (t = *tp) != NULL; tp = &t->next)
+		if (!strcmp(ops->kind, t->kind))
+			goto out;
 
 	ops->next = NULL;
 	*tp = ops;
+	rc = 0;
+out:
 	write_unlock(&cls_mod_lock);
-	return 0;
+	return rc;
 }
 
 int unregister_tcf_proto_ops(struct tcf_proto_ops *ops)
 {
 	struct tcf_proto_ops *t, **tp;
+	int rc = -ENOENT;
 
 	write_lock(&cls_mod_lock);
 	for (tp = &tcf_proto_base; (t=*tp) != NULL; tp = &t->next)
 		if (t == ops)
 			break;
 
-	if (!t) {
-		write_unlock(&cls_mod_lock);
-		return -ENOENT;
-	}
+	if (!t)
+		goto out;
 	*tp = t->next;
+	rc = 0;
+out:
 	write_unlock(&cls_mod_lock);
-	return 0;
+	return rc;
 }
 
 static int tfilter_notify(struct sk_buff *oskb, struct nlmsghdr *n,
@@ -223,8 +225,9 @@
 		tp->q = q;
 		tp->classify = tp_ops->classify;
 		tp->classid = parent;
-		err = tp_ops->init(tp);
-		if (err) {
+		err = -EBUSY;
+		if (!try_module_get(tp_ops->owner) ||
+		    (err = tp_ops->init(tp)) != 0) {
 			kfree(tp);
 			goto errout;
 		}
@@ -248,6 +251,7 @@
 			write_unlock(&qdisc_tree_lock);
 
 			tp->ops->destroy(tp);
+			module_put(tp->ops->owner);
 			kfree(tp);
 			err = 0;
 			goto errout;
@@ -368,11 +372,8 @@
 		q = dev->qdisc_sleeping;
 	else
 		q = qdisc_lookup(dev, TC_H_MAJ(tcm->tcm_parent));
-	if (q == NULL) {
-		read_unlock(&qdisc_tree_lock);
-		dev_put(dev);
-		return skb->len;
-	}
+	if (!q)
+		goto out;
 	if ((cops = q->ops->cl_ops) == NULL)
 		goto errout;
 	if (TC_H_MIN(tcm->tcm_parent)) {
@@ -422,7 +423,7 @@
 errout:
 	if (cl)
 		cops->put(q, cl);
-
+out:
 	read_unlock(&qdisc_tree_lock);
 	dev_put(dev);
 	return skb->len;
diff -Nru a/net/sched/cls_fw.c b/net/sched/cls_fw.c
--- a/net/sched/cls_fw.c	Wed Apr 30 22:28:08 2003
+++ b/net/sched/cls_fw.c	Wed Apr 30 22:28:08 2003
@@ -117,7 +117,6 @@
 
 static int fw_init(struct tcf_proto *tp)
 {
-	MOD_INC_USE_COUNT;
 	return 0;
 }
 
@@ -127,10 +126,8 @@
 	struct fw_filter *f;
 	int h;
 
-	if (head == NULL) {
-		MOD_DEC_USE_COUNT;
+	if (head == NULL)
 		return;
-	}
 
 	for (h=0; h<256; h++) {
 		while ((f=head->ht[h]) != NULL) {
@@ -146,7 +143,6 @@
 		}
 	}
 	kfree(head);
-	MOD_DEC_USE_COUNT;
 }
 
 static int fw_delete(struct tcf_proto *tp, unsigned long arg)
@@ -156,7 +152,7 @@
 	struct fw_filter **fp;
 
 	if (head == NULL || f == NULL)
-		return -EINVAL;
+		goto out;
 
 	for (fp=&head->ht[fw_hash(f->id)]; *fp; fp = &(*fp)->next) {
 		if (*fp == f) {
@@ -175,6 +171,7 @@
 			return 0;
 		}
 	}
+out:
 	return -EINVAL;
 }
 
@@ -351,18 +348,18 @@
 }
 
 struct tcf_proto_ops cls_fw_ops = {
-	NULL,
-	"fw",
-	fw_classify,
-	fw_init,
-	fw_destroy,
-
-	fw_get,
-	fw_put,
-	fw_change,
-	fw_delete,
-	fw_walk,
-	fw_dump
+	.next		=	NULL,
+	.kind		=	"fw",
+	.classify	=	fw_classify,
+	.init		=	fw_init,
+	.destroy	=	fw_destroy,
+	.get		=	fw_get,
+	.put		=	fw_put,
+	.change		=	fw_change,
+	.delete		=	fw_delete,
+	.walk		=	fw_walk,
+	.dump		=	fw_dump,
+	.owner		=	THIS_MODULE,
 };
 
 #ifdef MODULE
diff -Nru a/net/sched/cls_route.c b/net/sched/cls_route.c
--- a/net/sched/cls_route.c	Wed Apr 30 22:28:07 2003
+++ b/net/sched/cls_route.c	Wed Apr 30 22:28:07 2003
@@ -272,7 +272,6 @@
 
 static int route4_init(struct tcf_proto *tp)
 {
-	MOD_INC_USE_COUNT;
 	return 0;
 }
 
@@ -281,10 +280,8 @@
 	struct route4_head *head = xchg(&tp->root, NULL);
 	int h1, h2;
 
-	if (head == NULL) {
-		MOD_DEC_USE_COUNT;
+	if (head == NULL)
 		return;
-	}
 
 	for (h1=0; h1<=256; h1++) {
 		struct route4_bucket *b;
@@ -309,7 +306,6 @@
 		}
 	}
 	kfree(head);
-	MOD_DEC_USE_COUNT;
 }
 
 static int route4_delete(struct tcf_proto *tp, unsigned long arg)
@@ -607,18 +603,18 @@
 }
 
 struct tcf_proto_ops cls_route4_ops = {
-	NULL,
-	"route",
-	route4_classify,
-	route4_init,
-	route4_destroy,
-
-	route4_get,
-	route4_put,
-	route4_change,
-	route4_delete,
-	route4_walk,
-	route4_dump
+	.next		=	NULL,
+	.kind		=	"route",
+	.classify	=	route4_classify,
+	.init		=	route4_init,
+	.destroy	=	route4_destroy,
+	.get		=	route4_get,
+	.put		=	route4_put,
+	.change		=	route4_change,
+	.delete		=	route4_delete,
+	.walk		=	route4_walk,
+	.dump		=	route4_dump,
+	.owner		=	THIS_MODULE,
 };
 
 #ifdef MODULE
diff -Nru a/net/sched/cls_rsvp.h b/net/sched/cls_rsvp.h
--- a/net/sched/cls_rsvp.h	Wed Apr 30 22:28:04 2003
+++ b/net/sched/cls_rsvp.h	Wed Apr 30 22:28:04 2003
@@ -242,14 +242,12 @@
 {
 	struct rsvp_head *data;
 
-	MOD_INC_USE_COUNT;
 	data = kmalloc(sizeof(struct rsvp_head), GFP_KERNEL);
 	if (data) {
 		memset(data, 0, sizeof(struct rsvp_head));
 		tp->root = data;
 		return 0;
 	}
-	MOD_DEC_USE_COUNT;
 	return -ENOBUFS;
 }
 
@@ -289,7 +287,6 @@
 		}
 	}
 	kfree(data);
-	MOD_DEC_USE_COUNT;
 }
 
 static int rsvp_delete(struct tcf_proto *tp, unsigned long arg)
@@ -668,18 +665,18 @@
 }
 
 struct tcf_proto_ops RSVP_OPS = {
-	NULL,
-	RSVP_ID,
-	rsvp_classify,
-	rsvp_init,
-	rsvp_destroy,
-
-	rsvp_get,
-	rsvp_put,
-	rsvp_change,
-	rsvp_delete,
-	rsvp_walk,
-	rsvp_dump
+	.next		=	NULL,
+	.kind		=	RSVP_ID,
+	.classify	=	rsvp_classify,
+	.init		=	rsvp_init,
+	.destroy	=	rsvp_destroy,
+	.get		=	rsvp_get,
+	.put		=	rsvp_put,
+	.change		=	rsvp_change,
+	.delete		=	rsvp_delete,
+	.walk		=	rsvp_walk,
+	.dump		=	rsvp_dump,
+	.owner		=	THIS_MODULE,
 };
 
 #ifdef MODULE
diff -Nru a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
--- a/net/sched/cls_tcindex.c	Wed Apr 30 22:28:08 2003
+++ b/net/sched/cls_tcindex.c	Wed Apr 30 22:28:08 2003
@@ -144,12 +144,10 @@
 	struct tcindex_data *p;
 
 	DPRINTK("tcindex_init(tp %p)\n",tp);
-	MOD_INC_USE_COUNT;
 	p = kmalloc(sizeof(struct tcindex_data),GFP_KERNEL);
-	if (!p) {
-		MOD_DEC_USE_COUNT;
+	if (!p)
 		return -ENOMEM;
-	}
+
 	tp->root = p;
 	p->perfect = NULL;
 	p->h = NULL;
@@ -417,7 +415,6 @@
 		kfree(p->h);
 	kfree(p);
 	tp->root = NULL;
-	MOD_DEC_USE_COUNT;
 }
 
 
@@ -480,18 +477,18 @@
 }
 
 struct tcf_proto_ops cls_tcindex_ops = {
-	NULL,
-	"tcindex",
-	tcindex_classify,
-	tcindex_init,
-	tcindex_destroy,
-
-	tcindex_get,
-	tcindex_put,
-	tcindex_change,
-	tcindex_delete,
-	tcindex_walk,
-	tcindex_dump
+	.next		=	NULL,
+	.kind		=	"tcindex",
+	.classify	=	tcindex_classify,
+	.init		=	tcindex_init,
+	.destroy	=	tcindex_destroy,
+	.get		=	tcindex_get,
+	.put		=	tcindex_put,
+	.change		=	tcindex_change,
+	.delete		=	tcindex_delete,
+	.walk		=	tcindex_walk,
+	.dump		=	tcindex_dump,
+	.owner		=	THIS_MODULE,
 };
 
 
diff -Nru a/net/sched/cls_u32.c b/net/sched/cls_u32.c
--- a/net/sched/cls_u32.c	Wed Apr 30 22:28:06 2003
+++ b/net/sched/cls_u32.c	Wed Apr 30 22:28:06 2003
@@ -203,17 +203,17 @@
 u32_lookup_key(struct tc_u_hnode *ht, u32 handle)
 {
 	unsigned sel;
-	struct tc_u_knode *n;
+	struct tc_u_knode *n = NULL;
 
 	sel = TC_U32_HASH(handle);
 	if (sel > ht->divisor)
-		return 0;
+		goto out;
 
 	for (n = ht->ht[sel]; n; n = n->next)
 		if (n->handle == handle)
-			return n;
-
-	return NULL;
+			break;
+out:
+	return n;
 }
 
 
@@ -257,17 +257,14 @@
 	struct tc_u_hnode *root_ht;
 	struct tc_u_common *tp_c;
 
-	MOD_INC_USE_COUNT;
-
 	for (tp_c = u32_list; tp_c; tp_c = tp_c->next)
 		if (tp_c->q == tp->q)
 			break;
 
 	root_ht = kmalloc(sizeof(*root_ht), GFP_KERNEL);
-	if (root_ht == NULL) {
-		MOD_DEC_USE_COUNT;
+	if (root_ht == NULL)
 		return -ENOBUFS;
-	}
+
 	memset(root_ht, 0, sizeof(*root_ht));
 	root_ht->divisor = 0;
 	root_ht->refcnt++;
@@ -277,7 +274,6 @@
 		tp_c = kmalloc(sizeof(*tp_c), GFP_KERNEL);
 		if (tp_c == NULL) {
 			kfree(root_ht);
-			MOD_DEC_USE_COUNT;
 			return -ENOBUFS;
 		}
 		memset(tp_c, 0, sizeof(*tp_c));
@@ -402,7 +398,6 @@
 		kfree(tp_c);
 	}
 
-	MOD_DEC_USE_COUNT;
 	tp->data = NULL;
 }
 
@@ -690,18 +685,18 @@
 }
 
 struct tcf_proto_ops cls_u32_ops = {
-	NULL,
-	"u32",
-	u32_classify,
-	u32_init,
-	u32_destroy,
-
-	u32_get,
-	u32_put,
-	u32_change,
-	u32_delete,
-	u32_walk,
-	u32_dump
+	.next		=	NULL,
+	.kind		=	"u32",
+	.classify	=	u32_classify,
+	.init		=	u32_init,
+	.destroy	=	u32_destroy,
+	.get		=	u32_get,
+	.put		=	u32_put,
+	.change		=	u32_change,
+	.delete		=	u32_delete,
+	.walk		=	u32_walk,
+	.dump		=	u32_dump,
+	.owner		=	THIS_MODULE,
 };
 
 #ifdef MODULE
diff -Nru a/net/sched/sch_api.c b/net/sched/sch_api.c
--- a/net/sched/sch_api.c	Wed Apr 30 22:28:08 2003
+++ b/net/sched/sch_api.c	Wed Apr 30 22:28:08 2003
@@ -16,6 +16,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -138,21 +139,19 @@
 
 /* The list of all installed queueing disciplines. */
 
-static struct Qdisc_ops *qdisc_base = NULL;
+static struct Qdisc_ops *qdisc_base;
 
 /* Register/uregister queueing discipline */
 
 int register_qdisc(struct Qdisc_ops *qops)
 {
 	struct Qdisc_ops *q, **qp;
+	int rc = -EEXIST;
 
 	write_lock(&qdisc_mod_lock);
-	for (qp = &qdisc_base; (q=*qp)!=NULL; qp = &q->next) {
-		if (strcmp(qops->id, q->id) == 0) {
-			write_unlock(&qdisc_mod_lock);
-			return -EEXIST;
-		}
-	}
+	for (qp = &qdisc_base; (q = *qp) != NULL; qp = &q->next)
+		if (!strcmp(qops->id, q->id))
+			goto out;
 
 	if (qops->enqueue == NULL)
 		qops->enqueue = noop_qdisc_ops.enqueue;
@@ -163,8 +162,10 @@
 
 	qops->next = NULL;
 	*qp = qops;
+	rc = 0;
+out:
 	write_unlock(&qdisc_mod_lock);
-	return 0;
+	return rc;
 }
 
 int unregister_qdisc(struct Qdisc_ops *qops)
@@ -447,6 +448,10 @@
         else
                 sch->handle = handle;
 
+	err = -EBUSY;
+	if (!try_module_get(ops->owner))
+		goto err_out;
+
 	if (!ops->init || (err = ops->init(sch, tca[TCA_OPTIONS-1])) == 0) {
 		write_lock(&qdisc_tree_lock);
 		sch->next = dev->qdisc_list;
@@ -458,6 +463,7 @@
 #endif
 		return sch;
 	}
+	module_put(ops->owner);
 
 err_out:
 	*errp = err;
diff -Nru a/net/sched/sch_atm.c b/net/sched/sch_atm.c
--- a/net/sched/sch_atm.c	Wed Apr 30 22:28:09 2003
+++ b/net/sched/sch_atm.c	Wed Apr 30 22:28:09 2003
@@ -575,7 +575,6 @@
 	p->link.ref = 1;
 	p->link.next = NULL;
 	tasklet_init(&p->task,sch_atm_dequeue,(unsigned long) sch);
-	MOD_INC_USE_COUNT;
 	return 0;
 }
 
@@ -612,7 +611,6 @@
 		}
 	}
 	tasklet_kill(&p->task);
-	MOD_DEC_USE_COUNT;
 }
 
 
@@ -663,41 +661,35 @@
 	return 0;
 }
 
-static struct Qdisc_class_ops atm_class_ops =
-{
-	.graft		= atm_tc_graft,
-	.leaf		= atm_tc_leaf,
-	.get		= atm_tc_get,
-	.put		= atm_tc_put,
-	.change		= atm_tc_change,
-	.delete		= atm_tc_delete,
-	.walk		= atm_tc_walk,
-
-	.tcf_chain	= atm_tc_find_tcf,
-	.bind_tcf	= atm_tc_bind_filter,
-	.unbind_tcf	= atm_tc_put,
-
-	.dump		= atm_tc_dump_class,
+static struct Qdisc_class_ops atm_class_ops = {
+	.graft		=	atm_tc_graft,
+	.leaf		=	atm_tc_leaf,
+	.get		=	atm_tc_get,
+	.put		=	atm_tc_put,
+	.change		=	atm_tc_change,
+	.delete		=	atm_tc_delete,
+	.walk		=	atm_tc_walk,
+	.tcf_chain	=	atm_tc_find_tcf,
+	.bind_tcf	=	atm_tc_bind_filter,
+	.unbind_tcf	=	atm_tc_put,
+	.dump		=	atm_tc_dump_class,
 };
 
-struct Qdisc_ops atm_qdisc_ops =
-{
-	.next		= NULL,
-	.cl_ops		= &atm_class_ops,
-	.id		= "atm",
-	.priv_size	= sizeof(struct atm_qdisc_data),
-
-	.enqueue	= atm_tc_enqueue,
-	.dequeue	= atm_tc_dequeue,
-	.requeue	= atm_tc_requeue,
-	.drop		= atm_tc_drop,
-
-	.init		= atm_tc_init,
-	.reset		= atm_tc_reset,
-	.destroy	= atm_tc_destroy,
-	.change		= NULL,
-
-	.dump		= atm_tc_dump
+struct Qdisc_ops atm_qdisc_ops = {
+	.next		=	NULL,
+	.cl_ops		=	&atm_class_ops,
+	.id		=	"atm",
+	.priv_size	=	sizeof(struct atm_qdisc_data),
+	.enqueue	=	atm_tc_enqueue,
+	.dequeue	=	atm_tc_dequeue,
+	.requeue	=	atm_tc_requeue,
+	.drop		=	atm_tc_drop,
+	.init		=	atm_tc_init,
+	.reset		=	atm_tc_reset,
+	.destroy	=	atm_tc_destroy,
+	.change		=	NULL,
+	.dump		=	atm_tc_dump,
+	.owner		=	THIS_MODULE,
 };
 
 
diff -Nru a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c
--- a/net/sched/sch_cbq.c	Wed Apr 30 22:28:04 2003
+++ b/net/sched/sch_cbq.c	Wed Apr 30 22:28:04 2003
@@ -44,7 +44,7 @@
 	         Management Models for Packet Networks",
 		 IEEE/ACM Transactions on Networking, Vol.3, No.4, 1995
 
-	         [2] Sally Floyd, "Notes on CBQ and Guaranted Service", 1995
+	         [2] Sally Floyd, "Notes on CBQ and Guaranteed Service", 1995
 
 	         [3] Sally Floyd, "Notes on Class-Based Queueing: Setting
 		 Parameters", 1996
@@ -106,7 +106,7 @@
 	u32			defmap;
 
 	/* Link-sharing scheduler parameters */
-	long			maxidle;	/* Class paramters: see below. */
+	long			maxidle;	/* Class parameters: see below. */
 	long			offtime;
 	long			minidle;
 	u32			avpkt;
@@ -998,7 +998,7 @@
 	if (q->tx_class) {
 		psched_tdiff_t incr2;
 		/* Time integrator. We calculate EOS time
-		   by adding expected packet transmittion time.
+		   by adding expected packet transmission time.
 		   If real time is greater, we warp artificial clock,
 		   so that:
 
@@ -1411,11 +1411,8 @@
 
 	r = RTA_DATA(tb[TCA_CBQ_RATE-1]);
 
-	MOD_INC_USE_COUNT;
-	if ((q->link.R_tab = qdisc_get_rtab(r, tb[TCA_CBQ_RTAB-1])) == NULL) {
-		MOD_DEC_USE_COUNT;
+	if ((q->link.R_tab = qdisc_get_rtab(r, tb[TCA_CBQ_RTAB-1])) == NULL)
 		return -EINVAL;
-	}
 
 	q->link.refcnt = 1;
 	q->link.sibling = &q->link;
@@ -1749,7 +1746,6 @@
 	}
 
 	qdisc_put_rtab(q->link.R_tab);
-	MOD_DEC_USE_COUNT;
 }
 
 static void cbq_put(struct Qdisc *sch, unsigned long arg)
@@ -2064,41 +2060,35 @@
 	}
 }
 
-static struct Qdisc_class_ops cbq_class_ops =
-{
-	.graft		= cbq_graft,
-	.leaf		= cbq_leaf,
-	.get		= cbq_get,
-	.put		= cbq_put,
-	.change		= cbq_change_class,
-	.delete		= cbq_delete,
-	.walk		= cbq_walk,
-
-	.tcf_chain	= cbq_find_tcf,
-	.bind_tcf	= cbq_bind_filter,
-	.unbind_tcf	= cbq_unbind_filter,
-
-	.dump		= cbq_dump_class,
+static struct Qdisc_class_ops cbq_class_ops = {
+	.graft		=	cbq_graft,
+	.leaf		=	cbq_leaf,
+	.get		=	cbq_get,
+	.put		=	cbq_put,
+	.change		=	cbq_change_class,
+	.delete		=	cbq_delete,
+	.walk		=	cbq_walk,
+	.tcf_chain	=	cbq_find_tcf,
+	.bind_tcf	=	cbq_bind_filter,
+	.unbind_tcf	=	cbq_unbind_filter,
+	.dump		=	cbq_dump_class,
 };
 
-struct Qdisc_ops cbq_qdisc_ops =
-{
-	.next		= NULL,
-	.cl_ops		= &cbq_class_ops,
-	.id		= "cbq",
-	.priv_size	= sizeof(struct cbq_sched_data),
-
-	.enqueue	= cbq_enqueue,
-	.dequeue	= cbq_dequeue,
-	.requeue	= cbq_requeue,
-	.drop		= cbq_drop,
-
-	.init		= cbq_init,
-	.reset		= cbq_reset,
-	.destroy	= cbq_destroy,
-	.change		= NULL,
-
-	.dump		= cbq_dump,
+struct Qdisc_ops cbq_qdisc_ops = {
+	.next		=	NULL,
+	.cl_ops		=	&cbq_class_ops,
+	.id		=	"cbq",
+	.priv_size	=	sizeof(struct cbq_sched_data),
+	.enqueue	=	cbq_enqueue,
+	.dequeue	=	cbq_dequeue,
+	.requeue	=	cbq_requeue,
+	.drop		=	cbq_drop,
+	.init		=	cbq_init,
+	.reset		=	cbq_reset,
+	.destroy	=	cbq_destroy,
+	.change		=	NULL,
+	.dump		=	cbq_dump,
+	.owner		=	THIS_MODULE,
 };
 
 #ifdef MODULE
diff -Nru a/net/sched/sch_csz.c b/net/sched/sch_csz.c
--- a/net/sched/sch_csz.c	Wed Apr 30 22:28:10 2003
+++ b/net/sched/sch_csz.c	Wed Apr 30 22:28:10 2003
@@ -184,7 +184,7 @@
 	procedure for solving these equations.
 	See procedure csz_update(), that is a generalization of
 	the algorithm from S. Keshav's thesis Chapter 3
-	"Efficient Implementation of Fair Queeing".
+	"Efficient Implementation of Fair Queuing".
 
 	NOTES.
 
@@ -624,7 +624,7 @@
 
 	toks = -toks;
 
-	/* Remeber, that we should start watchdog */
+	/* Remember, that we should start watchdog */
 	if (toks < q->wd_expires)
 		q->wd_expires = toks;
 
@@ -756,8 +756,6 @@
 		q->filter_list = tp->next;
 		tp->ops->destroy(tp);
 	}
-
-	MOD_DEC_USE_COUNT;
 }
 
 static int csz_init(struct Qdisc *sch, struct rtattr *opt)
@@ -799,7 +797,6 @@
 	q->wd_timer.data = (unsigned long)sch;
 	q->wd_timer.function = csz_watchdog;
 #endif
-	MOD_INC_USE_COUNT;
 	return 0;
 }
 
@@ -1018,42 +1015,35 @@
 	return &q->filter_list;
 }
 
-struct Qdisc_class_ops csz_class_ops =
-{
-	.graft		= csz_graft,
-	.leaf		= csz_leaf,
-
-	.get		= csz_get,
-	.put		= csz_put,
-	.change		= csz_change,
-	.delete		= csz_delete,
-	.walk		= csz_walk,
-
-	.tcf_chain	= csz_find_tcf,
-	.bind_tcf	= csz_bind,
-	.unbind_tcf	= csz_put,
-
-	.dump		= csz_dump_class,
+struct Qdisc_class_ops csz_class_ops = {
+	.graft		=	csz_graft,
+	.leaf		=	csz_leaf,
+	.get		=	csz_get,
+	.put		=	csz_put,
+	.change		=	csz_change,
+	.delete		=	csz_delete,
+	.walk		=	csz_walk,
+	.tcf_chain	=	csz_find_tcf,
+	.bind_tcf	=	csz_bind,
+	.unbind_tcf	=	csz_put,
+	.dump		=	csz_dump_class,
 };
 
-struct Qdisc_ops csz_qdisc_ops =
-{
-	.next		= NULL,
-	.cl_ops		= &csz_class_ops,
-	.id		= "csz",
-	.priv_size	= sizeof(struct csz_sched_data),
-
-	.enqueue	= csz_enqueue,
-	.dequeue	= csz_dequeue,
-	.requeue	= NULL,
-	.drop		= NULL,
-
-	.init		= csz_init,
-	.reset		= csz_reset,
-	.destroy	= csz_destroy,
-	.change		= NULL,
-
-	.dump		= csz_dump,
+struct Qdisc_ops csz_qdisc_ops = {
+	.next		=	NULL,
+	.cl_ops		=	&csz_class_ops,
+	.id		=	"csz",
+	.priv_size	=	sizeof(struct csz_sched_data),
+	.enqueue	=	csz_enqueue,
+	.dequeue	=	csz_dequeue,
+	.requeue	=	NULL,
+	.drop		=	NULL,
+	.init		=	csz_init,
+	.reset		=	csz_reset,
+	.destroy	=	csz_destroy,
+	.change		=	NULL,
+	.dump		=	csz_dump,
+	.owner		=	THIS_MODULE,
 };
 
 
diff -Nru a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c
--- a/net/sched/sch_dsmark.c	Wed Apr 30 22:28:05 2003
+++ b/net/sched/sch_dsmark.c	Wed Apr 30 22:28:05 2003
@@ -353,7 +353,6 @@
 	if (!(p->q = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops)))
 		p->q = &noop_qdisc;
 	DPRINTK("dsmark_init: qdisc %p\n",&p->q);
-	MOD_INC_USE_COUNT;
 	return 0;
 }
 
@@ -382,7 +381,6 @@
 	qdisc_destroy(p->q);
 	p->q = &noop_qdisc;
 	kfree(p->mask);
-	MOD_DEC_USE_COUNT;
 }
 
 
@@ -433,41 +431,35 @@
 	return -1;
 }
 
-static struct Qdisc_class_ops dsmark_class_ops =
-{
-	.graft		= dsmark_graft,
-	.leaf		= dsmark_leaf,
-	.get		= dsmark_get,
-	.put		= dsmark_put,
-	.change		= dsmark_change,
-	.delete		= dsmark_delete,
-	.walk		= dsmark_walk,
-
-	.tcf_chain	= dsmark_find_tcf,
-	.bind_tcf	= dsmark_bind_filter,
-	.unbind_tcf	= dsmark_put,
-
-	.dump		= dsmark_dump_class,
+static struct Qdisc_class_ops dsmark_class_ops = {
+	.graft		=	dsmark_graft,
+	.leaf		=	dsmark_leaf,
+	.get		=	dsmark_get,
+	.put		=	dsmark_put,
+	.change		=	dsmark_change,
+	.delete		=	dsmark_delete,
+	.walk		=	dsmark_walk,
+	.tcf_chain	=	dsmark_find_tcf,
+	.bind_tcf	=	dsmark_bind_filter,
+	.unbind_tcf	=	dsmark_put,
+	.dump		=	dsmark_dump_class,
 };
 
-struct Qdisc_ops dsmark_qdisc_ops =
-{
-	.next		= NULL,
-	.cl_ops		= &dsmark_class_ops,
-	.id		= "dsmark",
-	.priv_size	= sizeof(struct dsmark_qdisc_data),
-
-	.enqueue	= dsmark_enqueue,
-	.dequeue	= dsmark_dequeue,
-	.requeue	= dsmark_requeue,
-	.drop		= dsmark_drop,
-
-	.init		= dsmark_init,
-	.reset		= dsmark_reset,
-	.destroy	= dsmark_destroy,
-	.change		= NULL,
-
-	.dump		= dsmark_dump
+struct Qdisc_ops dsmark_qdisc_ops = {
+	.next		=	NULL,
+	.cl_ops		=	&dsmark_class_ops,
+	.id		=	"dsmark",
+	.priv_size	=	sizeof(struct dsmark_qdisc_data),
+	.enqueue	=	dsmark_enqueue,
+	.dequeue	=	dsmark_dequeue,
+	.requeue	=	dsmark_requeue,
+	.drop		=	dsmark_drop,
+	.init		=	dsmark_init,
+	.reset		=	dsmark_reset,
+	.destroy	=	dsmark_destroy,
+	.change		=	NULL,
+	.dump		=	dsmark_dump,
+	.owner		=	THIS_MODULE,
 };
 
 #ifdef MODULE
diff -Nru a/net/sched/sch_fifo.c b/net/sched/sch_fifo.c
--- a/net/sched/sch_fifo.c	Wed Apr 30 22:28:05 2003
+++ b/net/sched/sch_fifo.c	Wed Apr 30 22:28:05 2003
@@ -10,6 +10,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <asm/bitops.h>
@@ -168,42 +169,36 @@
 	return -1;
 }
 
-struct Qdisc_ops pfifo_qdisc_ops =
-{
-	.next		= NULL,
-	.cl_ops		= NULL,
-	.id		= "pfifo",
-	.priv_size	= sizeof(struct fifo_sched_data),
-
-	.enqueue	= pfifo_enqueue,
-	.dequeue	= pfifo_dequeue,
-	.requeue	= pfifo_requeue,
-	.drop		= fifo_drop,
-
-	.init		= fifo_init,
-	.reset		= fifo_reset,
-	.destroy	= NULL,
-	.change		= fifo_init,
-
-	.dump		= fifo_dump,
+struct Qdisc_ops pfifo_qdisc_ops = {
+	.next		=	NULL,
+	.cl_ops		=	NULL,
+	.id		=	"pfifo",
+	.priv_size	=	sizeof(struct fifo_sched_data),
+	.enqueue	=	pfifo_enqueue,
+	.dequeue	=	pfifo_dequeue,
+	.requeue	=	pfifo_requeue,
+	.drop		=	fifo_drop,
+	.init		=	fifo_init,
+	.reset		=	fifo_reset,
+	.destroy	=	NULL,
+	.change		=	fifo_init,
+	.dump		=	fifo_dump,
+	.owner		=	THIS_MODULE,
 };
 
-struct Qdisc_ops bfifo_qdisc_ops =
-{
-	.next		= NULL,
-	.cl_ops		= NULL,
-	.id		= "bfifo",
-	.priv_size	= sizeof(struct fifo_sched_data),
-
-	.enqueue	= bfifo_enqueue,
-	.dequeue	= bfifo_dequeue,
-	.requeue	= bfifo_requeue,
-	.drop		= fifo_drop,
-
-	.init		= fifo_init,
-	.reset		= fifo_reset,
-	.destroy	= NULL,
-	.change		= fifo_init,
-
-	.dump		= fifo_dump,
+struct Qdisc_ops bfifo_qdisc_ops = {
+	.next		=	NULL,
+	.cl_ops		=	NULL,
+	.id		=	"bfifo",
+	.priv_size	=	sizeof(struct fifo_sched_data),
+	.enqueue	=	bfifo_enqueue,
+	.dequeue	=	bfifo_dequeue,
+	.requeue	=	bfifo_requeue,
+	.drop		=	fifo_drop,
+	.init		=	fifo_init,
+	.reset		=	fifo_reset,
+	.destroy	=	NULL,
+	.change		=	fifo_init,
+	.dump		=	fifo_dump,
+	.owner		=	THIS_MODULE,
 };
diff -Nru a/net/sched/sch_generic.c b/net/sched/sch_generic.c
--- a/net/sched/sch_generic.c	Wed Apr 30 22:28:03 2003
+++ b/net/sched/sch_generic.c	Wed Apr 30 22:28:03 2003
@@ -15,6 +15,7 @@
 #include <asm/system.h>
 #include <asm/bitops.h>
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -222,45 +223,40 @@
 	return NET_XMIT_CN;
 }
 
-struct Qdisc_ops noop_qdisc_ops =
-{
-	.next		= NULL,
-	.cl_ops		= NULL,
-	.id		= "noop",
-	.priv_size	= 0,
-
-	.enqueue	= noop_enqueue,
-	.dequeue	= noop_dequeue,
-	.requeue	= noop_requeue,
+struct Qdisc_ops noop_qdisc_ops = {
+	.next		=	NULL,
+	.cl_ops		=	NULL,
+	.id		=	"noop",
+	.priv_size	=	0,
+	.enqueue	=	noop_enqueue,
+	.dequeue	=	noop_dequeue,
+	.requeue	=	noop_requeue,
+	.owner		=	THIS_MODULE,
 };
 
-struct Qdisc noop_qdisc =
-{
-	.enqueue	= noop_enqueue,
-	.dequeue	= noop_dequeue,
-	.flags		= TCQ_F_BUILTIN,
-	.ops		= &noop_qdisc_ops,	
+struct Qdisc noop_qdisc = {
+	.enqueue	=	noop_enqueue,
+	.dequeue	=	noop_dequeue,
+	.flags		=	TCQ_F_BUILTIN,
+	.ops		=	&noop_qdisc_ops,	
 };
 
-
-struct Qdisc_ops noqueue_qdisc_ops =
-{
-	.next		= NULL,
-	.cl_ops		= NULL,
-	.id		= "noqueue",
-	.priv_size	= 0,
-
-	.enqueue	= noop_enqueue,
-	.dequeue	= noop_dequeue,
-	.requeue	= noop_requeue,
+struct Qdisc_ops noqueue_qdisc_ops = {
+	.next		=	NULL,
+	.cl_ops		=	NULL,
+	.id		=	"noqueue",
+	.priv_size	=	0,
+	.enqueue	=	noop_enqueue,
+	.dequeue	=	noop_dequeue,
+	.requeue	=	noop_requeue,
+	.owner		=	THIS_MODULE,
 };
 
-struct Qdisc noqueue_qdisc =
-{
-	.enqueue	= NULL,
-	.dequeue	= noop_dequeue,
-	.flags		= TCQ_F_BUILTIN,
-	.ops		= &noqueue_qdisc_ops,
+struct Qdisc noqueue_qdisc = {
+	.enqueue	=	NULL,
+	.dequeue	=	noop_dequeue,
+	.flags		=	TCQ_F_BUILTIN,
+	.ops		=	&noqueue_qdisc_ops,
 };
 
 
@@ -343,19 +339,17 @@
 	return 0;
 }
 
-static struct Qdisc_ops pfifo_fast_ops =
-{
-	.next		= NULL,
-	.cl_ops		= NULL,
-	.id		= "pfifo_fast",
-	.priv_size	= 3 * sizeof(struct sk_buff_head),
-
-	.enqueue	= pfifo_fast_enqueue,
-	.dequeue	= pfifo_fast_dequeue,
-	.requeue	= pfifo_fast_requeue,
-
-	.init		= pfifo_fast_init,
-	.reset		= pfifo_fast_reset,
+static struct Qdisc_ops pfifo_fast_ops = {
+	.next		=	NULL,
+	.cl_ops		=	NULL,
+	.id		=	"pfifo_fast",
+	.priv_size	=	3 * sizeof(struct sk_buff_head),
+	.enqueue	=	pfifo_fast_enqueue,
+	.dequeue	=	pfifo_fast_dequeue,
+	.requeue	=	pfifo_fast_requeue,
+	.init		=	pfifo_fast_init,
+	.reset		=	pfifo_fast_reset,
+	.owner		=	THIS_MODULE,
 };
 
 struct Qdisc * qdisc_create_dflt(struct net_device *dev, struct Qdisc_ops *ops)
@@ -422,6 +416,7 @@
 		ops->reset(qdisc);
 	if (ops->destroy)
 		ops->destroy(qdisc);
+	module_put(ops->owner);
 	if (!(qdisc->flags&TCQ_F_BUILTIN))
 		kfree(qdisc);
 }
diff -Nru a/net/sched/sch_gred.c b/net/sched/sch_gred.c
--- a/net/sched/sch_gred.c	Wed Apr 30 22:28:16 2003
+++ b/net/sched/sch_gred.c	Wed Apr 30 22:28:16 2003
@@ -348,7 +348,6 @@
 		table->grio=sopt->grio; 
 		table->initd=0;
 		/* probably need to clear all the table DP entries as well */
-		MOD_INC_USE_COUNT;
 		return 0;
 	    }
 
@@ -490,7 +489,6 @@
 		table->def=sopt->def_DP; 
 		table->grio=sopt->grio; 
 		table->initd=0;
-		MOD_INC_USE_COUNT;
 		return 0;
 	}
 
@@ -602,27 +600,23 @@
 		if (table->tab[i])
 			kfree(table->tab[i]);
 	}
-	MOD_DEC_USE_COUNT;
 }
 
-struct Qdisc_ops gred_qdisc_ops =
-{
-	.next		= NULL,
-	.cl_ops		= NULL,
-	.id		= "gred",
-	.priv_size	= sizeof(struct gred_sched),
-
-	.enqueue	= gred_enqueue,
-	.dequeue	= gred_dequeue,
-	.requeue	= gred_requeue,
-	.drop		= gred_drop,
-
-	.init		= gred_init,
-	.reset		= gred_reset,
-	.destroy	= gred_destroy,
-	.change		= gred_change,
-
-	.dump		= gred_dump,
+struct Qdisc_ops gred_qdisc_ops = {
+	.next		=	NULL,
+	.cl_ops		=	NULL,
+	.id		=	"gred",
+	.priv_size	=	sizeof(struct gred_sched),
+	.enqueue	=	gred_enqueue,
+	.dequeue	=	gred_dequeue,
+	.requeue	=	gred_requeue,
+	.drop		=	gred_drop,
+	.init		=	gred_init,
+	.reset		=	gred_reset,
+	.destroy	=	gred_destroy,
+	.change		=	gred_change,
+	.dump		=	gred_dump,
+	.owner		=	THIS_MODULE,
 };
 
 
diff -Nru a/net/sched/sch_htb.c b/net/sched/sch_htb.c
--- a/net/sched/sch_htb.c	Wed Apr 30 22:28:11 2003
+++ b/net/sched/sch_htb.c	Wed Apr 30 22:28:11 2003
@@ -765,7 +765,7 @@
 #endif
 
 /**
- * htb_charge_class - charges ammount "bytes" to leaf and ancestors
+ * htb_charge_class - charges amount "bytes" to leaf and ancestors
  *
  * Routine assumes that packet "bytes" long was dequeued from leaf cl
  * borrowing from "level". It accounts bytes to ceil leaky bucket for
@@ -1167,7 +1167,6 @@
 		q->rate2quantum = 1;
 	q->defcls = gopt->defcls;
 
-	MOD_INC_USE_COUNT;
 	return 0;
 }
 
@@ -1352,7 +1351,6 @@
 
 	htb_destroy_filters(&q->filter_list);
 	__skb_queue_purge(&q->direct_queue);
-	MOD_DEC_USE_COUNT;
 }
 
 static int htb_delete(struct Qdisc *sch, unsigned long arg)
@@ -1588,41 +1586,35 @@
 	}
 }
 
-static struct Qdisc_class_ops htb_class_ops =
-{
-    htb_graft,
-    htb_leaf,
-    htb_get,
-    htb_put,
-    htb_change_class,
-    htb_delete,
-    htb_walk,
-
-    htb_find_tcf,
-    htb_bind_filter,
-    htb_unbind_filter,
-
-    htb_dump_class,
+static struct Qdisc_class_ops htb_class_ops = {
+	.graft		=	htb_graft,
+	.leaf		=	htb_leaf,
+	.get		=	htb_get,
+	.put		=	htb_put,
+	.change		=	htb_change_class,
+	.delete		=	htb_delete,
+	.walk		=	htb_walk,
+	.tcf_chain	=	htb_find_tcf,
+	.bind_tcf	=	htb_bind_filter,
+	.unbind_tcf	=	htb_unbind_filter,
+	.dump		=	htb_dump_class,
 };
 
-struct Qdisc_ops htb_qdisc_ops =
-{
-    NULL,
-    &htb_class_ops,
-    "htb",
-    sizeof(struct htb_sched),
-
-    htb_enqueue,
-    htb_dequeue,
-    htb_requeue,
-    htb_drop,
-
-    htb_init,
-    htb_reset,
-    htb_destroy,
-    NULL /* htb_change */,
-
-    htb_dump,
+struct Qdisc_ops htb_qdisc_ops = {
+	.next		=	NULL,
+	.cl_ops		=	&htb_class_ops,
+	.id		=	"htb",
+	.priv_size	=	sizeof(struct htb_sched),
+	.enqueue	=	htb_enqueue,
+	.dequeue	=	htb_dequeue,
+	.requeue	=	htb_requeue,
+	.drop		=	htb_drop,
+	.init		=	htb_init,
+	.reset		=	htb_reset,
+	.destroy	=	htb_destroy,
+	.change		=	NULL /* htb_change */,
+	.dump		=	htb_dump,
+	.owner		=	THIS_MODULE,
 };
 
 #ifdef MODULE
diff -Nru a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c
--- a/net/sched/sch_ingress.c	Wed Apr 30 22:28:15 2003
+++ b/net/sched/sch_ingress.c	Wed Apr 30 22:28:15 2003
@@ -45,7 +45,7 @@
 
 /* Thanks to Doron Oz for this hack
 */
-static int nf_registered = 0; 
+static int nf_registered; 
 
 struct ingress_qdisc_data {
 	struct Qdisc		*q;
@@ -237,13 +237,12 @@
 }
 
 /* after ipt_filter */
-static struct nf_hook_ops ing_ops =
-{
-	{ NULL, NULL},
-	ing_hook,
-	PF_INET,
-	NF_IP_PRE_ROUTING,
-	NF_IP_PRI_FILTER + 1
+static struct nf_hook_ops ing_ops = {
+	.hook           = ing_hook,
+	.owner		= THIS_MODULE,
+	.pf             = PF_INET,
+	.hooknum        = NF_IP_PRE_ROUTING,
+	.priority       = NF_IP_PRI_FILTER + 1,
 };
 
 int ingress_init(struct Qdisc *sch,struct rtattr *opt)
@@ -254,7 +253,7 @@
 		if (nf_register_hook(&ing_ops) < 0) {
 			printk("ingress qdisc registration error \n");
 			goto error;
-			}
+		}
 		nf_registered++;
 	}
 
@@ -262,7 +261,6 @@
 	memset(p, 0, sizeof(*p));
 	p->filter_list = NULL;
 	p->q = &noop_qdisc;
-	MOD_INC_USE_COUNT;
 	return 0;
 error:
 	return -EINVAL;
@@ -308,9 +306,6 @@
 /* for future use */
 	qdisc_destroy(p->q);
 #endif
- 
-	MOD_DEC_USE_COUNT;
-
 }
 
 
@@ -329,41 +324,35 @@
 	return -1;
 }
 
-static struct Qdisc_class_ops ingress_class_ops =
-{
-	.graft		= ingress_graft,
-	.leaf		= ingress_leaf,
-	.get		= ingress_get,
-	.put		= ingress_put,
-	.change		= ingress_change,
-	.delete		= NULL,
-	.walk		= ingress_walk,
-
-	.tcf_chain	= ingress_find_tcf,
-	.bind_tcf	= ingress_bind_filter,
-	.unbind_tcf	= ingress_put,
-
-	.dump		= NULL,
+static struct Qdisc_class_ops ingress_class_ops = {
+	.graft		=	ingress_graft,
+	.leaf		=	ingress_leaf,
+	.get		=	ingress_get,
+	.put		=	ingress_put,
+	.change		=	ingress_change,
+	.delete		=	NULL,
+	.walk		=	ingress_walk,
+	.tcf_chain	=	ingress_find_tcf,
+	.bind_tcf	=	ingress_bind_filter,
+	.unbind_tcf	=	ingress_put,
+	.dump		=	NULL,
 };
 
-struct Qdisc_ops ingress_qdisc_ops =
-{
-	.next		= NULL,
-	.cl_ops		= &ingress_class_ops,
-	.id		= "ingress",
-	.priv_size	= sizeof(struct ingress_qdisc_data),
-
-	.enqueue	= ingress_enqueue,
-	.dequeue	= ingress_dequeue,
-	.requeue	= ingress_requeue,
-	.drop		= ingress_drop,
-
-	.init		= ingress_init,
-	.reset		= ingress_reset,
-	.destroy	= ingress_destroy,
-	.change		= NULL,
-
-	.dump		= ingress_dump,
+struct Qdisc_ops ingress_qdisc_ops = {
+	.next		=	NULL,
+	.cl_ops		=	&ingress_class_ops,
+	.id		=	"ingress",
+	.priv_size	=	sizeof(struct ingress_qdisc_data),
+	.enqueue	=	ingress_enqueue,
+	.dequeue	=	ingress_dequeue,
+	.requeue	=	ingress_requeue,
+	.drop		=	ingress_drop,
+	.init		=	ingress_init,
+	.reset		=	ingress_reset,
+	.destroy	=	ingress_destroy,
+	.change		=	NULL,
+	.dump		=	ingress_dump,
+	.owner		=	THIS_MODULE,
 };
 
 
diff -Nru a/net/sched/sch_prio.c b/net/sched/sch_prio.c
--- a/net/sched/sch_prio.c	Wed Apr 30 22:28:08 2003
+++ b/net/sched/sch_prio.c	Wed Apr 30 22:28:08 2003
@@ -169,7 +169,6 @@
 		qdisc_destroy(q->queues[prio]);
 		q->queues[prio] = &noop_qdisc;
 	}
-	MOD_DEC_USE_COUNT;
 }
 
 static int prio_tune(struct Qdisc *sch, struct rtattr *opt)
@@ -233,7 +232,6 @@
 		if ((err= prio_tune(sch, opt)) != 0)
 			return err;
 	}
-	MOD_INC_USE_COUNT;
 	return 0;
 }
 
@@ -369,42 +367,35 @@
 	return &q->filter_list;
 }
 
-static struct Qdisc_class_ops prio_class_ops =
-{
-	.graft		= prio_graft,
-	.leaf		= prio_leaf,
-
-	.get		= prio_get,
-	.put		= prio_put,
-	.change		= prio_change,
-	.delete		= prio_delete,
-	.walk		= prio_walk,
-
-	.tcf_chain	= prio_find_tcf,
-	.bind_tcf	= prio_bind,
-	.unbind_tcf	= prio_put,
-
-	.dump		= prio_dump_class,
+static struct Qdisc_class_ops prio_class_ops = {
+	.graft		=	prio_graft,
+	.leaf		=	prio_leaf,
+	.get		=	prio_get,
+	.put		=	prio_put,
+	.change		=	prio_change,
+	.delete		=	prio_delete,
+	.walk		=	prio_walk,
+	.tcf_chain	=	prio_find_tcf,
+	.bind_tcf	=	prio_bind,
+	.unbind_tcf	=	prio_put,
+	.dump		=	prio_dump_class,
 };
 
-struct Qdisc_ops prio_qdisc_ops =
-{
-	.next		= NULL,
-	.cl_ops		= &prio_class_ops,
-	.id		= "prio",
-	.priv_size	= sizeof(struct prio_sched_data),
-
-	.enqueue	= prio_enqueue,
-	.dequeue	= prio_dequeue,
-	.requeue	= prio_requeue,
-	.drop		= prio_drop,
-
-	.init		= prio_init,
-	.reset		= prio_reset,
-	.destroy	= prio_destroy,
-	.change		= prio_tune,
-
-	.dump		= prio_dump,
+struct Qdisc_ops prio_qdisc_ops = {
+	.next		=	NULL,
+	.cl_ops		=	&prio_class_ops,
+	.id		=	"prio",
+	.priv_size	=	sizeof(struct prio_sched_data),
+	.enqueue	=	prio_enqueue,
+	.dequeue	=	prio_dequeue,
+	.requeue	=	prio_requeue,
+	.drop		=	prio_drop,
+	.init		=	prio_init,
+	.reset		=	prio_reset,
+	.destroy	=	prio_destroy,
+	.change		=	prio_tune,
+	.dump		=	prio_dump,
+	.owner		=	THIS_MODULE,
 };
 
 #ifdef MODULE
diff -Nru a/net/sched/sch_red.c b/net/sched/sch_red.c
--- a/net/sched/sch_red.c	Wed Apr 30 22:28:19 2003
+++ b/net/sched/sch_red.c	Wed Apr 30 22:28:19 2003
@@ -61,7 +61,7 @@
 
 	avg = (1-W)*avg + W*current_queue_len,
 
-	W is the filter time constant (choosen as 2^(-Wlog)), it controls
+	W is the filter time constant (chosen as 2^(-Wlog)), it controls
 	the inertia of the algorithm. To allow larger bursts, W should be
 	decreased.
 
@@ -407,14 +407,7 @@
 
 static int red_init(struct Qdisc* sch, struct rtattr *opt)
 {
-	int err;
-
-	MOD_INC_USE_COUNT;
-
-	if ((err = red_change(sch, opt)) != 0) {
-		MOD_DEC_USE_COUNT;
-	}
-	return err;
+	return red_change(sch, opt);
 }
 
 
@@ -458,27 +451,23 @@
 
 static void red_destroy(struct Qdisc *sch)
 {
-	MOD_DEC_USE_COUNT;
 }
 
-struct Qdisc_ops red_qdisc_ops =
-{
-	.next		= NULL,
-	.cl_ops		= NULL,
-	.id		= "red",
-	.priv_size	= sizeof(struct red_sched_data),
-
-	.enqueue	= red_enqueue,
-	.dequeue	= red_dequeue,
-	.requeue	= red_requeue,
-	.drop		= red_drop,
-
-	.init		= red_init,
-	.reset		= red_reset,
-	.destroy	= red_destroy,
-	.change		= red_change,
-
-	.dump		= red_dump,
+struct Qdisc_ops red_qdisc_ops = {
+	.next		=	NULL,
+	.cl_ops		=	NULL,
+	.id		=	"red",
+	.priv_size	=	sizeof(struct red_sched_data),
+	.enqueue	=	red_enqueue,
+	.dequeue	=	red_dequeue,
+	.requeue	=	red_requeue,
+	.drop		=	red_drop,
+	.init		=	red_init,
+	.reset		=	red_reset,
+	.destroy	=	red_destroy,
+	.change		=	red_change,
+	.dump		=	red_dump,
+	.owner		=	THIS_MODULE,
 };
 
 
diff -Nru a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
--- a/net/sched/sch_sfq.c	Wed Apr 30 22:28:17 2003
+++ b/net/sched/sch_sfq.c	Wed Apr 30 22:28:17 2003
@@ -431,7 +431,6 @@
 	}
 	for (i=0; i<SFQ_DEPTH; i++)
 		sfq_link(q, i);
-	MOD_INC_USE_COUNT;
 	return 0;
 }
 
@@ -439,7 +438,6 @@
 {
 	struct sfq_sched_data *q = (struct sfq_sched_data *)sch->data;
 	del_timer(&q->perturb_timer);
-	MOD_DEC_USE_COUNT;
 }
 
 static int sfq_dump(struct Qdisc *sch, struct sk_buff *skb)
@@ -464,24 +462,21 @@
 	return -1;
 }
 
-struct Qdisc_ops sfq_qdisc_ops =
-{
-	.next		= NULL,
-	.cl_ops		= NULL,
-	.id		= "sfq",
-	.priv_size	= sizeof(struct sfq_sched_data),
-
-	.enqueue	= sfq_enqueue,
-	.dequeue	= sfq_dequeue,
-	.requeue	= sfq_requeue,
-	.drop		= sfq_drop,
-
-	.init		= sfq_init,
-	.reset		= sfq_reset,
-	.destroy	= sfq_destroy,
-	.change		= NULL,
-
-	.dump		= sfq_dump,
+struct Qdisc_ops sfq_qdisc_ops = {
+	.next		=	NULL,
+	.cl_ops		=	NULL,
+	.id		=	"sfq",
+	.priv_size	=	sizeof(struct sfq_sched_data),
+	.enqueue	=	sfq_enqueue,
+	.dequeue	=	sfq_dequeue,
+	.requeue	=	sfq_requeue,
+	.drop		=	sfq_drop,
+	.init		=	sfq_init,
+	.reset		=	sfq_reset,
+	.destroy	=	sfq_destroy,
+	.change		=	NULL,
+	.dump		=	sfq_dump,
+	.owner		=	THIS_MODULE,
 };
 
 #ifdef MODULE
diff -Nru a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
--- a/net/sched/sch_tbf.c	Wed Apr 30 22:28:04 2003
+++ b/net/sched/sch_tbf.c	Wed Apr 30 22:28:04 2003
@@ -330,23 +330,17 @@
 
 static int tbf_init(struct Qdisc* sch, struct rtattr *opt)
 {
-	int err;
 	struct tbf_sched_data *q = (struct tbf_sched_data *)sch->data;
 	
 	if (opt == NULL)
 		return -EINVAL;
 	
-	MOD_INC_USE_COUNT;
-	
 	PSCHED_GET_TIME(q->t_c);
 	init_timer(&q->wd_timer);
 	q->wd_timer.function = tbf_watchdog;
 	q->wd_timer.data = (unsigned long)sch;
 	
-	if ((err = tbf_change(sch, opt)) != 0) {
-		MOD_DEC_USE_COUNT;
-	}
-	return err;
+	return tbf_change(sch, opt);
 }
 
 static void tbf_destroy(struct Qdisc *sch)
@@ -359,8 +353,6 @@
 		qdisc_put_rtab(q->P_tab);
 	if (q->R_tab)
 		qdisc_put_rtab(q->R_tab);
-
-	MOD_DEC_USE_COUNT;
 }
 
 static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb)
@@ -391,24 +383,20 @@
 	return -1;
 }
 
-struct Qdisc_ops tbf_qdisc_ops =
-{
-	.next		= NULL,
-	.cl_ops		= NULL,
-	.id		= "tbf",
-	.priv_size	= sizeof(struct tbf_sched_data),
-
-	.enqueue	= tbf_enqueue,
-	.dequeue	= tbf_dequeue,
-	.requeue	= tbf_requeue,
-	.drop		= tbf_drop,
-
-	.init		= tbf_init,
-	.reset		= tbf_reset,
-	.destroy	= tbf_destroy,
-	.change		= tbf_change,
-
-	.dump		= tbf_dump,
+struct Qdisc_ops tbf_qdisc_ops = {
+	.next		=	NULL,
+	.cl_ops		=	NULL,
+	.id		=	"tbf",
+	.priv_size	=	sizeof(struct tbf_sched_data),
+	.enqueue	=	tbf_enqueue,
+	.dequeue	=	tbf_dequeue,
+	.requeue	=	tbf_requeue,
+	.drop		=	tbf_drop,
+	.init		=	tbf_init,
+	.reset		=	tbf_reset,
+	.destroy	=	tbf_destroy,
+	.change		=	tbf_change,
+	.dump		=	tbf_dump,
 };
 
 
diff -Nru a/net/sched/sch_teql.c b/net/sched/sch_teql.c
--- a/net/sched/sch_teql.c	Wed Apr 30 22:28:05 2003
+++ b/net/sched/sch_teql.c	Wed Apr 30 22:28:05 2003
@@ -177,8 +177,6 @@
 				
 		} while ((prev = q) != master->slaves);
 	}
-
-	MOD_DEC_USE_COUNT;
 }
 
 static int teql_qdisc_init(struct Qdisc *sch, struct rtattr *opt)
@@ -222,8 +220,6 @@
 		m->dev.mtu = dev->mtu;
 		m->dev.flags = (m->dev.flags&~FMASK)|(dev->flags&FMASK);
 	}
-	
-	MOD_INC_USE_COUNT;
 	return 0;
 }
 
@@ -386,14 +382,12 @@
 	m->dev.mtu = mtu;
 	m->dev.flags = (m->dev.flags&~FMASK) | flags;
 	netif_start_queue(&m->dev);
-	MOD_INC_USE_COUNT;
 	return 0;
 }
 
 static int teql_master_close(struct net_device *dev)
 {
 	netif_stop_queue(dev);
-	MOD_DEC_USE_COUNT;
 	return 0;
 }
 
@@ -440,20 +434,19 @@
 
 static struct teql_master the_master = {
 {
-	.next		= NULL,
-	.cl_ops		= NULL,
-	.id		= "",
-	.priv_size	= sizeof(struct teql_sched_data),
-
-	.enqueue	= teql_enqueue,
-	.dequeue	= teql_dequeue,
-	.requeue	= teql_requeue,
-	.drop		= NULL,
-
-	.init		= teql_qdisc_init,
-	.reset		= teql_reset,
-	.destroy	= teql_destroy,
-	.dump		= NULL,
+	.next		=	NULL,
+	.cl_ops		=	NULL,
+	.id		=	"",
+	.priv_size	=	sizeof(struct teql_sched_data),
+	.enqueue	=	teql_enqueue,
+	.dequeue	=	teql_dequeue,
+	.requeue	=	teql_requeue,
+	.drop		=	NULL,
+	.init		=	teql_qdisc_init,
+	.reset		=	teql_reset,
+	.destroy	=	teql_destroy,
+	.dump		=	NULL,
+	.owner		=	THIS_MODULE,
 },};
 
 
@@ -474,6 +467,7 @@
 	memcpy(the_master.qops.id, the_master.dev.name, IFNAMSIZ);
 	the_master.dev.init = teql_master_init;
 
+	SET_MODULE_OWNER(&the_master.dev);
 	err = register_netdevice(&the_master.dev);
 	if (err == 0) {
 		err = register_qdisc(&the_master.qops);
diff -Nru a/net/sctp/adler32.c b/net/sctp/adler32.c
--- a/net/sctp/adler32.c	Wed Apr 30 22:28:15 2003
+++ b/net/sctp/adler32.c	Wed Apr 30 22:28:15 2003
@@ -73,7 +73,7 @@
 
 /* Performance work as shown this pig to be the
  * worst CPU wise guy. I have done what I could think
- * of on my flight to Austrialia but I am sure some
+ * of on my flight to Australia but I am sure some
  * clever assembly could speed this up, but of
  * course this would require the dreaded #ifdef's for
  * architecture. If you can speed this up more, pass
@@ -105,7 +105,7 @@
 		/* first we add */
 		s2 = (s2 + s1);
 
-		/* again, it is more efficent (it seems) to
+		/* again, it is more efficient (it seems) to
 		 * subtract since the most s2 will ever be
 		 * is (BASE-1 + BASE-1) in the worse case.
 		 * This would then be (2 * BASE) - 2, which
diff -Nru a/net/sctp/associola.c b/net/sctp/associola.c
--- a/net/sctp/associola.c	Wed Apr 30 22:28:03 2003
+++ b/net/sctp/associola.c	Wed Apr 30 22:28:03 2003
@@ -88,7 +88,7 @@
 	return NULL;
 }
 
-/* Intialize a new association from provided memory. */
+/* Initialize a new association from provided memory. */
 sctp_association_t *sctp_association_init(sctp_association_t *asoc,
 					  const sctp_endpoint_t *ep,
 					  const struct sock *sk,
diff -Nru a/net/sctp/ipv6.c b/net/sctp/ipv6.c
--- a/net/sctp/ipv6.c	Wed Apr 30 22:28:11 2003
+++ b/net/sctp/ipv6.c	Wed Apr 30 22:28:11 2003
@@ -92,6 +92,7 @@
 void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 		 int type, int code, int offset, __u32 info)
 {
+	struct inet6_dev *idev;
 	struct ipv6hdr *iph = (struct ipv6hdr *)skb->data;
 	struct sctphdr *sh = (struct sctphdr *)(skb->data + offset);
 	struct sock *sk;
@@ -102,6 +103,8 @@
 	char *saveip, *savesctp;
 	int err;
 
+	idev = in6_dev_get(skb->dev);
+
 	/* Fix up skb to look at the embedded net header. */
 	saveip = skb->nh.raw;
 	savesctp  = skb->h.raw;
@@ -112,8 +115,8 @@
 	skb->nh.raw = saveip;
 	skb->h.raw = savesctp;
 	if (!sk) {
-		ICMP6_INC_STATS_BH(Icmp6InErrors);
-		return;
+		ICMP6_INC_STATS_BH(idev, Icmp6InErrors);
+		goto out;
 	}
 
 	/* Warning:  The sock lock is held.  Remember to call 
@@ -139,6 +142,9 @@
 
 out_unlock:
 	sctp_err_finish(sk, ep, asoc);
+out:
+	if (likely(idev != NULL))
+		in6_dev_put(idev);
 }
 
 /* Based on tcp_v6_xmit() in tcp_ipv6.c. */
@@ -836,10 +842,10 @@
 	inet6_register_protosw(&sctpv6_seqpacket_protosw);
 	inet6_register_protosw(&sctpv6_stream_protosw);
 
-	/* Register the SCTP specfic PF_INET6 functions. */
+	/* Register the SCTP specific PF_INET6 functions. */
 	sctp_register_pf(&sctp_pf_inet6_specific, PF_INET6);
 
-	/* Register the SCTP specfic AF_INET6 functions. */
+	/* Register the SCTP specific AF_INET6 functions. */
 	sctp_register_af(&sctp_ipv6_specific);
 
 	/* Register notifier for inet6 address additions/deletions. */
diff -Nru a/net/sctp/protocol.c b/net/sctp/protocol.c
--- a/net/sctp/protocol.c	Wed Apr 30 22:28:11 2003
+++ b/net/sctp/protocol.c	Wed Apr 30 22:28:11 2003
@@ -380,7 +380,7 @@
 
 /* Returns a valid dst cache entry for the given source and destination ip
  * addresses. If an association is passed, trys to get a dst entry with a
- * source adddress that matches an address in the bind address list.
+ * source address that matches an address in the bind address list.
  */
 struct dst_entry *sctp_v4_get_dst(struct sctp_association *asoc,
 				  union sctp_addr *daddr,
diff -Nru a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
--- a/net/sctp/sm_make_chunk.c	Wed Apr 30 22:28:05 2003
+++ b/net/sctp/sm_make_chunk.c	Wed Apr 30 22:28:05 2003
@@ -91,7 +91,7 @@
 	}
 };
 
-/* A helper to initilize to initilize an op error inside a
+/* A helper to initialize to initialize an op error inside a
  * provided chunk, as most cause codes will be embedded inside an
  * abort chunk.
  */
diff -Nru a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
--- a/net/sctp/sm_sideeffect.c	Wed Apr 30 22:28:11 2003
+++ b/net/sctp/sm_sideeffect.c	Wed Apr 30 22:28:11 2003
@@ -635,7 +635,7 @@
 			sk->state_change(sk);
 	}
 
-	/* Change the sk->state of a TCP-style socket that has sucessfully
+	/* Change the sk->state of a TCP-style socket that has successfully
 	 * completed a connect() call.
 	 */
 	if ((SCTP_STATE_ESTABLISHED == asoc->state) &&
diff -Nru a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
--- a/net/sctp/sm_statefuns.c	Wed Apr 30 22:28:04 2003
+++ b/net/sctp/sm_statefuns.c	Wed Apr 30 22:28:04 2003
@@ -445,7 +445,7 @@
 		}
 	}
 
-	/* Tag the variable length paramters.  Note that we never
+	/* Tag the variable length parameters.  Note that we never
 	 * convert the parameters in an INIT chunk.
 	 */
 	chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(sctp_inithdr_t));
@@ -1345,7 +1345,7 @@
  * set to 0 (indicating that no previous TCB existed).  The INIT ACK and
  * State Cookie are populated as specified in section 5.2.1.
  *
- * Verification Tag: Not specifed, but an INIT has no way of knowing
+ * Verification Tag: Not specified, but an INIT has no way of knowing
  * what the verification tag could be, so we ignore it.
  *
  * Inputs
@@ -1505,7 +1505,7 @@
  *     INIT-ACK and finally sent a COOKIE ECHO with the peer's same tag
  *     but a new tag of its own.
  */
-/* This case represents an intialization collision.  */
+/* This case represents an initialization collision.  */
 static sctp_disposition_t sctp_sf_do_dupcook_c(const sctp_endpoint_t *ep,
 					       const sctp_association_t *asoc,
 					       sctp_chunk_t *chunk,
@@ -1526,7 +1526,7 @@
  * D) When both local and remote tags match the endpoint should always
  *    enter the ESTABLISHED state, if it has not already done so.
  */
-/* This case represents an intialization collision.  */
+/* This case represents an initialization collision.  */
 static sctp_disposition_t sctp_sf_do_dupcook_d(const sctp_endpoint_t *ep,
 					       const sctp_association_t *asoc,
 					       sctp_chunk_t *chunk,
diff -Nru a/net/sctp/socket.c b/net/sctp/socket.c
--- a/net/sctp/socket.c	Wed Apr 30 22:28:20 2003
+++ b/net/sctp/socket.c	Wed Apr 30 22:28:20 2003
@@ -2854,7 +2854,7 @@
 	return pp;
 }
 
-/* FIXME: Commments! */
+/* FIXME: Comments! */
 static __inline__ void __sctp_put_port(struct sock *sk)
 {
 	struct sctp_protocol *sctp_proto = sctp_get_protocol();
diff -Nru a/net/sctp/transport.c b/net/sctp/transport.c
--- a/net/sctp/transport.c	Wed Apr 30 22:28:05 2003
+++ b/net/sctp/transport.c	Wed Apr 30 22:28:05 2003
@@ -78,7 +78,7 @@
 	return NULL;
 }
 
-/* Intialize a new transport from provided memory.  */
+/* Initialize a new transport from provided memory.  */
 struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
 					   const union sctp_addr *addr,
 					   int priority)
@@ -171,7 +171,7 @@
 }
 
 /* Start T3_rtx timer if it is not already running and update the heartbeat
- * timer.  This routine is called everytime a DATA chunk is sent.
+ * timer.  This routine is called every time a DATA chunk is sent.
  */
 void sctp_transport_reset_timers(struct sctp_transport *transport)
 {
diff -Nru a/net/socket.c b/net/socket.c
--- a/net/socket.c	Wed Apr 30 22:28:07 2003
+++ b/net/socket.c	Wed Apr 30 22:28:07 2003
@@ -69,8 +69,6 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/wanrouter.h>
-#include <linux/netlink.h>
-#include <linux/rtnetlink.h>
 #include <linux/if_bridge.h>
 #include <linux/init.h>
 #include <linux/poll.h>
@@ -143,6 +141,36 @@
 
 static struct net_proto_family *net_families[NPROTO];
 
+static __inline__ void net_family_bug(int family)
+{
+	printk(KERN_ERR "%d is not yet sock_registered!\n", family);
+	BUG();
+}
+
+int net_family_get(int family)
+{
+	struct net_proto_family *prot = net_families[family];
+	int rc = 1;
+
+	barrier();
+	if (likely(prot != NULL))
+		rc = try_module_get(prot->owner);
+	else
+		net_family_bug(family);
+	return rc;
+}
+
+void net_family_put(int family)
+{
+	struct net_proto_family *prot = net_families[family];
+
+	barrier();
+	if (likely(prot != NULL))
+		module_put(prot->owner);
+	else
+		net_family_bug(family);
+}
+
 #if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
 static atomic_t net_family_lockct = ATOMIC_INIT(0);
 static spinlock_t net_family_lock = SPIN_LOCK_UNLOCKED;
@@ -506,8 +534,13 @@
  
 void sock_release(struct socket *sock)
 {
-	if (sock->ops) 
+	if (sock->ops) {
+		const int family = sock->ops->family;
+
 		sock->ops->release(sock);
+		sock->ops = NULL;
+		net_family_put(family);
+	}
 
 	if (sock->fasync_list)
 		printk(KERN_ERR "sock_release: fasync list not empty!\n");
@@ -1058,11 +1091,12 @@
 
 	sock->type  = type;
 
+	i = -EAFNOSUPPORT;
+	if (!net_family_get(family))
+		goto out_release;
+
 	if ((i = net_families[family]->create(sock, protocol)) < 0) 
-	{
-		sock_release(sock);
-		goto out;
-	}
+		goto out_release;
 
 	*res = sock;
 	security_socket_post_create(sock, family, type, protocol);
@@ -1070,6 +1104,9 @@
 out:
 	net_family_read_unlock();
 	return i;
+out_release:
+	sock_release(sock);
+	goto out;
 }
 
 asmlinkage long sys_socket(int family, int type, int protocol)
@@ -1251,24 +1288,28 @@
 	if (err)
 		goto out_release;
 
+	err = -EAFNOSUPPORT;
+	if (!net_family_get(sock->ops->family))
+		goto out_release;
+
 	err = sock->ops->accept(sock, newsock, sock->file->f_flags);
 	if (err < 0)
-		goto out_release;
+		goto out_family_put;
 
 	if (upeer_sockaddr) {
 		if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
 			err = -ECONNABORTED;
-			goto out_release;
+			goto out_family_put;
 		}
 		err = move_addr_to_user(address, len, upeer_sockaddr, upeer_addrlen);
 		if (err < 0)
-			goto out_release;
+			goto out_family_put;
 	}
 
 	/* File flags are not inherited via accept() unlike another OSes. */
 
 	if ((err = sock_map_fd(newsock)) < 0)
-		goto out_release;
+		goto out_family_put;
 
 	security_socket_post_accept(sock, newsock);
 
@@ -1276,7 +1317,8 @@
 	sockfd_put(sock);
 out:
 	return err;
-
+out_family_put:
+	net_family_put(sock->ops->family);
 out_release:
 	sock_release(newsock);
 	goto out_put;
@@ -1944,17 +1986,6 @@
 	 *  do_initcalls is run.  
 	 */
 
-
-	/*
-	 * The netlink device handler may be needed early.
-	 */
-
-#ifdef CONFIG_NET
-	rtnetlink_init();
-#endif
-#ifdef CONFIG_NETLINK_DEV
-	init_netlink();
-#endif
 #ifdef CONFIG_NETFILTER
 	netfilter_init();
 #endif
diff -Nru a/net/sunrpc/cache.c b/net/sunrpc/cache.c
--- a/net/sunrpc/cache.c	Wed Apr 30 22:28:10 2003
+++ b/net/sunrpc/cache.c	Wed Apr 30 22:28:10 2003
@@ -477,7 +477,7 @@
  *
  * Implemented by linked list of requests.  Each open file has 
  * a ->private that also exists in this list.  New request are added
- * to the end and may wakeup and preceeding readers.
+ * to the end and may wakeup and preceding readers.
  * New readers are added to the head.  If, on read, an item is found with
  * CACHE_UPCALLING clear, we free it from the list.
  *
diff -Nru a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
--- a/net/sunrpc/rpc_pipe.c	Wed Apr 30 22:28:07 2003
+++ b/net/sunrpc/rpc_pipe.c	Wed Apr 30 22:28:07 2003
@@ -29,7 +29,6 @@
 #include <linux/sunrpc/rpc_pipe_fs.h>
 
 static struct vfsmount *rpc_mount;
-static spinlock_t rpc_mount_lock = SPIN_LOCK_UNLOCKED;
 static int rpc_mount_count;
 
 static struct file_system_type rpc_pipe_fs_type;
@@ -379,46 +378,13 @@
 static int
 rpc_get_mount(void)
 {
-	struct vfsmount * mnt = NULL;
-
-	spin_lock(&rpc_mount_lock);
-	if (rpc_mount)
-		goto out_get;
-	spin_unlock(&rpc_mount_lock);
-	mnt = kern_mount(&rpc_pipe_fs_type);
-	if (IS_ERR(mnt))
-		return -ENODEV;
-	spin_lock(&rpc_mount_lock);
-	if (!rpc_mount) {
-		rpc_mount = mnt;
-		mnt = NULL;
-		goto out_dontget;
-	}
-out_get:
-	mntget(rpc_mount);
-out_dontget:
-	++rpc_mount_count;
-	spin_unlock(&rpc_mount_lock);
-	if (mnt)
-		mntput(mnt);
-	return 0;
+	return simple_pin_fs("rpc_pipefs", &rpc_mount, &rpc_mount_count);
 }
 
 static void
 rpc_put_mount(void)
 {
-	struct vfsmount *mnt;
-
-	spin_lock(&rpc_mount_lock);
-	mnt = rpc_mount;
-	--rpc_mount_count;
-	if (rpc_mount_count == 0)
-		rpc_mount = NULL;
-	else
-		mnt = NULL;
-	spin_unlock(&rpc_mount_lock);
-	if (mnt)
-		mntput(mnt);
+	simple_release_fs(&rpc_mount, &rpc_mount_count);
 }
 
 static int
diff -Nru a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
--- a/net/sunrpc/svcsock.c	Wed Apr 30 22:28:04 2003
+++ b/net/sunrpc/svcsock.c	Wed Apr 30 22:28:04 2003
@@ -1469,7 +1469,7 @@
 }
 
 /*
- * recv data from a defered request into an active one
+ * recv data from a deferred request into an active one
  */
 static int svc_deferred_recv(struct svc_rqst *rqstp)
 {
diff -Nru a/net/unix/af_unix.c b/net/unix/af_unix.c
--- a/net/unix/af_unix.c	Wed Apr 30 22:28:11 2003
+++ b/net/unix/af_unix.c	Wed Apr 30 22:28:11 2003
@@ -47,6 +47,9 @@
  *	     Alexey Kuznetsov   :	Full scale SMP. Lot of bugs are introduced 8)
  *	      Malcolm Beattie   :	Set peercred for socketpair
  *	     Michal Ostrowski   :       Module initialization cleanup.
+ *	     Arnaldo C. Melo	:	Remove MOD_{INC,DEC}_USE_COUNT,
+ *	     				the core infrastructure is doing that
+ *	     				for all net proto families now (2.5.69+)
  *
  *
  * Known differences from reference BSD that was tested:
@@ -360,7 +363,6 @@
 #ifdef UNIX_REFCNT_DEBUG
 	printk(KERN_DEBUG "UNIX %p is destroyed, %d are still alive.\n", sk, atomic_read(&unix_nr_socks));
 #endif
-	MOD_DEC_USE_COUNT;
 }
 
 static int unix_release_sock (unix_socket *sk, int embrion)
@@ -478,19 +480,16 @@
 
 static struct sock * unix_create1(struct socket *sock)
 {
-	struct sock *sk;
+	struct sock *sk = NULL;
 	struct unix_sock *u;
 
 	if (atomic_read(&unix_nr_socks) >= 2*files_stat.max_files)
-		return NULL;
+		goto out;
 
-	MOD_INC_USE_COUNT;
 	sk = sk_alloc(PF_UNIX, GFP_KERNEL, sizeof(struct unix_sock),
 		      unix_sk_cachep);
-	if (!sk) {
-		MOD_DEC_USE_COUNT;
-		return NULL;
-	}
+	if (!sk)
+		goto out;
 
 	atomic_inc(&unix_nr_socks);
 
@@ -509,7 +508,7 @@
 	init_MUTEX(&u->readsem); /* single task reading lock */
 	init_waitqueue_head(&u->peer_wait);
 	unix_insert_socket(&unix_sockets_unbound, sk);
-
+out:
 	return sk;
 }
 
@@ -1513,7 +1512,7 @@
 		   - do not return fds - good, but too simple 8)
 		   - return fds, and do not return them on read (old strategy,
 		     apparently wrong)
-		   - clone fds (I choosed it for now, it is the most universal
+		   - clone fds (I chose it for now, it is the most universal
 		     solution)
 		
 	           POSIX 1003.1g does not actually define this clearly
@@ -1928,6 +1927,7 @@
 struct net_proto_family unix_family_ops = {
 	.family = PF_UNIX,
 	.create = unix_create,
+	.owner	= THIS_MODULE,
 };
 
 #ifdef CONFIG_SYSCTL
diff -Nru a/net/wanrouter/af_wanpipe.c b/net/wanrouter/af_wanpipe.c
--- a/net/wanrouter/af_wanpipe.c	Wed Apr 30 22:28:18 2003
+++ b/net/wanrouter/af_wanpipe.c	Wed Apr 30 22:28:18 2003
@@ -113,7 +113,7 @@
  *      function, wanpipe_rcv() to queue the incoming packets
  *      into an AF_WANPIPE socket queue.  Based on wanpipe_rcv()
  *      return code, the driver knows whether the packet was
- *      sucessfully queued.  If the socket queue is full, 
+ *      successfully queued.  If the socket queue is full, 
  *      protocol flow control is used by the driver, if any, 
  *      to slow down the traffic until the sock queue is free.
  *
@@ -217,7 +217,7 @@
  *
  *	Wanpipe socket bottom half handler.  This function
  *      is called by the WANPIPE device drivers to queue a
- *      incomming packet into the socket receive queue. 
+ *      incoming packet into the socket receive queue. 
  *      Once the packet is queued, all processes waiting to 
  *      read are woken up.
  *
@@ -298,7 +298,7 @@
  *
  *	Wanpipe LISTEN socket bottom half handler.  This function
  *      is called by the WANPIPE device drivers to queue an
- *      incomming call into the socket listening queue. 
+ *      incoming call into the socket listening queue. 
  *      Once the packet is queued, the waiting accept() process 
  *      is woken up.
  *
@@ -509,8 +509,6 @@
 	wan_opt->tx_timer.data	   = (unsigned long)sk;
 	wan_opt->tx_timer.function = wanpipe_delayed_transmit;
 
-	MOD_INC_USE_COUNT;
-
 	sock_init_data(NULL, sk);
 	return sk;
 }
@@ -739,7 +737,7 @@
  *
  *	Execute x25api commands.  The atomic variable
  *      chan->command is used to indicate to the driver that
- *      command is pending for exection.  The acutal command
+ *      command is pending for execution.  The acutal command
  *      structure is placed into a sock mbox structure 
  *      (wp_sk(sk)->mbox).
  *
@@ -846,7 +844,6 @@
 		}
 		sock_put(sk);
 		atomic_dec(&wanpipe_socks_nr);
-		MOD_DEC_USE_COUNT;
 		return;
 	}
 
@@ -1032,7 +1029,6 @@
 	}
 	sock_put(sk);
 	atomic_dec(&wanpipe_socks_nr);
-	MOD_DEC_USE_COUNT;
 	return 0;
 }
 
@@ -1135,7 +1131,7 @@
 	if (!sk)
 		return;
 
-	/* This functin can be called from interrupt. We must use
+	/* This function can be called from interrupt. We must use
 	 * appropriate locks */
 	
 	if (test_bit(1,&wanpipe_tx_critical)){
@@ -1197,7 +1193,6 @@
 	}
 	sock_put(sk);
 	atomic_dec(&wanpipe_socks_nr);
-	MOD_DEC_USE_COUNT;
 	return;
 }
 
@@ -1209,7 +1204,7 @@
 	if (!sk)
 		return;
 
-	/* This functin can be called from interrupt. We must use
+	/* This function can be called from interrupt. We must use
 	 * appropriate locks */
 	
 	write_lock(&wanpipe_sklist_lock);
@@ -1237,7 +1232,6 @@
 	}
 	sock_put(sk);
 	atomic_dec(&wanpipe_socks_nr);
-	MOD_DEC_USE_COUNT;
 	return;
 }
 
@@ -1262,8 +1256,6 @@
 	}
 	sock_put(sk);
 	atomic_dec(&wanpipe_socks_nr);
-	MOD_DEC_USE_COUNT;
-	return;
 }
 
 
@@ -2579,6 +2571,7 @@
 static struct net_proto_family wanpipe_family_ops = {
 	.family = PF_WANPIPE,
 	.create = wanpipe_create,
+	.owner	= THIS_MODULE,
 };
 
 struct notifier_block wanpipe_netdev_notifier = {
diff -Nru a/net/x25/af_x25.c b/net/x25/af_x25.c
--- a/net/x25/af_x25.c	Wed Apr 30 22:28:17 2003
+++ b/net/x25/af_x25.c	Wed Apr 30 22:28:17 2003
@@ -359,10 +359,8 @@
 		sk->timer.function = x25_destroy_timer;
 		sk->timer.data     = (unsigned long)sk;
 		add_timer(&sk->timer);
-	} else {
+	} else
 		sk_free(sk);
-		MOD_DEC_USE_COUNT;
-	}
 	release_sock(sk);
 	sock_put(sk);
 }
@@ -442,13 +440,11 @@
 
 static struct sock *x25_alloc_socket(void)
 {
-	struct sock *sk;
 	struct x25_opt *x25;
+	struct sock *sk = sk_alloc(AF_X25, GFP_ATOMIC, 1, NULL);
 
-	MOD_INC_USE_COUNT;
-
-	if ((sk = sk_alloc(AF_X25, GFP_ATOMIC, 1, NULL)) == NULL)
-		goto decmod;
+	if (!sk)
+		goto out;
 
 	x25 = x25_sk(sk) = kmalloc(sizeof(*x25), GFP_ATOMIC);
 	if (!x25)
@@ -469,8 +465,6 @@
 frees:
 	sk_free(sk);
 	sk = NULL;
-decmod:
-	MOD_DEC_USE_COUNT;
 	goto out;
 }
 
@@ -1324,6 +1318,7 @@
 struct net_proto_family x25_family_ops = {
 	.family =	AF_X25,
 	.create =	x25_create,
+	.owner	=	THIS_MODULE,
 };
 
 static struct proto_ops SOCKOPS_WRAPPED(x25_proto_ops) = {
diff -Nru a/scripts/modpost.c b/scripts/modpost.c
--- a/scripts/modpost.c	Wed Apr 30 22:28:05 2003
+++ b/scripts/modpost.c	Wed Apr 30 22:28:05 2003
@@ -404,9 +404,7 @@
 	buf_printf(b, "#include <linux/vermagic.h>\n");
 	buf_printf(b, "#include <linux/compiler.h>\n");
 	buf_printf(b, "\n");
-	buf_printf(b, "const char vermagic[]\n");
-	buf_printf(b, "__attribute__((section(\"__vermagic\"))) =\n");
-	buf_printf(b, "VERMAGIC_STRING;\n");
+	buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
 }
 
 /* Record CRCs for unresolved symbols */
diff -Nru a/sound/core/sgbuf.c b/sound/core/sgbuf.c
--- a/sound/core/sgbuf.c	Wed Apr 30 22:28:12 2003
+++ b/sound/core/sgbuf.c	Wed Apr 30 22:28:12 2003
@@ -85,7 +85,7 @@
 	}
 
 	sgbuf->size = size;
-	dmab->area = vmap(sgbuf->page_table, sgbuf->pages);
+	dmab->area = vmap(sgbuf->page_table, sgbuf->pages, VM_MAP, PAGE_KERNEL);
 	if (! dmab->area)
 		goto _failed;
 	return dmab->area;
diff -Nru a/sound/core/sound.c b/sound/core/sound.c
--- a/sound/core/sound.c	Wed Apr 30 22:28:12 2003
+++ b/sound/core/sound.c	Wed Apr 30 22:28:12 2003
@@ -68,10 +68,6 @@
 
 static DECLARE_MUTEX(sound_mutex);
 
-#ifdef CONFIG_DEVFS_FS
-static devfs_handle_t devfs_handle = NULL;
-#endif
-
 #ifdef CONFIG_KMOD
 
 /**
@@ -343,15 +339,7 @@
 	if ((err = snd_oss_init_module()) < 0)
 		return err;
 #endif
-#ifdef CONFIG_DEVFS_FS
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
-	devfs_handle = devfs_mk_dir(NULL, "snd", 3, NULL);
-#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,5,67)
-	devfs_handle = devfs_mk_dir(NULL, "snd", NULL);
-#else
-	devfs_handle = devfs_mk_dir("snd");
-#endif
-#endif
+	devfs_mk_dir("snd");
 	if (register_chrdev(major, "alsa", &snd_fops)) {
 		snd_printk(KERN_ERR "unable to register native major device number %d\n", major);
 		return -EIO;
@@ -404,9 +392,7 @@
 #endif
 	if (unregister_chrdev(major, "alsa") != 0)
 		snd_printk(KERN_ERR "unable to unregister major device number %d\n", major);
-#ifdef CONFIG_DEVFS_FS
-	devfs_unregister(devfs_handle);
-#endif
+	devfs_remove("snd");
 }
 
 module_init(alsa_sound_init)
diff -Nru a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c
--- a/sound/drivers/mpu401/mpu401_uart.c	Wed Apr 30 22:28:08 2003
+++ b/sound/drivers/mpu401/mpu401_uart.c	Wed Apr 30 22:28:08 2003
@@ -90,7 +90,7 @@
 #endif
 }
 
-static void _snd_mpu401_uart_interrupt(mpu401_t *mpu)
+static irqreturn_t _snd_mpu401_uart_interrupt(mpu401_t *mpu)
 {
 	if (test_bit(MPU401_MODE_BIT_INPUT, &mpu->mode)) {
 		if (! test_and_set_bit(MPU401_MODE_BIT_RX_LOOP, &mpu->mode)) {
@@ -108,6 +108,9 @@
 		snd_mpu401_uart_output_write(mpu);
 		spin_unlock(&mpu->output_lock);
 	}
+
+	/* FIXME! This should really check whether the irq was for us */
+	return IRQ_HANDLED;
 }
 
 /**
@@ -118,13 +121,13 @@
  *
  * Processes the interrupt for MPU401-UART i/o.
  */
-void snd_mpu401_uart_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t snd_mpu401_uart_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	mpu401_t *mpu = snd_magic_cast(mpu401_t, dev_id, return);
+	mpu401_t *mpu = snd_magic_cast(mpu401_t, dev_id, return IRQ_NONE);
 	
 	if (mpu == NULL)
-		return;
-	_snd_mpu401_uart_interrupt(mpu);
+		return IRQ_NONE;
+	return _snd_mpu401_uart_interrupt(mpu);
 }
 
 /*
diff -Nru a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c
--- a/sound/drivers/mtpav.c	Wed Apr 30 22:28:15 2003
+++ b/sound/drivers/mtpav.c	Wed Apr 30 22:28:15 2003
@@ -585,14 +585,15 @@
 	} while (sbyt & SIGS_BYTE);
 }
 
-static void snd_mtpav_irqh(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_mtpav_irqh(int irq, void *dev_id, struct pt_regs *regs)
 {
-	mtpav_t *mcard = snd_magic_cast(mtpav_t, dev_id, return);
+	mtpav_t *mcard = snd_magic_cast(mtpav_t, dev_id, return IRQ_NONE);
 
 	//printk("irqh()\n");
 	spin_lock(&mcard->spinlock);
 	snd_mtpav_read_bytes(mcard);
 	spin_unlock(&mcard->spinlock);
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c
--- a/sound/drivers/serial-u16550.c	Wed Apr 30 22:28:04 2003
+++ b/sound/drivers/serial-u16550.c	Wed Apr 30 22:28:04 2003
@@ -290,7 +290,7 @@
  * Note that some devices need OUT2 to be set before they will generate
  * interrupts at all. (Possibly tied to an internal pull-up on CTS?)
  */
-static void snd_uart16550_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_uart16550_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	snd_uart16550_t *uart;
 
@@ -298,11 +298,12 @@
 	spin_lock(&uart->open_lock);
 	if (uart->filemode == SERIAL_MODE_NOT_OPENED) {
 		spin_unlock(&uart->open_lock);
-		return;
+		return IRQ_NONE;
 	}
 	inb(uart->base + UART_IIR);		/* indicate to the UART that the interrupt has been serviced */
 	snd_uart16550_io_loop(uart);
 	spin_unlock(&uart->open_lock);
+	return IRQ_HANDLED;
 }
 
 /* When the polling mode, this function calls snd_uart16550_io_loop. */
diff -Nru a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c
--- a/sound/isa/ad1816a/ad1816a_lib.c	Wed Apr 30 22:28:11 2003
+++ b/sound/isa/ad1816a/ad1816a_lib.c	Wed Apr 30 22:28:11 2003
@@ -311,9 +311,9 @@
 }
 
 
-static void snd_ad1816a_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_ad1816a_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	ad1816a_t *chip = snd_magic_cast(ad1816a_t, dev_id, return);
+	ad1816a_t *chip = snd_magic_cast(ad1816a_t, dev_id, return IRQ_NONE);
 	unsigned char status;
 
 	spin_lock(&chip->lock);
@@ -332,6 +332,7 @@
 	spin_lock(&chip->lock);
 	snd_ad1816a_out(chip, AD1816A_INTERRUPT_STATUS, 0x00);
 	spin_unlock(&chip->lock);
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/sound/isa/ad1848/ad1848_lib.c b/sound/isa/ad1848/ad1848_lib.c
--- a/sound/isa/ad1848/ad1848_lib.c	Wed Apr 30 22:28:18 2003
+++ b/sound/isa/ad1848/ad1848_lib.c	Wed Apr 30 22:28:18 2003
@@ -585,9 +585,9 @@
 	return 0;
 }
 
-void snd_ad1848_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t snd_ad1848_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	ad1848_t *chip = snd_magic_cast(ad1848_t, dev_id, return);
+	ad1848_t *chip = snd_magic_cast(ad1848_t, dev_id, return IRQ_NONE);
 
 	if ((chip->mode & AD1848_MODE_PLAY) && chip->playback_substream &&
 	    (chip->mode & AD1848_MODE_RUNNING))
@@ -596,6 +596,7 @@
 	    (chip->mode & AD1848_MODE_RUNNING))
 		snd_pcm_period_elapsed(chip->capture_substream);
 	outb(0, AD1848P(chip, STATUS));	/* clear global interrupt bit */
+	return IRQ_HANDLED;
 }
 
 static snd_pcm_uframes_t snd_ad1848_playback_pointer(snd_pcm_substream_t * substream)
diff -Nru a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c
--- a/sound/isa/cs423x/cs4231_lib.c	Wed Apr 30 22:28:05 2003
+++ b/sound/isa/cs423x/cs4231_lib.c	Wed Apr 30 22:28:05 2003
@@ -967,9 +967,9 @@
 		chip->capture_substream->runtime->overrange++;
 }
 
-void snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	cs4231_t *chip = snd_magic_cast(cs4231_t, dev_id, return);
+	cs4231_t *chip = snd_magic_cast(cs4231_t, dev_id, return IRQ_NONE);
 	unsigned char status;
 
 	status = snd_cs4231_in(chip, CS4231_IRQ_STATUS);
@@ -998,6 +998,7 @@
 	spin_lock(&chip->reg_lock);
 	snd_cs4231_outm(chip, CS4231_IRQ_STATUS, ~CS4231_ALL_IRQS | ~status, 0);
 	spin_unlock(&chip->reg_lock);
+	return IRQ_HANDLED;
 }
 
 #ifdef LEGACY_SUPPORT
diff -Nru a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c
--- a/sound/isa/es1688/es1688_lib.c	Wed Apr 30 22:28:11 2003
+++ b/sound/isa/es1688/es1688_lib.c	Wed Apr 30 22:28:11 2003
@@ -482,9 +482,9 @@
 	return snd_es1688_trigger(chip, cmd, 0x0f);
 }
 
-void snd_es1688_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t snd_es1688_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	es1688_t *chip = snd_magic_cast(es1688_t, dev_id, return);
+	es1688_t *chip = snd_magic_cast(es1688_t, dev_id, return IRQ_NONE);
 
 	if (chip->trigger_value == 0x05)	/* ok.. playback is active */
 		snd_pcm_period_elapsed(chip->playback_substream);
@@ -492,6 +492,7 @@
 		snd_pcm_period_elapsed(chip->capture_substream);
 
 	inb(ES1688P(chip, DATA_AVAIL));	/* ack interrupt */
+	return IRQ_HANDLED;
 }
 
 static snd_pcm_uframes_t snd_es1688_playback_pointer(snd_pcm_substream_t * substream)
diff -Nru a/sound/isa/es18xx.c b/sound/isa/es18xx.c
--- a/sound/isa/es18xx.c	Wed Apr 30 22:28:08 2003
+++ b/sound/isa/es18xx.c	Wed Apr 30 22:28:08 2003
@@ -727,12 +727,11 @@
 		return snd_es18xx_playback2_trigger(chip, substream, cmd);
 }
 
-static void snd_es18xx_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	es18xx_t *chip = snd_magic_cast(es18xx_t, dev_id, return);
+	es18xx_t *chip = snd_magic_cast(es18xx_t, dev_id, return IRQ_NONE);
 	unsigned char status;
 
-
 	if (chip->caps & ES18XX_CONTROL) {
 		/* Read Interrupt status */
 		status = inb(chip->ctrl_port + 6);
@@ -787,7 +786,7 @@
 		/* ack interrupt */
 		snd_es18xx_mixer_write(chip, 0x66, 0x00);
 	}
-
+	return IRQ_HANDLED;
 }
 
 static snd_pcm_uframes_t snd_es18xx_playback_pointer(snd_pcm_substream_t * substream)
diff -Nru a/sound/isa/gus/gus_irq.c b/sound/isa/gus/gus_irq.c
--- a/sound/isa/gus/gus_irq.c	Wed Apr 30 22:28:17 2003
+++ b/sound/isa/gus/gus_irq.c	Wed Apr 30 22:28:17 2003
@@ -30,16 +30,19 @@
 #define STAT_ADD(x)	while (0) { ; }
 #endif
 
-void snd_gus_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t snd_gus_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	snd_gus_card_t * gus = snd_magic_cast(snd_gus_card_t, dev_id, return);
+	snd_gus_card_t * gus = snd_magic_cast(snd_gus_card_t,
+					dev_id, return IRQ_NONE);
 	unsigned char status;
 	int loop = 100;
-	
-      __again:
+	int handled = 0;
+
+__again:
 	status = inb(gus->gf1.reg_irqstat);
 	if (status == 0)
-		return;
+		return IRQ_RETVAL(handled);
+	handled = 1;
 	// snd_printk("IRQ: status = 0x%x\n", status);
 	if (status & 0x02) {
 		STAT_ADD(gus->gf1.interrupt_stat_midi_in);
@@ -101,6 +104,7 @@
 	}
 	if (--loop > 0)
 		goto __again;
+	return IRQ_NONE;
 }
 
 #ifdef CONFIG_SND_DEBUG
diff -Nru a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c
--- a/sound/isa/gus/gusmax.c	Wed Apr 30 22:28:11 2003
+++ b/sound/isa/gus/gusmax.c	Wed Apr 30 22:28:11 2003
@@ -129,22 +129,26 @@
 	return 0;
 }
 
-static void snd_gusmax_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_gusmax_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct snd_gusmax *maxcard = (struct snd_gusmax *) dev_id;
 	int loop, max = 5;
+	int handled = 0;
 
 	do {
 		loop = 0;
 		if (inb(maxcard->gus_status_reg)) {
+			handled = 1;
 			snd_gus_interrupt(irq, maxcard->gus, regs);
 			loop++;
 		}
 		if (inb(maxcard->pcm_status_reg) & 0x01) { /* IRQ bit is set? */
+			handled = 1;
 			snd_cs4231_interrupt(irq, maxcard->cs4231, regs);
 			loop++;
 		}
 	} while (loop && --max > 0);
+	return IRQ_RETVAL(handled);
 }
 
 static void __init snd_gusmax_init(int dev, snd_card_t * card, snd_gus_card_t * gus)
diff -Nru a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c
--- a/sound/isa/gus/interwave.c	Wed Apr 30 22:28:10 2003
+++ b/sound/isa/gus/interwave.c	Wed Apr 30 22:28:10 2003
@@ -312,22 +312,26 @@
 	return -ENODEV;
 }
 
-static void snd_interwave_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_interwave_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct snd_interwave *iwcard = (struct snd_interwave *) dev_id;
 	int loop, max = 5;
+	int handled = 0;
 
 	do {
 		loop = 0;
 		if (inb(iwcard->gus_status_reg)) {
+			handled = 1;
 			snd_gus_interrupt(irq, iwcard->gus, regs);
 			loop++;
 		}
 		if (inb(iwcard->pcm_status_reg) & 0x01) {	/* IRQ bit is set? */
+			handled = 1;
 			snd_cs4231_interrupt(irq, iwcard->cs4231, regs);
 			loop++;
 		}
 	} while (loop && --max > 0);
+	return IRQ_RETVAL(handled);
 }
 
 static void __devinit snd_interwave_reset(snd_gus_card_t * gus)
diff -Nru a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c
--- a/sound/isa/opl3sa2.c	Wed Apr 30 22:28:18 2003
+++ b/sound/isa/opl3sa2.c	Wed Apr 30 22:28:18 2003
@@ -297,26 +297,34 @@
 	return 0;
 }
 
-static void snd_opl3sa2_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_opl3sa2_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	unsigned short status;
-	opl3sa2_t *chip = snd_magic_cast(opl3sa2_t, dev_id, return);
+	opl3sa2_t *chip = snd_magic_cast(opl3sa2_t, dev_id, return IRQ_NONE);
+	int handled = 0;
 
 	if (chip == NULL || chip->card == NULL)
-		return;
+		return IRQ_NONE;
 
 	status = snd_opl3sa2_read(chip, OPL3SA2_IRQ_STATUS);
 
-	if (status & 0x20)
+	if (status & 0x20) {
+		handled = 1;
 		snd_opl3_interrupt(chip->synth);
+	}
 
-	if ((status & 0x10) && chip->rmidi != NULL)
+	if ((status & 0x10) && chip->rmidi != NULL) {
+		handled = 1;
 		snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data, regs);
+	}
 
-	if (status & 0x07)	/* TI,CI,PI */
+	if (status & 0x07) {	/* TI,CI,PI */
+		handled = 1;
 		snd_cs4231_interrupt(irq, chip->cs4231, regs);
+	}
 
 	if (status & 0x40) { /* hardware volume change */
+		handled = 1;
 		/* reading from Master Lch register at 0x07 clears this bit */
 		snd_opl3sa2_read(chip, OPL3SA2_MASTER_RIGHT);
 		snd_opl3sa2_read(chip, OPL3SA2_MASTER_LEFT);
@@ -325,6 +333,7 @@
 			snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_volume->id);
 		}
 	}
+	return IRQ_RETVAL(handled);
 }
 
 #define OPL3SA2_SINGLE(xname, xindex, reg, shift, mask, invert) \
diff -Nru a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
--- a/sound/isa/opti9xx/opti92x-ad1848.c	Wed Apr 30 22:28:05 2003
+++ b/sound/isa/opti9xx/opti92x-ad1848.c	Wed Apr 30 22:28:05 2003
@@ -1125,9 +1125,9 @@
 	spin_unlock_irqrestore(&chip->lock, flags);
 }
 
-void snd_opti93x_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	opti93x_t *codec = snd_magic_cast(opti93x_t, dev_id, return);
+	opti93x_t *codec = snd_magic_cast(opti93x_t, dev_id, return IRQ_NONE);
 	unsigned char status;
 
 	status = snd_opti9xx_read(codec->chip, OPTi9XX_MC_REG(11));
@@ -1138,6 +1138,7 @@
 		snd_pcm_period_elapsed(codec->capture_substream);
 	}
 	outb(0x00, OPTi93X_PORT(codec, STATUS));
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/sound/isa/sb/es968.c b/sound/isa/sb/es968.c
--- a/sound/isa/sb/es968.c	Wed Apr 30 22:28:09 2003
+++ b/sound/isa/sb/es968.c	Wed Apr 30 22:28:09 2003
@@ -78,16 +78,17 @@
 
 #define	DRIVER_NAME	"snd-card-es968"
 
-static void snd_card_es968_interrupt(int irq, void *dev_id,
+static irqreturn_t snd_card_es968_interrupt(int irq, void *dev_id,
 				     struct pt_regs *regs)
 {
-	sb_t *chip = snd_magic_cast(sb_t, dev_id, return);
+	sb_t *chip = snd_magic_cast(sb_t, dev_id, return IRQ_NONE);
 
 	if (chip->open & SB_OPEN_PCM) {
 		snd_sb8dsp_interrupt(chip);
 	} else {
 		snd_sb8dsp_midi_interrupt(chip);
 	}
+	return IRQ_HANDLED;
 }
 
 static int __devinit snd_card_es968_pnp(int dev, struct snd_card_es968 *acard,
diff -Nru a/sound/isa/sb/sb16_main.c b/sound/isa/sb/sb16_main.c
--- a/sound/isa/sb/sb16_main.c	Wed Apr 30 22:28:09 2003
+++ b/sound/isa/sb/sb16_main.c	Wed Apr 30 22:28:09 2003
@@ -393,9 +393,9 @@
 	return result;
 }
 
-void snd_sb16dsp_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t snd_sb16dsp_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	sb_t *chip = snd_magic_cast(sb_t, dev_id, return);
+	sb_t *chip = snd_magic_cast(sb_t, dev_id, return IRQ_NONE);
 	unsigned char status;
 	int ok;
 
@@ -438,6 +438,7 @@
 		snd_sb_ack_16bit(chip);
 		spin_unlock(&chip->reg_lock);
 	}
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c
--- a/sound/isa/sb/sb8.c	Wed Apr 30 22:28:11 2003
+++ b/sound/isa/sb/sb8.c	Wed Apr 30 22:28:11 2003
@@ -70,15 +70,16 @@
 
 static snd_card_t *snd_sb8_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
 
-static void snd_sb8_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_sb8_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	sb_t *chip = snd_magic_cast(sb_t, dev_id, return);
+	sb_t *chip = snd_magic_cast(sb_t, dev_id, return IRQ_NONE);
 
 	if (chip->open & SB_OPEN_PCM) {
 		snd_sb8dsp_interrupt(chip);
 	} else {
 		snd_sb8dsp_midi_interrupt(chip);
 	}
+	return IRQ_HANDLED;
 }
 
 static void snd_sb8_free(snd_card_t *card)
diff -Nru a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c
--- a/sound/isa/sb/sb_common.c	Wed Apr 30 22:28:19 2003
+++ b/sound/isa/sb/sb_common.c	Wed Apr 30 22:28:19 2003
@@ -214,7 +214,7 @@
 int snd_sbdsp_create(snd_card_t *card,
 		     unsigned long port,
 		     int irq,
-		     void (*irq_handler)(int, void *, struct pt_regs *),
+		     irqreturn_t (*irq_handler)(int, void *, struct pt_regs *),
 		     int dma8,
 		     int dma16,
 		     unsigned short hardware,
diff -Nru a/sound/isa/sgalaxy.c b/sound/isa/sgalaxy.c
--- a/sound/isa/sgalaxy.c	Wed Apr 30 22:28:20 2003
+++ b/sound/isa/sgalaxy.c	Wed Apr 30 22:28:20 2003
@@ -112,8 +112,9 @@
 	return 0;
 }
 
-static void snd_sgalaxy_dummy_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_sgalaxy_dummy_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
+	return IRQ_NONE;
 }
 
 static int __init snd_sgalaxy_setup_wss(unsigned long port, int irq, int dma)
diff -Nru a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c
--- a/sound/isa/wavefront/wavefront.c	Wed Apr 30 22:28:14 2003
+++ b/sound/isa/wavefront/wavefront.c	Wed Apr 30 22:28:14 2003
@@ -276,7 +276,7 @@
 
 #endif /* CONFIG_PNP */
 
-static void snd_wavefront_ics2115_interrupt(int irq, 
+static irqreturn_t snd_wavefront_ics2115_interrupt(int irq, 
 					    void *dev_id, 
 					    struct pt_regs *regs)
 {
@@ -285,13 +285,14 @@
 	acard = (snd_wavefront_card_t *) dev_id;
 
 	if (acard == NULL) 
-		return;
+		return IRQ_NONE;
 
 	if (acard->wavefront.interrupts_are_midi) {
 		snd_wavefront_midi_interrupt (acard);
 	} else {
 		snd_wavefront_internal_interrupt (acard);
 	}
+	return IRQ_HANDLED;
 }
 
 snd_hwdep_t * __devinit
diff -Nru a/sound/oss/Kconfig b/sound/oss/Kconfig
--- a/sound/oss/Kconfig	Wed Apr 30 22:28:15 2003
+++ b/sound/oss/Kconfig	Wed Apr 30 22:28:15 2003
@@ -872,7 +872,7 @@
 	  Say Y here if you have a Sound Blaster SB32, AWE32-PnP, SB AWE64 or
 	  similar sound card. See <file:Documentation/sound/oss/README.awe>,
 	  <file:Documentation/sound/oss/AWE32> and the Soundblaster-AWE
-	  mini-HOWTO, available from <http://www.linuxdoc.org/docs.html#howto>
+	  mini-HOWTO, available from <http://www.tldp.org/docs.html#howto>
 	  for more info.
 
 config SOUND_WAVEFRONT
diff -Nru a/sound/oss/ad1816.c b/sound/oss/ad1816.c
--- a/sound/oss/ad1816.c	Wed Apr 30 22:28:16 2003
+++ b/sound/oss/ad1816.c	Wed Apr 30 22:28:16 2003
@@ -540,7 +540,7 @@
 /* Interrupt handler */
 
 
-static void ad1816_interrupt (int irq, void *dev_id, struct pt_regs *dummy)
+static irqreturn_t ad1816_interrupt (int irq, void *dev_id, struct pt_regs *dummy)
 {
 	unsigned char	status;
 	ad1816_info	*devc;
@@ -549,7 +549,7 @@
 	
 	if (irq < 0 || irq > 15) {
 	        printk(KERN_WARNING "ad1816: Got bogus interrupt %d\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	dev = irq2dev[irq];
@@ -557,7 +557,7 @@
 	if (dev < 0 || dev >= num_audiodevs) {
 	        printk(KERN_WARNING "ad1816: IRQ2AD1816-mapping failed for "
 				    "irq %d device %d\n", irq,dev);
-		return;	        
+		return IRQ_NONE;
 	}
 
 	devc = (ad1816_info *) audio_devs[dev]->devc;
@@ -583,6 +583,7 @@
 		DMAbuf_outputintr (dev, 1);
 
 	spin_unlock(&devc->lock);
+	return IRQ_HANDLED;
 }
 
 /* ------------------------------------------------------------------- */
diff -Nru a/sound/oss/ad1848.c b/sound/oss/ad1848.c
--- a/sound/oss/ad1848.c	Wed Apr 30 22:28:11 2003
+++ b/sound/oss/ad1848.c	Wed Apr 30 22:28:11 2003
@@ -2212,7 +2212,7 @@
 		printk(KERN_ERR "ad1848: Can't find device to be unloaded. Base=%x\n", io_base);
 }
 
-void adintr(int irq, void *dev_id, struct pt_regs *dummy)
+irqreturn_t adintr(int irq, void *dev_id, struct pt_regs *dummy)
 {
 	unsigned char status;
 	ad1848_info *devc;
@@ -2287,6 +2287,7 @@
 	{
 		  goto interrupt_again;
 	}
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/sound/oss/ad1848.h b/sound/oss/ad1848.h
--- a/sound/oss/ad1848.h	Wed Apr 30 22:28:03 2003
+++ b/sound/oss/ad1848.h	Wed Apr 30 22:28:03 2003
@@ -1,4 +1,6 @@
 
+#include <linux/interrupt.h>
+
 #define AD_F_CS4231     0x0001  /* Returned if a CS4232 (or compatible) detected */
 #define AD_F_CS4248     0x0001  /* Returned if a CS4248 (or compatible) detected */
 
@@ -16,7 +18,7 @@
 int ad1848_detect (int io_base, int *flags, int *osp);
 int ad1848_control(int cmd, int arg);
 
-void adintr(int irq, void *dev_id, struct pt_regs * dummy);
+irqreturn_t adintr(int irq, void *dev_id, struct pt_regs * dummy);
 void attach_ms_sound(struct address_info * hw_config, struct module * owner);
 
 int probe_ms_sound(struct address_info *hw_config);
diff -Nru a/sound/oss/btaudio.c b/sound/oss/btaudio.c
--- a/sound/oss/btaudio.c	Wed Apr 30 22:28:06 2003
+++ b/sound/oss/btaudio.c	Wed Apr 30 22:28:06 2003
@@ -25,7 +25,6 @@
 #include <linux/sched.h>
 #include <linux/signal.h>
 #include <linux/types.h>
-#include <linux/wrapper.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/poll.h>
@@ -817,18 +816,20 @@
 			    "RISCI", "FBUS", "FTRGT", "FDSR", "PPERR",
 			    "RIPERR", "PABORT", "OCERR", "SCERR" };
 
-static void btaudio_irq(int irq, void *dev_id, struct pt_regs * regs)
+static irqreturn_t btaudio_irq(int irq, void *dev_id, struct pt_regs * regs)
 {
 	int count = 0;
 	u32 stat,astat;
 	struct btaudio *bta = dev_id;
+	int handled = 0;
 
 	for (;;) {
 		count++;
 		stat  = btread(REG_INT_STAT);
 		astat = stat & btread(REG_INT_MASK);
 		if (!astat)
-			return;
+			return IRQ_RETVAL(handled);
+		handled = 1;
 		btwrite(astat,REG_INT_STAT);
 
 		if (irq_debug) {
@@ -864,7 +865,7 @@
 			btwrite(0, REG_INT_MASK);
 		}
 	}
-	return;
+	return IRQ_NONE;
 }
 
 /* -------------------------------------------------------------- */
diff -Nru a/sound/oss/cmpci.c b/sound/oss/cmpci.c
--- a/sound/oss/cmpci.c	Wed Apr 30 22:28:10 2003
+++ b/sound/oss/cmpci.c	Wed Apr 30 22:28:10 2003
@@ -98,7 +98,6 @@
 #include <linux/slab.h>
 #include <linux/soundcard.h>
 #include <linux/pci.h>
-#include <linux/wrapper.h>
 #include <linux/init.h>
 #include <linux/poll.h>
 #include <linux/spinlock.h>
@@ -938,7 +937,7 @@
 		/* undo marking the pages as reserved */
 		pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
 		for (pstart = virt_to_page(db->rawbuf); pstart <= pend; pstart++)
-			mem_map_unreserve(pstart);
+			ClearPageReserved(pstart);
 		free_pages((unsigned long)db->rawbuf, db->buforder);
 	}
 	db->rawbuf = NULL;
@@ -987,7 +986,7 @@
 		/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
 		pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
 		for (pstart = virt_to_page(db->rawbuf); pstart <= pend; pstart++)
-			mem_map_reserve(pstart);
+			SetPageReserved(pstart);
 	}
 	bytepersec = rate << sample_shift[fmt];
 	bufs = PAGE_SIZE << db->buforder;
@@ -1156,7 +1155,7 @@
 }
 #endif
 
-static void cm_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t cm_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
         struct cm_state *s = (struct cm_state *)dev_id;
 	unsigned int intsrc, intstat;
@@ -1165,7 +1164,7 @@
 	/* fastpath out, to ease interrupt sharing */
 	intsrc = inl(s->iobase + CODEC_CMI_INT_STATUS);
 	if (!(intsrc & 0x80000000))
-		return;
+		return IRQ_NONE;
 	spin_lock(&s->lock);
 	intstat = inb(s->iobase + CODEC_CMI_INT_HLDCLR + 2);
 	/* acknowledge interrupt */
@@ -1180,6 +1179,7 @@
 	cm_handle_midi(s);
 #endif
 	spin_unlock(&s->lock);
+	return IRQ_HANDLED;
 }
 
 #ifdef CONFIG_SOUND_CMPCI_MIDI
diff -Nru a/sound/oss/cs4281/cs4281_wrapper-24.c b/sound/oss/cs4281/cs4281_wrapper-24.c
--- a/sound/oss/cs4281/cs4281_wrapper-24.c	Wed Apr 30 22:28:07 2003
+++ b/sound/oss/cs4281/cs4281_wrapper-24.c	Wed Apr 30 22:28:07 2003
@@ -28,8 +28,6 @@
 
 int cs4281_resume_null(struct pci_dev *pcidev) { return 0; }
 int cs4281_suspend_null(struct pci_dev *pcidev, u32 state) { return 0; }
-#define cs4x_mem_map_reserve(page) mem_map_reserve(page)
-#define cs4x_mem_map_unreserve(page) mem_map_unreserve(page)
 
 #define free_dmabuf(state, dmabuf) \
 	pci_free_consistent(state->pcidev, \
diff -Nru a/sound/oss/cs4281/cs4281m.c b/sound/oss/cs4281/cs4281m.c
--- a/sound/oss/cs4281/cs4281m.c	Wed Apr 30 22:28:19 2003
+++ b/sound/oss/cs4281/cs4281m.c	Wed Apr 30 22:28:19 2003
@@ -71,7 +71,6 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/poll.h>
-#include <linux/wrapper.h>
 #include <linux/fs.h>
 #include <linux/wait.h>
 
@@ -1705,7 +1704,7 @@
 		    virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) -
 				 1);
 		for (map = virt_to_page(db->rawbuf); map <= mapend; map++)
-			cs4x_mem_map_unreserve(map);
+			ClearPageReserved(map);
 		free_dmabuf(s, db);
 	}
 	if (s->tmpbuff && (db->type == CS_TYPE_ADC)) {
@@ -1714,7 +1713,7 @@
 		    virt_to_page(s->tmpbuff +
 				 (PAGE_SIZE << s->buforder_tmpbuff) - 1);
 		for (map = virt_to_page(s->tmpbuff); map <= mapend; map++)
-			cs4x_mem_map_unreserve(map);
+			ClearPageReserved(map);
 		free_dmabuf2(s, db);
 	}
 	s->tmpbuff = NULL;
@@ -1763,7 +1762,7 @@
 
 		// 2. mark each physical page in range as 'reserved'.
 		for (map = virt_to_page(db->rawbuf); map <= mapend; map++)
-			cs4x_mem_map_reserve(map);
+			SetPageReserved(map);
 	}
 	if (!s->tmpbuff && (db->type == CS_TYPE_ADC)) {
 		for (order = df; order >= DMABUF_MINORDER;
@@ -1786,7 +1785,7 @@
 
 		// 2. mark each physical page in range as 'reserved'.
 		for (map = virt_to_page(s->tmpbuff); map <= mapend; map++)
-			cs4x_mem_map_reserve(map);
+			SetPageReserved(map);
 	}
 	if (db->type == CS_TYPE_DAC) {
 		if (s->prop_dac.fmt & (AFMT_S16_LE | AFMT_U16_LE))
@@ -3792,7 +3791,7 @@
 
 
 
-static void cs4281_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t cs4281_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct cs4281_state *s = (struct cs4281_state *) dev_id;
 	unsigned int temp1;
@@ -3809,7 +3808,7 @@
 		writel(HICR_IEV | HICR_CHGM, s->pBA0 + BA0_HICR);
 		CS_DBGOUT(CS_INTERRUPT, 9, printk(KERN_INFO
 			"cs4281: cs4281_interrupt(): returning not cs4281 interrupt.\n"));
-		return;
+		return IRQ_NONE;
 	}
 
 	if (temp1 & HISR_DMA0)	// If play interrupt,
@@ -3823,6 +3822,7 @@
 	cs4281_update_ptr(s,CS_TRUE);
 	cs4281_handle_midi(s);
 	spin_unlock(&s->lock);
+	return IRQ_HANDLED;
 }
 
 // **************************************************************************
diff -Nru a/sound/oss/cs46xx.c b/sound/oss/cs46xx.c
--- a/sound/oss/cs46xx.c	Wed Apr 30 22:28:03 2003
+++ b/sound/oss/cs46xx.c	Wed Apr 30 22:28:03 2003
@@ -89,7 +89,6 @@
 #include <linux/bitops.h>
 #include <linux/init.h>
 #include <linux/poll.h>
-#include <linux/wrapper.h>
 #include <linux/ac97_codec.h>
 
 #include <asm/io.h>
@@ -1196,7 +1195,7 @@
 
 	// 2. mark each physical page in range as 'reserved'.
 	for (map = virt_to_page(dmabuf->rawbuf); map <= mapend; map++)
-		cs4x_mem_map_reserve(map);
+		SetPageReserved(map);
 
 	CS_DBGOUT(CS_PARMS, 9, printk("cs46xx: alloc_dmabuf(): allocated %ld (order = %d) bytes at %p\n",
 	       PAGE_SIZE << order, order, rawbuf) );
@@ -1233,7 +1232,7 @@
 
 	// 2. mark each physical page in range as 'reserved'.
 	for (map = virt_to_page(dmabuf->tmpbuff); map <= mapend; map++)
-		cs4x_mem_map_reserve(map);
+		SetPageReserved(map);
 	return 0;
 }
 
@@ -1248,7 +1247,7 @@
 		mapend = virt_to_page(dmabuf->rawbuf + 
 				(PAGE_SIZE << dmabuf->buforder) - 1);
 		for (map = virt_to_page(dmabuf->rawbuf); map <= mapend; map++)
-			cs4x_mem_map_unreserve(map);
+			ClearPageReserved(map);
 		free_dmabuf(state->card, dmabuf);
 	}
 
@@ -1257,7 +1256,7 @@
 		mapend = virt_to_page(dmabuf->tmpbuff +
 				(PAGE_SIZE << dmabuf->buforder_tmpbuff) - 1);
 		for (map = virt_to_page(dmabuf->tmpbuff); map <= mapend; map++)
-			cs4x_mem_map_unreserve(map);
+			ClearPageReserved(map);
 		free_dmabuf2(state->card, dmabuf);
 	}
 
@@ -1670,7 +1669,7 @@
                 wake_up(&card->midi.owait);
 }
 
-static void cs_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t cs_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct cs_card *card = (struct cs_card *)dev_id;
 	/* Single channel card */
@@ -1688,7 +1687,7 @@
 	{
 		cs461x_pokeBA0(card, BA0_HICR, HICR_CHGM|HICR_IEV);
 		spin_unlock(&card->lock);
-		return;
+		return IRQ_HANDLED;	/* Might be IRQ_NONE.. */
 	}
 	
 	/*
@@ -1709,6 +1708,7 @@
 	cs461x_pokeBA0(card, BA0_HICR, HICR_CHGM|HICR_IEV);
 	spin_unlock(&card->lock);
 	CS_DBGOUT(CS_INTERRUPT, 9, printk("cs46xx: cs_interrupt()- \n"));
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/sound/oss/cs46xx_wrapper-24.h b/sound/oss/cs46xx_wrapper-24.h
--- a/sound/oss/cs46xx_wrapper-24.h	Wed Apr 30 22:28:11 2003
+++ b/sound/oss/cs46xx_wrapper-24.h	Wed Apr 30 22:28:11 2003
@@ -31,9 +31,6 @@
 #define CS_OWNER owner:
 #define CS_THIS_MODULE THIS_MODULE,
 void cs46xx_null(struct pci_dev *pcidev) { return; }
-#define cs4x_mem_map_reserve(page) mem_map_reserve(page)
-#define cs4x_mem_map_unreserve(page) mem_map_unreserve(page)
-
 #define free_dmabuf(card, dmabuf) \
 	pci_free_consistent((card)->pci_dev, \
 			    PAGE_SIZE << (dmabuf)->buforder, \
diff -Nru a/sound/oss/dmabuf.c b/sound/oss/dmabuf.c
--- a/sound/oss/dmabuf.c	Wed Apr 30 22:28:03 2003
+++ b/sound/oss/dmabuf.c	Wed Apr 30 22:28:03 2003
@@ -26,7 +26,6 @@
 #define SAMPLE_ROUNDUP 0
 
 #include "sound_config.h"
-#include <linux/wrapper.h>
 
 #define DMAP_FREE_ON_CLOSE      0
 #define DMAP_KEEP_ON_CLOSE      1
@@ -116,7 +115,7 @@
 	dmap->raw_buf_phys = virt_to_bus(start_addr);
 
 	for (page = virt_to_page(start_addr); page <= virt_to_page(end_addr); page++)
-		mem_map_reserve(page);
+		SetPageReserved(page);
 	return 0;
 }
 
@@ -136,7 +135,7 @@
 	end_addr = start_addr + dmap->buffsize;
 
 	for (page = virt_to_page(start_addr); page <= virt_to_page(end_addr); page++)
-		mem_map_unreserve(page);
+		ClearPageReserved(page);
 
 	free_pages((unsigned long) dmap->raw_buf, sz);
 	dmap->raw_buf = NULL;
diff -Nru a/sound/oss/dmasound/dmasound_atari.c b/sound/oss/dmasound/dmasound_atari.c
--- a/sound/oss/dmasound/dmasound_atari.c	Wed Apr 30 22:28:06 2003
+++ b/sound/oss/dmasound/dmasound_atari.c	Wed Apr 30 22:28:06 2003
@@ -134,7 +134,7 @@
 static int FalconSetVolume(int volume);
 static void AtaPlayNextFrame(int index);
 static void AtaPlay(void);
-static void AtaInterrupt(int irq, void *dummy, struct pt_regs *fp);
+static irqreturn_t AtaInterrupt(int irq, void *dummy, struct pt_regs *fp);
 
 /*** Mid level stuff *********************************************************/
 
@@ -1250,7 +1250,7 @@
 }
 
 
-static void AtaInterrupt(int irq, void *dummy, struct pt_regs *fp)
+static irqreturn_t AtaInterrupt(int irq, void *dummy, struct pt_regs *fp)
 {
 #if 0
 	/* ++TeSche: if you should want to test this... */
@@ -1259,7 +1259,7 @@
 		if (++cnt == 10) {
 			/* simulate losing an interrupt */
 			cnt = 0;
-			return;
+			return IRQ_HANDLED;
 		}
 #endif
 	spin_lock(&dmasound.lock);
@@ -1269,7 +1269,7 @@
 		 * (almost) like on the TT.
 		 */
 		write_sq_ignore_int = 0;
-		return;
+		return IRQ_HANDLED;
 	}
 
 	if (!write_sq.active) {
@@ -1277,7 +1277,7 @@
 		 * the sq variables, so better don't do anything here.
 		 */
 		WAKE_UP(write_sq.sync_queue);
-		return;
+		return IRQ_HANDLED;
 	}
 
 	/* Probably ;) one frame is finished. Well, in fact it may be that a
@@ -1315,6 +1315,7 @@
 	   is nothing to play any more. Wake up a process
 	   waiting for audio output to drain. */
 	spin_unlock(&dmasound.lock);
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/sound/oss/dmasound/dmasound_awacs.c b/sound/oss/dmasound/dmasound_awacs.c
--- a/sound/oss/dmasound/dmasound_awacs.c	Wed Apr 30 22:28:07 2003
+++ b/sound/oss/dmasound/dmasound_awacs.c	Wed Apr 30 22:28:07 2003
@@ -266,9 +266,9 @@
 static int PMacSetVolume(int volume);
 static void PMacPlay(void);
 static void PMacRecord(void);
-static void pmac_awacs_tx_intr(int irq, void *devid, struct pt_regs *regs);
-static void pmac_awacs_rx_intr(int irq, void *devid, struct pt_regs *regs);
-static void pmac_awacs_intr(int irq, void *devid, struct pt_regs *regs);
+static irqreturn_t pmac_awacs_tx_intr(int irq, void *devid, struct pt_regs *regs);
+static irqreturn_t pmac_awacs_rx_intr(int irq, void *devid, struct pt_regs *regs);
+static irqreturn_t pmac_awacs_intr(int irq, void *devid, struct pt_regs *regs);
 static void awacs_write(int val);
 static int awacs_get_volume(int reg, int lshift);
 static int awacs_volume_setter(int volume, int n, int mute, int lshift);
@@ -395,20 +395,24 @@
 	return ((pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, gpio_addr, 0) & 0x02) !=0);
 }
 
-static void
+static irqreturn_t
 headphone_intr(int irq, void *devid, struct pt_regs *regs)
 {
+	int handled = 0;
 	spin_lock(&dmasound.lock);
 	if (read_audio_gpio(gpio_headphone_detect) == gpio_headphone_detect_pol) {
+		handled = 1;
 		printk(KERN_INFO "Audio jack plugged, muting speakers.\n");
 		write_audio_gpio(gpio_amp_mute, gpio_amp_mute_pol);
 		write_audio_gpio(gpio_headphone_mute, !gpio_headphone_mute_pol);
 	} else {
+		handled = 1;
 		printk(KERN_INFO "Audio jack unplugged, enabling speakers.\n");
 		write_audio_gpio(gpio_amp_mute, !gpio_amp_mute_pol);
 		write_audio_gpio(gpio_headphone_mute, gpio_headphone_mute_pol);
 	}
 	spin_unlock(&dmasound.lock);
+	return IRQ_RETVAL(handled);
 }
 
 
@@ -923,7 +927,7 @@
    'next_cmd' field will already point back to the original loop of blocks.
 */
 
-static void
+static irqreturn_t
 pmac_awacs_tx_intr(int irq, void *devid, struct pt_regs *regs)
 {
 	int i = write_sq.front;
@@ -1009,10 +1013,11 @@
 	if (!write_sq.active && (write_sq.syncing & 1))
 		WAKE_UP(write_sq.sync_queue); /* any time we're empty */
 	spin_unlock(&dmasound.lock);
+	return IRQ_HANDLED;
 }
 
 
-static void
+static irqreturn_t
 pmac_awacs_rx_intr(int irq, void *devid, struct pt_regs *regs)
 {
 	int stat ;
@@ -1023,12 +1028,12 @@
 	 * just blow it off.
 	 */
 	if (in_le32(&awacs_rxdma->cmdptr) == 0)
-		return;
+		return IRQ_HANDLED;
 
 	/* We also want to blow 'em off when shutting down.
 	*/
 	if (read_sq.active == 0)
-		return;
+		return IRQ_HANDLED;
 
 	spin_lock(&dmasound.lock);
 	/* Check multiple buffers in case we were held off from
@@ -1063,7 +1068,7 @@
 			out_le32(&awacs_rxdma->control,
 				((RUN|WAKE) << 16) + (RUN|WAKE));
 			spin_unlock(&dmasound.lock);
-			return; /* try this block again */
+			return IRQ_HANDLED; /* try this block again */
 		}
 		/* Clear status and move on to next buffer.
 		*/
@@ -1091,10 +1096,11 @@
 
 	WAKE_UP(read_sq.action_queue);
 	spin_unlock(&dmasound.lock);
+	return IRQ_HANDLED;
 }
 
 
-static void
+static irqreturn_t
 pmac_awacs_intr(int irq, void *devid, struct pt_regs *regs)
 {
 	int ctrl;
@@ -1113,6 +1119,7 @@
 	/* Writing 1s to the CNTLERR and PORTCHG bits clears them... */
 	out_le32(&awacs->control, ctrl);
 	spin_unlock(&dmasound.lock);
+	return IRQ_HANDLED;
 }
 
 static void
diff -Nru a/sound/oss/dmasound/dmasound_paula.c b/sound/oss/dmasound/dmasound_paula.c
--- a/sound/oss/dmasound/dmasound_paula.c	Wed Apr 30 22:28:03 2003
+++ b/sound/oss/dmasound/dmasound_paula.c	Wed Apr 30 22:28:03 2003
@@ -83,7 +83,7 @@
 static int AmiSetTreble(int treble);
 static void AmiPlayNextFrame(int index);
 static void AmiPlay(void);
-static void AmiInterrupt(int irq, void *dummy, struct pt_regs *fp);
+static irqreturn_t AmiInterrupt(int irq, void *dummy, struct pt_regs *fp);
 
 #ifdef CONFIG_HEARTBEAT
 
@@ -567,7 +567,7 @@
 }
 
 
-static void AmiInterrupt(int irq, void *dummy, struct pt_regs *fp)
+static irqreturn_t AmiInterrupt(int irq, void *dummy, struct pt_regs *fp)
 {
 	int minframes = 1;
 
@@ -578,7 +578,7 @@
 		 * the sq variables, so better don't do anything here.
 		 */
 		WAKE_UP(write_sq.sync_queue);
-		return;
+		return IRQ_HANDLED;
 	}
 
 	if (write_sq.active & AMI_PLAY_PLAYING) {
@@ -608,6 +608,7 @@
 		/* Nothing to play anymore.
 		   Wake up a process waiting for audio output to drain. */
 		WAKE_UP(write_sq.sync_queue);
+	return IRQ_HANDLED;
 }
 
 /*** Mid level stuff *********************************************************/
diff -Nru a/sound/oss/dmasound/dmasound_q40.c b/sound/oss/dmasound/dmasound_q40.c
--- a/sound/oss/dmasound/dmasound_q40.c	Wed Apr 30 22:28:03 2003
+++ b/sound/oss/dmasound/dmasound_q40.c	Wed Apr 30 22:28:03 2003
@@ -49,8 +49,8 @@
 static int Q40SetVolume(int volume);
 static void Q40PlayNextFrame(int index);
 static void Q40Play(void);
-static void Q40StereoInterrupt(int irq, void *dummy, struct pt_regs *fp);
-static void Q40MonoInterrupt(int irq, void *dummy, struct pt_regs *fp);
+static irqreturn_t Q40StereoInterrupt(int irq, void *dummy, struct pt_regs *fp);
+static irqreturn_t Q40MonoInterrupt(int irq, void *dummy, struct pt_regs *fp);
 static void Q40Interrupt(void);
 
 
@@ -464,7 +464,7 @@
 	spin_unlock_irqrestore_flags(&dmasound.lock, flags);
 }
 
-static void Q40StereoInterrupt(int irq, void *dummy, struct pt_regs *fp)
+static irqreturn_t Q40StereoInterrupt(int irq, void *dummy, struct pt_regs *fp)
 {
 	spin_lock(&dmasound.lock);
         if (q40_sc>1){
@@ -474,8 +474,9 @@
 	    master_outb(1,SAMPLE_CLEAR_REG);
 	}else Q40Interrupt();
 	spin_unlock(&dmasound.lock);
+	return IRQ_HANDLED;
 }
-static void Q40MonoInterrupt(int irq, void *dummy, struct pt_regs *fp)
+static irqreturn_t Q40MonoInterrupt(int irq, void *dummy, struct pt_regs *fp)
 {
 	spin_lock(&dmasound.lock);
         if (q40_sc>0){
@@ -485,6 +486,7 @@
 	    master_outb(1,SAMPLE_CLEAR_REG);
 	}else Q40Interrupt();
 	spin_unlock(&dmasound.lock);
+	return IRQ_HANDLED;
 }
 static void Q40Interrupt(void)
 {
diff -Nru a/sound/oss/emu10k1/audio.c b/sound/oss/emu10k1/audio.c
--- a/sound/oss/emu10k1/audio.c	Wed Apr 30 22:28:04 2003
+++ b/sound/oss/emu10k1/audio.c	Wed Apr 30 22:28:04 2003
@@ -37,8 +37,6 @@
 #include <asm/io.h>
 #include <linux/sched.h>
 #include <linux/smp_lock.h>
-#include <linux/wrapper.h>
-
 
 #include "hwaccess.h"
 #include "cardwo.h"
diff -Nru a/sound/oss/emu10k1/cardwo.c b/sound/oss/emu10k1/cardwo.c
--- a/sound/oss/emu10k1/cardwo.c	Wed Apr 30 22:28:15 2003
+++ b/sound/oss/emu10k1/cardwo.c	Wed Apr 30 22:28:15 2003
@@ -444,7 +444,7 @@
 	while (len) { 
 		for (voice_num = 0; voice_num < woinst->num_voices; voice_num++) {
 			if (__copy_from_user((u8 *)(voice[voice_num].mem.addr[pg]) + pgoff, src, woinst->format.bytespervoicesample))
-				return -EFAULT;
+				return;
 			src += woinst->format.bytespervoicesample;
 		}
 
diff -Nru a/sound/oss/emu10k1/irqmgr.c b/sound/oss/emu10k1/irqmgr.c
--- a/sound/oss/emu10k1/irqmgr.c	Wed Apr 30 22:28:10 2003
+++ b/sound/oss/emu10k1/irqmgr.c	Wed Apr 30 22:28:10 2003
@@ -37,10 +37,11 @@
 
 /* Interrupt handler */
 
-void emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct emu10k1_card *card = (struct emu10k1_card *) dev_id;
 	u32 irqstatus, irqstatus_tmp;
+	int handled = 0;
 
 	DPD(4, "emu10k1_interrupt called, irq =  %u\n", irq);
 
@@ -105,6 +106,8 @@
 		}
 
 		/* acknowledge interrupt */
-                outl(irqstatus_tmp, card->iobase + IPR);
+		outl(irqstatus_tmp, card->iobase + IPR);
+		handled = 1;
 	}
+	return IRQ_RETVAL(handled);
 }
diff -Nru a/sound/oss/emu10k1/main.c b/sound/oss/emu10k1/main.c
--- a/sound/oss/emu10k1/main.c	Wed Apr 30 22:28:18 2003
+++ b/sound/oss/emu10k1/main.c	Wed Apr 30 22:28:18 2003
@@ -157,7 +157,7 @@
 static struct midi_operations emu10k1_midi_operations;
 #endif
 
-extern void emu10k1_interrupt(int, void *, struct pt_regs *s);
+extern irqreturn_t emu10k1_interrupt(int, void *, struct pt_regs *s);
 
 static int __devinit emu10k1_audio_init(struct emu10k1_card *card)
 {
diff -Nru a/sound/oss/emu10k1/passthrough.c b/sound/oss/emu10k1/passthrough.c
--- a/sound/oss/emu10k1/passthrough.c	Wed Apr 30 22:28:09 2003
+++ b/sound/oss/emu10k1/passthrough.c	Wed Apr 30 22:28:09 2003
@@ -36,7 +36,6 @@
 #include <asm/io.h>
 #include <linux/sched.h>
 #include <linux/smp_lock.h>
-#include <linux/wrapper.h>
 
 #include "hwaccess.h"
 #include "cardwo.h"
diff -Nru a/sound/oss/es1370.c b/sound/oss/es1370.c
--- a/sound/oss/es1370.c	Wed Apr 30 22:28:19 2003
+++ b/sound/oss/es1370.c	Wed Apr 30 22:28:19 2003
@@ -151,7 +151,6 @@
 #include <linux/soundcard.h>
 #include <linux/pci.h>
 #include <linux/smp_lock.h>
-#include <linux/wrapper.h>
 #include <linux/init.h>
 #include <linux/poll.h>
 #include <linux/spinlock.h>
@@ -551,7 +550,7 @@
 		/* undo marking the pages as reserved */
 		pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
 		for (page = virt_to_page(db->rawbuf); page <= pend; page++)
-			mem_map_unreserve(page);
+			ClearPageReserved(page);
 		pci_free_consistent(s->dev, PAGE_SIZE << db->buforder, db->rawbuf, db->dmaaddr);
 	}
 	db->rawbuf = NULL;
@@ -577,7 +576,7 @@
 		/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
 		pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
 		for (page = virt_to_page(db->rawbuf); page <= pend; page++)
-			mem_map_reserve(page);
+			SetPageReserved(page);
 	}
 	fmt &= ES1370_FMT_MASK;
 	bytepersec = rate << sample_shift[fmt];
@@ -755,7 +754,7 @@
 	outb((s->midi.ocnt > 0) ? UCTRL_RXINTEN | UCTRL_ENA_TXINT : UCTRL_RXINTEN, s->io+ES1370_REG_UART_CONTROL);
 }
 
-static void es1370_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t es1370_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
         struct es1370_state *s = (struct es1370_state *)dev_id;
 	unsigned int intsrc, sctl;
@@ -763,7 +762,7 @@
 	/* fastpath out, to ease interrupt sharing */
 	intsrc = inl(s->io+ES1370_REG_STATUS);
 	if (!(intsrc & 0x80000000))
-		return;
+		return IRQ_NONE;
 	spin_lock(&s->lock);
 	/* clear audio interrupts first */
 	sctl = s->sctrl;
@@ -778,6 +777,7 @@
 	es1370_update_ptr(s);
 	es1370_handle_midi(s);
 	spin_unlock(&s->lock);
+	return IRQ_HANDLED;
 }
 
 /* --------------------------------------------------------------------- */
diff -Nru a/sound/oss/es1371.c b/sound/oss/es1371.c
--- a/sound/oss/es1371.c	Wed Apr 30 22:28:14 2003
+++ b/sound/oss/es1371.c	Wed Apr 30 22:28:14 2003
@@ -126,7 +126,6 @@
 #include <linux/spinlock.h>
 #include <linux/smp_lock.h>
 #include <linux/ac97_codec.h>
-#include <linux/wrapper.h>
 #include <linux/gameport.h>
 #include <linux/wait.h>
 
@@ -887,7 +886,7 @@
 		/* undo marking the pages as reserved */
 		pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
 		for (page = virt_to_page(db->rawbuf); page <= pend; page++)
-			mem_map_unreserve(page);
+			ClearPageReserved(page);
 		pci_free_consistent(s->dev, PAGE_SIZE << db->buforder, db->rawbuf, db->dmaaddr);
 	}
 	db->rawbuf = NULL;
@@ -913,7 +912,7 @@
 		/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
 		pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
 		for (page = virt_to_page(db->rawbuf); page <= pend; page++)
-			mem_map_reserve(page);
+			SetPageReserved(page);
 	}
 	fmt &= ES1371_FMT_MASK;
 	bytepersec = rate << sample_shift[fmt];
@@ -1091,7 +1090,7 @@
 	outb((s->midi.ocnt > 0) ? UCTRL_RXINTEN | UCTRL_ENA_TXINT : UCTRL_RXINTEN, s->io+ES1371_REG_UART_CONTROL);
 }
 
-static void es1371_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t es1371_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
         struct es1371_state *s = (struct es1371_state *)dev_id;
 	unsigned int intsrc, sctl;
@@ -1099,7 +1098,7 @@
 	/* fastpath out, to ease interrupt sharing */
 	intsrc = inl(s->io+ES1371_REG_STATUS);
 	if (!(intsrc & 0x80000000))
-		return;
+		return IRQ_NONE;
 	spin_lock(&s->lock);
 	/* clear audio interrupts first */
 	sctl = s->sctrl;
@@ -1114,6 +1113,7 @@
 	es1371_update_ptr(s);
 	es1371_handle_midi(s);
 	spin_unlock(&s->lock);
+	return IRQ_HANDLED;
 }
 
 /* --------------------------------------------------------------------- */
diff -Nru a/sound/oss/esssolo1.c b/sound/oss/esssolo1.c
--- a/sound/oss/esssolo1.c	Wed Apr 30 22:28:04 2003
+++ b/sound/oss/esssolo1.c	Wed Apr 30 22:28:04 2003
@@ -102,7 +102,6 @@
 #include <linux/poll.h>
 #include <linux/spinlock.h>
 #include <linux/smp_lock.h>
-#include <linux/wrapper.h>
 #include <linux/gameport.h>
 #include <linux/wait.h>
 
@@ -423,7 +422,7 @@
 		/* undo marking the pages as reserved */
 		pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
 		for (page = virt_to_page(db->rawbuf); page <= pend; page++)
-			mem_map_unreserve(page);
+			ClearPageReserved(page);
 		pci_free_consistent(s->dev, PAGE_SIZE << db->buforder, db->rawbuf, db->dmaaddr);
 	}
 	db->rawbuf = NULL;
@@ -449,7 +448,7 @@
 		/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
 		pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
 		for (page = virt_to_page(db->rawbuf); page <= pend; page++)
-			mem_map_reserve(page);
+			SetPageReserved(page);
 	}
 	if (s->fmt & (AFMT_S16_LE | AFMT_U16_LE))
 		sample_shift++;
@@ -1694,7 +1693,7 @@
 		wake_up(&s->midi.owait);
 }
 
-static void solo1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t solo1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
         struct solo1_state *s = (struct solo1_state *)dev_id;
 	unsigned int intsrc;
@@ -1702,7 +1701,7 @@
 	/* fastpath out, to ease interrupt sharing */
 	intsrc = inb(s->iobase+7); /* get interrupt source(s) */
 	if (!intsrc)
-		return;
+		return IRQ_NONE;
 	(void)inb(s->sbbase+0xe);  /* clear interrupt */
 	spin_lock(&s->lock);
 	/* clear audio interrupts first */
@@ -1711,6 +1710,7 @@
 	solo1_update_ptr(s);
 	solo1_handle_midi(s);
 	spin_unlock(&s->lock);
+	return IRQ_HANDLED;
 }
 
 static void solo1_midi_timer(unsigned long data)
diff -Nru a/sound/oss/gus.h b/sound/oss/gus.h
--- a/sound/oss/gus.h	Wed Apr 30 22:28:16 2003
+++ b/sound/oss/gus.h	Wed Apr 30 22:28:16 2003
@@ -3,7 +3,7 @@
 
 /*	From gus_card.c */
 int gus_set_midi_irq(int num);
-void gusintr(int irq, void *dev_id, struct pt_regs * dummy);
+irqreturn_t gusintr(int irq, void *dev_id, struct pt_regs * dummy);
 
 /*	From gus_wave.c */
 int gus_wave_detect(int baseaddr);
diff -Nru a/sound/oss/gus_card.c b/sound/oss/gus_card.c
--- a/sound/oss/gus_card.c	Wed Apr 30 22:28:03 2003
+++ b/sound/oss/gus_card.c	Wed Apr 30 22:28:03 2003
@@ -25,7 +25,7 @@
 #include "gus.h"
 #include "gus_hw.h"
 
-void            gusintr(int irq, void *dev_id, struct pt_regs *dummy);
+irqreturn_t gusintr(int irq, void *dev_id, struct pt_regs *dummy);
 
 int             gus_base = 0, gus_irq = 0, gus_dma = 0;
 int             gus_no_wave_dma = 0; 
@@ -119,10 +119,11 @@
 		sound_free_dma(hw_config->dma2);
 }
 
-void gusintr(int irq, void *dev_id, struct pt_regs *dummy)
+irqreturn_t gusintr(int irq, void *dev_id, struct pt_regs *dummy)
 {
 	unsigned char src;
 	extern int gus_timer_enabled;
+	int handled = 0;
 
 #ifdef CONFIG_SOUND_GUSMAX
 	if (have_gus_max) {
@@ -140,8 +141,8 @@
 	while (1)
 	{
 		if (!(src = inb(u_IrqStatus)))
-			return;
-
+			break;
+		handled = 1;
 		if (src & DMA_TC_IRQ)
 		{
 			guswave_dma_irq();
@@ -160,6 +161,7 @@
 		if (src & (WAVETABLE_IRQ | ENVELOPE_IRQ))
 			gus_voice_irq();
 	}
+	return IRQ_RETVAL(handled);
 }
 
 /*
diff -Nru a/sound/oss/gus_wave.c b/sound/oss/gus_wave.c
--- a/sound/oss/gus_wave.c	Wed Apr 30 22:28:06 2003
+++ b/sound/oss/gus_wave.c	Wed Apr 30 22:28:06 2003
@@ -508,7 +508,7 @@
 {
 	unsigned        vol, prev_vol, phase;
 	unsigned char   rate;
-	long int        flags;
+	unsigned long flags;
 
 	if (voices[voice].mode & WAVE_SUSTAIN_ON && voices[voice].env_phase == 2)
 	{
@@ -593,7 +593,7 @@
 static void gus_voice_fade(int voice)
 {
 	int instr_no = sample_map[voice], is16bits;
-	long int flags;
+	unsigned long flags;
 
 	spin_lock_irqsave(&gus_lock,flags);
 	gus_select_voice(voice);
@@ -1511,7 +1511,7 @@
 
 static int guswave_start_note(int dev, int voice, int note_num, int volume)
 {
-	long int flags;
+	unsigned long flags;
 	int mode;
 	int ret_val = 0;
 
diff -Nru a/sound/oss/i810_audio.c b/sound/oss/i810_audio.c
--- a/sound/oss/i810_audio.c	Wed Apr 30 22:28:14 2003
+++ b/sound/oss/i810_audio.c	Wed Apr 30 22:28:14 2003
@@ -96,7 +96,6 @@
 #include <linux/spinlock.h>
 #include <linux/smp_lock.h>
 #include <linux/ac97_codec.h>
-#include <linux/wrapper.h>
 #include <asm/uaccess.h>
 #include <asm/hardirq.h>
 
@@ -941,7 +940,7 @@
 	/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
 	pend = virt_to_page(rawbuf + (PAGE_SIZE << order) - 1);
 	for (page = virt_to_page(rawbuf); page <= pend; page++)
-		mem_map_reserve(page);
+		SetPageReserved(page);
 
 	return 0;
 }
@@ -956,7 +955,7 @@
 		/* undo marking the pages as reserved */
 		pend = virt_to_page(dmabuf->rawbuf + (PAGE_SIZE << dmabuf->buforder) - 1);
 		for (page = virt_to_page(dmabuf->rawbuf); page <= pend; page++)
-			mem_map_unreserve(page);
+			ClearPageReserved(page);
 		pci_free_consistent(state->card->pci_dev, PAGE_SIZE << dmabuf->buforder,
 				    dmabuf->rawbuf, dmabuf->dma_handle);
 	}
@@ -1389,7 +1388,7 @@
 #endif
 }
 
-static void i810_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t i810_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct i810_card *card = (struct i810_card *)dev_id;
 	u32 status;
@@ -1401,7 +1400,7 @@
 	if(!(status & INT_MASK)) 
 	{
 		spin_unlock(&card->lock);
-		return;  /* not for us */
+		return IRQ_NONE;  /* not for us */
 	}
 
 	if(status & (INT_PO|INT_PI|INT_MC))
@@ -1410,6 +1409,7 @@
  	/* clear 'em */
 	outl(status & INT_MASK, card->iobase + GLOB_STA);
 	spin_unlock(&card->lock);
+	return IRQ_HANDLED;
 }
 
 /* in this loop, dmabuf.count signifies the amount of data that is
diff -Nru a/sound/oss/ite8172.c b/sound/oss/ite8172.c
--- a/sound/oss/ite8172.c	Wed Apr 30 22:28:05 2003
+++ b/sound/oss/ite8172.c	Wed Apr 30 22:28:05 2003
@@ -67,7 +67,6 @@
 #include <linux/spinlock.h>
 #include <linux/smp_lock.h>
 #include <linux/ac97_codec.h>
-#include <linux/wrapper.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/uaccess.h>
@@ -640,7 +639,7 @@
 	/* undo marking the pages as reserved */
 	pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
 	for (page = virt_to_page(db->rawbuf); page <= pend; page++)
-	    mem_map_unreserve(page);
+	    ClearPageReserved(page);
 	pci_free_consistent(s->dev, PAGE_SIZE << db->buforder,
 			    db->rawbuf, db->dmaaddr);
     }
@@ -670,7 +669,7 @@
 	   otherwise remap_page_range doesn't do what we want */
 	pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
 	for (page = virt_to_page(db->rawbuf); page <= pend; page++)
-	    mem_map_reserve(page);
+	    SetPageReserved(page);
     }
 
     db->count = 0;
@@ -727,7 +726,7 @@
 
 /* hold spinlock for the following! */
 
-static void it8172_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t it8172_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
     struct it8172_state *s = (struct it8172_state *)dev_id;
     struct dmabuf* dac = &s->dma_dac;
@@ -741,8 +740,10 @@
     isc = inb(s->io+IT_AC_ISC);
 
     /* fastpath out, to ease interrupt sharing */
-    if (!(isc & (ISC_VCI | ISC_CCI | ISC_PCI)))
-	return;
+    if (!(isc & (ISC_VCI | ISC_CCI | ISC_PCI))) {
+	spin_unlock(&s->lock);
+	return IRQ_NONE;
+    }
 
     /* clear audio interrupts first */
     outb(isc | ISC_VCI | ISC_CCI | ISC_PCI, s->io+IT_AC_ISC);
@@ -819,6 +820,7 @@
     }
     
     spin_unlock(&s->lock);
+    return IRQ_HANDLED;
 }
 
 /* --------------------------------------------------------------------- */
diff -Nru a/sound/oss/maestro.c b/sound/oss/maestro.c
--- a/sound/oss/maestro.c	Wed Apr 30 22:28:16 2003
+++ b/sound/oss/maestro.c	Wed Apr 30 22:28:16 2003
@@ -208,7 +208,6 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/smp_lock.h>
-#include <linux/wrapper.h>
 #include <linux/string.h>
 #include <linux/ctype.h>
 #include <linux/ioport.h>
@@ -1631,7 +1630,7 @@
  *	Meet Bob, the timer...
  */
 
-static void ess_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t ess_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 static void stop_bob(struct ess_state *s)
 {
@@ -1900,7 +1899,7 @@
 	}
 }
 
-static void 
+static irqreturn_t
 ess_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
         struct ess_state *s;
@@ -1908,7 +1907,8 @@
 	int i;
 	u32 event;
 
-	if ( ! (event = inb(c->iobase+0x1A)) ) return;
+	if ( ! (event = inb(c->iobase+0x1A)) )
+		return IRQ_NONE;
 
 	outw(inw(c->iobase+4)&1, c->iobase+4);
 
@@ -1972,6 +1972,7 @@
 		ess_update_ptr(s);
 		spin_unlock(&s->lock);
 	}
+	return IRQ_HANDLED;
 }
 
 
@@ -2947,7 +2948,7 @@
 	/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
 	pend = virt_to_page(rawbuf + (PAGE_SIZE << order) - 1);
 	for (page = virt_to_page(rawbuf); page <= pend; page++)
-		mem_map_reserve(page);
+		SetPageReserved(page);
 
 	return 0;
 } 
@@ -2965,7 +2966,7 @@
 
 	pend = virt_to_page(s->card->dmapages + (PAGE_SIZE << s->card->dmaorder) - 1);
 	for (page = virt_to_page(s->card->dmapages); page <= pend; page++)
-		mem_map_unreserve(page);
+		ClearPageReserved(page);
 
 	free_pages((unsigned long)s->card->dmapages,s->card->dmaorder);
 	s->card->dmapages = NULL;
diff -Nru a/sound/oss/maestro3.c b/sound/oss/maestro3.c
--- a/sound/oss/maestro3.c	Wed Apr 30 22:28:16 2003
+++ b/sound/oss/maestro3.c	Wed Apr 30 22:28:16 2003
@@ -149,11 +149,6 @@
 #include <asm/dma.h>
 #include <asm/uaccess.h>
 
- /*
-  * for crizappy mmap()
-  */
-#include <linux/wrapper.h>
-
 #include "maestro3.h"
 
 #define M_DEBUG 1
@@ -1232,7 +1227,7 @@
     }
 }
 
-static void m3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t m3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
     struct m3_card *c = (struct m3_card *)dev_id;
     struct m3_state *s = &c->channels[0];
@@ -1240,13 +1235,14 @@
 
     status = inb(c->iobase+0x1A);
 
-    if(status == 0xff) return;
+    if(status == 0xff)
+	return IRQ_NONE;
    
     /* presumably acking the ints? */
     outw(status, c->iobase+0x1A); 
 
     if(c->in_suspend)
-        return;
+        return IRQ_HANDLED;
 
     /*
      * ack an assp int if its running
@@ -1269,6 +1265,7 @@
     /* XXX is this needed? */
     if(status & 0x40) 
         outb(0x40, c->iobase+0x1A);
+    return IRQ_HANDLED;
 }
 
 
@@ -1937,7 +1934,7 @@
 
         pend = virt_to_page(db->rawbuf + (PAGE_SIZE << order) - 1);
         for (page = virt_to_page(db->rawbuf); page <= pend; page++)
-            mem_map_reserve(page);
+            SetPageReserved(page);
     }
 
 
@@ -1968,7 +1965,7 @@
         struct page *page, *pend;
         pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
         for (page = virt_to_page(db->rawbuf); page <= pend; page++)
-            mem_map_unreserve(page);
+            ClearPageReserved(page);
     }
 
 
diff -Nru a/sound/oss/maui.c b/sound/oss/maui.c
--- a/sound/oss/maui.c	Wed Apr 30 22:28:13 2003
+++ b/sound/oss/maui.c	Wed Apr 30 22:28:13 2003
@@ -102,9 +102,10 @@
 	return 0;
 }
 
-static void mauiintr(int irq, void *dev_id, struct pt_regs *dummy)
+static irqreturn_t mauiintr(int irq, void *dev_id, struct pt_regs *dummy)
 {
 	irq_ok = 1;
+	return IRQ_HANDLED;
 }
 
 static int __init download_code(void)
diff -Nru a/sound/oss/mpu401.c b/sound/oss/mpu401.c
--- a/sound/oss/mpu401.c	Wed Apr 30 22:28:17 2003
+++ b/sound/oss/mpu401.c	Wed Apr 30 22:28:17 2003
@@ -444,15 +444,17 @@
 	return input_avail(devc);
 }
 
-void mpuintr(int irq, void *dev_id, struct pt_regs *dummy)
+irqreturn_t mpuintr(int irq, void *dev_id, struct pt_regs *dummy)
 {
 	struct mpu_config *devc;
 	int dev = (int) dev_id;
+	int handled = 0;
 
 	devc = &dev_conf[dev];
 
 	if (input_avail(devc))
 	{
+		handled = 1;
 		if (devc->base != 0 && (devc->opened & OPEN_READ || devc->mode == MODE_SYNTH))
 			mpu401_input_loop(devc);
 		else
@@ -461,6 +463,7 @@
 			read_data(devc);
 		}
 	}
+	return IRQ_RETVAL(handled);
 }
 
 static int mpu401_open(int dev, int mode,
@@ -500,7 +503,7 @@
 	{
 		if (!try_module_get(coprocessor->owner)) {
 			mpu401_close(dev);
-			return err;
+			return -ENODEV;
 		}
 
 		if ((err = coprocessor->open(coprocessor->devc, COPR_MIDI)) < 0)
@@ -839,7 +842,7 @@
 	coprocessor = midi_devs[midi_dev]->coproc;
 	if (coprocessor) {
 		if (!try_module_get(coprocessor->owner))
-			return err;
+			return -ENODEV;
 
 		if ((err = coprocessor->open(coprocessor->devc, COPR_MIDI)) < 0)
 		{
diff -Nru a/sound/oss/mpu401.h b/sound/oss/mpu401.h
--- a/sound/oss/mpu401.h	Wed Apr 30 22:28:08 2003
+++ b/sound/oss/mpu401.h	Wed Apr 30 22:28:08 2003
@@ -3,7 +3,7 @@
 int probe_uart401 (struct address_info *hw_config, struct module *owner);
 void unload_uart401 (struct address_info *hw_config);
 
-void uart401intr (int irq, void *dev_id, struct pt_regs * dummy);
+irqreturn_t uart401intr (int irq, void *dev_id, struct pt_regs * dummy);
 
 /*	From mpu401.c */
 int probe_mpu401(struct address_info *hw_config);
@@ -11,4 +11,4 @@
 void unload_mpu401(struct address_info *hw_info);
 
 int intchk_mpu401(void *dev_id);
-void mpuintr(int irq, void *dev_id, struct pt_regs * dummy);
+irqreturn_t mpuintr(int irq, void *dev_id, struct pt_regs * dummy);
diff -Nru a/sound/oss/msnd_pinnacle.c b/sound/oss/msnd_pinnacle.c
--- a/sound/oss/msnd_pinnacle.c	Wed Apr 30 22:28:11 2003
+++ b/sound/oss/msnd_pinnacle.c	Wed Apr 30 22:28:11 2003
@@ -45,6 +45,7 @@
 #include <linux/types.h>
 #include <linux/delay.h>
 #include <linux/init.h>
+#include <linux/interrupt.h>
 #include <linux/smp_lock.h>
 #include <asm/irq.h>
 #include <asm/io.h>
@@ -1061,7 +1062,7 @@
 	}
 }
 
-static void intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	/* Send ack to DSP */
 	inb(dev.io + HP_RXL);
@@ -1077,6 +1078,7 @@
 		else
 			isa_writew(wTmp, dev.DSPQ + JQS_wHead);
 	}
+	return IRQ_HANDLED;
 }
 
 static struct file_operations dev_fileops = {
diff -Nru a/sound/oss/nec_vrc5477.c b/sound/oss/nec_vrc5477.c
--- a/sound/oss/nec_vrc5477.c	Wed Apr 30 22:28:14 2003
+++ b/sound/oss/nec_vrc5477.c	Wed Apr 30 22:28:14 2003
@@ -78,7 +78,6 @@
 #include <linux/spinlock.h>
 #include <linux/smp_lock.h>
 #include <linux/ac97_codec.h>
-#include <linux/wrapper.h>
 #include <linux/interrupt.h>
 #include <asm/io.h>
 #include <asm/dma.h>
@@ -813,7 +812,7 @@
 		wake_up_interruptible(&dac->wait);
 }
 
-static void vrc5477_ac97_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t vrc5477_ac97_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct vrc5477_ac97_state *s = (struct vrc5477_ac97_state *)dev_id;
 	u32 irqStatus;
@@ -851,6 +850,7 @@
 	}
 
 	spin_unlock(&s->lock);
+	return IRQ_HANDLED;
 }
 
 /* --------------------------------------------------------------------- */
diff -Nru a/sound/oss/nm256.h b/sound/oss/nm256.h
--- a/sound/oss/nm256.h	Wed Apr 30 22:28:11 2003
+++ b/sound/oss/nm256.h	Wed Apr 30 22:28:11 2003
@@ -2,6 +2,8 @@
 #define _NM256_H_
 
 #include <linux/spinlock.h>
+#include <linux/interrupt.h>
+
 #include "ac97.h"
 
 /* The revisions that we currently handle.  */
@@ -113,7 +115,7 @@
     int has_irq;
 
     /* The card interrupt service routine. */
-    void (*introutine) (int, void *, struct pt_regs *);
+    irqreturn_t (*introutine) (int, void *, struct pt_regs *);
 
     /* Current audio config, cached. */
     struct sinfo {
diff -Nru a/sound/oss/nm256_audio.c b/sound/oss/nm256_audio.c
--- a/sound/oss/nm256_audio.c	Wed Apr 30 22:28:08 2003
+++ b/sound/oss/nm256_audio.c	Wed Apr 30 22:28:08 2003
@@ -44,8 +44,8 @@
 
 static int nm256_grabInterrupt (struct nm256_info *card);
 static int nm256_releaseInterrupt (struct nm256_info *card);
-static void nm256_interrupt (int irq, void *dev_id, struct pt_regs *dummy);
-static void nm256_interrupt_zx (int irq, void *dev_id, struct pt_regs *dummy);
+static irqreturn_t nm256_interrupt (int irq, void *dev_id, struct pt_regs *dummy);
+static irqreturn_t nm256_interrupt_zx (int irq, void *dev_id, struct pt_regs *dummy);
 static int handle_pm_event (struct pm_dev *dev, pm_request_t rqst, void *data);
 
 /* These belong in linux/pci.h. */
@@ -528,16 +528,17 @@
  * I suppose...yucky bleah.)
  */
 
-static void
+static irqreturn_t
 nm256_interrupt (int irq, void *dev_id, struct pt_regs *dummy)
 {
     struct nm256_info *card = (struct nm256_info *)dev_id;
     u16 status;
     static int badintrcount = 0;
+    int handled = 0;
 
     if ((card == NULL) || (card->magsig != NM_MAGIC_SIG)) {
 	printk (KERN_ERR "NM256: Bad card pointer\n");
-	return;
+	return IRQ_NONE;
     }
 
     status = nm256_readPort16 (card, 2, NM_INT_REG);
@@ -558,13 +559,14 @@
 	     * inserted a PCMCIA card and someone's spamming us with IRQ 9s.
 	     */
 
+	    handled = 1;
 	    if (card->playing)
 		stopPlay (card);
 	    if (card->recording)
 		stopRecord (card);
 	    badintrcount = 0;
 	}
-	return;
+	return IRQ_RETVAL(handled);
     }
 
     badintrcount = 0;
@@ -572,6 +574,7 @@
     /* Rather boring; check for individual interrupts and process them. */
 
     if (status & NM_PLAYBACK_INT) {
+	handled = 1;
 	status &= ~NM_PLAYBACK_INT;
 	NM_ACK_INT (card, NM_PLAYBACK_INT);
 
@@ -580,6 +583,7 @@
     }
 
     if (status & NM_RECORD_INT) {
+	handled = 1;
 	status &= ~NM_RECORD_INT;
 	NM_ACK_INT (card, NM_RECORD_INT);
 
@@ -590,6 +594,7 @@
     if (status & NM_MISC_INT_1) {
 	u8 cbyte;
 
+	handled = 1;
 	status &= ~NM_MISC_INT_1;
 	printk (KERN_ERR "NM256: Got misc interrupt #1\n");
 	NM_ACK_INT (card, NM_MISC_INT_1);
@@ -601,6 +606,7 @@
     if (status & NM_MISC_INT_2) {
 	u8 cbyte;
 
+	handled = 1;
 	status &= ~NM_MISC_INT_2;
 	printk (KERN_ERR "NM256: Got misc interrupt #2\n");
 	NM_ACK_INT (card, NM_MISC_INT_2);
@@ -610,11 +616,13 @@
 
     /* Unknown interrupt. */
     if (status) {
+	handled = 1;
 	printk (KERN_ERR "NM256: Fire in the hole! Unknown status 0x%x\n",
 		status);
 	/* Pray. */
 	NM_ACK_INT (card, status);
     }
+    return IRQ_RETVAL(handled);
 }
 
 /*
@@ -623,16 +631,17 @@
  * routine.
  */
 
-static void
+static irqreturn_t
 nm256_interrupt_zx (int irq, void *dev_id, struct pt_regs *dummy)
 {
     struct nm256_info *card = (struct nm256_info *)dev_id;
     u32 status;
     static int badintrcount = 0;
+    int handled = 0;
 
     if ((card == NULL) || (card->magsig != NM_MAGIC_SIG)) {
 	printk (KERN_ERR "NM256: Bad card pointer\n");
-	return;
+	return IRQ_NONE;
     }
 
     status = nm256_readPort32 (card, 2, NM_INT_REG);
@@ -655,13 +664,14 @@
 	     * IRQ 9s.
 	     */
 
+	    handled = 1;
 	    if (card->playing)
 		stopPlay (card);
 	    if (card->recording)
 		stopRecord (card);
 	    badintrcount = 0;
 	}
-	return;
+	return IRQ_RETVAL(handled);
     }
 
     badintrcount = 0;
@@ -669,6 +679,7 @@
     /* Rather boring; check for individual interrupts and process them. */
 
     if (status & NM2_PLAYBACK_INT) {
+	handled = 1;
 	status &= ~NM2_PLAYBACK_INT;
 	NM2_ACK_INT (card, NM2_PLAYBACK_INT);
 
@@ -677,6 +688,7 @@
     }
 
     if (status & NM2_RECORD_INT) {
+	handled = 1;
 	status &= ~NM2_RECORD_INT;
 	NM2_ACK_INT (card, NM2_RECORD_INT);
 
@@ -687,6 +699,7 @@
     if (status & NM2_MISC_INT_1) {
 	u8 cbyte;
 
+	handled = 1;
 	status &= ~NM2_MISC_INT_1;
 	printk (KERN_ERR "NM256: Got misc interrupt #1\n");
 	NM2_ACK_INT (card, NM2_MISC_INT_1);
@@ -697,6 +710,7 @@
     if (status & NM2_MISC_INT_2) {
 	u8 cbyte;
 
+	handled = 1;
 	status &= ~NM2_MISC_INT_2;
 	printk (KERN_ERR "NM256: Got misc interrupt #2\n");
 	NM2_ACK_INT (card, NM2_MISC_INT_2);
@@ -706,11 +720,13 @@
 
     /* Unknown interrupt. */
     if (status) {
+	handled = 1;
 	printk (KERN_ERR "NM256: Fire in the hole! Unknown status 0x%x\n",
 		status);
 	/* Pray. */
 	NM2_ACK_INT (card, status);
     }
+    return IRQ_RETVAL(handled);
 }
 
 /* 
diff -Nru a/sound/oss/os.h b/sound/oss/os.h
--- a/sound/oss/os.h	Wed Apr 30 22:28:20 2003
+++ b/sound/oss/os.h	Wed Apr 30 22:28:20 2003
@@ -32,7 +32,6 @@
 #include <linux/pci.h>
 #endif
 
-#include <linux/wrapper.h>
 #include <linux/soundcard.h>
 
 #define FALSE	0
diff -Nru a/sound/oss/pas2_card.c b/sound/oss/pas2_card.c
--- a/sound/oss/pas2_card.c	Wed Apr 30 22:28:12 2003
+++ b/sound/oss/pas2_card.c	Wed Apr 30 22:28:12 2003
@@ -89,7 +89,7 @@
 
 /******************* Begin of the Interrupt Handler ********************/
 
-void pasintr(int irq, void *dev_id, struct pt_regs *dummy)
+static irqreturn_t pasintr(int irq, void *dev_id, struct pt_regs *dummy)
 {
 	int             status;
 
@@ -106,6 +106,7 @@
 		  pas_midi_interrupt();
 		  status &= ~0x10;
 	}
+	return IRQ_HANDLED;
 }
 
 int pas_set_intr(int mask)
diff -Nru a/sound/oss/pss.c b/sound/oss/pss.c
--- a/sound/oss/pss.c	Wed Apr 30 22:28:20 2003
+++ b/sound/oss/pss.c	Wed Apr 30 22:28:20 2003
@@ -152,7 +152,7 @@
 
 static void pss_write(pss_confdata *devc, int data)
 {
-	int i, limit;
+	unsigned long i, limit;
 
 	limit = jiffies + HZ/10;	/* The timeout is 0.1 seconds */
 	/*
@@ -305,7 +305,8 @@
 
 static int pss_download_boot(pss_confdata * devc, unsigned char *block, int size, int flags)
 {
-	int i, limit, val, count;
+	int i, val, count;
+	unsigned long limit;
 
 	if (flags & CPF_FIRST)
 	{
diff -Nru a/sound/oss/rme96xx.c b/sound/oss/rme96xx.c
--- a/sound/oss/rme96xx.c	Wed Apr 30 22:28:07 2003
+++ b/sound/oss/rme96xx.c	Wed Apr 30 22:28:07 2003
@@ -542,7 +542,7 @@
 
 inline int rme96xx_gethwptr(rme96xx_info* s,int exact)
 {
-	long flags;
+	unsigned long flags;
 	if (exact) {
 		unsigned int hwp;
 /* the hwptr seems to be rather unreliable :(, so we don't use it */
@@ -587,7 +587,7 @@
 static int rme96xx_startcard(rme96xx_info *s,int stop)
 {
 	int i;
-	long flags;
+	unsigned long flags;
 
 	COMM       ("startcard");
 	if(s->control_register & RME96xx_IE){
@@ -760,7 +760,7 @@
 }
 
 
-static void rme96xx_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t rme96xx_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	int i;
 	rme96xx_info *s = (rme96xx_info *)dev_id;
@@ -770,7 +770,7 @@
 
 	status = readl(s->iobase + RME96xx_status_register);
 	if (!(status & RME96xx_IRQ)) {
-		return;
+		return IRQ_NONE;
 	}
 
 	spin_lock_irqsave(&s->lock,flags);
@@ -785,6 +785,7 @@
 			wake_up(&(db->wait));		
 	}  
 	spin_unlock_irqrestore(&s->lock,flags);
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/sound/oss/sb_common.c b/sound/oss/sb_common.c
--- a/sound/oss/sb_common.c	Wed Apr 30 22:28:04 2003
+++ b/sound/oss/sb_common.c	Wed Apr 30 22:28:04 2003
@@ -201,7 +201,7 @@
 		sb_intr(devc);
 }
 
-static void sbintr(int irq, void *dev_id, struct pt_regs *dummy)
+static irqreturn_t sbintr(int irq, void *dev_id, struct pt_regs *dummy)
 {
 	sb_devc *devc = dev_id;
 
@@ -219,6 +219,7 @@
 		sb_intr (devc);
 		break;
 	}
+	return IRQ_HANDLED;
 }
 
 int sb_dsp_reset(sb_devc * devc)
diff -Nru a/sound/oss/sonicvibes.c b/sound/oss/sonicvibes.c
--- a/sound/oss/sonicvibes.c	Wed Apr 30 22:28:08 2003
+++ b/sound/oss/sonicvibes.c	Wed Apr 30 22:28:08 2003
@@ -115,7 +115,6 @@
 #include <linux/poll.h>
 #include <linux/spinlock.h>
 #include <linux/smp_lock.h>
-#include <linux/wrapper.h>
 #include <linux/gameport.h>
 
 #include <asm/io.h>
@@ -709,7 +708,7 @@
 		/* undo marking the pages as reserved */
 		pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
 		for (page = virt_to_page(db->rawbuf); page <= pend; page++)
-			mem_map_unreserve(page);
+			ClearPageReserved(page);
 		pci_free_consistent(s->dev, PAGE_SIZE << db->buforder, db->rawbuf, db->dmaaddr);
 	}
 	db->rawbuf = NULL;
@@ -760,7 +759,7 @@
 		/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
 		pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
 		for (page = virt_to_page(db->rawbuf); page <= pend; page++)
-			mem_map_reserve(page);
+			SetPageReserved(page);
 	}
 	bytepersec = rate << sample_shift[fmt];
 	bufs = PAGE_SIZE << db->buforder;
@@ -899,7 +898,7 @@
 		wake_up(&s->midi.owait);
 }
 
-static void sv_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sv_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
         struct sv_state *s = (struct sv_state *)dev_id;
 	unsigned int intsrc;
@@ -907,11 +906,12 @@
 	/* fastpath out, to ease interrupt sharing */
 	intsrc = inb(s->ioenh + SV_CODEC_STATUS);
 	if (!(intsrc & (SV_CSTAT_DMAA | SV_CSTAT_DMAC | SV_CSTAT_MIDI)))
-		return;
+		return IRQ_NONE;
 	spin_lock(&s->lock);
 	sv_update_ptr(s);
 	sv_handle_midi(s);
 	spin_unlock(&s->lock);
+	return IRQ_HANDLED;
 }
 
 static void sv_midi_timer(unsigned long data)
diff -Nru a/sound/oss/sscape.c b/sound/oss/sscape.c
--- a/sound/oss/sscape.c	Wed Apr 30 22:28:11 2003
+++ b/sound/oss/sscape.c	Wed Apr 30 22:28:11 2003
@@ -39,7 +39,6 @@
 #include <linux/ioport.h>
 #include <linux/delay.h>
 #include <linux/proc_fs.h>
-#include <linux/wrapper.h>
 #include <linux/spinlock.h>
 
 #include "coproc.h"
@@ -839,7 +838,7 @@
 	devc->raw_buf_phys = virt_to_bus(start_addr);
 
 	for (page = virt_to_page(start_addr); page <= virt_to_page(end_addr); page++)
-		mem_map_reserve(page);
+		SetPageReserved(page);
 	return 1;
 }
 
@@ -855,7 +854,7 @@
 	end_addr = start_addr + devc->buffsize;
 
 	for (page = virt_to_page(start_addr); page <= virt_to_page(end_addr); page++)
-		mem_map_unreserve(page);
+		ClearPageReserved(page);
 
 	free_pages((unsigned long) devc->raw_buf, sz);
 	devc->raw_buf = NULL;
diff -Nru a/sound/oss/trident.c b/sound/oss/trident.c
--- a/sound/oss/trident.c	Wed Apr 30 22:28:14 2003
+++ b/sound/oss/trident.c	Wed Apr 30 22:28:14 2003
@@ -195,7 +195,6 @@
 #include <linux/spinlock.h>
 #include <linux/smp_lock.h>
 #include <linux/ac97_codec.h>
-#include <linux/wrapper.h>
 #include <linux/bitops.h>
 #include <linux/proc_fs.h>
 #include <linux/interrupt.h>
@@ -207,7 +206,7 @@
 #include <asm/io.h>
 #include <asm/dma.h>
 
-#if defined CONFIG_ALPHA_NAUTILUS || CONFIG_ALPHA_GENERIC
+#if defined(CONFIG_ALPHA_NAUTILUS) || defined(CONFIG_ALPHA_GENERIC)
 #include <asm/hwrpb.h>
 #endif
 
@@ -1222,7 +1221,7 @@
 	/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
 	pend = virt_to_page(rawbuf + (PAGE_SIZE << order) - 1);
 	for (page = virt_to_page(rawbuf); page <= pend; page++)
-		mem_map_reserve(page);
+		SetPageReserved(page);
 
 	return 0;
 }
@@ -1253,7 +1252,7 @@
 		/* undo marking the pages as reserved */
 		pend = virt_to_page(dmabuf->rawbuf + (PAGE_SIZE << dmabuf->buforder) - 1);
 		for (page = virt_to_page(dmabuf->rawbuf); page <= pend; page++)
-			mem_map_unreserve(page);
+			ClearPageReserved(page);
 		pci_free_consistent(pci_dev, PAGE_SIZE << dmabuf->buforder,
 				    dmabuf->rawbuf, dmabuf->dma_handle);
 		dmabuf->rawbuf = NULL;
@@ -1728,7 +1727,7 @@
 	}
 }
 
-static void trident_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t trident_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct trident_card *card = (struct trident_card *)dev_id;
 	u32 event;
@@ -1755,13 +1754,14 @@
 		event = inl(TRID_REG(card, T4D_MISCINT));
 		outl(event | (ST_TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW), TRID_REG(card, T4D_MISCINT));
 		spin_unlock(&card->lock);
-		return;
+		return IRQ_HANDLED;
 	}
 
 	/* manually clear interrupt status, bad hardware design, blame T^2 */
 	outl((ST_TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW),
 	     TRID_REG(card, T4D_MISCINT));
 	spin_unlock(&card->lock);
+	return IRQ_HANDLED;
 }
 
 /* in this loop, dmabuf.count signifies the amount of data that is waiting to be copied to
@@ -4284,7 +4284,7 @@
 		if(card->revision == ALI_5451_V02)
 			ali_close_multi_channels();
 		/* edited by HMSEO for GT sound */
-#if defined CONFIG_ALPHA_NAUTILUS || CONFIG_ALPHA_GENERIC
+#if defined(CONFIG_ALPHA_NAUTILUS) || defined(CONFIG_ALPHA_GENERIC)
 		{
 			u16 ac97_data;
 			extern struct hwrpb_struct *hwrpb;
diff -Nru a/sound/oss/uart401.c b/sound/oss/uart401.c
--- a/sound/oss/uart401.c	Wed Apr 30 22:28:16 2003
+++ b/sound/oss/uart401.c	Wed Apr 30 22:28:16 2003
@@ -96,18 +96,19 @@
 		printk(KERN_WARNING "Too much work in interrupt on uart401 (0x%X). UART jabbering ??\n", devc->base);
 }
 
-void uart401intr(int irq, void *dev_id, struct pt_regs *dummy)
+irqreturn_t uart401intr(int irq, void *dev_id, struct pt_regs *dummy)
 {
 	uart401_devc *devc = dev_id;
 
 	if (devc == NULL)
 	{
 		printk(KERN_ERR "uart401: bad devc\n");
-		return;
+		return IRQ_NONE;
 	}
 
 	if (input_avail(devc))
 		uart401_input_loop(devc);
+	return IRQ_HANDLED;
 }
 
 static int
diff -Nru a/sound/oss/uart6850.c b/sound/oss/uart6850.c
--- a/sound/oss/uart6850.c	Wed Apr 30 22:28:11 2003
+++ b/sound/oss/uart6850.c	Wed Apr 30 22:28:11 2003
@@ -105,10 +105,11 @@
 	}
 }
 
-void m6850intr(int irq, void *dev_id, struct pt_regs *dummy)
+static irqreturn_t m6850intr(int irq, void *dev_id, struct pt_regs *dummy)
 {
 	if (input_avail())
 		uart6850_input_loop();
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/sound/oss/via82cxxx_audio.c b/sound/oss/via82cxxx_audio.c
--- a/sound/oss/via82cxxx_audio.c	Wed Apr 30 22:28:06 2003
+++ b/sound/oss/via82cxxx_audio.c	Wed Apr 30 22:28:06 2003
@@ -31,7 +31,6 @@
 #include <linux/ac97_codec.h>
 #include <linux/smp_lock.h>
 #include <linux/ioport.h>
-#include <linux/wrapper.h>
 #include <linux/delay.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -1694,10 +1693,11 @@
 }
 
 
-static void via_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t via_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct via_info *card = dev_id;
 	u32 status32;
+	int handled = 0;
 
 	/* to minimize interrupt sharing costs, we use the SGD status
 	 * shadow register to check the status of all inputs and
@@ -1708,10 +1708,12 @@
 	if (!(status32 & VIA_INTR_MASK))
         {
 #ifdef CONFIG_MIDI_VIA82CXXX
-	    	 if (card->midi_devc)
+	    	 if (card->midi_devc) {
                     	uart401intr(irq, card->midi_devc, regs);
+			handled = 1;
+		}
 #endif
-		return;
+		goto out;
     	}
 	DPRINTK ("intr, status32 == 0x%08X\n", status32);
 
@@ -1720,14 +1722,21 @@
 	 */
 	spin_lock (&card->lock);
 
-	if (status32 & VIA_INTR_OUT)
+	if (status32 & VIA_INTR_OUT) {
+		handled = 1;
 		via_intr_channel (&card->ch_out);
-	if (status32 & VIA_INTR_IN)
+	}
+	if (status32 & VIA_INTR_IN) {
+		handled = 1;
 		via_intr_channel (&card->ch_in);
-	if (status32 & VIA_INTR_FM)
+	}
+	if (status32 & VIA_INTR_FM) {
+		handled = 1;
 		via_intr_channel (&card->ch_fm);
-
+	}
 	spin_unlock (&card->lock);
+out:
+	return IRQ_RETVAL(handled);
 }
 
 
diff -Nru a/sound/oss/vidc.h b/sound/oss/vidc.h
--- a/sound/oss/vidc.h	Wed Apr 30 22:28:03 2003
+++ b/sound/oss/vidc.h	Wed Apr 30 22:28:03 2003
@@ -37,7 +37,7 @@
  * DMA Interrupt handler
  */
 
-extern void vidc_sound_dma_irq(int irqnr, void *ref, struct pt_regs *regs);
+extern irqreturn_t vidc_sound_dma_irq(int irqnr, void *ref, struct pt_regs *regs);
 
 /*
  * Filler routine pointer
diff -Nru a/sound/oss/vidc_fill.S b/sound/oss/vidc_fill.S
--- a/sound/oss/vidc_fill.S	Wed Apr 30 22:28:11 2003
+++ b/sound/oss/vidc_fill.S	Wed Apr 30 22:28:11 2003
@@ -133,6 +133,10 @@
  *  ip = corrupted
  */
 
+%%%%%%%%%%%%%%%%%%%
+fixme!  This funtion needs to return IRQ_HANDLED
+%%%%%%%%%%%%%%%%%%%
+
 ENTRY(vidc_sound_dma_irq)
 		stmfd	sp!, {r4 - r8, lr}
 		ldr	r8, =dma_start
diff -Nru a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c
--- a/sound/oss/vwsnd.c	Wed Apr 30 22:28:10 2003
+++ b/sound/oss/vwsnd.c	Wed Apr 30 22:28:10 2003
@@ -2236,7 +2236,7 @@
 		pcm_output(devc, underflown, 0);
 }
 
-static void vwsnd_audio_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t vwsnd_audio_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	vwsnd_dev_t *devc = (vwsnd_dev_t *) dev_id;
 	unsigned int status;
@@ -2246,6 +2246,7 @@
 	status = li_get_clear_intr_status(&devc->lith);
 	vwsnd_audio_read_intr(devc, status);
 	vwsnd_audio_write_intr(devc, status);
+	return IRQ_HANDLED;
 }
 
 static ssize_t vwsnd_audio_do_read(struct file *file,
diff -Nru a/sound/oss/waveartist.c b/sound/oss/waveartist.c
--- a/sound/oss/waveartist.c	Wed Apr 30 22:28:07 2003
+++ b/sound/oss/waveartist.c	Wed Apr 30 22:28:07 2003
@@ -833,7 +833,7 @@
 };
 
 
-static void
+static irqreturn_t
 waveartist_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
 	wavnc_info *devc = (wavnc_info *)dev_id;
@@ -872,6 +872,7 @@
 		// We do not use SB mode natively...
 		printk(KERN_WARNING "waveartist: Unexpected SB interrupt...\n");
 	spin_unlock(&waveartist_lock);
+	return IRQ_HANDLED;
 }
 
 /* -------------------------------------------------------------------------
diff -Nru a/sound/oss/wavfront.c b/sound/oss/wavfront.c
--- a/sound/oss/wavfront.c	Wed Apr 30 22:28:10 2003
+++ b/sound/oss/wavfront.c	Wed Apr 30 22:28:10 2003
@@ -2123,8 +2123,8 @@
 /* WaveFront: Linux modular sound kernel installation interface        */
 /***********************************************************************/
 
-void
-wavefrontintr (int irq, void *dev_id, struct pt_regs *dummy)
+static irqreturn_t
+wavefrontintr(int irq, void *dev_id, struct pt_regs *dummy)
 {
 	struct wf_config *hw = dev_id;
 
@@ -2149,12 +2149,13 @@
 	*/
 
 	if ((wavefront_status() & (STAT_INTR_READ|STAT_INTR_WRITE)) == 0) {
-		return;
+		return IRQ_NONE;
 	}
 
 	hw->irq_ok = 1;
 	hw->irq_cnt++;
 	wake_up_interruptible (&hw->interrupt_sleeper);
+	return IRQ_HANDLED;
 }
 
 /* STATUS REGISTER 
diff -Nru a/sound/oss/wf_midi.c b/sound/oss/wf_midi.c
--- a/sound/oss/wf_midi.c	Wed Apr 30 22:28:04 2003
+++ b/sound/oss/wf_midi.c	Wed Apr 30 22:28:04 2003
@@ -354,8 +354,8 @@
 	return 1;
 }
 
-void
-wf_mpuintr (int irq, void *dev_id, struct pt_regs *dummy)
+static irqreturn_t
+wf_mpuintr(int irq, void *dev_id, struct pt_regs *dummy)
 
 {
 	struct wf_mpu_config *physical_dev = dev_id;
@@ -364,10 +364,11 @@
 	int n;
 
 	if (!input_avail()) { /* not for us */
-		return;
+		return IRQ_NONE;
 	}
 
-	if (mi->m_busy) return;
+	if (mi->m_busy)
+		return IRQ_HANDLED;
 	spin_lock(&lock);
 	mi->m_busy = 1;
 
@@ -410,6 +411,7 @@
 
 	mi->m_busy = 0;
 	spin_unlock(&lock);
+	return IRQ_HANDLED;
 }
 
 static int
diff -Nru a/sound/oss/ymfpci.c b/sound/oss/ymfpci.c
--- a/sound/oss/ymfpci.c	Wed Apr 30 22:28:11 2003
+++ b/sound/oss/ymfpci.c	Wed Apr 30 22:28:11 2003
@@ -1016,7 +1016,7 @@
 	return 0;
 }
 
-void ymf_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t ymf_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	ymfpci_t *codec = dev_id;
 	u32 status, nvoice, mode;
@@ -1050,6 +1050,7 @@
 		/* timer handler */
 		ymfpci_writel(codec, YDSXGR_INTFLAG, ~0);
 	}
+	return IRQ_HANDLED;
 }
 
 static void ymf_pcm_free_substream(struct ymf_pcm *ypcm)
diff -Nru a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
--- a/sound/pci/ali5451/ali5451.c	Wed Apr 30 22:28:17 2003
+++ b/sound/pci/ali5451/ali5451.c	Wed Apr 30 22:28:17 2003
@@ -1032,15 +1032,16 @@
 }
 
 
-static void snd_ali_card_interrupt(int irq,
-				   void *dev_id,
-				   struct pt_regs *regs)
+static irqreturn_t snd_ali_card_interrupt(int irq,
+					  void *dev_id,
+					  struct pt_regs *regs)
 {
-	ali_t 	*codec = snd_magic_cast(ali_t, dev_id, return);
+	ali_t *codec = snd_magic_cast(ali_t, dev_id, return IRQ_NONE);
 
 	if (codec == NULL)
-		return;
+		return IRQ_NONE;
 	snd_ali_interrupt(codec);
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/sound/pci/als4000.c b/sound/pci/als4000.c
--- a/sound/pci/als4000.c	Wed Apr 30 22:28:17 2003
+++ b/sound/pci/als4000.c	Wed Apr 30 22:28:17 2003
@@ -356,9 +356,9 @@
 	return bytes_to_frames( substream->runtime, result );
 }
 
-static void snd_als4000_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_als4000_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	sb_t *chip = snd_magic_cast(sb_t, dev_id, return);
+	sb_t *chip = snd_magic_cast(sb_t, dev_id, return IRQ_NONE);
 	unsigned long flags;
 	unsigned gcr_status;
 	unsigned sb_status;
@@ -387,6 +387,7 @@
 		inb(chip->mpu_port);
 	if (sb_status & 0x20)
 		inb(SBP(chip, RESET));
+	return IRQ_HANDLED;
 }
 
 /*****************************************************************/
diff -Nru a/sound/pci/cmipci.c b/sound/pci/cmipci.c
--- a/sound/pci/cmipci.c	Wed Apr 30 22:28:11 2003
+++ b/sound/pci/cmipci.c	Wed Apr 30 22:28:11 2003
@@ -1640,15 +1640,15 @@
 /*
  * interrupt handler
  */
-static void snd_cmipci_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_cmipci_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	cmipci_t *cm = snd_magic_cast(cmipci_t, dev_id, return);
+	cmipci_t *cm = snd_magic_cast(cmipci_t, dev_id, return IRQ_NONE);
 	unsigned int status, mask = 0;
 	
 	/* fastpath out, to ease interrupt sharing */
 	status = snd_cmipci_read(cm, CM_REG_INT_STATUS);
 	if (!(status & CM_INTR))
-		return;
+		return IRQ_NONE;
 
 	/* acknowledge interrupt */
 	spin_lock(&cm->reg_lock);
@@ -1669,6 +1669,8 @@
 		if ((status & CM_CHINT1) && cm->channel[1].running)
 			snd_pcm_period_elapsed(cm->channel[1].substream);
 	}
+
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/sound/pci/cs4281.c b/sound/pci/cs4281.c
--- a/sound/pci/cs4281.c	Wed Apr 30 22:28:17 2003
+++ b/sound/pci/cs4281.c	Wed Apr 30 22:28:17 2003
@@ -511,7 +511,7 @@
 
 };
 
-static void snd_cs4281_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t snd_cs4281_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 static struct pci_device_id snd_cs4281_ids[] __devinitdata = {
 	{ 0x1013, 0x6005, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },	/* CS4281 */
@@ -1883,18 +1883,18 @@
  *  Interrupt handler
  */
 
-static void snd_cs4281_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_cs4281_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	cs4281_t *chip = snd_magic_cast(cs4281_t, dev_id, return);
+	cs4281_t *chip = snd_magic_cast(cs4281_t, dev_id, return IRQ_NONE);
 	unsigned int status, dma, val;
 	cs4281_dma_t *cdma;
 
 	if (chip == NULL)
-		return;
+		return IRQ_NONE;
 	status = snd_cs4281_peekBA0(chip, BA0_HISR);
 	if ((status & 0x7fffffff) == 0) {
 		snd_cs4281_pokeBA0(chip, BA0_HICR, BA0_HICR_EOI);
-		return;
+		return IRQ_NONE;
 	}
 
 	if (status & (BA0_HISR_DMA(0)|BA0_HISR_DMA(1)|BA0_HISR_DMA(2)|BA0_HISR_DMA(3))) {
@@ -1949,6 +1949,8 @@
 
 	/* EOI to the PCI part... reenables interrupts */
 	snd_cs4281_pokeBA0(chip, BA0_HICR, BA0_HICR_EOI);
+
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
--- a/sound/pci/cs46xx/cs46xx_lib.c	Wed Apr 30 22:28:04 2003
+++ b/sound/pci/cs46xx/cs46xx_lib.c	Wed Apr 30 22:28:04 2003
@@ -1217,9 +1217,9 @@
 	return 0;
 }
 
-static void snd_cs46xx_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_cs46xx_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	cs46xx_t *chip = snd_magic_cast(cs46xx_t, dev_id, return);
+	cs46xx_t *chip = snd_magic_cast(cs46xx_t, dev_id, return IRQ_NONE);
 	u32 status1;
 #ifdef CONFIG_SND_CS46XX_NEW_DSP
 	dsp_spos_instance_t * ins = chip->dsp_spos_instance;
@@ -1234,7 +1234,7 @@
 	status1 = snd_cs46xx_peekBA0(chip, BA0_HISR);
 	if ((status1 & 0x7fffffff) == 0) {
 		snd_cs46xx_pokeBA0(chip, BA0_HICR, HICR_CHGM | HICR_IEV);
-		return;
+		return IRQ_NONE;
 	}
 
 #ifdef CONFIG_SND_CS46XX_NEW_DSP
@@ -1305,6 +1305,8 @@
 	 *  EOI to the PCI part....reenables interrupts
 	 */
 	snd_cs46xx_pokeBA0(chip, BA0_HICR, HICR_CHGM | HICR_IEV);
+
+	return IRQ_HANDLED;
 }
 
 static snd_pcm_hardware_t snd_cs46xx_playback =
diff -Nru a/sound/pci/emu10k1/irq.c b/sound/pci/emu10k1/irq.c
--- a/sound/pci/emu10k1/irq.c	Wed Apr 30 22:28:13 2003
+++ b/sound/pci/emu10k1/irq.c	Wed Apr 30 22:28:13 2003
@@ -30,13 +30,15 @@
 #include <sound/core.h>
 #include <sound/emu10k1.h>
 
-void snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	emu10k1_t *emu = snd_magic_cast(emu10k1_t, dev_id, return);
+	emu10k1_t *emu = snd_magic_cast(emu10k1_t, dev_id, return IRQ_NONE);
 	unsigned int status;
+	int handled = 0;
 
 	while ((status = inl(emu->port + IPR)) != 0) {
 		// printk("irq - status = 0x%x\n", status);
+		handled = 1;
 		if (status & IPR_PCIERROR) {
 			snd_printk("interrupt: PCI error\n");
 			snd_emu10k1_intr_disable(emu, INTE_PCIERRORENABLE);
@@ -145,4 +147,5 @@
 			outl(IPR_FXDSP, emu->port + IPR);
 		}
 	}
+	return IRQ_RETVAL(handled);
 }
diff -Nru a/sound/pci/ens1370.c b/sound/pci/ens1370.c
--- a/sound/pci/ens1370.c	Wed Apr 30 22:28:15 2003
+++ b/sound/pci/ens1370.c	Wed Apr 30 22:28:15 2003
@@ -412,7 +412,7 @@
 #endif
 };
 
-static void snd_audiopci_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t snd_audiopci_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 static struct pci_device_id snd_audiopci_ids[] __devinitdata = {
 #ifdef CHIP1370
@@ -2231,17 +2231,17 @@
  *  Interrupt handler
  */
 
-static void snd_audiopci_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_audiopci_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	ensoniq_t *ensoniq = snd_magic_cast(ensoniq_t, dev_id, return);
+	ensoniq_t *ensoniq = snd_magic_cast(ensoniq_t, dev_id, return IRQ_NONE);
 	unsigned int status, sctrl;
 
 	if (ensoniq == NULL)
-		return;
+		return IRQ_NONE;
 
 	status = inl(ES_REG(ensoniq, STATUS));
 	if (!(status & ES_INTR))
-		return;
+		return IRQ_NONE;
 
 	spin_lock(&ensoniq->reg_lock);
 	sctrl = ensoniq->sctrl;
@@ -2263,6 +2263,7 @@
 		snd_pcm_period_elapsed(ensoniq->capture_substream);
 	if ((status & ES_DAC1) && ensoniq->playback1_substream)
 		snd_pcm_period_elapsed(ensoniq->playback1_substream);
+	return IRQ_HANDLED;
 }
 
 static int __devinit snd_audiopci_probe(struct pci_dev *pci,
diff -Nru a/sound/pci/es1938.c b/sound/pci/es1938.c
--- a/sound/pci/es1938.c	Wed Apr 30 22:28:12 2003
+++ b/sound/pci/es1938.c	Wed Apr 30 22:28:12 2003
@@ -249,7 +249,7 @@
 #endif
 };
 
-static void snd_es1938_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 static struct pci_device_id snd_es1938_ids[] __devinitdata = {
         { 0x125d, 0x1969, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },   /* Solo-1 */
@@ -1490,10 +1490,11 @@
 /* --------------------------------------------------------------------
  * Interrupt handler
  * -------------------------------------------------------------------- */
-static void snd_es1938_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	es1938_t *chip = snd_magic_cast(es1938_t, dev_id, return);
+	es1938_t *chip = snd_magic_cast(es1938_t, dev_id, return IRQ_NONE);
 	unsigned char status, audiostatus;
+	int handled = 0;
 
 	status = inb(SLIO_REG(chip, IRQCONTROL));
 #if 0
@@ -1509,6 +1510,7 @@
 		printk("Es1938debug - AUDIO channel 1 DMAC DMA status: 0x%x\n", inl(SLDM_REG(chip, DMASTATUS)));
 #endif
 		/* clear irq */
+		handled = 1;
 		audiostatus = inb(SLSB_REG(chip, STATUS));
 		if (chip->active & ADC1)
 			snd_pcm_period_elapsed(chip->capture_substream);
@@ -1525,6 +1527,7 @@
 
 #endif
 		/* clear irq */
+		handled = 1;
 		snd_es1938_mixer_bits(chip, ESSSB_IREG_AUDIO2CONTROL2, 0x80, 0);
 		if (chip->active & DAC2)
 			snd_pcm_period_elapsed(chip->playback1_substream);
@@ -1533,6 +1536,7 @@
 	/* Hardware volume */
 	if (status & 0x40) {
 		int split = snd_es1938_mixer_read(chip, 0x64) & 0x80;
+		handled = 1;
 		snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_switch->id);
 		snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_volume->id);
 		if (!split) {
@@ -1546,9 +1550,12 @@
 	/* MPU401 */
 	if (status & 0x80) {
 		// snd_es1938_mixer_bits(chip, ESSSB_IREG_MPU401CONTROL, 0x40, 0); /* ack? */
-		if (chip->rmidi)
+		if (chip->rmidi) {
+			handled = 1;
 			snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data, regs);
+		}
 	}
+	return IRQ_RETVAL(handled);
 }
 
 #define ES1938_DMA_SIZE 64
diff -Nru a/sound/pci/es1968.c b/sound/pci/es1968.c
--- a/sound/pci/es1968.c	Wed Apr 30 22:28:13 2003
+++ b/sound/pci/es1968.c	Wed Apr 30 22:28:13 2003
@@ -600,7 +600,7 @@
 #endif
 };
 
-static void snd_es1968_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 static struct pci_device_id snd_es1968_ids[] __devinitdata = {
 	/* Maestro 1 */
@@ -2009,13 +2009,13 @@
 /*
  * interrupt handler
  */
-static void snd_es1968_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	es1968_t *chip = snd_magic_cast(es1968_t, dev_id, return);
+	es1968_t *chip = snd_magic_cast(es1968_t, dev_id, return IRQ_NONE);
 	u32 event;
 
 	if (!(event = inb(chip->io_port + 0x1A)))
-		return;
+		return IRQ_NONE;
 
 	outw(inw(chip->io_port + 4) & 1, chip->io_port + 4);
 
@@ -2041,6 +2041,8 @@
 		}
 		spin_unlock(&chip->substream_lock);
 	}
+
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/sound/pci/fm801.c b/sound/pci/fm801.c
--- a/sound/pci/fm801.c	Wed Apr 30 22:28:15 2003
+++ b/sound/pci/fm801.c	Wed Apr 30 22:28:15 2003
@@ -481,16 +481,16 @@
 	return bytes_to_frames(substream->runtime, ptr);
 }
 
-static void snd_fm801_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_fm801_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	fm801_t *chip = snd_magic_cast(fm801_t, dev_id, return);
+	fm801_t *chip = snd_magic_cast(fm801_t, dev_id, return IRQ_NONE);
 	unsigned short status;
 	unsigned int tmp;
 
 	status = inw(FM801_REG(chip, IRQ_STATUS));
 	status &= FM801_IRQ_PLAYBACK|FM801_IRQ_CAPTURE|FM801_IRQ_MPU|FM801_IRQ_VOLUME;
 	if (! status)
-		return;
+		return IRQ_NONE;
 	/* ack first */
 	outw(status, FM801_REG(chip, IRQ_STATUS));
 	if (chip->pcm && (status & FM801_IRQ_PLAYBACK) && chip->playback_substream) {
@@ -525,6 +525,8 @@
 		snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data, regs);
 	if (status & FM801_IRQ_VOLUME)
 		;/* TODO */
+
+	return IRQ_HANDLED;
 }
 
 static snd_pcm_hardware_t snd_fm801_playback =
diff -Nru a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
--- a/sound/pci/ice1712/ice1712.c	Wed Apr 30 22:28:07 2003
+++ b/sound/pci/ice1712/ice1712.c	Wed Apr 30 22:28:07 2003
@@ -398,15 +398,17 @@
  *  Interrupt handler
  */
 
-static void snd_ice1712_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_ice1712_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	ice1712_t *ice = snd_magic_cast(ice1712_t, dev_id, return);
+	ice1712_t *ice = snd_magic_cast(ice1712_t, dev_id, return IRQ_NONE);
 	unsigned char status;
+	int handled = 0;
 
 	while (1) {
 		status = inb(ICEREG(ice, IRQSTAT));
 		if (status == 0)
 			break;
+		handled = 1;
 		if (status & ICE1712_IRQ_MPU1) {
 			if (ice->rmidi[0])
 				snd_mpu401_uart_interrupt(irq, ice->rmidi[0]->private_data, regs);
@@ -462,6 +464,7 @@
 			outb(ICE1712_IRQ_CONPBK, ICEREG(ice, IRQSTAT));
 		}
 	}
+	return IRQ_RETVAL(handled);
 }
 
 
diff -Nru a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
--- a/sound/pci/ice1712/ice1724.c	Wed Apr 30 22:28:08 2003
+++ b/sound/pci/ice1712/ice1724.c	Wed Apr 30 22:28:08 2003
@@ -194,16 +194,18 @@
  *  Interrupt handler
  */
 
-static void snd_vt1724_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_vt1724_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	ice1712_t *ice = snd_magic_cast(ice1712_t, dev_id, return);
+	ice1712_t *ice = snd_magic_cast(ice1712_t, dev_id, return IRQ_NONE);
 	unsigned char status;
+	int handled = 0;
 
 	while (1) {
 		status = inb(ICEREG1724(ice, IRQSTAT));
 		if (status == 0)
 			break;
-		
+
+		handled = 1;		
 		/*  these should probably be separated at some point, 
 			but as we don't currently have MPU support on the board I will leave it */
 		if ((status & VT1724_IRQ_MPU_RX)||(status & VT1724_IRQ_MPU_TX)) {
@@ -242,6 +244,7 @@
 
 		}
 	}
+	return IRQ_RETVAL(handled);
 }
 
 /*
diff -Nru a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
--- a/sound/pci/intel8x0.c	Wed Apr 30 22:28:11 2003
+++ b/sound/pci/intel8x0.c	Wed Apr 30 22:28:11 2003
@@ -716,9 +716,9 @@
 	iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI);
 }
 
-static void snd_intel8x0_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_intel8x0_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	intel8x0_t *chip = snd_magic_cast(intel8x0_t, dev_id, return);
+	intel8x0_t *chip = snd_magic_cast(intel8x0_t, dev_id, return IRQ_NONE);
 	ichdev_t *ichdev;
 	unsigned int status;
 	unsigned int i;
@@ -727,7 +727,7 @@
 	status = igetdword(chip, chip->int_sta_reg);
 	if ((status & chip->int_sta_mask) == 0) {
 		spin_unlock(&chip->reg_lock);
-		return;
+		return IRQ_NONE;
 	}
 	/* ack first */
 	iputdword(chip, chip->int_sta_reg, status & ~chip->int_sta_mask);
@@ -738,6 +738,7 @@
 		if (status & ichdev->int_sta_mask)
 			snd_intel8x0_update(chip, ichdev);
 	}
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
--- a/sound/pci/korg1212/korg1212.c	Wed Apr 30 22:28:03 2003
+++ b/sound/pci/korg1212/korg1212.c	Wed Apr 30 22:28:03 2003
@@ -1133,18 +1133,19 @@
 	snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_COMPLETE);
 }
 
-static void snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
         u32 doorbellValue;
-        korg1212_t *korg1212 = snd_magic_cast(korg1212_t, dev_id, return);
+        korg1212_t *korg1212 = snd_magic_cast(korg1212_t, dev_id,
+						return IRQ_NONE);
 
 	if(irq != korg1212->irq)
-		return;
+		return IRQ_NONE;
 
         doorbellValue = readl(korg1212->inDoorbellPtr);
 
         if (!doorbellValue)
-		return;
+		return IRQ_NONE;
 
 	spin_lock(&korg1212->lock);
 
@@ -1218,6 +1219,8 @@
 	korg1212->inIRQ--;
 
 	spin_unlock(&korg1212->lock);
+
+	return IRQ_HANDLED;
 }
 
 static int snd_korg1212_downloadDSPCode(korg1212_t *korg1212)
diff -Nru a/sound/pci/maestro3.c b/sound/pci/maestro3.c
--- a/sound/pci/maestro3.c	Wed Apr 30 22:28:10 2003
+++ b/sound/pci/maestro3.c	Wed Apr 30 22:28:10 2003
@@ -1549,7 +1549,7 @@
 	}
 }
 
-static void 
+static irqreturn_t
 snd_m3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	m3_t *chip = snd_magic_cast(m3_t, dev_id, );
@@ -1559,13 +1559,13 @@
 	status = inb(chip->iobase + 0x1A);
 
 	if (status == 0xff)
-		return;
+		return IRQ_NONE;
    
 	/* presumably acking the ints? */
 	outw(status, chip->iobase + 0x1A);
 
 	/*if (in_suspend)
-		return;*/
+		return IRQ_NONE;*/
 
 	/*
 	 * ack an assp int if its running
@@ -1592,6 +1592,8 @@
 	/* XXX is this needed? */
 	if (status & 0x40) 
 		outb(0x40, chip->iobase+0x1A);
+
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
--- a/sound/pci/nm256/nm256.c	Wed Apr 30 22:28:16 2003
+++ b/sound/pci/nm256/nm256.c	Wed Apr 30 22:28:16 2003
@@ -238,7 +238,7 @@
 	int mixer_status_mask;		/* bit mask to test the mixer status */
 
 	int irq;
-	void (*interrupt)(int, void *, struct pt_regs *);
+	irqreturn_t (*interrupt)(int, void *, struct pt_regs *);
 	int badintrcount;		/* counter to check bogus interrupts */
 
 	nm256_stream_t streams[2];
@@ -972,10 +972,10 @@
  * I suppose...yucky bleah.)
  */
 
-static void
+static irqreturn_t
 snd_nm256_interrupt(int irq, void *dev_id, struct pt_regs *dummy)
 {
-	nm256_t *chip = snd_magic_cast(nm256_t, dev_id, return);
+	nm256_t *chip = snd_magic_cast(nm256_t, dev_id, return IRQ_NONE);
 	u16 status;
 	u8 cbyte;
 
@@ -984,7 +984,7 @@
 	/* Not ours. */
 	if (status == 0) {
 		snd_nm256_intr_check(chip);
-		return;
+		return IRQ_NONE;
 	}
 
 	chip->badintrcount = 0;
@@ -1030,6 +1030,7 @@
 	}
 
 	spin_unlock(&chip->reg_lock);
+	return IRQ_HANDLED;
 }
 
 /*
@@ -1038,7 +1039,7 @@
  * routine.
  */
 
-static void
+static irqreturn_t
 snd_nm256_interrupt_zx(int irq, void *dev_id, struct pt_regs *dummy)
 {
 	nm256_t *chip = snd_magic_cast(nm256_t, dev_id, return);
@@ -1050,7 +1051,7 @@
 	/* Not ours. */
 	if (status == 0) {
 		snd_nm256_intr_check(chip);
-		return;
+		return IRQ_NONE;
 	}
 
 	chip->badintrcount = 0;
@@ -1095,6 +1096,7 @@
 	}
 
 	spin_unlock(&chip->reg_lock);
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/sound/pci/rme32.c b/sound/pci/rme32.c
--- a/sound/pci/rme32.c	Wed Apr 30 22:28:19 2003
+++ b/sound/pci/rme32.c	Wed Apr 30 22:28:19 2003
@@ -833,14 +833,14 @@
 	writel(rme32->wcreg, rme32->iobase + RME32_IO_CONTROL_REGISTER);
 }
 
-static void
+static irqreturn_t
 snd_rme32_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	rme32_t *rme32 = (rme32_t *) dev_id;
 
 	rme32->rcreg = readl(rme32->iobase + RME32_IO_CONTROL_REGISTER);
 	if (!(rme32->rcreg & RME32_RCR_IRQ)) {
-		return;
+		return IRQ_NONE;
 	} else {
 		if (rme32->capture_substream) {
 			snd_pcm_period_elapsed(rme32->capture_substream);
@@ -850,6 +850,7 @@
 		}
 		writel(0, rme32->iobase + RME32_IO_CONFIRM_ACTION_IRQ);
 	}
+	return IRQ_HANDLED;
 }
 
 static unsigned int period_bytes[] = { RME32_BLOCK_SIZE };
diff -Nru a/sound/pci/rme96.c b/sound/pci/rme96.c
--- a/sound/pci/rme96.c	Wed Apr 30 22:28:07 2003
+++ b/sound/pci/rme96.c	Wed Apr 30 22:28:07 2003
@@ -1153,7 +1153,7 @@
 	writel(rme96->wcreg, rme96->iobase + RME96_IO_CONTROL_REGISTER);
 }
 
-static void
+static irqreturn_t
 snd_rme96_interrupt(int irq,
 		    void *dev_id,
 		    struct pt_regs *regs)
@@ -1165,7 +1165,7 @@
 	if (!((rme96->rcreg & RME96_RCR_IRQ) ||
 	      (rme96->rcreg & RME96_RCR_IRQ_2)))
 	{
-		return;
+		return IRQ_NONE;
 	}
 	
 	if (rme96->rcreg & RME96_RCR_IRQ) {
@@ -1178,6 +1178,7 @@
 		snd_pcm_period_elapsed(rme96->capture_substream);		
 		writel(0, rme96->iobase + RME96_IO_CONFIRM_REC_IRQ);
 	}
+	return IRQ_HANDLED;
 }
 
 static unsigned int period_bytes[] = { RME96_SMALL_BLOCK_SIZE, RME96_LARGE_BLOCK_SIZE };
diff -Nru a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
--- a/sound/pci/rme9652/hdsp.c	Wed Apr 30 22:28:07 2003
+++ b/sound/pci/rme9652/hdsp.c	Wed Apr 30 22:28:07 2003
@@ -3076,7 +3076,7 @@
 	}
 } 
 
-void snd_hdsp_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	hdsp_t *hdsp = (hdsp_t *) dev_id;
 	unsigned int status;
@@ -3094,7 +3094,7 @@
 	midi1 = status & HDSP_midi1IRQPending;
 
 	if (!audio && !midi0 && !midi1) {
-		return;
+		return IRQ_NONE;
 	}
 
 	hdsp_write(hdsp, HDSP_interruptConfirmation, 0);
@@ -3128,6 +3128,7 @@
 	}
 	if (schedule)
 	    tasklet_hi_schedule(&hdsp->midi_tasklet);
+	return IRQ_HANDLED;
 }
 
 static snd_pcm_uframes_t snd_hdsp_hw_pointer(snd_pcm_substream_t *substream)
diff -Nru a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
--- a/sound/pci/rme9652/rme9652.c	Wed Apr 30 22:28:08 2003
+++ b/sound/pci/rme9652/rme9652.c	Wed Apr 30 22:28:08 2003
@@ -1947,12 +1947,12 @@
 	rme9652_set_rate(rme9652, 48000);
 }
 
-void snd_rme9652_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_rme9652_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	rme9652_t *rme9652 = (rme9652_t *) dev_id;
 
 	if (!(rme9652_read(rme9652, RME9652_status_register) & RME9652_IRQ)) {
-		return;
+		return IRQ_NONE;
 	}
 
 	rme9652_write(rme9652, RME9652_irq_clear, 0);
@@ -1964,6 +1964,7 @@
 	if (rme9652->playback_substream) {
 		snd_pcm_period_elapsed(rme9652->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream);
 	}
+	return IRQ_HANDLED;
 }
 
 static snd_pcm_uframes_t snd_rme9652_hw_pointer(snd_pcm_substream_t *substream)
diff -Nru a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c
--- a/sound/pci/sonicvibes.c	Wed Apr 30 22:28:13 2003
+++ b/sound/pci/sonicvibes.c	Wed Apr 30 22:28:13 2003
@@ -596,18 +596,19 @@
 	return result;
 }
 
-static void snd_sonicvibes_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_sonicvibes_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	sonicvibes_t *sonic = snd_magic_cast(sonicvibes_t, dev_id, return);
+	sonicvibes_t *sonic = snd_magic_cast(sonicvibes_t, dev_id,
+						return IRQ_NONE);
 	unsigned char status;
 
 	status = inb(SV_REG(sonic, STATUS));
 	if (!(status & (SV_DMAA_IRQ | SV_DMAC_IRQ | SV_MIDI_IRQ)))
-		return;
+		return IRQ_NONE;
 	if (status == 0xff) {	/* failure */
 		outb(sonic->irqmask = ~0, SV_REG(sonic, IRQMASK));
 		snd_printk("IRQ failure - interrupts disabled!!\n");
-		return;
+		return IRQ_HANDLED;
 	}
 	if (sonic->pcm) {
 		if (status & SV_DMAA_IRQ)
@@ -654,6 +655,8 @@
 		snd_ctl_notify(sonic->card, SNDRV_CTL_EVENT_MASK_VALUE, &sonic->master_mute->id);
 		snd_ctl_notify(sonic->card, SNDRV_CTL_EVENT_MASK_VALUE, &sonic->master_volume->id);
 	}
+
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
--- a/sound/pci/trident/trident_main.c	Wed Apr 30 22:28:11 2003
+++ b/sound/pci/trident/trident_main.c	Wed Apr 30 22:28:11 2003
@@ -48,7 +48,7 @@
 
 static int snd_trident_pcm_mixer_build(trident_t *trident, snd_trident_voice_t * voice, snd_pcm_substream_t *substream);
 static int snd_trident_pcm_mixer_free(trident_t *trident, snd_trident_voice_t * voice, snd_pcm_substream_t *substream);
-static void snd_trident_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t snd_trident_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 #ifdef CONFIG_PM
 static int snd_trident_set_power_state(snd_card_t *card, unsigned int power_state);
 #endif
@@ -3683,20 +3683,20 @@
                 the method try & fail so it is possible that it won't
                 work on all computers. [jaroslav]
 
-   Returns:     None.
+   Returns:     Whether IRQ was handled or not.
   
   ---------------------------------------------------------------------------*/
 
-static void snd_trident_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_trident_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	trident_t *trident = snd_magic_cast(trident_t, dev_id, return);
+	trident_t *trident = snd_magic_cast(trident_t, dev_id, return IRQ_NONE);
 	unsigned int audio_int, chn_int, stimer, channel, mask, tmp;
 	int delta;
 	snd_trident_voice_t *voice;
 
 	audio_int = inl(TRID_REG(trident, T4D_MISCINT));
 	if ((audio_int & (ADDRESS_IRQ|MPU401_IRQ)) == 0)
-		return;
+		return IRQ_NONE;
 	if (audio_int & ADDRESS_IRQ) {
 		// get interrupt status for all channels
 		spin_lock(&trident->reg_lock);
@@ -3781,6 +3781,8 @@
 		}
 	}
 	// outl((ST_TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW), TRID_REG(trident, T4D_MISCINT));
+
+	return IRQ_HANDLED;
 }
 
 /*---------------------------------------------------------------------------
diff -Nru a/sound/pci/via82xx.c b/sound/pci/via82xx.c
--- a/sound/pci/via82xx.c	Wed Apr 30 22:28:15 2003
+++ b/sound/pci/via82xx.c	Wed Apr 30 22:28:15 2003
@@ -574,9 +574,9 @@
  *  Interrupt handler
  */
 
-static void snd_via82xx_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_via82xx_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	via82xx_t *chip = snd_magic_cast(via82xx_t, dev_id, return);
+	via82xx_t *chip = snd_magic_cast(via82xx_t, dev_id, return IRQ_NONE);
 	unsigned int status;
 	unsigned int i;
 
@@ -591,8 +591,8 @@
 		spin_unlock(&chip->reg_lock);
 		if (chip->rmidi)
 			/* check mpu401 interrupt */
-			snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data, regs);
-		return;
+			return snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data, regs);
+		return IRQ_NONE;
 	}
 // _skip_sgd:
 
@@ -611,6 +611,7 @@
 		outb(c_status, VIADEV_REG(viadev, OFFSET_STATUS)); /* ack */
 	}
 	spin_unlock(&chip->reg_lock);
+	return IRQ_HANDLED;
 }
 
 /*
diff -Nru a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
--- a/sound/pci/ymfpci/ymfpci_main.c	Wed Apr 30 22:28:16 2003
+++ b/sound/pci/ymfpci/ymfpci_main.c	Wed Apr 30 22:28:16 2003
@@ -741,9 +741,9 @@
 	}
 }
 
-static void snd_ymfpci_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	ymfpci_t *chip = snd_magic_cast(ymfpci_t, dev_id, return);
+	ymfpci_t *chip = snd_magic_cast(ymfpci_t, dev_id, return IRQ_NONE);
 	u32 status, nvoice, mode;
 	ymfpci_voice_t *voice;
 
@@ -787,6 +787,8 @@
 
 	if (chip->rawmidi)
 		snd_mpu401_uart_interrupt(irq, chip->rawmidi->private_data, regs);
+
+	return IRQ_HANDLED;
 }
 
 static snd_pcm_hardware_t snd_ymfpci_playback =
diff -Nru a/sound/ppc/pmac.c b/sound/ppc/pmac.c
--- a/sound/ppc/pmac.c	Wed Apr 30 22:28:20 2003
+++ b/sound/ppc/pmac.c	Wed Apr 30 22:28:20 2003
@@ -693,23 +693,25 @@
 /*
  * interrupt handlers
  */
-static void
+static irqreturn_t
 snd_pmac_tx_intr(int irq, void *devid, struct pt_regs *regs)
 {
 	pmac_t *chip = snd_magic_cast(pmac_t, devid, return);
 	snd_pmac_pcm_update(chip, &chip->playback);
+	return IRQ_HANDLED;
 }
 
 
-static void
+static irqreturn_t
 snd_pmac_rx_intr(int irq, void *devid, struct pt_regs *regs)
 {
 	pmac_t *chip = snd_magic_cast(pmac_t, devid, return);
 	snd_pmac_pcm_update(chip, &chip->capture);
+	return IRQ_HANDLED;
 }
 
 
-static void
+static irqreturn_t
 snd_pmac_ctrl_intr(int irq, void *devid, struct pt_regs *regs)
 {
 	pmac_t *chip = snd_magic_cast(pmac_t, devid, return);
@@ -728,6 +730,7 @@
 	}
 	/* Writing 1s to the CNTLERR and PORTCHG bits clears them... */
 	out_le32(&chip->awacs->control, ctrl);
+	return IRQ_HANDLED;
 }
 
 
diff -Nru a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c
--- a/sound/ppc/tumbler.c	Wed Apr 30 22:28:03 2003
+++ b/sound/ppc/tumbler.c	Wed Apr 30 22:28:03 2003
@@ -785,11 +785,14 @@
 
 
 /* interrupt - headphone plug changed */
-static void headphone_intr(int irq, void *devid, struct pt_regs *regs)
+static irqreturn_t headphone_intr(int irq, void *devid, struct pt_regs *regs)
 {
 	pmac_t *chip = snd_magic_cast(pmac_t, devid, return);
-	if (chip->update_automute && chip->initialized)
+	if (chip->update_automute && chip->initialized) {
 		chip->update_automute(chip, 1);
+		return IRQ_HANDLED;
+	}
+	return IRQ_NONE;
 }
 
 /* look for audio-gpio device */
diff -Nru a/sound/sound_core.c b/sound/sound_core.c
--- a/sound/sound_core.c	Wed Apr 30 22:28:18 2003
+++ b/sound/sound_core.c	Wed Apr 30 22:28:18 2003
@@ -54,7 +54,7 @@
 	int unit_minor;
 	struct file_operations *unit_fops;
 	struct sound_unit *next;
-	devfs_handle_t de;
+	char name[32];
 };
 
 #ifdef CONFIG_SOUND_MSNDCLAS
@@ -151,30 +151,29 @@
 
 static int sound_insert_unit(struct sound_unit **list, struct file_operations *fops, int index, int low, int top, const char *name, umode_t mode)
 {
+	struct sound_unit *s = kmalloc(sizeof(*s), GFP_KERNEL);
 	int r;
-	struct sound_unit *s=(struct sound_unit *)kmalloc(sizeof(struct sound_unit), GFP_KERNEL);
-	char name_buf[32];
 
-	if(s==NULL)
+	if (!s)
 		return -ENOMEM;
 		
 	spin_lock(&sound_loader_lock);
-	r=__sound_insert_unit(s,list,fops,index,low,top);
+	r = __sound_insert_unit(s, list, fops, index, low, top);
 	spin_unlock(&sound_loader_lock);
 	
-	if(r<0)
-	{
-		kfree(s);
-		return r;
-	}
-	
-	if (r < SOUND_STEP)
-		sprintf (name_buf, "sound/%s", name);
+	if (r < 0)
+		goto fail;
+	else if (r < SOUND_STEP)
+		sprintf(s->name, "sound/%s", name);
 	else
-		sprintf (name_buf, "sound/%s%d", name, r / SOUND_STEP);
-	s->de = devfs_register (NULL, name_buf,
-				DEVFS_FL_NONE, SOUND_MAJOR, s->unit_minor,
-				S_IFCHR | mode, fops, NULL);
+		sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP);
+
+	devfs_register(NULL, s->name, 0, SOUND_MAJOR, s->unit_minor,
+			S_IFCHR | mode, fops, NULL);
+	return r;
+
+ fail:
+	kfree(s);
 	return r;
 }
 
@@ -192,7 +191,7 @@
 	p = __sound_remove_unit(list, unit);
 	spin_unlock(&sound_loader_lock);
 	if (p) {
-		devfs_unregister (p->de);
+		devfs_remove(p->name);
 		kfree(p);
 	}
 }
diff -Nru a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c
--- a/sound/sparc/amd7930.c	Wed Apr 30 22:28:05 2003
+++ b/sound/sparc/amd7930.c	Wed Apr 30 22:28:05 2003
@@ -497,7 +497,7 @@
 	__amd7930_write_map(amd);
 }
 
-static void snd_amd7930_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_amd7930_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	amd7930_t *amd = dev_id;
 	unsigned int elapsed;
@@ -536,6 +536,8 @@
 		snd_pcm_period_elapsed(amd->playback_substream);
 	else
 		snd_pcm_period_elapsed(amd->capture_substream);
+
+	return IRQ_HANDLED;
 }
 
 static int snd_amd7930_trigger(amd7930_t *amd, unsigned int flag, int cmd)
diff -Nru a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c
--- a/sound/sparc/cs4231.c	Wed Apr 30 22:28:04 2003
+++ b/sound/sparc/cs4231.c	Wed Apr 30 22:28:04 2003
@@ -1228,7 +1228,7 @@
 }
 
 #ifdef SBUS_SUPPORT
-static void snd_cs4231_sbus_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_cs4231_sbus_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	cs4231_t *chip = snd_magic_cast(cs4231_t, dev_id, return);
 	u32 csr;
@@ -1240,12 +1240,14 @@
 		     APC_GENL_INT |
 		     APC_XINT_PEMP |
 		     APC_XINT_CEMP)))
-		return;
+		return IRQ_NONE;
 
 	/* ACK the APC interrupt. */
 	sbus_writel(csr, chip->port + APCCSR);
 
 	snd_cs4231_generic_interrupt(chip);
+
+	return IRQ_HANDLED;
 }
 #endif
 
